[Scummvm-cvs-logs] scummvm master -> ef22b7d449b66a7b953e0584c6ab5db9bdd948b9

sev- sev at scummvm.org
Mon May 26 14:53:26 CEST 2014


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

Summary:
d4df315e87 MADS: Initial implementation of Adlib sound driver
85e913864c MADS: Renaming and fixes for loading sample data
a47bb52d2e MADS: Add some missing channel initialisation
409f51cb99 MADS: Further sound udpate fixes
ece3e9a220 MADS: Booyah! Copy protection failure air escaping sound playing
0e46c809d1 MADS: Initial implementation of MSurface class and dependant classes
530cbb4bc3 MADS: Adding in classes for fonts, game, user interfaec, and graphics
97087e8cd1 MADS: Fix warnings identified by gcc
5c565797e5 MADS: Extra cleanup and commenting for MSurface methods
c687d3f64c MADS: Cleanup of palette code, updated old-style 4 byte RGB usage to 3 bytes
1b0c1b3f56 MADS: Fix GCC warnings
488bf66c3e MADS: Fix memory leaks in MSurface
7593ec29d0 MADS: Fix feature flags for Rex Nebular detection entry
58bb1383d0 MADS: Added skeleton files for the game and dialogs
de384bae2e MADS: Moved sound_nebular file into new nebular/ folder
4581b26b12 MADS: Implemented resource manager using ScummVM Archive interface
0838621002 MADS: Added remaining commands from the asound.001 player
7020dbea6a MADS: Fixes for the HagArchive reading resources
40b3ab62ca MADS: Fixes for reading in HOGANUS entries
9f1416c6a3 MADS: Implemented constructor for copy protection dialog, and support methods
54c4515232 MADS: Beginnings of dialog class hierarchy
82514b4a28 MADS: Beginnings of cursor initialization
02a1d0eaa3 MADS: Further cursor/event initialisation
3df1237187 MADS: Removed M4-specific code. Keeping engine MADS-specific for now
6c354bccf2 MADS: Implemented more logic for dialog display
6b774d2284 MADS: Copy protection dialog is starting to be displayed
1d80edb2dd MADS: Fixes for the display of dialogs
8c9420a834 MADS: Added game initialisation code
8ee283d921 MADS: Implemented sound player logic and outer game loop
37b788b7dd MADS: Added skeleton framework for game scene classes
4c867aa62f MADS: Shift some fields and methods to Dialogs and Game classes
cc16e42f20 MADS: Beginnings of scene-specific data loading
c9057bd6a8 MADS: Moved scene data classes into their own code file
9eaab29afe MADS: Starting to refactor some Scene array fields as separate classes
c49d7196fc MADS: In progress implementation of loadScene
badb8d9744 MADS: More work implementing scene info loading
7880ae0b18 Merge branch 'master' into mads
7f8b2025c0 MADS: Basic scne info loading is now working
411a405400 MADS: Further fixes for SceneInfo data loading
4bd1217daf MADS: Added loading for scene nodes and hotspost
7912f81f2c MADS: Added skeleton file for animation class
e17fdb5aab MADS: Actually added new animation files
cc810add74 MADS: In progress implementing animation loader
d5b5cbbb68 MADS: Implemented rest of animation loading
4931c8257d MADS: Further animation loading and final section of scene loading code
b816b9990d MADS: Added skeleton class for actions
72163a233f MADS: Moved Player class into it's own file
a0996b7384 MADS: Implemented more of the multi-scene loop
3a842a079c MADS: Bulk of implementation of ScreenObjects::check
d8026b9ef7 MADS: Implementing Scene::doFrame
3a3a295758 MADS: Implemented sequence list, improvements for sprite assets
9e356dd945 MADS: Implemented extra message and dirty area classes
f6888eef10 MADS: Implementation of timer functionality for Scene::doFrame
1607a91047 MADS: Finished remainder of Scene::doFrame
568fc31b30 MADS: Beginnings of code support for Scene::drawElements
23ebeec600 MADS: Further implementation of drawElements
d98f890029 MADS: Completed implementing drawElements and support methods
a0e955d8d3 MADS: More Animation class implementation
73a7140be7 MADS: Starting implementation of scene group 8
c35271f20c MADS: Moved hotspot code to a separate file
2d9bb392ae MADS: Implemented missing hotspot method
c9186f51b9 MADS: Added in Rex Nebular globals class
a77ed90618 MADS: Implementing support methods needed for scene 804 initialisation
1874ec2111 MADS: More initialisation code for scene 804, and missing engine methods
3399516c5e MADS: Implemented remainder of scene 804 setup code and support methods
8bfa5f1da2 MADS: Make resource file access case insensitive
7310080967 MADS: Fix memory leak with conversation font loading
80bba74640 MADS: Fix sprites loading for scene 804
8d3857c053 MADS: Cleanup code for accessing sprite assets
0f214e4c9d MADS: Fix for loading animation data
9c88ed1682 MADS: Fix loading user interface background
984099ae2c MADS: Implemented stubbed SpriteSlots methods
c2587af8f2 MADS: Clarified Events::_currentTimer as Scene::_frameStartTime
5536b8a933 MADS: Fixes for sprite list initialisation
8cd85f3a00 MADS: Fixes for drawing scene elements
c89193f24f MADS: Removed old RGBList code from old M4 engine
680b5a4487 MADS: In progress implementation of PaletteUsage::process
9e69e64d3f MADS: Completed PaletteUsage::process
d295a16545 MADS: Properly hook up use of PaletteUsage::process
5543d5884c MADS: Refactoring calls to PaletteUsage::process, and initial bugfixes
5d4b6b79db MADS: Fix for palette initialisation in Palette::initRange
5a1c64e732 MADS: Further fixes for PaletteUsage::process
5047c118f1 MADS: Fix for executing queued sound commands
41e86d553e MADS: Renamed game palette to palette flags
be1a53062a MADS: Convert 6 bit palettes to 8 bit values
2d99f761f0 MADS: Implemented scene 804 step
709fcc6fac MADS: Fix inter-frame wait loop
98f7ba9643 MADS: Fix definition/loading of animation frame change data
d9bb593b5f MADS: Implemented PaletteUsage::updateUsage
408f5e79df MADS: General cleanup and minor fixes
0df4d0aed1 MADS: Fixed loading of scene depth surface for Rex Nebular
e80373c823 MADS: Add guard against reading depth value outside bounds of depth surface
b2d90ddaab MADS: Fix positioning of foreground sprites
84fb90e7a5 MADS: Fix GCC warnings and memory leaks
3f0cd4771c MADS: Fixed handling of dirty rects to copy areas to the physical screen
12b79e8178 MADS: Fix for sprite slot cleanup post-frame draw
37bb5150d0 MADS: Fixes for handling sprite transparency
c9661ca88c MADS: Fix off by 1 frame references in srite drawing
d2bbdd255a MADS: Implement palette shifting for loaded sprites
49ca357e9e MADS: Remove redundant _encoding field from MSprite
e00a1b88ca MADS: Perform palette translation on background
10124f6806 MADS: Implemented scene 103 setup and needed support methods
b652e2eafd MADS: Merged the InterfaceSurface and UserInterface classes
ca6cf0eaf2 MADS: Fix display of user interface during animation
c4ed42e6d5 MADS: Implementing UserInterface loading
630679a5c8 MADS: Completed UserInterface::loadElements
2fb9edc4ee MADS: Added some more ImageInterEntries methods
dfcef632ea MADS: Hooked up the in-progress scene 103
5e3684b37a MADS: Simplified code for PaletteUsage::prioritize
120374b7d0 MADS: Simplified PaletteUsage::process list sorting
1787049087 MADS: Add loading of game inventory list and quotes
136b64db83 MADS: Move setAAName() to Scene1xx
9ffaf672ff MADS: Move setPlayerSpritesPrefix() to Scene1xx
ecbe2c87fd MADS: Implement Scene2xx functions
834cf846f1 MADS: Implement Scene201::setup, remove some function definition, add some Noun enum values
f3415b762e MADS: Implemented lots of Player methods
74da0c2ef7 MADS: Fix for loading player sprites during scene startup
d599c7c404 MADS: Fix to display player
4dd057edd9 MADS: First real try - Implement Scene201::enter()
39a36064ac MADS: In progress text draw methods for user interface
e24a4b7b16 MADS: Fix for Scene2xx::setPlayerSpritesPrefix
acba8f9254 MADS: Implementing user interface text display methods
b831323c85 MADS: Added caching for font instances
e6b73f4938 MADS: Actions text in the UI now displaying correctly
d57d4b876e MADS: Implement some more logic used in scene 201
0c8a3a47e2 MADS: Transformed ImageInterEntries to be User Interface UISlots
d494db888e MADS: Beginnings of code for UI inventory item animation
a82a0f2618 MADS: Complete scene 201
26c90afdef MADS: Add scene 201 in createScene()
306ea295ee MADS: Add isInInventory()
4875c83f10 MADS: Implemented DirtyArea::setUISlot
5b4b7a5ca9 MADS: Finished UISlots::draw method
53eac0d7c0 MADS: Fixes for scene background loading
7b808b4464 MADS: Added inventory add/remove methods
829a099ad2 MADS: Implement Scene202::actions
b04f7c1693 MADS: set public 2 inventory functions, fix signed/unsigned comparison
cfe2257d00 MADS: Use removeFromInventory and addToInventory in Scene 202
c43f834792 MADS: More work on scene 202
66643b3ad6 MADS: Some more work on Scene 202
db017b746d MADS: Moved ScreenObjects into the Game class
4ab73a89ab MADS: Preliminary code to show game cursor
8d252f4f0e MADS: Implemented methods for checking action at mouse position and clicking
436949eba2 MADS: Implemented more action logic for highlighting hotspots
8df3da1556 MADS: Added new file for static resources
79f51c4ebd MADS: Minor initial sprite slots loading fixes, missing code from SequenceList::loadSprites
2b141aaba6 MADS: Fixes for screen objects loading and checking
de09300fdd MADS: Fix initialisation of scene 103
2090987b81 MADS: Fixes for handling horizontally flipped frames
202d4ad4f1 MADS: Implemented more of scene 103 code
07b9a54e27 MADS: Implement Scene202::Step
4fec23ad1c MADS: Refactor Scene202::step()
7cdaa9648c MADS: Implemented ScreenObjects::checkScroller
bbabe2b06b MADS: Fix positioning of kernel messages
adddf02e70 MADS: Implemente Scene::changeDepthSurface()
74b48ba813 MADS: Fixes for displaying kernel messages
265fbce3dd MADS: Implement getTimeout()
ef152fa2ba MADS: Added _savedLookFlag to MADSAction
db4e74f4dd MADS: Add _v8425C, set _globals._v7 as uint32
eb82e63398 MADS: make _msgOffset a uint32
c42e831817 MADS: Introduce another getRandomNumber function with 2 parameters
2ac614d898 MADS: Add some variables in / move a variable to _globals
83a8ec1471 MADS: Add a stub for Dialog::showPicture()
a7c4fc7e23 MADS: In progress implementing ScreenObjects::elementHighlighted
c64a024aa0 MADS: Completed elementHighlighted method
06766e930b MADS: Fix main switch statement in elementHighlighted
0b351f79d8 MADS: Further fixes for hotspot highlighting
8dd9dab76c MADS: Implement Sequence::setScale and GameNebular::sub71312.
6fed5933a8 MADS: Implement and get rid of two warnings
0d15807501 MADS: Fixes for animating inventory item
ded2de015a MADS: Finished scene 103 action logic
1a54ae3de8 MADS: Fix incorrect constant usage in scene 103 logic
9ef27c4ea0 MADS: Moved sub71312 method to be SequenceList::setMsgLayout
a223189599 MADS: Added extra debugger commands
a3952509a9 MADS: In progress work on action starting
7f4dbf7d48 MADS: Implemented more action handling methods
c57acfb154 MADS: Implement scene 203
ce9a15f010 MADS: Fix the setting/clearing of _mouseReleased flag
0dfa60ae00 MADS: Refactored out and fixed cursor changes for hotspots
0b1c15e6dc MADS: Fix setting category/desc Id from highlighted screen elements
48e785c329 MADS: Fix a couple of warnings in the hotspot code
aef340c25a MADS: Implement Scene205::setup and Scene205::enter
c177056653 MADS: Add detection for another Rex
d958f50924 MADS: Fix incorrect palette for player sprites
3c504f4d02 MADS: Cleanup of user interface selection code
2879b895bc MADS: Fixes for UI item selection, add added an enum for Font::setColorMode
9028484d4b MADS: Start work on Scene 207
c09bfdab2f MADS: Finish Scene 207
633da299f6 MADS: Add scene 208
e9977e81d0 MADS: Fixes and cleanup for palette loading
7b15d2e379 MADS: Moved palette translation define into source file
407021d245 MADS: Added a Facing enum for the player directions
04cbbb5f0a MADS: Added enums for copy protection result and globals
46021c487b MADS: Use globalId enum, add a skeletton for scene 209
56f7b51754 MADS: Add an enum for kRandomNumber
f9e2c1c71f MADS: Cleaned up game initialisation code to use more constants
2eaafe1579 MADS: Review scene 201
253023b9bb MADS: Add missing case for sprite assets palette loading
eeb4b940b7 MADS: Fixes for highlighting game actions
fc03e5a4fa MADS: Fix for selecting actions from the list
0a4c4c8eda MADS: Walking is now sort of working
0e0792b37f MADS: Some polishing work on Scene 202
103e87b404 Merge branch 'mads' of github.com:/dreammaster/scummvm into mads
377cbbe77d MADS: Cleanup of game and player fields used during initialization
6c85572d76 MADS: Initial cleanup of action/player handling
b9daf53bcd MADS: Cleanup of direction setup, fix sprite mirroring for walking
5df6ff9329 MADS: suppress optional parameters of isAction, rework and renaming in scene 202
5abec8506b MADS: Some work on scene 205
49278129f6 MADS: Cleanup of Player::updateFrame
05459ac27f MADS: Clean up of Player::move method
fac216be33 MADS: Cleanup of Scene::checkStartWalk to become Player::newWalk
f983add480 MADS: Replace some magic values by enums
e8de00f877 MADS: Some more renaming in scene 202
d801c2ffdd MADS: Implement palette::lock() and unlock(), get rid of some magic values in scene 202 and 203, some renaming
71b1343adf MADS: Implemented NebularGame::step
addb3e2900 MADS: Minor renamings and added display of walk nodes to debugger
5f3a150225 MADS: Some renaming in scene 207
f3db90b646 MADS: Refactored pathfinder into it's own class
87c97a1bcb MADS: Implement two stubs in scene 207 (which is now complete)
03af091a16 MADS: Remove some magic values related to verbs
0f3d4c02ad MADS: Implement Scene208::updateTrap()
32b9530789 MADS: Fixes for the pathfinder
89af9dde8c MADS: Implemented message loading/decoding
fc61e79f29 MADS: Implement Scene208::subAction()
30b1bd99eb MADS: Reduce the scope of a variable in scene 208::subAction()
49310e4a8e MADS: Some more rework in scene 208
57f1c6e9d9 MADS: Implemented message parser for action dialog display
195c53a688 MADS: Added some missing code for scene change freeing
87124b4380 MADS: Fix for hotspot highlighting when mouse moves
0c1001fbf4 MADS: Minor variable renaming and remove incorrect variable set in scene loop
041773705b MADS: Fix/clean up ending of ScreenObjects::check
3f8ee8fafa MADS: Cleanup of UISlots and flag types
f0458042f2 MADS: In progress cleanup of checkActionAtMousePos
74c6bafed4 MADS: Further clean up/renaming of checkActionAtMousePos
83ac948923 MADS: Renaming to use InterWaiting enum entries
d163ee088a MADS: Renamings for saving fields in MADSAction::startAction
25b93a11ee MADS: Fix hotspot loading, and a couple of other warnings
19a814f38c MADS: Fix setting _commandError in MADSAction::startAction
7f15c6d5fd MADS: Beginnings of proper look dialog display
366e6ae38f MADS: Fix action checks in scene 103 actions code
4639d37609 MADS: Fixes for properly displaying the text of a message dialog
b778217d8e MADS: Fix for actions get repeated endlessly
ebe4d369a5 MADS: Fixes for actions triggering prematurely
2a105149fe MADS: Fix pathfinding when dest pos is exactly the same as source pos
06aeba275a MADS: Fix right mouse button handling
ecdaf23344 MADS: Fix to stop daemon actions overwriting currently active player actions
0b9c802bf0 MADS: Fix for actions getting aborted due to _commandError being set
88dcc7e0d6 MADS: Add debugger command to display quotes
c117e59009 MADS: Implement scene 209
ae6e19d7fc MADS: Some rework in scene group 1 and 8
3b27d99c39 MADS: Remove useless global variable
d3bc036a46 MADS: Fix display of dialog at end of taking turkey explosion sequence
41e527bb73 MADS: Fix incorrect parameter in turky explosion sequence
0f1b1e3b8c MADS: Remove redundant if block around sequence sub-entries loop
e37d1b7280 MADS: Cleanup of the MADSAction class
11403c5db6 MADS: Further cleanup of previously anonymous fields
ff7d2e2dbf MADS: Add missing scene codes variant handling
962d41e8ca MADS: Fix calculating player depth in the scene
a2871fb1b0 MADS: Fix display of scene inventory items
0c55beb40c MADS: In progress doObjectScene implementation
783f9a0b6e MADS: Completed doObjectScene implementation
29789847a8 MADS: More implementation for looking at inventory items
166a549cd5 MADS: Temporarily hook showPicture method to use standard show method
4e13e74f27 MADS: Fix to correctly wrap lines in text dialogs
bd11534499 MADS: Fix incorrect look description in scene 103
2457905ed4 MADS: Fixes for switching between scenes
b435c76b25 MADS: Fix loading of scene sprite set names
54bcb822fb MADS: Properly free scene-specific sprite sets when leaving scene
1c50c69ba6 MADS: Added stubbed Animation::preLoad method
66b7419f30 MADS: Remove stubbed methods that were undeed mouse handler calls
f6a6ea9741 MADS: Remove stub warning for originald debugger code not to be implemented
7e13f488ab MADS: Implement loading logic for UI background animations
f6cfd1d53b MADS: Implement missing dirty rect merged area pointer
0f476c31ef MADS: Implement scene 210, some cleanup of some other 2xx scenes, add some stubs
04cfa85d74 MADS: Use Common::Point in DynamicHotspot::setPosition()
3e2cba4cda MADS: Hook scene 210 in hardcoded logic
cd77110093 MADS: Fixes for movement issues in the grasslands
531ebab4da MADS: Added preliminary keyboard handling and keypress process stub
21a0e38f34 MADS: Resolve some old TODOs
09adb571d3 MADS: Cleanup of verb/preposition flags handling
e144e9810f MADS: Dropped old ActionMode enums in favour of ScrCategory
6c2c752d05 MADS: Fix selecting inventory vocab actions in the user interface
57bd5e0683 MADS: Some refactoring, implement Scene 211
2368ab7886 MADS: Initialize variables used by Scene 211
8df0833546 MADS: Fixes for correctly displaying inventory list in the user interface
ee7e7e6834 MADS: Implement scene 212
266c895250 MADS: Fix wear response for rebreather
90a030c352 MADS: Implement Scene 101
99f947fbc3 MADS: Avoid to specify the 2nd parameter of addSprites when it's the default value
dbbfdeec8f MADS: Added an item command to the debugger
da43f4438d MADS: Minor fix to inentory top index setting
0eb08fdcc0 MADS: Fix bounds calculation for inventory scroller
39c66afe66 MADS: Fixes for inventory scrollbar display
a30e78137e MADS: Added method stub for unhandled action method
4225304a34 MADS: Implement scene 102
d8c35b71db MADS: Fixed incorrect parameter order in scene 101 chair sit down
9ef9dd24c2 MADS: Replace warning with call to stubbed unhandledAction method
f548711b77 MADS: Fix palette transformation during SceneInfo::load
84552f07b4 MADS: Implement unhandledAction
5ef46aff11 MADS: rename a variable in unhandledAction
3ad447313b MADS: Initialize scene102 variables, move an empty function of Scene 103 to header
f8469aa20a MADS: Fix CREATE_MSVC9
ad346bbd3b MADS: Implement scene 104, start splitting the arrays storing sprite and sequence indexes
03be9bb807 MADS: Fix check on asset name suffix
59d1873302 MADS: Split the other sprite and sequence index arrays
5793daa75e MADS: Implement Scene 105
2a979e59a0 MADS: Refactoring PaletteUsage to use external data arrays
bb82a344a9 MADS: Further refactoring for PaletteUsage data arrays
8b2a7525cc MADS: Fix a bunch of GCC warnings
9b0f0b6efe MADS: Add missing handling code for palette _rgbList
d41833e8e5 MADS: Implement Palette::refreshHighColors()
41ea3e2374 MADS: Fix misspelling in if statement
387e7d800d MADS: Add missing call to new refreshHighColors method
d58d9075da MADS: Initialize a variable in scene 105
a2d03dad4c MADS: Fix for sprite animation range
0e67669001 MADS: Fix sitting down on chair in scene 101
85b7a8d019 MADS: Fix for resetting trigger mode between scenes
fc7e91691d MADS: Added noun constants for walking through doors
f4165c5f8a MADS: Field/method renaming
3833688674 MADS: Implement scene 106
7a6163584c MADS: Implement scene 107
5ee4123947 MADS: Implement scene 108
3e1bbb724d MADS: Fix a big in scene 102, implement scene 109
848c94cd0e MADS: Fix for sprite refreshes when doing player cutscenes
9643b543f0 MADS: Implement scene 110
968a8e16a4 MADS: Implement scene 110
eb1f885c42 MADS: Implement scene 111
52ba3b4083 MADS: Implement scene 112
27a2ead154 MADS: Fix several Rects in scene 101 and 109
3db3aced02 MADS: Implement scene 214
7b907be937 MADS: General cleanup and minor renamings
dea63c9fe8 MADS: Renaming for sprite cycle triggers
0b340a0343 MADS: Fix depth issues with sitting in chair in scene 101
eb26b70fc5 MADS: Fix rects in scene 202, 210, 211, implement scene 215
ec9c7166ab MADS: Remove some useless accolades, implement scene 216
48f49eeb80 MADS: Fix player/sprite setup/teardown for scene 112
9f67216b11 MADS: Fix to stop game ending when loading a cutscene scene
c2bf78848d MADS: Fix drawing background sprites
c7567a90ca MADS: Add scene3xx functions
39088c0121 MADS: Implement scene 301
301ca80915 MADS: Implement scene 302
5f44b97d08 MADS: Implement scene 303 and 304
cfd4943647 MADS: Fix for correctly loading animation sprite sets
73a5055438 MADS: Fix unloading animations with associated messages
45084a4702 MADS: Fix scene animation data being unloaded prematurely
0483ad2e0d MADS: Implement scene 307
40f2b01dfb Merge branch 'mads' of github.com:/dreammaster/scummvm into mads
8c9b65c34a MADS: Fixes for inventory scroller
15c64dd972 MADS: Implement scene 308
3813eddf02 MADS: Skip the unused SECTION0.HAG for now
cce0a4a3cf MADS: Fix some memory leaks in SpriteAsset class
058e1ae575 MADS: Implement scene 309
66f2a85721 MADS: Implement scene 310
3fa488db3a MADS: Implement scene 311
559efad195 MADS: Moved Animation::free to be Scene::freeAnimation
34d0bc72b5 MADS: Implement scene 313, come renaming in RGB4 structure, used by AnimPalData
c4669dd2f2 MADS: Fix refresh of inventory list after scrolling
58378a0965 MADS: Implemented MSurface::mergeFrom method
ad6a80cae7 MADS: Add support for sprite flipping in UI background animations
1362414e77 MADS: Implement palette animation code
a05f3fef9e MADS: Remove unused variables in scene 313
9d25832a81 MADS: Fix color of on-screen text
a31cae55a1 MADS: Added extra initialisation of Scene class fields
2ccaea811f MADS: Fix update of palette due to palette cycling
fb78efa3a7 MADS: Implement scene 316
4559444c54 MADS: Fix calculating Rails::_next
254519296e MADS: Beginnings of implementing conversation methods
f0ce06f0e9 MADS: Implemented display of conversation topics
ed4cedd816 MADS: Fixes for scene 210 conversation
034773fda7 MADS: Implement scene 318, some renaming
0e6c4abd13 MADS: Use Conversation class in Scene Group 3
ff70186855 MADS: Improve background user interface sprite animations
692af23f6f MADS: Create a Globals base class that the games will derive from
b2e2a2deee MADS: Implement scene 319
aedf859303 MADS: Fix compilation warning
3f1a49b567 MADS: Implemented Conversation::read method
0e9e6cda40 MADS: Beginnings of savegame synchronisation
ee1a33946f MADS: Implement scene 320
c1a90cdda1 MADS: Further synchronization implementation
1495f04bbc MADS: Fix scenes previously using globals to properly use locals
0f1cb2a5c1 MADS: Add a synchronize method to some of the group 1 scenes
ba34b1f882 MADS: Implement scene 321
26b7deb610 MADS: Fix bugs in scene 307
f330106be2 MADS: Hook game scene into synchronisation logic
1098246f2b MADS: Added methods for can save/load currently
f18104e756 MADS: Fixed Conversation::read method
41c6ad6971 MADS: Better fix of scene 307
6801694070 MADS: Fix compilation warning in scene 804
41d8af2d56 MADS: Implement scene 351
44fd705fdf MADS: Refactor Scene351::actions()
bae0a6590a MADS: Implemented savegame header read/writes
bb5edf5426 MADS: Implemented more save/load logic
f9d26d7b4f MADS: Add Scene 352
1e024f4260 MADS: Implement scene 353
6405d96ae4 MADS: Implement scene 354
2cff7557fe MADS: Beginnings of full screen dialogs
da1b4c8316 MADS: Implement scene 357
bf106aeb6a MADS: Implement scene 358
2e4e0f76aa MADS: Implement scene 359
6bac381576 MADS: Implement scene 360
15658397d4 MADS: Show the current scene when using "scene" without params
62f800341d MADS: Add detection entries for Dragonsphere and Phantom
4d159955a1 MADS: Set Rex to start from scene 101, like the original
76950bf0ac MADS: Add skeleton classes for Phantom and Dragonsphere
4eba5032d8 MADS: Add initial support for V2 backgrounds and hotspots
16bbc100dd MADS: Handle the missing sections in Phantom and Dragonsphere
9c30f3e073 MADS: Hook up the new skeleton scene logic for Phantom and Dragonsphere
87ad5a8397 MADS: Add a HACK to reuse the Nebular dialog class for now for V2 games
027a2f3710 MADS: Disable the hotspot description code for V2 games
29234dc34d MADS: Remove the unused GType_Riddle game ID (it's an M4 game)
6c9075eb25 MADS: Implement the audio player
83a1ce6e29 MADS: Implement scene 366
1e3061d3bb MADS: Bugfixes for Nebular scene 102
5bb66bdd5b MADS: Implement case 361
464627f043 MADS: Fix a couple of warnings
ff7f30af99 MADS: Implement scene 387
396905d905 MADS: Implement scene 388
5be9157dce MADS: Implement scene 389
04b809a7a2 MADS: Implement scene 390
aac3206ec8 MADS: Implement scene 391
be75349346 MADS: Refactor a bit scene 389, implement scene 399
487a9d4069 MADS: Add scene4xx common functions
ad93617aa7 MADS: Add stubs for all of the missing Rex Nebular scenes
82933592ff MADS: Fix original engine bug with highlighted hotspots between scenes
5c56c57b96 MADS: Fix class hierarchy for scene group 3
d2e93c2f0e MADS: Hook up scene 321 to scene factory
4f435d5e1c MADS: Removed redundant method definitions from scene classes
cd74c7eac5 MADS: Further workarounds for player data being accessed during cutscenes
60e78c9f1d MADS: Implement scene 401
a770419abc MADS: Add an isCursorVisible() method
dccc4510e8 MADS: Fix for highlighting and using dynamic hotspots
16d46fda7c MADS: Fix for on-screen text no longer being removed
9d2bcbd499 MADS: Fix a crash when trying to pick up objects that can't be picked
c37c45370c MADS: Fix a bug in scene 102
521e0394f6 MADS: Check for sane object IDs when checking for inventory objects
e24292a72f MADS: Implement scene 402
b7776bdbdd MADS: Fixes for using items on other items
7a34dcf83d MADS: Further fix for using items on objects
0da6934b70 MADS: Implement scene 405
57bf0673d7 MADS: Default game to impossible difficulty by default
88cf2c7caa MADS: Fix actions being triggered at the end of animation sequences
1ed8142599 MADS: Add scene 406
0350cc79b3 MADS: Implement scene 407
b9a1b53761 MADS: Implement scene 408
c5aa86f965 MADS: Implement scene 410
8c58a046db MADS: Fix palette corruption when playing animations
d888938d9b MADS: Add a sanity check in MADSAction::set()
92ab7e87a0 MADS: sub70C52 is setMotion
b5949010a6 MADS: Implemented more savegame synchronization
e258419a3e MADS: Add some further savegame loading logic
dbbd7feab7 MADS: Implement scene 411
a54aeaccce MADS: Misc savegame fixes and added meta query info
5e455e489f MADS: Implement scene 413
84159c59ef MADS: Savegames are now working
800ff80c52 MADS: Default to first inventory item after loading a savegame
9cd7e8b886 MADS: Maintain inventory ordering in savegames
d38e1aa500 MADS: Reorganise Nebular dialog methods
f9b52398bd MADS: Add a sanity check in DynamicHotspots::remove()
27982c850a MADS: Fix several logic bugs in scenes 102, 109 and 212
0023e99621 MADS: Fix bugs in SpriteSets::remove()
e5e5bdd7f1 MADS: Add a FIXME for scene 109
17b253a251 MADS: Add synchronize in scene 401 and 402
68671d77c2 MADS: Fix a bug in SequenceList::scan()
dfb53b180f MADS: Sprites aren't always cleared properly - add a FIXME
8a4bb1d48c MADS: Add enums for some magic numbers in Nebular scene group 2
356e0655cc MADS: Clean up the Rex object IDs a bit
d730abf16f MADS: Replace some more magic values for inventory items and actions
5f2ca95771 MADS: Replace some more article magic numbers with their enum
2e5fcc1460 MADS: Replace some magic values in scene 208 with their enums
9966afbb8f MADS: More naming for scene 208
f894b3f126 MADS: Implement scene 409, first try of Teleporter implementation
ff5b97e75a MADS: In progress greyscale fading for picking up inventory items
36a1b66c71 MADS: Fix for scene loading in teleporter scenes
bc774144aa MADS: Implement scene 213
e46e25b102 MADS: Remove optional parameters in scene213
18ffdf9fd0 MADS: Implement scene 322
5d1c0ef918 MADS: Implement scene 5xx ancestor
622f6eb727 MADS: Implement scene 502
c892d8c725 MADS: Implemented remainder of fadeToGrey
24b79dc5f1 MADS: Fix gcc warnings
8ebb16e98a MADS: Further gcc compilation fixes
e9d76d27a0 MADS: Fix immediate crashes in new fadeToGrey logic
3519208e4e MADS: Add scene 7xx
6fc91b4369 MADS: Implement scene 707
2d379e1769 MADS: Add initial files for Rex scene group 6
183dd32096 MADS: Implement scene 711
555f6a3dda MADS: Some renaming in scene8xx and scene804, implement scene 807
595f5dcb4f MADS: Implement scene6XX::setPlayerSpritesPrefix and scene6xx::sceneEntrySound
753579172f MADS: Fix code display in Teleporter room
f8380e9654 MADS: Fix teleporter booths to show booth code as 4 digits
13bd409bbf MADS: Add a sanity check for color 255
3adf1aba77 MADS: Add a sanity check to scene 413
417536d01c MADS: Document all game scenes, and allow entering unimplemented scenes
2ff16fbc49 MADS: Restore accidentally reverted code
c5878e401c MADS: Fix scene loading for V2 games
d88e165e00 MADS: Fix loading of V2 hotspots
66593ef302 MADS: Index and document all Phantom scenes
add4135d46 MADS: Index and document all Dragonsphere scenes
daf4170d74 MADS: Implement scene 501
da3d8f746c MADS: Implement scene 503
b36b6185be MADS: Implement Rex Nebular scene 710
bd136a1c87 MADS: Implement Rex Nebular scene 752
0c079f4d69 MADS: Fixes for correctly setting up grey fading palette intensities
b3cc8db370 MADS: Rename difficulty constants to match IDB, implement scene 504
8dfddac863 MADS: Implement Rex Nebular scene 702 and add some nouns
fdc3424eab MADS: Synchronize local scene variables for Rex scene group 1
025c13c240 MADS: Synchronize local scene variables for Rex scene group 2
07a022888d MADS: Implement scene 505
52a8ca23c6 MADS: Implement Scene205::Actions, some polishing
00dd6a5e2a MADS: Add recently added fields in Scene205::synchronize()
3fc8cd0a03 MADS: Fix typo in NebularGlobals::synchronize()
35a54a0570 MADS: Synchronize local scene variables for Rex scene group 3
189b629b33 MADS: Synchronize the remaining local scene variables for Rex scene group 4
e89b16a5f2 MADS: Reset the font in KernelMessages::reset()
3600205ba2 MADS: Use the font friendly name in Scene::clearMessageList()
ff3b6e4f05 MADS: Use friendly name for the deep pit in scene 208
056e9b083f MADS: Bugfix for using objects on dynamic hotspots
99ea49fe61 MADS: Add a FIXME in UserInterface::updateInventoryScroller()
7cd467dfab MADS: Bugfix for combining the poison darts with the plant stalk
4d98dafc5c MADS: Use friendly name for global 36 (monkey status)
2502bd8996 MADS: Use friendly names in globals
b7dd01fdef MADS: Remove trailing whitespace
0ab1e9d07b MADS: Replace some magic bomb status values with their friendly name
98518ef500 MADS: Bugfix for shooting down the monkey
5454965224 MADS: Implement scene 506
2cf67c9af2 MADS: Implement scene 507
214e051c30 MADS: Implement scene 508
b42bf6342c MADS: Remove superfluous empty scene methods
2ec60606d8 MADS: Implement scene 511
e2f2e31db3 MADS: Changed greyList to use original style insertion sort
88ac15d69e MADS: Greyscale fading now close to the original
5edc13bf78 MADS: Implement scene 512
be6cedef02 MADS: Implement scene 513
9b79267bd7 MADS: Implement scene 515
600a715661 MADS: Split verbs from nouns
5ae5a1aa58 MADS: Start implementing scene 701
4f4106eff4 MADS: Implement scene 511
2990034571 MADS: Implement scene 601
434f335611 MADS: Implement scene 602
3f3040063a MADS: Fix restoring palette after showing picture dialog
1655a0aa90 MADS: Implement scene 603
bbeb24aaab MADS: Implement scene 604
3b09886796 MADS: Implement scene 605
e21534ecc2 MADS: Implement scene 607
8abcbf3fb0 MADS: Refactoring of dialog classes, more implementation of PictureDialog
991096d01e MADS: Implement scene 620
5e13514d28 MADS: Fix hiding the status text when doing actions
604bca43de MADS: Implement the dialog textNoun method
a0fcbeeb4f MADS: Dialog positioning and UI shading fix for picture dialog
24243d57e6 MADS: Fix dialog colors for PictureDialog class
8e728a04e8 MADS: Implement scene 608
85c311059c MADS: Implement scene 609
59da02fa9a MADS: Hook in the section 1 sound player
c19cfb5b64 MADS: Implement scene 610
4033dc5dac MADS: Implemented sound player for scene group 2
2e221fe34f MADS: Replace some magic values of the monkey status
2c9568c921 MADS: Implement scene 611
2db45fac8c MADS: Implement Scene 612
95e144a314 MADS: Some refactoring in scene group 7
9fcebd296a MADS: Some bugfixes to the debug console
f46dc0a44e MADS: Add a dummy implementation of setMotion()
02df998be9 MADS: Bugfixes and cleanup for scene 202
1a7e586a67 MADS: Further work on scene 701
c1663ab6cc MADS: Implemented sound player for scene group 3
c05aaa029b MADS: Implemented sound player for scene group 4
690efa51f5 MADS: Implement scene 703
84b38d8b39 MADS: Fix incorrect array indexes referencing outputIndexes
d7086fc3a5 MADS: Implemented sound player for scene group 5
80bac656ab MADS: Add some nouns for the teleporter
655233bdfb MADS: Fix bug when watching the meteorologist through the binoculars
7028bc3b71 MADS: Implement sound player for scene group 6
82064df60a MADS: Bugfix for sequence triggers
41c93dc0b5 MADS: Check if a rect is sane before attempting to create it
e776a76241 MADS: Implemented sound player for scene group 7
c151132b12 MADS: Bugfixes for shooting down the monkey
f9fe18c506 MADS: Bugfixes and cleanup for scene 202
4cf895ad06 MADS: Do not attempt to remove objects that aren't in the inventory
8a30fe7d5d MADS: Add a FIXME for scene 307
514f122847 MADS: Implemented sound player for scene group 8
dbf2cfef57 MADS: Remove some optional parameters
54d8f17686 MADS: Implement scene 704
ede08b748a MADS: Spacing
a197d91df6 MADS: Add a sanity check in pollActiveChannel()
73dbec2011 MADS: Clean up sound driver creation switch block
7010bc6be4 MADS: Some more work on scene 701
3f4e4c50b9 MADS: Bugfix for scene 804
1c54f97916 MADS: Implement scene 705
3af6bbb397 MADS: Implement scene 706
d590ca39d1 MADS: Properly implemented object quality code
5d62f6bb29 MADS: Implement scene 751
622f97244d MADS: In progress framework for on-screen random messages
dc1d78e8ad MADS: Implement scene 801
73945d5532 MADS: Further work on scene 701
15dfef0796 MADS: Implement scene 802
11f784713e MADS: Completed random message generation method
3244db7ff4 MADS: Added initialisation method for random messages display
bc639c25c8 MADS: Fix for using inventory actions
e7bef9019a MADS: Implement scene 803, add an ongoingGame global flag to exit the multiple game loops
e1a06ae543 MADS: Replace _ongoingGame by the use of quitGame()
9f081b0a8b MADS: Implement scene 805
ba4122cca2 MADS: Implement scene 808
d3b136993f MADS: Implement scene 810
e59d2ace2d MADS: Some work and bugfixing in scene 701
cacd7c51ed MADS: Remove temporary DummyScene
96aaf48f44 MADS: Changed 16-bit globals over to be 32-bits
edb5db36b5 MADS: Add removePlayerSprites(), remove a TODO
7f82b0eafa MADS: Rework removePlayerSprites(), get rid of another TODO
46cedfc903 MADS: Implement two palette functions
e016e65767 MADS: Reduce the scope of a variable in Action, rename some British variable names
6d1fc8256f MADS: Some more British -> American English modifications
20c2693126 MADS: Fix scrolling check
9544db6510 MADS: Reduce the scope of a variable in ASound
83f82104d0 MADS: Reduce the scope of another variable in Animation
b384447e71 MADS: Reduce the scope of some variables in Palette
081a7ee30c MADS: Refactor a bit the calls of generateRandom()
9613db3edf MADS: Reduce the scope of a variable in Resource
373b67e5be MADS: Some refactoring in scene 402
499f09a1c0 MADS: Reduce variable scope in scene group 5, rename one variable
410ba93433 MADS: Some refactoring in scene group 3
2c5ef80218 MADS: Fix bug in scene 207
33fb64a1bd MADS: Remove some useless empty functions
42e8daf49d MADS: Replace hex values in dialogs with their decimal values
8619f85674 MADS: Bugfixes and cleanup in scene 101
87418b66a0 MADS: Replace several verbs with their friendly names
03add3cdd7 MADS: Replace more dialog IDs with their decimal values
d3c5a88bfc MADS: Fix some usages of isAction() with nouns
7f8c1e9a48 MADS: Replace more verbs with their friendly names
0d09060fa8 MADS: Replace more verbs with friendly names and fix usages of isAction
e409f4dedd MADS: Add debugger commands for the game vocab
59d7f8bfc0 MADS: Replace most of the action nouns with their friendly names
5a87fd42f0 MADS: Add more debugger commands for items
4f4be954ed MADS: Don't error out in the SoundManager in MADS v2 games
3aaf4e48c2 MADS: Add the inventory item names for Dragonsphere
facbe1b177 MADS: Add the inventory item names for Phantom
3aa9dc3947 MADS: Add synchronize in scene 501
c548b70e91 MADS: Add more friendly names for nouns
e2a6759533 MADS: Fix a bug in scene 104
5aa63bc71a MADS: Rename several nouns to verbs
cca6d19b2a MADS: Fix typo
645d0d92ad MADS: Add nouns for Phantom
5e1eaaa6f3 MADS: Add nouns for Dragonsphere
60b9876d81 MADS: Add more friendly names for nouns
1b34888b26 MADS: Fix the GMM menu for V2 games
eb7d018b4a MADS: Add a debug command to show messages
555b4dfd6e MADS: Load scene speech resources for V2 CD games
8a08a19097 Merge branch 'master' into mads
6804c08546 MADS: Fix compilation warning reported by digitall
c494781645 MADS: Add synchronize where useful in scene group 5
39068bb1ed MADS: Add synchronize where useful in scene group 6
6f66459f4a MADS: Add synchronize where useful in scene group 7
df23dff517 MADS: Change the animation _animMode to an enum'ed _bgType
6bfc9ce8f2 MADS: Completely remove synchronizeString in favour of syncString
876ef49a3a MADS: Fix loading sprite in scene 701
17012de54b MADS: Remove redundant frame entry remap block in animation loading
6a468994fa MADS: Fix synchronize in scene 752
c0b9a5a58f MADS: Remove obsolete comment
057f239ed6 MADS: Remove some redundant TODOs
4804be16c2 MADS: Add synchronize functions in scene group 8
39f5f0a093 MADS: Move some contructors from .h to .cpp in scene group 1
b9ccb8a1ec MADS: Remove useless variable in scene 103
7260ad19d5 MADS: Move the remaining contructors out of the header in scene group 1
69acf34cba MADS: Some refactoring in group scene 1
12a70d2ce1 MADS: Fix issues with inventory list scrolling when it shouldn't
e8cbe9e7de MADS: Move contructors out of the header in scene group 2
904796f3a5 MADS: Move contructors out of the header in scene group 3
542adf8ba4 MADS: Move contructors out of the header in scene group 4
77d85a63f1 MADS: Fix ending of turkey explosion sequence in scene 103
27d4573edf MADS: Move contructors out of the header in scene group 5
cdbf134927 MADS: Move contructors out of the header in scene group 6
cc65a8d015 MADS: Move contructors out of the header in scene group 7
2a73b6c08e MADS: Move contructors out of the header in scene group 8
55e6e2bdb4 MADS: Reorder some Synchronize functions for consistency across scene groups
1bcd021774 MADS: Refactored VGA_COLOR_REV, which wasn't correct
3202abaa89 MADS: Standardized fading out methods as fadeOut
b2860fc675 MADS: Implemented scene fading
722b32506e MADS: Replaced a TODO with a stubbed method
0d54216beb MADS: Fix checks for assets count when calling releasePlayerSprites
786c771bb8 MADS: Implement screen shaking
ef22702ac4 MADS: Fix for standing up from chair in scene 101
8f9a75a925 MADS: Add _sceneSurface subsurface, so sprite drawing is cropped correctly
87f7c0cda3 MADS: Generalize sequence record _msgPos as _position
690d956403 MADS: Properly implement sequence entry object movement
f744342498 MADS: Fix showing wait cursor when scene changes
4cc0add4a9 MADS: Fix for multiple selection of actions not working
ce5c2f3e28 MADS: Fix for player disappearing after throwing fish or burger
ea19581ae3 MADS: Standardised on passing depth surfaces as DepthSurface
142f2ad208 MADS: Change sprite drawing to use DepthSurface getDepth method
6f046eafde MADS: Fix for assert when a scene uses more than one animation
a01d502d20 MADS: Fix drawing of background elements
49866d442f MADS: Properly implement cursor hotspot handling
feb02eaea9 MADS: Further fix for setting cursor hotspot position
c5ced2347c MADS: Improve user interface animations
dfe6ae9d59 MADS: Fix a bug in scene 701 logic, rework some timer calls
ef22b7d449 Merge pull request #464 from dreammaster/mads


Commit: d4df315e8787f6230aa55b6d8542e7adda89cd48
    https://github.com/scummvm/scummvm/commit/d4df315e8787f6230aa55b6d8542e7adda89cd48
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-16T15:22:57-05:00

Commit Message:
MADS: Initial implementation of Adlib sound driver

Changed paths:
  A engines/mads/configure.engine
  A engines/mads/detection.cpp
  A engines/mads/detection_tables.h
  A engines/mads/mads.cpp
  A engines/mads/mads.h
  A engines/mads/module.mk
  A engines/mads/sound.cpp
  A engines/mads/sound.h
  A engines/mads/sound_nebular.cpp
  A engines/mads/sound_nebular.h



diff --git a/engines/mads/configure.engine b/engines/mads/configure.engine
new file mode 100644
index 0000000..60d833e
--- /dev/null
+++ b/engines/mads/configure.engine
@@ -0,0 +1,3 @@
+# This file is included from the main "configure" script
+# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
+add_engine mads "Rex Nebular and the Cosmic Gender Bender" no
diff --git a/engines/mads/detection.cpp b/engines/mads/detection.cpp
new file mode 100644
index 0000000..4e56655
--- /dev/null
+++ b/engines/mads/detection.cpp
@@ -0,0 +1,171 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 "mads/mads.h"
+
+#include "base/plugins.h"
+#include "common/savefile.h"
+#include "common/str-array.h"
+#include "common/memstream.h"
+#include "engines/advancedDetector.h"
+#include "common/system.h"
+#include "graphics/colormasks.h"
+#include "graphics/surface.h"
+
+#define MAX_SAVES 99
+
+namespace MADS {
+
+struct MADSGameDescription {
+	ADGameDescription desc;
+};
+
+uint32 MADSEngine::getFeatures() const {
+	return _gameDescription->desc.flags;
+}
+
+Common::Language MADSEngine::getLanguage() const {
+	return _gameDescription->desc.language;
+}
+
+Common::Platform MADSEngine::getPlatform() const {
+	return _gameDescription->desc.platform;
+}
+
+bool MADSEngine::getIsDemo() const {
+	return _gameDescription->desc.flags & ADGF_DEMO;
+}
+
+} // End of namespace MADS
+
+static const PlainGameDescriptor MADSGames[] = {
+	{"MADS", "MADS"},
+	{"nebular", "Rex Nebular and the Cosmic Gender Bender"},
+	{0, 0}
+};
+
+#include "mads/detection_tables.h"
+
+class MADSMetaEngine : public AdvancedMetaEngine {
+public:
+	MADSMetaEngine() : AdvancedMetaEngine(MADS::gameDescriptions, sizeof(MADS::MADSGameDescription), MADSGames) {
+		_maxScanDepth = 3;
+	}
+
+	virtual const char *getName() const {
+		return "MADS Engine";
+	}
+
+	virtual const char *getOriginalCopyright() const {
+		return "MADS (c)";
+	}
+
+	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;
+	virtual void removeSaveState(const char *target, int slot) const;
+	SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
+};
+
+bool MADSMetaEngine::hasFeature(MetaEngineFeature f) const {
+	return
+	    (f == kSupportsListSaves) ||
+		(f == kSupportsLoadingDuringStartup) ||
+		(f == kSupportsDeleteSave) ||
+		(f == kSavesSupportMetaInfo) ||
+		(f == kSavesSupportThumbnail);
+}
+
+bool MADS::MADSEngine::hasFeature(EngineFeature f) const {
+	return
+		(f == kSupportsRTL) ||
+		(f == kSupportsLoadingDuringRuntime) ||
+		(f == kSupportsSavingDuringRuntime);
+}
+
+bool MADSMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+	const MADS::MADSGameDescription *gd = (const MADS::MADSGameDescription *)desc;
+	if (gd) {
+		*engine = new MADS::MADSEngine(syst, gd);
+	}
+	return gd != 0;
+}
+
+SaveStateList MADSMetaEngine::listSaves(const char *target) const {
+	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+	Common::StringArray filenames;
+	Common::String saveDesc;
+	Common::String pattern = Common::String::format("%s.0??", target);
+
+	filenames = saveFileMan->listSavefiles(pattern);
+	sort(filenames.begin(), filenames.end());   // Sort to get the files in numerical order
+
+	SaveStateList saveList;
+	for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
+		const char *ext = strrchr(file->c_str(), '.');
+		int slot = ext ? atoi(ext + 1) : -1;
+
+		if (slot >= 0 && slot < MAX_SAVES) {
+			Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file);
+
+			if (in) {
+				delete in;
+			}
+		}
+	}
+
+	return saveList;
+}
+
+int MADSMetaEngine::getMaximumSaveSlot() const {
+	return MAX_SAVES;
+}
+
+void MADSMetaEngine::removeSaveState(const char *target, int slot) const {
+	Common::String filename = Common::String::format("%s.%03d", target, slot);
+	g_system->getSavefileManager()->removeSavefile(filename);
+}
+
+SaveStateDescriptor MADSMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
+	Common::String filename = Common::String::format("%s.%03d", target, slot);
+	Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(filename);
+
+	if (f) {
+		delete f;
+
+		// Create the return descriptor
+		SaveStateDescriptor desc(slot, "");
+
+		return desc;
+	}
+
+	return SaveStateDescriptor();
+}
+
+
+#if PLUGIN_ENABLED_DYNAMIC(MADS)
+REGISTER_PLUGIN_DYNAMIC(MADS, PLUGIN_TYPE_ENGINE, MADSMetaEngine);
+#else
+REGISTER_PLUGIN_STATIC(MADS, PLUGIN_TYPE_ENGINE, MADSMetaEngine);
+#endif
diff --git a/engines/mads/detection_tables.h b/engines/mads/detection_tables.h
new file mode 100644
index 0000000..7a66029
--- /dev/null
+++ b/engines/mads/detection_tables.h
@@ -0,0 +1,45 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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.
+ *
+ */
+
+namespace MADS {
+
+static const MADSGameDescription gameDescriptions[] = {
+	{
+		// Rex Nebular and the Cosmic Gender Bender DOS English
+		{
+			"nebular",
+			0,
+			{
+				{"mpslabs.001", 0, "4df5c557b52abb5b661cf4befe5ae301", 1315354},
+				AD_LISTEND
+			},
+			Common::EN_ANY,
+			Common::kPlatformDOS,
+			ADGF_NO_FLAGS,
+			GUIO1(GUIO_NONE)
+		},
+	},
+
+	{ AD_TABLE_END_MARKER }
+};
+
+} // End of namespace MADS
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
new file mode 100644
index 0000000..39ef195
--- /dev/null
+++ b/engines/mads/mads.cpp
@@ -0,0 +1,74 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 "mads/mads.h"
+#include "mads/sound.h"
+#include "common/scummsys.h"
+#include "common/config-manager.h"
+#include "common/debug-channels.h"
+#include "engines/util.h"
+#include "common/events.h"
+
+namespace MADS {
+
+MADSEngine *g_vm;
+
+MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :
+		Engine(syst), _randomSource("MADS") {
+	DebugMan.addDebugChannel(kDebugPath, "Path", "Pathfinding debug level");
+	DebugMan.addDebugChannel(kDebugScripts, "scripts", "Game scripts");
+}
+
+MADSEngine::~MADSEngine() {
+}
+
+void MADSEngine::initialise() {
+	_soundManager.setVm(this, _mixer);
+}
+
+static uint32 lastSoundFrame = 0;
+
+Common::Error MADSEngine::run() {
+	initGraphics(320, 200, false);
+	initialise();
+	_soundManager.test();
+
+	Common::Event e;
+	while (!shouldQuit()) {
+		g_system->getEventManager()->pollEvent(e);
+		g_system->delayMillis(10);
+
+		uint32 milli = g_system->getMillis();
+		if (milli > (lastSoundFrame + 50)) {
+			lastSoundFrame = milli;
+			_soundManager.poll();
+		}
+	}
+
+	return Common::kNoError;
+}
+
+int MADSEngine::getRandomNumber(int maxNumber) {
+	return _randomSource.getRandomNumber(maxNumber);
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
new file mode 100644
index 0000000..b54c46e
--- /dev/null
+++ b/engines/mads/mads.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.
+ *
+ */
+
+#ifndef MADS_MADS_H
+#define MADS_MADS_H
+
+#include "common/scummsys.h"
+#include "common/system.h"
+#include "common/error.h"
+#include "common/random.h"
+#include "common/util.h"
+#include "engines/engine.h"
+#include "graphics/surface.h"
+#include "mads/sound.h"
+
+/**
+ * This is the namespace of the MADS engine.
+ *
+ * Status of this engine: In Development
+ *
+ * Games using this engine:
+ * - Rex Nebular and the Cosmic Gender Bender
+ */
+namespace MADS {
+
+#define DEBUG_BASIC 1
+#define DEBUG_INTERMEDIATE 2
+#define DEBUG_DETAILED 3
+
+#define MAX_RESOLVE 1000
+
+enum MADSDebugChannels {
+	kDebugPath      = 1 << 0,
+	kDebugScripts	= 1 << 1
+};
+
+
+struct MADSGameDescription;
+
+
+class MADSEngine : public Engine {
+private:
+	const MADSGameDescription *_gameDescription;
+	Common::RandomSource _randomSource;
+	SoundManager _soundManager;
+
+	void initialise();
+protected:
+	// Engine APIs
+	virtual Common::Error run();
+	virtual bool hasFeature(EngineFeature f) const;
+public:
+	MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc);
+	virtual ~MADSEngine();
+
+	uint32 getFeatures() const;
+	Common::Language getLanguage() const;
+	Common::Platform getPlatform() const;
+	uint16 getVersion() const;
+	bool getIsDemo() const;
+
+	int getRandomNumber(int maxNumber);
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_MADS_H */
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
new file mode 100644
index 0000000..d8a26a2
--- /dev/null
+++ b/engines/mads/module.mk
@@ -0,0 +1,15 @@
+MODULE := engines/mads
+
+MODULE_OBJS := \
+	detection.o \
+	sound.o \
+	sound_nebular.o \
+	mads.o
+
+# This module can be built as a plugin
+ifeq ($(ENABLE_MADS), DYNAMIC_PLUGIN)
+PLUGIN := 1
+endif
+
+# Include common rules
+include $(srcdir)/rules.mk
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
new file mode 100644
index 0000000..335afb4
--- /dev/null
+++ b/engines/mads/sound.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/raw.h"
+#include "common/memstream.h"
+#include "mads/sound.h"
+
+namespace MADS {
+
+SoundManager::SoundManager() {
+	_asound = nullptr;
+}
+
+SoundManager::~SoundManager() {
+	delete _asound;
+}
+
+void SoundManager::setVm(MADSEngine *vm, Audio::Mixer *mixer) { 
+	_vm = vm; 
+	_mixer = mixer;
+}
+
+void SoundManager::test() {
+	_asound = new Nebular::ASound1(_mixer);
+	_asound->command(28);
+}
+
+void SoundManager::poll() {
+	if (_asound)
+		_asound->poll();
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/sound.h b/engines/mads/sound.h
new file mode 100644
index 0000000..20b56ec
--- /dev/null
+++ b/engines/mads/sound.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_SOUND_H
+#define MADS_SOUND_H
+
+#include "common/scummsys.h"
+#include "audio/audiostream.h"
+#include "audio/mixer.h"
+#include "mads/sound_nebular.h"
+
+namespace MADS {
+
+class MADSEngine;
+
+class SoundManager {
+private:
+	MADSEngine *_vm;
+	Audio::Mixer *_mixer;
+	Nebular::ASound *_asound;
+public:
+	SoundManager();
+	~SoundManager();
+	
+	void setVm(MADSEngine *vm, Audio::Mixer *mixer);
+	void test();
+	void poll();
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_SOUND_H */
diff --git a/engines/mads/sound_nebular.cpp b/engines/mads/sound_nebular.cpp
new file mode 100644
index 0000000..03fdc5f
--- /dev/null
+++ b/engines/mads/sound_nebular.cpp
@@ -0,0 +1,1097 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 "audio/audiostream.h"
+#include "audio/decoders/raw.h"
+#include "common/algorithm.h"
+#include "common/debug.h"
+#include "common/memstream.h"
+#include "mads/sound.h"
+#include "mads/sound_nebular.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+AdlibChannel::AdlibChannel() {
+	_activeCount = 0;
+	_field1 = 0;
+	_field2 = 0;
+	_field3 = 0;
+	_field4 = 0;
+	_field5 = 0;
+	_volume = 0;
+	_field7 = 0;
+	_field8 = 0;
+	_field9 = 0;
+	_fieldA = 0;
+	_fieldB = 0;
+	_fieldC = 0;
+	_fieldD = 0;
+	_fieldE = 0;
+	_ptr1 = nullptr;
+	_pSrc = nullptr;
+	_ptr3 = nullptr;
+	_ptr4 = nullptr;
+	_field17 = 0;
+	_field19 = 0;
+	_soundData = nullptr;
+	_field1D = 0;
+	_field1E = 0;
+	_field1F = 0;
+}
+
+void AdlibChannel::reset() {
+	_activeCount = 0;
+	_field1 = 0;
+	_field2 = 0;
+	_field3 = 0;
+}
+
+void AdlibChannel::enable(int flag) {
+	if (_activeCount) {
+		_fieldE = flag;
+		_soundData = nullptr; // TODO: Check original set it to flag??!
+	}
+}
+
+void AdlibChannel::setPtr2(byte *pData) {
+	_pSrc = pData;
+	_field2 = 0xFF;
+	_fieldA = 1;
+	_field9 = 1;
+}
+
+void AdlibChannel::load(byte *pData) {
+	_ptr1 = _pSrc = _ptr3 = pData;
+	_ptr4 = _soundData = pData;
+	_fieldA = 0xFF;
+	_activeCount = 1;
+	_fieldD = 64;
+	_field1 = 0;
+	_field1F = 0;
+	_field2 = _field3 = 0;
+	_volume = _field7 = 0;
+	_field1D = _field1E = 0;
+	_fieldE = 0;
+	_field9 = 0;
+	_fieldB = 0;
+	_field17 = 0;
+	_field19 = 0;
+}
+
+void AdlibChannel::check(byte *nullPtr) {
+	if (_activeCount && _fieldE) {
+		if (!_field1E) {
+			_pSrc = nullPtr;
+			_fieldE = 0;
+		} else {
+			_field2 = 0xFF;
+			_fieldA = 4;
+			if (!_field9)
+				_field9 = 1;
+		}
+	}
+}
+
+/*-----------------------------------------------------------------------*/
+
+SoundData::SoundData(Common::SeekableReadStream &s) {
+	_field0 = s.readByte();
+	_field1 = s.readByte();
+	_field2 = s.readByte();
+	_field3 = s.readByte();
+	_field4 = s.readByte();
+	_field5 = s.readByte();
+	_field6 = s.readByte();
+	_field7 = s.readByte();
+	_field8 = s.readByte();
+	_field9 = s.readByte();
+	_fieldA = s.readByte();
+	_fieldB = s.readByte();
+	_fieldC = s.readByte();
+	_fieldD = s.readByte();
+	_fieldE = s.readByte();
+	_field10 = s.readUint16LE();
+	_field12 = s.readUint16LE();
+	_field14 = s.readUint16LE();
+}
+
+/*-----------------------------------------------------------------------*/
+
+ASound::ASound(Audio::Mixer *mixer, const Common::String &filename, int dataOffset) {
+	// Open up the appropriate sound file
+	if (!_soundFile.open(filename))
+		error("Could not open file - %s", filename.c_str());
+
+	_dataOffset = dataOffset;
+	_mixer = mixer;
+	_opl = OPL::Config::create();
+	assert(_opl);
+	_opl->init(11025);
+
+	// Initialise fields
+	_activeChannelPtr = nullptr;
+	_soundDataPtr = nullptr;
+	_frameCounter = 0;
+	_isDisabled = false;
+	_v1 = 0;
+	_v2 = 0;
+	_activeChannelNumber = 0;
+	_freqMask1 = _freqMask2 = 0;
+	_freqBase1 = _freqBase2 = 0;
+	_channelNum1 = _channelNum2 = 0;
+	_v7 = 0;
+	_v8 = 0;
+	_v9 = 0;
+	_v10 = 0;
+	_pollResult = 0;
+	_resultFlag = 0;
+	_nullData[0] = _nullData[1] = 0;
+	Common::fill(&_ports[0], &_ports[256], 0);
+	_stateFlag = false;
+	_activeChannelReg = 0;
+	_v11 = 0;
+	_randomSeed = 1234;
+	_amDep = _vibDep = _splitPoint = true;
+
+	// Initialise the Adlib
+	adlibInit();
+
+	// Reset the adlib
+	command0();
+}
+
+ASound::~ASound() {
+	Common::List<CachedDataEntry>::iterator i;
+	for (i = _dataCache.begin(); i != _dataCache.end(); ++i)
+		delete[] (*i)._data;
+
+	delete _opl;
+}
+
+void ASound::adlibInit() {
+	// No implementation
+}
+
+int ASound::stop() { 
+	command0();
+	int result = _pollResult;
+	_pollResult = 0;
+	return result;
+}
+
+int ASound::poll() {
+	// Update any playing sounds
+	update();
+
+	// Return result
+	int result = _pollResult;
+	_pollResult = 0;
+	return result;
+}
+
+void ASound::noise() {
+	int randomVal = getRandomNumber();
+
+	if (_v1) {
+		setFrequency(_channelNum1, (randomVal ^ 0xFFFF) & _freqMask1 + _freqBase1);
+	}
+
+	if (_v2) {
+		setFrequency(_channelNum2, randomVal & _freqMask2 + _freqBase2);		
+	}
+}
+
+void ASound::write(int reg, int val) {
+	debug("reg %.2x = %.2x", reg, val);
+	_opl->write(reg, val);
+}
+
+int ASound::write2(int state, int reg, int val) {
+	// TODO: Original has a state parameter, not used when in Adlib mode?
+	_ports[reg] = val;
+	write(reg, val);
+	return state;
+}
+
+void ASound::channelOn(int reg, int volume) {
+	write2(8, reg, (_ports[reg] & 0xC0) | (volume & 0x3F));
+}
+
+void ASound::channelOff(int reg) {
+	write2(8, reg, _ports[reg] | 0x3F);
+}
+
+void ASound::resultCheck() {
+	if (_resultFlag != 1) {
+		_resultFlag = 1;
+		_pollResult = 1;
+	}
+}
+
+byte *ASound::loadData(int offset, int size) {
+	// First scan for an existing copy	
+	Common::List<CachedDataEntry>::iterator i;
+	for (i = _dataCache.begin(); i != _dataCache.end(); ++i) {
+		CachedDataEntry &e = *i;
+		if (e._offset == offset)
+			return e._data;
+	}
+
+	// No existing entry found, so load up data and store as a new entry
+	CachedDataEntry rec;
+	rec._offset = offset;
+	rec._data = new byte[size];
+	_soundFile.seek(_dataOffset + offset);
+	_soundFile.read(rec._data, size);
+	_dataCache.push_back(rec);
+
+	// Return the data
+	return rec._data;
+}
+
+void ASound::playSound(int offset, int size) {
+	// Load the specified data block
+	playSound(loadData(offset, size));
+}
+
+void ASound::playSound(byte *pData) {
+	// Scan for a high level free channel
+	for (int i = 5; i < ADLIB_CHANNEL_COUNT; ++i) {
+		if (!_channels[i]._activeCount) {
+			_channels[i].load(pData);
+			return;
+		}
+	}
+
+	// None found, do a secondary scan for an interruptable channel
+	for (int i = ADLIB_CHANNEL_COUNT - 1; i >= ADLIB_CHANNEL_MIDWAY; --i) {
+		if (_channels[i]._fieldE == 0xFF) {
+			_channels[i].load(pData);
+			return;
+		}
+	}
+}
+
+bool ASound::isSoundActive(byte *pData) {
+	for (int i = 0; i < ADLIB_CHANNEL_MIDWAY; ++i) {
+		if (_channels[i]._activeCount && _channels[i]._soundData == pData)
+			return true;
+	}
+
+	return false;
+}
+
+void ASound::setFrequency(int channel, int freq) {
+	write2(8, 0xA0 + channel, freq & 0xFF);
+	write2(8, 0xB0 + channel, (freq >> 8) | 0x20);
+}
+
+int ASound::getRandomNumber() {
+	int v = 0x9248 + (int)_randomSeed;
+	_randomSeed = ((v >> 3) | (v << 13)) & 0xFFFF;
+	return _randomSeed;
+}
+
+void ASound::update() {
+	getRandomNumber();
+	if (_isDisabled)
+		return;
+
+	++_frameCounter;
+	pollChannels();
+	checkChannels();
+
+	if (_v1 == _v2) {
+		if (_resultFlag != -1) {
+			_resultFlag = -1;
+			_pollResult = -1;
+		}
+	} else {
+		if (_v1) {
+			_freqBase1 += _v7;
+			if (!--_v1) {
+				if (!_v2 || _channelNum1 != _channelNum2) {
+					write2(8, 0xA0 + _channelNum1, 0);
+					write2(8, 0xB0 + _channelNum1, 0);
+				}
+			}
+		}
+
+		if (_v2) {
+			_freqBase2 += _v8;
+			if (!--_v2) {
+				if (!_v1 || _channelNum2 != _channelNum1) {
+					write2(8, 0xA0 + _channelNum2, 0);
+					write2(8, 0xB0 + _channelNum2, 0);
+				}
+			}
+		}
+	}
+}
+
+void ASound::pollChannels() {
+	_activeChannelNumber = 0;
+	for (int i = 0; i < ADLIB_CHANNEL_COUNT; ++i) {
+		_activeChannelPtr = &_channels[i];
+		pollActiveChannel();
+	}
+}
+
+void ASound::checkChannels() {
+	for (int i = 0; i < ADLIB_CHANNEL_COUNT; ++i)
+		_channels[i].check(_nullData);
+}
+
+void ASound::pollActiveChannel() {
+	bool flag = false;
+
+	AdlibChannel *chan = _activeChannelPtr; 
+	if (chan->_activeCount) {
+		if (chan->_field8 > 0 && --chan->_field8 == 0)
+			updateOctave();
+
+		if (--_activeChannelPtr->_activeCount <= 0) {
+			for (;;) {
+				byte *pSrc = chan->_pSrc;
+				if (!(*pSrc & 0x80) || (*pSrc <= 0xF0)) {
+					if (flag)
+						updateActiveChannel();
+
+					chan->_field4 = *pSrc++;
+					chan->_activeCount = *pSrc++;
+					chan->_pSrc += 2;
+
+					if (!chan->_field4 || !chan->_activeCount) {
+						updateOctave();
+					} else {
+						chan->_field8 = chan->_activeCount - chan->_field7;
+						updateChannelState();
+					}
+
+					break;
+				} else {
+					flag = false;
+
+					switch ((~*pSrc) & 0xF) {
+					case 0:
+						if (!chan->_field17) {
+							if (*++pSrc == 0) {
+								chan->_pSrc += 2;
+								chan->_ptr3 = chan->_pSrc;
+								chan->_field17 = 0;
+							} else {
+								chan->_field17 = *pSrc;
+								chan->_pSrc = chan->_ptr3;
+							}
+						} else if (--chan->_field17) {
+							chan->_pSrc = chan->_ptr3;
+						} else {
+							chan->_pSrc += 2;
+							chan->_ptr3 = chan->_pSrc;
+						}
+						break;
+
+					case 1:
+						if (!chan->_field19) {
+							if (*++pSrc == 0) {
+								chan->_pSrc += 2;
+								chan->_ptr4 = chan->_pSrc;
+								chan->_ptr3 = chan->_pSrc;
+								chan->_field17 = 0;
+								chan->_field19 = 0;
+							} else {
+								chan->_field19 = *pSrc;
+								chan->_pSrc = chan->_ptr4;
+								chan->_ptr3 = chan->_ptr4;
+							}
+						} else if (--chan->_field19) {
+							chan->_ptr4 = chan->_pSrc;
+							chan->_ptr3 = chan->_pSrc;
+						} else {
+							chan->_pSrc += 2;
+							chan->_ptr4 = chan->_pSrc;
+							chan->_ptr3 = chan->_pSrc;
+						}
+						break;
+
+					case 2:
+						// Loop sound data
+						chan->_field1 = 0;
+						chan->_field2 = chan->_field3 = 0;
+						chan->_volume = chan->_field7 = 0;
+						chan->_field1D = chan->_field1E = 0;
+						chan->_field8 = 0;
+						chan->_field9 = 0;
+						chan->_fieldB = 0;
+						chan->_field17 = 0;
+						chan->_field19 = 0;
+						chan->_fieldD = 0x40;
+						chan->_ptr1 = chan->_soundData;
+						chan->_pSrc = chan->_soundData;
+						chan->_ptr3 = chan->_soundData;
+						chan->_ptr4 = chan->_soundData;
+
+						chan->_pSrc += 2;
+						break;
+
+					case 3:
+						chan->_field5 = *++pSrc;
+						chan->_pSrc += 2;
+						channelProc1(chan->_field5);
+						break;
+
+					case 4:
+						chan->_field7 = *++pSrc;
+						chan->_pSrc += 2;
+						break;
+
+					case 5:
+						chan->_field1 = *++pSrc;
+						chan->_pSrc += 2;
+						break;
+
+					case 6:
+						++pSrc;
+						if (chan->_fieldE) {
+							chan->_volume = *pSrc >> 1;
+							flag = 1;
+							chan->_pSrc += 2;
+						} else {
+							chan->_pSrc += 2;
+						}
+						break;
+
+					case 7:
+						++pSrc;
+						if (!chan->_fieldE) {
+							chan->_fieldA = *pSrc;
+							chan->_field2 = *++pSrc;
+							chan->_field9 = 1;
+						}
+
+						chan->_pSrc += 3;
+						break;
+
+					case 8:
+						chan->_field1D = *++pSrc;
+						chan->_pSrc += 2;
+						break;
+
+					case 9: {
+						int v1 = *++pSrc;
+						++pSrc;
+						int v2 = (v1 - 1) & getRandomNumber();
+						int v3 = pSrc[v2];
+						int v4 = pSrc[v1];
+
+						pSrc[v4 + v1 + 1] = v3;
+						chan->_pSrc += v1 + 3;
+						break;
+					}
+
+					case 10:
+						++pSrc;
+						if (chan->_fieldE) {
+							chan->_pSrc += 2;
+						} else {
+							chan->_field1E = *pSrc >> 1;
+							flag = 1;
+							chan->_pSrc += 2;
+						}
+						break;
+
+					case 11:
+						chan->_fieldD = *++pSrc;
+						flag = 1;
+						chan->_pSrc += 2;
+						break;
+
+					case 12:
+						chan->_fieldC = *++pSrc;
+						chan->_field3 = *++pSrc;
+						chan->_fieldB = 1;
+						chan->_pSrc += 2;
+						break;
+
+					case 13:
+						++pSrc;
+						chan->_pSrc += 2;
+						break;
+
+					case 14:
+						chan->_field1F = *++pSrc;
+						chan->_pSrc += 2;
+						break;
+					
+					default:
+						break;
+					}
+				}
+			}
+		}
+
+		if (chan->_field1)
+			updateFNumber();
+
+		flag = false;
+		if (chan->_field9 || chan->_field8) {
+			if (!--chan->_field9) {
+				chan->_field9 = chan->_fieldA;
+				if (chan->_field2) {
+					chan->_field9 = CLIP(chan->_field2 + chan->_field1E, 0, 63);
+				}
+			}
+
+			if (!--chan->_fieldB) {
+				chan->_fieldB = chan->_fieldC;
+				if (chan->_field3) {
+					chan->_fieldD = chan->_field3;
+					flag = true;
+				}
+			}
+
+			if (flag)
+				updateActiveChannel();
+		}
+	}
+
+	++_activeChannelNumber;
+}
+
+void ASound::updateOctave() {
+ 	int reg = 0xB0 + _activeChannelNumber;
+	write2(8, reg, _ports[reg] & 0xDF);
+}
+
+static int _vList1[] = {
+	0x200, 0x21E, 0x23F, 0x261, 0x285, 0x2AB, 
+	0x2D4, 0x2FF, 0x32D, 0x35D, 0x390, 0x3C7
+};
+
+void ASound::updateChannelState() {
+	updateActiveChannel();
+
+	if (_channelData[_activeChannelNumber]._field0) {
+		if (_channelNum1 == _activeChannelNumber)
+			_stateFlag = 0;
+		if (_channelNum2 == _activeChannelNumber)
+			_stateFlag = 1;
+
+		if (!_stateFlag) {
+			_stateFlag = 1;
+			if (_v1)
+				write2(8, 0xB0 + _channelNum1, _ports[0xB0 + _channelNum1] & 0xDF);
+
+			_channelNum1 = _activeChannelNumber;
+			_v1 = _channelData[_channelNum1]._field0;
+			_freqMask1 = _channelData[_channelNum1]._freqMask;
+			_freqBase1 = _channelData[_channelNum1]._freqBase;
+			_v7 = _channelData[_channelNum1]._field6;
+		} else {
+			_stateFlag = 0;
+			if (_v2)
+				write2(8, 0xB0 + _channelNum2, _ports[0xB0 + _channelNum2] & 0xDF);
+
+			_channelNum2 = _activeChannelNumber;
+			_v2 = _channelData[_channelNum2]._field0;
+			_freqMask2 = _channelData[_channelNum2]._freqMask;
+			_freqBase2 = _channelData[_channelNum2]._freqBase;
+			_v8 = _channelData[_channelNum2]._field6;
+		}
+
+		resultCheck();
+	} else {
+		int reg = 0xA0 + _activeChannelNumber;
+		int v = (_activeChannelPtr->_field4 + _activeChannelPtr->_field1F) / 12;
+		int vHi = v >> 8;
+		int vLo = v & 0xFF;
+		int val = _vList1[vHi] + vHi;
+		write2(8, reg, val & 0xFF);
+
+		reg += 0x10;
+		write2(8, reg, (_ports[reg] & 0x20) | (vLo << 2) | (val >> 8));
+
+		write2(8, reg, _ports[reg] | 0x20);
+	}
+}
+
+static const int outputIndexes[] = {
+	3, 1, 4, 2, 5, 6, 9, 7, 10, 8, 11, 12, 15, 13, 16, 14, 17
+};
+static const int outputChannels[] = {
+	0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 16, 17, 18, 19, 20, 21, 0
+};
+static const int volumeList[] = {
+	0x3F, 0x3F, 0x36, 0x31, 0x2D, 0x2A, 0x28, 0x26, 0x24, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1D, 0x1C,
+	0x1B, 0x1A, 0x19, 0x19, 0x18, 0x17, 0x17, 0x16, 0x16, 0x15, 0x15, 0x14, 0x14, 0x13, 0x12, 0x12,
+	0x11, 0x11, 0x10, 0x10, 0x0F, 0x0F, 0x0E, 0x0E, 0x0D, 0x0D, 0x0C, 0x0C, 0x0B, 0x0B, 0x0A, 0x0A,
+	0x0A, 0x09, 0x09, 0x09, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x08, 0x07, 0x07, 0x07, 0x07, 0x07,
+	0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04,
+	0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+	0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01,
+	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+void ASound::updateActiveChannel() {
+	int reg = 0x40 + outputChannels[outputIndexes[_activeChannelNumber * 2]];
+	int portVal = _ports[reg] & 0xFFC0;
+	int newVolume = CLIP(_activeChannelPtr->_volume + _activeChannelPtr->_field1E, 0, 63);
+	
+	// TODO: Double-check _v5660 = 5600h
+	int val = CLIP(newVolume - volumeList[_activeChannelPtr->_fieldD], 0, 63);
+	val = (63 - val) | portVal;
+
+	int val2 = CLIP(newVolume - volumeList[-(_activeChannelPtr->_fieldD - 127)], 0, 63);
+	val2 = (63 - val2) | portVal;
+	write2(0, reg, val);
+	write2(2, reg, val2);
+}
+
+void ASound::channelProc1(int recIndex) {
+	_activeChannelReg = 0xB0 + _activeChannelNumber;
+	write2(8, _activeChannelReg, _ports[_activeChannelReg] & 0xDF);
+
+	_activeChannelReg = _activeChannelNumber;
+	_soundDataPtr = &_soundData[recIndex * 2];
+	_v11 = outputChannels[outputIndexes[_activeChannelReg * 2 - 1]];
+	channelProc2();
+
+	AdlibChannelData &cd = _channelData[_activeChannelNumber];
+	cd._field6 = _soundDataPtr->_field14;
+	cd._freqBase = _soundDataPtr->_field12;
+	cd._freqMask = _soundDataPtr->_field10;
+	cd._field0 = _soundDataPtr->_fieldE;
+
+	_soundDataPtr = &_soundData[recIndex * 2 + 1];
+	_v11 = outputChannels[outputIndexes[_activeChannelReg * 2]];
+	channelProc2();
+}
+
+void ASound::channelProc2() {
+	// Write out vib flags and split point
+	write2(8, 0x40 + _v11, 0x3F);
+	int depthRhythm = _ports[0xBD] & 0x3F | (_amDep ? 0x80 : 0) |
+		(_vibDep ? 0x40 : 0);
+	write2(8, 0xBD, depthRhythm);
+	write2(8, 8, _splitPoint ? 0x40 : 0);
+
+	int val = _soundDataPtr->_fieldA;
+	val = (val << 1) | (1 - _soundDataPtr->_fieldD);
+	write2(8, 0xC0 + _activeChannelReg, val);
+
+	val = (_soundDataPtr->_field0 << 4) | (_soundDataPtr->_field1 & 0xF);
+	write2(8, 0x60 + _v11, val);
+
+	val = (_soundDataPtr->_field2 << 4) | (_soundDataPtr->_field3 & 0xF);
+	write2(8, 0x80 + _v11, val);
+
+	val = (_soundDataPtr->_fieldB ? 0x80 : 0) | (_soundDataPtr->_fieldC ? 0x40 : 0)
+		| (_soundDataPtr->_field4 ? 0x20 : 0) | (_soundDataPtr->_field5 ? 0x10 : 0)
+		| (_soundDataPtr->_field9 & 0xF);
+	write2(8, 0x20 + _v11, val);
+
+	write2(8, 0xE0 + _v11, _soundDataPtr->_field8 & 3);
+	
+	val = -(_soundDataPtr->_field6 & 0x3F - 0x3F) | (_soundDataPtr->_field7 << 6);
+	write2(8, 0x40 + _v11, val);
+}
+
+void ASound::updateFNumber() {
+	int loReg = 0xA0 + _activeChannelNumber;
+	int hiReg = 0xB0 + _activeChannelNumber;
+	int val1 = (_ports[hiReg] & 0x1F) << 8;
+	val1 += _ports[loReg] + _activeChannelPtr->_field1;
+	write2(8, loReg, val1);
+
+	int val2 = (_ports[hiReg] & 0x20) | (val1 >> 8);
+	write2(8, hiReg, val2);
+}
+
+int ASound::command0() {
+	bool isDisabled = _isDisabled;
+	_isDisabled = true;
+
+	for (int i = 0; i < ADLIB_CHANNEL_COUNT; ++i)
+		_channels[i].reset();
+
+	_v1 = 0;
+	_v2 = 0;
+	_freqMask1 = _freqMask2 = 0;
+	_freqBase1 = _freqBase2 = 0;
+	_v7 = 0;
+	_v8 = 0;	
+
+	_isDisabled = isDisabled;
+	return 0;
+}
+
+int ASound::command1() {
+	for (int i = 0; i < ADLIB_CHANNEL_COUNT; ++i)
+		_channels[i].enable(0xFF);
+	return 0;
+}
+
+int ASound::command2() {
+	for (int i = 0; i < ADLIB_CHANNEL_MIDWAY; ++i)
+		_channels[i].setPtr2(_nullData);
+	return 0;
+}
+
+int ASound::command3() {
+	for (int i = 0; i < ADLIB_CHANNEL_MIDWAY; ++i)
+		_channels[i].enable(0xFF);
+	return 0;
+}
+
+int ASound::command4() {
+	for (int i = ADLIB_CHANNEL_MIDWAY; i < ADLIB_CHANNEL_COUNT; ++i)
+		_channels[i].setPtr2(_nullData);
+	return 0;
+}
+
+int ASound::command5() {
+	for (int i = 5; i < ADLIB_CHANNEL_COUNT; ++i)
+		_channels[i].enable(0xFF);
+	return 0;
+}
+
+int ASound::command6() {
+	_v9 = _v1;
+	_v1 = 0;
+	_v10 = _v2;
+	_v2 = 0;
+
+	channelOff(0x43);
+	channelOff(0x44);
+	channelOff(0x45);
+	channelOff(0x4B);
+	channelOff(0x4C);
+	channelOff(0x4D);
+	channelOff(0x53);
+	channelOff(0x54);
+	channelOff(0x55);
+
+	return 0;
+}
+
+int ASound::command7() {
+	channelOn(0x43, _channels[0]._volume);
+	channelOn(0x44, _channels[1]._volume);
+	channelOn(0x45, _channels[2]._volume);
+	channelOn(0x4B, _channels[3]._volume);
+	channelOn(0x4C, _channels[4]._volume);
+	channelOn(0x4D, _channels[5]._volume);
+
+	_v1 = _v9;
+	_v2 = _v10;
+
+	if (_v9 != _v10)
+		resultCheck();
+
+	_isDisabled = 0;
+	return _v10;
+}
+
+int ASound::command8() {
+	int result = 0;
+	for (int i = 0; i < ADLIB_CHANNEL_COUNT; ++i)
+		result |= _channels[i]._activeCount;
+
+	return result;
+}
+
+/*-----------------------------------------------------------------------*/
+
+const ASound1::CommandPtr ASound1::_commandList[42] = {
+	&ASound1::command0, &ASound1::command1, &ASound1::command2, &ASound1::command3,
+	&ASound1::command4, &ASound1::command5, &ASound1::command6, &ASound1::command7, 
+	&ASound1::command8, &ASound1::command9, &ASound1::command10, &ASound1::command11,
+	&ASound1::command12, &ASound1::command13, &ASound1::command14, &ASound1::command15,
+	&ASound1::command16, &ASound1::command17, &ASound1::command18, &ASound1::command19, 
+	&ASound1::command20, &ASound1::command21, &ASound1::command22, &ASound1::command23, 
+	&ASound1::command24, &ASound1::command25, &ASound1::command26, &ASound1::command27,
+	&ASound1::command28, &ASound1::command29, &ASound1::command30, &ASound1::command31, 
+	&ASound1::command32, &ASound1::command33, &ASound1::command34, &ASound1::command35,
+	&ASound1::command36, &ASound1::command37, &ASound1::command38, &ASound1::command39, 
+	&ASound1::command40, &ASound1::command41
+};
+
+ASound1::ASound1(Audio::Mixer *mixer): ASound(mixer, "asound.001", 0x1520) {
+	_cmd23Toggle = false;
+	
+	// Load sound data
+	_soundFile.seek(_dataOffset + 0x12C);
+	for (int i = 0; i < 98; ++i)
+		_soundData.push_back(SoundData(_soundFile));
+}
+
+int ASound1::command(int commandId) {
+	if (commandId > 41)
+		return 0;
+
+	_frameCounter = 0;
+	return (this->*_commandList[commandId])();
+}
+
+int ASound1::command9() {
+	playSound(0xC68, 12);
+	return 0;
+}
+
+int ASound1::command10() {
+	byte *pData1 = loadData(0x130E, 48);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[0].load(pData1);
+		_channels[1].load(loadData(0x133E, 392));
+		_channels[2].load(loadData(0x14C6, 46));
+		_channels[3].load(loadData(0x14F4, 48));
+	}
+
+	return 0;
+}
+
+int ASound1::command11() {
+	command111213();
+	_channels[0]._field1E = 0;
+	_channels[1]._field1E = 0;
+	return 0;
+}
+
+int ASound1::command12() {
+	command111213();
+	_channels[0]._field1E = 40;
+	_channels[1]._field1E = 0;
+	return 0;
+}
+
+int ASound1::command13() {
+	command111213();
+	_channels[0]._field1E = 40;
+	_channels[1]._field1E = 50;
+	return 0;
+}
+
+int ASound1::command14() {
+	playSound(0x1216, 248);
+	return 0;
+}
+
+int ASound1::command15() {
+	byte *pData1 = loadData(0x1524, 152);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[4].load(pData1);
+		_channels[5].load(loadData(0x15BC, 94));
+		_channels[6].load(loadData(0x161A, 94));
+		_channels[7].load(loadData(0x1678, 42));
+		_channels[8].load(loadData(0x16A2, 42));
+	}
+
+	return 0;
+}
+
+int ASound1::command16() {
+	playSound(0xC74, 14);
+	return 0;
+}
+
+int ASound1::command17() {
+	playSound(0xE9A, 10);
+	return 0;
+}
+
+int ASound1::command18() {
+	playSound(0xCA6, 20);
+	return 0;
+}
+
+int ASound1::command19() {
+	playSound(0xCBA, 74);
+	return 0;
+}
+
+int ASound1::command20() {
+	byte *pData = loadData(0xD18, 28);
+	if (!isSoundActive(pData))
+		playSound(pData);
+	return 0;
+}
+
+int ASound1::command21() {
+	playSound(0xD04, 20);
+	return 0;
+}
+
+int ASound1::command22() {
+	byte *pData = loadData(0xD34, 10);
+	pData[6] = (getRandomNumber() & 7) + 85;
+
+	if (!isSoundActive(pData))
+		playSound(pData);
+
+	return 0;
+}
+
+int ASound1::command23() {
+	_cmd23Toggle = !_cmd23Toggle;
+	playSound(_cmd23Toggle ? 0xD3E : 0xD46, 8);
+	return 0;
+}
+
+int ASound1::command24() {
+	playSound(0xD4E, 18);
+	playSound(0xD60, 20);
+	playSound(0xD74, 14);
+	return 0;
+}
+
+int ASound1::command25() {
+	byte *pData = loadData(0xD82, 16);
+	if (!isSoundActive(pData))
+		playSound(pData);
+
+	return 0;
+}
+
+int ASound1::command26() {
+	error("TODO: command26");
+	return 0;
+}
+
+int ASound1::command27() {
+	error("TODO: ASound::command27");
+	return 0;
+}
+
+int ASound1::command28() {
+	playSound(0xD92, 28);
+	return 0;
+}
+
+int ASound1::command29() {
+	error("TODO: ASound::command29");
+	return 0;
+}
+
+int ASound1::command30() {
+	error("TODO: ASound::command30");
+	return 0;
+}
+
+int ASound1::command31() {
+	byte *pData = loadData(0xDAE, 14);
+	if (!isSoundActive(pData))
+		playSound(pData);
+
+	return 0;
+}
+
+int ASound1::command32() {
+	error("TODO: ASound::command32");
+	return 0;
+}
+
+int ASound1::command33() {
+	playSound(0xDBC, 10);
+	playSound(0xDC6, 10);
+	return 0;
+}
+
+int ASound1::command34() {
+	int v = getRandomNumber() & 0x20;
+	if (!v) 
+		v = 0x60;
+
+	byte *pData = loadData(0xDD0, 22);
+	pData[8] = pData[15] = v;
+	playSound(pData);
+	return 0;
+}
+
+int ASound1::command35() {
+	playSound(0xDE6, 16);
+	return 0;
+}
+
+int ASound1::command36() {
+	playSound(0xE10, 10);
+	command34();
+
+	return 0;
+}
+
+int ASound1::command37() {
+	playSound(0xE1A, 14);
+	return 0;
+}
+
+int ASound1::command38() {
+	playSound(0xE28, 114);
+	return 0;
+}
+
+int ASound1::command39() {
+	byte *pData1 = loadData(0x16CC, 82);
+	if (!isSoundActive(pData1)) {
+		_channels[5].load(pData1);
+		_channels[6].load(loadData(0x171E, 30));
+		_channels[7].load(loadData(0x173C, 40));
+		_channels[8].load(loadData(0x1764, 64));
+	}
+	return 0;
+}
+
+int ASound1::command40() {
+	playSound(0xDF6, 26);
+	return 0;
+}
+
+int ASound1::command41() {
+	playSound(0xC32, 34);
+	playSound(0xC54, 20);
+	return 0;
+}
+
+void ASound1::command111213() {
+	byte *pData1 = loadData(0xEF6, 408);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[0].load(pData1);
+		_channels[1].load(loadData(0x108E, 266));
+		_channels[2].load(loadData(0x1198, 66));
+		_channels[2].load(loadData(0x11DA, 60));
+	}
+}
+
+void ASound1::command2627293032() {
+	// TODO: This method takes a parameter off the stack for several levels up.
+	// i.e. something the caller's caller pushed onto the stack. Need to figure
+	// out a better way to pass parameters down if this is actually in use.
+}
+
+} // End of namespace Nebular
+
+} // End of namespace MADS
diff --git a/engines/mads/sound_nebular.h b/engines/mads/sound_nebular.h
new file mode 100644
index 0000000..8f92389
--- /dev/null
+++ b/engines/mads/sound_nebular.h
@@ -0,0 +1,354 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_SOUND_NEBULAR_H
+#define MADS_SOUND_NEBULAR_H
+
+#include "common/scummsys.h"
+#include "common/file.h"
+#include "audio/audiostream.h"
+#include "audio/fmopl.h"
+#include "audio/mixer.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+class SoundManager;
+
+/**
+ * Represents the data for a channel on the Adlib
+ */
+class AdlibChannel {
+public:
+	int _activeCount;
+	int _field1;
+	int _field2;
+	int _field3;
+	int _field4;
+	int _field5;
+	int _volume;
+	int _field7;
+	int _field8;
+	int _field9;
+	int _fieldA;
+	int _fieldB;
+	int _fieldC;
+	int _fieldD;
+	int _fieldE;
+	byte *_ptr1;
+	byte *_pSrc;
+	byte *_ptr3;
+	byte *_ptr4;
+	int _field17;
+	int _field19;
+	byte *_soundData;
+	int _field1D;
+	int _field1E;
+	int _field1F;
+public:
+	AdlibChannel();
+
+	void reset();
+	void enable(int flag);
+	void setPtr2(byte *pData);
+	void load(byte *pData);
+	void check(byte *nullPtr);
+};
+
+class AdlibChannelData {
+public:
+	int _field0;
+	int _freqMask;
+	int _freqBase;
+	int _field6;
+};
+
+class SoundData {
+public:
+	int _field0;
+	int _field1;
+	int _field2;
+	int _field3;
+	int _field4;
+	int _field5;
+	int _field6;
+	int _field7;
+	int _field8;
+	int _field9;
+	int _fieldA;
+	int _fieldB;
+	int _fieldC;
+	int _fieldD;
+	int _fieldE;
+	int _field10;
+	int _field12;
+	int _field14;
+
+	SoundData() {}
+	SoundData(Common::SeekableReadStream &s);
+};
+
+#define ADLIB_CHANNEL_COUNT 9
+#define ADLIB_CHANNEL_MIDWAY 5
+
+/**
+ * Base class for the sound player resource files
+ */
+class ASound {
+private:
+	struct CachedDataEntry {
+		int _offset;
+		byte *_data;
+	};
+	Common::List<CachedDataEntry> _dataCache;
+	uint16 _randomSeed;
+
+	/**
+	 * Does the initial Adlib initialisation
+	 */
+	void adlibInit();
+
+	/**
+	 * Does on-going processing for the Adlib sounds being played
+	 */
+	void update();
+
+	/**
+	 * Polls each of the channels for updates
+	 */
+	void pollChannels();
+
+	/**
+	 * Checks the status of the channels
+	 */
+	void checkChannels();
+
+	/**
+	 * Polls the currently active channel
+	 */
+	void pollActiveChannel();
+
+	/**
+	 * Updates the octave of the currently active channel
+	 */
+	void updateOctave();
+
+	void updateChannelState();
+	void updateActiveChannel();
+	void channelProc1(int recIndex);
+	void channelProc2();
+	void updateFNumber();
+protected:
+	/**
+	 * Write a byte to an Adlib register
+	 */
+	void write(int reg, int val);
+
+	/**
+	 * Write a byte to an Adlib register, and store it in the _ports array
+	 */
+	int write2(int state, int reg, int val);
+
+	/**
+	 * Turn a channel on
+	 */
+	void channelOn(int reg, int volume);
+
+	/**
+	 * Turn a channel off
+	 */
+	void channelOff(int reg);
+
+	/**
+	 * Checks for whether a poll result needs to be set
+	 */
+	void resultCheck();
+
+	/**
+	 * Loads a data block from the sound file, caching the result for any future
+	 * calls for the same data
+	 */
+	byte *loadData(int offset, int size);
+
+	/**
+	 * Play the specified sound
+	 * @param offset	Offset of sound data within sound player data segment
+	 * @param size		Size of sound data block
+	 */
+	void playSound(int offset, int size);
+
+	/**
+	 * Play the specified raw sound data
+	 * @param pData		Pointer to data block containing sound data
+	 */
+	void playSound(byte *pData);
+
+	/**
+	 * Checks to see whether the given block of data is already loaded into a channel.
+	 */
+	bool isSoundActive(byte *pData);
+
+	/**
+	 * Sets the frequency for a given channel.
+	 */
+	void setFrequency(int channel, int freq);
+
+	/**
+	 * Returns a 16-bit random number
+	 */
+	int getRandomNumber();
+
+	int command0();
+	int command1();
+	int command2();
+	int command3();
+	int command4();
+	int command5();
+	int command6();
+	int command7();
+	int command8();
+public:
+	Audio::Mixer *_mixer;
+	FM_OPL *_opl;
+	AdlibChannel _channels[ADLIB_CHANNEL_COUNT];
+	AdlibChannel *_activeChannelPtr;
+	AdlibChannelData _channelData[11];
+	Common::Array<SoundData> _soundData;
+	SoundData *_soundDataPtr;
+	Common::File _soundFile;
+	int _dataOffset;
+	int _frameCounter;
+	bool _isDisabled;
+	int _v1;
+	int _v2;
+	int _activeChannelNumber;
+	int _freqMask1;
+	int _freqMask2;
+	int _freqBase1;
+	int _freqBase2;
+	int _channelNum1, _channelNum2;
+	int _v7;
+	int _v8;
+	int _v9;
+	int _v10;
+	int _pollResult;
+	int _resultFlag;
+	byte _nullData[2];
+	int _ports[256];
+	bool _stateFlag;
+	int _activeChannelReg;
+	int _v11;
+	bool _amDep, _vibDep, _splitPoint;
+public:
+	/**
+	 * Constructor
+	 * @param filename		Specifies the adlib sound player file to use
+	 * @param dataOffset	Offset in the file of the data segment
+	 */
+	ASound(Audio::Mixer *mixer, const Common::String &filename, int dataOffset);
+
+	/**
+	 * Destructor
+	 */
+	virtual ~ASound();
+
+	/**
+	 * Execute a player command. Most commands represent sounds to play, but some
+	 * low number commands also provide control operations
+	 */
+	virtual int command(int commandId) = 0;
+
+	/**
+	 * Stop all currently playing sounds
+	 */
+	int stop();
+
+	/**
+	 * Main poll method to allow sounds to progress
+	 */
+	int poll();
+
+	/**
+	 * General noise/note output
+	 */
+	void noise();
+
+	/**
+	 * Return the current frame counter
+	 */
+	int getFrameCounter() { return _frameCounter; }
+};
+
+class ASound1: public ASound {
+private:
+	typedef int (ASound1::*CommandPtr)();
+	static const CommandPtr _commandList[42];
+	bool _cmd23Toggle;
+
+	int command9();
+	int command10();
+	int command11();
+	int command12();
+	int command13();
+	int command14();
+	int command15();
+	int command16();
+	int command17();
+	int command18();
+	int command19();
+	int command20();
+	int command21();
+	int command22();
+	int command23();
+	int command24();
+	int command25();
+	int command26();
+	int command27();
+	int command28();
+	int command29();
+	int command30();
+	int command31();
+	int command32();
+	int command33();
+	int command34();
+	int command35();
+	int command36();
+	int command37();
+	int command38();
+	int command39();
+	int command40();
+	int command41();
+
+	void command111213();
+	void command2627293032();
+public:
+	ASound1(Audio::Mixer *mixer);
+
+	virtual int command(int commandId);
+};
+
+} // End of namespace Nebular
+
+} // End of namespace MADS
+
+#endif /* MADS_SOUND_NEBULAR_H */


Commit: 85e913864cb618211086c752ae79b0af51d28ae9
    https://github.com/scummvm/scummvm/commit/85e913864cb618211086c752ae79b0af51d28ae9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-16T17:02:13-05:00

Commit Message:
MADS: Renaming and fixes for loading sample data

Changed paths:
    engines/mads/sound_nebular.cpp
    engines/mads/sound_nebular.h



diff --git a/engines/mads/sound_nebular.cpp b/engines/mads/sound_nebular.cpp
index 03fdc5f..e364fbd 100644
--- a/engines/mads/sound_nebular.cpp
+++ b/engines/mads/sound_nebular.cpp
@@ -38,7 +38,7 @@ AdlibChannel::AdlibChannel() {
 	_field2 = 0;
 	_field3 = 0;
 	_field4 = 0;
-	_field5 = 0;
+	_sampleIndex = 0;
 	_volume = 0;
 	_field7 = 0;
 	_field8 = 0;
@@ -115,24 +115,25 @@ void AdlibChannel::check(byte *nullPtr) {
 
 /*-----------------------------------------------------------------------*/
 
-SoundData::SoundData(Common::SeekableReadStream &s) {
-	_field0 = s.readByte();
-	_field1 = s.readByte();
-	_field2 = s.readByte();
-	_field3 = s.readByte();
-	_field4 = s.readByte();
-	_field5 = s.readByte();
-	_field6 = s.readByte();
-	_field7 = s.readByte();
-	_field8 = s.readByte();
-	_field9 = s.readByte();
-	_fieldA = s.readByte();
-	_fieldB = s.readByte();
-	_fieldC = s.readByte();
-	_fieldD = s.readByte();
+AdlibSample::AdlibSample(Common::SeekableReadStream &s) {
+	_attackRate = s.readByte();
+	_decayRate = s.readByte();
+	_sustainLevel = s.readByte();
+	_releaseRate = s.readByte();
+	_egTyp = s.readByte() != 0;
+	_ksr = s.readByte() != 0;
+	_totalLevel = s.readByte();
+	_scalingLevel = s.readByte();
+	_waveformSelect = s.readByte();
+	_freqMultiple = s.readByte();
+	_feedback = s.readByte();
+	_ampMod = s.readByte() != 0;
+	_vib = s.readByte();
+	_alg = s.readByte();
 	_fieldE = s.readByte();
-	_field10 = s.readUint16LE();
-	_field12 = s.readUint16LE();
+	s.skip(1);
+	_freqMask = s.readUint16LE();
+	_freqBase = s.readUint16LE();
 	_field14 = s.readUint16LE();
 }
 
@@ -151,7 +152,7 @@ ASound::ASound(Audio::Mixer *mixer, const Common::String &filename, int dataOffs
 
 	// Initialise fields
 	_activeChannelPtr = nullptr;
-	_soundDataPtr = nullptr;
+	_samplePtr = nullptr;
 	_frameCounter = 0;
 	_isDisabled = false;
 	_v1 = 0;
@@ -456,9 +457,9 @@ void ASound::pollActiveChannel() {
 						break;
 
 					case 3:
-						chan->_field5 = *++pSrc;
+						chan->_sampleIndex = *++pSrc;
 						chan->_pSrc += 2;
-						channelProc1(chan->_field5);
+						loadSample(chan->_sampleIndex);
 						break;
 
 					case 4:
@@ -669,27 +670,27 @@ void ASound::updateActiveChannel() {
 	write2(2, reg, val2);
 }
 
-void ASound::channelProc1(int recIndex) {
+void ASound::loadSample(int sampleIndex) {
 	_activeChannelReg = 0xB0 + _activeChannelNumber;
 	write2(8, _activeChannelReg, _ports[_activeChannelReg] & 0xDF);
 
 	_activeChannelReg = _activeChannelNumber;
-	_soundDataPtr = &_soundData[recIndex * 2];
+	_samplePtr = &_samples[sampleIndex * 2];
 	_v11 = outputChannels[outputIndexes[_activeChannelReg * 2 - 1]];
-	channelProc2();
+	processSample();
 
 	AdlibChannelData &cd = _channelData[_activeChannelNumber];
-	cd._field6 = _soundDataPtr->_field14;
-	cd._freqBase = _soundDataPtr->_field12;
-	cd._freqMask = _soundDataPtr->_field10;
-	cd._field0 = _soundDataPtr->_fieldE;
+	cd._field6 = _samplePtr->_field14;
+	cd._freqBase = _samplePtr->_freqBase;
+	cd._freqMask = _samplePtr->_freqMask;
+	cd._field0 = _samplePtr->_fieldE;
 
-	_soundDataPtr = &_soundData[recIndex * 2 + 1];
+	_samplePtr = &_samples[sampleIndex * 2 + 1];
 	_v11 = outputChannels[outputIndexes[_activeChannelReg * 2]];
-	channelProc2();
+	processSample();
 }
 
-void ASound::channelProc2() {
+void ASound::processSample() {
 	// Write out vib flags and split point
 	write2(8, 0x40 + _v11, 0x3F);
 	int depthRhythm = _ports[0xBD] & 0x3F | (_amDep ? 0x80 : 0) |
@@ -697,24 +698,29 @@ void ASound::channelProc2() {
 	write2(8, 0xBD, depthRhythm);
 	write2(8, 8, _splitPoint ? 0x40 : 0);
 
-	int val = _soundDataPtr->_fieldA;
-	val = (val << 1) | (1 - _soundDataPtr->_fieldD);
+	// Write out feedback & Alg
+	int val = (_samplePtr->_feedback << 1) | (1 - _samplePtr->_alg);
 	write2(8, 0xC0 + _activeChannelReg, val);
 
-	val = (_soundDataPtr->_field0 << 4) | (_soundDataPtr->_field1 & 0xF);
+	// Write out attack/decay rate
+	val = (_samplePtr->_attackRate << 4) | (_samplePtr->_decayRate & 0xF);
 	write2(8, 0x60 + _v11, val);
 
-	val = (_soundDataPtr->_field2 << 4) | (_soundDataPtr->_field3 & 0xF);
+	// Write out sustain level/release rate
+	val = (_samplePtr->_sustainLevel << 4) | (_samplePtr->_releaseRate & 0xF);
 	write2(8, 0x80 + _v11, val);
 
-	val = (_soundDataPtr->_fieldB ? 0x80 : 0) | (_soundDataPtr->_fieldC ? 0x40 : 0)
-		| (_soundDataPtr->_field4 ? 0x20 : 0) | (_soundDataPtr->_field5 ? 0x10 : 0)
-		| (_soundDataPtr->_field9 & 0xF);
+	// Write out misc flags
+	val = (_samplePtr->_ampMod ? 0x80 : 0) | (_samplePtr->_vib ? 0x40 : 0)
+		| (_samplePtr->_egTyp ? 0x20 : 0) | (_samplePtr->_ksr ? 0x10 : 0)
+		| (_samplePtr->_freqMultiple & 0xF);
 	write2(8, 0x20 + _v11, val);
 
-	write2(8, 0xE0 + _v11, _soundDataPtr->_field8 & 3);
+	// Write out waveform select
+	write2(8, 0xE0 + _v11, _samplePtr->_waveformSelect & 3);
 	
-	val = -(_soundDataPtr->_field6 & 0x3F - 0x3F) | (_soundDataPtr->_field7 << 6);
+	// Write out total level & scaling level
+	val = -(_samplePtr->_totalLevel & 0x3F - 0x3F) | (_samplePtr->_scalingLevel << 6);
 	write2(8, 0x40 + _v11, val);
 }
 
@@ -841,10 +847,10 @@ const ASound1::CommandPtr ASound1::_commandList[42] = {
 ASound1::ASound1(Audio::Mixer *mixer): ASound(mixer, "asound.001", 0x1520) {
 	_cmd23Toggle = false;
 	
-	// Load sound data
+	// Load sound samples
 	_soundFile.seek(_dataOffset + 0x12C);
 	for (int i = 0; i < 98; ++i)
-		_soundData.push_back(SoundData(_soundFile));
+		_samples.push_back(AdlibSample(_soundFile));
 }
 
 int ASound1::command(int commandId) {
diff --git a/engines/mads/sound_nebular.h b/engines/mads/sound_nebular.h
index 8f92389..d37c52e 100644
--- a/engines/mads/sound_nebular.h
+++ b/engines/mads/sound_nebular.h
@@ -45,7 +45,7 @@ public:
 	int _field2;
 	int _field3;
 	int _field4;
-	int _field5;
+	int _sampleIndex;
 	int _volume;
 	int _field7;
 	int _field8;
@@ -83,29 +83,29 @@ public:
 	int _field6;
 };
 
-class SoundData {
+class AdlibSample {
 public:
-	int _field0;
-	int _field1;
-	int _field2;
-	int _field3;
-	int _field4;
-	int _field5;
-	int _field6;
-	int _field7;
-	int _field8;
-	int _field9;
-	int _fieldA;
-	int _fieldB;
-	int _fieldC;
-	int _fieldD;
+	int _attackRate;
+	int _decayRate;
+	int _sustainLevel;
+	int _releaseRate;
+	bool _egTyp;
+	bool _ksr;
+	int _totalLevel;
+	int _scalingLevel;
+	int _waveformSelect;
+	int _freqMultiple;
+	int _feedback;
+	bool _ampMod;
+	int _vib;
+	int _alg;
 	int _fieldE;
-	int _field10;
-	int _field12;
+	int _freqMask;
+	int _freqBase;
 	int _field14;
 
-	SoundData() {}
-	SoundData(Common::SeekableReadStream &s);
+	AdlibSample() {}
+	AdlibSample(Common::SeekableReadStream &s);
 };
 
 #define ADLIB_CHANNEL_COUNT 9
@@ -155,8 +155,17 @@ private:
 
 	void updateChannelState();
 	void updateActiveChannel();
-	void channelProc1(int recIndex);
-	void channelProc2();
+	
+	/**
+	 * Loads up the specified sample
+	 */
+	void loadSample(int sampleIndex);
+
+	/**
+	 * Writes out the data of the selected sample to the Adlib
+	 */
+	void processSample();
+
 	void updateFNumber();
 protected:
 	/**
@@ -233,8 +242,8 @@ public:
 	AdlibChannel _channels[ADLIB_CHANNEL_COUNT];
 	AdlibChannel *_activeChannelPtr;
 	AdlibChannelData _channelData[11];
-	Common::Array<SoundData> _soundData;
-	SoundData *_soundDataPtr;
+	Common::Array<AdlibSample> _samples;
+	AdlibSample *_samplePtr;
 	Common::File _soundFile;
 	int _dataOffset;
 	int _frameCounter;


Commit: a47bb52d2e5a76a88e039b80cc6e064f8e74a199
    https://github.com/scummvm/scummvm/commit/a47bb52d2e5a76a88e039b80cc6e064f8e74a199
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-16T17:14:28-05:00

Commit Message:
MADS: Add some missing channel initialisation

Changed paths:
    engines/mads/sound.cpp
    engines/mads/sound_nebular.cpp



diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index 335afb4..e3590f5 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -42,7 +42,9 @@ void SoundManager::setVm(MADSEngine *vm, Audio::Mixer *mixer) {
 
 void SoundManager::test() {
 	_asound = new Nebular::ASound1(_mixer);
+	_asound->command(5);
 	_asound->command(28);
+	_asound->command(19);
 }
 
 void SoundManager::poll() {
diff --git a/engines/mads/sound_nebular.cpp b/engines/mads/sound_nebular.cpp
index e364fbd..6733f4e 100644
--- a/engines/mads/sound_nebular.cpp
+++ b/engines/mads/sound_nebular.cpp
@@ -70,7 +70,11 @@ void AdlibChannel::reset() {
 void AdlibChannel::enable(int flag) {
 	if (_activeCount) {
 		_fieldE = flag;
-		_soundData = nullptr; // TODO: Check original set it to flag??!
+
+		// WORKAROUND: Original set _soundData pointer to flag. Since this seems
+		// just intended to invalidate any prior pointer, I've replaced it with
+		// a simple null pointer
+		_soundData = nullptr; 
 	}
 }
 
@@ -930,11 +934,13 @@ int ASound1::command17() {
 }
 
 int ASound1::command18() {
+	command1();
 	playSound(0xCA6, 20);
 	return 0;
 }
 
 int ASound1::command19() {
+	command1();
 	playSound(0xCBA, 74);
 	return 0;
 }


Commit: 409f51cb99bcd9e1024e57b250d70327f61e6d15
    https://github.com/scummvm/scummvm/commit/409f51cb99bcd9e1024e57b250d70327f61e6d15
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-16T22:26:31-05:00

Commit Message:
MADS: Further sound udpate fixes

Changed paths:
    engines/mads/sound_nebular.cpp
    engines/mads/sound_nebular.h



diff --git a/engines/mads/sound_nebular.cpp b/engines/mads/sound_nebular.cpp
index 6733f4e..a111693 100644
--- a/engines/mads/sound_nebular.cpp
+++ b/engines/mads/sound_nebular.cpp
@@ -195,7 +195,12 @@ ASound::~ASound() {
 }
 
 void ASound::adlibInit() {
-	// No implementation
+	write(4, 0x60);
+	write(4, 0x80);
+	write(2, 0xff);
+	write(4, 0x21);
+	write(4, 0x60);
+	write(4, 0x80);
 }
 
 int ASound::stop() { 
@@ -228,7 +233,6 @@ void ASound::noise() {
 }
 
 void ASound::write(int reg, int val) {
-	debug("reg %.2x = %.2x", reg, val);
 	_opl->write(reg, val);
 }
 
@@ -369,9 +373,9 @@ void ASound::checkChannels() {
 }
 
 void ASound::pollActiveChannel() {
-	bool flag = false;
-
 	AdlibChannel *chan = _activeChannelPtr; 
+	bool updateFlag = true;
+
 	if (chan->_activeCount) {
 		if (chan->_field8 > 0 && --chan->_field8 == 0)
 			updateOctave();
@@ -380,7 +384,7 @@ void ASound::pollActiveChannel() {
 			for (;;) {
 				byte *pSrc = chan->_pSrc;
 				if (!(*pSrc & 0x80) || (*pSrc <= 0xF0)) {
-					if (flag)
+					if (updateFlag)
 						updateActiveChannel();
 
 					chan->_field4 = *pSrc++;
@@ -394,9 +398,10 @@ void ASound::pollActiveChannel() {
 						updateChannelState();
 					}
 
+					// Break out of processing loop
 					break;
 				} else {
-					flag = false;
+					updateFlag = false;
 
 					switch ((~*pSrc) & 0xF) {
 					case 0:
@@ -479,10 +484,10 @@ void ASound::pollActiveChannel() {
 					case 6:
 						++pSrc;
 						if (chan->_fieldE) {
-							chan->_volume = *pSrc >> 1;
-							flag = 1;
 							chan->_pSrc += 2;
 						} else {
+							chan->_volume = *pSrc >> 1;
+							updateFlag = true;
 							chan->_pSrc += 2;
 						}
 						break;
@@ -521,14 +526,14 @@ void ASound::pollActiveChannel() {
 							chan->_pSrc += 2;
 						} else {
 							chan->_field1E = *pSrc >> 1;
-							flag = 1;
+							updateFlag = true;
 							chan->_pSrc += 2;
 						}
 						break;
 
 					case 11:
 						chan->_fieldD = *++pSrc;
-						flag = 1;
+						updateFlag = true;
 						chan->_pSrc += 2;
 						break;
 
@@ -559,12 +564,22 @@ void ASound::pollActiveChannel() {
 		if (chan->_field1)
 			updateFNumber();
 
-		flag = false;
-		if (chan->_field9 || chan->_field8) {
+		updateFlag = false;
+		if (chan->_field9 || chan->_fieldB) {
 			if (!--chan->_field9) {
 				chan->_field9 = chan->_fieldA;
 				if (chan->_field2) {
-					chan->_field9 = CLIP(chan->_field2 + chan->_field1E, 0, 63);
+					int8 newVal = (int8)chan->_field2 + (int8)chan->_field1E;
+					if (newVal < 0) {
+						chan->_field9 = 0;
+						newVal = 0;
+					} else if (newVal > 63) {
+						chan->_field9 = 0;
+						newVal = 63;
+					}
+
+					chan->_field1E = newVal;
+					updateFlag = true;
 				}
 			}
 
@@ -572,11 +587,11 @@ void ASound::pollActiveChannel() {
 				chan->_fieldB = chan->_fieldC;
 				if (chan->_field3) {
 					chan->_fieldD = chan->_field3;
-					flag = true;
+					updateFlag = true;
 				}
 			}
 
-			if (flag)
+			if (updateFlag)
 				updateActiveChannel();
 		}
 	}
@@ -628,14 +643,13 @@ void ASound::updateChannelState() {
 		resultCheck();
 	} else {
 		int reg = 0xA0 + _activeChannelNumber;
-		int v = (_activeChannelPtr->_field4 + _activeChannelPtr->_field1F) / 12;
-		int vHi = v >> 8;
-		int vLo = v & 0xFF;
-		int val = _vList1[vHi] + vHi;
+		int vTimes = (_activeChannelPtr->_field4 + _activeChannelPtr->_field1F) / 12;
+		int vOffset = (_activeChannelPtr->_field4 + _activeChannelPtr->_field1F) % 12;
+		int val = _vList1[vOffset] + _activeChannelPtr->_field1D;
 		write2(8, reg, val & 0xFF);
 
 		reg += 0x10;
-		write2(8, reg, (_ports[reg] & 0x20) | (vLo << 2) | (val >> 8));
+		write2(8, reg, (_ports[reg] & 0x20) | (vTimes << 2) | (val >> 8));
 
 		write2(8, reg, _ports[reg] | 0x20);
 	}
@@ -664,7 +678,8 @@ void ASound::updateActiveChannel() {
 	int portVal = _ports[reg] & 0xFFC0;
 	int newVolume = CLIP(_activeChannelPtr->_volume + _activeChannelPtr->_field1E, 0, 63);
 	
-	// TODO: Double-check _v5660 = 5600h
+	// Note: Original had a whole block not seeming to be used, since the initialisation
+	// sets a variable to 5660h, and doesn't change it, so the branch is never taken
 	int val = CLIP(newVolume - volumeList[_activeChannelPtr->_fieldD], 0, 63);
 	val = (63 - val) | portVal;
 
@@ -753,6 +768,15 @@ int ASound::command0() {
 	_v7 = 0;
 	_v8 = 0;	
 
+	// Reset Adlib port registers
+	for (int reg = 0x4F; reg >= 0x40; --reg)
+		write2(8, reg, 0x3F);
+	for (int reg = 0xFF; reg >= 0x60; --reg)
+		write2(8, reg, 0);
+	for (int reg = 0x3F; reg > 0; --reg)
+		write2(8, reg, 0);
+	write2(8, 1, 0x20);
+
 	_isDisabled = isDisabled;
 	return 0;
 }
diff --git a/engines/mads/sound_nebular.h b/engines/mads/sound_nebular.h
index d37c52e..e2367a5 100644
--- a/engines/mads/sound_nebular.h
+++ b/engines/mads/sound_nebular.h
@@ -51,7 +51,7 @@ public:
 	int _field8;
 	int _field9;
 	int _fieldA;
-	int _fieldB;
+	uint8 _fieldB;
 	int _fieldC;
 	int _fieldD;
 	int _fieldE;


Commit: ece3e9a2200052cc65f60e0295b674095d7a6a66
    https://github.com/scummvm/scummvm/commit/ece3e9a2200052cc65f60e0295b674095d7a6a66
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-16T23:04:02-05:00

Commit Message:
MADS: Booyah! Copy protection failure air escaping sound playing

Changed paths:
    engines/mads/mads.cpp
    engines/mads/sound_nebular.cpp
    engines/mads/sound_nebular.h



diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 39ef195..25730fa 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -45,8 +45,6 @@ void MADSEngine::initialise() {
 	_soundManager.setVm(this, _mixer);
 }
 
-static uint32 lastSoundFrame = 0;
-
 Common::Error MADSEngine::run() {
 	initGraphics(320, 200, false);
 	initialise();
@@ -56,12 +54,6 @@ Common::Error MADSEngine::run() {
 	while (!shouldQuit()) {
 		g_system->getEventManager()->pollEvent(e);
 		g_system->delayMillis(10);
-
-		uint32 milli = g_system->getMillis();
-		if (milli > (lastSoundFrame + 50)) {
-			lastSoundFrame = milli;
-			_soundManager.poll();
-		}
 	}
 
 	return Common::kNoError;
diff --git a/engines/mads/sound_nebular.cpp b/engines/mads/sound_nebular.cpp
index a111693..146a620 100644
--- a/engines/mads/sound_nebular.cpp
+++ b/engines/mads/sound_nebular.cpp
@@ -148,12 +148,6 @@ ASound::ASound(Audio::Mixer *mixer, const Common::String &filename, int dataOffs
 	if (!_soundFile.open(filename))
 		error("Could not open file - %s", filename.c_str());
 
-	_dataOffset = dataOffset;
-	_mixer = mixer;
-	_opl = OPL::Config::create();
-	assert(_opl);
-	_opl->init(11025);
-
 	// Initialise fields
 	_activeChannelPtr = nullptr;
 	_samplePtr = nullptr;
@@ -179,6 +173,21 @@ ASound::ASound(Audio::Mixer *mixer, const Common::String &filename, int dataOffs
 	_randomSeed = 1234;
 	_amDep = _vibDep = _splitPoint = true;
 
+	_samplesTillCallback = 0;
+	_samplesTillCallbackRemainder = 0;
+	_samplesPerCallback = getRate() / CALLBACKS_PER_SECOND;
+	_samplesPerCallbackRemainder = getRate() % CALLBACKS_PER_SECOND;
+
+	// Store passed parameters, and setup OPL
+	_dataOffset = dataOffset;
+	_mixer = mixer;
+	_opl = OPL::Config::create();
+	assert(_opl);
+
+	_opl->init(getRate());
+	_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, 
+		Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
+
 	// Initialise the Adlib
 	adlibInit();
 
@@ -191,6 +200,7 @@ ASound::~ASound() {
 	for (i = _dataCache.begin(); i != _dataCache.end(); ++i)
 		delete[] (*i)._data;
 
+	_mixer->stopHandle(_soundHandle);
 	delete _opl;
 }
 
@@ -233,7 +243,7 @@ void ASound::noise() {
 }
 
 void ASound::write(int reg, int val) {
-	_opl->write(reg, val);
+	_queue.push(RegisterValue(reg, val));
 }
 
 int ASound::write2(int state, int reg, int val) {
@@ -243,6 +253,15 @@ int ASound::write2(int state, int reg, int val) {
 	return state;
 }
 
+void ASound::flush() {
+	Common::StackLock slock(_driverMutex);
+
+	while (!_queue.empty()) {
+		RegisterValue v = _queue.pop();
+		_opl->writeReg(v._regNum, v._value);
+	}
+}
+
 void ASound::channelOn(int reg, int volume) {
 	write2(8, reg, (_ports[reg] & 0xC0) | (volume & 0x3F));
 }
@@ -754,6 +773,34 @@ void ASound::updateFNumber() {
 	write2(8, hiReg, val2);
 }
 
+int ASound::readBuffer(int16 *buffer, const int numSamples) {
+	Common::StackLock slock(_driverMutex);
+
+	int32 samplesLeft = numSamples;
+	memset(buffer, 0, sizeof(int16) * numSamples);
+	while (samplesLeft) {
+		if (!_samplesTillCallback) {
+			poll();
+			flush();
+
+			_samplesTillCallback = _samplesPerCallback;
+			_samplesTillCallbackRemainder += _samplesPerCallbackRemainder;
+			if (_samplesTillCallbackRemainder >= CALLBACKS_PER_SECOND) {
+				_samplesTillCallback++;
+				_samplesTillCallbackRemainder -= CALLBACKS_PER_SECOND;
+			}
+		}
+
+		int32 render = MIN<int>(samplesLeft, _samplesTillCallback);
+		samplesLeft -= render;
+		_samplesTillCallback -= render;
+
+		_opl->readBuffer(buffer, render);
+		buffer += render;
+	}
+	return numSamples;
+}
+
 int ASound::command0() {
 	bool isDisabled = _isDisabled;
 	_isDisabled = true;
diff --git a/engines/mads/sound_nebular.h b/engines/mads/sound_nebular.h
index e2367a5..f9251c9 100644
--- a/engines/mads/sound_nebular.h
+++ b/engines/mads/sound_nebular.h
@@ -25,6 +25,8 @@
 
 #include "common/scummsys.h"
 #include "common/file.h"
+#include "common/mutex.h"
+#include "common/queue.h"
 #include "audio/audiostream.h"
 #include "audio/fmopl.h"
 #include "audio/mixer.h"
@@ -108,13 +110,23 @@ public:
 	AdlibSample(Common::SeekableReadStream &s);
 };
 
+struct RegisterValue {
+	uint8 _regNum;
+	uint8 _value;
+
+	RegisterValue(int regNum, int value) {
+		_regNum = regNum; _value = value;
+	}
+};
+
 #define ADLIB_CHANNEL_COUNT 9
 #define ADLIB_CHANNEL_MIDWAY 5
+#define CALLBACKS_PER_SECOND 60
 
 /**
  * Base class for the sound player resource files
  */
-class ASound {
+class ASound: public Audio::AudioStream {
 private:
 	struct CachedDataEntry {
 		int _offset;
@@ -169,16 +181,21 @@ private:
 	void updateFNumber();
 protected:
 	/**
-	 * Write a byte to an Adlib register
+	 * Queue a byte for an Adlib register
 	 */
 	void write(int reg, int val);
 
 	/**
-	 * Write a byte to an Adlib register, and store it in the _ports array
+	 * Queue a byte for an Adlib register, and store it in the _ports array
 	 */
 	int write2(int state, int reg, int val);
 
 	/**
+	 * Flush any pending Adlib register values to the OPL driver
+	 */
+	void flush();
+
+	/**
 	 * Turn a channel on
 	 */
 	void channelOn(int reg, int volume);
@@ -239,12 +256,15 @@ protected:
 public:
 	Audio::Mixer *_mixer;
 	FM_OPL *_opl;
+	Audio::SoundHandle _soundHandle;
 	AdlibChannel _channels[ADLIB_CHANNEL_COUNT];
 	AdlibChannel *_activeChannelPtr;
 	AdlibChannelData _channelData[11];
 	Common::Array<AdlibSample> _samples;
 	AdlibSample *_samplePtr;
 	Common::File _soundFile;
+	Common::Queue<RegisterValue> _queue;
+	Common::Mutex _driverMutex;
 	int _dataOffset;
 	int _frameCounter;
 	bool _isDisabled;
@@ -268,6 +288,10 @@ public:
 	int _activeChannelReg;
 	int _v11;
 	bool _amDep, _vibDep, _splitPoint;
+	int _samplesPerCallback;
+	int _samplesPerCallbackRemainder;
+	int _samplesTillCallback;
+	int _samplesTillCallbackRemainder;
 public:
 	/**
 	 * Constructor
@@ -306,6 +330,27 @@ public:
 	 * Return the current frame counter
 	 */
 	int getFrameCounter() { return _frameCounter; }
+
+	// AudioStream interface
+	/**
+	 * Main buffer read
+	 */
+	virtual int readBuffer(int16 *buffer, const int numSamples);
+	
+	/**
+	 * Mono sound only
+	 */
+	virtual bool isStereo() const { return false; }
+	
+	/**
+	 * Data is continuously pushed, so definitive end
+	 */
+	virtual bool endOfData() const { return false; }
+
+	/**
+	 * Return sample rate
+	 */
+	virtual int getRate() const { return 11025; }
 };
 
 class ASound1: public ASound {


Commit: 0e46c809d10dcd8fd766d7adcb966785e7955f5b
    https://github.com/scummvm/scummvm/commit/0e46c809d10dcd8fd766d7adcb966785e7955f5b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-18T20:08:58-05:00

Commit Message:
MADS: Initial implementation of MSurface class and dependant classes

Changed paths:
  A engines/mads/compression.cpp
  A engines/mads/compression.h
  A engines/mads/events.cpp
  A engines/mads/events.h
  A engines/mads/msprite.cpp
  A engines/mads/msprite.h
  A engines/mads/msurface.cpp
  A engines/mads/msurface.h
  A engines/mads/palette.cpp
  A engines/mads/palette.h
  A engines/mads/resources.cpp
  A engines/mads/resources.h
    engines/mads/detection.cpp
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/module.mk
    engines/mads/sound.cpp
    engines/mads/sound.h
    engines/mads/sound_nebular.h



diff --git a/engines/mads/compression.cpp b/engines/mads/compression.cpp
new file mode 100644
index 0000000..f8df5a5
--- /dev/null
+++ b/engines/mads/compression.cpp
@@ -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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "mads/compression.h"
+
+namespace MADS {
+
+const char *const madsPackString = "MADSPACK";
+
+bool MadsPack::isCompressed(Common::SeekableReadStream *stream) {
+	// Check whether the passed stream is packed
+
+	char tempBuffer[8];
+	stream->seek(0);
+	if (stream->read(tempBuffer, 8) == 8) {
+		if (!strncmp(tempBuffer, madsPackString, 8)) 
+			return true;
+	}
+
+	return false;
+}
+
+MadsPack::MadsPack(Common::SeekableReadStream *stream) {
+	initialise(stream);
+}
+
+MadsPack::MadsPack(const Common::String &resourceName, MADSEngine *vm) {
+	Common::SeekableReadStream *stream = vm->_resources->get(resourceName);
+	initialise(stream);
+	vm->_resources->toss(resourceName);
+}
+
+void MadsPack::initialise(Common::SeekableReadStream *stream) {
+	if (!MadsPack::isCompressed(stream))
+		error("Attempted to decompress a resource that was not MadsPacked");
+
+	stream->seek(14);
+	_count = stream->readUint16LE();
+	_items = new MadsPackEntry[_count];
+	
+	byte *headerData = new byte[0xA0];
+	byte *header = headerData;
+	stream->read(headerData, 0xA0);
+
+	for (int i = 0; i < _count; ++i, header += 10) {
+		// Get header data
+		_items[i].hash = READ_LE_UINT16(header);
+		_items[i].size = READ_LE_UINT32(header + 2);
+		_items[i].compressedSize = READ_LE_UINT32(header + 6);
+
+		_items[i].data = new byte[_items[i].size];
+		if (_items[i].size == _items[i].compressedSize) {
+			// Entry isn't compressed
+			stream->read(_items[i].data, _items[i].size);
+		} else {
+			// Decompress the entry
+			byte *compressedData = new byte[_items[i].compressedSize];
+			stream->read(compressedData, _items[i].compressedSize);
+			
+			FabDecompressor fab;
+			fab.decompress(compressedData, _items[i].compressedSize, _items[i].data, _items[i].size);
+			delete[] compressedData;
+		}
+	}
+
+	delete[] headerData;
+	_dataOffset = stream->pos();
+}
+
+MadsPack::~MadsPack() {
+	for (int i = 0; i < _count; ++i)
+		delete[] _items[i].data;
+	delete[] _items;
+}
+
+//--------------------------------------------------------------------------
+
+const char *FabInputExceededError = "FabDecompressor - Passed end of input buffer during decompression";
+const char *FabOutputExceededError = "FabDecompressor - Decompressed data exceeded specified size";
+
+void FabDecompressor::decompress(const byte *srcData, int srcSize, byte *destData, int destSize) {
+	byte copyLen, copyOfsShift, copyOfsMask, copyLenMask;
+	unsigned long copyOfs;
+	byte *destP;
+	
+	// Validate that the data starts with the FAB header
+	if (strncmp((const char *)srcData, "FAB", 3) != 0)
+		error("FabDecompressor - Invalid compressed data");
+
+	int shiftVal = srcData[3];
+	if ((shiftVal < 10) || (shiftVal > 13))
+		error("FabDecompressor - Invalid shift start");
+
+	copyOfsShift = 16 - shiftVal;
+	copyOfsMask = 0xFF << (shiftVal - 8);
+	copyLenMask = (1 << copyOfsShift) - 1;
+	copyOfs = 0xFFFF0000;
+	destP = destData;
+
+	// Initialise data fields
+	_srcData = srcData;
+	_srcP = _srcData + 6;
+	_srcSize = srcSize;
+	_bitsLeft = 16;	
+	_bitBuffer = READ_LE_UINT16(srcData + 4);
+
+	for (;;) {
+		if (getBit() == 0) {
+			if (getBit() == 0) {
+				copyLen = ((getBit() << 1) | getBit()) + 2;
+				copyOfs = *_srcP++ | 0xFFFFFF00;
+			} else {
+				copyOfs = (((_srcP[1] >> copyOfsShift) | copyOfsMask) << 8) | _srcP[0];
+				copyLen = _srcP[1] & copyLenMask;
+				_srcP += 2;
+				if (copyLen == 0) {
+					copyLen = *_srcP++;
+					if (copyLen == 0)
+						break;
+					else if (copyLen == 1)
+						continue;
+					else
+						copyLen++;
+				} else {
+					copyLen += 2;
+				}
+				copyOfs |= 0xFFFF0000;
+			}
+			while (copyLen-- > 0) {
+				if (destP - destData == destSize)
+					error(FabOutputExceededError);
+
+				*destP = destP[(signed int)copyOfs];
+				destP++;
+			}
+		} else {
+			if (_srcP - srcData == srcSize)
+				error(FabInputExceededError);
+			if (destP - destData == destSize)
+				error(FabOutputExceededError);
+
+			*destP++ = *_srcP++;
+		}
+	}
+
+	if (destP - destData != destSize)
+		error("FabDecompressor - Decompressed data does not match header decompressed size");
+}
+
+int FabDecompressor::getBit() {
+	_bitsLeft--;
+	if (_bitsLeft == 0) {
+		if (_srcP - _srcData == _srcSize)
+			error(FabInputExceededError);
+
+		_bitBuffer = (READ_LE_UINT16(_srcP) << 1) | (_bitBuffer & 1);
+		_srcP += 2;
+		_bitsLeft = 16;
+	}
+
+	int bit = _bitBuffer & 1;
+	_bitBuffer >>= 1;
+	return bit;
+}
+
+} // End of namespace M4
diff --git a/engines/mads/compression.h b/engines/mads/compression.h
new file mode 100644
index 0000000..bf690dc
--- /dev/null
+++ b/engines/mads/compression.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_COMPRESSION_H
+#define MADS_COMPRESSION_H
+
+#include "common/scummsys.h"
+#include "common/endian.h"
+#include "common/memstream.h"
+#include "common/stream.h"
+
+#include "mads/mads.h"
+
+namespace MADS {
+
+struct MadsPackEntry {
+public:
+	uint16 hash;
+	uint32 size;
+	uint32 compressedSize;
+	byte *data;
+};
+
+class MadsPack {
+private:
+	MadsPackEntry *_items;
+	int _count;
+	int _dataOffset;
+
+	void initialise(Common::SeekableReadStream *stream);
+public:
+	static bool isCompressed(Common::SeekableReadStream *stream);
+	MadsPack(Common::SeekableReadStream *stream);
+	MadsPack(const Common::String &resourceName, MADSEngine *_vm);
+	~MadsPack();
+
+	int getCount() const { return _count; }
+	MadsPackEntry &getItem(int index) const { return _items[index]; }
+	MadsPackEntry &operator[](int index) const { return _items[index]; }
+	Common::MemoryReadStream *getItemStream(int index) {
+		return new Common::MemoryReadStream(_items[index].data, _items[index].size,
+			DisposeAfterUse::NO);
+	}
+	int getDataOffset() const { return _dataOffset; }
+};
+
+class FabDecompressor {
+private:
+    int _bitsLeft;
+    uint32 _bitBuffer;
+	const byte *_srcData, *_srcP;
+	int _srcSize;
+
+	int getBit();
+public:
+	void decompress(const byte *srcData, int srcSize, byte *destData, int destSize);
+};
+
+} // End of namespace MADS
+
+#endif
diff --git a/engines/mads/detection.cpp b/engines/mads/detection.cpp
index 4e56655..73a4b97 100644
--- a/engines/mads/detection.cpp
+++ b/engines/mads/detection.cpp
@@ -38,8 +38,19 @@ namespace MADS {
 
 struct MADSGameDescription {
 	ADGameDescription desc;
+
+	int gameID;
+	uint32 features;
 };
 
+uint32 MADSEngine::getGameID() const {
+	return _gameDescription->gameID;
+}
+
+uint32 MADSEngine::getGameFeatures() const {
+	return _gameDescription->gameID;
+}
+
 uint32 MADSEngine::getFeatures() const {
 	return _gameDescription->desc.flags;
 }
@@ -52,10 +63,6 @@ Common::Platform MADSEngine::getPlatform() const {
 	return _gameDescription->desc.platform;
 }
 
-bool MADSEngine::getIsDemo() const {
-	return _gameDescription->desc.flags & ADGF_DEMO;
-}
-
 } // End of namespace MADS
 
 static const PlainGameDescriptor MADSGames[] = {
@@ -165,7 +172,7 @@ SaveStateDescriptor MADSMetaEngine::querySaveMetaInfos(const char *target, int s
 
 
 #if PLUGIN_ENABLED_DYNAMIC(MADS)
-REGISTER_PLUGIN_DYNAMIC(MADS, PLUGIN_TYPE_ENGINE, MADSMetaEngine);
+	REGISTER_PLUGIN_DYNAMIC(MADS, PLUGIN_TYPE_ENGINE, MADSMetaEngine);
 #else
-REGISTER_PLUGIN_STATIC(MADS, PLUGIN_TYPE_ENGINE, MADSMetaEngine);
+	REGISTER_PLUGIN_STATIC(MADS, PLUGIN_TYPE_ENGINE, MADSMetaEngine);
 #endif
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
new file mode 100644
index 0000000..8d6262a
--- /dev/null
+++ b/engines/mads/events.cpp
@@ -0,0 +1,34 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "common/events.h"
+#include "mads/mads.h"
+#include "mads/events.h"
+
+namespace MADS {
+
+EventsManager::EventsManager(MADSEngine *vm) {
+	_vm = vm;
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/events.h b/engines/mads/events.h
new file mode 100644
index 0000000..ea52c7a
--- /dev/null
+++ b/engines/mads/events.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_EVENTS_H
+#define MADS_EVENTS_H
+
+#include "common/scummsys.h"
+
+namespace MADS {
+
+class MADSEngine;
+
+class EventsManager {
+private:
+	MADSEngine *_vm;
+public:
+	EventsManager(MADSEngine *vm);
+
+	void handleEvents() { /* TODO */ }
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_EVENTS_H */
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 25730fa..9998bc0 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -20,35 +20,57 @@
  *
  */
 
-#include "mads/mads.h"
-#include "mads/sound.h"
 #include "common/scummsys.h"
 #include "common/config-manager.h"
 #include "common/debug-channels.h"
-#include "engines/util.h"
 #include "common/events.h"
+#include "engines/util.h"
+#include "mads/mads.h"
+#include "mads/resources.h"
+#include "mads/sound.h"
+#include "mads/msurface.h"
+#include "mads/msprite.h"
 
 namespace MADS {
 
-MADSEngine *g_vm;
-
 MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :
-		Engine(syst), _randomSource("MADS") {
-	DebugMan.addDebugChannel(kDebugPath, "Path", "Pathfinding debug level");
-	DebugMan.addDebugChannel(kDebugScripts, "scripts", "Game scripts");
+		_gameDescription(gameDesc), Engine(syst), _randomSource("MADS") {
+	
+	// Initialise fields
+	_easyMouse = true;
+	_invObjectStill = false;
+	_textWindowStill = false;
+	_palette = nullptr;
+	_resources = nullptr;
+	_screen = nullptr;
+	_sound = nullptr;
 }
 
 MADSEngine::~MADSEngine() {
+	delete _events;
+	delete _resources;
+	delete _screen;
+	delete _sound;
 }
 
 void MADSEngine::initialise() {
-	_soundManager.setVm(this, _mixer);
+	// Set up debug channels
+	DebugMan.addDebugChannel(kDebugPath, "Path", "Pathfinding debug level");
+	DebugMan.addDebugChannel(kDebugScripts, "scripts", "Game scripts");
+
+	// Initial sub-system engine references
+	MSurface::setVm(this);
+	MSprite::setVm(this);
+
+	_events = new EventsManager(this);
+	_resources = new ResourcesManager(this);
+	_screen = MSurface::init();
+	_sound = new SoundManager(this, _mixer);
 }
 
 Common::Error MADSEngine::run() {
 	initGraphics(320, 200, false);
 	initialise();
-	_soundManager.test();
 
 	Common::Event e;
 	while (!shouldQuit()) {
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index b54c46e..8ca181e 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -30,6 +30,9 @@
 #include "common/util.h"
 #include "engines/engine.h"
 #include "graphics/surface.h"
+#include "mads/events.h"
+#include "mads/msurface.h"
+#include "mads/resources.h"
 #include "mads/sound.h"
 
 /**
@@ -46,13 +49,22 @@ namespace MADS {
 #define DEBUG_INTERMEDIATE 2
 #define DEBUG_DETAILED 3
 
-#define MAX_RESOLVE 1000
-
 enum MADSDebugChannels {
 	kDebugPath      = 1 << 0,
 	kDebugScripts	= 1 << 1
 };
 
+enum {
+	GType_RexNebular = 0,
+	GType_DragonSphere = 1,
+	GType_Phantom = 2,
+	GType_Riddle = 3
+};
+
+enum {
+	GF_MADS = 1 << 0,
+	GF_M4 = 1 << 1
+};
 
 struct MADSGameDescription;
 
@@ -61,14 +73,27 @@ class MADSEngine : public Engine {
 private:
 	const MADSGameDescription *_gameDescription;
 	Common::RandomSource _randomSource;
-	SoundManager _soundManager;
 
+	bool _easyMouse;
+	bool _invObjectStill;
+	bool _textWindowStill;
+
+	/**
+	 * Handles basic initialisation
+	 */
 	void initialise();
 protected:
 	// Engine APIs
 	virtual Common::Error run();
 	virtual bool hasFeature(EngineFeature f) const;
 public:
+	EventsManager *_events;
+	Palette *_palette;
+	ResourcesManager *_resources;
+	MSurface *_screen;
+	SoundManager *_sound;
+
+public:
 	MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc);
 	virtual ~MADSEngine();
 
@@ -76,7 +101,8 @@ public:
 	Common::Language getLanguage() const;
 	Common::Platform getPlatform() const;
 	uint16 getVersion() const;
-	bool getIsDemo() const;
+	uint32 getGameID() const;
+	uint32 getGameFeatures() const;
 
 	int getRandomNumber(int maxNumber);
 };
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index d8a26a2..7ac919f 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -1,10 +1,17 @@
 MODULE := engines/mads
 
 MODULE_OBJS := \
+	compression.o \
 	detection.o \
+	events.o \
+	mads.o \
+	msprite.o \
+	msurface.o \
+	palette.o \
+	resources.o \
 	sound.o \
 	sound_nebular.o \
-	mads.o
+	sprite.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_MADS), DYNAMIC_PLUGIN)
diff --git a/engines/mads/msprite.cpp b/engines/mads/msprite.cpp
new file mode 100644
index 0000000..60c22d8
--- /dev/null
+++ b/engines/mads/msprite.cpp
@@ -0,0 +1,207 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "engines/util.h"
+#include "graphics/palette.h"
+#include "mads/mads.h"
+#include "mads/msurface.h"
+#include "mads/msprite.h"
+
+namespace MADS {
+
+enum {
+	kEndOfLine   = 0,
+	kEndOfSprite = 1,
+	kMarker = 2
+};
+
+MADSEngine *MSprite::_vm;
+
+MSprite *MSprite::init(MSurface &s) {
+	if (_vm->getGameFeatures() & GF_MADS) {
+		return new MSpriteMADS(s);
+	} else {
+		return new MSpriteM4(s);
+	}
+}
+
+MSprite *MSprite::init(Common::SeekableReadStream *source, const Common::Point &offset, 
+		int widthVal, int heightVal, bool decodeRle, uint8 encodingVal) {
+
+	if (_vm->getGameFeatures() & GF_MADS) {
+		return new MSpriteMADS(source, offset, widthVal, heightVal, decodeRle, encodingVal);
+	} else {
+		return new MSpriteM4(source, offset, widthVal, heightVal, decodeRle, encodingVal);
+	}
+}
+
+MSprite::MSprite(MSurface &s): _surface(s) {
+	_encoding = 0;
+}
+
+MSprite::MSprite(Common::SeekableReadStream *source, const Common::Point &offset, 
+		int widthVal, int heightVal, bool decodeRle, uint8 encodingVal)
+		: _surface(*MSurface::init(widthVal, heightVal)), 
+		_encoding(encodingVal), _offset(offset) {
+
+	// Load the sprite data
+	load(source, widthVal, heightVal, decodeRle);
+}
+
+MSprite::~MSprite() {
+}
+
+/*------------------------------------------------------------------------*/
+
+void MSpriteMADS::load(Common::SeekableReadStream *stream, int widthVal, int heightVal,
+		bool decodeRle) {
+	loadSprite(stream);
+}
+
+// TODO: The sprite outlines (pixel value 0xFD) are not shown
+void MSpriteMADS::loadSprite(Common::SeekableReadStream *source) {
+	byte *outp, *lineStart;
+	bool newLine = false;
+
+	outp = _surface.getData();
+	lineStart = _surface.getData();
+
+	while (1) {
+		byte cmd1, cmd2, count, pixel;
+
+		if (newLine) {
+			outp = lineStart + _surface.w;
+			lineStart = outp;
+			newLine = false;
+		}
+
+		cmd1 = source->readByte();
+
+		if (cmd1 == 0xFC)
+			break;
+		else if (cmd1 == 0xFF)
+			newLine = true;
+		else if (cmd1 == 0xFD) {
+			while (!newLine) {
+				count = source->readByte();
+				if (count == 0xFF) {
+					newLine = true;
+				} else {
+					pixel = source->readByte();
+					while (count--)
+						*outp++ = (pixel == 0xFD) ? 0 : pixel;
+				}
+			}
+		} else {
+			while (!newLine) {
+				cmd2 = source->readByte();
+				if (cmd2 == 0xFF) {
+					newLine = true;
+				} else if (cmd2 == 0xFE) {
+					count = source->readByte();
+					pixel = source->readByte();
+					while (count--)
+						*outp++ = (pixel == 0xFD) ? 0 : pixel;
+				} else {
+					*outp++ = (cmd2 == 0xFD) ? 0 : cmd2;
+				}
+			}
+		}
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+void MSpriteM4::load(Common::SeekableReadStream *stream, int widthVal, int heightVal,
+		bool decodeRle) {
+	if (decodeRle) {
+		loadRle(stream);
+	} else {
+		// Raw sprite data, load directly
+		byte *dst = _surface.getData();
+		stream->read(dst, widthVal * heightVal);
+	}
+}
+
+void MSpriteM4::loadRle(Common::SeekableReadStream* rleData) {
+	byte *dst = _surface.getData();
+	for (;;) {
+		byte len = rleData->readByte();
+		if (len == 0) {
+			len = rleData->readByte();
+			if (len <= kMarker) {
+				if (len == kEndOfSprite)
+					break;
+			} else {
+				while (len--) {
+					*dst++ = rleData->readByte();
+				}
+			}
+		} else {
+			byte value = rleData->readByte();
+			while (len--)
+				*dst++ = value;
+		}
+	}
+}
+
+void MSpriteM4::loadDeltaRle(Common::SeekableReadStream* rleData, int destX, int destY) {
+	int lineNum = 0;
+	byte *dst = _surface.getBasePtr(destX, destY);
+
+	for (;;) {
+		byte len = rleData->readByte();
+		if (len == 0) {
+			len = rleData->readByte();
+			if (len <= kMarker) {
+				if (len == kEndOfLine) {
+					dst = _surface.getBasePtr(destX, destY + lineNum);
+					lineNum++;
+				} else if (len == kEndOfSprite)
+					break;
+			} else {
+				while (len--) {
+					byte pixel = rleData->readByte();
+					if (pixel == 0)
+						dst++;
+					else
+						*dst++ = pixel;
+					/* NOTE: The change below behaved differently than the old code,
+					   so I put the old code back in again above.
+					   If the pixel value is 0, nothing should be written to the
+					   output buffer, since 0 means transparent. */
+					//*dst++ = (pixel == 0xFD) ? 0 : pixel;
+				}
+			}
+		} else {
+			byte value = rleData->readByte();
+			if (value == 0)
+				dst += len;
+			else
+				while (len--)
+					*dst++ = value;
+		}
+	}
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/msprite.h b/engines/mads/msprite.h
new file mode 100644
index 0000000..c49aac4
--- /dev/null
+++ b/engines/mads/msprite.h
@@ -0,0 +1,152 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_MSPRITE_H
+#define MADS_MSPRITE_H
+
+#include "common/scummsys.h"
+#include "mads/msurface.h"
+
+namespace MADS {
+
+class MADSEngine;
+
+struct BGR8 {
+	uint8 b, g, r;
+};
+
+typedef struct {
+	int32	x;			// x position relative	to GrBuff(0, 0)
+	int32	y;			// y position relative	to GrBuff(0, 0)
+	int32	scale_x;	// x scale factor (can be negative for reverse draw)
+	int32	scale_y;	// y scale factor (can't be negative)
+	uint8*	depth_map;	// depth code array for destination (doesn't care if srcDepth is 0)
+	BGR8*	Pal;		// palette for shadow draw (doesn't care if SHADOW bit is not set in Src.encoding)
+	uint8*	ICT;		// Inverse Color Table (doesn't care if SHADOW bit is not set in Src.encoding)
+	uint8	depth;		// depth code for source (0 if no depth processing)
+} DrawRequestX;
+
+typedef struct
+{
+	uint32 Pack;
+	uint32 Stream;
+	long   hot_x;
+	long   hot_y;
+	uint32 Width;
+	uint32 Height;
+	uint32 Comp;
+	uint32 Reserved[8];
+	uint8* data;
+} RendCell;
+
+#define SS_HEADER_NUM_FIELDS 14
+struct SpriteSeriesHeader {
+	uint32 header;
+	uint32 size;
+	uint32 packing;
+	uint32 frameRate;
+	uint32 pixSpeed;
+	uint32 maxWidth;
+	uint32 maxHeight;
+	uint32 reserved3;
+	uint32 reserved4;
+	uint32 reserved5;
+	uint32 reserved6;
+	uint32 reserved7;
+	uint32 reserved8;
+	uint32 count;
+};
+
+#define SF_HEADER_NUM_FIELDS 15
+struct SpriteFrameHeader {
+	uint32 pack;
+	uint32 stream;
+	uint32 x;
+	uint32 y;
+	uint32 width;
+	uint32 height;
+	uint32 comp;
+	uint32 reserved1;
+	uint32 reserved2;
+	uint32 reserved3;
+	uint32 reserved4;
+	uint32 reserved5;
+	uint32 reserved6;
+	uint32 reserved7;
+	uint32 reserved8;
+};
+
+class MSprite {
+public:
+	MSprite *init(MSurface &s);
+	MSprite *init(Common::SeekableReadStream *source, const Common::Point &offset, int widthVal, 
+		int heightVal, bool decodeRle = true, uint8 encodingVal = 0);
+protected:
+	static MADSEngine *_vm;
+
+	MSprite(MSurface &s);
+	MSprite(Common::SeekableReadStream *source, const Common::Point &offset, 
+		int widthVal, int heightVal, bool decodeRle = true, uint8 encodingVal = 0);
+
+	virtual void load(Common::SeekableReadStream *stream, int widthVal, int heightVal, bool decodeRle) {}
+public:
+	static void setVm(MADSEngine *vm) { _vm = vm; }
+	virtual ~MSprite();
+
+	MSurface &_surface;
+	Common::Point _pos;
+	Common::Point _offset;
+	uint8 _encoding;
+};
+
+class MSpriteMADS: public MSprite {
+	friend class MSprite;
+private:
+	void loadSprite(Common::SeekableReadStream *source);
+protected:
+	MSpriteMADS(MSurface &s): MSprite(s) {}
+	MSpriteMADS(Common::SeekableReadStream *source, const Common::Point &offset, 
+		int widthVal, int heightVal, bool decodeRle = true, uint8 encodingVal = 0):
+		MSprite(source, offset, widthVal, heightVal, decodeRle, encodingVal) {}
+
+	virtual void load(Common::SeekableReadStream *stream, int widthVal, int heightVal, bool decodeRle);
+};
+
+class MSpriteM4: public MSprite {
+	friend class MSprite;
+private:
+	// Loads a sprite from the given stream, and optionally decompresses the RLE-encoded data
+	// Loads an RLE compressed sprite; the surface must have been created before
+	void loadRle(Common::SeekableReadStream *rleData);
+	void loadDeltaRle(Common::SeekableReadStream *rleData, int destX, int destY);
+protected:
+	MSpriteM4(MSurface &s): MSprite(s) {}
+	MSpriteM4(Common::SeekableReadStream *source, const Common::Point &offset, 
+		int widthVal, int heightVal, bool decodeRle = true, uint8 encodingVal = 0):
+		MSprite(source, offset, widthVal, heightVal, decodeRle, encodingVal) {}
+
+	virtual void load(Common::SeekableReadStream *stream, int widthVal, int heightVal, bool decodeRle);
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_MSPRITE_H */
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
new file mode 100644
index 0000000..810f932
--- /dev/null
+++ b/engines/mads/msurface.cpp
@@ -0,0 +1,690 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 "engines/util.h"
+#include "mads/mads.h"
+#include "mads/compression.h"
+#include "mads/msurface.h"
+#include "mads/msprite.h"
+
+namespace MADS {
+
+MADSEngine *MSurface::_vm = nullptr;
+
+MSurface *MSurface::init(bool isScreen) {
+	if (_vm->getGameID() == GType_RexNebular) {
+		return new MSurfaceNebular(isScreen);
+	} else if (_vm->getGameFeatures() & GF_MADS) {
+		return new MSurfaceMADS(isScreen);
+	} else {
+		return new MSurfaceM4(isScreen);
+	}
+}
+
+MSurface *MSurface::init(int w, int h) {
+	if (_vm->getGameID() == GType_RexNebular) {
+		return new MSurfaceNebular(w, h);
+	} else if (_vm->getGameFeatures() & GF_MADS) {
+		return new MSurfaceMADS(w, h);
+	} else {
+		return new MSurfaceM4(w, h);
+	}
+}
+
+MSurface::MSurface(bool isScreen) { 
+	create(g_system->getWidth(), g_system->getHeight());
+	_isScreen = isScreen;
+}
+
+MSurface::MSurface(int Width, int Height) { 
+	create(Width, Height); 
+	_isScreen = false; 
+}
+
+void MSurface::vLine(int x, int y1, int y2) {
+	Graphics::Surface::vLine(x, y1, y2, _color);
+}
+
+void MSurface::hLine(int x1, int x2, int y) {
+	Graphics::Surface::hLine(x1, y, x2, _color);
+}
+
+void MSurface::vLineXor(int x, int y1, int y2) {
+	// Clipping
+	if (x < 0 || x >= w)
+		return;
+
+	if (y2 < y1)
+		SWAP(y2, y1);
+
+	if (y1 < 0)
+		y1 = 0;
+	if (y2 >= h)
+		y2 = h - 1;
+
+	byte *ptr = (byte *)getBasePtr(x, y1);
+	while (y1++ <= y2) {
+		*ptr ^= 0xFF;
+		ptr += pitch;
+	}
+
+}
+
+void MSurface::hLineXor(int x1, int x2, int y) {
+	// Clipping
+	if (y < 0 || y >= h)
+		return;
+
+	if (x2 < x1)
+		SWAP(x2, x1);
+
+	if (x1 < 0)
+		x1 = 0;
+	if (x2 >= w)
+		x2 = w - 1;
+
+	if (x2 < x1)
+		return;
+
+	byte *ptr = (byte *)getBasePtr(x1, y);
+	while (x1++ <= x2)
+		*ptr++ ^= 0xFF;
+
+}
+
+void MSurface::line(int x1, int y1, int x2, int y2, byte color) {
+	Graphics::Surface::drawLine(x1, y1, x2, y2, color);
+}
+
+
+void MSurface::frameRect(int x1, int y1, int x2, int y2) {
+	Graphics::Surface::frameRect(Common::Rect(x1, y1, x2, y2), _color);
+}
+
+void MSurface::fillRect(int x1, int y1, int x2, int y2) {
+	Graphics::Surface::fillRect(Common::Rect(x1, y1, x2, y2), _color);
+}
+
+int MSurface::scaleValue(int value, int scale, int err) {
+	int scaled = 0;
+	while (value--) {
+		err -= scale;
+		while (err < 0) {
+			scaled++;
+			err += 100;
+		}
+	}
+	return scaled;
+}
+
+void MSurface::drawSprite(int x, int y, SpriteInfo &info, const Common::Rect &clipRect) {
+
+	enum {
+		kStatusSkip,
+		kStatusScale,
+		kStatusDraw
+	};
+
+	// NOTE: The current clipping code assumes that the top left corner of the clip
+	// rectangle is always 0, 0
+	assert(clipRect.top == 0 && clipRect.left == 0);
+
+	// TODO: Put err* and scaled* into SpriteInfo
+	int errX = info.hotX * info.scaleX % 100;
+	int errY = info.hotY * info.scaleY % 100;
+	int scaledWidth = scaleValue(info.width, info.scaleX, errX);
+	int scaledHeight = scaleValue(info.height, info.scaleY, errY);
+
+	/*
+	printf("MSurface::drawSprite() info.width = %d; info.scaleX = %d; info.height = %d; info.scaleY = %d; scaledWidth = %d; scaledHeight = %d\n",
+		info.width, info.scaleX, info.height, info.scaleY, scaledWidth, scaledHeight); fflush(stdout);
+	*/
+	
+	int clipX = 0, clipY = 0;
+	// Clip the sprite's width and height according to the clip rectangle's dimensions
+	// This clips the sprite to the bottom and right
+	if (x >= 0) {
+		scaledWidth = MIN<int>(x + scaledWidth, clipRect.right) - x;
+	} else {
+		clipX = x;
+		scaledWidth = x + scaledWidth;
+	}
+	if (y >= 0) {
+		scaledHeight = MIN<int>(y + scaledHeight, clipRect.bottom) - y;
+	} else {
+		clipY = y;
+		scaledHeight = y + scaledHeight;
+	}
+
+	//printf("MSurface::drawSprite() width = %d; height = %d; scaledWidth = %d; scaledHeight = %d\n", info.width, info.height, scaledWidth, scaledHeight); fflush(stdout);
+
+	// Check if sprite is inside the screen. If it's not, there's no need to draw it
+	if (scaledWidth + x <= 0 || scaledHeight + y <= 0)	// check left and top (in case x,y are negative)
+		return;
+	if (scaledWidth <= 0 || scaledHeight <= 0)			// check right and bottom
+		return;
+	int heightAmt = scaledHeight;
+
+	byte *src = info.sprite->_surface.getData();
+	byte *dst = getBasePtr(x - info.hotX - clipX, y - info.hotY - clipY);
+
+	int status = kStatusSkip;
+	byte *scaledLineBuf = new byte[scaledWidth];
+
+	while (heightAmt > 0) {
+
+		if (status == kStatusSkip) {
+			// Skip line
+			errY -= info.scaleY;
+			if (errY < 0)
+				status = kStatusScale;
+			else
+				src += info.width;
+		} else {
+
+			if (status == kStatusScale) {
+				// Scale current line
+				byte *lineDst = scaledLineBuf;
+				int curErrX = errX;
+				int widthVal = scaledWidth;
+				byte *tempSrc = src;
+				int startX = clipX;
+				while (widthVal > 0) {
+					byte pixel = *tempSrc++;
+					curErrX -= info.scaleX;
+					while (curErrX < 0) {
+						if (startX == 0) {
+							*lineDst++ = pixel;
+							widthVal--;
+						} else {
+							startX++;
+						}
+						curErrX += 100;
+					}
+				}
+				src += info.width;
+				status = kStatusDraw;
+			}
+
+			if (status == kStatusDraw && clipY == 0) {
+				// Draw previously scaled line
+				// TODO Implement different drawing types (depth, shadow etc.)
+				byte *tempDst = dst;
+				for (int lineX = 0; lineX < scaledWidth; lineX++) {
+					byte pixel = scaledLineBuf[lineX];
+
+					if (info.encoding & 0x80) {
+
+						if (pixel == 0x80) {
+							pixel = 0;
+						} else {
+							byte destPixel = *tempDst;
+							byte r, g, b;
+							r = CLIP((info.palette[destPixel].r * pixel) >> 10, 0, 31);
+							g = CLIP((info.palette[destPixel].g * pixel) >> 10, 0, 31);
+							b = CLIP((info.palette[destPixel].b * pixel) >> 10, 0, 31);
+							pixel = info.inverseColorTable[(b << 10) | (g << 5) | r];
+						}
+					}
+
+					if (pixel)
+						*tempDst = pixel;
+
+					tempDst++;
+				}
+				dst += pitch;
+				heightAmt--;
+				// TODO depth etc.
+				//depthAddress += Destination -> Width;
+
+				errY += 100;
+				if (errY >= 0)
+					status = kStatusSkip;
+			} else if (status == kStatusDraw && clipY < 0) {
+				clipY++;
+
+				errY += 100;
+				if (errY >= 0)
+					status = kStatusSkip;
+			}
+
+		}
+
+	}
+	
+	delete[] scaledLineBuf;
+
+}
+
+// Surface methods
+
+byte *MSurface::getData() {
+	return (byte *)Graphics::Surface::getPixels();
+}
+
+byte *MSurface::getBasePtr(int x, int y) {
+	return (byte *)Graphics::Surface::getBasePtr(x, y);
+}
+
+void MSurface::freeData() {
+}
+
+void MSurface::empty() {
+	Common::fill(getBasePtr(0, 0), getBasePtr(w, h), _vm->_palette->BLACK);
+}
+
+void MSurface::frameRect(const Common::Rect &r, uint8 color) {
+	Graphics::Surface::frameRect(r, color);
+}
+
+void MSurface::fillRect(const Common::Rect &r, uint8 color) {
+	Graphics::Surface::fillRect(r, color);
+}
+
+void MSurface::copyFrom(MSurface *src, const Common::Rect &srcBounds, int destX, int destY,
+						 int transparentColor) {
+	// Validation of the rectangle and position
+	if ((destX >= w) || (destY >= h))
+		return;
+
+	Common::Rect copyRect = srcBounds;
+	if (destX < 0) {
+		copyRect.left += -destX;
+		destX = 0;
+	} else if (destX + copyRect.width() > w) {
+		copyRect.right -= destX + copyRect.width() - w;
+	}
+	if (destY < 0) {
+		copyRect.top += -destY;
+		destY = 0;
+	} else if (destY + copyRect.height() > h) {
+		copyRect.bottom -= destY + copyRect.height() - h;
+	}
+
+	if (!copyRect.isValidRect())
+		return;
+
+	// Copy the specified area
+
+	byte *data = src->getData();
+	byte *srcPtr = data + (src->width() * copyRect.top + copyRect.left);
+	byte *destPtr = (byte *)pixels + (destY * width()) + destX;
+
+	for (int rowCtr = 0; rowCtr < copyRect.height(); ++rowCtr) {
+		if (transparentColor == -1)
+			// No transparency, so copy line over
+			Common::copy(srcPtr, srcPtr + copyRect.width(), destPtr);
+		else {
+			// Copy each byte one at a time checking for the transparency color
+			for (int xCtr = 0; xCtr < copyRect.width(); ++xCtr)
+				if (srcPtr[xCtr] != transparentColor) destPtr[xCtr] = srcPtr[xCtr];
+		}
+
+		srcPtr += src->width();
+		destPtr += width();
+	}
+
+	src->freeData();
+}
+
+#undef COL_TRANS
+
+void MSurface::translate(RGBList *list, bool isTransparent) {
+	byte *p = getBasePtr(0, 0);
+	byte *palIndexes = list->palIndexes();
+
+	for (int i = 0; i < width() * height(); ++i, ++p) {
+		if (!isTransparent || (*p != 0)) {
+			assert(*p < list->size());
+			*p = palIndexes[*p];
+		}
+	}
+
+	freeData();
+}
+
+/*------------------------------------------------------------------------*/
+
+void MSurfaceMADS::loadCodes(Common::SeekableReadStream *source) {
+	if (!source) {
+		free();
+		return;
+	}
+
+	uint16 widthVal = 320;
+	uint16 heightVal = 156;
+	byte *walkMap = new byte[source->size()];
+
+	create(widthVal, heightVal);
+	source->read(walkMap, source->size());
+
+	byte *ptr = (byte *)getBasePtr(0, 0);
+
+	for (int y = 0; y < heightVal; y++) {
+		for (int x = 0; x < widthVal; x++) {
+			int ofs = x + (y * widthVal);
+			if ((walkMap[ofs / 8] << (ofs % 8)) & 0x80)
+				*ptr++ = 1;		// walkable
+			else
+				*ptr++ = 0;
+		}
+	}
+}
+
+void MSurfaceMADS::loadBackground(int roomNumber, RGBList **palData) {
+	// clear previous data
+	empty();
+
+	// Get a MadsPack reference to the tile set and mapping
+	char resourceName[20];
+	int i;
+
+	// Uncompressed tile map resource
+	sprintf(resourceName, "rm%d.mm", roomNumber);
+	MadsPack tileMapFile(resourceName, _vm);
+	Common::SeekableReadStream *mapStream = tileMapFile.getItemStream(0);
+
+	// Get the details of the tiles and map
+	mapStream->readUint32LE();
+	int tileCountX = mapStream->readUint16LE();
+	int tileCountY = mapStream->readUint16LE();
+	int tileWidthMap = mapStream->readUint16LE();
+	int tileHeightMap = mapStream->readUint16LE();
+	int screenWidth = mapStream->readUint16LE();
+	int screenHeight = mapStream->readUint16LE();
+	int tileCountMap = tileCountX * tileCountY;
+	delete mapStream;
+
+	// Obtain tile map information
+	typedef Common::List<Common::SharedPtr<MSurface> > TileSetList;
+	typedef TileSetList::iterator TileSetIterator;
+	TileSetList tileSet;
+	uint16 *tileMap = new uint16[tileCountMap];
+	mapStream = tileMapFile.getItemStream(1);
+	for (i = 0; i < tileCountMap; ++i)
+		tileMap[i] = mapStream->readUint16LE();
+	delete mapStream;
+
+	_vm->_resources->toss(resourceName);
+
+	// --------------------------------------------------------------------------------
+
+	// Tile map data, which needs to be kept compressed, as the tile offsets refer to
+	// the compressed data. Each tile is then uncompressed separately
+	sprintf(resourceName, "rm%d.tt", roomNumber);
+	Common::SeekableReadStream *tileDataComp = _vm->_resources->get(resourceName);
+	MadsPack tileData(tileDataComp);
+	Common::SeekableReadStream *tileDataUncomp = tileData.getItemStream(0);
+
+	// Validate that the data matches between the tiles and tile map file and is valid
+	int tileCount = tileDataUncomp->readUint16LE();
+	int tileWidth = tileDataUncomp->readUint16LE();
+	int tileHeight = tileDataUncomp->readUint16LE();
+	delete tileDataUncomp;
+	assert(tileCountMap == tileCount);
+	assert(tileWidth == tileWidthMap);
+	assert(tileHeight == tileHeightMap);
+	assert(screenWidth == _vm->_screen->width());
+	assert(screenHeight <= _vm->_screen->height());
+
+	// --------------------------------------------------------------------------------
+
+	// Get the palette to use
+	tileDataUncomp = tileData.getItemStream(2);
+	// Set palette
+	if (!palData) {
+		_vm->_palette->setMadsPalette(tileDataUncomp, 4);
+	} else {
+		int numColors;
+		RGB8 *rgbList = _vm->_palette->decodeMadsPalette(tileDataUncomp, &numColors);
+		*palData = new RGBList(numColors, rgbList, true);
+	}
+	delete tileDataUncomp;
+
+	// --------------------------------------------------------------------------------
+
+	// Get tile data
+
+	tileDataUncomp = tileData.getItemStream(1);
+	FabDecompressor fab;
+	uint32 compressedTileDataSize = 0;
+
+	for (i = 0; i < tileCount; i++) {
+		tileDataUncomp->seek(i * 4, SEEK_SET);
+		uint32 tileOfs = tileDataUncomp->readUint32LE();
+		MSurface *newTile = MSurface::init(tileWidth, tileHeight);
+
+		if (i == tileCount - 1)
+			compressedTileDataSize = tileDataComp->size() - tileOfs;
+		else
+			compressedTileDataSize = tileDataUncomp->readUint32LE() - tileOfs;
+
+		//printf("Tile: %i, compressed size: %i\n", i, compressedTileDataSize);
+
+		newTile->empty();
+
+		byte *compressedTileData = new byte[compressedTileDataSize];
+
+		tileDataComp->seek(tileData.getDataOffset() + tileOfs, SEEK_SET);
+		tileDataComp->read(compressedTileData, compressedTileDataSize);
+
+		fab.decompress(compressedTileData, compressedTileDataSize, newTile->getData(), 
+			tileWidth * tileHeight);
+		tileSet.push_back(TileSetList::value_type(newTile));
+		delete[] compressedTileData;
+	}
+
+	delete tileDataUncomp;
+
+	// --------------------------------------------------------------------------------
+
+	// Loop through the mapping data to place the tiles on the screen
+	
+	uint16 *tIndex = &tileMap[0];
+	for (int y = 0; y < tileCountY; y++) {
+		for (int x = 0; x < tileCountX; x++) {
+			int tileIndex = *tIndex++;
+			assert(tileIndex < tileCount);
+			TileSetIterator tile = tileSet.begin();
+			for (i = 0; i < tileIndex; i++)
+				++tile;
+			((*tile).get())->copyTo(this, x * tileWidth, y * tileHeight);
+		}
+	}
+	tileSet.clear();
+	_vm->_resources->toss(resourceName);
+}
+
+void MSurfaceMADS::loadInterface(int index, RGBList **palData) {
+	char resourceName[20];
+	sprintf(resourceName, "i%d.int", index);
+	MadsPack intFile(resourceName, _vm);
+	RGB8 *palette = new RGB8[16];
+
+	// Chunk 0, palette
+	Common::SeekableReadStream *intStream = intFile.getItemStream(0);
+	
+	for (int i = 0; i < 16; i++) {
+		palette[i].r = intStream->readByte() << 2;
+		palette[i].g = intStream->readByte() << 2;
+		palette[i].b = intStream->readByte() << 2;
+		intStream->readByte();
+		intStream->readByte();
+		intStream->readByte();
+	}
+	*palData = new RGBList(16, palette, true);
+	delete intStream;
+
+	// Chunk 1, data
+	intStream = intFile.getItemStream(1);
+	create(320, 44);
+	intStream->read(pixels, 320 * 44);
+	delete intStream;
+}
+
+/*------------------------------------------------------------------------*/
+
+void MSurfaceNebular::loadBackground(int roomNumber, RGBList **palData) {
+	// clear previous data
+	empty();
+
+	Common::String resourceName = Common::String::format("rm%d.art", roomNumber);
+	Common::SeekableReadStream *stream = _vm->_resources->get(resourceName);	
+	loadBackgroundStream(stream, palData);
+
+	_vm->_resources->toss(resourceName);
+}
+
+void MSurfaceNebular::loadBackgroundStream(Common::SeekableReadStream *source, RGBList **palData) {
+	MadsPack packData(source);
+	Common::MemoryReadStream *sourceUnc = packData.getItemStream(0);
+
+	int sceneWidth = sourceUnc->readUint16LE();
+	int sceneHeight = sourceUnc->readUint16LE();
+	int sceneSize = sceneWidth * sceneHeight;
+	if (sceneWidth > this->width()) {
+		warning("Background width is %i, too large to fit in screen. Setting it to %i", sceneWidth, this->width());
+		sceneWidth = this->width();
+		sceneSize = sceneWidth * sceneHeight;
+	}
+	if (sceneHeight > this->height()) {
+		warning("Background height is %i, too large to fit in screen.Setting it to %i", sceneHeight, this->height());
+		sceneHeight = this->height();
+		sceneSize = sceneWidth * sceneHeight;
+	}
+
+	// Set palette
+	if (!palData) {
+		_vm->_palette->setMadsPalette(sourceUnc, 4);
+	} else {
+		int numColors;
+		RGB8 *rgbList = _vm->_palette->decodeMadsPalette(sourceUnc, &numColors);
+		*palData = new RGBList(numColors, rgbList, true);
+	}
+	delete sourceUnc;
+
+	// Get the raw data for the background
+	sourceUnc = packData.getItemStream(1);
+	assert((int)sourceUnc->size() >= sceneSize);
+
+	byte *pData = (byte *)pixels;
+	sourceUnc->read(pData, sceneSize);
+	
+	freeData();
+	delete sourceUnc;
+}
+
+/*------------------------------------------------------------------------*/
+
+void MSurfaceM4::loadCodes(Common::SeekableReadStream *source) {
+	if (!source) {
+		free();
+		return;
+	}
+
+	uint16 widthVal = source->readUint16LE();
+	uint16 heightVal = source->readUint16LE();
+
+	create(widthVal, heightVal);
+	source->read(pixels, widthVal * heightVal);
+}
+
+void MSurfaceM4::loadBackground(int roomNumber, RGBList **palData) {
+	if (palData)
+		*palData = NULL;
+	Common::String resourceName = Common::String::format("%i.tt", roomNumber);
+	Common::SeekableReadStream *stream = _vm->_resources->get(resourceName);	
+	loadBackgroundStream(stream);
+
+	_vm->_resources->toss(resourceName);
+}
+
+void MSurfaceM4::loadBackgroundStream(Common::SeekableReadStream *source) {
+	MSurface *tileBuffer = MSurface::init();
+	uint curTileX = 0, curTileY = 0;
+	int clipX = 0, clipY = 0;
+	RGB8 palette[256];
+
+	source->skip(4);
+	/*uint32 size =*/ source->readUint32LE();
+	uint32 widthVal = source->readUint32LE();
+	uint32 heightVal = source->readUint32LE();
+	uint32 tilesX = source->readUint32LE();
+	uint32 tilesY = source->readUint32LE();
+	uint32 tileWidth = source->readUint32LE();
+	uint32 tileHeight = source->readUint32LE();
+	uint8 blackIndex = 0;
+
+	// BGR data, which is converted to RGB8
+	for (uint i = 0; i < 256; i++) {
+		palette[i].b = source->readByte() << 2;
+		palette[i].g = source->readByte() << 2;
+		palette[i].r = source->readByte() << 2;
+		palette[i].u = source->readByte() << 2;
+
+		if ((blackIndex == 0) && !palette[i].r && !palette[i].g && !palette[i].b)
+			blackIndex = i;
+	}
+	
+	_vm->_palette->setPalette(palette, 0, 256);
+
+	// resize or create the surface
+	// Note that the height of the scene in game scenes is smaller than the screen height, 
+	// as the bottom part of the screen is the inventory
+	assert(width() == (int)widthVal);
+
+	tileBuffer->create(tileWidth, tileHeight);
+
+	for (curTileY = 0; curTileY < tilesY; curTileY++) {
+		clipY = MIN(heightVal, (1 + curTileY) * tileHeight) - (curTileY * tileHeight);
+
+		for (curTileX = 0; curTileX < tilesX; curTileX++) {
+			clipX = MIN(widthVal, (1 + curTileX) * tileWidth) - (curTileX * tileWidth);
+
+			// Read a tile and copy it to the destination surface
+			source->read(tileBuffer->getData(), tileWidth * tileHeight);
+			Common::Rect srcBounds(0, 0, clipX, clipY);
+			copyFrom(tileBuffer, srcBounds, curTileX * tileWidth, curTileY * tileHeight);
+		}
+	}
+
+	if (heightVal < (uint)height())
+		fillRect(Common::Rect(0, heightVal, width(), height()), blackIndex);
+
+	delete tileBuffer;
+}
+
+/*------------------------------------------------------------------------*/
+
+void MSurfaceRiddle::loadBackground(const Common::String &sceneName) {
+	char resourceName[20];
+	Common::SeekableReadStream *stream;
+	// Loads a Riddle scene
+	Common::String resName = Common::String::format("%s.tt", sceneName.c_str());
+	stream = _vm->_resources->get(resourceName);
+
+	loadBackgroundStream(stream);
+
+	_vm->_resources->toss(resourceName);
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
new file mode 100644
index 0000000..9bb651b
--- /dev/null
+++ b/engines/mads/msurface.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_MSURFACE_H
+#define MADS_MSURFACE_H
+
+#include "common/scummsys.h"
+#include "common/rect.h"
+#include "graphics/surface.h"
+#include "mads/palette.h"
+
+namespace MADS {
+
+class MADSEngine;
+class MSprite;
+
+struct SpriteInfo {
+	MSprite *sprite;
+	int hotX, hotY;
+	int width, height;
+	int scaleX, scaleY;
+	uint8 encoding;
+	byte *inverseColorTable;
+	RGB8 *palette;
+};
+
+class MSurface : public Graphics::Surface {
+public:
+	static MADSEngine *_vm;
+
+	/**
+	 * Sets the engine reference
+	 */
+	static void setVm(MADSEngine *vm) { _vm = vm; }
+
+	/**
+	 * Create a new surface the same size as the screen.
+	 * @param isScreen		Set to true for the screen surface
+	 */
+	static MSurface *init(bool isScreen = false);
+
+	/**
+	 * Create a surface
+	 */
+	static MSurface *init(int w, int h);
+private:
+	byte _color;
+	bool _isScreen;
+protected:
+	MSurface(bool isScreen = false);
+	MSurface(int w, int h);
+public:
+	void create(int w, int h) {
+		Graphics::Surface::create(w, h, Graphics::PixelFormat::createFormatCLUT8());
+	}
+
+	void setColor(byte value) { _color = value; }
+	byte getColor() { return _color; }
+	void vLine(int x, int y1, int y2);
+	void hLine(int x1, int x2, int y);
+	void vLineXor(int x, int y1, int y2);
+	void hLineXor(int x1, int x2, int y);
+	void line(int x1, int y1, int x2, int y2, byte color);
+	void frameRect(int x1, int y1, int x2, int y2);
+	void fillRect(int x1, int y1, int x2, int y2);
+
+	static int scaleValue(int value, int scale, int err);	
+	void drawSprite(int x, int y, SpriteInfo &info, const Common::Rect &clipRect);
+
+	// Surface methods
+	int width() { return w; }
+	int height() { return h; }
+	void setSize(int sizeX, int sizeY);
+	byte *getData();
+	byte *getBasePtr(int x, int y);
+	void freeData();
+	void empty();
+	void frameRect(const Common::Rect &r, uint8 color);
+	void fillRect(const Common::Rect &r, uint8 color);
+	void copyFrom(MSurface *src, const Common::Rect &srcBounds, int destX, int destY,
+		int transparentColor = -1);
+
+	void update() { 
+		if (_isScreen) {
+			g_system->copyRectToScreen((const byte *)pixels, pitch, 0, 0, w, h);
+			g_system->updateScreen(); 
+		}
+	}
+
+	// copyTo methods
+	void copyTo(MSurface *dest, int transparentColor = -1) { 
+		dest->copyFrom(this, Common::Rect(width(), height()), 0, 0, transparentColor);		
+	}
+	void copyTo(MSurface *dest, int x, int y, int transparentColor = -1) {
+		dest->copyFrom(this, Common::Rect(width(), height()), x, y, transparentColor);
+	}
+	void copyTo(MSurface *dest, const Common::Rect &srcBounds, int destX, int destY,
+				int transparentColor = -1) {
+		dest->copyFrom(this, srcBounds, destX, destY, transparentColor);
+	}
+
+	void translate(RGBList *list, bool isTransparent = false);
+
+	// Base virtual methods
+	virtual void loadBackground(const Common::String &sceneName) {}
+	virtual void loadBackground(int roomNumber, RGBList **palData) = 0;
+	virtual void loadBackground(Common::SeekableReadStream *source, RGBList **palData) {}
+	virtual void loadCodes(Common::SeekableReadStream *source) = 0;
+	virtual void loadInterface(int index, RGBList **palData) {}
+};
+
+class MSurfaceMADS: public MSurface {
+	friend class MSurface;
+protected:
+	MSurfaceMADS(bool isScreen = false): MSurface(isScreen) {}
+	MSurfaceMADS(int w, int h): MSurface(w, h) {}
+public:
+	virtual void loadCodes(Common::SeekableReadStream *source);
+	virtual void loadBackground(const Common::String &sceneName) {}
+	virtual void loadBackground(int roomNumber, RGBList **palData);
+	virtual void loadInterface(int index, RGBList **palData);
+};
+
+class MSurfaceNebular: public MSurfaceMADS {
+	friend class MSurface;
+protected:
+	MSurfaceNebular(bool isScreen = false): MSurfaceMADS(isScreen) {}
+	MSurfaceNebular(int w, int h): MSurfaceMADS(w, h) {}
+private:
+	void loadBackgroundStream(Common::SeekableReadStream *source, RGBList **palData);
+public:
+	virtual void loadBackground(int roomNumber, RGBList **palData);
+};
+
+class MSurfaceM4: public MSurface {
+	friend class MSurface;
+protected:
+	MSurfaceM4(bool isScreen = false): MSurface(isScreen) {}
+	MSurfaceM4(int w, int h): MSurface(w, h) {}
+
+	void loadBackgroundStream(Common::SeekableReadStream *source);
+public:
+	virtual void loadCodes(Common::SeekableReadStream *source);
+	virtual void loadBackground(int roomNumber, RGBList **palData);
+};
+
+class MSurfaceRiddle: public MSurfaceM4 {
+	friend class MSurface;
+protected:
+	MSurfaceRiddle(bool isScreen = false): MSurfaceM4(isScreen) {}
+	MSurfaceRiddle(int w, int h): MSurfaceM4(w, h) {}
+public:
+	virtual void loadBackground(const Common::String &sceneName);
+};
+/*
+	void rexLoadBackground(Common::SeekableReadStream *source, RGBList **palData = NULL);
+	void madsLoadBackground(int roomNumber, RGBList **palData = NULL);
+	void m4LoadBackground(Common::SeekableReadStream *source);
+
+	void madsloadInterface(int index, RGBList **palData);
+	
+	*/
+
+} // End of namespace MADS
+
+#endif /* MADS_MSURFACE_H */
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
new file mode 100644
index 0000000..cfd8568
--- /dev/null
+++ b/engines/mads/palette.cpp
@@ -0,0 +1,289 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "engines/util.h"
+#include "graphics/palette.h"
+#include "mads/mads.h"
+#include "mads/msurface.h"
+
+namespace MADS {
+
+RGBList::RGBList(int numEntries, RGB8 *srcData, bool freeData) {
+	_size = numEntries;
+	assert(numEntries <= 256);
+
+	if (srcData == NULL) {
+		_data = new RGB8[numEntries];
+		_freeData = true;
+	} else {
+		_data = srcData;
+		_freeData = freeData;
+	}
+
+	_palIndexes = new byte[numEntries];
+	Common::fill(&_palIndexes[0], &_palIndexes[numEntries], 0);
+}
+
+RGBList::~RGBList() {
+	if (_freeData)
+		delete[] _data;
+	delete[] _palIndexes;
+}
+
+/*------------------------------------------------------------------------*/
+
+#define VGA_COLOR_TRANS(x) (x == 0x3f ? 255 : x << 2)
+
+Palette::Palette(MADSEngine *vm) : _vm(vm) {
+	reset();
+	_fading_in_progress = false;
+	Common::fill(&_usageCount[0], &_usageCount[256], 0);
+}
+
+void Palette::setPalette(const byte *colors, uint start, uint num) {
+	g_system->getPaletteManager()->setPalette(colors, start, num);
+	reset();
+}
+
+void Palette::setPalette(const RGB8 *colors, uint start, uint num) {
+	g_system->getPaletteManager()->setPalette((const byte *)colors, start, num);
+	reset();
+}
+
+void Palette::grabPalette(byte *colors, uint start, uint num) {
+	g_system->getPaletteManager()->grabPalette(colors, start, num);
+	reset();
+}
+
+uint8 Palette::palIndexFromRgb(byte r, byte g, byte b, RGB8 *paletteData) {
+	byte index = 0;
+	int32 minDist = 0x7fffffff;
+	RGB8 palData[256];
+	int Rdiff, Gdiff, Bdiff;
+
+	if (paletteData == NULL) {
+		g_system->getPaletteManager()->grabPalette((byte *)palData, 0, 256);
+		paletteData = &palData[0];
+	}
+
+	for (int palIndex = 0; palIndex < 256; ++palIndex) {
+		Rdiff = r - paletteData[palIndex].r;
+		Gdiff = g - paletteData[palIndex].g;
+		Bdiff = b - paletteData[palIndex].b;
+
+		if (Rdiff * Rdiff + Gdiff * Gdiff + Bdiff * Bdiff < minDist) {
+			minDist = Rdiff * Rdiff + Gdiff * Gdiff + Bdiff * Bdiff;
+			index = (uint8)palIndex;
+		}
+	}
+
+	return (uint8)index;
+}
+
+void Palette::reset() {
+	RGB8 palData[256];
+	g_system->getPaletteManager()->grabPalette((byte *)palData, 0, 256);
+
+	BLACK = palIndexFromRgb(0, 0, 0, palData);
+	BLUE = palIndexFromRgb(0, 0, 255, palData);
+	GREEN = palIndexFromRgb(0, 255, 0, palData);
+	CYAN = palIndexFromRgb(0, 255, 255, palData);
+	RED = palIndexFromRgb(255, 0, 0, palData);
+	VIOLET = palIndexFromRgb(255, 0, 255, palData);
+	BROWN = palIndexFromRgb(168, 84, 84, palData);
+	LIGHT_GRAY = palIndexFromRgb(168, 168, 168, palData);
+	DARK_GRAY = palIndexFromRgb(84, 84, 84, palData);
+	LIGHT_BLUE = palIndexFromRgb(0, 0, 127, palData);
+	LIGHT_GREEN = palIndexFromRgb(0, 127, 0, palData);
+	LIGHT_CYAN = palIndexFromRgb(0, 127, 127, palData);
+	LIGHT_RED = palIndexFromRgb(84, 0, 0, palData);
+	PINK = palIndexFromRgb(84, 0, 0, palData);
+	YELLOW = palIndexFromRgb(0, 84, 84, palData);
+	WHITE = palIndexFromRgb(255, 255, 255, palData);
+}
+
+void Palette::fadeIn(int numSteps, uint delayAmount, RGBList *destPalette) {
+	fadeIn(numSteps, delayAmount, destPalette->data(), destPalette->size());
+}
+
+void Palette::fadeIn(int numSteps, uint delayAmount, RGB8 *destPalette, int numColors) {
+	if (_fading_in_progress)
+		return;
+
+	_fading_in_progress = true;
+	RGB8 blackPalette[256];
+	Common::fill((byte *)&blackPalette[0], (byte *)&blackPalette[256], 0);
+
+	// Initially set the black palette
+	_vm->_palette->setPalette(blackPalette, 0, numColors);
+
+	// Handle the actual fading
+	fadeRange(blackPalette, destPalette, 0, numColors - 1, numSteps, delayAmount);
+
+	_fading_in_progress = false;
+}
+
+RGB8 *Palette::decodeMadsPalette(Common::SeekableReadStream *palStream, int *numColors) {
+	*numColors = palStream->readUint16LE();
+	assert(*numColors <= 252);
+
+	RGB8 *palData = new RGB8[*numColors];
+	Common::fill((byte *)&palData[0], (byte *)&palData[*numColors], 0);
+
+	for (int i = 0; i < *numColors; ++i) {
+		byte r = palStream->readByte();
+		byte g = palStream->readByte();
+		byte b = palStream->readByte();
+		palData[i].r = VGA_COLOR_TRANS(r);
+		palData[i].g = VGA_COLOR_TRANS(g);
+		palData[i].b = VGA_COLOR_TRANS(b);
+
+		// The next 3 bytes are unused
+		palStream->skip(3);
+	}
+
+	return palData;
+}
+
+int Palette::setMadsPalette(Common::SeekableReadStream *palStream, int indexStart) {
+	int colorCount;
+	RGB8 *palData = Palette::decodeMadsPalette(palStream, &colorCount);
+	_vm->_palette->setPalette(palData, indexStart, colorCount);
+	delete palData;
+	return colorCount;
+}
+
+void Palette::setMadsSystemPalette() {
+	// Rex Nebular default system palette
+	resetColorCounts();
+
+	RGB8 palData[4];
+	palData[0].r = palData[0].g = palData[0].b = 0;
+	palData[1].r = palData[1].g = palData[1].b = 0x54;
+	palData[2].r = palData[2].g = palData[2].b = 0xb4;
+	palData[3].r = palData[3].g = palData[3].b = 0xff;
+	
+	setPalette(palData, 0, 4);
+	blockRange(0, 4);
+}
+
+void Palette::resetColorCounts() {
+	Common::fill(&_usageCount[0], &_usageCount[256], 0);
+}
+
+void Palette::blockRange(int startIndex, int size) {
+	// Use a reference count of -1 to signal a palette index shouldn't be used
+	Common::fill(&_usageCount[startIndex], &_usageCount[startIndex + size], -1);
+}
+
+void Palette::addRange(RGBList *list) {
+	RGB8 *data = list->data();
+	byte *palIndexes = list->palIndexes();
+	RGB8 palData[256];
+	g_system->getPaletteManager()->grabPalette((byte *)&palData[0], 0, 256);
+	bool paletteChanged = false;
+	
+	for (int colIndex = 0; colIndex < list->size(); ++colIndex) {
+		// Scan through for an existing copy of the RGB value
+		int palIndex = -1; 
+		while (++palIndex < 256) {
+			if (_usageCount[palIndex] <= 0)
+				// Palette index is to be skipped
+				continue;
+
+			if ((palData[palIndex].r == data[colIndex].r) && 
+				(palData[palIndex].g == data[colIndex].g) &&
+				(palData[palIndex].b == data[colIndex].b)) 
+				// Match found
+				break;
+		}
+
+		if (palIndex == 256) {
+			// No match found, so find a free slot to use
+			palIndex = -1;
+			while (++palIndex < 256) {
+				if (_usageCount[palIndex] == 0)
+					break;
+			}
+
+			if (palIndex == 256) 
+				error("addRange - Ran out of palette space to allocate");
+
+			palData[palIndex].r = data[colIndex].r;
+			palData[palIndex].g = data[colIndex].g;
+			palData[palIndex].b = data[colIndex].b;
+			paletteChanged = true;
+		}
+
+		palIndexes[colIndex] = palIndex;
+		++_usageCount[palIndex];
+	}
+
+	if (paletteChanged) {
+		g_system->getPaletteManager()->setPalette((byte *)&palData[0], 0, 256);
+		reset();
+	}
+}
+
+void Palette::deleteRange(RGBList *list) {
+	// Release the reference count on each of the palette entries
+	for (int colIndex = 0; colIndex < list->size(); ++colIndex) {
+		int palIndex = list->palIndexes()[colIndex];
+		assert(_usageCount[palIndex] > 0);
+		--_usageCount[palIndex];
+	}
+}
+
+void Palette::deleteAllRanges() {
+	for (int colIndex = 0; colIndex < 255; ++colIndex)
+		_usageCount[colIndex] = 0;
+}
+
+void Palette::fadeRange(RGB8 *srcPal, RGB8 *destPal,  int startIndex, int endIndex, 
+					 int numSteps, uint delayAmount) {
+	RGB8 tempPal[256];
+
+	// perform the fade
+	for(int stepCtr = 1; stepCtr <= numSteps; ++stepCtr) {
+		// Delay the specified amount
+		uint32 startTime = g_system->getMillis();
+		while ((g_system->getMillis() - startTime) < delayAmount) {
+			_vm->_events->handleEvents();
+			g_system->delayMillis(10);
+		}
+
+		for (int i = startIndex; i <= endIndex; ++i) {
+			// Handle the intermediate rgb values for fading
+			tempPal[i].r = (byte) (srcPal[i].r + (destPal[i].r - srcPal[i].r) * stepCtr / numSteps);   
+			tempPal[i].g = (byte) (srcPal[i].g + (destPal[i].g - srcPal[i].g) * stepCtr / numSteps); 
+			tempPal[i].b = (byte) (srcPal[i].b + (destPal[i].b - srcPal[i].b) * stepCtr / numSteps); 
+		}
+		
+		_vm->_palette->setPalette(&tempPal[startIndex], startIndex, endIndex - startIndex + 1);
+	}
+
+	// Make sure the end palette exactly matches what is wanted
+	_vm->_palette->setPalette(&destPal[startIndex], startIndex, endIndex - startIndex + 1);
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
new file mode 100644
index 0000000..ab03d8d
--- /dev/null
+++ b/engines/mads/palette.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_PALETTE_H
+#define MADS_PALETTE_H
+
+#include "common/scummsys.h"
+
+namespace MADS {
+
+class MADSEngine;
+
+struct RGB8 {
+	uint8 r, g, b, u;
+};
+
+class RGBList {
+private:
+	int _size;
+	RGB8 *_data;
+	byte *_palIndexes;
+	bool _freeData;
+public:
+	RGBList(int numEntries = 256, RGB8 *srcData = NULL, bool freeData = true);
+	~RGBList();
+
+	RGB8 *data() { return _data; }
+	byte *palIndexes() { return _palIndexes; }
+	int size() { return _size; }
+};
+
+#define PALETTE_COUNT 256
+
+class Palette {
+private:
+	MADSEngine *_vm;
+	bool _colorsChanged;
+	bool _fading_in_progress;
+	byte _originalPalette[PALETTE_COUNT * 4];
+	byte _fadedPalette[PALETTE_COUNT * 4];
+	int _usageCount[PALETTE_COUNT];
+
+	void reset();
+public:
+	Palette(MADSEngine *vm);
+
+	void setPalette(const byte *colors, uint start, uint num);
+	void setPalette(const RGB8 *colors, uint start, uint num);
+	void grabPalette(byte *colors, uint start, uint num);
+	void grabPalette(RGB8 *colors, uint start, uint num) {
+		grabPalette((byte *)colors, start, num);
+	}
+	uint8 palIndexFromRgb(byte r, byte g, byte b, RGB8 *paletteData = NULL);
+
+	void fadeIn(int numSteps, uint delayAmount, RGB8 *destPalette, int numColors);
+	void fadeIn(int numSteps, uint delayAmount, RGBList *destPalette);
+	static RGB8 *decodeMadsPalette(Common::SeekableReadStream *palStream,  int *numColors);
+	int setMadsPalette(Common::SeekableReadStream *palStream, int indexStart = 0);
+	void setMadsSystemPalette();
+	void fadeRange(RGB8 *srcPal, RGB8 *destPal,  int startIndex, int endIndex, 
+		int numSteps, uint delayAmount);
+
+	// Methods used for reference counting color usage
+	void resetColorCounts();
+	void blockRange(int startIndex, int size);
+	void addRange(RGBList *list);
+	void deleteRange(RGBList *list);
+	void deleteAllRanges();
+
+	// Color indexes
+	uint8 BLACK;
+	uint8 BLUE;
+	uint8 GREEN;
+	uint8 CYAN;
+	uint8 RED;
+	uint8 VIOLET;
+	uint8 BROWN;
+	uint8 LIGHT_GRAY;
+	uint8 DARK_GRAY;
+	uint8 LIGHT_BLUE;
+	uint8 LIGHT_GREEN;
+	uint8 LIGHT_CYAN;
+	uint8 LIGHT_RED;
+	uint8 PINK;
+	uint8 YELLOW;
+	uint8 WHITE;
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_PALETTE_H */
diff --git a/engines/mads/resources.cpp b/engines/mads/resources.cpp
new file mode 100644
index 0000000..27b94a9
--- /dev/null
+++ b/engines/mads/resources.cpp
@@ -0,0 +1,32 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "mads/resources.h"
+
+namespace MADS {
+
+ResourcesManager::ResourcesManager(MADSEngine *vm) {
+	_vm = vm;
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/resources.h b/engines/mads/resources.h
new file mode 100644
index 0000000..6eee0ea
--- /dev/null
+++ b/engines/mads/resources.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_RESOURCES_H
+#define MADS_RESOURCES_H
+
+#include "common/scummsys.h"
+#include "common/stream.h"
+
+namespace MADS {
+
+class MADSEngine;
+
+class ResourcesManager {
+private:
+	MADSEngine *_vm;
+public:
+	ResourcesManager(MADSEngine *vm);
+
+	/**
+	 * Return a named resource
+	 */
+	Common::SeekableReadStream *get(const Common::String &resourceName) {
+		// TODO
+		return nullptr;
+	}
+
+	/**
+	 * Release a previously loaded resource
+	 */
+	void toss(const Common::String &resourceName) {
+		// TODO
+	}
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_RESOURCES_H */
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index e3590f5..46ba997 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -27,7 +27,9 @@
 
 namespace MADS {
 
-SoundManager::SoundManager() {
+SoundManager::SoundManager(MADSEngine *vm, Audio::Mixer *mixer) {
+	_vm = vm;
+	_mixer = mixer;
 	_asound = nullptr;
 }
 
@@ -35,11 +37,6 @@ SoundManager::~SoundManager() {
 	delete _asound;
 }
 
-void SoundManager::setVm(MADSEngine *vm, Audio::Mixer *mixer) { 
-	_vm = vm; 
-	_mixer = mixer;
-}
-
 void SoundManager::test() {
 	_asound = new Nebular::ASound1(_mixer);
 	_asound->command(5);
diff --git a/engines/mads/sound.h b/engines/mads/sound.h
index 20b56ec..cbd6511 100644
--- a/engines/mads/sound.h
+++ b/engines/mads/sound.h
@@ -38,10 +38,9 @@ private:
 	Audio::Mixer *_mixer;
 	Nebular::ASound *_asound;
 public:
-	SoundManager();
+	SoundManager(MADSEngine *vm, Audio::Mixer *mixer);
 	~SoundManager();
 	
-	void setVm(MADSEngine *vm, Audio::Mixer *mixer);
 	void test();
 	void poll();
 };
diff --git a/engines/mads/sound_nebular.h b/engines/mads/sound_nebular.h
index f9251c9..11836e6 100644
--- a/engines/mads/sound_nebular.h
+++ b/engines/mads/sound_nebular.h
@@ -33,10 +33,10 @@
 
 namespace MADS {
 
-namespace Nebular {
-
 class SoundManager;
 
+namespace Nebular {
+
 /**
  * Represents the data for a channel on the Adlib
  */


Commit: 530cbb4bc3406757ee3daeb3fc1972f79fd9199b
    https://github.com/scummvm/scummvm/commit/530cbb4bc3406757ee3daeb3fc1972f79fd9199b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-18T23:43:06-05:00

Commit Message:
MADS: Adding in classes for fonts, game, user interfaec, and graphics

Changed paths:
  A engines/mads/font.cpp
  A engines/mads/font.h
  A engines/mads/game.cpp
  A engines/mads/game.h
  A engines/mads/graphics.cpp
  A engines/mads/graphics.h
  A engines/mads/user_interface.cpp
  A engines/mads/user_interface.h
    engines/mads/compression.cpp
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/module.mk
    engines/mads/msurface.cpp
    engines/mads/resources.h



diff --git a/engines/mads/compression.cpp b/engines/mads/compression.cpp
index f8df5a5..b5e24df 100644
--- a/engines/mads/compression.cpp
+++ b/engines/mads/compression.cpp
@@ -25,6 +25,8 @@
 namespace MADS {
 
 const char *const madsPackString = "MADSPACK";
+const char *const FabInputExceededError = "FabDecompressor - Passed end of input buffer during decompression";
+const char *const FabOutputExceededError = "FabDecompressor - Decompressed data exceeded specified size";
 
 bool MadsPack::isCompressed(Common::SeekableReadStream *stream) {
 	// Check whether the passed stream is packed
@@ -94,9 +96,6 @@ MadsPack::~MadsPack() {
 
 //--------------------------------------------------------------------------
 
-const char *FabInputExceededError = "FabDecompressor - Passed end of input buffer during decompression";
-const char *FabOutputExceededError = "FabDecompressor - Decompressed data exceeded specified size";
-
 void FabDecompressor::decompress(const byte *srcData, int srcSize, byte *destData, int destSize) {
 	byte copyLen, copyOfsShift, copyOfsMask, copyLenMask;
 	unsigned long copyOfs;
diff --git a/engines/mads/font.cpp b/engines/mads/font.cpp
new file mode 100644
index 0000000..b7400ed
--- /dev/null
+++ b/engines/mads/font.cpp
@@ -0,0 +1,283 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/compression.h"
+#include "mads/font.h"
+#include "mads/msurface.h"
+
+namespace MADS {
+
+Font *Font::init(MADSEngine *vm) {
+	if (vm->getGameFeatures() & GF_MADS) {
+		return new FontMADS(vm);
+	} else {
+		return new FontM4(vm);
+	}
+}
+
+Font::Font(MADSEngine *vm) : _vm(vm) {
+	_sysFont = true;
+	
+	_fontColors[0] = _vm->_palette->BLACK;
+	_fontColors[1] = _vm->_palette->WHITE;
+	_fontColors[2] = _vm->_palette->BLACK;
+	_fontColors[3] = _vm->_palette->DARK_GRAY;
+}
+
+Font::~Font() {
+	if (!_sysFont) {
+		delete[] _charWidths;
+		delete[] _charOffs;
+		delete[] _charData;
+	}
+}
+
+void Font::setColor(uint8 color) {
+	if (_sysFont)
+		_fontColors[1] = color;
+	else 
+		_fontColors[3] = color;		
+}
+
+void Font::setColors(uint8 alt1, uint8 alt2, uint8 foreground) {
+	if (_sysFont)
+		_fontColors[1] = foreground;
+	else {
+		_fontColors[1] = alt1;
+		_fontColors[2] = alt2;
+		_fontColors[3] = foreground;
+	}
+}
+
+int Font::write(MSurface *surface, const Common::String &msg, const Common::Point &pt, int width, int spaceWidth, uint8 colors[]) {
+
+	/*TODO
+	if (custom_ascii_converter) {			 // if there is a function to convert the extended ASCII characters
+		custom_ascii_converter(out_string);	 // call it with the string
+	}
+	*/
+
+	if (width > 0)
+		width = MIN(surface->width(), pt.x + width);
+	else
+		width = surface->width();
+
+	int x = pt.x + 1;
+	int y = pt.y + 1;
+	
+	int skipY = 0;
+	if (y < 0) {
+		skipY = -y;
+		y = 0;
+	}
+
+	int height = MAX(0, _maxHeight - skipY);
+	if (height == 0)
+		return x;
+
+	int bottom = y + height - 1;
+	if (bottom > surface->height() - 1) {
+		height -= MIN(height, bottom - (surface->height() - 1));
+	}
+
+	if (height <= 0)
+		return x;
+
+	byte *destPtr = surface->getBasePtr(x, y);
+	uint8 *oldDestPtr = destPtr;
+
+	int xPos = x;
+
+	const char *text = msg.c_str();
+	while (*text) {
+		char theChar = (*text++) & 0x7F;
+		int charWidth = _charWidths[theChar];
+		
+		if (charWidth > 0) {
+
+			if (xPos + charWidth >= width)
+				return xPos;
+
+			uint8 *charData = &_charData[_charOffs[theChar]];
+			int bpp = getBpp(charWidth);
+
+			if (skipY != 0)
+				charData += bpp * skipY;
+
+			for (int i = 0; i < height; i++) {
+				for (int j = 0; j < bpp; j++) {
+					if (*charData & 0xc0)
+						*destPtr = colors[(*charData & 0xc0) >> 6];
+					destPtr++;
+					if (*charData & 0x30)
+						*destPtr = colors[(*charData & 0x30) >> 4];
+					destPtr++;
+					if (*charData & 0x0C)
+						*destPtr = colors[(*charData & 0x0C) >> 2];
+					destPtr++;
+					if (*charData & 0x03)
+						*destPtr = colors[*charData & 0x03];
+					destPtr++;
+					charData++;
+				}
+
+				destPtr += surface->width() - bpp * 4;
+
+			}
+
+			destPtr = oldDestPtr + charWidth + spaceWidth;
+			oldDestPtr = destPtr;
+
+		}
+
+		xPos += charWidth + spaceWidth;
+		
+	}
+
+	surface->freeData();
+	return xPos;
+
+}
+
+int Font::getWidth(const Common::String &msg, int spaceWidth) {
+	/*
+	if (custom_ascii_converter) {			 // if there is a function to convert the extended ASCII characters
+		custom_ascii_converter(out_string);	 // call it with the string
+	}
+	*/
+	int width = 0;
+	const char *text = msg.c_str();
+
+	while (*text)
+		width += _charWidths[*text++ & 0x7F] + spaceWidth;
+	return width;
+}
+
+/*------------------------------------------------------------------------*/
+
+void FontMADS::setFont(const Common::String &filename) {
+	if (!_filename.empty() && (filename == _filename))
+		// Already using specified font, so don't bother reloading
+		return;
+
+	_sysFont = false;
+	_filename = filename;
+
+	MadsPack fontData(filename, _vm);
+	Common::SeekableReadStream *fontFile = fontData.getItemStream(0);
+
+	_maxHeight = fontFile->readByte();
+	_maxWidth = fontFile->readByte();
+
+	_charWidths = new uint8[128];
+	// Char data is shifted by 1
+	_charWidths[0] = 0;
+	fontFile->read(_charWidths + 1, 127);
+	fontFile->readByte();	// remainder
+
+	_charOffs = new uint16[128];
+
+	uint startOffs = 2 + 128 + 256;
+	uint fontSize = fontFile->size() - startOffs;
+
+	// Char data is shifted by 1
+	_charOffs[0] = 0;
+	for (int i = 1; i < 128; i++)
+		_charOffs[i] = fontFile->readUint16LE() - startOffs;
+	fontFile->readUint16LE();	// remainder
+
+	_charData = new uint8[fontSize];
+	fontFile->read(_charData, fontSize);
+
+	delete fontFile;
+}
+
+int FontMADS::getBpp(int charWidth) {
+	if (charWidth > 12)
+		return 4;
+	else if (charWidth > 8)
+		return 3;
+	else if (charWidth > 4)
+		return 2;
+	else
+		return 1;
+}
+
+/*------------------------------------------------------------------------*/
+
+void FontM4::setFont(const Common::String &filename) {
+	if (!_filename.empty() && (filename == _filename))
+		// Already using specified font, so don't bother reloading
+		return;
+
+	_sysFont = false;
+	_filename = filename;
+
+	Common::SeekableReadStream *fontFile = _vm->_resources->openFile(filename);
+	
+	if (fontFile->readUint32LE() != MKTAG('F', 'O', 'N', 'T')) {
+		warning("Font: FONT tag expected");
+		return;
+	}
+
+	_maxHeight = fontFile->readByte();
+	_maxWidth = fontFile->readByte();
+	uint fontSize = fontFile->readUint32LE();
+	
+	//printf("Font::Font: _maxWidth = %d, _maxHeight = %d, fontSize = %d\n", _maxWidth, _maxHeight, fontSize);
+
+	if (fontFile->readUint32LE() != MKTAG('W', 'I', 'D', 'T')) {
+		warning("Font: WIDT tag expected");
+		return;
+	}
+
+	_charWidths = new uint8[256];
+	fontFile->read(_charWidths, 256);
+
+	if (fontFile->readUint32LE() != MKTAG('O', 'F', 'F', 'S')) {
+		warning("Font: OFFS tag expected\n");
+		return;
+	}
+
+	_charOffs = new uint16[256];
+
+	for (int i = 0; i < 256; i++)
+		_charOffs[i] = fontFile->readUint16LE();
+
+	if (fontFile->readUint32LE() != MKTAG('P', 'I', 'X', 'S')) {
+		warning("Font: PIXS tag expected\n");
+		return;
+	}
+
+	_charData = new uint8[fontSize];
+	fontFile->read(_charData, fontSize);
+
+	_vm->_resources->toss(filename);
+}
+
+int FontM4::getBpp(int charWidth) {
+	return charWidth / 4 + 1;
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/font.h b/engines/mads/font.h
new file mode 100644
index 0000000..d36be80
--- /dev/null
+++ b/engines/mads/font.h
@@ -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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_FONT_H
+#define MADS_FONT_H
+
+#include "common/scummsys.h"
+#include "common/util.h"
+#include "common/endian.h"
+#include "mads/msurface.h"
+
+namespace MADS {
+
+#define FONT_MENU "fontmenu.fnt"
+#define FONT_INTERFACE "fontintr.fnt"
+#define FONT_TINY "small.fnt"
+#define FONT_SMALL "small.fnt"
+#define FONT_MEDIUM "medium.fnt"
+#define FONT_LINE "fontline.fnt"
+#define FONT_CONVERSATION "fontconv.fnt"
+#define FONT_4X6 "4x6pp.fnt"
+#define FONT_5X6 "5x6pp.fnt"
+
+#define FONT_CONVERSATION_MADS "fontconv.ff"
+#define FONT_INTERFACE_MADS "fontintr.ff"
+#define FONT_MAIN_MADS "fontmain.ff"
+#define FONT_MENU_MADS "fontmenu.ff"	// Not in Rex (uses bitmap files for menu strings)
+#define FONT_MISC_MADS "fontmisc.ff"
+#define FONT_TELE_MADS "fonttele.ff"	// Not in Phantom
+#define FONT_PHAN_MADS "fontphan.ff"	// Phantom only
+
+class MADSEngine;
+
+class Font {
+protected:
+	MADSEngine *_vm;
+
+	uint8 _maxWidth, _maxHeight;
+	uint8 *_charWidths;
+	uint16 *_charOffs;
+	uint8 *_charData;
+	bool _sysFont;
+	Common::String _filename;
+	uint8 _fontColors[4];
+
+protected:
+	Font(MADSEngine *vm);
+
+	virtual void setFont(const Common::String &filename) = 0;
+	virtual int getBpp(int charWidth) = 0;
+public:
+	static Font *init(MADSEngine *vm);
+public:
+	virtual ~Font();
+
+	void setColor(uint8 color);
+	void setColors(uint8 alt1, uint8 alt2, uint8 foreground);
+
+	int getWidth(const Common::String &msg, int spaceWidth = -1);
+	int getHeight() const { return _maxHeight; }
+	int write(MSurface *surface, const Common::String &msg, const Common::Point &pt, int width, int spaceWidth, uint8 colors[]);
+	int writeString(MSurface *surface, const Common::String &msg, const Common::Point &pt, int width = 0, int spaceWidth = -1) {
+		return write(surface, msg, pt, width, spaceWidth, _fontColors);
+	}
+};
+
+class FontMADS: public Font {
+	friend class Font;
+protected:
+	virtual void setFont(const Common::String &filename);
+	virtual int getBpp(int charWidth);
+
+	FontMADS(MADSEngine *vm): Font(vm) {}
+};
+
+class FontM4: public Font {
+	friend class Font;
+protected:
+	virtual void setFont(const Common::String &filename);
+	virtual int getBpp(int charWidth);
+
+	FontM4(MADSEngine *vm): Font(vm) {}
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_FONT_H */
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
new file mode 100644
index 0000000..491117f
--- /dev/null
+++ b/engines/mads/game.cpp
@@ -0,0 +1,39 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/game.h"
+#include "mads/graphics.h"
+#include "mads/msurface.h"
+
+namespace MADS {
+
+Game *Game::init(MADSEngine *vm) {
+	return new Game(vm);
+}
+
+Game::Game(MADSEngine *vm): _vm(vm), _surface(MSurface::init(
+		MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT)) {
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/game.h b/engines/mads/game.h
new file mode 100644
index 0000000..190dc88
--- /dev/null
+++ b/engines/mads/game.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.
+ *
+ */
+
+#ifndef MADS_GAME_H
+#define MADS_GAME_H
+
+#include "common/scummsys.h"
+
+namespace MADS {
+
+class MADSEngine;
+
+class Game {
+private:
+	MADSEngine *_vm;
+	MSurface *_surface;
+
+	Game(MADSEngine *vm);
+public:
+	static Game *init(MADSEngine *vm);
+public:
+	~Game();
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_GAME_H */
diff --git a/engines/mads/graphics.cpp b/engines/mads/graphics.cpp
new file mode 100644
index 0000000..267785b
--- /dev/null
+++ b/engines/mads/graphics.cpp
@@ -0,0 +1,30 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/graphics.h"
+
+namespace MADS {
+
+
+} // End of namespace MADS
diff --git a/engines/mads/graphics.h b/engines/mads/graphics.h
new file mode 100644
index 0000000..87cd8be
--- /dev/null
+++ b/engines/mads/graphics.h
@@ -0,0 +1,36 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_GRAPHICS_H
+#define MADS_GRAPHICS_H
+
+#include "common/scummsys.h"
+
+namespace MADS {
+
+#define MADS_SCREEN_WIDTH 320
+#define MADS_SCREEN_HEIGHT 200
+#define MADS_INTERFACE_HEIGHT 44
+
+} // End of namespace MADS
+
+#endif /* MADS_GRAPHICS_H */
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 9998bc0..0ddb6bf 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -26,6 +26,7 @@
 #include "common/events.h"
 #include "engines/util.h"
 #include "mads/mads.h"
+#include "mads/graphics.h"
 #include "mads/resources.h"
 #include "mads/sound.h"
 #include "mads/msurface.h"
@@ -40,17 +41,24 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :
 	_easyMouse = true;
 	_invObjectStill = false;
 	_textWindowStill = false;
+
+	_events = nullptr;
+	_font = nullptr;
 	_palette = nullptr;
 	_resources = nullptr;
 	_screen = nullptr;
 	_sound = nullptr;
+	_userInterface = nullptr;
 }
 
 MADSEngine::~MADSEngine() {
 	delete _events;
+	delete _font;
+	delete _palette;
 	delete _resources;
 	delete _screen;
 	delete _sound;
+	delete _userInterface;
 }
 
 void MADSEngine::initialise() {
@@ -63,13 +71,18 @@ void MADSEngine::initialise() {
 	MSprite::setVm(this);
 
 	_events = new EventsManager(this);
+	_palette = new Palette(this);
+	_font = Font::init(this);
 	_resources = new ResourcesManager(this);
-	_screen = MSurface::init();
+	_screen = MSurface::init(true);
 	_sound = new SoundManager(this, _mixer);
+	_userInterface = UserInterface::init(this);
+
+	_screen->empty();
 }
 
 Common::Error MADSEngine::run() {
-	initGraphics(320, 200, false);
+	initGraphics(MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT, false);
 	initialise();
 
 	Common::Event e;
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index 8ca181e..86a5499 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -31,9 +31,11 @@
 #include "engines/engine.h"
 #include "graphics/surface.h"
 #include "mads/events.h"
+#include "mads/font.h"
 #include "mads/msurface.h"
 #include "mads/resources.h"
 #include "mads/sound.h"
+#include "mads/user_interface.h"
 
 /**
  * This is the namespace of the MADS engine.
@@ -88,10 +90,12 @@ protected:
 	virtual bool hasFeature(EngineFeature f) const;
 public:
 	EventsManager *_events;
+	Font *_font;
 	Palette *_palette;
 	ResourcesManager *_resources;
 	MSurface *_screen;
 	SoundManager *_sound;
+	UserInterface *_userInterface;
 
 public:
 	MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc);
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 7ac919f..d2ae9ea 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -4,6 +4,9 @@ MODULE_OBJS := \
 	compression.o \
 	detection.o \
 	events.o \
+	font.o \
+	game.o \
+	graphics.o \
 	mads.o \
 	msprite.o \
 	msurface.o \
@@ -11,7 +14,8 @@ MODULE_OBJS := \
 	resources.o \
 	sound.o \
 	sound_nebular.o \
-	sprite.o
+	sprite.o \
+	user_interface.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_MADS), DYNAMIC_PLUGIN)
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 810f932..eca3f76 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -21,10 +21,11 @@
  */
 
 #include "engines/util.h"
-#include "mads/mads.h"
 #include "mads/compression.h"
-#include "mads/msurface.h"
+#include "mads/graphics.h"
+#include "mads/mads.h"
 #include "mads/msprite.h"
+#include "mads/msurface.h"
 
 namespace MADS {
 
@@ -370,8 +371,8 @@ void MSurfaceMADS::loadCodes(Common::SeekableReadStream *source) {
 		return;
 	}
 
-	uint16 widthVal = 320;
-	uint16 heightVal = 156;
+	uint16 widthVal = MADS_SCREEN_WIDTH;
+	uint16 heightVal = MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT;
 	byte *walkMap = new byte[source->size()];
 
 	create(widthVal, heightVal);
@@ -536,8 +537,8 @@ void MSurfaceMADS::loadInterface(int index, RGBList **palData) {
 
 	// Chunk 1, data
 	intStream = intFile.getItemStream(1);
-	create(320, 44);
-	intStream->read(pixels, 320 * 44);
+	create(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
+	intStream->read(pixels, MADS_SCREEN_WIDTH * MADS_INTERFACE_HEIGHT);
 	delete intStream;
 }
 
diff --git a/engines/mads/resources.h b/engines/mads/resources.h
index 6eee0ea..68bb475 100644
--- a/engines/mads/resources.h
+++ b/engines/mads/resources.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "common/stream.h"
+#include "common/str.h"
 
 namespace MADS {
 
@@ -39,11 +40,15 @@ public:
 	/**
 	 * Return a named resource
 	 */
-	Common::SeekableReadStream *get(const Common::String &resourceName) {
+	Common::SeekableReadStream *get(const Common::String &resourceName, bool loadFlag = false) {
 		// TODO
 		return nullptr;
 	}
 
+	Common::SeekableReadStream *openFile(const Common::String &resourceName) { 
+		return get(resourceName, false); 
+	}
+
 	/**
 	 * Release a previously loaded resource
 	 */
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
new file mode 100644
index 0000000..2af134a
--- /dev/null
+++ b/engines/mads/user_interface.cpp
@@ -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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/graphics.h"
+#include "mads/user_interface.h"
+#include "mads/msurface.h"
+
+namespace MADS {
+
+UserInterface *UserInterface::init(MADSEngine *vm) {
+	return new UserInterface(vm);
+}
+
+UserInterface::UserInterface(MADSEngine *vm): _vm(vm), _surface(
+	MSurface::init(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT)) {
+}
+
+UserInterface::~UserInterface() {
+	delete _surface;
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
new file mode 100644
index 0000000..838638b
--- /dev/null
+++ b/engines/mads/user_interface.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.
+ *
+ */
+
+#ifndef MADS_USER_INTERFACE_H
+#define MADS_USER_INTERFACE_H
+
+#include "common/scummsys.h"
+
+namespace MADS {
+
+class MADSEngine;
+
+class UserInterface {
+private:
+	MADSEngine *_vm;
+	MSurface *_surface;
+
+	UserInterface(MADSEngine *vm);
+public:
+	static UserInterface *init(MADSEngine *vm);
+public:
+	~UserInterface();
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_USER_INTERFACE_H */


Commit: 97087e8cd1aee602217c36f1c71d4ca3f74e0e40
    https://github.com/scummvm/scummvm/commit/97087e8cd1aee602217c36f1c71d4ca3f74e0e40
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-18T23:56:41-05:00

Commit Message:
MADS: Fix warnings identified by gcc

Changed paths:
    engines/mads/module.mk
    engines/mads/msurface.h
    engines/mads/sound_nebular.cpp



diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index d2ae9ea..401b909 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -14,7 +14,6 @@ MODULE_OBJS := \
 	resources.o \
 	sound.o \
 	sound_nebular.o \
-	sprite.o \
 	user_interface.o
 
 # This module can be built as a plugin
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index 9bb651b..21b0cbc 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -69,6 +69,8 @@ protected:
 	MSurface(bool isScreen = false);
 	MSurface(int w, int h);
 public:
+	virtual ~MSurface() {}
+
 	void create(int w, int h) {
 		Graphics::Surface::create(w, h, Graphics::PixelFormat::createFormatCLUT8());
 	}
@@ -155,7 +157,7 @@ class MSurfaceM4: public MSurface {
 	friend class MSurface;
 protected:
 	MSurfaceM4(bool isScreen = false): MSurface(isScreen) {}
-	MSurfaceM4(int w, int h): MSurface(w, h) {}
+	MSurfaceM4(int widthVal, int heightVal): MSurface(widthVal, heightVal) {}
 
 	void loadBackgroundStream(Common::SeekableReadStream *source);
 public:
@@ -167,18 +169,10 @@ class MSurfaceRiddle: public MSurfaceM4 {
 	friend class MSurface;
 protected:
 	MSurfaceRiddle(bool isScreen = false): MSurfaceM4(isScreen) {}
-	MSurfaceRiddle(int w, int h): MSurfaceM4(w, h) {}
+	MSurfaceRiddle(int widthVal, int heightVal): MSurfaceM4(widthVal, heightVal) {}
 public:
 	virtual void loadBackground(const Common::String &sceneName);
 };
-/*
-	void rexLoadBackground(Common::SeekableReadStream *source, RGBList **palData = NULL);
-	void madsLoadBackground(int roomNumber, RGBList **palData = NULL);
-	void m4LoadBackground(Common::SeekableReadStream *source);
-
-	void madsloadInterface(int index, RGBList **palData);
-	
-	*/
 
 } // End of namespace MADS
 
diff --git a/engines/mads/sound_nebular.cpp b/engines/mads/sound_nebular.cpp
index 146a620..7c1410c 100644
--- a/engines/mads/sound_nebular.cpp
+++ b/engines/mads/sound_nebular.cpp
@@ -234,11 +234,11 @@ void ASound::noise() {
 	int randomVal = getRandomNumber();
 
 	if (_v1) {
-		setFrequency(_channelNum1, (randomVal ^ 0xFFFF) & _freqMask1 + _freqBase1);
+		setFrequency(_channelNum1, ((randomVal ^ 0xFFFF) & _freqMask1) + _freqBase1);
 	}
 
 	if (_v2) {
-		setFrequency(_channelNum2, randomVal & _freqMask2 + _freqBase2);		
+		setFrequency(_channelNum2, (randomVal & _freqMask2) + _freqBase2);		
 	}
 }
 
@@ -731,7 +731,7 @@ void ASound::loadSample(int sampleIndex) {
 void ASound::processSample() {
 	// Write out vib flags and split point
 	write2(8, 0x40 + _v11, 0x3F);
-	int depthRhythm = _ports[0xBD] & 0x3F | (_amDep ? 0x80 : 0) |
+	int depthRhythm = (_ports[0xBD] & 0x3F) | (_amDep ? 0x80 : 0) |
 		(_vibDep ? 0x40 : 0);
 	write2(8, 0xBD, depthRhythm);
 	write2(8, 8, _splitPoint ? 0x40 : 0);
@@ -758,7 +758,7 @@ void ASound::processSample() {
 	write2(8, 0xE0 + _v11, _samplePtr->_waveformSelect & 3);
 	
 	// Write out total level & scaling level
-	val = -(_samplePtr->_totalLevel & 0x3F - 0x3F) | (_samplePtr->_scalingLevel << 6);
+	val = -((_samplePtr->_totalLevel & 0x3F) - 0x3F) | (_samplePtr->_scalingLevel << 6);
 	write2(8, 0x40 + _v11, val);
 }
 


Commit: 5c565797e5516de97686650be8cc810007111641
    https://github.com/scummvm/scummvm/commit/5c565797e5516de97686650be8cc810007111641
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-19T20:22:06-05:00

Commit Message:
MADS: Extra cleanup and commenting for MSurface methods

Changed paths:
    engines/mads/font.cpp
    engines/mads/msurface.cpp
    engines/mads/msurface.h



diff --git a/engines/mads/font.cpp b/engines/mads/font.cpp
index b7400ed..9da46c3 100644
--- a/engines/mads/font.cpp
+++ b/engines/mads/font.cpp
@@ -79,9 +79,9 @@ int Font::write(MSurface *surface, const Common::String &msg, const Common::Poin
 	*/
 
 	if (width > 0)
-		width = MIN(surface->width(), pt.x + width);
+		width = MIN(surface->getWidth(), pt.x + width);
 	else
-		width = surface->width();
+		width = surface->getWidth();
 
 	int x = pt.x + 1;
 	int y = pt.y + 1;
@@ -97,8 +97,8 @@ int Font::write(MSurface *surface, const Common::String &msg, const Common::Poin
 		return x;
 
 	int bottom = y + height - 1;
-	if (bottom > surface->height() - 1) {
-		height -= MIN(height, bottom - (surface->height() - 1));
+	if (bottom > surface->getHeight() - 1) {
+		height -= MIN(height, bottom - (surface->getHeight() - 1));
 	}
 
 	if (height <= 0)
@@ -142,7 +142,7 @@ int Font::write(MSurface *surface, const Common::String &msg, const Common::Poin
 					charData++;
 				}
 
-				destPtr += surface->width() - bpp * 4;
+				destPtr += surface->getWidth() - bpp * 4;
 
 			}
 
@@ -155,7 +155,6 @@ int Font::write(MSurface *surface, const Common::String &msg, const Common::Poin
 		
 	}
 
-	surface->freeData();
 	return xPos;
 
 }
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index eca3f76..b3a4510 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -41,23 +41,23 @@ MSurface *MSurface::init(bool isScreen) {
 	}
 }
 
-MSurface *MSurface::init(int w, int h) {
+MSurface *MSurface::init(int width, int height) {
 	if (_vm->getGameID() == GType_RexNebular) {
-		return new MSurfaceNebular(w, h);
+		return new MSurfaceNebular(width, height);
 	} else if (_vm->getGameFeatures() & GF_MADS) {
-		return new MSurfaceMADS(w, h);
+		return new MSurfaceMADS(width, height);
 	} else {
-		return new MSurfaceM4(w, h);
+		return new MSurfaceM4(width, height);
 	}
 }
 
 MSurface::MSurface(bool isScreen) { 
-	create(g_system->getWidth(), g_system->getHeight());
+	setSize(g_system->getWidth(), g_system->getHeight());
 	_isScreen = isScreen;
 }
 
-MSurface::MSurface(int Width, int Height) { 
-	create(Width, Height); 
+MSurface::MSurface(int width, int height) { 
+	setSize(width, height); 
 	_isScreen = false; 
 }
 
@@ -137,7 +137,7 @@ int MSurface::scaleValue(int value, int scale, int err) {
 	return scaled;
 }
 
-void MSurface::drawSprite(int x, int y, SpriteInfo &info, const Common::Rect &clipRect) {
+void MSurface::drawSprite(const Common::Point &pt, SpriteInfo &info, const Common::Rect &clipRect) {
 
 	enum {
 		kStatusSkip,
@@ -155,11 +155,7 @@ void MSurface::drawSprite(int x, int y, SpriteInfo &info, const Common::Rect &cl
 	int scaledWidth = scaleValue(info.width, info.scaleX, errX);
 	int scaledHeight = scaleValue(info.height, info.scaleY, errY);
 
-	/*
-	printf("MSurface::drawSprite() info.width = %d; info.scaleX = %d; info.height = %d; info.scaleY = %d; scaledWidth = %d; scaledHeight = %d\n",
-		info.width, info.scaleX, info.height, info.scaleY, scaledWidth, scaledHeight); fflush(stdout);
-	*/
-	
+	int x = pt.x, y = pt.y;
 	int clipX = 0, clipY = 0;
 	// Clip the sprite's width and height according to the clip rectangle's dimensions
 	// This clips the sprite to the bottom and right
@@ -176,8 +172,6 @@ void MSurface::drawSprite(int x, int y, SpriteInfo &info, const Common::Rect &cl
 		scaledHeight = y + scaledHeight;
 	}
 
-	//printf("MSurface::drawSprite() width = %d; height = %d; scaledWidth = %d; scaledHeight = %d\n", info.width, info.height, scaledWidth, scaledHeight); fflush(stdout);
-
 	// Check if sprite is inside the screen. If it's not, there's no need to draw it
 	if (scaledWidth + x <= 0 || scaledHeight + y <= 0)	// check left and top (in case x,y are negative)
 		return;
@@ -206,16 +200,16 @@ void MSurface::drawSprite(int x, int y, SpriteInfo &info, const Common::Rect &cl
 				// Scale current line
 				byte *lineDst = scaledLineBuf;
 				int curErrX = errX;
-				int widthVal = scaledWidth;
+				int width = scaledWidth;
 				byte *tempSrc = src;
 				int startX = clipX;
-				while (widthVal > 0) {
+				while (width > 0) {
 					byte pixel = *tempSrc++;
 					curErrX -= info.scaleX;
 					while (curErrX < 0) {
 						if (startX == 0) {
 							*lineDst++ = pixel;
-							widthVal--;
+							width--;
 						} else {
 							startX++;
 						}
@@ -276,19 +270,6 @@ void MSurface::drawSprite(int x, int y, SpriteInfo &info, const Common::Rect &cl
 
 }
 
-// Surface methods
-
-byte *MSurface::getData() {
-	return (byte *)Graphics::Surface::getPixels();
-}
-
-byte *MSurface::getBasePtr(int x, int y) {
-	return (byte *)Graphics::Surface::getBasePtr(x, y);
-}
-
-void MSurface::freeData() {
-}
-
 void MSurface::empty() {
 	Common::fill(getBasePtr(0, 0), getBasePtr(w, h), _vm->_palette->BLACK);
 }
@@ -301,9 +282,10 @@ void MSurface::fillRect(const Common::Rect &r, uint8 color) {
 	Graphics::Surface::fillRect(r, color);
 }
 
-void MSurface::copyFrom(MSurface *src, const Common::Rect &srcBounds, int destX, int destY,
-						 int transparentColor) {
-	// Validation of the rectangle and position
+void MSurface::copyFrom(MSurface *src, const Common::Rect &srcBounds, 
+		const Common::Point &destPos, int transparentColor) {
+	// Validation of the rectangle and position	
+	int destX = destPos.x, destY = destPos.y;		
 	if ((destX >= w) || (destY >= h))
 		return;
 
@@ -327,8 +309,8 @@ void MSurface::copyFrom(MSurface *src, const Common::Rect &srcBounds, int destX,
 	// Copy the specified area
 
 	byte *data = src->getData();
-	byte *srcPtr = data + (src->width() * copyRect.top + copyRect.left);
-	byte *destPtr = (byte *)pixels + (destY * width()) + destX;
+	byte *srcPtr = data + (src->getWidth() * copyRect.top + copyRect.left);
+	byte *destPtr = (byte *)pixels + (destY * getWidth()) + destX;
 
 	for (int rowCtr = 0; rowCtr < copyRect.height(); ++rowCtr) {
 		if (transparentColor == -1)
@@ -340,27 +322,21 @@ void MSurface::copyFrom(MSurface *src, const Common::Rect &srcBounds, int destX,
 				if (srcPtr[xCtr] != transparentColor) destPtr[xCtr] = srcPtr[xCtr];
 		}
 
-		srcPtr += src->width();
-		destPtr += width();
+		srcPtr += src->getWidth();
+		destPtr += getWidth();
 	}
-
-	src->freeData();
 }
 
-#undef COL_TRANS
-
 void MSurface::translate(RGBList *list, bool isTransparent) {
 	byte *p = getBasePtr(0, 0);
 	byte *palIndexes = list->palIndexes();
 
-	for (int i = 0; i < width() * height(); ++i, ++p) {
+	for (int i = 0; i < getWidth() * getHeight(); ++i, ++p) {
 		if (!isTransparent || (*p != 0)) {
 			assert(*p < list->size());
 			*p = palIndexes[*p];
 		}
 	}
-
-	freeData();
 }
 
 /*------------------------------------------------------------------------*/
@@ -371,18 +347,18 @@ void MSurfaceMADS::loadCodes(Common::SeekableReadStream *source) {
 		return;
 	}
 
-	uint16 widthVal = MADS_SCREEN_WIDTH;
-	uint16 heightVal = MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT;
+	uint16 width = MADS_SCREEN_WIDTH;
+	uint16 height = MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT;
 	byte *walkMap = new byte[source->size()];
 
-	create(widthVal, heightVal);
+	setSize(width, height);
 	source->read(walkMap, source->size());
 
 	byte *ptr = (byte *)getBasePtr(0, 0);
 
-	for (int y = 0; y < heightVal; y++) {
-		for (int x = 0; x < widthVal; x++) {
-			int ofs = x + (y * widthVal);
+	for (int y = 0; y < height; y++) {
+		for (int x = 0; x < width; x++) {
+			int ofs = x + (y * width);
 			if ((walkMap[ofs / 8] << (ofs % 8)) & 0x80)
 				*ptr++ = 1;		// walkable
 			else
@@ -444,8 +420,8 @@ void MSurfaceMADS::loadBackground(int roomNumber, RGBList **palData) {
 	assert(tileCountMap == tileCount);
 	assert(tileWidth == tileWidthMap);
 	assert(tileHeight == tileHeightMap);
-	assert(screenWidth == _vm->_screen->width());
-	assert(screenHeight <= _vm->_screen->height());
+	assert(screenWidth == _vm->_screen->getWidth());
+	assert(screenHeight <= _vm->_screen->getHeight());
 
 	// --------------------------------------------------------------------------------
 
@@ -508,7 +484,7 @@ void MSurfaceMADS::loadBackground(int roomNumber, RGBList **palData) {
 			TileSetIterator tile = tileSet.begin();
 			for (i = 0; i < tileIndex; i++)
 				++tile;
-			((*tile).get())->copyTo(this, x * tileWidth, y * tileHeight);
+			((*tile).get())->copyTo(this, Common::Point(x * tileWidth, y * tileHeight));
 		}
 	}
 	tileSet.clear();
@@ -537,7 +513,7 @@ void MSurfaceMADS::loadInterface(int index, RGBList **palData) {
 
 	// Chunk 1, data
 	intStream = intFile.getItemStream(1);
-	create(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
+	setSize(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
 	intStream->read(pixels, MADS_SCREEN_WIDTH * MADS_INTERFACE_HEIGHT);
 	delete intStream;
 }
@@ -562,14 +538,14 @@ void MSurfaceNebular::loadBackgroundStream(Common::SeekableReadStream *source, R
 	int sceneWidth = sourceUnc->readUint16LE();
 	int sceneHeight = sourceUnc->readUint16LE();
 	int sceneSize = sceneWidth * sceneHeight;
-	if (sceneWidth > this->width()) {
-		warning("Background width is %i, too large to fit in screen. Setting it to %i", sceneWidth, this->width());
-		sceneWidth = this->width();
+	if (sceneWidth > this->getWidth()) {
+		warning("Background width is %i, too large to fit in screen. Setting it to %i", sceneWidth, getWidth());
+		sceneWidth = this->getWidth();
 		sceneSize = sceneWidth * sceneHeight;
 	}
-	if (sceneHeight > this->height()) {
-		warning("Background height is %i, too large to fit in screen.Setting it to %i", sceneHeight, this->height());
-		sceneHeight = this->height();
+	if (sceneHeight > getHeight()) {
+		warning("Background height is %i, too large to fit in screen.Setting it to %i", sceneHeight, getHeight());
+		sceneHeight = getHeight();
 		sceneSize = sceneWidth * sceneHeight;
 	}
 
@@ -590,7 +566,6 @@ void MSurfaceNebular::loadBackgroundStream(Common::SeekableReadStream *source, R
 	byte *pData = (byte *)pixels;
 	sourceUnc->read(pData, sceneSize);
 	
-	freeData();
 	delete sourceUnc;
 }
 
@@ -602,11 +577,11 @@ void MSurfaceM4::loadCodes(Common::SeekableReadStream *source) {
 		return;
 	}
 
-	uint16 widthVal = source->readUint16LE();
-	uint16 heightVal = source->readUint16LE();
+	uint16 width = source->readUint16LE();
+	uint16 height = source->readUint16LE();
 
-	create(widthVal, heightVal);
-	source->read(pixels, widthVal * heightVal);
+	setSize(width, height);
+	source->read(pixels, width * height);
 }
 
 void MSurfaceM4::loadBackground(int roomNumber, RGBList **palData) {
@@ -627,8 +602,8 @@ void MSurfaceM4::loadBackgroundStream(Common::SeekableReadStream *source) {
 
 	source->skip(4);
 	/*uint32 size =*/ source->readUint32LE();
-	uint32 widthVal = source->readUint32LE();
-	uint32 heightVal = source->readUint32LE();
+	uint32 width = source->readUint32LE();
+	uint32 height = source->readUint32LE();
 	uint32 tilesX = source->readUint32LE();
 	uint32 tilesY = source->readUint32LE();
 	uint32 tileWidth = source->readUint32LE();
@@ -651,25 +626,26 @@ void MSurfaceM4::loadBackgroundStream(Common::SeekableReadStream *source) {
 	// resize or create the surface
 	// Note that the height of the scene in game scenes is smaller than the screen height, 
 	// as the bottom part of the screen is the inventory
-	assert(width() == (int)widthVal);
+	assert(getWidth() == (int)width);
 
-	tileBuffer->create(tileWidth, tileHeight);
+	tileBuffer->setSize(tileWidth, tileHeight);
 
 	for (curTileY = 0; curTileY < tilesY; curTileY++) {
-		clipY = MIN(heightVal, (1 + curTileY) * tileHeight) - (curTileY * tileHeight);
+		clipY = MIN(height, (1 + curTileY) * tileHeight) - (curTileY * tileHeight);
 
 		for (curTileX = 0; curTileX < tilesX; curTileX++) {
-			clipX = MIN(widthVal, (1 + curTileX) * tileWidth) - (curTileX * tileWidth);
+			clipX = MIN(width, (1 + curTileX) * tileWidth) - (curTileX * tileWidth);
 
 			// Read a tile and copy it to the destination surface
 			source->read(tileBuffer->getData(), tileWidth * tileHeight);
 			Common::Rect srcBounds(0, 0, clipX, clipY);
-			copyFrom(tileBuffer, srcBounds, curTileX * tileWidth, curTileY * tileHeight);
+			copyFrom(tileBuffer, srcBounds, 
+				Common::Point(curTileX * tileWidth, curTileY * tileHeight));
 		}
 	}
 
-	if (heightVal < (uint)height())
-		fillRect(Common::Rect(0, heightVal, width(), height()), blackIndex);
+	if (height < (uint)getHeight())
+		fillRect(Common::Rect(0, height, getWidth(), getHeight()), blackIndex);
 
 	delete tileBuffer;
 }
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index 21b0cbc..05777d3 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -33,6 +33,9 @@ namespace MADS {
 class MADSEngine;
 class MSprite;
 
+/**
+ * Basic sprite information
+ */
 struct SpriteInfo {
 	MSprite *sprite;
 	int hotX, hotY;
@@ -43,6 +46,9 @@ struct SpriteInfo {
 	RGB8 *palette;
 };
 
+/*
+ * MADS graphics surface
+ */
 class MSurface : public Graphics::Surface {
 public:
 	static MADSEngine *_vm;
@@ -61,46 +67,126 @@ public:
 	/**
 	 * Create a surface
 	 */
-	static MSurface *init(int w, int h);
+	static MSurface *init(int width, int height);
 private:
 	byte _color;
 	bool _isScreen;
 protected:
+	/**
+	 * Basic constructor
+	 */
 	MSurface(bool isScreen = false);
-	MSurface(int w, int h);
+
+	/**
+	 * Constructor for a surface with fixed dimensions
+	 */
+	MSurface(int width, int height);
+public:
+	/**
+	 * Helper method for calculating new dimensions when scaling a sprite
+	 */
+	static int scaleValue(int value, int scale, int err);	
 public:
 	virtual ~MSurface() {}
 
-	void create(int w, int h) {
-		Graphics::Surface::create(w, h, Graphics::PixelFormat::createFormatCLUT8());
+	/**
+	 * Reinitialises a surface to have a given set of dimensions
+	 */
+	void setSize(int width, int height) {
+		Graphics::Surface::create(width, height, Graphics::PixelFormat::createFormatCLUT8());
 	}
 
+	/**
+	 * Sets the color used for drawing on the surface
+	 */
 	void setColor(byte value) { _color = value; }
-	byte getColor() { return _color; }
+
+	/**
+	 * Returns the currently active color
+	 */
+	byte getColor() const { return _color; }
+	
+	/**
+	 * Draws a vertical line using the currently set color
+	 */
 	void vLine(int x, int y1, int y2);
+
+	/**
+	 * Draws a horizontal line using the currently set color
+	 */
 	void hLine(int x1, int x2, int y);
+
+	/**
+	 * Draws a vertical line using an Xor on each pixel
+	 */
 	void vLineXor(int x, int y1, int y2);
+
+	/**
+	 * Draws a horizontal line using an Xor on each pixel
+	 */
 	void hLineXor(int x1, int x2, int y);
+
+	/**
+	 * Draws an arbitrary line on the screen using a specified color
+	 */
 	void line(int x1, int y1, int x2, int y2, byte color);
+
+	/**
+	 * Draws a rectangular frame using the currently set color
+	 */
 	void frameRect(int x1, int y1, int x2, int y2);
-	void fillRect(int x1, int y1, int x2, int y2);
 
-	static int scaleValue(int value, int scale, int err);	
-	void drawSprite(int x, int y, SpriteInfo &info, const Common::Rect &clipRect);
-
-	// Surface methods
-	int width() { return w; }
-	int height() { return h; }
-	void setSize(int sizeX, int sizeY);
-	byte *getData();
-	byte *getBasePtr(int x, int y);
-	void freeData();
-	void empty();
+	/**
+	 * Draws a rectangular frame using a specified color
+	 */
 	void frameRect(const Common::Rect &r, uint8 color);
+
+	/**
+	 * Draws a filled in box using the currently set color
+	 */
+	void fillRect(int x1, int y1, int x2, int y2);
+
+	/**
+	 * Draws a filled in box using a specified color
+	 */
 	void fillRect(const Common::Rect &r, uint8 color);
-	void copyFrom(MSurface *src, const Common::Rect &srcBounds, int destX, int destY,
-		int transparentColor = -1);
 
+	/**
+	 * Draws a sprite
+	 * @param pt		Position to draw sprite at
+	 * @param info		General sprite details
+	 * @param clipRect	Clipping rectangle to constrain sprite drawing within
+	 */
+	void drawSprite(const Common::Point &pt, SpriteInfo &info, const Common::Rect &clipRect);
+
+	/**
+	 * Returns the width of the surface
+	 */
+	int getWidth() const { return w; }
+
+	/**
+	 * Returns the height of the surface
+	 */
+	int getHeight() const { return h; }
+
+	/**
+	 * Returns a pointer to the surface data
+	 */
+	byte *getData() { return (byte *)Graphics::Surface::getPixels(); }
+	
+	/**
+	 * Returns a pointer to a given position within the surface
+	 */
+	byte *getBasePtr(int x, int y) { return (byte *)Graphics::Surface::getBasePtr(x, y); }
+
+	/**
+	 * Clears the surface
+	 */
+	void empty();
+
+	/**
+	 * Updates the surface. If it's the screen surface, copies it to the physical screen.
+	 */
 	void update() { 
 		if (_isScreen) {
 			g_system->copyRectToScreen((const byte *)pixels, pitch, 0, 0, w, h);
@@ -108,25 +194,67 @@ public:
 		}
 	}
 
-	// copyTo methods
+	/**
+	 * Copys a sub-section of another surface into the current one.
+	 * @param src			Source surface
+	 * @param srcBounds		Area of source surface to copy
+	 * @param destPos		Destination position to draw in current surface
+	 * @param transparentColor	Transparency palette index
+	 */
+	void copyFrom(MSurface *src, const Common::Rect &srcBounds, const Common::Point &destPos,
+		int transparentColor = -1);
+
+	/**
+	 * Copies the surface to a given destination surface
+	 */
 	void copyTo(MSurface *dest, int transparentColor = -1) { 
-		dest->copyFrom(this, Common::Rect(width(), height()), 0, 0, transparentColor);		
+		dest->copyFrom(this, Common::Rect(w, h), Common::Point(), transparentColor);		
 	}
-	void copyTo(MSurface *dest, int x, int y, int transparentColor = -1) {
-		dest->copyFrom(this, Common::Rect(width(), height()), x, y, transparentColor);
+
+	/**
+	 * Copies the surface to a given destination surface
+	 */
+	void copyTo(MSurface *dest, const Common::Point &pt, int transparentColor = -1) {
+		dest->copyFrom(this, Common::Rect(w, h), pt, transparentColor);
 	}
-	void copyTo(MSurface *dest, const Common::Rect &srcBounds, int destX, int destY,
+
+	/**
+	 * Copies the surface to a given destination surface
+	 */
+	void copyTo(MSurface *dest, const Common::Rect &srcBounds, const Common::Point &destPos,
 				int transparentColor = -1) {
-		dest->copyFrom(this, srcBounds, destX, destY, transparentColor);
+		dest->copyFrom(this, srcBounds, destPos, transparentColor);
 	}
 
+	/**
+	 * Translates the data of a surface using a specified RGBList translation matrix.
+	 */
 	void translate(RGBList *list, bool isTransparent = false);
 
 	// Base virtual methods
+	/**
+	 * Loads a background by scene name
+	 */
 	virtual void loadBackground(const Common::String &sceneName) {}
+
+	/**
+	 * Load background by room number
+	 */
 	virtual void loadBackground(int roomNumber, RGBList **palData) = 0;
+
+	/**
+	 * Load background from a passed stream
+	 */
 	virtual void loadBackground(Common::SeekableReadStream *source, RGBList **palData) {}
+
+	/**
+	 * Load scene codes from a passed stream
+	 */
 	virtual void loadCodes(Common::SeekableReadStream *source) = 0;
+
+	/**
+	 * Load a given user interface by index
+	 */
 	virtual void loadInterface(int index, RGBList **palData) {}
 };
 
@@ -134,7 +262,7 @@ class MSurfaceMADS: public MSurface {
 	friend class MSurface;
 protected:
 	MSurfaceMADS(bool isScreen = false): MSurface(isScreen) {}
-	MSurfaceMADS(int w, int h): MSurface(w, h) {}
+	MSurfaceMADS(int width, int height): MSurface(width, height) {}
 public:
 	virtual void loadCodes(Common::SeekableReadStream *source);
 	virtual void loadBackground(const Common::String &sceneName) {}
@@ -146,7 +274,7 @@ class MSurfaceNebular: public MSurfaceMADS {
 	friend class MSurface;
 protected:
 	MSurfaceNebular(bool isScreen = false): MSurfaceMADS(isScreen) {}
-	MSurfaceNebular(int w, int h): MSurfaceMADS(w, h) {}
+	MSurfaceNebular(int width, int height): MSurfaceMADS(width, height) {}
 private:
 	void loadBackgroundStream(Common::SeekableReadStream *source, RGBList **palData);
 public:
@@ -157,7 +285,7 @@ class MSurfaceM4: public MSurface {
 	friend class MSurface;
 protected:
 	MSurfaceM4(bool isScreen = false): MSurface(isScreen) {}
-	MSurfaceM4(int widthVal, int heightVal): MSurface(widthVal, heightVal) {}
+	MSurfaceM4(int width, int height): MSurface(width, height) {}
 
 	void loadBackgroundStream(Common::SeekableReadStream *source);
 public:
@@ -169,7 +297,7 @@ class MSurfaceRiddle: public MSurfaceM4 {
 	friend class MSurface;
 protected:
 	MSurfaceRiddle(bool isScreen = false): MSurfaceM4(isScreen) {}
-	MSurfaceRiddle(int widthVal, int heightVal): MSurfaceM4(widthVal, heightVal) {}
+	MSurfaceRiddle(int width, int height): MSurfaceM4(width, height) {}
 public:
 	virtual void loadBackground(const Common::String &sceneName);
 };


Commit: c687d3f64cc5ac6ec09539129c5f8b0d3a7148ad
    https://github.com/scummvm/scummvm/commit/c687d3f64cc5ac6ec09539129c5f8b0d3a7148ad
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-19T21:28:54-05:00

Commit Message:
MADS: Cleanup of palette code, updated old-style 4 byte RGB usage to 3 bytes

Changed paths:
    engines/mads/mads.cpp
    engines/mads/msurface.cpp
    engines/mads/msurface.h
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 0ddb6bf..36b5ec5 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -71,7 +71,7 @@ void MADSEngine::initialise() {
 	MSprite::setVm(this);
 
 	_events = new EventsManager(this);
-	_palette = new Palette(this);
+	_palette = Palette::init(this);
 	_font = Font::init(this);
 	_resources = new ResourcesManager(this);
 	_screen = MSurface::init(true);
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index b3a4510..e7cc08e 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -234,9 +234,9 @@ void MSurface::drawSprite(const Common::Point &pt, SpriteInfo &info, const Commo
 						} else {
 							byte destPixel = *tempDst;
 							byte r, g, b;
-							r = CLIP((info.palette[destPixel].r * pixel) >> 10, 0, 31);
-							g = CLIP((info.palette[destPixel].g * pixel) >> 10, 0, 31);
-							b = CLIP((info.palette[destPixel].b * pixel) >> 10, 0, 31);
+							r = CLIP((info.palette[destPixel * 3] * pixel) >> 10, 0, 31);
+							g = CLIP((info.palette[destPixel * 3 + 1] * pixel) >> 10, 0, 31);
+							b = CLIP((info.palette[destPixel * 3 + 2] * pixel) >> 10, 0, 31);
 							pixel = info.inverseColorTable[(b << 10) | (g << 5) | r];
 						}
 					}
@@ -429,10 +429,10 @@ void MSurfaceMADS::loadBackground(int roomNumber, RGBList **palData) {
 	tileDataUncomp = tileData.getItemStream(2);
 	// Set palette
 	if (!palData) {
-		_vm->_palette->setMadsPalette(tileDataUncomp, 4);
+		_vm->_palette->loadPalette(tileDataUncomp, 4);
 	} else {
 		int numColors;
-		RGB8 *rgbList = _vm->_palette->decodeMadsPalette(tileDataUncomp, &numColors);
+		byte *rgbList = _vm->_palette->decodePalette(tileDataUncomp, &numColors);
 		*palData = new RGBList(numColors, rgbList, true);
 	}
 	delete tileDataUncomp;
@@ -495,18 +495,16 @@ void MSurfaceMADS::loadInterface(int index, RGBList **palData) {
 	char resourceName[20];
 	sprintf(resourceName, "i%d.int", index);
 	MadsPack intFile(resourceName, _vm);
-	RGB8 *palette = new RGB8[16];
+	byte *palette = new byte[16 * 3];
 
 	// Chunk 0, palette
 	Common::SeekableReadStream *intStream = intFile.getItemStream(0);
 	
 	for (int i = 0; i < 16; i++) {
-		palette[i].r = intStream->readByte() << 2;
-		palette[i].g = intStream->readByte() << 2;
-		palette[i].b = intStream->readByte() << 2;
-		intStream->readByte();
-		intStream->readByte();
-		intStream->readByte();
+		palette[i * 3] = intStream->readByte() << 2;
+		palette[i * 3 + 1] = intStream->readByte() << 2;
+		palette[i * 3 + 2] = intStream->readByte() << 2;
+		intStream->skip(3);
 	}
 	*palData = new RGBList(16, palette, true);
 	delete intStream;
@@ -551,10 +549,10 @@ void MSurfaceNebular::loadBackgroundStream(Common::SeekableReadStream *source, R
 
 	// Set palette
 	if (!palData) {
-		_vm->_palette->setMadsPalette(sourceUnc, 4);
+		_vm->_palette->loadPalette(sourceUnc, 4);
 	} else {
 		int numColors;
-		RGB8 *rgbList = _vm->_palette->decodeMadsPalette(sourceUnc, &numColors);
+		byte *rgbList = _vm->_palette->decodePalette(sourceUnc, &numColors);
 		*palData = new RGBList(numColors, rgbList, true);
 	}
 	delete sourceUnc;
@@ -598,7 +596,7 @@ void MSurfaceM4::loadBackgroundStream(Common::SeekableReadStream *source) {
 	MSurface *tileBuffer = MSurface::init();
 	uint curTileX = 0, curTileY = 0;
 	int clipX = 0, clipY = 0;
-	RGB8 palette[256];
+	byte palette[256];
 
 	source->skip(4);
 	/*uint32 size =*/ source->readUint32LE();
@@ -612,12 +610,13 @@ void MSurfaceM4::loadBackgroundStream(Common::SeekableReadStream *source) {
 
 	// BGR data, which is converted to RGB8
 	for (uint i = 0; i < 256; i++) {
-		palette[i].b = source->readByte() << 2;
-		palette[i].g = source->readByte() << 2;
-		palette[i].r = source->readByte() << 2;
-		palette[i].u = source->readByte() << 2;
+		byte r, g, b;
+		palette[i * 3] = r = source->readByte() << 2;
+		palette[i * 3 + 1] = g = source->readByte() << 2;
+		palette[i * 3 + 2] = b = source->readByte() << 2;
+		source->skip(1);
 
-		if ((blackIndex == 0) && !palette[i].r && !palette[i].g && !palette[i].b)
+		if ((blackIndex == 0) && !r && !g && !b)
 			blackIndex = i;
 	}
 	
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index 05777d3..fe6d1f2 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -43,7 +43,7 @@ struct SpriteInfo {
 	int scaleX, scaleY;
 	uint8 encoding;
 	byte *inverseColorTable;
-	RGB8 *palette;
+	byte *palette;
 };
 
 /*
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index cfd8568..6a5d507 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -28,12 +28,12 @@
 
 namespace MADS {
 
-RGBList::RGBList(int numEntries, RGB8 *srcData, bool freeData) {
+RGBList::RGBList(int numEntries, byte *srcData, bool freeData) {
 	_size = numEntries;
-	assert(numEntries <= 256);
+	assert(numEntries <= PALETTE_COUNT);
 
 	if (srcData == NULL) {
-		_data = new RGB8[numEntries];
+		_data = new byte[numEntries * 3];
 		_freeData = true;
 	} else {
 		_data = srcData;
@@ -54,10 +54,18 @@ RGBList::~RGBList() {
 
 #define VGA_COLOR_TRANS(x) (x == 0x3f ? 255 : x << 2)
 
+Palette *Palette::init(MADSEngine *vm) {
+	if (vm->getGameFeatures() & GF_MADS) {
+		return new PaletteMADS(vm);
+	} else {
+		return new PaletteM4(vm);
+	}
+}
+
 Palette::Palette(MADSEngine *vm) : _vm(vm) {
 	reset();
 	_fading_in_progress = false;
-	Common::fill(&_usageCount[0], &_usageCount[256], 0);
+	Common::fill(&_usageCount[0], &_usageCount[PALETTE_COUNT], 0);
 }
 
 void Palette::setPalette(const byte *colors, uint start, uint num) {
@@ -65,31 +73,26 @@ void Palette::setPalette(const byte *colors, uint start, uint num) {
 	reset();
 }
 
-void Palette::setPalette(const RGB8 *colors, uint start, uint num) {
-	g_system->getPaletteManager()->setPalette((const byte *)colors, start, num);
-	reset();
-}
-
 void Palette::grabPalette(byte *colors, uint start, uint num) {
 	g_system->getPaletteManager()->grabPalette(colors, start, num);
 	reset();
 }
 
-uint8 Palette::palIndexFromRgb(byte r, byte g, byte b, RGB8 *paletteData) {
+uint8 Palette::palIndexFromRgb(byte r, byte g, byte b, byte *paletteData) {
 	byte index = 0;
 	int32 minDist = 0x7fffffff;
-	RGB8 palData[256];
+	byte palData[PALETTE_SIZE];
 	int Rdiff, Gdiff, Bdiff;
 
 	if (paletteData == NULL) {
-		g_system->getPaletteManager()->grabPalette((byte *)palData, 0, 256);
+		g_system->getPaletteManager()->grabPalette(palData, 0, PALETTE_COUNT);
 		paletteData = &palData[0];
 	}
 
-	for (int palIndex = 0; palIndex < 256; ++palIndex) {
-		Rdiff = r - paletteData[palIndex].r;
-		Gdiff = g - paletteData[palIndex].g;
-		Bdiff = b - paletteData[palIndex].b;
+	for (int palIndex = 0; palIndex < PALETTE_COUNT; ++palIndex) {
+		Rdiff = r - paletteData[palIndex * 3];
+		Gdiff = g - paletteData[palIndex * 3 + 1];
+		Bdiff = b - paletteData[palIndex * 3 + 2];
 
 		if (Rdiff * Rdiff + Gdiff * Gdiff + Bdiff * Bdiff < minDist) {
 			minDist = Rdiff * Rdiff + Gdiff * Gdiff + Bdiff * Bdiff;
@@ -101,8 +104,8 @@ uint8 Palette::palIndexFromRgb(byte r, byte g, byte b, RGB8 *paletteData) {
 }
 
 void Palette::reset() {
-	RGB8 palData[256];
-	g_system->getPaletteManager()->grabPalette((byte *)palData, 0, 256);
+	byte palData[PALETTE_SIZE];
+	g_system->getPaletteManager()->grabPalette(palData, 0, PALETTE_COUNT);
 
 	BLACK = palIndexFromRgb(0, 0, 0, palData);
 	BLUE = palIndexFromRgb(0, 0, 255, palData);
@@ -126,13 +129,13 @@ void Palette::fadeIn(int numSteps, uint delayAmount, RGBList *destPalette) {
 	fadeIn(numSteps, delayAmount, destPalette->data(), destPalette->size());
 }
 
-void Palette::fadeIn(int numSteps, uint delayAmount, RGB8 *destPalette, int numColors) {
+void Palette::fadeIn(int numSteps, uint delayAmount, byte *destPalette, int numColors) {
 	if (_fading_in_progress)
 		return;
 
 	_fading_in_progress = true;
-	RGB8 blackPalette[256];
-	Common::fill((byte *)&blackPalette[0], (byte *)&blackPalette[256], 0);
+	byte blackPalette[PALETTE_SIZE];
+	Common::fill(&blackPalette[0], &blackPalette[PALETTE_SIZE], 0);
 
 	// Initially set the black palette
 	_vm->_palette->setPalette(blackPalette, 0, numColors);
@@ -143,52 +146,8 @@ void Palette::fadeIn(int numSteps, uint delayAmount, RGB8 *destPalette, int numC
 	_fading_in_progress = false;
 }
 
-RGB8 *Palette::decodeMadsPalette(Common::SeekableReadStream *palStream, int *numColors) {
-	*numColors = palStream->readUint16LE();
-	assert(*numColors <= 252);
-
-	RGB8 *palData = new RGB8[*numColors];
-	Common::fill((byte *)&palData[0], (byte *)&palData[*numColors], 0);
-
-	for (int i = 0; i < *numColors; ++i) {
-		byte r = palStream->readByte();
-		byte g = palStream->readByte();
-		byte b = palStream->readByte();
-		palData[i].r = VGA_COLOR_TRANS(r);
-		palData[i].g = VGA_COLOR_TRANS(g);
-		palData[i].b = VGA_COLOR_TRANS(b);
-
-		// The next 3 bytes are unused
-		palStream->skip(3);
-	}
-
-	return palData;
-}
-
-int Palette::setMadsPalette(Common::SeekableReadStream *palStream, int indexStart) {
-	int colorCount;
-	RGB8 *palData = Palette::decodeMadsPalette(palStream, &colorCount);
-	_vm->_palette->setPalette(palData, indexStart, colorCount);
-	delete palData;
-	return colorCount;
-}
-
-void Palette::setMadsSystemPalette() {
-	// Rex Nebular default system palette
-	resetColorCounts();
-
-	RGB8 palData[4];
-	palData[0].r = palData[0].g = palData[0].b = 0;
-	palData[1].r = palData[1].g = palData[1].b = 0x54;
-	palData[2].r = palData[2].g = palData[2].b = 0xb4;
-	palData[3].r = palData[3].g = palData[3].b = 0xff;
-	
-	setPalette(palData, 0, 4);
-	blockRange(0, 4);
-}
-
 void Palette::resetColorCounts() {
-	Common::fill(&_usageCount[0], &_usageCount[256], 0);
+	Common::fill(&_usageCount[0], &_usageCount[PALETTE_COUNT], 0);
 }
 
 void Palette::blockRange(int startIndex, int size) {
@@ -197,41 +156,41 @@ void Palette::blockRange(int startIndex, int size) {
 }
 
 void Palette::addRange(RGBList *list) {
-	RGB8 *data = list->data();
+	byte *data = list->data();
 	byte *palIndexes = list->palIndexes();
-	RGB8 palData[256];
-	g_system->getPaletteManager()->grabPalette((byte *)&palData[0], 0, 256);
+	byte palData[PALETTE_COUNT];
+	g_system->getPaletteManager()->grabPalette(palData, 0, PALETTE_COUNT);
 	bool paletteChanged = false;
 	
 	for (int colIndex = 0; colIndex < list->size(); ++colIndex) {
 		// Scan through for an existing copy of the RGB value
 		int palIndex = -1; 
-		while (++palIndex < 256) {
+		while (++palIndex < PALETTE_COUNT) {
 			if (_usageCount[palIndex] <= 0)
 				// Palette index is to be skipped
 				continue;
 
-			if ((palData[palIndex].r == data[colIndex].r) && 
-				(palData[palIndex].g == data[colIndex].g) &&
-				(palData[palIndex].b == data[colIndex].b)) 
+			if ((palData[palIndex * 3] == data[colIndex * 3]) && 
+				(palData[palIndex * 3 + 1] == data[colIndex * 3 + 1]) &&
+				(palData[palIndex * 3 + 2] == data[colIndex * 3 + 2])) 
 				// Match found
 				break;
 		}
 
-		if (palIndex == 256) {
+		if (palIndex == PALETTE_COUNT) {
 			// No match found, so find a free slot to use
 			palIndex = -1;
-			while (++palIndex < 256) {
+			while (++palIndex < PALETTE_COUNT) {
 				if (_usageCount[palIndex] == 0)
 					break;
 			}
 
-			if (palIndex == 256) 
+			if (palIndex == PALETTE_COUNT) 
 				error("addRange - Ran out of palette space to allocate");
 
-			palData[palIndex].r = data[colIndex].r;
-			palData[palIndex].g = data[colIndex].g;
-			palData[palIndex].b = data[colIndex].b;
+			palData[palIndex * 3] = data[colIndex * 3];
+			palData[palIndex * 3 + 1] = data[colIndex * 3 + 1];
+			palData[palIndex * 3 + 2] = data[colIndex * 3 + 2];
 			paletteChanged = true;
 		}
 
@@ -240,7 +199,7 @@ void Palette::addRange(RGBList *list) {
 	}
 
 	if (paletteChanged) {
-		g_system->getPaletteManager()->setPalette((byte *)&palData[0], 0, 256);
+		g_system->getPaletteManager()->setPalette(&palData[0], 0, 256);
 		reset();
 	}
 }
@@ -259,9 +218,9 @@ void Palette::deleteAllRanges() {
 		_usageCount[colIndex] = 0;
 }
 
-void Palette::fadeRange(RGB8 *srcPal, RGB8 *destPal,  int startIndex, int endIndex, 
+void Palette::fadeRange(byte *srcPal, byte *destPal,  int startIndex, int endIndex, 
 					 int numSteps, uint delayAmount) {
-	RGB8 tempPal[256];
+	byte tempPal[256 * 3];
 
 	// perform the fade
 	for(int stepCtr = 1; stepCtr <= numSteps; ++stepCtr) {
@@ -274,16 +233,62 @@ void Palette::fadeRange(RGB8 *srcPal, RGB8 *destPal,  int startIndex, int endInd
 
 		for (int i = startIndex; i <= endIndex; ++i) {
 			// Handle the intermediate rgb values for fading
-			tempPal[i].r = (byte) (srcPal[i].r + (destPal[i].r - srcPal[i].r) * stepCtr / numSteps);   
-			tempPal[i].g = (byte) (srcPal[i].g + (destPal[i].g - srcPal[i].g) * stepCtr / numSteps); 
-			tempPal[i].b = (byte) (srcPal[i].b + (destPal[i].b - srcPal[i].b) * stepCtr / numSteps); 
+			tempPal[i * 3] = (byte) (srcPal[i * 3] + (destPal[i * 3] - srcPal[i * 3]) * stepCtr / numSteps);   
+			tempPal[i * 3 + 1] = (byte) (srcPal[i * 3 + 1] + (destPal[i * 3 + 1] - srcPal[i * 3 + 1]) * stepCtr / numSteps); 
+			tempPal[i * 3 + 2] = (byte) (srcPal[i * 3 + 2] + (destPal[i * 3 + 2] - srcPal[i * 3 + 2]) * stepCtr / numSteps); 
 		}
 		
-		_vm->_palette->setPalette(&tempPal[startIndex], startIndex, endIndex - startIndex + 1);
+		_vm->_palette->setPalette(&tempPal[startIndex * 3], startIndex, endIndex - startIndex + 1);
 	}
 
 	// Make sure the end palette exactly matches what is wanted
-	_vm->_palette->setPalette(&destPal[startIndex], startIndex, endIndex - startIndex + 1);
+	_vm->_palette->setPalette(&destPal[startIndex * 3], startIndex, endIndex - startIndex + 1);
+}
+
+/*------------------------------------------------------------------------*/
+
+byte *PaletteMADS::decodePalette(Common::SeekableReadStream *palStream, int *numColors) {
+	*numColors = palStream->readUint16LE();
+	assert(*numColors <= 252);
+
+	byte *palData = new byte[*numColors * 3];
+	Common::fill(&palData[0], &palData[*numColors * 3], 0);
+
+	for (int i = 0; i < *numColors; ++i) {
+		byte r = palStream->readByte();
+		byte g = palStream->readByte();
+		byte b = palStream->readByte();
+		palData[i * 3] = VGA_COLOR_TRANS(r);
+		palData[i * 3 + 1] = VGA_COLOR_TRANS(g);
+		palData[i * 3 + 2] = VGA_COLOR_TRANS(b);
+
+		// The next 3 bytes are unused
+		palStream->skip(3);
+	}
+
+	return palData;
+}
+
+int PaletteMADS::loadPalette(Common::SeekableReadStream *palStream, int indexStart) {
+	int colorCount;
+	byte *palData = decodePalette(palStream, &colorCount);
+	_vm->_palette->setPalette(palData, indexStart, colorCount);
+
+	delete palData;
+	return colorCount;
+}
+
+void PaletteMADS::setSystemPalette() {
+	resetColorCounts();
+
+	byte palData[4 * 3];
+	palData[0 * 3] = palData[0 * 3 + 1] = palData[0 * 3 + 2] = 0;
+	palData[1 * 3] = palData[1 * 3 + 1] = palData[1 * 3 + 2] = 0x54;
+	palData[2 * 3] = palData[2 * 3 + 1] = palData[2 * 3 + 2] = 0xb4;
+	palData[3 * 3] = palData[3 * 3 + 1] = palData[3 * 3 + 2] = 0xff;
+	
+	setPalette(palData, 0, 4);
+	blockRange(0, 4);
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index ab03d8d..a5d9c6a 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -29,63 +29,137 @@ namespace MADS {
 
 class MADSEngine;
 
-struct RGB8 {
-	uint8 r, g, b, u;
-};
-
+/**
+ * Used to store a list of RGB values
+ */
 class RGBList {
 private:
 	int _size;
-	RGB8 *_data;
+	byte *_data;
 	byte *_palIndexes;
 	bool _freeData;
 public:
-	RGBList(int numEntries = 256, RGB8 *srcData = NULL, bool freeData = true);
+	/** 
+	 * Constructor
+	 */
+	RGBList(int numEntries = 256, byte *srcData = NULL, bool freeData = true);
+
+	/**
+	 * Destructor
+	 */
 	~RGBList();
 
-	RGB8 *data() { return _data; }
+	/**
+	 * Returns the raw data containing the RGB values as 3 bytes per entry
+	 */
+	byte *data() { return _data; }
+
+	/**
+	 * Returns the list of palette indexes each RGB tuple maps to in the current palette
+	 */
 	byte *palIndexes() { return _palIndexes; }
-	int size() { return _size; }
+
+	/**
+	 * Returns the size of the palette
+	 */
+	int size() const { return _size; }
 };
 
 #define PALETTE_COUNT 256
+#define PALETTE_SIZE (256 * 3)
 
 class Palette {
 private:
+	/**
+	 * Support method used by the fading code
+	 */
+	void fadeRange(byte *srcPal, byte *destPal,  int startIndex, int endIndex, 
+		int numSteps, uint delayAmount);
+protected:
 	MADSEngine *_vm;
 	bool _colorsChanged;
+
 	bool _fading_in_progress;
 	byte _originalPalette[PALETTE_COUNT * 4];
 	byte _fadedPalette[PALETTE_COUNT * 4];
 	int _usageCount[PALETTE_COUNT];
 
+	Palette(MADSEngine *vm);
 	void reset();
 public:
-	Palette(MADSEngine *vm);
-
+	/**
+	 * Creates a new palette instance
+	 */
+	static Palette *init(MADSEngine *vm);
+
+	/**
+	 * Sets a new palette
+	 */
 	void setPalette(const byte *colors, uint start, uint num);
-	void setPalette(const RGB8 *colors, uint start, uint num);
-	void grabPalette(byte *colors, uint start, uint num);
-	void grabPalette(RGB8 *colors, uint start, uint num) {
-		grabPalette((byte *)colors, start, num);
-	}
-	uint8 palIndexFromRgb(byte r, byte g, byte b, RGB8 *paletteData = NULL);
 
-	void fadeIn(int numSteps, uint delayAmount, RGB8 *destPalette, int numColors);
+	/**
+	 * Returns a subset of the currently loaded palette
+	 */
+	void grabPalette(byte *colors, uint start, uint num);
+	
+	/**
+	 * Returns the palette index in the palette that most closely matches the
+	 * specified RGB pair
+	 */
+	uint8 palIndexFromRgb(byte r, byte g, byte b, byte *paletteData = nullptr);
+
+	/**
+	 * Performs a fade in
+	 */
+	void fadeIn(int numSteps, uint delayAmount, byte *destPalette, int numColors);
+
+	/**
+	 * Performs a fade in
+	 */
 	void fadeIn(int numSteps, uint delayAmount, RGBList *destPalette);
-	static RGB8 *decodeMadsPalette(Common::SeekableReadStream *palStream,  int *numColors);
-	int setMadsPalette(Common::SeekableReadStream *palStream, int indexStart = 0);
-	void setMadsSystemPalette();
-	void fadeRange(RGB8 *srcPal, RGB8 *destPal,  int startIndex, int endIndex, 
-		int numSteps, uint delayAmount);
 
 	// Methods used for reference counting color usage
+	/**
+	 * Resets the usage counts for the palette
+	 */
 	void resetColorCounts();
+
+	/**
+	 * Blocks out a range of the palette from being used
+	 */
 	void blockRange(int startIndex, int size);
+
+	/**
+	 * Adds the data of an RGBList into the current palette and increment usage counts.
+	 */
 	void addRange(RGBList *list);
+
+	/**
+	 * Delets a range from the current palette, dercementing the accompanying usage counts.
+	 */
 	void deleteRange(RGBList *list);
+
+	/**
+	 * Deletes all loaded RGB lists are their usage references.
+	 */
 	void deleteAllRanges();
 
+	// Virtual method table
+	/**
+	 * Decode a palette and return it, without affecting the Palette itself
+	 */
+	virtual byte *decodePalette(Common::SeekableReadStream *palStream, int *numColors) = 0;
+
+	/**
+	 * Loads a palette from a stream
+	 */
+	virtual int loadPalette(Common::SeekableReadStream *palStream, int indexStart = 0) = 0;
+
+	/**
+	 * Sets a small set of system/core colors needed by the game
+	 */
+	virtual void setSystemPalette() = 0;
+
 	// Color indexes
 	uint8 BLACK;
 	uint8 BLUE;
@@ -105,6 +179,30 @@ public:
 	uint8 WHITE;
 };
 
+class PaletteMADS: protected Palette {
+	friend class Palette;
+protected:
+	PaletteMADS(MADSEngine *vm): Palette(vm) {}
+public:
+	virtual byte *decodePalette(Common::SeekableReadStream *palStream, int *numColors);
+	virtual int loadPalette(Common::SeekableReadStream *palStream, int indexStart = 0);
+	virtual void setSystemPalette();
+};
+
+class PaletteM4: protected Palette {
+	friend class Palette;
+protected:
+	PaletteM4(MADSEngine *vm): Palette(vm) {}
+public:
+	virtual byte *decodePalette(Common::SeekableReadStream *palStream, int *numColors) {
+		return nullptr;
+	}
+	virtual int loadPalette(Common::SeekableReadStream *palStream, int indexStart = 0) {
+		return 0;
+	}
+	virtual void setSystemPalette() {}
+};
+
 } // End of namespace MADS
 
 #endif /* MADS_PALETTE_H */


Commit: 1b0c1b3f561576cbcd7c1494d3893200442dace4
    https://github.com/scummvm/scummvm/commit/1b0c1b3f561576cbcd7c1494d3893200442dace4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-19T21:31:41-05:00

Commit Message:
MADS: Fix GCC warnings

Changed paths:
    engines/mads/font.cpp
    engines/mads/palette.h



diff --git a/engines/mads/font.cpp b/engines/mads/font.cpp
index 9da46c3..e97cc95 100644
--- a/engines/mads/font.cpp
+++ b/engines/mads/font.cpp
@@ -112,14 +112,14 @@ int Font::write(MSurface *surface, const Common::String &msg, const Common::Poin
 	const char *text = msg.c_str();
 	while (*text) {
 		char theChar = (*text++) & 0x7F;
-		int charWidth = _charWidths[theChar];
+		int charWidth = _charWidths[(byte)theChar];
 		
 		if (charWidth > 0) {
 
 			if (xPos + charWidth >= width)
 				return xPos;
 
-			uint8 *charData = &_charData[_charOffs[theChar]];
+			uint8 *charData = &_charData[_charOffs[(byte)theChar]];
 			int bpp = getBpp(charWidth);
 
 			if (skipY != 0)
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index a5d9c6a..a97d5de 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -91,6 +91,11 @@ public:
 	 * Creates a new palette instance
 	 */
 	static Palette *init(MADSEngine *vm);
+	
+	/**
+	 * Destructor
+	 */
+	virtual ~Palette() {}
 
 	/**
 	 * Sets a new palette


Commit: 488bf66c3e451a65ab14a387f681fb91aa5c6253
    https://github.com/scummvm/scummvm/commit/488bf66c3e451a65ab14a387f681fb91aa5c6253
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-19T21:56:38-05:00

Commit Message:
MADS: Fix memory leaks in MSurface

Changed paths:
    engines/mads/msurface.cpp
    engines/mads/msurface.h



diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index e7cc08e..f71a4a7 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -51,16 +51,27 @@ MSurface *MSurface::init(int width, int height) {
 	}
 }
 
-MSurface::MSurface(bool isScreen) { 
+MSurface::MSurface(bool isScreen) {
+	pixels = nullptr;
 	setSize(g_system->getWidth(), g_system->getHeight());
 	_isScreen = isScreen;
 }
 
 MSurface::MSurface(int width, int height) { 
+	pixels = nullptr;
 	setSize(width, height); 
 	_isScreen = false; 
 }
 
+MSurface::~MSurface() {
+	Graphics::Surface::free();
+}
+
+void MSurface::setSize(int width, int height) {
+	Graphics::Surface::free();
+	Graphics::Surface::create(width, height, Graphics::PixelFormat::createFormatCLUT8());
+}
+
 void MSurface::vLine(int x, int y1, int y2) {
 	Graphics::Surface::vLine(x, y1, y2, _color);
 }
@@ -271,7 +282,7 @@ void MSurface::drawSprite(const Common::Point &pt, SpriteInfo &info, const Commo
 }
 
 void MSurface::empty() {
-	Common::fill(getBasePtr(0, 0), getBasePtr(w, h), _vm->_palette->BLACK);
+	Common::fill(getBasePtr(0, 0), getBasePtr(0, h), _vm->_palette->BLACK);
 }
 
 void MSurface::frameRect(const Common::Rect &r, uint8 color) {
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index fe6d1f2..42c56e9 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -87,14 +87,15 @@ public:
 	 */
 	static int scaleValue(int value, int scale, int err);	
 public:
-	virtual ~MSurface() {}
+	/**
+	 * Destructor
+	 */
+	virtual ~MSurface();
 
 	/**
 	 * Reinitialises a surface to have a given set of dimensions
 	 */
-	void setSize(int width, int height) {
-		Graphics::Surface::create(width, height, Graphics::PixelFormat::createFormatCLUT8());
-	}
+	void setSize(int width, int height);
 
 	/**
 	 * Sets the color used for drawing on the surface


Commit: 7593ec29d060268b7102509324d83e87c4ddd77c
    https://github.com/scummvm/scummvm/commit/7593ec29d060268b7102509324d83e87c4ddd77c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-19T22:01:10-05:00

Commit Message:
MADS: Fix feature flags for Rex Nebular detection entry

Changed paths:
    engines/mads/detection.cpp
    engines/mads/detection_tables.h



diff --git a/engines/mads/detection.cpp b/engines/mads/detection.cpp
index 73a4b97..015859f 100644
--- a/engines/mads/detection.cpp
+++ b/engines/mads/detection.cpp
@@ -48,7 +48,7 @@ uint32 MADSEngine::getGameID() const {
 }
 
 uint32 MADSEngine::getGameFeatures() const {
-	return _gameDescription->gameID;
+	return _gameDescription->features;
 }
 
 uint32 MADSEngine::getFeatures() const {
diff --git a/engines/mads/detection_tables.h b/engines/mads/detection_tables.h
index 7a66029..7410dce 100644
--- a/engines/mads/detection_tables.h
+++ b/engines/mads/detection_tables.h
@@ -37,6 +37,8 @@ static const MADSGameDescription gameDescriptions[] = {
 			ADGF_NO_FLAGS,
 			GUIO1(GUIO_NONE)
 		},
+		GType_RexNebular,
+		GF_MADS
 	},
 
 	{ AD_TABLE_END_MARKER }


Commit: 58bb1383d0b11d357128ca2b0a7634f091c0fb5b
    https://github.com/scummvm/scummvm/commit/58bb1383d0b11d357128ca2b0a7634f091c0fb5b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-19T23:17:57-05:00

Commit Message:
MADS: Added skeleton files for the game and dialogs

Changed paths:
  A engines/mads/nebular/dialogs_nebular.cpp
  A engines/mads/nebular/dialogs_nebular.h
  A engines/mads/nebular/game_nebular.cpp
  A engines/mads/nebular/game_nebular.h
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/module.mk



diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 8d6262a..0950ac0 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -22,6 +22,7 @@
 
 #include "common/scummsys.h"
 #include "common/events.h"
+#include "engines/util.h"
 #include "mads/mads.h"
 #include "mads/events.h"
 
@@ -31,4 +32,12 @@ EventsManager::EventsManager(MADSEngine *vm) {
 	_vm = vm;
 }
 
+void EventsManager::handleEvents() {
+	Common::Event e;
+	while (!_vm->shouldQuit()) {
+		g_system->getEventManager()->pollEvent(e);
+		g_system->delayMillis(10);
+	}
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/events.h b/engines/mads/events.h
index ea52c7a..33d5c8e 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -35,7 +35,7 @@ private:
 public:
 	EventsManager(MADSEngine *vm);
 
-	void handleEvents() { /* TODO */ }
+	void handleEvents();
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 491117f..0a04fda 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -23,17 +23,29 @@
 #include "common/scummsys.h"
 #include "mads/mads.h"
 #include "mads/game.h"
+#include "mads/nebular/game_nebular.h"
 #include "mads/graphics.h"
 #include "mads/msurface.h"
 
 namespace MADS {
 
 Game *Game::init(MADSEngine *vm) {
-	return new Game(vm);
+	if (vm->getGameID() == GType_RexNebular)
+		return new Nebular::GameNebular(vm);
+
+	return nullptr;
+}
+
+Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr) {
+}
+
+Game::~Game() {
+	delete _surface;
 }
 
-Game::Game(MADSEngine *vm): _vm(vm), _surface(MSurface::init(
-		MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT)) {
+void Game::run() {
+	if (!checkCopyProtection())
+		return;
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 190dc88..2f0dcf7 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -30,15 +30,25 @@ namespace MADS {
 class MADSEngine;
 
 class Game {
-private:
+protected:
 	MADSEngine *_vm;
 	MSurface *_surface;
 
 	Game(MADSEngine *vm);
+
+	/**
+	 * Perform any copy protection check
+	 */
+	virtual bool checkCopyProtection() = 0;
 public:
 	static Game *init(MADSEngine *vm);
 public:
-	~Game();
+	virtual ~Game();
+
+	/**
+	 * Run the game
+	 */
+	void run();
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 36b5ec5..05c1140 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -44,6 +44,7 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :
 
 	_events = nullptr;
 	_font = nullptr;
+	_game = nullptr;
 	_palette = nullptr;
 	_resources = nullptr;
 	_screen = nullptr;
@@ -54,6 +55,7 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :
 MADSEngine::~MADSEngine() {
 	delete _events;
 	delete _font;
+	delete _game;
 	delete _palette;
 	delete _resources;
 	delete _screen;
@@ -77,6 +79,7 @@ void MADSEngine::initialise() {
 	_screen = MSurface::init(true);
 	_sound = new SoundManager(this, _mixer);
 	_userInterface = UserInterface::init(this);
+	_game = Game::init(this);
 
 	_screen->empty();
 }
@@ -85,11 +88,11 @@ Common::Error MADSEngine::run() {
 	initGraphics(MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT, false);
 	initialise();
 
-	Common::Event e;
-	while (!shouldQuit()) {
-		g_system->getEventManager()->pollEvent(e);
-		g_system->delayMillis(10);
-	}
+	// Run the game
+	_game->run();
+
+	// Dummy loop to keep application active
+	_events->handleEvents();
 
 	return Common::kNoError;
 }
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index 86a5499..a6ae776 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -32,6 +32,7 @@
 #include "graphics/surface.h"
 #include "mads/events.h"
 #include "mads/font.h"
+#include "mads/game.h"
 #include "mads/msurface.h"
 #include "mads/resources.h"
 #include "mads/sound.h"
@@ -91,6 +92,7 @@ protected:
 public:
 	EventsManager *_events;
 	Font *_font;
+	Game *_game;
 	Palette *_palette;
 	ResourcesManager *_resources;
 	MSurface *_screen;
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 401b909..3f78103 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -1,6 +1,8 @@
 MODULE := engines/mads
 
 MODULE_OBJS := \
+	nebular/dialogs_nebular.o \
+	nebular/game_nebular.o \
 	compression.o \
 	detection.o \
 	events.o \
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
new file mode 100644
index 0000000..5aede49
--- /dev/null
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -0,0 +1,37 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "common/config-manager.h"
+#include "mads/mads.h"
+#include "mads/graphics.h"
+#include "mads/msurface.h"
+#include "mads/nebular/dialogs_nebular.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+
+} // End of namespace Nebular
+
+} // End of namespace MADS
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
new file mode 100644
index 0000000..669ac1e
--- /dev/null
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_GAME_NEBULAR_H
+#define MADS_GAME_NEBULAR_H
+
+#include "common/scummsys.h"
+#include "mads/game.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+class CopyProtectionDialog {
+public:
+	static bool show() { return false; }
+};
+
+} // End of namespace Nebular
+
+} // End of namespace MADS
+
+#endif /* MADS_GAME_NEBULAR_H */
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
new file mode 100644
index 0000000..43d705f
--- /dev/null
+++ b/engines/mads/nebular/game_nebular.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/scummsys.h"
+#include "common/config-manager.h"
+#include "mads/mads.h"
+#include "mads/game.h"
+#include "mads/graphics.h"
+#include "mads/msurface.h"
+#include "mads/nebular/game_nebular.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+GameNebular::GameNebular(MADSEngine *vm): Game(vm) {
+	_surface =MSurface::init(MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT);
+}
+
+bool GameNebular::checkCopyProtection() {
+	if (!ConfMan.getBool("copy_protection") || (ConfMan.hasKey("passed_protection") &&
+			ConfMan.getInt("passed_protection") == 1))
+		return true;
+
+	return false;
+}
+
+} // End of namespace Nebular
+
+} // End of namespace MADS
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
new file mode 100644
index 0000000..b0f088f
--- /dev/null
+++ b/engines/mads/nebular/game_nebular.h
@@ -0,0 +1,45 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_GAME_NEBULAR_H
+#define MADS_GAME_NEBULAR_H
+
+#include "common/scummsys.h"
+#include "mads/game.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+class GameNebular: public Game {
+	friend class Game;
+protected:
+	GameNebular(MADSEngine *vm);
+
+	virtual bool checkCopyProtection();
+};
+
+} // End of namespace Nebular
+
+} // End of namespace MADS
+
+#endif /* MADS_GAME_NEBULAR_H */


Commit: de384bae2ef1b904224b0fe00326e5a0597aafb6
    https://github.com/scummvm/scummvm/commit/de384bae2ef1b904224b0fe00326e5a0597aafb6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-19T23:21:05-05:00

Commit Message:
MADS: Moved sound_nebular file into new nebular/ folder

Changed paths:
  A engines/mads/nebular/sound_nebular.cpp
  A engines/mads/nebular/sound_nebular.h
  R engines/mads/sound_nebular.cpp
  R engines/mads/sound_nebular.h
    engines/mads/module.mk
    engines/mads/sound.h



diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 3f78103..9d115b8 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -3,6 +3,7 @@ MODULE := engines/mads
 MODULE_OBJS := \
 	nebular/dialogs_nebular.o \
 	nebular/game_nebular.o \
+	nebular/sound_nebular.o \
 	compression.o \
 	detection.o \
 	events.o \
@@ -15,7 +16,6 @@ MODULE_OBJS := \
 	palette.o \
 	resources.o \
 	sound.o \
-	sound_nebular.o \
 	user_interface.o
 
 # This module can be built as a plugin
diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp
new file mode 100644
index 0000000..9c3ac61
--- /dev/null
+++ b/engines/mads/nebular/sound_nebular.cpp
@@ -0,0 +1,1180 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 "audio/audiostream.h"
+#include "audio/decoders/raw.h"
+#include "common/algorithm.h"
+#include "common/debug.h"
+#include "common/memstream.h"
+#include "mads/sound.h"
+#include "mads/nebular/sound_nebular.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+AdlibChannel::AdlibChannel() {
+	_activeCount = 0;
+	_field1 = 0;
+	_field2 = 0;
+	_field3 = 0;
+	_field4 = 0;
+	_sampleIndex = 0;
+	_volume = 0;
+	_field7 = 0;
+	_field8 = 0;
+	_field9 = 0;
+	_fieldA = 0;
+	_fieldB = 0;
+	_fieldC = 0;
+	_fieldD = 0;
+	_fieldE = 0;
+	_ptr1 = nullptr;
+	_pSrc = nullptr;
+	_ptr3 = nullptr;
+	_ptr4 = nullptr;
+	_field17 = 0;
+	_field19 = 0;
+	_soundData = nullptr;
+	_field1D = 0;
+	_field1E = 0;
+	_field1F = 0;
+}
+
+void AdlibChannel::reset() {
+	_activeCount = 0;
+	_field1 = 0;
+	_field2 = 0;
+	_field3 = 0;
+}
+
+void AdlibChannel::enable(int flag) {
+	if (_activeCount) {
+		_fieldE = flag;
+
+		// WORKAROUND: Original set _soundData pointer to flag. Since this seems
+		// just intended to invalidate any prior pointer, I've replaced it with
+		// a simple null pointer
+		_soundData = nullptr; 
+	}
+}
+
+void AdlibChannel::setPtr2(byte *pData) {
+	_pSrc = pData;
+	_field2 = 0xFF;
+	_fieldA = 1;
+	_field9 = 1;
+}
+
+void AdlibChannel::load(byte *pData) {
+	_ptr1 = _pSrc = _ptr3 = pData;
+	_ptr4 = _soundData = pData;
+	_fieldA = 0xFF;
+	_activeCount = 1;
+	_fieldD = 64;
+	_field1 = 0;
+	_field1F = 0;
+	_field2 = _field3 = 0;
+	_volume = _field7 = 0;
+	_field1D = _field1E = 0;
+	_fieldE = 0;
+	_field9 = 0;
+	_fieldB = 0;
+	_field17 = 0;
+	_field19 = 0;
+}
+
+void AdlibChannel::check(byte *nullPtr) {
+	if (_activeCount && _fieldE) {
+		if (!_field1E) {
+			_pSrc = nullPtr;
+			_fieldE = 0;
+		} else {
+			_field2 = 0xFF;
+			_fieldA = 4;
+			if (!_field9)
+				_field9 = 1;
+		}
+	}
+}
+
+/*-----------------------------------------------------------------------*/
+
+AdlibSample::AdlibSample(Common::SeekableReadStream &s) {
+	_attackRate = s.readByte();
+	_decayRate = s.readByte();
+	_sustainLevel = s.readByte();
+	_releaseRate = s.readByte();
+	_egTyp = s.readByte() != 0;
+	_ksr = s.readByte() != 0;
+	_totalLevel = s.readByte();
+	_scalingLevel = s.readByte();
+	_waveformSelect = s.readByte();
+	_freqMultiple = s.readByte();
+	_feedback = s.readByte();
+	_ampMod = s.readByte() != 0;
+	_vib = s.readByte();
+	_alg = s.readByte();
+	_fieldE = s.readByte();
+	s.skip(1);
+	_freqMask = s.readUint16LE();
+	_freqBase = s.readUint16LE();
+	_field14 = s.readUint16LE();
+}
+
+/*-----------------------------------------------------------------------*/
+
+ASound::ASound(Audio::Mixer *mixer, const Common::String &filename, int dataOffset) {
+	// Open up the appropriate sound file
+	if (!_soundFile.open(filename))
+		error("Could not open file - %s", filename.c_str());
+
+	// Initialise fields
+	_activeChannelPtr = nullptr;
+	_samplePtr = nullptr;
+	_frameCounter = 0;
+	_isDisabled = false;
+	_v1 = 0;
+	_v2 = 0;
+	_activeChannelNumber = 0;
+	_freqMask1 = _freqMask2 = 0;
+	_freqBase1 = _freqBase2 = 0;
+	_channelNum1 = _channelNum2 = 0;
+	_v7 = 0;
+	_v8 = 0;
+	_v9 = 0;
+	_v10 = 0;
+	_pollResult = 0;
+	_resultFlag = 0;
+	_nullData[0] = _nullData[1] = 0;
+	Common::fill(&_ports[0], &_ports[256], 0);
+	_stateFlag = false;
+	_activeChannelReg = 0;
+	_v11 = 0;
+	_randomSeed = 1234;
+	_amDep = _vibDep = _splitPoint = true;
+
+	_samplesTillCallback = 0;
+	_samplesTillCallbackRemainder = 0;
+	_samplesPerCallback = getRate() / CALLBACKS_PER_SECOND;
+	_samplesPerCallbackRemainder = getRate() % CALLBACKS_PER_SECOND;
+
+	// Store passed parameters, and setup OPL
+	_dataOffset = dataOffset;
+	_mixer = mixer;
+	_opl = OPL::Config::create();
+	assert(_opl);
+
+	_opl->init(getRate());
+	_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, 
+		Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
+
+	// Initialise the Adlib
+	adlibInit();
+
+	// Reset the adlib
+	command0();
+}
+
+ASound::~ASound() {
+	Common::List<CachedDataEntry>::iterator i;
+	for (i = _dataCache.begin(); i != _dataCache.end(); ++i)
+		delete[] (*i)._data;
+
+	_mixer->stopHandle(_soundHandle);
+	delete _opl;
+}
+
+void ASound::adlibInit() {
+	write(4, 0x60);
+	write(4, 0x80);
+	write(2, 0xff);
+	write(4, 0x21);
+	write(4, 0x60);
+	write(4, 0x80);
+}
+
+int ASound::stop() { 
+	command0();
+	int result = _pollResult;
+	_pollResult = 0;
+	return result;
+}
+
+int ASound::poll() {
+	// Update any playing sounds
+	update();
+
+	// Return result
+	int result = _pollResult;
+	_pollResult = 0;
+	return result;
+}
+
+void ASound::noise() {
+	int randomVal = getRandomNumber();
+
+	if (_v1) {
+		setFrequency(_channelNum1, ((randomVal ^ 0xFFFF) & _freqMask1) + _freqBase1);
+	}
+
+	if (_v2) {
+		setFrequency(_channelNum2, (randomVal & _freqMask2) + _freqBase2);		
+	}
+}
+
+void ASound::write(int reg, int val) {
+	_queue.push(RegisterValue(reg, val));
+}
+
+int ASound::write2(int state, int reg, int val) {
+	// TODO: Original has a state parameter, not used when in Adlib mode?
+	_ports[reg] = val;
+	write(reg, val);
+	return state;
+}
+
+void ASound::flush() {
+	Common::StackLock slock(_driverMutex);
+
+	while (!_queue.empty()) {
+		RegisterValue v = _queue.pop();
+		_opl->writeReg(v._regNum, v._value);
+	}
+}
+
+void ASound::channelOn(int reg, int volume) {
+	write2(8, reg, (_ports[reg] & 0xC0) | (volume & 0x3F));
+}
+
+void ASound::channelOff(int reg) {
+	write2(8, reg, _ports[reg] | 0x3F);
+}
+
+void ASound::resultCheck() {
+	if (_resultFlag != 1) {
+		_resultFlag = 1;
+		_pollResult = 1;
+	}
+}
+
+byte *ASound::loadData(int offset, int size) {
+	// First scan for an existing copy	
+	Common::List<CachedDataEntry>::iterator i;
+	for (i = _dataCache.begin(); i != _dataCache.end(); ++i) {
+		CachedDataEntry &e = *i;
+		if (e._offset == offset)
+			return e._data;
+	}
+
+	// No existing entry found, so load up data and store as a new entry
+	CachedDataEntry rec;
+	rec._offset = offset;
+	rec._data = new byte[size];
+	_soundFile.seek(_dataOffset + offset);
+	_soundFile.read(rec._data, size);
+	_dataCache.push_back(rec);
+
+	// Return the data
+	return rec._data;
+}
+
+void ASound::playSound(int offset, int size) {
+	// Load the specified data block
+	playSound(loadData(offset, size));
+}
+
+void ASound::playSound(byte *pData) {
+	// Scan for a high level free channel
+	for (int i = 5; i < ADLIB_CHANNEL_COUNT; ++i) {
+		if (!_channels[i]._activeCount) {
+			_channels[i].load(pData);
+			return;
+		}
+	}
+
+	// None found, do a secondary scan for an interruptable channel
+	for (int i = ADLIB_CHANNEL_COUNT - 1; i >= ADLIB_CHANNEL_MIDWAY; --i) {
+		if (_channels[i]._fieldE == 0xFF) {
+			_channels[i].load(pData);
+			return;
+		}
+	}
+}
+
+bool ASound::isSoundActive(byte *pData) {
+	for (int i = 0; i < ADLIB_CHANNEL_MIDWAY; ++i) {
+		if (_channels[i]._activeCount && _channels[i]._soundData == pData)
+			return true;
+	}
+
+	return false;
+}
+
+void ASound::setFrequency(int channel, int freq) {
+	write2(8, 0xA0 + channel, freq & 0xFF);
+	write2(8, 0xB0 + channel, (freq >> 8) | 0x20);
+}
+
+int ASound::getRandomNumber() {
+	int v = 0x9248 + (int)_randomSeed;
+	_randomSeed = ((v >> 3) | (v << 13)) & 0xFFFF;
+	return _randomSeed;
+}
+
+void ASound::update() {
+	getRandomNumber();
+	if (_isDisabled)
+		return;
+
+	++_frameCounter;
+	pollChannels();
+	checkChannels();
+
+	if (_v1 == _v2) {
+		if (_resultFlag != -1) {
+			_resultFlag = -1;
+			_pollResult = -1;
+		}
+	} else {
+		if (_v1) {
+			_freqBase1 += _v7;
+			if (!--_v1) {
+				if (!_v2 || _channelNum1 != _channelNum2) {
+					write2(8, 0xA0 + _channelNum1, 0);
+					write2(8, 0xB0 + _channelNum1, 0);
+				}
+			}
+		}
+
+		if (_v2) {
+			_freqBase2 += _v8;
+			if (!--_v2) {
+				if (!_v1 || _channelNum2 != _channelNum1) {
+					write2(8, 0xA0 + _channelNum2, 0);
+					write2(8, 0xB0 + _channelNum2, 0);
+				}
+			}
+		}
+	}
+}
+
+void ASound::pollChannels() {
+	_activeChannelNumber = 0;
+	for (int i = 0; i < ADLIB_CHANNEL_COUNT; ++i) {
+		_activeChannelPtr = &_channels[i];
+		pollActiveChannel();
+	}
+}
+
+void ASound::checkChannels() {
+	for (int i = 0; i < ADLIB_CHANNEL_COUNT; ++i)
+		_channels[i].check(_nullData);
+}
+
+void ASound::pollActiveChannel() {
+	AdlibChannel *chan = _activeChannelPtr; 
+	bool updateFlag = true;
+
+	if (chan->_activeCount) {
+		if (chan->_field8 > 0 && --chan->_field8 == 0)
+			updateOctave();
+
+		if (--_activeChannelPtr->_activeCount <= 0) {
+			for (;;) {
+				byte *pSrc = chan->_pSrc;
+				if (!(*pSrc & 0x80) || (*pSrc <= 0xF0)) {
+					if (updateFlag)
+						updateActiveChannel();
+
+					chan->_field4 = *pSrc++;
+					chan->_activeCount = *pSrc++;
+					chan->_pSrc += 2;
+
+					if (!chan->_field4 || !chan->_activeCount) {
+						updateOctave();
+					} else {
+						chan->_field8 = chan->_activeCount - chan->_field7;
+						updateChannelState();
+					}
+
+					// Break out of processing loop
+					break;
+				} else {
+					updateFlag = false;
+
+					switch ((~*pSrc) & 0xF) {
+					case 0:
+						if (!chan->_field17) {
+							if (*++pSrc == 0) {
+								chan->_pSrc += 2;
+								chan->_ptr3 = chan->_pSrc;
+								chan->_field17 = 0;
+							} else {
+								chan->_field17 = *pSrc;
+								chan->_pSrc = chan->_ptr3;
+							}
+						} else if (--chan->_field17) {
+							chan->_pSrc = chan->_ptr3;
+						} else {
+							chan->_pSrc += 2;
+							chan->_ptr3 = chan->_pSrc;
+						}
+						break;
+
+					case 1:
+						if (!chan->_field19) {
+							if (*++pSrc == 0) {
+								chan->_pSrc += 2;
+								chan->_ptr4 = chan->_pSrc;
+								chan->_ptr3 = chan->_pSrc;
+								chan->_field17 = 0;
+								chan->_field19 = 0;
+							} else {
+								chan->_field19 = *pSrc;
+								chan->_pSrc = chan->_ptr4;
+								chan->_ptr3 = chan->_ptr4;
+							}
+						} else if (--chan->_field19) {
+							chan->_ptr4 = chan->_pSrc;
+							chan->_ptr3 = chan->_pSrc;
+						} else {
+							chan->_pSrc += 2;
+							chan->_ptr4 = chan->_pSrc;
+							chan->_ptr3 = chan->_pSrc;
+						}
+						break;
+
+					case 2:
+						// Loop sound data
+						chan->_field1 = 0;
+						chan->_field2 = chan->_field3 = 0;
+						chan->_volume = chan->_field7 = 0;
+						chan->_field1D = chan->_field1E = 0;
+						chan->_field8 = 0;
+						chan->_field9 = 0;
+						chan->_fieldB = 0;
+						chan->_field17 = 0;
+						chan->_field19 = 0;
+						chan->_fieldD = 0x40;
+						chan->_ptr1 = chan->_soundData;
+						chan->_pSrc = chan->_soundData;
+						chan->_ptr3 = chan->_soundData;
+						chan->_ptr4 = chan->_soundData;
+
+						chan->_pSrc += 2;
+						break;
+
+					case 3:
+						chan->_sampleIndex = *++pSrc;
+						chan->_pSrc += 2;
+						loadSample(chan->_sampleIndex);
+						break;
+
+					case 4:
+						chan->_field7 = *++pSrc;
+						chan->_pSrc += 2;
+						break;
+
+					case 5:
+						chan->_field1 = *++pSrc;
+						chan->_pSrc += 2;
+						break;
+
+					case 6:
+						++pSrc;
+						if (chan->_fieldE) {
+							chan->_pSrc += 2;
+						} else {
+							chan->_volume = *pSrc >> 1;
+							updateFlag = true;
+							chan->_pSrc += 2;
+						}
+						break;
+
+					case 7:
+						++pSrc;
+						if (!chan->_fieldE) {
+							chan->_fieldA = *pSrc;
+							chan->_field2 = *++pSrc;
+							chan->_field9 = 1;
+						}
+
+						chan->_pSrc += 3;
+						break;
+
+					case 8:
+						chan->_field1D = *++pSrc;
+						chan->_pSrc += 2;
+						break;
+
+					case 9: {
+						int v1 = *++pSrc;
+						++pSrc;
+						int v2 = (v1 - 1) & getRandomNumber();
+						int v3 = pSrc[v2];
+						int v4 = pSrc[v1];
+
+						pSrc[v4 + v1 + 1] = v3;
+						chan->_pSrc += v1 + 3;
+						break;
+					}
+
+					case 10:
+						++pSrc;
+						if (chan->_fieldE) {
+							chan->_pSrc += 2;
+						} else {
+							chan->_field1E = *pSrc >> 1;
+							updateFlag = true;
+							chan->_pSrc += 2;
+						}
+						break;
+
+					case 11:
+						chan->_fieldD = *++pSrc;
+						updateFlag = true;
+						chan->_pSrc += 2;
+						break;
+
+					case 12:
+						chan->_fieldC = *++pSrc;
+						chan->_field3 = *++pSrc;
+						chan->_fieldB = 1;
+						chan->_pSrc += 2;
+						break;
+
+					case 13:
+						++pSrc;
+						chan->_pSrc += 2;
+						break;
+
+					case 14:
+						chan->_field1F = *++pSrc;
+						chan->_pSrc += 2;
+						break;
+					
+					default:
+						break;
+					}
+				}
+			}
+		}
+
+		if (chan->_field1)
+			updateFNumber();
+
+		updateFlag = false;
+		if (chan->_field9 || chan->_fieldB) {
+			if (!--chan->_field9) {
+				chan->_field9 = chan->_fieldA;
+				if (chan->_field2) {
+					int8 newVal = (int8)chan->_field2 + (int8)chan->_field1E;
+					if (newVal < 0) {
+						chan->_field9 = 0;
+						newVal = 0;
+					} else if (newVal > 63) {
+						chan->_field9 = 0;
+						newVal = 63;
+					}
+
+					chan->_field1E = newVal;
+					updateFlag = true;
+				}
+			}
+
+			if (!--chan->_fieldB) {
+				chan->_fieldB = chan->_fieldC;
+				if (chan->_field3) {
+					chan->_fieldD = chan->_field3;
+					updateFlag = true;
+				}
+			}
+
+			if (updateFlag)
+				updateActiveChannel();
+		}
+	}
+
+	++_activeChannelNumber;
+}
+
+void ASound::updateOctave() {
+ 	int reg = 0xB0 + _activeChannelNumber;
+	write2(8, reg, _ports[reg] & 0xDF);
+}
+
+static int _vList1[] = {
+	0x200, 0x21E, 0x23F, 0x261, 0x285, 0x2AB, 
+	0x2D4, 0x2FF, 0x32D, 0x35D, 0x390, 0x3C7
+};
+
+void ASound::updateChannelState() {
+	updateActiveChannel();
+
+	if (_channelData[_activeChannelNumber]._field0) {
+		if (_channelNum1 == _activeChannelNumber)
+			_stateFlag = 0;
+		if (_channelNum2 == _activeChannelNumber)
+			_stateFlag = 1;
+
+		if (!_stateFlag) {
+			_stateFlag = 1;
+			if (_v1)
+				write2(8, 0xB0 + _channelNum1, _ports[0xB0 + _channelNum1] & 0xDF);
+
+			_channelNum1 = _activeChannelNumber;
+			_v1 = _channelData[_channelNum1]._field0;
+			_freqMask1 = _channelData[_channelNum1]._freqMask;
+			_freqBase1 = _channelData[_channelNum1]._freqBase;
+			_v7 = _channelData[_channelNum1]._field6;
+		} else {
+			_stateFlag = 0;
+			if (_v2)
+				write2(8, 0xB0 + _channelNum2, _ports[0xB0 + _channelNum2] & 0xDF);
+
+			_channelNum2 = _activeChannelNumber;
+			_v2 = _channelData[_channelNum2]._field0;
+			_freqMask2 = _channelData[_channelNum2]._freqMask;
+			_freqBase2 = _channelData[_channelNum2]._freqBase;
+			_v8 = _channelData[_channelNum2]._field6;
+		}
+
+		resultCheck();
+	} else {
+		int reg = 0xA0 + _activeChannelNumber;
+		int vTimes = (_activeChannelPtr->_field4 + _activeChannelPtr->_field1F) / 12;
+		int vOffset = (_activeChannelPtr->_field4 + _activeChannelPtr->_field1F) % 12;
+		int val = _vList1[vOffset] + _activeChannelPtr->_field1D;
+		write2(8, reg, val & 0xFF);
+
+		reg += 0x10;
+		write2(8, reg, (_ports[reg] & 0x20) | (vTimes << 2) | (val >> 8));
+
+		write2(8, reg, _ports[reg] | 0x20);
+	}
+}
+
+static const int outputIndexes[] = {
+	3, 1, 4, 2, 5, 6, 9, 7, 10, 8, 11, 12, 15, 13, 16, 14, 17
+};
+static const int outputChannels[] = {
+	0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 16, 17, 18, 19, 20, 21, 0
+};
+static const int volumeList[] = {
+	0x3F, 0x3F, 0x36, 0x31, 0x2D, 0x2A, 0x28, 0x26, 0x24, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1D, 0x1C,
+	0x1B, 0x1A, 0x19, 0x19, 0x18, 0x17, 0x17, 0x16, 0x16, 0x15, 0x15, 0x14, 0x14, 0x13, 0x12, 0x12,
+	0x11, 0x11, 0x10, 0x10, 0x0F, 0x0F, 0x0E, 0x0E, 0x0D, 0x0D, 0x0C, 0x0C, 0x0B, 0x0B, 0x0A, 0x0A,
+	0x0A, 0x09, 0x09, 0x09, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x08, 0x07, 0x07, 0x07, 0x07, 0x07,
+	0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04,
+	0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
+	0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01,
+	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+};
+
+void ASound::updateActiveChannel() {
+	int reg = 0x40 + outputChannels[outputIndexes[_activeChannelNumber * 2]];
+	int portVal = _ports[reg] & 0xFFC0;
+	int newVolume = CLIP(_activeChannelPtr->_volume + _activeChannelPtr->_field1E, 0, 63);
+	
+	// Note: Original had a whole block not seeming to be used, since the initialisation
+	// sets a variable to 5660h, and doesn't change it, so the branch is never taken
+	int val = CLIP(newVolume - volumeList[_activeChannelPtr->_fieldD], 0, 63);
+	val = (63 - val) | portVal;
+
+	int val2 = CLIP(newVolume - volumeList[-(_activeChannelPtr->_fieldD - 127)], 0, 63);
+	val2 = (63 - val2) | portVal;
+	write2(0, reg, val);
+	write2(2, reg, val2);
+}
+
+void ASound::loadSample(int sampleIndex) {
+	_activeChannelReg = 0xB0 + _activeChannelNumber;
+	write2(8, _activeChannelReg, _ports[_activeChannelReg] & 0xDF);
+
+	_activeChannelReg = _activeChannelNumber;
+	_samplePtr = &_samples[sampleIndex * 2];
+	_v11 = outputChannels[outputIndexes[_activeChannelReg * 2 - 1]];
+	processSample();
+
+	AdlibChannelData &cd = _channelData[_activeChannelNumber];
+	cd._field6 = _samplePtr->_field14;
+	cd._freqBase = _samplePtr->_freqBase;
+	cd._freqMask = _samplePtr->_freqMask;
+	cd._field0 = _samplePtr->_fieldE;
+
+	_samplePtr = &_samples[sampleIndex * 2 + 1];
+	_v11 = outputChannels[outputIndexes[_activeChannelReg * 2]];
+	processSample();
+}
+
+void ASound::processSample() {
+	// Write out vib flags and split point
+	write2(8, 0x40 + _v11, 0x3F);
+	int depthRhythm = (_ports[0xBD] & 0x3F) | (_amDep ? 0x80 : 0) |
+		(_vibDep ? 0x40 : 0);
+	write2(8, 0xBD, depthRhythm);
+	write2(8, 8, _splitPoint ? 0x40 : 0);
+
+	// Write out feedback & Alg
+	int val = (_samplePtr->_feedback << 1) | (1 - _samplePtr->_alg);
+	write2(8, 0xC0 + _activeChannelReg, val);
+
+	// Write out attack/decay rate
+	val = (_samplePtr->_attackRate << 4) | (_samplePtr->_decayRate & 0xF);
+	write2(8, 0x60 + _v11, val);
+
+	// Write out sustain level/release rate
+	val = (_samplePtr->_sustainLevel << 4) | (_samplePtr->_releaseRate & 0xF);
+	write2(8, 0x80 + _v11, val);
+
+	// Write out misc flags
+	val = (_samplePtr->_ampMod ? 0x80 : 0) | (_samplePtr->_vib ? 0x40 : 0)
+		| (_samplePtr->_egTyp ? 0x20 : 0) | (_samplePtr->_ksr ? 0x10 : 0)
+		| (_samplePtr->_freqMultiple & 0xF);
+	write2(8, 0x20 + _v11, val);
+
+	// Write out waveform select
+	write2(8, 0xE0 + _v11, _samplePtr->_waveformSelect & 3);
+	
+	// Write out total level & scaling level
+	val = -((_samplePtr->_totalLevel & 0x3F) - 0x3F) | (_samplePtr->_scalingLevel << 6);
+	write2(8, 0x40 + _v11, val);
+}
+
+void ASound::updateFNumber() {
+	int loReg = 0xA0 + _activeChannelNumber;
+	int hiReg = 0xB0 + _activeChannelNumber;
+	int val1 = (_ports[hiReg] & 0x1F) << 8;
+	val1 += _ports[loReg] + _activeChannelPtr->_field1;
+	write2(8, loReg, val1);
+
+	int val2 = (_ports[hiReg] & 0x20) | (val1 >> 8);
+	write2(8, hiReg, val2);
+}
+
+int ASound::readBuffer(int16 *buffer, const int numSamples) {
+	Common::StackLock slock(_driverMutex);
+
+	int32 samplesLeft = numSamples;
+	memset(buffer, 0, sizeof(int16) * numSamples);
+	while (samplesLeft) {
+		if (!_samplesTillCallback) {
+			poll();
+			flush();
+
+			_samplesTillCallback = _samplesPerCallback;
+			_samplesTillCallbackRemainder += _samplesPerCallbackRemainder;
+			if (_samplesTillCallbackRemainder >= CALLBACKS_PER_SECOND) {
+				_samplesTillCallback++;
+				_samplesTillCallbackRemainder -= CALLBACKS_PER_SECOND;
+			}
+		}
+
+		int32 render = MIN<int>(samplesLeft, _samplesTillCallback);
+		samplesLeft -= render;
+		_samplesTillCallback -= render;
+
+		_opl->readBuffer(buffer, render);
+		buffer += render;
+	}
+	return numSamples;
+}
+
+int ASound::command0() {
+	bool isDisabled = _isDisabled;
+	_isDisabled = true;
+
+	for (int i = 0; i < ADLIB_CHANNEL_COUNT; ++i)
+		_channels[i].reset();
+
+	_v1 = 0;
+	_v2 = 0;
+	_freqMask1 = _freqMask2 = 0;
+	_freqBase1 = _freqBase2 = 0;
+	_v7 = 0;
+	_v8 = 0;	
+
+	// Reset Adlib port registers
+	for (int reg = 0x4F; reg >= 0x40; --reg)
+		write2(8, reg, 0x3F);
+	for (int reg = 0xFF; reg >= 0x60; --reg)
+		write2(8, reg, 0);
+	for (int reg = 0x3F; reg > 0; --reg)
+		write2(8, reg, 0);
+	write2(8, 1, 0x20);
+
+	_isDisabled = isDisabled;
+	return 0;
+}
+
+int ASound::command1() {
+	for (int i = 0; i < ADLIB_CHANNEL_COUNT; ++i)
+		_channels[i].enable(0xFF);
+	return 0;
+}
+
+int ASound::command2() {
+	for (int i = 0; i < ADLIB_CHANNEL_MIDWAY; ++i)
+		_channels[i].setPtr2(_nullData);
+	return 0;
+}
+
+int ASound::command3() {
+	for (int i = 0; i < ADLIB_CHANNEL_MIDWAY; ++i)
+		_channels[i].enable(0xFF);
+	return 0;
+}
+
+int ASound::command4() {
+	for (int i = ADLIB_CHANNEL_MIDWAY; i < ADLIB_CHANNEL_COUNT; ++i)
+		_channels[i].setPtr2(_nullData);
+	return 0;
+}
+
+int ASound::command5() {
+	for (int i = 5; i < ADLIB_CHANNEL_COUNT; ++i)
+		_channels[i].enable(0xFF);
+	return 0;
+}
+
+int ASound::command6() {
+	_v9 = _v1;
+	_v1 = 0;
+	_v10 = _v2;
+	_v2 = 0;
+
+	channelOff(0x43);
+	channelOff(0x44);
+	channelOff(0x45);
+	channelOff(0x4B);
+	channelOff(0x4C);
+	channelOff(0x4D);
+	channelOff(0x53);
+	channelOff(0x54);
+	channelOff(0x55);
+
+	return 0;
+}
+
+int ASound::command7() {
+	channelOn(0x43, _channels[0]._volume);
+	channelOn(0x44, _channels[1]._volume);
+	channelOn(0x45, _channels[2]._volume);
+	channelOn(0x4B, _channels[3]._volume);
+	channelOn(0x4C, _channels[4]._volume);
+	channelOn(0x4D, _channels[5]._volume);
+
+	_v1 = _v9;
+	_v2 = _v10;
+
+	if (_v9 != _v10)
+		resultCheck();
+
+	_isDisabled = 0;
+	return _v10;
+}
+
+int ASound::command8() {
+	int result = 0;
+	for (int i = 0; i < ADLIB_CHANNEL_COUNT; ++i)
+		result |= _channels[i]._activeCount;
+
+	return result;
+}
+
+/*-----------------------------------------------------------------------*/
+
+const ASound1::CommandPtr ASound1::_commandList[42] = {
+	&ASound1::command0, &ASound1::command1, &ASound1::command2, &ASound1::command3,
+	&ASound1::command4, &ASound1::command5, &ASound1::command6, &ASound1::command7, 
+	&ASound1::command8, &ASound1::command9, &ASound1::command10, &ASound1::command11,
+	&ASound1::command12, &ASound1::command13, &ASound1::command14, &ASound1::command15,
+	&ASound1::command16, &ASound1::command17, &ASound1::command18, &ASound1::command19, 
+	&ASound1::command20, &ASound1::command21, &ASound1::command22, &ASound1::command23, 
+	&ASound1::command24, &ASound1::command25, &ASound1::command26, &ASound1::command27,
+	&ASound1::command28, &ASound1::command29, &ASound1::command30, &ASound1::command31, 
+	&ASound1::command32, &ASound1::command33, &ASound1::command34, &ASound1::command35,
+	&ASound1::command36, &ASound1::command37, &ASound1::command38, &ASound1::command39, 
+	&ASound1::command40, &ASound1::command41
+};
+
+ASound1::ASound1(Audio::Mixer *mixer): ASound(mixer, "asound.001", 0x1520) {
+	_cmd23Toggle = false;
+	
+	// Load sound samples
+	_soundFile.seek(_dataOffset + 0x12C);
+	for (int i = 0; i < 98; ++i)
+		_samples.push_back(AdlibSample(_soundFile));
+}
+
+int ASound1::command(int commandId) {
+	if (commandId > 41)
+		return 0;
+
+	_frameCounter = 0;
+	return (this->*_commandList[commandId])();
+}
+
+int ASound1::command9() {
+	playSound(0xC68, 12);
+	return 0;
+}
+
+int ASound1::command10() {
+	byte *pData1 = loadData(0x130E, 48);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[0].load(pData1);
+		_channels[1].load(loadData(0x133E, 392));
+		_channels[2].load(loadData(0x14C6, 46));
+		_channels[3].load(loadData(0x14F4, 48));
+	}
+
+	return 0;
+}
+
+int ASound1::command11() {
+	command111213();
+	_channels[0]._field1E = 0;
+	_channels[1]._field1E = 0;
+	return 0;
+}
+
+int ASound1::command12() {
+	command111213();
+	_channels[0]._field1E = 40;
+	_channels[1]._field1E = 0;
+	return 0;
+}
+
+int ASound1::command13() {
+	command111213();
+	_channels[0]._field1E = 40;
+	_channels[1]._field1E = 50;
+	return 0;
+}
+
+int ASound1::command14() {
+	playSound(0x1216, 248);
+	return 0;
+}
+
+int ASound1::command15() {
+	byte *pData1 = loadData(0x1524, 152);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[4].load(pData1);
+		_channels[5].load(loadData(0x15BC, 94));
+		_channels[6].load(loadData(0x161A, 94));
+		_channels[7].load(loadData(0x1678, 42));
+		_channels[8].load(loadData(0x16A2, 42));
+	}
+
+	return 0;
+}
+
+int ASound1::command16() {
+	playSound(0xC74, 14);
+	return 0;
+}
+
+int ASound1::command17() {
+	playSound(0xE9A, 10);
+	return 0;
+}
+
+int ASound1::command18() {
+	command1();
+	playSound(0xCA6, 20);
+	return 0;
+}
+
+int ASound1::command19() {
+	command1();
+	playSound(0xCBA, 74);
+	return 0;
+}
+
+int ASound1::command20() {
+	byte *pData = loadData(0xD18, 28);
+	if (!isSoundActive(pData))
+		playSound(pData);
+	return 0;
+}
+
+int ASound1::command21() {
+	playSound(0xD04, 20);
+	return 0;
+}
+
+int ASound1::command22() {
+	byte *pData = loadData(0xD34, 10);
+	pData[6] = (getRandomNumber() & 7) + 85;
+
+	if (!isSoundActive(pData))
+		playSound(pData);
+
+	return 0;
+}
+
+int ASound1::command23() {
+	_cmd23Toggle = !_cmd23Toggle;
+	playSound(_cmd23Toggle ? 0xD3E : 0xD46, 8);
+	return 0;
+}
+
+int ASound1::command24() {
+	playSound(0xD4E, 18);
+	playSound(0xD60, 20);
+	playSound(0xD74, 14);
+	return 0;
+}
+
+int ASound1::command25() {
+	byte *pData = loadData(0xD82, 16);
+	if (!isSoundActive(pData))
+		playSound(pData);
+
+	return 0;
+}
+
+int ASound1::command26() {
+	error("TODO: command26");
+	return 0;
+}
+
+int ASound1::command27() {
+	error("TODO: ASound::command27");
+	return 0;
+}
+
+int ASound1::command28() {
+	playSound(0xD92, 28);
+	return 0;
+}
+
+int ASound1::command29() {
+	error("TODO: ASound::command29");
+	return 0;
+}
+
+int ASound1::command30() {
+	error("TODO: ASound::command30");
+	return 0;
+}
+
+int ASound1::command31() {
+	byte *pData = loadData(0xDAE, 14);
+	if (!isSoundActive(pData))
+		playSound(pData);
+
+	return 0;
+}
+
+int ASound1::command32() {
+	error("TODO: ASound::command32");
+	return 0;
+}
+
+int ASound1::command33() {
+	playSound(0xDBC, 10);
+	playSound(0xDC6, 10);
+	return 0;
+}
+
+int ASound1::command34() {
+	int v = getRandomNumber() & 0x20;
+	if (!v) 
+		v = 0x60;
+
+	byte *pData = loadData(0xDD0, 22);
+	pData[8] = pData[15] = v;
+	playSound(pData);
+	return 0;
+}
+
+int ASound1::command35() {
+	playSound(0xDE6, 16);
+	return 0;
+}
+
+int ASound1::command36() {
+	playSound(0xE10, 10);
+	command34();
+
+	return 0;
+}
+
+int ASound1::command37() {
+	playSound(0xE1A, 14);
+	return 0;
+}
+
+int ASound1::command38() {
+	playSound(0xE28, 114);
+	return 0;
+}
+
+int ASound1::command39() {
+	byte *pData1 = loadData(0x16CC, 82);
+	if (!isSoundActive(pData1)) {
+		_channels[5].load(pData1);
+		_channels[6].load(loadData(0x171E, 30));
+		_channels[7].load(loadData(0x173C, 40));
+		_channels[8].load(loadData(0x1764, 64));
+	}
+	return 0;
+}
+
+int ASound1::command40() {
+	playSound(0xDF6, 26);
+	return 0;
+}
+
+int ASound1::command41() {
+	playSound(0xC32, 34);
+	playSound(0xC54, 20);
+	return 0;
+}
+
+void ASound1::command111213() {
+	byte *pData1 = loadData(0xEF6, 408);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[0].load(pData1);
+		_channels[1].load(loadData(0x108E, 266));
+		_channels[2].load(loadData(0x1198, 66));
+		_channels[2].load(loadData(0x11DA, 60));
+	}
+}
+
+void ASound1::command2627293032() {
+	// TODO: This method takes a parameter off the stack for several levels up.
+	// i.e. something the caller's caller pushed onto the stack. Need to figure
+	// out a better way to pass parameters down if this is actually in use.
+}
+
+} // End of namespace Nebular
+
+} // End of namespace MADS
diff --git a/engines/mads/nebular/sound_nebular.h b/engines/mads/nebular/sound_nebular.h
new file mode 100644
index 0000000..11836e6
--- /dev/null
+++ b/engines/mads/nebular/sound_nebular.h
@@ -0,0 +1,408 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_SOUND_NEBULAR_H
+#define MADS_SOUND_NEBULAR_H
+
+#include "common/scummsys.h"
+#include "common/file.h"
+#include "common/mutex.h"
+#include "common/queue.h"
+#include "audio/audiostream.h"
+#include "audio/fmopl.h"
+#include "audio/mixer.h"
+
+namespace MADS {
+
+class SoundManager;
+
+namespace Nebular {
+
+/**
+ * Represents the data for a channel on the Adlib
+ */
+class AdlibChannel {
+public:
+	int _activeCount;
+	int _field1;
+	int _field2;
+	int _field3;
+	int _field4;
+	int _sampleIndex;
+	int _volume;
+	int _field7;
+	int _field8;
+	int _field9;
+	int _fieldA;
+	uint8 _fieldB;
+	int _fieldC;
+	int _fieldD;
+	int _fieldE;
+	byte *_ptr1;
+	byte *_pSrc;
+	byte *_ptr3;
+	byte *_ptr4;
+	int _field17;
+	int _field19;
+	byte *_soundData;
+	int _field1D;
+	int _field1E;
+	int _field1F;
+public:
+	AdlibChannel();
+
+	void reset();
+	void enable(int flag);
+	void setPtr2(byte *pData);
+	void load(byte *pData);
+	void check(byte *nullPtr);
+};
+
+class AdlibChannelData {
+public:
+	int _field0;
+	int _freqMask;
+	int _freqBase;
+	int _field6;
+};
+
+class AdlibSample {
+public:
+	int _attackRate;
+	int _decayRate;
+	int _sustainLevel;
+	int _releaseRate;
+	bool _egTyp;
+	bool _ksr;
+	int _totalLevel;
+	int _scalingLevel;
+	int _waveformSelect;
+	int _freqMultiple;
+	int _feedback;
+	bool _ampMod;
+	int _vib;
+	int _alg;
+	int _fieldE;
+	int _freqMask;
+	int _freqBase;
+	int _field14;
+
+	AdlibSample() {}
+	AdlibSample(Common::SeekableReadStream &s);
+};
+
+struct RegisterValue {
+	uint8 _regNum;
+	uint8 _value;
+
+	RegisterValue(int regNum, int value) {
+		_regNum = regNum; _value = value;
+	}
+};
+
+#define ADLIB_CHANNEL_COUNT 9
+#define ADLIB_CHANNEL_MIDWAY 5
+#define CALLBACKS_PER_SECOND 60
+
+/**
+ * Base class for the sound player resource files
+ */
+class ASound: public Audio::AudioStream {
+private:
+	struct CachedDataEntry {
+		int _offset;
+		byte *_data;
+	};
+	Common::List<CachedDataEntry> _dataCache;
+	uint16 _randomSeed;
+
+	/**
+	 * Does the initial Adlib initialisation
+	 */
+	void adlibInit();
+
+	/**
+	 * Does on-going processing for the Adlib sounds being played
+	 */
+	void update();
+
+	/**
+	 * Polls each of the channels for updates
+	 */
+	void pollChannels();
+
+	/**
+	 * Checks the status of the channels
+	 */
+	void checkChannels();
+
+	/**
+	 * Polls the currently active channel
+	 */
+	void pollActiveChannel();
+
+	/**
+	 * Updates the octave of the currently active channel
+	 */
+	void updateOctave();
+
+	void updateChannelState();
+	void updateActiveChannel();
+	
+	/**
+	 * Loads up the specified sample
+	 */
+	void loadSample(int sampleIndex);
+
+	/**
+	 * Writes out the data of the selected sample to the Adlib
+	 */
+	void processSample();
+
+	void updateFNumber();
+protected:
+	/**
+	 * Queue a byte for an Adlib register
+	 */
+	void write(int reg, int val);
+
+	/**
+	 * Queue a byte for an Adlib register, and store it in the _ports array
+	 */
+	int write2(int state, int reg, int val);
+
+	/**
+	 * Flush any pending Adlib register values to the OPL driver
+	 */
+	void flush();
+
+	/**
+	 * Turn a channel on
+	 */
+	void channelOn(int reg, int volume);
+
+	/**
+	 * Turn a channel off
+	 */
+	void channelOff(int reg);
+
+	/**
+	 * Checks for whether a poll result needs to be set
+	 */
+	void resultCheck();
+
+	/**
+	 * Loads a data block from the sound file, caching the result for any future
+	 * calls for the same data
+	 */
+	byte *loadData(int offset, int size);
+
+	/**
+	 * Play the specified sound
+	 * @param offset	Offset of sound data within sound player data segment
+	 * @param size		Size of sound data block
+	 */
+	void playSound(int offset, int size);
+
+	/**
+	 * Play the specified raw sound data
+	 * @param pData		Pointer to data block containing sound data
+	 */
+	void playSound(byte *pData);
+
+	/**
+	 * Checks to see whether the given block of data is already loaded into a channel.
+	 */
+	bool isSoundActive(byte *pData);
+
+	/**
+	 * Sets the frequency for a given channel.
+	 */
+	void setFrequency(int channel, int freq);
+
+	/**
+	 * Returns a 16-bit random number
+	 */
+	int getRandomNumber();
+
+	int command0();
+	int command1();
+	int command2();
+	int command3();
+	int command4();
+	int command5();
+	int command6();
+	int command7();
+	int command8();
+public:
+	Audio::Mixer *_mixer;
+	FM_OPL *_opl;
+	Audio::SoundHandle _soundHandle;
+	AdlibChannel _channels[ADLIB_CHANNEL_COUNT];
+	AdlibChannel *_activeChannelPtr;
+	AdlibChannelData _channelData[11];
+	Common::Array<AdlibSample> _samples;
+	AdlibSample *_samplePtr;
+	Common::File _soundFile;
+	Common::Queue<RegisterValue> _queue;
+	Common::Mutex _driverMutex;
+	int _dataOffset;
+	int _frameCounter;
+	bool _isDisabled;
+	int _v1;
+	int _v2;
+	int _activeChannelNumber;
+	int _freqMask1;
+	int _freqMask2;
+	int _freqBase1;
+	int _freqBase2;
+	int _channelNum1, _channelNum2;
+	int _v7;
+	int _v8;
+	int _v9;
+	int _v10;
+	int _pollResult;
+	int _resultFlag;
+	byte _nullData[2];
+	int _ports[256];
+	bool _stateFlag;
+	int _activeChannelReg;
+	int _v11;
+	bool _amDep, _vibDep, _splitPoint;
+	int _samplesPerCallback;
+	int _samplesPerCallbackRemainder;
+	int _samplesTillCallback;
+	int _samplesTillCallbackRemainder;
+public:
+	/**
+	 * Constructor
+	 * @param filename		Specifies the adlib sound player file to use
+	 * @param dataOffset	Offset in the file of the data segment
+	 */
+	ASound(Audio::Mixer *mixer, const Common::String &filename, int dataOffset);
+
+	/**
+	 * Destructor
+	 */
+	virtual ~ASound();
+
+	/**
+	 * Execute a player command. Most commands represent sounds to play, but some
+	 * low number commands also provide control operations
+	 */
+	virtual int command(int commandId) = 0;
+
+	/**
+	 * Stop all currently playing sounds
+	 */
+	int stop();
+
+	/**
+	 * Main poll method to allow sounds to progress
+	 */
+	int poll();
+
+	/**
+	 * General noise/note output
+	 */
+	void noise();
+
+	/**
+	 * Return the current frame counter
+	 */
+	int getFrameCounter() { return _frameCounter; }
+
+	// AudioStream interface
+	/**
+	 * Main buffer read
+	 */
+	virtual int readBuffer(int16 *buffer, const int numSamples);
+	
+	/**
+	 * Mono sound only
+	 */
+	virtual bool isStereo() const { return false; }
+	
+	/**
+	 * Data is continuously pushed, so definitive end
+	 */
+	virtual bool endOfData() const { return false; }
+
+	/**
+	 * Return sample rate
+	 */
+	virtual int getRate() const { return 11025; }
+};
+
+class ASound1: public ASound {
+private:
+	typedef int (ASound1::*CommandPtr)();
+	static const CommandPtr _commandList[42];
+	bool _cmd23Toggle;
+
+	int command9();
+	int command10();
+	int command11();
+	int command12();
+	int command13();
+	int command14();
+	int command15();
+	int command16();
+	int command17();
+	int command18();
+	int command19();
+	int command20();
+	int command21();
+	int command22();
+	int command23();
+	int command24();
+	int command25();
+	int command26();
+	int command27();
+	int command28();
+	int command29();
+	int command30();
+	int command31();
+	int command32();
+	int command33();
+	int command34();
+	int command35();
+	int command36();
+	int command37();
+	int command38();
+	int command39();
+	int command40();
+	int command41();
+
+	void command111213();
+	void command2627293032();
+public:
+	ASound1(Audio::Mixer *mixer);
+
+	virtual int command(int commandId);
+};
+
+} // End of namespace Nebular
+
+} // End of namespace MADS
+
+#endif /* MADS_SOUND_NEBULAR_H */
diff --git a/engines/mads/sound.h b/engines/mads/sound.h
index cbd6511..7a9a4ef 100644
--- a/engines/mads/sound.h
+++ b/engines/mads/sound.h
@@ -26,7 +26,7 @@
 #include "common/scummsys.h"
 #include "audio/audiostream.h"
 #include "audio/mixer.h"
-#include "mads/sound_nebular.h"
+#include "mads/nebular/sound_nebular.h"
 
 namespace MADS {
 
diff --git a/engines/mads/sound_nebular.cpp b/engines/mads/sound_nebular.cpp
deleted file mode 100644
index 7c1410c..0000000
--- a/engines/mads/sound_nebular.cpp
+++ /dev/null
@@ -1,1180 +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 "audio/audiostream.h"
-#include "audio/decoders/raw.h"
-#include "common/algorithm.h"
-#include "common/debug.h"
-#include "common/memstream.h"
-#include "mads/sound.h"
-#include "mads/sound_nebular.h"
-
-namespace MADS {
-
-namespace Nebular {
-
-AdlibChannel::AdlibChannel() {
-	_activeCount = 0;
-	_field1 = 0;
-	_field2 = 0;
-	_field3 = 0;
-	_field4 = 0;
-	_sampleIndex = 0;
-	_volume = 0;
-	_field7 = 0;
-	_field8 = 0;
-	_field9 = 0;
-	_fieldA = 0;
-	_fieldB = 0;
-	_fieldC = 0;
-	_fieldD = 0;
-	_fieldE = 0;
-	_ptr1 = nullptr;
-	_pSrc = nullptr;
-	_ptr3 = nullptr;
-	_ptr4 = nullptr;
-	_field17 = 0;
-	_field19 = 0;
-	_soundData = nullptr;
-	_field1D = 0;
-	_field1E = 0;
-	_field1F = 0;
-}
-
-void AdlibChannel::reset() {
-	_activeCount = 0;
-	_field1 = 0;
-	_field2 = 0;
-	_field3 = 0;
-}
-
-void AdlibChannel::enable(int flag) {
-	if (_activeCount) {
-		_fieldE = flag;
-
-		// WORKAROUND: Original set _soundData pointer to flag. Since this seems
-		// just intended to invalidate any prior pointer, I've replaced it with
-		// a simple null pointer
-		_soundData = nullptr; 
-	}
-}
-
-void AdlibChannel::setPtr2(byte *pData) {
-	_pSrc = pData;
-	_field2 = 0xFF;
-	_fieldA = 1;
-	_field9 = 1;
-}
-
-void AdlibChannel::load(byte *pData) {
-	_ptr1 = _pSrc = _ptr3 = pData;
-	_ptr4 = _soundData = pData;
-	_fieldA = 0xFF;
-	_activeCount = 1;
-	_fieldD = 64;
-	_field1 = 0;
-	_field1F = 0;
-	_field2 = _field3 = 0;
-	_volume = _field7 = 0;
-	_field1D = _field1E = 0;
-	_fieldE = 0;
-	_field9 = 0;
-	_fieldB = 0;
-	_field17 = 0;
-	_field19 = 0;
-}
-
-void AdlibChannel::check(byte *nullPtr) {
-	if (_activeCount && _fieldE) {
-		if (!_field1E) {
-			_pSrc = nullPtr;
-			_fieldE = 0;
-		} else {
-			_field2 = 0xFF;
-			_fieldA = 4;
-			if (!_field9)
-				_field9 = 1;
-		}
-	}
-}
-
-/*-----------------------------------------------------------------------*/
-
-AdlibSample::AdlibSample(Common::SeekableReadStream &s) {
-	_attackRate = s.readByte();
-	_decayRate = s.readByte();
-	_sustainLevel = s.readByte();
-	_releaseRate = s.readByte();
-	_egTyp = s.readByte() != 0;
-	_ksr = s.readByte() != 0;
-	_totalLevel = s.readByte();
-	_scalingLevel = s.readByte();
-	_waveformSelect = s.readByte();
-	_freqMultiple = s.readByte();
-	_feedback = s.readByte();
-	_ampMod = s.readByte() != 0;
-	_vib = s.readByte();
-	_alg = s.readByte();
-	_fieldE = s.readByte();
-	s.skip(1);
-	_freqMask = s.readUint16LE();
-	_freqBase = s.readUint16LE();
-	_field14 = s.readUint16LE();
-}
-
-/*-----------------------------------------------------------------------*/
-
-ASound::ASound(Audio::Mixer *mixer, const Common::String &filename, int dataOffset) {
-	// Open up the appropriate sound file
-	if (!_soundFile.open(filename))
-		error("Could not open file - %s", filename.c_str());
-
-	// Initialise fields
-	_activeChannelPtr = nullptr;
-	_samplePtr = nullptr;
-	_frameCounter = 0;
-	_isDisabled = false;
-	_v1 = 0;
-	_v2 = 0;
-	_activeChannelNumber = 0;
-	_freqMask1 = _freqMask2 = 0;
-	_freqBase1 = _freqBase2 = 0;
-	_channelNum1 = _channelNum2 = 0;
-	_v7 = 0;
-	_v8 = 0;
-	_v9 = 0;
-	_v10 = 0;
-	_pollResult = 0;
-	_resultFlag = 0;
-	_nullData[0] = _nullData[1] = 0;
-	Common::fill(&_ports[0], &_ports[256], 0);
-	_stateFlag = false;
-	_activeChannelReg = 0;
-	_v11 = 0;
-	_randomSeed = 1234;
-	_amDep = _vibDep = _splitPoint = true;
-
-	_samplesTillCallback = 0;
-	_samplesTillCallbackRemainder = 0;
-	_samplesPerCallback = getRate() / CALLBACKS_PER_SECOND;
-	_samplesPerCallbackRemainder = getRate() % CALLBACKS_PER_SECOND;
-
-	// Store passed parameters, and setup OPL
-	_dataOffset = dataOffset;
-	_mixer = mixer;
-	_opl = OPL::Config::create();
-	assert(_opl);
-
-	_opl->init(getRate());
-	_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, 
-		Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
-
-	// Initialise the Adlib
-	adlibInit();
-
-	// Reset the adlib
-	command0();
-}
-
-ASound::~ASound() {
-	Common::List<CachedDataEntry>::iterator i;
-	for (i = _dataCache.begin(); i != _dataCache.end(); ++i)
-		delete[] (*i)._data;
-
-	_mixer->stopHandle(_soundHandle);
-	delete _opl;
-}
-
-void ASound::adlibInit() {
-	write(4, 0x60);
-	write(4, 0x80);
-	write(2, 0xff);
-	write(4, 0x21);
-	write(4, 0x60);
-	write(4, 0x80);
-}
-
-int ASound::stop() { 
-	command0();
-	int result = _pollResult;
-	_pollResult = 0;
-	return result;
-}
-
-int ASound::poll() {
-	// Update any playing sounds
-	update();
-
-	// Return result
-	int result = _pollResult;
-	_pollResult = 0;
-	return result;
-}
-
-void ASound::noise() {
-	int randomVal = getRandomNumber();
-
-	if (_v1) {
-		setFrequency(_channelNum1, ((randomVal ^ 0xFFFF) & _freqMask1) + _freqBase1);
-	}
-
-	if (_v2) {
-		setFrequency(_channelNum2, (randomVal & _freqMask2) + _freqBase2);		
-	}
-}
-
-void ASound::write(int reg, int val) {
-	_queue.push(RegisterValue(reg, val));
-}
-
-int ASound::write2(int state, int reg, int val) {
-	// TODO: Original has a state parameter, not used when in Adlib mode?
-	_ports[reg] = val;
-	write(reg, val);
-	return state;
-}
-
-void ASound::flush() {
-	Common::StackLock slock(_driverMutex);
-
-	while (!_queue.empty()) {
-		RegisterValue v = _queue.pop();
-		_opl->writeReg(v._regNum, v._value);
-	}
-}
-
-void ASound::channelOn(int reg, int volume) {
-	write2(8, reg, (_ports[reg] & 0xC0) | (volume & 0x3F));
-}
-
-void ASound::channelOff(int reg) {
-	write2(8, reg, _ports[reg] | 0x3F);
-}
-
-void ASound::resultCheck() {
-	if (_resultFlag != 1) {
-		_resultFlag = 1;
-		_pollResult = 1;
-	}
-}
-
-byte *ASound::loadData(int offset, int size) {
-	// First scan for an existing copy	
-	Common::List<CachedDataEntry>::iterator i;
-	for (i = _dataCache.begin(); i != _dataCache.end(); ++i) {
-		CachedDataEntry &e = *i;
-		if (e._offset == offset)
-			return e._data;
-	}
-
-	// No existing entry found, so load up data and store as a new entry
-	CachedDataEntry rec;
-	rec._offset = offset;
-	rec._data = new byte[size];
-	_soundFile.seek(_dataOffset + offset);
-	_soundFile.read(rec._data, size);
-	_dataCache.push_back(rec);
-
-	// Return the data
-	return rec._data;
-}
-
-void ASound::playSound(int offset, int size) {
-	// Load the specified data block
-	playSound(loadData(offset, size));
-}
-
-void ASound::playSound(byte *pData) {
-	// Scan for a high level free channel
-	for (int i = 5; i < ADLIB_CHANNEL_COUNT; ++i) {
-		if (!_channels[i]._activeCount) {
-			_channels[i].load(pData);
-			return;
-		}
-	}
-
-	// None found, do a secondary scan for an interruptable channel
-	for (int i = ADLIB_CHANNEL_COUNT - 1; i >= ADLIB_CHANNEL_MIDWAY; --i) {
-		if (_channels[i]._fieldE == 0xFF) {
-			_channels[i].load(pData);
-			return;
-		}
-	}
-}
-
-bool ASound::isSoundActive(byte *pData) {
-	for (int i = 0; i < ADLIB_CHANNEL_MIDWAY; ++i) {
-		if (_channels[i]._activeCount && _channels[i]._soundData == pData)
-			return true;
-	}
-
-	return false;
-}
-
-void ASound::setFrequency(int channel, int freq) {
-	write2(8, 0xA0 + channel, freq & 0xFF);
-	write2(8, 0xB0 + channel, (freq >> 8) | 0x20);
-}
-
-int ASound::getRandomNumber() {
-	int v = 0x9248 + (int)_randomSeed;
-	_randomSeed = ((v >> 3) | (v << 13)) & 0xFFFF;
-	return _randomSeed;
-}
-
-void ASound::update() {
-	getRandomNumber();
-	if (_isDisabled)
-		return;
-
-	++_frameCounter;
-	pollChannels();
-	checkChannels();
-
-	if (_v1 == _v2) {
-		if (_resultFlag != -1) {
-			_resultFlag = -1;
-			_pollResult = -1;
-		}
-	} else {
-		if (_v1) {
-			_freqBase1 += _v7;
-			if (!--_v1) {
-				if (!_v2 || _channelNum1 != _channelNum2) {
-					write2(8, 0xA0 + _channelNum1, 0);
-					write2(8, 0xB0 + _channelNum1, 0);
-				}
-			}
-		}
-
-		if (_v2) {
-			_freqBase2 += _v8;
-			if (!--_v2) {
-				if (!_v1 || _channelNum2 != _channelNum1) {
-					write2(8, 0xA0 + _channelNum2, 0);
-					write2(8, 0xB0 + _channelNum2, 0);
-				}
-			}
-		}
-	}
-}
-
-void ASound::pollChannels() {
-	_activeChannelNumber = 0;
-	for (int i = 0; i < ADLIB_CHANNEL_COUNT; ++i) {
-		_activeChannelPtr = &_channels[i];
-		pollActiveChannel();
-	}
-}
-
-void ASound::checkChannels() {
-	for (int i = 0; i < ADLIB_CHANNEL_COUNT; ++i)
-		_channels[i].check(_nullData);
-}
-
-void ASound::pollActiveChannel() {
-	AdlibChannel *chan = _activeChannelPtr; 
-	bool updateFlag = true;
-
-	if (chan->_activeCount) {
-		if (chan->_field8 > 0 && --chan->_field8 == 0)
-			updateOctave();
-
-		if (--_activeChannelPtr->_activeCount <= 0) {
-			for (;;) {
-				byte *pSrc = chan->_pSrc;
-				if (!(*pSrc & 0x80) || (*pSrc <= 0xF0)) {
-					if (updateFlag)
-						updateActiveChannel();
-
-					chan->_field4 = *pSrc++;
-					chan->_activeCount = *pSrc++;
-					chan->_pSrc += 2;
-
-					if (!chan->_field4 || !chan->_activeCount) {
-						updateOctave();
-					} else {
-						chan->_field8 = chan->_activeCount - chan->_field7;
-						updateChannelState();
-					}
-
-					// Break out of processing loop
-					break;
-				} else {
-					updateFlag = false;
-
-					switch ((~*pSrc) & 0xF) {
-					case 0:
-						if (!chan->_field17) {
-							if (*++pSrc == 0) {
-								chan->_pSrc += 2;
-								chan->_ptr3 = chan->_pSrc;
-								chan->_field17 = 0;
-							} else {
-								chan->_field17 = *pSrc;
-								chan->_pSrc = chan->_ptr3;
-							}
-						} else if (--chan->_field17) {
-							chan->_pSrc = chan->_ptr3;
-						} else {
-							chan->_pSrc += 2;
-							chan->_ptr3 = chan->_pSrc;
-						}
-						break;
-
-					case 1:
-						if (!chan->_field19) {
-							if (*++pSrc == 0) {
-								chan->_pSrc += 2;
-								chan->_ptr4 = chan->_pSrc;
-								chan->_ptr3 = chan->_pSrc;
-								chan->_field17 = 0;
-								chan->_field19 = 0;
-							} else {
-								chan->_field19 = *pSrc;
-								chan->_pSrc = chan->_ptr4;
-								chan->_ptr3 = chan->_ptr4;
-							}
-						} else if (--chan->_field19) {
-							chan->_ptr4 = chan->_pSrc;
-							chan->_ptr3 = chan->_pSrc;
-						} else {
-							chan->_pSrc += 2;
-							chan->_ptr4 = chan->_pSrc;
-							chan->_ptr3 = chan->_pSrc;
-						}
-						break;
-
-					case 2:
-						// Loop sound data
-						chan->_field1 = 0;
-						chan->_field2 = chan->_field3 = 0;
-						chan->_volume = chan->_field7 = 0;
-						chan->_field1D = chan->_field1E = 0;
-						chan->_field8 = 0;
-						chan->_field9 = 0;
-						chan->_fieldB = 0;
-						chan->_field17 = 0;
-						chan->_field19 = 0;
-						chan->_fieldD = 0x40;
-						chan->_ptr1 = chan->_soundData;
-						chan->_pSrc = chan->_soundData;
-						chan->_ptr3 = chan->_soundData;
-						chan->_ptr4 = chan->_soundData;
-
-						chan->_pSrc += 2;
-						break;
-
-					case 3:
-						chan->_sampleIndex = *++pSrc;
-						chan->_pSrc += 2;
-						loadSample(chan->_sampleIndex);
-						break;
-
-					case 4:
-						chan->_field7 = *++pSrc;
-						chan->_pSrc += 2;
-						break;
-
-					case 5:
-						chan->_field1 = *++pSrc;
-						chan->_pSrc += 2;
-						break;
-
-					case 6:
-						++pSrc;
-						if (chan->_fieldE) {
-							chan->_pSrc += 2;
-						} else {
-							chan->_volume = *pSrc >> 1;
-							updateFlag = true;
-							chan->_pSrc += 2;
-						}
-						break;
-
-					case 7:
-						++pSrc;
-						if (!chan->_fieldE) {
-							chan->_fieldA = *pSrc;
-							chan->_field2 = *++pSrc;
-							chan->_field9 = 1;
-						}
-
-						chan->_pSrc += 3;
-						break;
-
-					case 8:
-						chan->_field1D = *++pSrc;
-						chan->_pSrc += 2;
-						break;
-
-					case 9: {
-						int v1 = *++pSrc;
-						++pSrc;
-						int v2 = (v1 - 1) & getRandomNumber();
-						int v3 = pSrc[v2];
-						int v4 = pSrc[v1];
-
-						pSrc[v4 + v1 + 1] = v3;
-						chan->_pSrc += v1 + 3;
-						break;
-					}
-
-					case 10:
-						++pSrc;
-						if (chan->_fieldE) {
-							chan->_pSrc += 2;
-						} else {
-							chan->_field1E = *pSrc >> 1;
-							updateFlag = true;
-							chan->_pSrc += 2;
-						}
-						break;
-
-					case 11:
-						chan->_fieldD = *++pSrc;
-						updateFlag = true;
-						chan->_pSrc += 2;
-						break;
-
-					case 12:
-						chan->_fieldC = *++pSrc;
-						chan->_field3 = *++pSrc;
-						chan->_fieldB = 1;
-						chan->_pSrc += 2;
-						break;
-
-					case 13:
-						++pSrc;
-						chan->_pSrc += 2;
-						break;
-
-					case 14:
-						chan->_field1F = *++pSrc;
-						chan->_pSrc += 2;
-						break;
-					
-					default:
-						break;
-					}
-				}
-			}
-		}
-
-		if (chan->_field1)
-			updateFNumber();
-
-		updateFlag = false;
-		if (chan->_field9 || chan->_fieldB) {
-			if (!--chan->_field9) {
-				chan->_field9 = chan->_fieldA;
-				if (chan->_field2) {
-					int8 newVal = (int8)chan->_field2 + (int8)chan->_field1E;
-					if (newVal < 0) {
-						chan->_field9 = 0;
-						newVal = 0;
-					} else if (newVal > 63) {
-						chan->_field9 = 0;
-						newVal = 63;
-					}
-
-					chan->_field1E = newVal;
-					updateFlag = true;
-				}
-			}
-
-			if (!--chan->_fieldB) {
-				chan->_fieldB = chan->_fieldC;
-				if (chan->_field3) {
-					chan->_fieldD = chan->_field3;
-					updateFlag = true;
-				}
-			}
-
-			if (updateFlag)
-				updateActiveChannel();
-		}
-	}
-
-	++_activeChannelNumber;
-}
-
-void ASound::updateOctave() {
- 	int reg = 0xB0 + _activeChannelNumber;
-	write2(8, reg, _ports[reg] & 0xDF);
-}
-
-static int _vList1[] = {
-	0x200, 0x21E, 0x23F, 0x261, 0x285, 0x2AB, 
-	0x2D4, 0x2FF, 0x32D, 0x35D, 0x390, 0x3C7
-};
-
-void ASound::updateChannelState() {
-	updateActiveChannel();
-
-	if (_channelData[_activeChannelNumber]._field0) {
-		if (_channelNum1 == _activeChannelNumber)
-			_stateFlag = 0;
-		if (_channelNum2 == _activeChannelNumber)
-			_stateFlag = 1;
-
-		if (!_stateFlag) {
-			_stateFlag = 1;
-			if (_v1)
-				write2(8, 0xB0 + _channelNum1, _ports[0xB0 + _channelNum1] & 0xDF);
-
-			_channelNum1 = _activeChannelNumber;
-			_v1 = _channelData[_channelNum1]._field0;
-			_freqMask1 = _channelData[_channelNum1]._freqMask;
-			_freqBase1 = _channelData[_channelNum1]._freqBase;
-			_v7 = _channelData[_channelNum1]._field6;
-		} else {
-			_stateFlag = 0;
-			if (_v2)
-				write2(8, 0xB0 + _channelNum2, _ports[0xB0 + _channelNum2] & 0xDF);
-
-			_channelNum2 = _activeChannelNumber;
-			_v2 = _channelData[_channelNum2]._field0;
-			_freqMask2 = _channelData[_channelNum2]._freqMask;
-			_freqBase2 = _channelData[_channelNum2]._freqBase;
-			_v8 = _channelData[_channelNum2]._field6;
-		}
-
-		resultCheck();
-	} else {
-		int reg = 0xA0 + _activeChannelNumber;
-		int vTimes = (_activeChannelPtr->_field4 + _activeChannelPtr->_field1F) / 12;
-		int vOffset = (_activeChannelPtr->_field4 + _activeChannelPtr->_field1F) % 12;
-		int val = _vList1[vOffset] + _activeChannelPtr->_field1D;
-		write2(8, reg, val & 0xFF);
-
-		reg += 0x10;
-		write2(8, reg, (_ports[reg] & 0x20) | (vTimes << 2) | (val >> 8));
-
-		write2(8, reg, _ports[reg] | 0x20);
-	}
-}
-
-static const int outputIndexes[] = {
-	3, 1, 4, 2, 5, 6, 9, 7, 10, 8, 11, 12, 15, 13, 16, 14, 17
-};
-static const int outputChannels[] = {
-	0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 16, 17, 18, 19, 20, 21, 0
-};
-static const int volumeList[] = {
-	0x3F, 0x3F, 0x36, 0x31, 0x2D, 0x2A, 0x28, 0x26, 0x24, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1D, 0x1C,
-	0x1B, 0x1A, 0x19, 0x19, 0x18, 0x17, 0x17, 0x16, 0x16, 0x15, 0x15, 0x14, 0x14, 0x13, 0x12, 0x12,
-	0x11, 0x11, 0x10, 0x10, 0x0F, 0x0F, 0x0E, 0x0E, 0x0D, 0x0D, 0x0C, 0x0C, 0x0B, 0x0B, 0x0A, 0x0A,
-	0x0A, 0x09, 0x09, 0x09, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x08, 0x07, 0x07, 0x07, 0x07, 0x07,
-	0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04,
-	0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
-	0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01,
-	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-};
-
-void ASound::updateActiveChannel() {
-	int reg = 0x40 + outputChannels[outputIndexes[_activeChannelNumber * 2]];
-	int portVal = _ports[reg] & 0xFFC0;
-	int newVolume = CLIP(_activeChannelPtr->_volume + _activeChannelPtr->_field1E, 0, 63);
-	
-	// Note: Original had a whole block not seeming to be used, since the initialisation
-	// sets a variable to 5660h, and doesn't change it, so the branch is never taken
-	int val = CLIP(newVolume - volumeList[_activeChannelPtr->_fieldD], 0, 63);
-	val = (63 - val) | portVal;
-
-	int val2 = CLIP(newVolume - volumeList[-(_activeChannelPtr->_fieldD - 127)], 0, 63);
-	val2 = (63 - val2) | portVal;
-	write2(0, reg, val);
-	write2(2, reg, val2);
-}
-
-void ASound::loadSample(int sampleIndex) {
-	_activeChannelReg = 0xB0 + _activeChannelNumber;
-	write2(8, _activeChannelReg, _ports[_activeChannelReg] & 0xDF);
-
-	_activeChannelReg = _activeChannelNumber;
-	_samplePtr = &_samples[sampleIndex * 2];
-	_v11 = outputChannels[outputIndexes[_activeChannelReg * 2 - 1]];
-	processSample();
-
-	AdlibChannelData &cd = _channelData[_activeChannelNumber];
-	cd._field6 = _samplePtr->_field14;
-	cd._freqBase = _samplePtr->_freqBase;
-	cd._freqMask = _samplePtr->_freqMask;
-	cd._field0 = _samplePtr->_fieldE;
-
-	_samplePtr = &_samples[sampleIndex * 2 + 1];
-	_v11 = outputChannels[outputIndexes[_activeChannelReg * 2]];
-	processSample();
-}
-
-void ASound::processSample() {
-	// Write out vib flags and split point
-	write2(8, 0x40 + _v11, 0x3F);
-	int depthRhythm = (_ports[0xBD] & 0x3F) | (_amDep ? 0x80 : 0) |
-		(_vibDep ? 0x40 : 0);
-	write2(8, 0xBD, depthRhythm);
-	write2(8, 8, _splitPoint ? 0x40 : 0);
-
-	// Write out feedback & Alg
-	int val = (_samplePtr->_feedback << 1) | (1 - _samplePtr->_alg);
-	write2(8, 0xC0 + _activeChannelReg, val);
-
-	// Write out attack/decay rate
-	val = (_samplePtr->_attackRate << 4) | (_samplePtr->_decayRate & 0xF);
-	write2(8, 0x60 + _v11, val);
-
-	// Write out sustain level/release rate
-	val = (_samplePtr->_sustainLevel << 4) | (_samplePtr->_releaseRate & 0xF);
-	write2(8, 0x80 + _v11, val);
-
-	// Write out misc flags
-	val = (_samplePtr->_ampMod ? 0x80 : 0) | (_samplePtr->_vib ? 0x40 : 0)
-		| (_samplePtr->_egTyp ? 0x20 : 0) | (_samplePtr->_ksr ? 0x10 : 0)
-		| (_samplePtr->_freqMultiple & 0xF);
-	write2(8, 0x20 + _v11, val);
-
-	// Write out waveform select
-	write2(8, 0xE0 + _v11, _samplePtr->_waveformSelect & 3);
-	
-	// Write out total level & scaling level
-	val = -((_samplePtr->_totalLevel & 0x3F) - 0x3F) | (_samplePtr->_scalingLevel << 6);
-	write2(8, 0x40 + _v11, val);
-}
-
-void ASound::updateFNumber() {
-	int loReg = 0xA0 + _activeChannelNumber;
-	int hiReg = 0xB0 + _activeChannelNumber;
-	int val1 = (_ports[hiReg] & 0x1F) << 8;
-	val1 += _ports[loReg] + _activeChannelPtr->_field1;
-	write2(8, loReg, val1);
-
-	int val2 = (_ports[hiReg] & 0x20) | (val1 >> 8);
-	write2(8, hiReg, val2);
-}
-
-int ASound::readBuffer(int16 *buffer, const int numSamples) {
-	Common::StackLock slock(_driverMutex);
-
-	int32 samplesLeft = numSamples;
-	memset(buffer, 0, sizeof(int16) * numSamples);
-	while (samplesLeft) {
-		if (!_samplesTillCallback) {
-			poll();
-			flush();
-
-			_samplesTillCallback = _samplesPerCallback;
-			_samplesTillCallbackRemainder += _samplesPerCallbackRemainder;
-			if (_samplesTillCallbackRemainder >= CALLBACKS_PER_SECOND) {
-				_samplesTillCallback++;
-				_samplesTillCallbackRemainder -= CALLBACKS_PER_SECOND;
-			}
-		}
-
-		int32 render = MIN<int>(samplesLeft, _samplesTillCallback);
-		samplesLeft -= render;
-		_samplesTillCallback -= render;
-
-		_opl->readBuffer(buffer, render);
-		buffer += render;
-	}
-	return numSamples;
-}
-
-int ASound::command0() {
-	bool isDisabled = _isDisabled;
-	_isDisabled = true;
-
-	for (int i = 0; i < ADLIB_CHANNEL_COUNT; ++i)
-		_channels[i].reset();
-
-	_v1 = 0;
-	_v2 = 0;
-	_freqMask1 = _freqMask2 = 0;
-	_freqBase1 = _freqBase2 = 0;
-	_v7 = 0;
-	_v8 = 0;	
-
-	// Reset Adlib port registers
-	for (int reg = 0x4F; reg >= 0x40; --reg)
-		write2(8, reg, 0x3F);
-	for (int reg = 0xFF; reg >= 0x60; --reg)
-		write2(8, reg, 0);
-	for (int reg = 0x3F; reg > 0; --reg)
-		write2(8, reg, 0);
-	write2(8, 1, 0x20);
-
-	_isDisabled = isDisabled;
-	return 0;
-}
-
-int ASound::command1() {
-	for (int i = 0; i < ADLIB_CHANNEL_COUNT; ++i)
-		_channels[i].enable(0xFF);
-	return 0;
-}
-
-int ASound::command2() {
-	for (int i = 0; i < ADLIB_CHANNEL_MIDWAY; ++i)
-		_channels[i].setPtr2(_nullData);
-	return 0;
-}
-
-int ASound::command3() {
-	for (int i = 0; i < ADLIB_CHANNEL_MIDWAY; ++i)
-		_channels[i].enable(0xFF);
-	return 0;
-}
-
-int ASound::command4() {
-	for (int i = ADLIB_CHANNEL_MIDWAY; i < ADLIB_CHANNEL_COUNT; ++i)
-		_channels[i].setPtr2(_nullData);
-	return 0;
-}
-
-int ASound::command5() {
-	for (int i = 5; i < ADLIB_CHANNEL_COUNT; ++i)
-		_channels[i].enable(0xFF);
-	return 0;
-}
-
-int ASound::command6() {
-	_v9 = _v1;
-	_v1 = 0;
-	_v10 = _v2;
-	_v2 = 0;
-
-	channelOff(0x43);
-	channelOff(0x44);
-	channelOff(0x45);
-	channelOff(0x4B);
-	channelOff(0x4C);
-	channelOff(0x4D);
-	channelOff(0x53);
-	channelOff(0x54);
-	channelOff(0x55);
-
-	return 0;
-}
-
-int ASound::command7() {
-	channelOn(0x43, _channels[0]._volume);
-	channelOn(0x44, _channels[1]._volume);
-	channelOn(0x45, _channels[2]._volume);
-	channelOn(0x4B, _channels[3]._volume);
-	channelOn(0x4C, _channels[4]._volume);
-	channelOn(0x4D, _channels[5]._volume);
-
-	_v1 = _v9;
-	_v2 = _v10;
-
-	if (_v9 != _v10)
-		resultCheck();
-
-	_isDisabled = 0;
-	return _v10;
-}
-
-int ASound::command8() {
-	int result = 0;
-	for (int i = 0; i < ADLIB_CHANNEL_COUNT; ++i)
-		result |= _channels[i]._activeCount;
-
-	return result;
-}
-
-/*-----------------------------------------------------------------------*/
-
-const ASound1::CommandPtr ASound1::_commandList[42] = {
-	&ASound1::command0, &ASound1::command1, &ASound1::command2, &ASound1::command3,
-	&ASound1::command4, &ASound1::command5, &ASound1::command6, &ASound1::command7, 
-	&ASound1::command8, &ASound1::command9, &ASound1::command10, &ASound1::command11,
-	&ASound1::command12, &ASound1::command13, &ASound1::command14, &ASound1::command15,
-	&ASound1::command16, &ASound1::command17, &ASound1::command18, &ASound1::command19, 
-	&ASound1::command20, &ASound1::command21, &ASound1::command22, &ASound1::command23, 
-	&ASound1::command24, &ASound1::command25, &ASound1::command26, &ASound1::command27,
-	&ASound1::command28, &ASound1::command29, &ASound1::command30, &ASound1::command31, 
-	&ASound1::command32, &ASound1::command33, &ASound1::command34, &ASound1::command35,
-	&ASound1::command36, &ASound1::command37, &ASound1::command38, &ASound1::command39, 
-	&ASound1::command40, &ASound1::command41
-};
-
-ASound1::ASound1(Audio::Mixer *mixer): ASound(mixer, "asound.001", 0x1520) {
-	_cmd23Toggle = false;
-	
-	// Load sound samples
-	_soundFile.seek(_dataOffset + 0x12C);
-	for (int i = 0; i < 98; ++i)
-		_samples.push_back(AdlibSample(_soundFile));
-}
-
-int ASound1::command(int commandId) {
-	if (commandId > 41)
-		return 0;
-
-	_frameCounter = 0;
-	return (this->*_commandList[commandId])();
-}
-
-int ASound1::command9() {
-	playSound(0xC68, 12);
-	return 0;
-}
-
-int ASound1::command10() {
-	byte *pData1 = loadData(0x130E, 48);
-	if (!isSoundActive(pData1)) {
-		command1();
-		_channels[0].load(pData1);
-		_channels[1].load(loadData(0x133E, 392));
-		_channels[2].load(loadData(0x14C6, 46));
-		_channels[3].load(loadData(0x14F4, 48));
-	}
-
-	return 0;
-}
-
-int ASound1::command11() {
-	command111213();
-	_channels[0]._field1E = 0;
-	_channels[1]._field1E = 0;
-	return 0;
-}
-
-int ASound1::command12() {
-	command111213();
-	_channels[0]._field1E = 40;
-	_channels[1]._field1E = 0;
-	return 0;
-}
-
-int ASound1::command13() {
-	command111213();
-	_channels[0]._field1E = 40;
-	_channels[1]._field1E = 50;
-	return 0;
-}
-
-int ASound1::command14() {
-	playSound(0x1216, 248);
-	return 0;
-}
-
-int ASound1::command15() {
-	byte *pData1 = loadData(0x1524, 152);
-	if (!isSoundActive(pData1)) {
-		command1();
-		_channels[4].load(pData1);
-		_channels[5].load(loadData(0x15BC, 94));
-		_channels[6].load(loadData(0x161A, 94));
-		_channels[7].load(loadData(0x1678, 42));
-		_channels[8].load(loadData(0x16A2, 42));
-	}
-
-	return 0;
-}
-
-int ASound1::command16() {
-	playSound(0xC74, 14);
-	return 0;
-}
-
-int ASound1::command17() {
-	playSound(0xE9A, 10);
-	return 0;
-}
-
-int ASound1::command18() {
-	command1();
-	playSound(0xCA6, 20);
-	return 0;
-}
-
-int ASound1::command19() {
-	command1();
-	playSound(0xCBA, 74);
-	return 0;
-}
-
-int ASound1::command20() {
-	byte *pData = loadData(0xD18, 28);
-	if (!isSoundActive(pData))
-		playSound(pData);
-	return 0;
-}
-
-int ASound1::command21() {
-	playSound(0xD04, 20);
-	return 0;
-}
-
-int ASound1::command22() {
-	byte *pData = loadData(0xD34, 10);
-	pData[6] = (getRandomNumber() & 7) + 85;
-
-	if (!isSoundActive(pData))
-		playSound(pData);
-
-	return 0;
-}
-
-int ASound1::command23() {
-	_cmd23Toggle = !_cmd23Toggle;
-	playSound(_cmd23Toggle ? 0xD3E : 0xD46, 8);
-	return 0;
-}
-
-int ASound1::command24() {
-	playSound(0xD4E, 18);
-	playSound(0xD60, 20);
-	playSound(0xD74, 14);
-	return 0;
-}
-
-int ASound1::command25() {
-	byte *pData = loadData(0xD82, 16);
-	if (!isSoundActive(pData))
-		playSound(pData);
-
-	return 0;
-}
-
-int ASound1::command26() {
-	error("TODO: command26");
-	return 0;
-}
-
-int ASound1::command27() {
-	error("TODO: ASound::command27");
-	return 0;
-}
-
-int ASound1::command28() {
-	playSound(0xD92, 28);
-	return 0;
-}
-
-int ASound1::command29() {
-	error("TODO: ASound::command29");
-	return 0;
-}
-
-int ASound1::command30() {
-	error("TODO: ASound::command30");
-	return 0;
-}
-
-int ASound1::command31() {
-	byte *pData = loadData(0xDAE, 14);
-	if (!isSoundActive(pData))
-		playSound(pData);
-
-	return 0;
-}
-
-int ASound1::command32() {
-	error("TODO: ASound::command32");
-	return 0;
-}
-
-int ASound1::command33() {
-	playSound(0xDBC, 10);
-	playSound(0xDC6, 10);
-	return 0;
-}
-
-int ASound1::command34() {
-	int v = getRandomNumber() & 0x20;
-	if (!v) 
-		v = 0x60;
-
-	byte *pData = loadData(0xDD0, 22);
-	pData[8] = pData[15] = v;
-	playSound(pData);
-	return 0;
-}
-
-int ASound1::command35() {
-	playSound(0xDE6, 16);
-	return 0;
-}
-
-int ASound1::command36() {
-	playSound(0xE10, 10);
-	command34();
-
-	return 0;
-}
-
-int ASound1::command37() {
-	playSound(0xE1A, 14);
-	return 0;
-}
-
-int ASound1::command38() {
-	playSound(0xE28, 114);
-	return 0;
-}
-
-int ASound1::command39() {
-	byte *pData1 = loadData(0x16CC, 82);
-	if (!isSoundActive(pData1)) {
-		_channels[5].load(pData1);
-		_channels[6].load(loadData(0x171E, 30));
-		_channels[7].load(loadData(0x173C, 40));
-		_channels[8].load(loadData(0x1764, 64));
-	}
-	return 0;
-}
-
-int ASound1::command40() {
-	playSound(0xDF6, 26);
-	return 0;
-}
-
-int ASound1::command41() {
-	playSound(0xC32, 34);
-	playSound(0xC54, 20);
-	return 0;
-}
-
-void ASound1::command111213() {
-	byte *pData1 = loadData(0xEF6, 408);
-	if (!isSoundActive(pData1)) {
-		command1();
-		_channels[0].load(pData1);
-		_channels[1].load(loadData(0x108E, 266));
-		_channels[2].load(loadData(0x1198, 66));
-		_channels[2].load(loadData(0x11DA, 60));
-	}
-}
-
-void ASound1::command2627293032() {
-	// TODO: This method takes a parameter off the stack for several levels up.
-	// i.e. something the caller's caller pushed onto the stack. Need to figure
-	// out a better way to pass parameters down if this is actually in use.
-}
-
-} // End of namespace Nebular
-
-} // End of namespace MADS
diff --git a/engines/mads/sound_nebular.h b/engines/mads/sound_nebular.h
deleted file mode 100644
index 11836e6..0000000
--- a/engines/mads/sound_nebular.h
+++ /dev/null
@@ -1,408 +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 MADS_SOUND_NEBULAR_H
-#define MADS_SOUND_NEBULAR_H
-
-#include "common/scummsys.h"
-#include "common/file.h"
-#include "common/mutex.h"
-#include "common/queue.h"
-#include "audio/audiostream.h"
-#include "audio/fmopl.h"
-#include "audio/mixer.h"
-
-namespace MADS {
-
-class SoundManager;
-
-namespace Nebular {
-
-/**
- * Represents the data for a channel on the Adlib
- */
-class AdlibChannel {
-public:
-	int _activeCount;
-	int _field1;
-	int _field2;
-	int _field3;
-	int _field4;
-	int _sampleIndex;
-	int _volume;
-	int _field7;
-	int _field8;
-	int _field9;
-	int _fieldA;
-	uint8 _fieldB;
-	int _fieldC;
-	int _fieldD;
-	int _fieldE;
-	byte *_ptr1;
-	byte *_pSrc;
-	byte *_ptr3;
-	byte *_ptr4;
-	int _field17;
-	int _field19;
-	byte *_soundData;
-	int _field1D;
-	int _field1E;
-	int _field1F;
-public:
-	AdlibChannel();
-
-	void reset();
-	void enable(int flag);
-	void setPtr2(byte *pData);
-	void load(byte *pData);
-	void check(byte *nullPtr);
-};
-
-class AdlibChannelData {
-public:
-	int _field0;
-	int _freqMask;
-	int _freqBase;
-	int _field6;
-};
-
-class AdlibSample {
-public:
-	int _attackRate;
-	int _decayRate;
-	int _sustainLevel;
-	int _releaseRate;
-	bool _egTyp;
-	bool _ksr;
-	int _totalLevel;
-	int _scalingLevel;
-	int _waveformSelect;
-	int _freqMultiple;
-	int _feedback;
-	bool _ampMod;
-	int _vib;
-	int _alg;
-	int _fieldE;
-	int _freqMask;
-	int _freqBase;
-	int _field14;
-
-	AdlibSample() {}
-	AdlibSample(Common::SeekableReadStream &s);
-};
-
-struct RegisterValue {
-	uint8 _regNum;
-	uint8 _value;
-
-	RegisterValue(int regNum, int value) {
-		_regNum = regNum; _value = value;
-	}
-};
-
-#define ADLIB_CHANNEL_COUNT 9
-#define ADLIB_CHANNEL_MIDWAY 5
-#define CALLBACKS_PER_SECOND 60
-
-/**
- * Base class for the sound player resource files
- */
-class ASound: public Audio::AudioStream {
-private:
-	struct CachedDataEntry {
-		int _offset;
-		byte *_data;
-	};
-	Common::List<CachedDataEntry> _dataCache;
-	uint16 _randomSeed;
-
-	/**
-	 * Does the initial Adlib initialisation
-	 */
-	void adlibInit();
-
-	/**
-	 * Does on-going processing for the Adlib sounds being played
-	 */
-	void update();
-
-	/**
-	 * Polls each of the channels for updates
-	 */
-	void pollChannels();
-
-	/**
-	 * Checks the status of the channels
-	 */
-	void checkChannels();
-
-	/**
-	 * Polls the currently active channel
-	 */
-	void pollActiveChannel();
-
-	/**
-	 * Updates the octave of the currently active channel
-	 */
-	void updateOctave();
-
-	void updateChannelState();
-	void updateActiveChannel();
-	
-	/**
-	 * Loads up the specified sample
-	 */
-	void loadSample(int sampleIndex);
-
-	/**
-	 * Writes out the data of the selected sample to the Adlib
-	 */
-	void processSample();
-
-	void updateFNumber();
-protected:
-	/**
-	 * Queue a byte for an Adlib register
-	 */
-	void write(int reg, int val);
-
-	/**
-	 * Queue a byte for an Adlib register, and store it in the _ports array
-	 */
-	int write2(int state, int reg, int val);
-
-	/**
-	 * Flush any pending Adlib register values to the OPL driver
-	 */
-	void flush();
-
-	/**
-	 * Turn a channel on
-	 */
-	void channelOn(int reg, int volume);
-
-	/**
-	 * Turn a channel off
-	 */
-	void channelOff(int reg);
-
-	/**
-	 * Checks for whether a poll result needs to be set
-	 */
-	void resultCheck();
-
-	/**
-	 * Loads a data block from the sound file, caching the result for any future
-	 * calls for the same data
-	 */
-	byte *loadData(int offset, int size);
-
-	/**
-	 * Play the specified sound
-	 * @param offset	Offset of sound data within sound player data segment
-	 * @param size		Size of sound data block
-	 */
-	void playSound(int offset, int size);
-
-	/**
-	 * Play the specified raw sound data
-	 * @param pData		Pointer to data block containing sound data
-	 */
-	void playSound(byte *pData);
-
-	/**
-	 * Checks to see whether the given block of data is already loaded into a channel.
-	 */
-	bool isSoundActive(byte *pData);
-
-	/**
-	 * Sets the frequency for a given channel.
-	 */
-	void setFrequency(int channel, int freq);
-
-	/**
-	 * Returns a 16-bit random number
-	 */
-	int getRandomNumber();
-
-	int command0();
-	int command1();
-	int command2();
-	int command3();
-	int command4();
-	int command5();
-	int command6();
-	int command7();
-	int command8();
-public:
-	Audio::Mixer *_mixer;
-	FM_OPL *_opl;
-	Audio::SoundHandle _soundHandle;
-	AdlibChannel _channels[ADLIB_CHANNEL_COUNT];
-	AdlibChannel *_activeChannelPtr;
-	AdlibChannelData _channelData[11];
-	Common::Array<AdlibSample> _samples;
-	AdlibSample *_samplePtr;
-	Common::File _soundFile;
-	Common::Queue<RegisterValue> _queue;
-	Common::Mutex _driverMutex;
-	int _dataOffset;
-	int _frameCounter;
-	bool _isDisabled;
-	int _v1;
-	int _v2;
-	int _activeChannelNumber;
-	int _freqMask1;
-	int _freqMask2;
-	int _freqBase1;
-	int _freqBase2;
-	int _channelNum1, _channelNum2;
-	int _v7;
-	int _v8;
-	int _v9;
-	int _v10;
-	int _pollResult;
-	int _resultFlag;
-	byte _nullData[2];
-	int _ports[256];
-	bool _stateFlag;
-	int _activeChannelReg;
-	int _v11;
-	bool _amDep, _vibDep, _splitPoint;
-	int _samplesPerCallback;
-	int _samplesPerCallbackRemainder;
-	int _samplesTillCallback;
-	int _samplesTillCallbackRemainder;
-public:
-	/**
-	 * Constructor
-	 * @param filename		Specifies the adlib sound player file to use
-	 * @param dataOffset	Offset in the file of the data segment
-	 */
-	ASound(Audio::Mixer *mixer, const Common::String &filename, int dataOffset);
-
-	/**
-	 * Destructor
-	 */
-	virtual ~ASound();
-
-	/**
-	 * Execute a player command. Most commands represent sounds to play, but some
-	 * low number commands also provide control operations
-	 */
-	virtual int command(int commandId) = 0;
-
-	/**
-	 * Stop all currently playing sounds
-	 */
-	int stop();
-
-	/**
-	 * Main poll method to allow sounds to progress
-	 */
-	int poll();
-
-	/**
-	 * General noise/note output
-	 */
-	void noise();
-
-	/**
-	 * Return the current frame counter
-	 */
-	int getFrameCounter() { return _frameCounter; }
-
-	// AudioStream interface
-	/**
-	 * Main buffer read
-	 */
-	virtual int readBuffer(int16 *buffer, const int numSamples);
-	
-	/**
-	 * Mono sound only
-	 */
-	virtual bool isStereo() const { return false; }
-	
-	/**
-	 * Data is continuously pushed, so definitive end
-	 */
-	virtual bool endOfData() const { return false; }
-
-	/**
-	 * Return sample rate
-	 */
-	virtual int getRate() const { return 11025; }
-};
-
-class ASound1: public ASound {
-private:
-	typedef int (ASound1::*CommandPtr)();
-	static const CommandPtr _commandList[42];
-	bool _cmd23Toggle;
-
-	int command9();
-	int command10();
-	int command11();
-	int command12();
-	int command13();
-	int command14();
-	int command15();
-	int command16();
-	int command17();
-	int command18();
-	int command19();
-	int command20();
-	int command21();
-	int command22();
-	int command23();
-	int command24();
-	int command25();
-	int command26();
-	int command27();
-	int command28();
-	int command29();
-	int command30();
-	int command31();
-	int command32();
-	int command33();
-	int command34();
-	int command35();
-	int command36();
-	int command37();
-	int command38();
-	int command39();
-	int command40();
-	int command41();
-
-	void command111213();
-	void command2627293032();
-public:
-	ASound1(Audio::Mixer *mixer);
-
-	virtual int command(int commandId);
-};
-
-} // End of namespace Nebular
-
-} // End of namespace MADS
-
-#endif /* MADS_SOUND_NEBULAR_H */


Commit: 4581b26b12d21801eee0c5df2dbd1b260300498c
    https://github.com/scummvm/scummvm/commit/4581b26b12d21801eee0c5df2dbd1b260300498c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-20T22:27:01-05:00

Commit Message:
MADS: Implemented resource manager using ScummVM Archive interface

Changed paths:
    engines/mads/compression.cpp
    engines/mads/font.cpp
    engines/mads/mads.cpp
    engines/mads/msurface.cpp
    engines/mads/nebular/dialogs_nebular.h
    engines/mads/resources.cpp
    engines/mads/resources.h



diff --git a/engines/mads/compression.cpp b/engines/mads/compression.cpp
index b5e24df..febb6ec 100644
--- a/engines/mads/compression.cpp
+++ b/engines/mads/compression.cpp
@@ -46,9 +46,9 @@ MadsPack::MadsPack(Common::SeekableReadStream *stream) {
 }
 
 MadsPack::MadsPack(const Common::String &resourceName, MADSEngine *vm) {
-	Common::SeekableReadStream *stream = vm->_resources->get(resourceName);
+	Common::SeekableReadStream *stream = nullptr; //vm->_resources->get(resourceName);
 	initialise(stream);
-	vm->_resources->toss(resourceName);
+//	vm->_resources->toss(resourceName);
 }
 
 void MadsPack::initialise(Common::SeekableReadStream *stream) {
diff --git a/engines/mads/font.cpp b/engines/mads/font.cpp
index e97cc95..076eca9 100644
--- a/engines/mads/font.cpp
+++ b/engines/mads/font.cpp
@@ -233,7 +233,7 @@ void FontM4::setFont(const Common::String &filename) {
 	_sysFont = false;
 	_filename = filename;
 
-	Common::SeekableReadStream *fontFile = _vm->_resources->openFile(filename);
+	Common::SeekableReadStream *fontFile = nullptr; //_vm->_resources->openFile(filename);
 	
 	if (fontFile->readUint32LE() != MKTAG('F', 'O', 'N', 'T')) {
 		warning("Font: FONT tag expected");
@@ -272,7 +272,7 @@ void FontM4::setFont(const Common::String &filename) {
 	_charData = new uint8[fontSize];
 	fontFile->read(_charData, fontSize);
 
-	_vm->_resources->toss(filename);
+//	_vm->_resources->toss(filename);
 }
 
 int FontM4::getBpp(int charWidth) {
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 05c1140..ec99b31 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -72,10 +72,10 @@ void MADSEngine::initialise() {
 	MSurface::setVm(this);
 	MSprite::setVm(this);
 
+	ResourcesManager::init(this);
 	_events = new EventsManager(this);
 	_palette = Palette::init(this);
 	_font = Font::init(this);
-	_resources = new ResourcesManager(this);
 	_screen = MSurface::init(true);
 	_sound = new SoundManager(this, _mixer);
 	_userInterface = UserInterface::init(this);
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index f71a4a7..2c0b433 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -26,6 +26,7 @@
 #include "mads/mads.h"
 #include "mads/msprite.h"
 #include "mads/msurface.h"
+#include "mads/resources.h"
 
 namespace MADS {
 
@@ -412,14 +413,14 @@ void MSurfaceMADS::loadBackground(int roomNumber, RGBList **palData) {
 		tileMap[i] = mapStream->readUint16LE();
 	delete mapStream;
 
-	_vm->_resources->toss(resourceName);
+//	_vm->_resources->toss(resourceName);
 
 	// --------------------------------------------------------------------------------
 
 	// Tile map data, which needs to be kept compressed, as the tile offsets refer to
 	// the compressed data. Each tile is then uncompressed separately
 	sprintf(resourceName, "rm%d.tt", roomNumber);
-	Common::SeekableReadStream *tileDataComp = _vm->_resources->get(resourceName);
+	Common::SeekableReadStream *tileDataComp = nullptr; //_vm->_resources->get(resourceName);
 	MadsPack tileData(tileDataComp);
 	Common::SeekableReadStream *tileDataUncomp = tileData.getItemStream(0);
 
@@ -499,7 +500,7 @@ void MSurfaceMADS::loadBackground(int roomNumber, RGBList **palData) {
 		}
 	}
 	tileSet.clear();
-	_vm->_resources->toss(resourceName);
+//	_vm->_resources->toss(resourceName);
 }
 
 void MSurfaceMADS::loadInterface(int index, RGBList **palData) {
@@ -534,10 +535,10 @@ void MSurfaceNebular::loadBackground(int roomNumber, RGBList **palData) {
 	empty();
 
 	Common::String resourceName = Common::String::format("rm%d.art", roomNumber);
-	Common::SeekableReadStream *stream = _vm->_resources->get(resourceName);	
+	Common::SeekableReadStream *stream = nullptr; //_vm->_resources->get(resourceName);	
 	loadBackgroundStream(stream, palData);
 
-	_vm->_resources->toss(resourceName);
+//	_vm->_resources->toss(resourceName);
 }
 
 void MSurfaceNebular::loadBackgroundStream(Common::SeekableReadStream *source, RGBList **palData) {
@@ -597,10 +598,10 @@ void MSurfaceM4::loadBackground(int roomNumber, RGBList **palData) {
 	if (palData)
 		*palData = NULL;
 	Common::String resourceName = Common::String::format("%i.tt", roomNumber);
-	Common::SeekableReadStream *stream = _vm->_resources->get(resourceName);	
+	Common::SeekableReadStream *stream = nullptr;//_vm->_resources->get(resourceName);	
 	loadBackgroundStream(stream);
 
-	_vm->_resources->toss(resourceName);
+//	_vm->_resources->toss(resourceName);
 }
 
 void MSurfaceM4::loadBackgroundStream(Common::SeekableReadStream *source) {
@@ -663,15 +664,11 @@ void MSurfaceM4::loadBackgroundStream(Common::SeekableReadStream *source) {
 /*------------------------------------------------------------------------*/
 
 void MSurfaceRiddle::loadBackground(const Common::String &sceneName) {
-	char resourceName[20];
-	Common::SeekableReadStream *stream;
 	// Loads a Riddle scene
 	Common::String resName = Common::String::format("%s.tt", sceneName.c_str());
-	stream = _vm->_resources->get(resourceName);
-
-	loadBackgroundStream(stream);
+	File stream(resName);
 
-	_vm->_resources->toss(resourceName);
+	loadBackgroundStream(&stream);
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index 669ac1e..a747f75 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -31,6 +31,8 @@ namespace MADS {
 namespace Nebular {
 
 class CopyProtectionDialog {
+private:
+
 public:
 	static bool show() { return false; }
 };
diff --git a/engines/mads/resources.cpp b/engines/mads/resources.cpp
index 27b94a9..0630230 100644
--- a/engines/mads/resources.cpp
+++ b/engines/mads/resources.cpp
@@ -21,12 +21,267 @@
  */
 
 #include "common/scummsys.h"
+#include "common/archive.h"
+#include "common/substream.h"
+#include "common/textconsole.h"
+#include "mads/mads.h"
 #include "mads/resources.h"
 
 namespace MADS {
 
-ResourcesManager::ResourcesManager(MADSEngine *vm) {
-	_vm = vm;
+enum ResourceType {RESTYPE_ROOM, RESTYPE_SC, RESTYPE_TEXT, RESTYPE_QUO, RESTYPE_I,
+	RESTYPE_OB, RESTYPE_FONT, RESTYPE_SOUND, RESTYPE_SPEECH, RESTYPE_HAS_EXT, RESTYPE_NO_EXT};
+
+/**
+ * HAG Archives implementation
+ */
+class HagArchive : public Common::Archive {
+private:
+	/**
+	 * Details of a single entry in a HAG file index
+	 */
+	struct HagEntry {
+		Common::String _resourceName;
+		uint32 _offset;
+		uint32 _size;
+
+		HagEntry(): _offset(0), _size(0) {}
+		HagEntry(Common::String resourceName, uint32 offset, uint32 size):
+			_resourceName(resourceName), _offset(offset), _size(size) {}
+	};
+
+	class HagIndex {
+	public:
+		Common::List<HagEntry> _entries;
+		Common::String _filename;
+	};
+
+	Common::Array<HagIndex> _index;
+
+	/**
+	 * Load the index of all the game's HAG files
+	 */
+	void loadIndex();
+
+	/**
+	 * Given a resource name, opens up the correct HAG file and returns whether
+	 * an entry with the given name exists.
+	 */
+	bool getHeaderEntry(const Common::String &resourceName, HagIndex &hagIndex, HagEntry &hagEntry) const;
+
+	/**
+	 * Returns the HAG resource filename that will contain a given resource
+	 */
+	Common::String getResourceFilename(const Common::String &resourceName) const;
+
+	/**
+	 * Return a resource type given a resource name
+	 */
+	ResourceType getResourceType(const Common::String &resourceName) const;
+public:
+	HagArchive();
+	virtual ~HagArchive();
+
+	// Archive implementation
+	virtual bool hasFile(const Common::String &name) const;
+	virtual int listMembers(Common::ArchiveMemberList &list) const;
+	virtual const Common::ArchiveMemberPtr getMember(const Common::String &name) const;
+	virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
+};
+
+void ResourcesManager::init(MADSEngine *vm) {
+	if (vm->getGameFeatures() & GF_MADS)
+		SearchMan.add("HAG", new HagArchive());
+	else
+		error("Unsupported game engine");
+}
+
+/*------------------------------------------------------------------------*/
+
+void File::openFile(const Common::String &filename) {
+	if (!Common::File::open(filename))
+		error("Could not open file - %s", filename.c_str());
+}
+
+/*------------------------------------------------------------------------*/
+
+const char *const MADSCONCAT_STRING = "MADSCONCAT";
+
+HagArchive::HagArchive() {
+	loadIndex();
+}
+
+HagArchive::~HagArchive() {
+}
+
+// Archive implementation
+bool HagArchive::hasFile(const Common::String &name) const {
+	HagIndex hagIndex;
+	HagEntry hagEntry;
+	return getHeaderEntry(name, hagIndex, hagEntry);
+}
+
+int HagArchive::listMembers(Common::ArchiveMemberList &list) const {
+	int members = 0;
+
+	for (uint hagCtr = 0; hagCtr < _index.size(); ++hagCtr) {
+		HagIndex hagIndex = _index[hagCtr];
+		Common::List<HagEntry>::iterator i;
+
+		for (i = hagIndex._entries.begin(); i != hagIndex._entries.end(); ++i) {
+			list.push_back(Common::ArchiveMemberList::value_type(
+				new Common::GenericArchiveMember((*i)._resourceName, this)));
+			++members;
+		}
+	}
+
+	return members;
+}
+
+const Common::ArchiveMemberPtr HagArchive::getMember(const Common::String &name) const {
+	if (!hasFile(name))
+		return Common::ArchiveMemberPtr();
+
+	return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this));
+}
+
+Common::SeekableReadStream *HagArchive::createReadStreamForMember(const Common::String &name) const {
+	HagIndex hagIndex;
+	HagEntry hagEntry;
+
+	if (getHeaderEntry(name, hagIndex, hagEntry)) {
+		// Entry found. If the correct file is not already open, open it
+		Common::File f;
+		if (!f.open(hagIndex._filename))
+			error("Could not open HAG file");
+
+		// Return a substream for the specific resource
+		return new Common::SeekableSubReadStream(&f, 
+			hagEntry._offset, hagEntry._size, DisposeAfterUse::YES);
+	}
+
+	return nullptr;
+}
+
+void HagArchive::loadIndex() {
+	Common::File hagFile;
+
+	for (int sectionIndex = -1; sectionIndex < 10; ++sectionIndex) {
+		Common::String filename = (sectionIndex == -1) ? "GLOBAL.HAG" :
+			Common::String::format("SECTION%d.HAG", sectionIndex);
+		if (!hagFile.open(filename))
+			error("Could not locate HAG file - %s", filename.c_str());
+	
+		// Check for header
+		char headerBuffer[16];
+		if ((hagFile.read(headerBuffer, 16) != 16) || 
+				(strncmp(headerBuffer, MADSCONCAT_STRING, 10) != 0))
+			error("Invalid HAG file opened");
+
+		// Scan through the HAG index
+		int numEntries = hagFile.readUint16LE();
+
+		HagIndex hagIndex;
+		for (int idx = 0; idx < numEntries; ++idx) {
+			// Read in the details of the next resource
+			char resourceBuffer[14];
+			uint32 offset = hagFile.readUint32LE();
+			uint32 size = hagFile.readUint32LE();
+			hagFile.read(resourceBuffer, 14);
+
+			hagIndex._entries.push_back(HagEntry(resourceBuffer, offset, size));
+		}
+
+		hagFile.close();
+		_index.push_back(hagIndex);
+	}
+}
+
+bool HagArchive::getHeaderEntry(const Common::String &resourceName,
+		HagIndex &hagIndex, HagEntry &hagEntry) const {
+	Common::String resName = resourceName;
+	resName.toUppercase();
+	if (resName[0] == '*')
+		resName.deleteChar(0);
+
+	Common::String hagFilename = getResourceFilename(resName);
+
+	// Find the index for the given file
+	for (uint hagCtr = 0; hagCtr < _index.size(); ++hagCtr) {
+		hagIndex = _index[hagCtr];
+
+		if (hagIndex._filename == hagFilename) {
+			Common::List<HagEntry>::iterator ei;
+			for (ei = hagIndex._entries.begin(); ei != hagIndex._entries.end(); ++ei) {
+				hagEntry = *ei;
+				if (hagEntry._resourceName == resName)
+					return true;
+			}
+		}
+	}
+
+	return false;
+}
+
+Common::String HagArchive::getResourceFilename(const Common::String &resourceName) const {
+	ResourceType resType = getResourceType(resourceName);
+	Common::String outputFilename = "GLOBAL.HAG";
+
+	if ((resType == RESTYPE_ROOM) || (resType == RESTYPE_SC)) {
+		int value = atoi(resourceName.c_str() + 2);
+		int hagFileNum = (resType == RESTYPE_ROOM) ? value / 100 : value;
+
+		if (hagFileNum > 0)
+			outputFilename = Common::String::format("SECTION%d.HAG", hagFileNum);
+	}
+
+	if (resType == RESTYPE_SPEECH)
+		outputFilename = "SPEECH.HAG";
+
+	return outputFilename;
+}
+
+ResourceType HagArchive::getResourceType(const Common::String &resourceName) const {
+	if (resourceName.hasPrefix("RM")) {
+		// Room resource
+		return RESTYPE_ROOM;
+	} else if (resourceName.hasPrefix("SC")) {
+		// SC resource
+		return RESTYPE_SC;
+	} else if (resourceName.hasSuffix(".TXT")) {
+		// Text resource
+		return RESTYPE_TEXT;
+	} else if (resourceName.hasSuffix(".QUO")) {
+		// QUO resource
+		return RESTYPE_QUO;
+	} else if (resourceName.hasPrefix("I")) {
+		// I resource
+		return RESTYPE_I;
+	} else if (resourceName.hasPrefix("OB")) {
+		// OB resource
+		return RESTYPE_OB;
+	} else if (resourceName.hasPrefix("FONT")) {
+		// FONT resource
+		return RESTYPE_FONT;
+	} else if (resourceName.hasPrefix("SOUND")) {
+		// SOUND resource
+		return RESTYPE_SOUND;
+	} else if (resourceName.hasPrefix("SPCHC")) {
+		// SPEECH resource
+		return RESTYPE_SPEECH;
+	} 
+
+	// Check for a known extension
+	const char *extPos = strchr(resourceName.c_str(), '.');
+	if (extPos) {
+		++extPos;
+		if (!strcmp(extPos, "FL") || !strcmp(extPos, "LBM") || !strcmp(extPos, "ANM") ||
+			!strcmp(extPos, "AA") || !strcmp(extPos, "SS")) {
+			return RESTYPE_HAS_EXT;
+		}
+	}
+
+	return RESTYPE_NO_EXT;
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/resources.h b/engines/mads/resources.h
index 68bb475..f4b7009 100644
--- a/engines/mads/resources.h
+++ b/engines/mads/resources.h
@@ -24,7 +24,7 @@
 #define MADS_RESOURCES_H
 
 #include "common/scummsys.h"
-#include "common/stream.h"
+#include "common/file.h"
 #include "common/str.h"
 
 namespace MADS {
@@ -32,29 +32,32 @@ namespace MADS {
 class MADSEngine;
 
 class ResourcesManager {
-private:
-	MADSEngine *_vm;
 public:
-	ResourcesManager(MADSEngine *vm);
+	/**
+	 * Instantiates the resource manager
+	 */
+	static void init(MADSEngine *vm);
+};
 
+/**
+ * Derived file class
+ */
+class File: public Common::File {
+public:
 	/**
-	 * Return a named resource
+	 * Constructor
 	 */
-	Common::SeekableReadStream *get(const Common::String &resourceName, bool loadFlag = false) {
-		// TODO
-		return nullptr;
-	}
+	File(): Common::File() {}
 
-	Common::SeekableReadStream *openFile(const Common::String &resourceName) { 
-		return get(resourceName, false); 
-	}
+	/**
+	 * Constructor
+	 */
+	File(const Common::String &filename) { openFile(filename); }
 
 	/**
-	 * Release a previously loaded resource
+	 * Opens the given file, throwing an error if it can't be opened
 	 */
-	void toss(const Common::String &resourceName) {
-		// TODO
-	}
+	void openFile(const Common::String &filename);
 };
 
 } // End of namespace MADS


Commit: 08386210025c65d7199d26962a00a4206e06a899
    https://github.com/scummvm/scummvm/commit/08386210025c65d7199d26962a00a4206e06a899
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-21T20:16:08-05:00

Commit Message:
MADS: Added remaining commands from the asound.001 player

Changed paths:
    engines/mads/nebular/sound_nebular.cpp
    engines/mads/nebular/sound_nebular.h



diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp
index 9c3ac61..dba4b36 100644
--- a/engines/mads/nebular/sound_nebular.cpp
+++ b/engines/mads/nebular/sound_nebular.cpp
@@ -303,9 +303,9 @@ void ASound::playSound(int offset, int size) {
 	playSound(loadData(offset, size));
 }
 
-void ASound::playSound(byte *pData) {
+void ASound::playSound(byte *pData, int startingChannel) {
 	// Scan for a high level free channel
-	for (int i = 5; i < ADLIB_CHANNEL_COUNT; ++i) {
+	for (int i = startingChannel; i < ADLIB_CHANNEL_COUNT; ++i) {
 		if (!_channels[i]._activeCount) {
 			_channels[i].load(pData);
 			return;
@@ -313,7 +313,7 @@ void ASound::playSound(byte *pData) {
 	}
 
 	// None found, do a secondary scan for an interruptable channel
-	for (int i = ADLIB_CHANNEL_COUNT - 1; i >= ADLIB_CHANNEL_MIDWAY; --i) {
+	for (int i = ADLIB_CHANNEL_COUNT - 1; i >= startingChannel; --i) {
 		if (_channels[i]._fieldE == 0xFF) {
 			_channels[i].load(pData);
 			return;
@@ -928,10 +928,11 @@ ASound1::ASound1(Audio::Mixer *mixer): ASound(mixer, "asound.001", 0x1520) {
 		_samples.push_back(AdlibSample(_soundFile));
 }
 
-int ASound1::command(int commandId) {
+int ASound1::command(int commandId, int param) {
 	if (commandId > 41)
 		return 0;
 
+	_commandParam = param;
 	_frameCounter = 0;
 	return (this->*_commandList[commandId])();
 }
@@ -1060,12 +1061,22 @@ int ASound1::command25() {
 }
 
 int ASound1::command26() {
-	error("TODO: command26");
+	byte *pData = loadData(0xEEC, 10);
+	pData[5] = (command2627293032() + 0x7F) & 0xFF;
+
+	if (!isSoundActive(pData))
+		_channels[6].load(pData);
+
 	return 0;
 }
 
 int ASound1::command27() {
-	error("TODO: ASound::command27");
+	byte *pData = loadData(0xEE2, 10);
+	pData[5] = (command2627293032() + 0x40) & 0xFF;
+
+	if (!isSoundActive(pData))
+		_channels[7].load(pData);
+
 	return 0;
 }
 
@@ -1075,12 +1086,23 @@ int ASound1::command28() {
 }
 
 int ASound1::command29() {
-	error("TODO: ASound::command29");
+	byte *pData = loadData(0xC82, 36);
+	byte v = (command2627293032() + 0x40) & 0xFF;
+	pData[7] = pData[13] = pData[21] = pData[27] = v;
+
+	if (!isSoundActive(pData))
+		playSound(pData, 0);
+
 	return 0;
 }
 
 int ASound1::command30() {
-	error("TODO: ASound::command30");
+	byte *pData = loadData(0xEA6, 16);
+	pData[7] = (command2627293032() + 0x40) & 0xFF;
+
+	if (!isSoundActive(pData))
+		playSound(pData, 0);
+
 	return 0;
 }
 
@@ -1093,7 +1115,14 @@ int ASound1::command31() {
 }
 
 int ASound1::command32() {
-	error("TODO: ASound::command32");
+	byte *pData = loadData(0xEB4, 46);
+	int v = command2627293032() + 0x40;
+	pData[9] = pData[17] = pData[25] = pData[33] = v & 0xFF;
+	pData[11] = pData[19] = pData[27] = pData[35] = v >> 8;
+
+	if (!isSoundActive(pData))
+		playSound(pData, 0);
+
 	return 0;
 }
 
@@ -1169,10 +1198,8 @@ void ASound1::command111213() {
 	}
 }
 
-void ASound1::command2627293032() {
-	// TODO: This method takes a parameter off the stack for several levels up.
-	// i.e. something the caller's caller pushed onto the stack. Need to figure
-	// out a better way to pass parameters down if this is actually in use.
+int ASound1::command2627293032() {
+	return (_commandParam > 0x40) ? _commandParam - 0x40 : _commandParam & 0xff00;
 }
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/sound_nebular.h b/engines/mads/nebular/sound_nebular.h
index 11836e6..c7a2862 100644
--- a/engines/mads/nebular/sound_nebular.h
+++ b/engines/mads/nebular/sound_nebular.h
@@ -226,8 +226,9 @@ protected:
 	/**
 	 * Play the specified raw sound data
 	 * @param pData		Pointer to data block containing sound data
+	 * @param startingChannel	Channel to start scan from
 	 */
-	void playSound(byte *pData);
+	void playSound(byte *pData, int startingChannel = ADLIB_CHANNEL_COUNT);
 
 	/**
 	 * Checks to see whether the given block of data is already loaded into a channel.
@@ -307,9 +308,11 @@ public:
 
 	/**
 	 * Execute a player command. Most commands represent sounds to play, but some
-	 * low number commands also provide control operations
+	 * low number commands also provide control operations.
+	 * @param commandId		Player ommand to execute.
+	 * @param param			Optional parameter used by a few commands
 	 */
-	virtual int command(int commandId) = 0;
+	virtual int command(int commandId, int param = 0) = 0;
 
 	/**
 	 * Stop all currently playing sounds
@@ -358,6 +361,7 @@ private:
 	typedef int (ASound1::*CommandPtr)();
 	static const CommandPtr _commandList[42];
 	bool _cmd23Toggle;
+	int _commandParam;
 
 	int command9();
 	int command10();
@@ -394,11 +398,11 @@ private:
 	int command41();
 
 	void command111213();
-	void command2627293032();
+	int command2627293032();
 public:
 	ASound1(Audio::Mixer *mixer);
 
-	virtual int command(int commandId);
+	virtual int command(int commandId, int param = 0);
 };
 
 } // End of namespace Nebular


Commit: 7020dbea6a56e41dc199257e898240451bb5bfb1
    https://github.com/scummvm/scummvm/commit/7020dbea6a56e41dc199257e898240451bb5bfb1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-21T21:03:15-05:00

Commit Message:
MADS: Fixes for the HagArchive reading resources

Changed paths:
    engines/mads/resources.cpp



diff --git a/engines/mads/resources.cpp b/engines/mads/resources.cpp
index 0630230..ac46df9 100644
--- a/engines/mads/resources.cpp
+++ b/engines/mads/resources.cpp
@@ -22,7 +22,6 @@
 
 #include "common/scummsys.h"
 #include "common/archive.h"
-#include "common/substream.h"
 #include "common/textconsole.h"
 #include "mads/mads.h"
 #include "mads/resources.h"
@@ -155,9 +154,9 @@ Common::SeekableReadStream *HagArchive::createReadStreamForMember(const Common::
 		if (!f.open(hagIndex._filename))
 			error("Could not open HAG file");
 
-		// Return a substream for the specific resource
-		return new Common::SeekableSubReadStream(&f, 
-			hagEntry._offset, hagEntry._size, DisposeAfterUse::YES);
+		// Return a new stream for the specific resource
+		f.seek(hagEntry._offset);
+		return f.readStream(hagEntry._size);
 	}
 
 	return nullptr;
@@ -182,6 +181,8 @@ void HagArchive::loadIndex() {
 		int numEntries = hagFile.readUint16LE();
 
 		HagIndex hagIndex;
+		hagIndex._filename = filename;
+
 		for (int idx = 0; idx < numEntries; ++idx) {
 			// Read in the details of the next resource
 			char resourceBuffer[14];


Commit: 40b3ab62ca8a16c2fd06bfcc691967c4f510d52a
    https://github.com/scummvm/scummvm/commit/40b3ab62ca8a16c2fd06bfcc691967c4f510d52a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-21T21:03:44-05:00

Commit Message:
MADS: Fixes for reading in HOGANUS entries

Changed paths:
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/dialogs_nebular.h
    engines/mads/nebular/game_nebular.cpp



diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 5aede49..cd7ab86 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -31,6 +31,45 @@ namespace MADS {
 
 namespace Nebular {
 
+bool CopyProtectionDialog::show(MADSEngine *vm) {
+	CopyProtectionDialog *dlg = new CopyProtectionDialog(vm);
+
+	delete dlg;
+	return true;
+}
+
+CopyProtectionDialog::CopyProtectionDialog(MADSEngine *vm): _vm(vm) {
+	getHogAnusEntry(_hogEntry);
+}
+
+bool CopyProtectionDialog::getHogAnusEntry(HOGANUS &entry) {
+	File f;
+	f.open("*HOGANUS.DAT");
+
+	// Read in the total number of entries, and randomly pick an entry to use
+	int numEntries = f.readUint16LE();
+	int entryIndex = _vm->getRandomNumber(numEntries - 2) + 1;
+
+	// Read in the encrypted entry
+	f.seek(28 * entryIndex + 2);
+	byte entryData[28];
+	f.read(entryData, 28);
+
+	// Decrypt it
+	for (int i = 0; i < 28; ++i)
+		entryData[i] = ~entryData[i];
+
+	// Fill out the fields
+	entry._bookId = entryData[0];
+	entry._pageNum = READ_LE_UINT16(&entryData[2]);
+	entry._lineNum = READ_LE_UINT16(&entryData[4]);
+	entry._wordNum = READ_LE_UINT16(&entryData[6]);
+	entry._word = Common::String((char *)&entryData[8]);
+
+	f.close();
+	return true;
+}
+
 
 } // End of namespace Nebular
 
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index a747f75..6417c2c 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -20,8 +20,8 @@
  *
  */
 
-#ifndef MADS_GAME_NEBULAR_H
-#define MADS_GAME_NEBULAR_H
+#ifndef MADS_DIALOGS_NEBULAR_H
+#define MADS_DIALOGS_NEBULAR_H
 
 #include "common/scummsys.h"
 #include "mads/game.h"
@@ -30,15 +30,37 @@ namespace MADS {
 
 namespace Nebular {
 
+struct HOGANUS {
+	int _bookId;
+	int _pageNum;
+	int _lineNum;
+	int _wordNum;
+	Common::String _word;
+};
+
 class CopyProtectionDialog {
 private:
+	MADSEngine *_vm;
+	HOGANUS _hogEntry;
+
+	/**
+	 * Constructor
+	 */
+	CopyProtectionDialog(MADSEngine *vm);
 
+	/**
+	 * Get a random copy protection entry from the HOGANUS resource
+	 */
+	bool getHogAnusEntry(HOGANUS &entry);
 public:
-	static bool show() { return false; }
+	/**
+	 * Show the dialog
+	 */
+	static bool show(MADSEngine *vm);
 };
 
 } // End of namespace Nebular
 
 } // End of namespace MADS
 
-#endif /* MADS_GAME_NEBULAR_H */
+#endif /* MADS_DIALOGS_NEBULAR_H */
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 43d705f..10c210c 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -27,6 +27,7 @@
 #include "mads/graphics.h"
 #include "mads/msurface.h"
 #include "mads/nebular/game_nebular.h"
+#include "mads/nebular/dialogs_nebular.h"
 
 namespace MADS {
 
@@ -37,10 +38,10 @@ GameNebular::GameNebular(MADSEngine *vm): Game(vm) {
 }
 
 bool GameNebular::checkCopyProtection() {
-	if (!ConfMan.getBool("copy_protection") || (ConfMan.hasKey("passed_protection") &&
-			ConfMan.getInt("passed_protection") == 1))
+	if (!ConfMan.getBool("copy_protection"))
 		return true;
 
+	CopyProtectionDialog::show(_vm);
 	return false;
 }
 


Commit: 9f1416c6a358eb1dc860ff1176ae89721d82fc50
    https://github.com/scummvm/scummvm/commit/9f1416c6a358eb1dc860ff1176ae89721d82fc50
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-22T00:24:39-05:00

Commit Message:
MADS: Implemented constructor for copy protection dialog, and support methods

Changed paths:
    engines/mads/font.cpp
    engines/mads/font.h
    engines/mads/mads.cpp
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/dialogs_nebular.h
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/font.cpp b/engines/mads/font.cpp
index 076eca9..5254150 100644
--- a/engines/mads/font.cpp
+++ b/engines/mads/font.cpp
@@ -28,14 +28,6 @@
 
 namespace MADS {
 
-Font *Font::init(MADSEngine *vm) {
-	if (vm->getGameFeatures() & GF_MADS) {
-		return new FontMADS(vm);
-	} else {
-		return new FontM4(vm);
-	}
-}
-
 Font::Font(MADSEngine *vm) : _vm(vm) {
 	_sysFont = true;
 	
@@ -53,6 +45,43 @@ Font::~Font() {
 	}
 }
 
+void Font::setFont(const Common::String &filename) {
+	if (!_filename.empty() && (filename == _filename))
+		// Already using specified font, so don't bother reloading
+		return;
+
+	_sysFont = false;
+	_filename = filename;
+
+	MadsPack fontData(filename, _vm);
+	Common::SeekableReadStream *fontFile = fontData.getItemStream(0);
+
+	_maxHeight = fontFile->readByte();
+	_maxWidth = fontFile->readByte();
+
+	_charWidths = new uint8[128];
+	// Char data is shifted by 1
+	_charWidths[0] = 0;
+	fontFile->read(_charWidths + 1, 127);
+	fontFile->readByte();	// remainder
+
+	_charOffs = new uint16[128];
+
+	uint startOffs = 2 + 128 + 256;
+	uint fontSize = fontFile->size() - startOffs;
+
+	// Char data is shifted by 1
+	_charOffs[0] = 0;
+	for (int i = 1; i < 128; i++)
+		_charOffs[i] = fontFile->readUint16LE() - startOffs;
+	fontFile->readUint16LE();	// remainder
+
+	_charData = new uint8[fontSize];
+	fontFile->read(_charData, fontSize);
+
+	delete fontFile;
+}
+
 void Font::setColor(uint8 color) {
 	if (_sysFont)
 		_fontColors[1] = color;
@@ -60,14 +89,11 @@ void Font::setColor(uint8 color) {
 		_fontColors[3] = color;		
 }
 
-void Font::setColors(uint8 alt1, uint8 alt2, uint8 foreground) {
-	if (_sysFont)
-		_fontColors[1] = foreground;
-	else {
-		_fontColors[1] = alt1;
-		_fontColors[2] = alt2;
-		_fontColors[3] = foreground;
-	}
+void Font::setColors(uint8 v1, uint8 v2, uint8 v3, uint8 v4) {
+	_fontColors[0] = v1;
+	_fontColors[1] = v2;
+	_fontColors[2] = v3;
+	_fontColors[3] = v4;
 }
 
 int Font::write(MSurface *surface, const Common::String &msg, const Common::Point &pt, int width, int spaceWidth, uint8 colors[]) {
@@ -160,11 +186,6 @@ int Font::write(MSurface *surface, const Common::String &msg, const Common::Poin
 }
 
 int Font::getWidth(const Common::String &msg, int spaceWidth) {
-	/*
-	if (custom_ascii_converter) {			 // if there is a function to convert the extended ASCII characters
-		custom_ascii_converter(out_string);	 // call it with the string
-	}
-	*/
 	int width = 0;
 	const char *text = msg.c_str();
 
@@ -173,46 +194,7 @@ int Font::getWidth(const Common::String &msg, int spaceWidth) {
 	return width;
 }
 
-/*------------------------------------------------------------------------*/
-
-void FontMADS::setFont(const Common::String &filename) {
-	if (!_filename.empty() && (filename == _filename))
-		// Already using specified font, so don't bother reloading
-		return;
-
-	_sysFont = false;
-	_filename = filename;
-
-	MadsPack fontData(filename, _vm);
-	Common::SeekableReadStream *fontFile = fontData.getItemStream(0);
-
-	_maxHeight = fontFile->readByte();
-	_maxWidth = fontFile->readByte();
-
-	_charWidths = new uint8[128];
-	// Char data is shifted by 1
-	_charWidths[0] = 0;
-	fontFile->read(_charWidths + 1, 127);
-	fontFile->readByte();	// remainder
-
-	_charOffs = new uint16[128];
-
-	uint startOffs = 2 + 128 + 256;
-	uint fontSize = fontFile->size() - startOffs;
-
-	// Char data is shifted by 1
-	_charOffs[0] = 0;
-	for (int i = 1; i < 128; i++)
-		_charOffs[i] = fontFile->readUint16LE() - startOffs;
-	fontFile->readUint16LE();	// remainder
-
-	_charData = new uint8[fontSize];
-	fontFile->read(_charData, fontSize);
-
-	delete fontFile;
-}
-
-int FontMADS::getBpp(int charWidth) {
+int Font::getBpp(int charWidth) {
 	if (charWidth > 12)
 		return 4;
 	else if (charWidth > 8)
@@ -223,60 +205,4 @@ int FontMADS::getBpp(int charWidth) {
 		return 1;
 }
 
-/*------------------------------------------------------------------------*/
-
-void FontM4::setFont(const Common::String &filename) {
-	if (!_filename.empty() && (filename == _filename))
-		// Already using specified font, so don't bother reloading
-		return;
-
-	_sysFont = false;
-	_filename = filename;
-
-	Common::SeekableReadStream *fontFile = nullptr; //_vm->_resources->openFile(filename);
-	
-	if (fontFile->readUint32LE() != MKTAG('F', 'O', 'N', 'T')) {
-		warning("Font: FONT tag expected");
-		return;
-	}
-
-	_maxHeight = fontFile->readByte();
-	_maxWidth = fontFile->readByte();
-	uint fontSize = fontFile->readUint32LE();
-	
-	//printf("Font::Font: _maxWidth = %d, _maxHeight = %d, fontSize = %d\n", _maxWidth, _maxHeight, fontSize);
-
-	if (fontFile->readUint32LE() != MKTAG('W', 'I', 'D', 'T')) {
-		warning("Font: WIDT tag expected");
-		return;
-	}
-
-	_charWidths = new uint8[256];
-	fontFile->read(_charWidths, 256);
-
-	if (fontFile->readUint32LE() != MKTAG('O', 'F', 'F', 'S')) {
-		warning("Font: OFFS tag expected\n");
-		return;
-	}
-
-	_charOffs = new uint16[256];
-
-	for (int i = 0; i < 256; i++)
-		_charOffs[i] = fontFile->readUint16LE();
-
-	if (fontFile->readUint32LE() != MKTAG('P', 'I', 'X', 'S')) {
-		warning("Font: PIXS tag expected\n");
-		return;
-	}
-
-	_charData = new uint8[fontSize];
-	fontFile->read(_charData, fontSize);
-
-//	_vm->_resources->toss(filename);
-}
-
-int FontM4::getBpp(int charWidth) {
-	return charWidth / 4 + 1;
-}
-
 } // End of namespace MADS
diff --git a/engines/mads/font.h b/engines/mads/font.h
index d36be80..3f01260 100644
--- a/engines/mads/font.h
+++ b/engines/mads/font.h
@@ -62,19 +62,16 @@ protected:
 	Common::String _filename;
 	uint8 _fontColors[4];
 
-protected:
-	Font(MADSEngine *vm);
-
-	virtual void setFont(const Common::String &filename) = 0;
-	virtual int getBpp(int charWidth) = 0;
-public:
-	static Font *init(MADSEngine *vm);
+	int getBpp(int charWidth);
 public:
+	Font(MADSEngine *vm);
 	virtual ~Font();
 
+	void setFont(const Common::String &filename);
 	void setColor(uint8 color);
-	void setColors(uint8 alt1, uint8 alt2, uint8 foreground);
+	void setColors(uint8 v1, uint8 v2, uint8 v3, uint8 v4);
 
+	int maxWidth() const { return _maxWidth; }
 	int getWidth(const Common::String &msg, int spaceWidth = -1);
 	int getHeight() const { return _maxHeight; }
 	int write(MSurface *surface, const Common::String &msg, const Common::Point &pt, int width, int spaceWidth, uint8 colors[]);
@@ -83,24 +80,6 @@ public:
 	}
 };
 
-class FontMADS: public Font {
-	friend class Font;
-protected:
-	virtual void setFont(const Common::String &filename);
-	virtual int getBpp(int charWidth);
-
-	FontMADS(MADSEngine *vm): Font(vm) {}
-};
-
-class FontM4: public Font {
-	friend class Font;
-protected:
-	virtual void setFont(const Common::String &filename);
-	virtual int getBpp(int charWidth);
-
-	FontM4(MADSEngine *vm): Font(vm) {}
-};
-
 } // End of namespace MADS
 
 #endif /* MADS_FONT_H */
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index ec99b31..827c62a 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -74,8 +74,8 @@ void MADSEngine::initialise() {
 
 	ResourcesManager::init(this);
 	_events = new EventsManager(this);
-	_palette = Palette::init(this);
-	_font = Font::init(this);
+	_palette = new Palette(this);
+	_font = new Font(this);
 	_screen = MSurface::init(true);
 	_sound = new SoundManager(this, _mixer);
 	_userInterface = UserInterface::init(this);
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index cd7ab86..85b06ce 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -31,15 +31,178 @@ namespace MADS {
 
 namespace Nebular {
 
+TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName, 
+		const Common::Point &pos, int maxChars) {
+	_vm = vm;
+	_fontName = fontName;
+	_position = pos;
+	
+	_vm->_font->setFont(FONT_INTERFACE);
+	_vm->_font->setColors(TEXTDIALOG_FONT, TEXTDIALOG_FONT, TEXTDIALOG_FONT, TEXTDIALOG_FONT);
+
+	_innerWidth = (_vm->_font->maxWidth() + 1) * maxChars;
+	_width = _innerWidth + 10;
+	_lineSize = maxChars * 2;
+	_lineWidth = 0;
+	_currentX = 0;
+	_numLines = 0;
+	Common::fill(&_lineXp[0], &_lineXp[TEXT_DIALOG_MAX_LINES], 0);
+	
+	Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_F8 * 3], 
+		&_vm->_palette->_mainPalette[TEXTDIALOG_F8 * 3 + 8 * 3], 
+		&_savedPalette[0]);
+	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_F8, 2, 0x24, 0x20);
+	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FA, 2, 0x27, 0x1C);
+	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FC, 2, 0x24, 0x20);
+	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FE, 1, 0x37, 0x37);
+
+	_vm->_palette->setPalette(_vm->_palette->_mainPalette + (TEXTDIALOG_F8 * 3),
+		TEXTDIALOG_F8, 8);
+}
+
+TextDialog::~TextDialog() {
+}
+
+void TextDialog::addLine(const Common::String &line, bool underline) {
+	if (_lineWidth > 0 || _currentX > 0)
+		incNumLines();
+
+	int stringWidth = _vm->_font->getWidth(line);
+	if (stringWidth >= _innerWidth || (int)line.size() >= _lineSize) {
+		wordWrap(line);
+	} else {
+		_lineXp[_numLines] = (_innerWidth / 2) - (stringWidth / 2);
+		_lines[_numLines] = line;
+
+		if (underline)
+			underlineLine();
+	}
+
+	incNumLines();
+}
+
+void TextDialog::underlineLine() {
+	_lineXp[_numLines] |= 0x80;
+}
+
+void TextDialog::incNumLines() {
+	_lineWidth = 0;
+	_currentX = 0;
+	if (++_numLines == TEXT_DIALOG_MAX_LINES)
+		error("Exceeded text dialog line max");
+}
+
+void TextDialog::wordWrap(const Common::String &line) {
+	Common::String tempLine;
+
+	if (!line.empty()) {
+		const char *srcP = line.c_str();
+		
+		do {
+			tempLine = "";
+			bool endWord = false;
+			bool newLine = false;
+			bool continueFlag = true;
+
+			do {
+				if (!*srcP) {
+					continueFlag = false;
+				} else {
+					tempLine += *srcP;
+
+					if (*srcP == 10) {
+						continueFlag = false;
+						newLine = true;
+						++srcP;
+						tempLine.deleteLastChar();
+					} else if (*srcP == ' ') {
+						++srcP;
+						endWord = true;
+					} else if (!endWord) {
+						++srcP;
+					} else {
+						tempLine.deleteLastChar();
+						continueFlag = false;
+					}
+				}
+			} while (continueFlag);
+
+			if (tempLine.hasSuffix(" "))
+				tempLine.deleteLastChar();
+
+			Common::String tempLine2;
+			if (_currentX > 0)
+				tempLine2 += ' ';
+			tempLine2 += tempLine;
+
+			int lineWidth = _vm->_font->getWidth(tempLine2, 1);
+			if (((_currentX + (int)tempLine2.size()) > _lineSize) ||
+					((_lineWidth + lineWidth) > _innerWidth)) {
+				incNumLines();
+				appendLine(tempLine);
+			} else {
+				appendLine(tempLine2);
+			}
+
+			if (newLine)
+				incNumLines();
+		} while (*srcP);
+	}
+}
+
+void TextDialog::appendLine(const Common::String &line) {
+	_currentX += line.size();
+	_lineWidth += _vm->_font->getWidth(line, 1);
+	_lines[_numLines] += line;
+}
+
+/*------------------------------------------------------------------------*/
+
 bool CopyProtectionDialog::show(MADSEngine *vm) {
-	CopyProtectionDialog *dlg = new CopyProtectionDialog(vm);
+	CopyProtectionDialog *dlg = new CopyProtectionDialog(vm, false);
 
 	delete dlg;
 	return true;
 }
 
-CopyProtectionDialog::CopyProtectionDialog(MADSEngine *vm): _vm(vm) {
+CopyProtectionDialog::CopyProtectionDialog(MADSEngine *vm, bool priorAnswerWrong):
+		TextDialog(vm, FONT_INTERFACE_MADS, Common::Point(-1, -1), 32) {
 	getHogAnusEntry(_hogEntry);
+
+	if (priorAnswerWrong) {
+		addLine("ANSWER INCORRECT!", true);
+		wordWrap("\n");
+		addLine("(But we'll give you another chance!)");
+	} else {
+		addLine("REX NEBULAR version 8.43", true);
+		wordWrap("\n");
+		addLine("(Copy Protection, for your convenience)");
+	}
+	wordWrap("\n");
+
+	wordWrap("Now comes the part that everybody hates.  But if we don't");
+	wordWrap("do this, nasty rodent-like people will pirate this game");
+	wordWrap("and a whole generation of talented designers, programmers,");
+	wordWrap("artists, and playtesters will go hungry, and will wander");
+	wordWrap("aimlessly through the land at night searching for peace.");
+	wordWrap("So let's grit our teeth and get it over with.  Just get");
+	
+	Common::String line = "out your copy of ";
+	line += _hogEntry._bookId == 103 ? "the GAME MANUAL" : "REX'S LOGBOOK";
+	line += ".  See!  That was easy.  ";
+	wordWrap(line);
+
+	line = Common::String::format("Next, just turn to page %d. On line %d, find word number %d, ",
+		_hogEntry._pageNum, _hogEntry._lineNum, _hogEntry._wordNum);
+	wordWrap(line);
+
+	wordWrap("and type it on the line below (we',27h,'ve even given you");
+	wordWrap("first letter as a hint).  As soon as you do that, we can get");
+	wordWrap("right into this really COOL adventure game!\n");
+	wordWrap("\n");
+	wordWrap("                    ");
+	wordWrap("\n");
+
 }
 
 bool CopyProtectionDialog::getHogAnusEntry(HOGANUS &entry) {
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index 6417c2c..3e28ee3 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -30,6 +30,76 @@ namespace MADS {
 
 namespace Nebular {
 
+enum {
+	TEXTDIALOG_F8 = 0XF8,
+	TEXTDIALOG_F9 = 0XF8,
+	TEXTDIALOG_FA = 0XF8,
+	TEXTDIALOG_FB = 0XF8,
+	TEXTDIALOG_FC = 0XF8,
+	TEXTDIALOG_FD = 0XF8,
+	TEXTDIALOG_FE = 0XF8,
+	TEXTDIALOG_FONT = 0
+};
+
+#define TEXT_DIALOG_MAX_LINES 20
+
+class TextDialog {
+private:
+	/**
+	 * Increments the number of text lines the text dialog uses
+	 */
+	void incNumLines();
+
+	/**
+	 * Flags the previously added line to be underlined
+	 */
+	void underlineLine();
+
+	/**
+	 * Append text to the currently end line.
+	 */
+	void appendLine(const Common::String &line);
+protected:
+	MADSEngine *_vm;
+	Common::Point _position;
+	Common::String _fontName;
+	int _width;
+	int _innerWidth;
+	int _lineWidth;
+	int _currentX;
+	int _numLines;
+	int _lineSize;
+	Common::String _lines[TEXT_DIALOG_MAX_LINES];
+	int _lineXp[TEXT_DIALOG_MAX_LINES];
+	byte _savedPalette[8 * 3];
+
+	/**
+	 * Add a new line to the dialog
+	 */
+	void addLine(const Common::String &line, bool underline = false);
+
+	/**
+	 * Adds one or more lines, word wrapping the passed text
+	 */
+	void wordWrap(const Common::String &line);
+public:
+	/**
+	 * Constructor
+	 * @param vm			Engine reference
+	 * @param fontName		Font to use for display
+	 * @param pos			Position for window top-left
+	 * @param maxChars		Horizontal width of window in characters
+	 */
+	TextDialog(MADSEngine *vm, const Common::String &fontName, const Common::Point &pos, 
+		int maxChars);
+
+	/**
+	 * Destructor
+	 */
+	~TextDialog();
+
+};
+
 struct HOGANUS {
 	int _bookId;
 	int _pageNum;
@@ -38,15 +108,14 @@ struct HOGANUS {
 	Common::String _word;
 };
 
-class CopyProtectionDialog {
+class CopyProtectionDialog: public TextDialog {
 private:
-	MADSEngine *_vm;
 	HOGANUS _hogEntry;
 
 	/**
 	 * Constructor
 	 */
-	CopyProtectionDialog(MADSEngine *vm);
+	CopyProtectionDialog(MADSEngine *vm, bool priorAnswerWrong);
 
 	/**
 	 * Get a random copy protection entry from the HOGANUS resource
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 6a5d507..c858984 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -54,18 +54,11 @@ RGBList::~RGBList() {
 
 #define VGA_COLOR_TRANS(x) (x == 0x3f ? 255 : x << 2)
 
-Palette *Palette::init(MADSEngine *vm) {
-	if (vm->getGameFeatures() & GF_MADS) {
-		return new PaletteMADS(vm);
-	} else {
-		return new PaletteM4(vm);
-	}
-}
-
 Palette::Palette(MADSEngine *vm) : _vm(vm) {
 	reset();
 	_fading_in_progress = false;
 	Common::fill(&_usageCount[0], &_usageCount[PALETTE_COUNT], 0);
+	Common::fill(&_mainPalette[0], &_mainPalette[PALETTE_SIZE], 0);
 }
 
 void Palette::setPalette(const byte *colors, uint start, uint num) {
@@ -245,9 +238,35 @@ void Palette::fadeRange(byte *srcPal, byte *destPal,  int startIndex, int endInd
 	_vm->_palette->setPalette(&destPal[startIndex * 3], startIndex, endIndex - startIndex + 1);
 }
 
-/*------------------------------------------------------------------------*/
+void Palette::setGradient(byte *palette, int start, int count, int rgbValue1, int rgbValue2) {
+	int rgbCtr = 0;
+	int rgbDiff = -(rgbValue2 - rgbValue1);
+	int rgbCurrent = rgbValue2;
+
+	if (count >  0) {
+		byte *pDest = palette + start * 3;
+		int endVal = count - 1;
+		int numLeft = count;
+
+		do {
+			pDest[0] = pDest[1] = pDest[2] = rgbCurrent;
+
+			if (count > 1) {
+				rgbCtr += rgbDiff;
+				if (rgbCtr >= endVal) {
+					do {
+						++rgbCurrent;
+						rgbCtr += 1 - numLeft;
+					} while (rgbCtr >= endVal);
+				}
+			}
+
+			pDest += 3;
+		} while (--numLeft > 0);
+	}
+}
 
-byte *PaletteMADS::decodePalette(Common::SeekableReadStream *palStream, int *numColors) {
+byte *Palette::decodePalette(Common::SeekableReadStream *palStream, int *numColors) {
 	*numColors = palStream->readUint16LE();
 	assert(*numColors <= 252);
 
@@ -269,7 +288,7 @@ byte *PaletteMADS::decodePalette(Common::SeekableReadStream *palStream, int *num
 	return palData;
 }
 
-int PaletteMADS::loadPalette(Common::SeekableReadStream *palStream, int indexStart) {
+int Palette::loadPalette(Common::SeekableReadStream *palStream, int indexStart) {
 	int colorCount;
 	byte *palData = decodePalette(palStream, &colorCount);
 	_vm->_palette->setPalette(palData, indexStart, colorCount);
@@ -278,7 +297,7 @@ int PaletteMADS::loadPalette(Common::SeekableReadStream *palStream, int indexSta
 	return colorCount;
 }
 
-void PaletteMADS::setSystemPalette() {
+void Palette::setSystemPalette() {
 	resetColorCounts();
 
 	byte palData[4 * 3];
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index a97d5de..0ef8693 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -84,13 +84,14 @@ protected:
 	byte _fadedPalette[PALETTE_COUNT * 4];
 	int _usageCount[PALETTE_COUNT];
 
-	Palette(MADSEngine *vm);
 	void reset();
 public:
+	byte _mainPalette[PALETTE_SIZE];
+public:
 	/**
-	 * Creates a new palette instance
+	 * Constructor
 	 */
-	static Palette *init(MADSEngine *vm);
+	Palette(MADSEngine *vm);
 	
 	/**
 	 * Destructor
@@ -153,17 +154,22 @@ public:
 	/**
 	 * Decode a palette and return it, without affecting the Palette itself
 	 */
-	virtual byte *decodePalette(Common::SeekableReadStream *palStream, int *numColors) = 0;
+	byte *decodePalette(Common::SeekableReadStream *palStream, int *numColors);
 
 	/**
 	 * Loads a palette from a stream
 	 */
-	virtual int loadPalette(Common::SeekableReadStream *palStream, int indexStart = 0) = 0;
+	int loadPalette(Common::SeekableReadStream *palStream, int indexStart = 0);
 
 	/**
 	 * Sets a small set of system/core colors needed by the game
 	 */
-	virtual void setSystemPalette() = 0;
+	void setSystemPalette();
+
+	/**
+	 * Update a range of an arbitrary palette
+	 */
+	static void setGradient(byte *palette, int start, int count, int rgbValue1, int rgbValue2);
 
 	// Color indexes
 	uint8 BLACK;
@@ -184,30 +190,6 @@ public:
 	uint8 WHITE;
 };
 
-class PaletteMADS: protected Palette {
-	friend class Palette;
-protected:
-	PaletteMADS(MADSEngine *vm): Palette(vm) {}
-public:
-	virtual byte *decodePalette(Common::SeekableReadStream *palStream, int *numColors);
-	virtual int loadPalette(Common::SeekableReadStream *palStream, int indexStart = 0);
-	virtual void setSystemPalette();
-};
-
-class PaletteM4: protected Palette {
-	friend class Palette;
-protected:
-	PaletteM4(MADSEngine *vm): Palette(vm) {}
-public:
-	virtual byte *decodePalette(Common::SeekableReadStream *palStream, int *numColors) {
-		return nullptr;
-	}
-	virtual int loadPalette(Common::SeekableReadStream *palStream, int indexStart = 0) {
-		return 0;
-	}
-	virtual void setSystemPalette() {}
-};
-
 } // End of namespace MADS
 
 #endif /* MADS_PALETTE_H */


Commit: 54c4515232ec26397903373ed46e9492223ce2f2
    https://github.com/scummvm/scummvm/commit/54c4515232ec26397903373ed46e9492223ce2f2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-22T08:39:44-05:00

Commit Message:
MADS: Beginnings of dialog class hierarchy

Changed paths:
  A engines/mads/dialogs.cpp
  A engines/mads/dialogs.h
    engines/mads/font.h
    engines/mads/module.mk
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/dialogs_nebular.h



diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
new file mode 100644
index 0000000..4e64f08
--- /dev/null
+++ b/engines/mads/dialogs.cpp
@@ -0,0 +1,200 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "common/config-manager.h"
+#include "mads/mads.h"
+#include "mads/graphics.h"
+#include "mads/msurface.h"
+#include "mads/nebular/dialogs_nebular.h"
+
+namespace MADS {
+
+Dialog::Dialog(MADSEngine *vm): _vm(vm), _savedSurface(nullptr),
+		_position(Common::Point(-1, -1)), _width(0), _height(0) {
+}
+
+Dialog::~Dialog() {
+	delete _savedSurface;
+}
+
+
+void Dialog::save(MSurface *s) {
+	_savedSurface = MSurface::init(_width, _height);
+	s->copyTo(_savedSurface, 
+		Common::Rect(_position.x, _position.y, _position.x + _width, _position.y + _height),
+		Common::Point());
+}
+
+void Dialog::restore(MSurface *s) {
+	_savedSurface->copyTo(s, _position);
+	delete _savedSurface;
+	_savedSurface = nullptr;
+}
+
+/*------------------------------------------------------------------------*/
+
+TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName, 
+		const Common::Point &pos, int maxChars):
+		Dialog(vm) {
+	_vm = vm;
+	_fontName = fontName;
+	_position = pos;
+	
+	_vm->_font->setFont(FONT_INTERFACE);
+	_vm->_font->setColors(TEXTDIALOG_FONT, TEXTDIALOG_FONT, TEXTDIALOG_FONT, TEXTDIALOG_FONT);
+
+	_innerWidth = (_vm->_font->maxWidth() + 1) * maxChars;
+	_width = _innerWidth + 10;
+	_lineSize = maxChars * 2;
+	_lineWidth = 0;
+	_currentX = 0;
+	_numLines = 0;
+	Common::fill(&_lineXp[0], &_lineXp[TEXT_DIALOG_MAX_LINES], 0);
+	
+	Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_F8 * 3], 
+		&_vm->_palette->_mainPalette[TEXTDIALOG_F8 * 3 + 8 * 3], 
+		&_savedPalette[0]);
+	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_F8, 2, 0x24, 0x20);
+	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FA, 2, 0x27, 0x1C);
+	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FC, 2, 0x24, 0x20);
+	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FE, 1, 0x37, 0x37);
+
+	_vm->_palette->setPalette(_vm->_palette->_mainPalette + (TEXTDIALOG_F8 * 3),
+		TEXTDIALOG_F8, 8);
+}
+
+TextDialog::~TextDialog() {
+}
+
+void TextDialog::addLine(const Common::String &line, bool underline) {
+	if (_lineWidth > 0 || _currentX > 0)
+		incNumLines();
+
+	int stringWidth = _vm->_font->getWidth(line);
+	if (stringWidth >= _innerWidth || (int)line.size() >= _lineSize) {
+		wordWrap(line);
+	} else {
+		_lineXp[_numLines] = (_innerWidth / 2) - (stringWidth / 2);
+		_lines[_numLines] = line;
+
+		if (underline)
+			underlineLine();
+	}
+
+	incNumLines();
+}
+
+void TextDialog::underlineLine() {
+	_lineXp[_numLines] |= 0x80;
+}
+
+void TextDialog::incNumLines() {
+	_lineWidth = 0;
+	_currentX = 0;
+	if (++_numLines == TEXT_DIALOG_MAX_LINES)
+		error("Exceeded text dialog line max");
+}
+
+void TextDialog::wordWrap(const Common::String &line) {
+	Common::String tempLine;
+
+	if (!line.empty()) {
+		const char *srcP = line.c_str();
+		
+		do {
+			tempLine = "";
+			bool endWord = false;
+			bool newLine = false;
+			bool continueFlag = true;
+
+			do {
+				if (!*srcP) {
+					continueFlag = false;
+				} else {
+					tempLine += *srcP;
+
+					if (*srcP == 10) {
+						continueFlag = false;
+						newLine = true;
+						++srcP;
+						tempLine.deleteLastChar();
+					} else if (*srcP == ' ') {
+						++srcP;
+						endWord = true;
+					} else if (!endWord) {
+						++srcP;
+					} else {
+						tempLine.deleteLastChar();
+						continueFlag = false;
+					}
+				}
+			} while (continueFlag);
+
+			if (tempLine.hasSuffix(" "))
+				tempLine.deleteLastChar();
+
+			Common::String tempLine2;
+			if (_currentX > 0)
+				tempLine2 += ' ';
+			tempLine2 += tempLine;
+
+			int lineWidth = _vm->_font->getWidth(tempLine2, 1);
+			if (((_currentX + (int)tempLine2.size()) > _lineSize) ||
+					((_lineWidth + lineWidth) > _innerWidth)) {
+				incNumLines();
+				appendLine(tempLine);
+			} else {
+				appendLine(tempLine2);
+			}
+
+			if (newLine)
+				incNumLines();
+		} while (*srcP);
+	}
+}
+
+void TextDialog::appendLine(const Common::String &line) {
+	_currentX += line.size();
+	_lineWidth += _vm->_font->getWidth(line, 1);
+	_lines[_numLines] += line;
+}
+
+/*------------------------------------------------------------------------*/
+
+MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...): 
+		TextDialog(vm, FONT_INTERFACE, Common::Point(-1, -1), maxChars) {
+	// Add in passed line list
+	va_list va;
+	va_start(va, maxChars);
+
+	const char *line = va_arg(va, const char *);
+	while (line) {
+		addLine(line);
+		line = va_arg(va, const char *);
+	}
+	va_end(va);
+
+	// TODO
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
new file mode 100644
index 0000000..03710b6
--- /dev/null
+++ b/engines/mads/dialogs.h
@@ -0,0 +1,137 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_DIALOGS_H
+#define MADS_DIALOGS_H
+
+#include "common/scummsys.h"
+#include "mads/game.h"
+#include "mads/msurface.h"
+
+namespace MADS {
+
+class Dialog {
+protected:
+	MADSEngine *_vm;
+	MSurface *_savedSurface;
+	Common::Point _position;
+	int _width;
+	int _height;
+
+	/**
+	 * Save the section of the passed surface the dialog will cover.
+	 * @param s		Screen surface to save
+	 */
+	void save(MSurface *s);
+
+	/**
+	 * Restore saved dialog surface
+	 * @param s		Screen surface to restore to.
+	 */
+	void restore(MSurface *s);
+public:
+	/**
+	 * Constructor
+	 */
+	Dialog(MADSEngine *vm);
+
+	/**
+	 * Destructor
+	 */
+	~Dialog();
+};
+
+enum {
+	TEXTDIALOG_F8 = 0XF8,
+	TEXTDIALOG_F9 = 0XF8,
+	TEXTDIALOG_FA = 0XF8,
+	TEXTDIALOG_FB = 0XF8,
+	TEXTDIALOG_FC = 0XF8,
+	TEXTDIALOG_FD = 0XF8,
+	TEXTDIALOG_FE = 0XF8,
+	TEXTDIALOG_FONT = 0
+};
+
+#define TEXT_DIALOG_MAX_LINES 20
+
+class TextDialog: protected Dialog {
+private:
+	/**
+	 * Increments the number of text lines the text dialog uses
+	 */
+	void incNumLines();
+
+	/**
+	 * Flags the previously added line to be underlined
+	 */
+	void underlineLine();
+
+	/**
+	 * Append text to the currently end line.
+	 */
+	void appendLine(const Common::String &line);
+protected:
+	Common::String _fontName;
+	int _innerWidth;
+	int _lineWidth;
+	int _currentX;
+	int _numLines;
+	int _lineSize;
+	Common::String _lines[TEXT_DIALOG_MAX_LINES];
+	int _lineXp[TEXT_DIALOG_MAX_LINES];
+	byte _savedPalette[8 * 3];
+
+	/**
+	 * Add a new line to the dialog
+	 */
+	void addLine(const Common::String &line, bool underline = false);
+
+	/**
+	 * Adds one or more lines, word wrapping the passed text
+	 */
+	void wordWrap(const Common::String &line);
+public:
+	/**
+	 * Constructor
+	 * @param vm			Engine reference
+	 * @param fontName		Font to use for display
+	 * @param pos			Position for window top-left
+	 * @param maxChars		Horizontal width of window in characters
+	 */
+	TextDialog(MADSEngine *vm, const Common::String &fontName, const Common::Point &pos, 
+		int maxChars);
+
+	/**
+	 * Destructor
+	 */
+	~TextDialog();
+
+};
+
+class MessageDialog: protected TextDialog {
+public:
+	MessageDialog(MADSEngine *vm, int lines, ...);
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_DIALOGS_H */
diff --git a/engines/mads/font.h b/engines/mads/font.h
index 3f01260..e042768 100644
--- a/engines/mads/font.h
+++ b/engines/mads/font.h
@@ -30,23 +30,13 @@
 
 namespace MADS {
 
-#define FONT_MENU "fontmenu.fnt"
-#define FONT_INTERFACE "fontintr.fnt"
-#define FONT_TINY "small.fnt"
-#define FONT_SMALL "small.fnt"
-#define FONT_MEDIUM "medium.fnt"
-#define FONT_LINE "fontline.fnt"
-#define FONT_CONVERSATION "fontconv.fnt"
-#define FONT_4X6 "4x6pp.fnt"
-#define FONT_5X6 "5x6pp.fnt"
-
-#define FONT_CONVERSATION_MADS "fontconv.ff"
-#define FONT_INTERFACE_MADS "fontintr.ff"
-#define FONT_MAIN_MADS "fontmain.ff"
-#define FONT_MENU_MADS "fontmenu.ff"	// Not in Rex (uses bitmap files for menu strings)
-#define FONT_MISC_MADS "fontmisc.ff"
-#define FONT_TELE_MADS "fonttele.ff"	// Not in Phantom
-#define FONT_PHAN_MADS "fontphan.ff"	// Phantom only
+#define FONT_CONVERSATION "fontconv.ff"
+#define FONT_INTERFACE "fontintr.ff"
+#define FONT_MAIN "fontmain.ff"
+#define FONT_MENU "fontmenu.ff"	// Not in Rex (uses bitmap files for menu strings)
+#define FONT_MISC "fontmisc.ff"
+#define FONT_TELE "fonttele.ff"	// Not in Phantom
+#define FONT_PHAN "fontphan.ff"	// Phantom only
 
 class MADSEngine;
 
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 9d115b8..179c197 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS := \
 	nebular/sound_nebular.o \
 	compression.o \
 	detection.o \
+	dialogs.o \
 	events.o \
 	font.o \
 	game.o \
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 85b06ce..76b6162 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -31,133 +31,6 @@ namespace MADS {
 
 namespace Nebular {
 
-TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName, 
-		const Common::Point &pos, int maxChars) {
-	_vm = vm;
-	_fontName = fontName;
-	_position = pos;
-	
-	_vm->_font->setFont(FONT_INTERFACE);
-	_vm->_font->setColors(TEXTDIALOG_FONT, TEXTDIALOG_FONT, TEXTDIALOG_FONT, TEXTDIALOG_FONT);
-
-	_innerWidth = (_vm->_font->maxWidth() + 1) * maxChars;
-	_width = _innerWidth + 10;
-	_lineSize = maxChars * 2;
-	_lineWidth = 0;
-	_currentX = 0;
-	_numLines = 0;
-	Common::fill(&_lineXp[0], &_lineXp[TEXT_DIALOG_MAX_LINES], 0);
-	
-	Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_F8 * 3], 
-		&_vm->_palette->_mainPalette[TEXTDIALOG_F8 * 3 + 8 * 3], 
-		&_savedPalette[0]);
-	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_F8, 2, 0x24, 0x20);
-	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FA, 2, 0x27, 0x1C);
-	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FC, 2, 0x24, 0x20);
-	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FE, 1, 0x37, 0x37);
-
-	_vm->_palette->setPalette(_vm->_palette->_mainPalette + (TEXTDIALOG_F8 * 3),
-		TEXTDIALOG_F8, 8);
-}
-
-TextDialog::~TextDialog() {
-}
-
-void TextDialog::addLine(const Common::String &line, bool underline) {
-	if (_lineWidth > 0 || _currentX > 0)
-		incNumLines();
-
-	int stringWidth = _vm->_font->getWidth(line);
-	if (stringWidth >= _innerWidth || (int)line.size() >= _lineSize) {
-		wordWrap(line);
-	} else {
-		_lineXp[_numLines] = (_innerWidth / 2) - (stringWidth / 2);
-		_lines[_numLines] = line;
-
-		if (underline)
-			underlineLine();
-	}
-
-	incNumLines();
-}
-
-void TextDialog::underlineLine() {
-	_lineXp[_numLines] |= 0x80;
-}
-
-void TextDialog::incNumLines() {
-	_lineWidth = 0;
-	_currentX = 0;
-	if (++_numLines == TEXT_DIALOG_MAX_LINES)
-		error("Exceeded text dialog line max");
-}
-
-void TextDialog::wordWrap(const Common::String &line) {
-	Common::String tempLine;
-
-	if (!line.empty()) {
-		const char *srcP = line.c_str();
-		
-		do {
-			tempLine = "";
-			bool endWord = false;
-			bool newLine = false;
-			bool continueFlag = true;
-
-			do {
-				if (!*srcP) {
-					continueFlag = false;
-				} else {
-					tempLine += *srcP;
-
-					if (*srcP == 10) {
-						continueFlag = false;
-						newLine = true;
-						++srcP;
-						tempLine.deleteLastChar();
-					} else if (*srcP == ' ') {
-						++srcP;
-						endWord = true;
-					} else if (!endWord) {
-						++srcP;
-					} else {
-						tempLine.deleteLastChar();
-						continueFlag = false;
-					}
-				}
-			} while (continueFlag);
-
-			if (tempLine.hasSuffix(" "))
-				tempLine.deleteLastChar();
-
-			Common::String tempLine2;
-			if (_currentX > 0)
-				tempLine2 += ' ';
-			tempLine2 += tempLine;
-
-			int lineWidth = _vm->_font->getWidth(tempLine2, 1);
-			if (((_currentX + (int)tempLine2.size()) > _lineSize) ||
-					((_lineWidth + lineWidth) > _innerWidth)) {
-				incNumLines();
-				appendLine(tempLine);
-			} else {
-				appendLine(tempLine2);
-			}
-
-			if (newLine)
-				incNumLines();
-		} while (*srcP);
-	}
-}
-
-void TextDialog::appendLine(const Common::String &line) {
-	_currentX += line.size();
-	_lineWidth += _vm->_font->getWidth(line, 1);
-	_lines[_numLines] += line;
-}
-
-/*------------------------------------------------------------------------*/
-
 bool CopyProtectionDialog::show(MADSEngine *vm) {
 	CopyProtectionDialog *dlg = new CopyProtectionDialog(vm, false);
 
@@ -166,7 +39,7 @@ bool CopyProtectionDialog::show(MADSEngine *vm) {
 }
 
 CopyProtectionDialog::CopyProtectionDialog(MADSEngine *vm, bool priorAnswerWrong):
-		TextDialog(vm, FONT_INTERFACE_MADS, Common::Point(-1, -1), 32) {
+		TextDialog(vm, FONT_INTERFACE, Common::Point(-1, -1), 32) {
 	getHogAnusEntry(_hogEntry);
 
 	if (priorAnswerWrong) {
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index 3e28ee3..7a63397 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -25,81 +25,12 @@
 
 #include "common/scummsys.h"
 #include "mads/game.h"
+#include "mads/dialogs.h"
 
 namespace MADS {
 
 namespace Nebular {
 
-enum {
-	TEXTDIALOG_F8 = 0XF8,
-	TEXTDIALOG_F9 = 0XF8,
-	TEXTDIALOG_FA = 0XF8,
-	TEXTDIALOG_FB = 0XF8,
-	TEXTDIALOG_FC = 0XF8,
-	TEXTDIALOG_FD = 0XF8,
-	TEXTDIALOG_FE = 0XF8,
-	TEXTDIALOG_FONT = 0
-};
-
-#define TEXT_DIALOG_MAX_LINES 20
-
-class TextDialog {
-private:
-	/**
-	 * Increments the number of text lines the text dialog uses
-	 */
-	void incNumLines();
-
-	/**
-	 * Flags the previously added line to be underlined
-	 */
-	void underlineLine();
-
-	/**
-	 * Append text to the currently end line.
-	 */
-	void appendLine(const Common::String &line);
-protected:
-	MADSEngine *_vm;
-	Common::Point _position;
-	Common::String _fontName;
-	int _width;
-	int _innerWidth;
-	int _lineWidth;
-	int _currentX;
-	int _numLines;
-	int _lineSize;
-	Common::String _lines[TEXT_DIALOG_MAX_LINES];
-	int _lineXp[TEXT_DIALOG_MAX_LINES];
-	byte _savedPalette[8 * 3];
-
-	/**
-	 * Add a new line to the dialog
-	 */
-	void addLine(const Common::String &line, bool underline = false);
-
-	/**
-	 * Adds one or more lines, word wrapping the passed text
-	 */
-	void wordWrap(const Common::String &line);
-public:
-	/**
-	 * Constructor
-	 * @param vm			Engine reference
-	 * @param fontName		Font to use for display
-	 * @param pos			Position for window top-left
-	 * @param maxChars		Horizontal width of window in characters
-	 */
-	TextDialog(MADSEngine *vm, const Common::String &fontName, const Common::Point &pos, 
-		int maxChars);
-
-	/**
-	 * Destructor
-	 */
-	~TextDialog();
-
-};
-
 struct HOGANUS {
 	int _bookId;
 	int _pageNum;


Commit: 82514b4a28904ead97552f6605cd3bde6924660b
    https://github.com/scummvm/scummvm/commit/82514b4a28904ead97552f6605cd3bde6924660b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-22T11:13:35-05:00

Commit Message:
MADS: Beginnings of cursor initialization

Changed paths:
  A engines/mads/assets.cpp
  A engines/mads/assets.h
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/mads.cpp
    engines/mads/module.mk
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
new file mode 100644
index 0000000..7c1b169
--- /dev/null
+++ b/engines/mads/assets.cpp
@@ -0,0 +1,30 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/events.h"
+
+namespace MADS {
+
+
+} // End of namespace MADS
diff --git a/engines/mads/assets.h b/engines/mads/assets.h
new file mode 100644
index 0000000..dcd7390
--- /dev/null
+++ b/engines/mads/assets.h
@@ -0,0 +1,34 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_ASSETS_H
+#define MADS_ASSETS_H
+
+#include "common/scummsys.h"
+#include "mads/msprite.h"
+
+namespace MADS {
+
+
+} // End of namespace MADS
+
+#endif /* MADS_ASSETS_H */
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 0950ac0..ec06287 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -30,6 +30,25 @@ namespace MADS {
 
 EventsManager::EventsManager(MADSEngine *vm) {
 	_vm = vm;
+	_cursorSprites = nullptr;
+}
+
+EventsManager::~EventsManager() {
+	delete _cursorSprites;
+}
+
+void EventsManager::loadCursors(const Common::String &spritesName) {
+	error("TODO: load SpriteSet");
+}
+
+void EventsManager::setCursor(CursorType cursorId) {
+	_cursorId = cursorId;
+	_newCursorId = cursorId;
+	changeCursor();
+}
+
+void EventsManager::changeCursor() {
+
 }
 
 void EventsManager::handleEvents() {
diff --git a/engines/mads/events.h b/engines/mads/events.h
index 33d5c8e..860f36d 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -24,17 +24,47 @@
 #define MADS_EVENTS_H
 
 #include "common/scummsys.h"
+#include "mads/msprite.h"
 
 namespace MADS {
 
+enum CursorType { CURSOR_NONE = 0, CURSOR_ARROW = 1, CURSOR_WAIT = 2, CURSOR_GO_DOWN = 3, 
+	CURSOR_GO_UP = 4, CURSOR_GO_LEFT = 5, CURSOR_GO_RIGHT = 6 };
+
 class MADSEngine;
 
 class EventsManager {
 private:
 	MADSEngine *_vm;
+	CursorType _cursorId;
+	CursorType _newCursorId;
+	void *_cursorSprites;
+
+	/**
+	 * Updates the cursor image when the current cursor changes
+	 */
+	void changeCursor();
 public:
+	/**
+	 * Constructor
+	 */
 	EventsManager(MADSEngine *vm);
 
+	/**
+	 * Destructor
+	 */
+	~EventsManager();
+
+	/**
+	 * Loads the sprite set containing the cursors
+	 */
+	void loadCursors(const Common::String &spritesName);
+
+	/**
+	 * Sets the cursor
+	 */
+	void setCursor(CursorType cursorId);
+
 	void handleEvents();
 };
 
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 0a04fda..48c79ba 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -37,6 +37,7 @@ Game *Game::init(MADSEngine *vm) {
 }
 
 Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr) {
+	_sectionNumber = _priorSectionNumber = 0;
 }
 
 Game::~Game() {
@@ -48,4 +49,14 @@ void Game::run() {
 		return;
 }
 
+void Game::initSection(int sectionNumber) {
+	_priorSectionNumber = _sectionNumber;
+	_sectionNumber = sectionNumber;
+
+	_vm->_palette->resetGamePalette(18, 10);
+	_vm->_palette->setLowRange();
+
+	// TODO
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 2f0dcf7..bb15a8e 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -40,9 +40,18 @@ protected:
 	 * Perform any copy protection check
 	 */
 	virtual bool checkCopyProtection() = 0;
+
+	/**
+	 * Initialises the current section number of the game
+	 */
+	void initSection(int sectionNumber);
+
 public:
 	static Game *init(MADSEngine *vm);
 public:
+	int _sectionNumber;
+	int _priorSectionNumber;
+public:
 	virtual ~Game();
 
 	/**
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 827c62a..687852a 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -81,6 +81,7 @@ void MADSEngine::initialise() {
 	_userInterface = UserInterface::init(this);
 	_game = Game::init(this);
 
+	_events->loadCursors("*CURSOR.SS");
 	_screen->empty();
 }
 
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 179c197..ec85355 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -4,6 +4,7 @@ MODULE_OBJS := \
 	nebular/dialogs_nebular.o \
 	nebular/game_nebular.o \
 	nebular/sound_nebular.o \
+	assets.o \
 	compression.o \
 	detection.o \
 	dialogs.o \
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index c858984..2d7bd42 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -310,4 +310,68 @@ void Palette::setSystemPalette() {
 	blockRange(0, 4);
 }
 
+void Palette::resetGamePalette(int lowRange, int highRange) {
+	Common::fill((byte *)&_gamePalette[0], (byte *)&_gamePalette[PALETTE_COUNT], 0);
+	initRange(_mainPalette);
+
+	// Init low range to common RGB values
+	if (lowRange) {
+		_gamePalette[0].r = 1;
+		_gamePalette[0].b = 0;
+
+		Common::fill(&_gamePalette[1], &_gamePalette[lowRange - 1], _gamePalette[0]);
+	}
+
+	// Init high range to common RGB values
+	if (highRange) {
+		_gamePalette[255].r = 1;
+		_gamePalette[255].b = 0;
+
+		Common::fill(&_gamePalette[255 - highRange], &_gamePalette[254], _gamePalette[255]);
+	}
+}
+
+void Palette::initRange(byte *palette) {
+	int var6 = 0;
+	int vdx = 0;
+	int vbx = 0;
+	do {
+		int vdi = (vdx == 1) ? 0 : 0x2A;
+		int var8 = 0;
+		int varE = vbx;
+		int var10 = vdx;
+		do {
+			int vdx = 0;
+			do {
+				int vcx = 0;
+				int var4 = vdx;
+				do {
+					int var2 = var6 + vcx;
+					byte *destP = &palette[var2 * 3];
+					
+					destP[0] = (var8) ? vdi & 0xFF : vbx & 0XFF;
+					destP[1] = (var4) ? vdi & 0xFF : vbx & 0XFF;
+					destP[2] = (vcx) ? vdi & 0xFF : vbx & 0XFF;					
+				} while (++vcx < 2);
+
+				var6 += 2;
+				vdx = var4;
+			} while (++vdx < 2);
+		} while (++var8 < 2);
+	
+		vdx = var10 + 1;
+		vbx = varE + 21;
+	} while (vbx < 42);
+
+	palette[19] = 21;
+}
+
+void Palette::setLowRange() {
+	_mainPalette[0] = _mainPalette[1] = _mainPalette[2] = 0; 
+	_mainPalette[3] = _mainPalette[4] = _mainPalette[5] = 0x15; 
+	_mainPalette[6] = _mainPalette[7] = _mainPalette[8] = 0x2A; 
+	_mainPalette[9] = _mainPalette[10] = _mainPalette[11] = 0x3F; 
+	_vm->_palette->setPalette(_mainPalette, 0, 4);
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 0ef8693..53620d8 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -29,6 +29,13 @@ namespace MADS {
 
 class MADSEngine;
 
+struct RGB4 {
+	byte r;
+	byte g;
+	byte b;
+	byte u;
+};
+
 /**
  * Used to store a list of RGB values
  */
@@ -75,6 +82,11 @@ private:
 	 */
 	void fadeRange(byte *srcPal, byte *destPal,  int startIndex, int endIndex, 
 		int numSteps, uint delayAmount);
+
+	/**
+	 * Initialises a stanadrd range of colours for the given palette
+	 */
+	void initRange(byte *palette);
 protected:
 	MADSEngine *_vm;
 	bool _colorsChanged;
@@ -87,6 +99,7 @@ protected:
 	void reset();
 public:
 	byte _mainPalette[PALETTE_SIZE];
+	RGB4 _gamePalette[PALETTE_COUNT];
 public:
 	/**
 	 * Constructor
@@ -171,6 +184,16 @@ public:
 	 */
 	static void setGradient(byte *palette, int start, int count, int rgbValue1, int rgbValue2);
 
+	/**
+	 * Resets the game palette
+	 */
+	void resetGamePalette(int v1, int v2);
+
+	/**
+	 * Set the first four palette entries with preset values
+	 */
+	void setLowRange();
+
 	// Color indexes
 	uint8 BLACK;
 	uint8 BLUE;


Commit: 02a1d0eaa3f462425d115f4d88c3d2badbc7a236
    https://github.com/scummvm/scummvm/commit/02a1d0eaa3f462425d115f4d88c3d2badbc7a236
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-22T12:17:37-05:00

Commit Message:
MADS: Further cursor/event initialisation

Changed paths:
    engines/mads/assets.cpp
    engines/mads/assets.h
    engines/mads/compression.cpp
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/font.h
    engines/mads/game.cpp
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/msprite.h
    engines/mads/palette.cpp



diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index 7c1b169..6ad313c 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -22,9 +22,74 @@
 
 #include "common/scummsys.h"
 #include "mads/mads.h"
+#include "mads/assets.h"
+#include "mads/compression.h"
 #include "mads/events.h"
 
 namespace MADS {
 
+SpriteAsset::SpriteAsset(MADSEngine *vm, const Common::String &resourceName, int flags):
+		_vm(vm) {
+	Common::String resName = resourceName;
+	if (!resName.hasSuffix(".SS"))
+		resName += ".SS";
+	
+	File file(resName);
+	MadsPack sprites(&file);
+
+	int curFrame = 0;
+	uint32 frameOffset = 0;
+	_frameRate = 0;
+	_pixelSpeed = 0;
+	_maxWidth = 0;
+	_maxHeight = 0;
+
+	Common::SeekableReadStream *spriteStream = sprites.getItemStream(0);
+	for (int i = 0; i < 19; i++) {
+		spriteStream->readUint16LE();
+	}
+	_frameCount = spriteStream->readUint16LE();
+	// we skip the rest of the data
+	delete spriteStream;
+
+	// Get the palette data
+	spriteStream = sprites.getItemStream(2);
+	int numColors = 0;
+	byte *palData = _vm->_palette->decodePalette(spriteStream, &numColors);
+
+	Common::copy(palData, &palData[numColors], &_palette[0]);
+	if (numColors < 256) 
+		Common::fill(&_palette[numColors * 3], &_palette[PALETTE_SIZE], 0);
+	_colorCount = numColors;
+	delete[] palData;
+	delete spriteStream;
+
+	spriteStream = sprites.getItemStream(1);
+	Common::SeekableReadStream *spriteDataStream = sprites.getItemStream(3);
+
+	SpriteAssetFrame frame;
+	for (curFrame = 0; curFrame < _frameCount; curFrame++) {
+		frame.comp = 0;
+		frameOffset = spriteStream->readUint32LE();
+		_frameOffsets.push_back(frameOffset);
+		spriteStream->readUint32LE();	// frame size
+		frame.x = spriteStream->readUint16LE();
+		frame.y = spriteStream->readUint16LE();
+		frame.w = spriteStream->readUint16LE();
+		frame.h = spriteStream->readUint16LE();
+		if (curFrame == 0) {
+			debugN(kDebugGraphics, "%i frames, x = %i, y = %i, w = %i, h = %i\n", 
+				_frameCount, frame.x, frame.y, frame.w, frame.h);
+		}
+
+		frame.frame = MSprite::init(spriteDataStream, Common::Point(frame.x, frame.y), 
+			frame.w, frame.h, false);
+		_frames.push_back(frame);
+	}
+
+	delete spriteStream;
+	delete spriteDataStream;
+	file.close();
+}
 
 } // End of namespace MADS
diff --git a/engines/mads/assets.h b/engines/mads/assets.h
index dcd7390..c64209e 100644
--- a/engines/mads/assets.h
+++ b/engines/mads/assets.h
@@ -24,10 +24,45 @@
 #define MADS_ASSETS_H
 
 #include "common/scummsys.h"
+#include "common/array.h"
+#include "mads/msprite.h"
+#include "mads/palette.h"
 #include "mads/msprite.h"
 
 namespace MADS {
 
+struct SpriteAssetFrame {
+	uint32 stream;
+	int x, y, w, h;
+	uint32 comp;
+	MSprite *frame;
+};
+
+class SpriteAsset {
+private:
+	MADSEngine *_vm;
+	byte _palette[PALETTE_SIZE];
+	int _colorCount;
+	uint32 _srcSize;
+	int _frameRate, _pixelSpeed;
+	int _maxWidth, _maxHeight;
+	int _frameCount;
+	Common::Array<uint32> _frameOffsets;
+	Common::Array<SpriteAssetFrame> _frames;
+	uint32 _frameStartOffset;
+public:
+	SpriteAsset(MADSEngine *vm, const Common::String &resourceName, int flags);
+	int getCount() { return _frameCount; }
+	int getFrameRate() const { return _frameRate; }
+	int getPixelSpeed() const { return _pixelSpeed; }
+	int getFrameWidth(int index);
+	int getFrameHeight(int index);
+	int getMaxFrameWidth() const { return _maxWidth; }
+	int getMaxFrameHeight() const { return _maxHeight; }
+	MSprite *getFrame(int frameIndex);
+	byte *getPalette() { return _palette; }
+	int getColorCount() { return _colorCount; }
+};
 
 } // End of namespace MADS
 
diff --git a/engines/mads/compression.cpp b/engines/mads/compression.cpp
index febb6ec..5000319 100644
--- a/engines/mads/compression.cpp
+++ b/engines/mads/compression.cpp
@@ -46,9 +46,9 @@ MadsPack::MadsPack(Common::SeekableReadStream *stream) {
 }
 
 MadsPack::MadsPack(const Common::String &resourceName, MADSEngine *vm) {
-	Common::SeekableReadStream *stream = nullptr; //vm->_resources->get(resourceName);
-	initialise(stream);
-//	vm->_resources->toss(resourceName);
+	File file(resourceName);
+	initialise(&file);
+	file.close();
 }
 
 void MadsPack::initialise(Common::SeekableReadStream *stream) {
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index ec06287..bb980af 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -38,11 +38,16 @@ EventsManager::~EventsManager() {
 }
 
 void EventsManager::loadCursors(const Common::String &spritesName) {
-	error("TODO: load SpriteSet");
+	_cursorSprites = new SpriteAsset(_vm, "*CURSOR.SS", 0x4000);
 }
 
 void EventsManager::setCursor(CursorType cursorId) {
 	_cursorId = cursorId;
+	changeCursor();
+}
+
+void EventsManager::setCursor2(CursorType cursorId) {
+	_cursorId = cursorId;
 	_newCursorId = cursorId;
 	changeCursor();
 }
diff --git a/engines/mads/events.h b/engines/mads/events.h
index 860f36d..c5cc5bf 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "mads/msprite.h"
+#include "mads/assets.h"
 
 namespace MADS {
 
@@ -38,13 +39,14 @@ private:
 	MADSEngine *_vm;
 	CursorType _cursorId;
 	CursorType _newCursorId;
-	void *_cursorSprites;
 
 	/**
 	 * Updates the cursor image when the current cursor changes
 	 */
 	void changeCursor();
 public:
+	SpriteAsset *_cursorSprites;
+public:
 	/**
 	 * Constructor
 	 */
@@ -65,6 +67,11 @@ public:
 	 */
 	void setCursor(CursorType cursorId);
 
+	/**
+	 * Sets the cursor
+	 */
+	void setCursor2(CursorType cursorId);
+
 	void handleEvents();
 };
 
diff --git a/engines/mads/font.h b/engines/mads/font.h
index e042768..3deb3f4 100644
--- a/engines/mads/font.h
+++ b/engines/mads/font.h
@@ -30,13 +30,13 @@
 
 namespace MADS {
 
-#define FONT_CONVERSATION "fontconv.ff"
-#define FONT_INTERFACE "fontintr.ff"
-#define FONT_MAIN "fontmain.ff"
-#define FONT_MENU "fontmenu.ff"	// Not in Rex (uses bitmap files for menu strings)
-#define FONT_MISC "fontmisc.ff"
-#define FONT_TELE "fonttele.ff"	// Not in Phantom
-#define FONT_PHAN "fontphan.ff"	// Phantom only
+#define FONT_CONVERSATION "*FONTCONV.FF"
+#define FONT_INTERFACE "*FONTINTR.FF"
+#define FONT_MAIN "*FONTMAIN.FF"
+#define FONT_MENU "*FONTMENU.FF"	// Not in Rex (uses bitmap files for menu strings)
+#define FONT_MISC "*FONTMISC.FF"
+#define FONT_TELE "*FONTTELE.FF"	// Not in Phantom
+#define FONT_PHAN "*FONTPHAN.FF"	// Phantom only
 
 class MADSEngine;
 
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 48c79ba..774ec98 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -55,8 +55,10 @@ void Game::initSection(int sectionNumber) {
 
 	_vm->_palette->resetGamePalette(18, 10);
 	_vm->_palette->setLowRange();
-
-	// TODO
+	
+	assert(_vm->_events->_cursorSprites);
+	_vm->_events->setCursor2((_vm->_events->_cursorSprites->getCount() <= 1) ? 
+		CURSOR_ARROW : CURSOR_WAIT);
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 687852a..aa2bd55 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -67,6 +67,7 @@ void MADSEngine::initialise() {
 	// Set up debug channels
 	DebugMan.addDebugChannel(kDebugPath, "Path", "Pathfinding debug level");
 	DebugMan.addDebugChannel(kDebugScripts, "scripts", "Game scripts");
+	DebugMan.addDebugChannel(kDebugGraphics, "graphics", "Graphics handling");
 
 	// Initial sub-system engine references
 	MSurface::setVm(this);
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index a6ae776..b50cf07 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -54,7 +54,8 @@ namespace MADS {
 
 enum MADSDebugChannels {
 	kDebugPath      = 1 << 0,
-	kDebugScripts	= 1 << 1
+	kDebugScripts	= 1 << 1,
+	kDebugGraphics	= 1 << 2
 };
 
 enum {
diff --git a/engines/mads/msprite.h b/engines/mads/msprite.h
index c49aac4..c454597 100644
--- a/engines/mads/msprite.h
+++ b/engines/mads/msprite.h
@@ -97,8 +97,8 @@ struct SpriteFrameHeader {
 
 class MSprite {
 public:
-	MSprite *init(MSurface &s);
-	MSprite *init(Common::SeekableReadStream *source, const Common::Point &offset, int widthVal, 
+	static MSprite *init(MSurface &s);
+	static MSprite *init(Common::SeekableReadStream *source, const Common::Point &offset, int widthVal, 
 		int heightVal, bool decodeRle = true, uint8 encodingVal = 0);
 protected:
 	static MADSEngine *_vm;
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 2d7bd42..82ffa4e 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -240,8 +240,8 @@ void Palette::fadeRange(byte *srcPal, byte *destPal,  int startIndex, int endInd
 
 void Palette::setGradient(byte *palette, int start, int count, int rgbValue1, int rgbValue2) {
 	int rgbCtr = 0;
-	int rgbDiff = -(rgbValue2 - rgbValue1);
 	int rgbCurrent = rgbValue2;
+	int rgbDiff = -(rgbValue2 - rgbValue1);
 
 	if (count >  0) {
 		byte *pDest = palette + start * 3;
@@ -251,7 +251,7 @@ void Palette::setGradient(byte *palette, int start, int count, int rgbValue1, in
 		do {
 			pDest[0] = pDest[1] = pDest[2] = rgbCurrent;
 
-			if (count > 1) {
+			if (numLeft > 1) {
 				rgbCtr += rgbDiff;
 				if (rgbCtr >= endVal) {
 					do {


Commit: 3df12371873cb8e3380422aa3095e367408526af
    https://github.com/scummvm/scummvm/commit/3df12371873cb8e3380422aa3095e367408526af
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-22T14:20:34-05:00

Commit Message:
MADS: Removed M4-specific code. Keeping engine MADS-specific for now

Changed paths:
    engines/mads/compression.cpp
    engines/mads/detection_tables.h
    engines/mads/mads.h
    engines/mads/msprite.cpp
    engines/mads/msprite.h
    engines/mads/msurface.cpp
    engines/mads/msurface.h
    engines/mads/resources.cpp



diff --git a/engines/mads/compression.cpp b/engines/mads/compression.cpp
index 5000319..2190fc4 100644
--- a/engines/mads/compression.cpp
+++ b/engines/mads/compression.cpp
@@ -181,4 +181,4 @@ int FabDecompressor::getBit() {
 	return bit;
 }
 
-} // End of namespace M4
+} // End of namespace MADS
diff --git a/engines/mads/detection_tables.h b/engines/mads/detection_tables.h
index 7410dce..ac5316d 100644
--- a/engines/mads/detection_tables.h
+++ b/engines/mads/detection_tables.h
@@ -38,7 +38,7 @@ static const MADSGameDescription gameDescriptions[] = {
 			GUIO1(GUIO_NONE)
 		},
 		GType_RexNebular,
-		GF_MADS
+		0
 	},
 
 	{ AD_TABLE_END_MARKER }
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index b50cf07..b7598eb 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -65,11 +65,6 @@ enum {
 	GType_Riddle = 3
 };
 
-enum {
-	GF_MADS = 1 << 0,
-	GF_M4 = 1 << 1
-};
-
 struct MADSGameDescription;
 
 
diff --git a/engines/mads/msprite.cpp b/engines/mads/msprite.cpp
index 60c22d8..b15796d 100644
--- a/engines/mads/msprite.cpp
+++ b/engines/mads/msprite.cpp
@@ -38,21 +38,13 @@ enum {
 MADSEngine *MSprite::_vm;
 
 MSprite *MSprite::init(MSurface &s) {
-	if (_vm->getGameFeatures() & GF_MADS) {
-		return new MSpriteMADS(s);
-	} else {
-		return new MSpriteM4(s);
-	}
+	return new MSprite(s);
 }
 
 MSprite *MSprite::init(Common::SeekableReadStream *source, const Common::Point &offset, 
 		int widthVal, int heightVal, bool decodeRle, uint8 encodingVal) {
 
-	if (_vm->getGameFeatures() & GF_MADS) {
-		return new MSpriteMADS(source, offset, widthVal, heightVal, decodeRle, encodingVal);
-	} else {
-		return new MSpriteM4(source, offset, widthVal, heightVal, decodeRle, encodingVal);
-	}
+	return new MSprite(source, offset, widthVal, heightVal, decodeRle, encodingVal);
 }
 
 MSprite::MSprite(MSurface &s): _surface(s) {
@@ -65,21 +57,15 @@ MSprite::MSprite(Common::SeekableReadStream *source, const Common::Point &offset
 		_encoding(encodingVal), _offset(offset) {
 
 	// Load the sprite data
-	load(source, widthVal, heightVal, decodeRle);
+	loadSprite(source);
 }
 
 MSprite::~MSprite() {
 }
 
-/*------------------------------------------------------------------------*/
-
-void MSpriteMADS::load(Common::SeekableReadStream *stream, int widthVal, int heightVal,
-		bool decodeRle) {
-	loadSprite(stream);
-}
 
 // TODO: The sprite outlines (pixel value 0xFD) are not shown
-void MSpriteMADS::loadSprite(Common::SeekableReadStream *source) {
+void MSprite::loadSprite(Common::SeekableReadStream *source) {
 	byte *outp, *lineStart;
 	bool newLine = false;
 
@@ -130,78 +116,4 @@ void MSpriteMADS::loadSprite(Common::SeekableReadStream *source) {
 	}
 }
 
-/*------------------------------------------------------------------------*/
-
-void MSpriteM4::load(Common::SeekableReadStream *stream, int widthVal, int heightVal,
-		bool decodeRle) {
-	if (decodeRle) {
-		loadRle(stream);
-	} else {
-		// Raw sprite data, load directly
-		byte *dst = _surface.getData();
-		stream->read(dst, widthVal * heightVal);
-	}
-}
-
-void MSpriteM4::loadRle(Common::SeekableReadStream* rleData) {
-	byte *dst = _surface.getData();
-	for (;;) {
-		byte len = rleData->readByte();
-		if (len == 0) {
-			len = rleData->readByte();
-			if (len <= kMarker) {
-				if (len == kEndOfSprite)
-					break;
-			} else {
-				while (len--) {
-					*dst++ = rleData->readByte();
-				}
-			}
-		} else {
-			byte value = rleData->readByte();
-			while (len--)
-				*dst++ = value;
-		}
-	}
-}
-
-void MSpriteM4::loadDeltaRle(Common::SeekableReadStream* rleData, int destX, int destY) {
-	int lineNum = 0;
-	byte *dst = _surface.getBasePtr(destX, destY);
-
-	for (;;) {
-		byte len = rleData->readByte();
-		if (len == 0) {
-			len = rleData->readByte();
-			if (len <= kMarker) {
-				if (len == kEndOfLine) {
-					dst = _surface.getBasePtr(destX, destY + lineNum);
-					lineNum++;
-				} else if (len == kEndOfSprite)
-					break;
-			} else {
-				while (len--) {
-					byte pixel = rleData->readByte();
-					if (pixel == 0)
-						dst++;
-					else
-						*dst++ = pixel;
-					/* NOTE: The change below behaved differently than the old code,
-					   so I put the old code back in again above.
-					   If the pixel value is 0, nothing should be written to the
-					   output buffer, since 0 means transparent. */
-					//*dst++ = (pixel == 0xFD) ? 0 : pixel;
-				}
-			}
-		} else {
-			byte value = rleData->readByte();
-			if (value == 0)
-				dst += len;
-			else
-				while (len--)
-					*dst++ = value;
-		}
-	}
-}
-
 } // End of namespace MADS
diff --git a/engines/mads/msprite.h b/engines/mads/msprite.h
index c454597..bb21772 100644
--- a/engines/mads/msprite.h
+++ b/engines/mads/msprite.h
@@ -107,7 +107,7 @@ protected:
 	MSprite(Common::SeekableReadStream *source, const Common::Point &offset, 
 		int widthVal, int heightVal, bool decodeRle = true, uint8 encodingVal = 0);
 
-	virtual void load(Common::SeekableReadStream *stream, int widthVal, int heightVal, bool decodeRle) {}
+	void loadSprite(Common::SeekableReadStream *source);
 public:
 	static void setVm(MADSEngine *vm) { _vm = vm; }
 	virtual ~MSprite();
@@ -118,35 +118,6 @@ public:
 	uint8 _encoding;
 };
 
-class MSpriteMADS: public MSprite {
-	friend class MSprite;
-private:
-	void loadSprite(Common::SeekableReadStream *source);
-protected:
-	MSpriteMADS(MSurface &s): MSprite(s) {}
-	MSpriteMADS(Common::SeekableReadStream *source, const Common::Point &offset, 
-		int widthVal, int heightVal, bool decodeRle = true, uint8 encodingVal = 0):
-		MSprite(source, offset, widthVal, heightVal, decodeRle, encodingVal) {}
-
-	virtual void load(Common::SeekableReadStream *stream, int widthVal, int heightVal, bool decodeRle);
-};
-
-class MSpriteM4: public MSprite {
-	friend class MSprite;
-private:
-	// Loads a sprite from the given stream, and optionally decompresses the RLE-encoded data
-	// Loads an RLE compressed sprite; the surface must have been created before
-	void loadRle(Common::SeekableReadStream *rleData);
-	void loadDeltaRle(Common::SeekableReadStream *rleData, int destX, int destY);
-protected:
-	MSpriteM4(MSurface &s): MSprite(s) {}
-	MSpriteM4(Common::SeekableReadStream *source, const Common::Point &offset, 
-		int widthVal, int heightVal, bool decodeRle = true, uint8 encodingVal = 0):
-		MSprite(source, offset, widthVal, heightVal, decodeRle, encodingVal) {}
-
-	virtual void load(Common::SeekableReadStream *stream, int widthVal, int heightVal, bool decodeRle);
-};
-
 } // End of namespace MADS
 
 #endif /* MADS_MSPRITE_H */
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 2c0b433..b4ee129 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -35,20 +35,16 @@ MADSEngine *MSurface::_vm = nullptr;
 MSurface *MSurface::init(bool isScreen) {
 	if (_vm->getGameID() == GType_RexNebular) {
 		return new MSurfaceNebular(isScreen);
-	} else if (_vm->getGameFeatures() & GF_MADS) {
-		return new MSurfaceMADS(isScreen);
 	} else {
-		return new MSurfaceM4(isScreen);
+		return new MSurfaceMADS(isScreen);
 	}
 }
 
 MSurface *MSurface::init(int width, int height) {
 	if (_vm->getGameID() == GType_RexNebular) {
 		return new MSurfaceNebular(width, height);
-	} else if (_vm->getGameFeatures() & GF_MADS) {
-		return new MSurfaceMADS(width, height);
 	} else {
-		return new MSurfaceM4(width, height);
+		return new MSurfaceMADS(width, height);
 	}
 }
 
@@ -579,96 +575,4 @@ void MSurfaceNebular::loadBackgroundStream(Common::SeekableReadStream *source, R
 	delete sourceUnc;
 }
 
-/*------------------------------------------------------------------------*/
-
-void MSurfaceM4::loadCodes(Common::SeekableReadStream *source) {
-	if (!source) {
-		free();
-		return;
-	}
-
-	uint16 width = source->readUint16LE();
-	uint16 height = source->readUint16LE();
-
-	setSize(width, height);
-	source->read(pixels, width * height);
-}
-
-void MSurfaceM4::loadBackground(int roomNumber, RGBList **palData) {
-	if (palData)
-		*palData = NULL;
-	Common::String resourceName = Common::String::format("%i.tt", roomNumber);
-	Common::SeekableReadStream *stream = nullptr;//_vm->_resources->get(resourceName);	
-	loadBackgroundStream(stream);
-
-//	_vm->_resources->toss(resourceName);
-}
-
-void MSurfaceM4::loadBackgroundStream(Common::SeekableReadStream *source) {
-	MSurface *tileBuffer = MSurface::init();
-	uint curTileX = 0, curTileY = 0;
-	int clipX = 0, clipY = 0;
-	byte palette[256];
-
-	source->skip(4);
-	/*uint32 size =*/ source->readUint32LE();
-	uint32 width = source->readUint32LE();
-	uint32 height = source->readUint32LE();
-	uint32 tilesX = source->readUint32LE();
-	uint32 tilesY = source->readUint32LE();
-	uint32 tileWidth = source->readUint32LE();
-	uint32 tileHeight = source->readUint32LE();
-	uint8 blackIndex = 0;
-
-	// BGR data, which is converted to RGB8
-	for (uint i = 0; i < 256; i++) {
-		byte r, g, b;
-		palette[i * 3] = r = source->readByte() << 2;
-		palette[i * 3 + 1] = g = source->readByte() << 2;
-		palette[i * 3 + 2] = b = source->readByte() << 2;
-		source->skip(1);
-
-		if ((blackIndex == 0) && !r && !g && !b)
-			blackIndex = i;
-	}
-	
-	_vm->_palette->setPalette(palette, 0, 256);
-
-	// resize or create the surface
-	// Note that the height of the scene in game scenes is smaller than the screen height, 
-	// as the bottom part of the screen is the inventory
-	assert(getWidth() == (int)width);
-
-	tileBuffer->setSize(tileWidth, tileHeight);
-
-	for (curTileY = 0; curTileY < tilesY; curTileY++) {
-		clipY = MIN(height, (1 + curTileY) * tileHeight) - (curTileY * tileHeight);
-
-		for (curTileX = 0; curTileX < tilesX; curTileX++) {
-			clipX = MIN(width, (1 + curTileX) * tileWidth) - (curTileX * tileWidth);
-
-			// Read a tile and copy it to the destination surface
-			source->read(tileBuffer->getData(), tileWidth * tileHeight);
-			Common::Rect srcBounds(0, 0, clipX, clipY);
-			copyFrom(tileBuffer, srcBounds, 
-				Common::Point(curTileX * tileWidth, curTileY * tileHeight));
-		}
-	}
-
-	if (height < (uint)getHeight())
-		fillRect(Common::Rect(0, height, getWidth(), getHeight()), blackIndex);
-
-	delete tileBuffer;
-}
-
-/*------------------------------------------------------------------------*/
-
-void MSurfaceRiddle::loadBackground(const Common::String &sceneName) {
-	// Loads a Riddle scene
-	Common::String resName = Common::String::format("%s.tt", sceneName.c_str());
-	File stream(resName);
-
-	loadBackgroundStream(&stream);
-}
-
 } // End of namespace MADS
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index 42c56e9..940c5b5 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -282,27 +282,6 @@ public:
 	virtual void loadBackground(int roomNumber, RGBList **palData);
 };
 
-class MSurfaceM4: public MSurface {
-	friend class MSurface;
-protected:
-	MSurfaceM4(bool isScreen = false): MSurface(isScreen) {}
-	MSurfaceM4(int width, int height): MSurface(width, height) {}
-
-	void loadBackgroundStream(Common::SeekableReadStream *source);
-public:
-	virtual void loadCodes(Common::SeekableReadStream *source);
-	virtual void loadBackground(int roomNumber, RGBList **palData);
-};
-
-class MSurfaceRiddle: public MSurfaceM4 {
-	friend class MSurface;
-protected:
-	MSurfaceRiddle(bool isScreen = false): MSurfaceM4(isScreen) {}
-	MSurfaceRiddle(int width, int height): MSurfaceM4(width, height) {}
-public:
-	virtual void loadBackground(const Common::String &sceneName);
-};
-
 } // End of namespace MADS
 
 #endif /* MADS_MSURFACE_H */
diff --git a/engines/mads/resources.cpp b/engines/mads/resources.cpp
index ac46df9..fe021fc 100644
--- a/engines/mads/resources.cpp
+++ b/engines/mads/resources.cpp
@@ -89,10 +89,7 @@ public:
 };
 
 void ResourcesManager::init(MADSEngine *vm) {
-	if (vm->getGameFeatures() & GF_MADS)
-		SearchMan.add("HAG", new HagArchive());
-	else
-		error("Unsupported game engine");
+	SearchMan.add("HAG", new HagArchive());
 }
 
 /*------------------------------------------------------------------------*/


Commit: 6c354bccf253118d459f92f16d8f702ae07806fb
    https://github.com/scummvm/scummvm/commit/6c354bccf253118d459f92f16d8f702ae07806fb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-22T17:25:30-05:00

Commit Message:
MADS: Implemented more logic for dialog display

Changed paths:
  A engines/mads/debugger.cpp
  A engines/mads/debugger.h
    engines/mads/dialogs.cpp
    engines/mads/dialogs.h
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/module.mk
    engines/mads/msurface.cpp
    engines/mads/msurface.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp
new file mode 100644
index 0000000..ceaeeaa
--- /dev/null
+++ b/engines/mads/debugger.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "mads/mads.h"
+#include "mads/debugger.h"
+
+namespace MADS {
+
+Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) {
+	DCmd_Register("continue",		WRAP_METHOD(Debugger, Cmd_Exit));
+}
+/*
+static int strToInt(const char *s) {
+	if (!*s)
+		// No string at all
+		return 0;
+	else if (toupper(s[strlen(s) - 1]) != 'H')
+		// Standard decimal string
+		return atoi(s);
+
+	// Hexadecimal string
+	uint tmp = 0;
+	int read = sscanf(s, "%xh", &tmp);
+	if (read < 1)
+		error("strToInt failed on string \"%s\"", s);
+	return (int)tmp;
+}
+*/
+
+} // End of namespace MADS
diff --git a/engines/mads/debugger.h b/engines/mads/debugger.h
new file mode 100644
index 0000000..044151c
--- /dev/null
+++ b/engines/mads/debugger.h
@@ -0,0 +1,45 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_DEBUGGER_H
+#define MADS_DEBUGGER_H
+
+#include "common/scummsys.h"
+#include "gui/debugger.h"
+
+namespace MADS {
+
+class MADSEngine;
+
+class Debugger : public GUI::Debugger {
+private:
+	MADSEngine *_vm;
+public:
+	Debugger(MADSEngine *vm);
+	virtual ~Debugger() {}
+
+protected:
+};
+
+} // End of namespace MADS
+
+#endif	/* MADS_DEBUGGER_H */
diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index 4e64f08..ebb2141 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -51,6 +51,44 @@ void Dialog::restore(MSurface *s) {
 	_savedSurface = nullptr;
 }
 
+void Dialog::draw() {
+	// Save the screen portion the dialog will overlap
+	save(_vm->_screen);
+
+	// Draw the dialog
+	// Fill entire content of dialog
+	_vm->_screen->fillRect(Common::Rect(_position.x, _position.y,
+		_position.x + _width, _position.y + _height), TEXTDIALOG_BACKGROUND);
+
+	// Draw the outer edge line
+	_vm->_screen->frameRect(Common::Rect(_position.x, _position.y,
+		_position.x + _width, _position.y + _height), TEXTDIALOG_EDGE);
+
+	// Draw the gravelly dialog content
+	drawContent(Common::Rect(_position.x + 2, _position.y + 2,
+		_position.x + _width - 4, _position.y + _height - 4), 0,
+		TEXTDIALOG_CONTENT1, TEXTDIALOG_CONTENT2);
+}
+
+void Dialog::drawContent(const Common::Rect &r, int seed, byte color1, byte color2) {
+	uint16 currSeed = seed ? seed : 0xB78E;
+
+	for (int yp = 0; yp < r.height(); ++yp) {
+		byte *destP = _vm->_screen->getBasePtr(r.left, r.top + yp);
+		
+		for (int xp = 0; xp < r.width(); ++xp) {
+			uint16 seedAdjust = currSeed;
+			currSeed += 0x181D;
+			seedAdjust = (seedAdjust >> 9) | ((seedAdjust & 0x1ff) << 7);
+			currSeed ^= seedAdjust;
+			seedAdjust = (seedAdjust >> 3) | ((seedAdjust & 7) << 13);
+			currSeed += seedAdjust;
+
+			*destP++ = (currSeed & 0x10) ? color1 : color2;
+		}
+	}
+}
+
 /*------------------------------------------------------------------------*/
 
 TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName, 
@@ -61,7 +99,7 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName,
 	_position = pos;
 	
 	_vm->_font->setFont(FONT_INTERFACE);
-	_vm->_font->setColors(TEXTDIALOG_FONT, TEXTDIALOG_FONT, TEXTDIALOG_FONT, TEXTDIALOG_FONT);
+	_vm->_font->setColors(TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK);
 
 	_innerWidth = (_vm->_font->maxWidth() + 1) * maxChars;
 	_width = _innerWidth + 10;
@@ -71,16 +109,16 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName,
 	_numLines = 0;
 	Common::fill(&_lineXp[0], &_lineXp[TEXT_DIALOG_MAX_LINES], 0);
 	
-	Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_F8 * 3], 
-		&_vm->_palette->_mainPalette[TEXTDIALOG_F8 * 3 + 8 * 3], 
+	Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3], 
+		&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3 + 8 * 3], 
 		&_savedPalette[0]);
-	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_F8, 2, 0x24, 0x20);
-	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FA, 2, 0x27, 0x1C);
+	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_CONTENT1, 2, 0x24, 0x20);
+	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_EDGE, 2, 0x27, 0x1C);
 	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FC, 2, 0x24, 0x20);
 	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FE, 1, 0x37, 0x37);
 
-	_vm->_palette->setPalette(_vm->_palette->_mainPalette + (TEXTDIALOG_F8 * 3),
-		TEXTDIALOG_F8, 8);
+	_vm->_palette->setPalette(_vm->_palette->_mainPalette + (TEXTDIALOG_CONTENT1 * 3),
+		TEXTDIALOG_CONTENT1, 8);
 }
 
 TextDialog::~TextDialog() {
@@ -179,6 +217,58 @@ void TextDialog::appendLine(const Common::String &line) {
 	_lines[_numLines] += line;
 }
 
+void TextDialog::draw() {
+	if (!_lineWidth)
+		--_numLines;
+
+	// Figure out the size and position for the dialog
+	_height = (_vm->_font->getHeight() + 1) * (_numLines + 1) + 10;
+	if (_position.x == -1)
+		_position.x = 160 - (_width / 2);
+	if (_position.y == -1)
+		_position.y = 100 - (_height / 2);
+
+	if ((_position.x + _width) > _vm->_screen->getWidth())
+		_position.x = _vm->_screen->getWidth() - (_position.x + _width);
+	if ((_position.y + _height) > _vm->_screen->getHeight())
+		_position.y = _vm->_screen->getHeight() - (_position.y + _height);
+
+//	int askYp = (_vm->_font->getHeight() + 1) * _vm->_font->getHeight() + 3; 
+
+	// Draw the underlying dialog
+	Dialog::draw();
+
+	// Draw the text lines
+	int lineYp = _position.y + 5; 
+	for (int lineNum = 0; lineNum < _numLines; ++lineNum) {
+		if (_lineXp[lineNum] == -1) {
+			// Draw a line across the entire dialog
+			_vm->_screen->setColor(TEXTDIALOG_BLACK);
+			_vm->_screen->hLine(_position.x + 2, 
+				lineYp + (_vm->_font->getHeight() + 1)  / 2,
+				_position.x + _width - 4);
+		} else {
+			// Draw a text line
+			int xp = (_lineXp[lineNum] & 0x7F) + 5;
+			int yp = lineYp;
+			if (_lineXp[lineNum] & 0x40)
+				++yp;
+
+			_vm->_font->writeString(_vm->_screen, _lines[lineNum], 
+				Common::Point(xp, yp), 1);
+
+			if (_lineXp[lineNum] & 0x80) {
+				// Draw an underline under the text
+				int lineWidth = _vm->_font->getWidth(_lines[lineNum]);
+				_vm->_screen->setColor(TEXTDIALOG_BLACK);
+				_vm->_screen->hLine(xp, yp + _vm->_font->getHeight(), xp + lineWidth);
+			}
+		}
+
+		lineYp += _vm->_font->getHeight() + 1;
+	}
+}
+
 /*------------------------------------------------------------------------*/
 
 MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...): 
@@ -193,8 +283,10 @@ MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...):
 		line = va_arg(va, const char *);
 	}
 	va_end(va);
+}
+
+void MessageDialog::show() {
 
-	// TODO
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index 03710b6..407f6d3 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -48,6 +48,16 @@ protected:
 	 * @param s		Screen surface to restore to.
 	 */
 	void restore(MSurface *s);
+
+	/**
+	 * Draws the content of a dialog with a gravelly alternating color.
+	 */
+	void drawContent(const Common::Rect &r, int seed, byte color1, byte color2);
+protected:
+	/**
+	 * Draw the dialog
+	 */
+	virtual void draw();
 public:
 	/**
 	 * Constructor
@@ -61,14 +71,14 @@ public:
 };
 
 enum {
-	TEXTDIALOG_F8 = 0XF8,
-	TEXTDIALOG_F9 = 0XF8,
-	TEXTDIALOG_FA = 0XF8,
-	TEXTDIALOG_FB = 0XF8,
-	TEXTDIALOG_FC = 0XF8,
-	TEXTDIALOG_FD = 0XF8,
-	TEXTDIALOG_FE = 0XF8,
-	TEXTDIALOG_FONT = 0
+	TEXTDIALOG_CONTENT1 = 0XF8,
+	TEXTDIALOG_CONTENT2 = 0XF9,
+	TEXTDIALOG_EDGE = 0XFA,
+	TEXTDIALOG_BACKGROUND = 0XFB,
+	TEXTDIALOG_FC = 0XFC,
+	TEXTDIALOG_FD = 0XFD,
+	TEXTDIALOG_FE = 0XFE,
+	TEXTDIALOG_BLACK = 0
 };
 
 #define TEXT_DIALOG_MAX_LINES 20
@@ -96,6 +106,8 @@ protected:
 	int _currentX;
 	int _numLines;
 	int _lineSize;
+	int _askXp;
+	int _askLineNum;
 	Common::String _lines[TEXT_DIALOG_MAX_LINES];
 	int _lineXp[TEXT_DIALOG_MAX_LINES];
 	byte _savedPalette[8 * 3];
@@ -125,11 +137,20 @@ public:
 	 */
 	~TextDialog();
 
+	/**
+	 * Draw the dialog
+	 */
+	virtual void draw();
 };
 
 class MessageDialog: protected TextDialog {
 public:
 	MessageDialog(MADSEngine *vm, int lines, ...);
+
+	/**
+	 * Show the dialog, and wait until a key or mouse press.
+	 */
+	void show();
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index bb980af..3c50063 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -21,16 +21,22 @@
  */
 
 #include "common/scummsys.h"
+#include "graphics/cursorman.h"
 #include "common/events.h"
 #include "engines/util.h"
 #include "mads/mads.h"
 #include "mads/events.h"
 
+#define GAME_FRAME_RATE 50
+#define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE) 
+
 namespace MADS {
 
 EventsManager::EventsManager(MADSEngine *vm) {
 	_vm = vm;
 	_cursorSprites = nullptr;
+	_gameCounter = 0;
+	_priorFrameTime = 0;
 }
 
 EventsManager::~EventsManager() {
@@ -38,7 +44,7 @@ EventsManager::~EventsManager() {
 }
 
 void EventsManager::loadCursors(const Common::String &spritesName) {
-	_cursorSprites = new SpriteAsset(_vm, "*CURSOR.SS", 0x4000);
+	_cursorSprites = new SpriteAsset(_vm, spritesName, 0x4000);
 }
 
 void EventsManager::setCursor(CursorType cursorId) {
@@ -52,15 +58,86 @@ void EventsManager::setCursor2(CursorType cursorId) {
 	changeCursor();
 }
 
+void EventsManager::showCursor() {
+	CursorMan.showMouse(true);
+}
+
+void EventsManager::hideCursor() {
+	CursorMan.showMouse(false);
+}
+
 void EventsManager::changeCursor() {
 
 }
 
-void EventsManager::handleEvents() {
-	Common::Event e;
-	while (!_vm->shouldQuit()) {
-		g_system->getEventManager()->pollEvent(e);
+void EventsManager::pollEvents() {
+	checkForNextFrameCounter();
+	_mouseClicked = false;
+	_mouseReleased = false;
+	_keyPressed = false;
+
+	Common::Event event;
+	while (g_system->getEventManager()->pollEvent(event)) {
+		// Handle keypress
+		switch (event.type) {
+		case Common::EVENT_QUIT:
+		case Common::EVENT_RTL:
+		case Common::EVENT_KEYUP:
+			return;
+
+		case Common::EVENT_KEYDOWN:
+			// Check for debugger
+			if (event.kbd.keycode == Common::KEYCODE_d && (event.kbd.flags & Common::KBD_CTRL)) {
+				// Attach to the debugger
+				_vm->_debugger->attach();
+				_vm->_debugger->onFrame();
+			} else {
+				_keyPressed = true;
+			}
+			return;
+		case Common::EVENT_LBUTTONDOWN:
+		case Common::EVENT_RBUTTONDOWN:
+			_mouseClicked = true;
+			return;
+		case Common::EVENT_LBUTTONUP:
+		case Common::EVENT_RBUTTONUP:
+			_mouseReleased = true;
+			return;
+		case Common::EVENT_MOUSEMOVE:
+			_mousePos = event.mouse;
+			break;
+		default:
+ 			break;
+		}
+	}
+}
+
+void EventsManager::checkForNextFrameCounter() {
+	// Check for next game frame
+	uint32 milli = g_system->getMillis();
+	if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) {
+		++_gameCounter;
+		_priorFrameTime = milli;
+
+		// Give time to the debugger
+		_vm->_debugger->onFrame();
+
+		// Display the frame
+		_vm->_screen->updateScreen();
+
+		// Signal the ScummVM debugger
+		_vm->_debugger->onFrame();
+	}
+}
+
+void EventsManager::delay(int cycles) {
+	uint32 totalMilli = cycles * 1000 / GAME_FRAME_RATE;
+	uint32 delayEnd = g_system->getMillis() + totalMilli;
+
+	while (!_vm->shouldQuit() && g_system->getMillis() < delayEnd) {
 		g_system->delayMillis(10);
+
+		pollEvents();
 	}
 }
 
diff --git a/engines/mads/events.h b/engines/mads/events.h
index c5cc5bf..fefc64d 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -39,13 +39,24 @@ private:
 	MADSEngine *_vm;
 	CursorType _cursorId;
 	CursorType _newCursorId;
+	uint32 _gameCounter;
+	uint32 _priorFrameTime;
+	Common::Point _mousePos;
 
 	/**
 	 * Updates the cursor image when the current cursor changes
 	 */
 	void changeCursor();
+
+	/**
+	 * Checks for whether the next game frame number has been reached.
+	 */
+	void checkForNextFrameCounter();
 public:
 	SpriteAsset *_cursorSprites;
+	bool _mouseClicked;
+	bool _mouseReleased;
+	bool _keyPressed;
 public:
 	/**
 	 * Constructor
@@ -72,7 +83,30 @@ public:
 	 */
 	void setCursor2(CursorType cursorId);
 
-	void handleEvents();
+	/**
+	 * Show the mouse cursor
+	 */
+	void showCursor();
+
+	/**
+	 * Hide the mouse cursor
+	 */
+	void hideCursor();
+
+	/**
+	 * Poll any pending events
+	 */
+	void pollEvents();
+
+	/**
+	 * Return the current mouse position
+	 */
+	Common::Point mousePos() const { return _mousePos; }
+
+	/**
+	 * Delay for a given number of frames
+	 */
+	void delay(int amount);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index aa2bd55..3a121d0 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -42,6 +42,7 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :
 	_invObjectStill = false;
 	_textWindowStill = false;
 
+	_debugger = nullptr;
 	_events = nullptr;
 	_font = nullptr;
 	_game = nullptr;
@@ -53,6 +54,7 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :
 }
 
 MADSEngine::~MADSEngine() {
+	delete _debugger;
 	delete _events;
 	delete _font;
 	delete _game;
@@ -74,10 +76,11 @@ void MADSEngine::initialise() {
 	MSprite::setVm(this);
 
 	ResourcesManager::init(this);
+	_debugger = new Debugger(this);
 	_events = new EventsManager(this);
 	_palette = new Palette(this);
 	_font = new Font(this);
-	_screen = MSurface::init(true);
+	_screen = MSurface::init(g_system->getWidth(), g_system->getHeight());
 	_sound = new SoundManager(this, _mixer);
 	_userInterface = UserInterface::init(this);
 	_game = Game::init(this);
@@ -94,7 +97,7 @@ Common::Error MADSEngine::run() {
 	_game->run();
 
 	// Dummy loop to keep application active
-	_events->handleEvents();
+	_events->delay(9999);
 
 	return Common::kNoError;
 }
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index b7598eb..5166b7b 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -30,6 +30,7 @@
 #include "common/util.h"
 #include "engines/engine.h"
 #include "graphics/surface.h"
+#include "mads/debugger.h"
 #include "mads/events.h"
 #include "mads/font.h"
 #include "mads/game.h"
@@ -86,6 +87,7 @@ protected:
 	virtual Common::Error run();
 	virtual bool hasFeature(EngineFeature f) const;
 public:
+	Debugger *_debugger;
 	EventsManager *_events;
 	Font *_font;
 	Game *_game;
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index ec85355..0b5f4c7 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS := \
 	nebular/sound_nebular.o \
 	assets.o \
 	compression.o \
+	debugger.o \
 	detection.o \
 	dialogs.o \
 	events.o \
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index b4ee129..0846470 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -32,11 +32,11 @@ namespace MADS {
 
 MADSEngine *MSurface::_vm = nullptr;
 
-MSurface *MSurface::init(bool isScreen) {
+MSurface *MSurface::init() {
 	if (_vm->getGameID() == GType_RexNebular) {
-		return new MSurfaceNebular(isScreen);
+		return new MSurfaceNebular();
 	} else {
-		return new MSurfaceMADS(isScreen);
+		return new MSurfaceMADS();
 	}
 }
 
@@ -48,16 +48,13 @@ MSurface *MSurface::init(int width, int height) {
 	}
 }
 
-MSurface::MSurface(bool isScreen) {
+MSurface::MSurface() {
 	pixels = nullptr;
-	setSize(g_system->getWidth(), g_system->getHeight());
-	_isScreen = isScreen;
 }
 
 MSurface::MSurface(int width, int height) { 
 	pixels = nullptr;
 	setSize(width, height); 
-	_isScreen = false; 
 }
 
 MSurface::~MSurface() {
@@ -120,17 +117,24 @@ void MSurface::hLineXor(int x1, int x2, int y) {
 
 }
 
-void MSurface::line(int x1, int y1, int x2, int y2, byte color) {
-	Graphics::Surface::drawLine(x1, y1, x2, y2, color);
+void MSurface::line(const Common::Point &startPos, const Common::Point &endPos, byte color) {
+	Graphics::Surface::drawLine(startPos.x, startPos.y, endPos.x, endPos.y, color);
 }
 
+void MSurface::frameRect(const Common::Rect &r) {
+	Graphics::Surface::frameRect(r, _color);
+}
 
-void MSurface::frameRect(int x1, int y1, int x2, int y2) {
-	Graphics::Surface::frameRect(Common::Rect(x1, y1, x2, y2), _color);
+void MSurface::frameRect(const Common::Rect &r, byte color) {
+	Graphics::Surface::frameRect(r, color);
 }
 
-void MSurface::fillRect(int x1, int y1, int x2, int y2) {
-	Graphics::Surface::fillRect(Common::Rect(x1, y1, x2, y2), _color);
+void MSurface::fillRect(const Common::Rect &r) {
+	Graphics::Surface::fillRect(r, _color);
+}
+
+void MSurface::fillRect(const Common::Rect &r, byte color) {
+	Graphics::Surface::fillRect(r, color);
 }
 
 int MSurface::scaleValue(int value, int scale, int err) {
@@ -282,12 +286,9 @@ void MSurface::empty() {
 	Common::fill(getBasePtr(0, 0), getBasePtr(0, h), _vm->_palette->BLACK);
 }
 
-void MSurface::frameRect(const Common::Rect &r, uint8 color) {
-	Graphics::Surface::frameRect(r, color);
-}
-
-void MSurface::fillRect(const Common::Rect &r, uint8 color) {
-	Graphics::Surface::fillRect(r, color);
+void MSurface::updateScreen() { 
+	g_system->copyRectToScreen((const byte *)pixels, pitch, 0, 0, w, h);
+	g_system->updateScreen(); 
 }
 
 void MSurface::copyFrom(MSurface *src, const Common::Rect &srcBounds, 
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index 940c5b5..2e4ca7e 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -59,10 +59,9 @@ public:
 	static void setVm(MADSEngine *vm) { _vm = vm; }
 
 	/**
-	 * Create a new surface the same size as the screen.
-	 * @param isScreen		Set to true for the screen surface
+	 * Create a new surface.
 	 */
-	static MSurface *init(bool isScreen = false);
+	static MSurface *init();
 
 	/**
 	 * Create a surface
@@ -70,12 +69,11 @@ public:
 	static MSurface *init(int width, int height);
 private:
 	byte _color;
-	bool _isScreen;
 protected:
 	/**
 	 * Basic constructor
 	 */
-	MSurface(bool isScreen = false);
+	MSurface();
 
 	/**
 	 * Constructor for a surface with fixed dimensions
@@ -129,28 +127,37 @@ public:
 
 	/**
 	 * Draws an arbitrary line on the screen using a specified color
+	 * @param startPos		Starting position
+	 * @param endPos		Ending position
+	 * @param color			Color to use
 	 */
-	void line(int x1, int y1, int x2, int y2, byte color);
+	void line(const Common::Point &startPos, const Common::Point &endPos, byte color);
 
 	/**
 	 * Draws a rectangular frame using the currently set color
+	 * @param r		Bounds for rectangle
 	 */
-	void frameRect(int x1, int y1, int x2, int y2);
+	void frameRect(const Common::Rect &r);
 
 	/**
-	 * Draws a rectangular frame using a specified color
+	 * Draws a rectangular frame using the currently set color
+	 * @param r		Bounds for rectangle
+	 * @param color	Color to use
 	 */
-	void frameRect(const Common::Rect &r, uint8 color);
+	void frameRect(const Common::Rect &r, byte color);
 
 	/**
 	 * Draws a filled in box using the currently set color
+	 * @param r		Bounds for rectangle
 	 */
-	void fillRect(int x1, int y1, int x2, int y2);
+	void fillRect(const Common::Rect &r);
 
 	/**
-	 * Draws a filled in box using a specified color
+	 * Draws a filled in box using the currently set color
+	 * @param r		Bounds for rectangle
+	 * @param color	Color to use
 	 */
-	void fillRect(const Common::Rect &r, uint8 color);
+	void fillRect(const Common::Rect &r, byte color);
 
 	/**
 	 * Draws a sprite
@@ -171,6 +178,13 @@ public:
 	int getHeight() const { return h; }
 
 	/**
+	 * Returns the size of the surface as a Rect
+	 */
+	Common::Rect getBounds() const {
+		return Common::Rect(0, 0, w, h);
+	}
+
+	/**
 	 * Returns a pointer to the surface data
 	 */
 	byte *getData() { return (byte *)Graphics::Surface::getPixels(); }
@@ -186,14 +200,9 @@ public:
 	void empty();
 
 	/**
-	 * Updates the surface. If it's the screen surface, copies it to the physical screen.
+	 * Updates the screen with the contents of the surface
 	 */
-	void update() { 
-		if (_isScreen) {
-			g_system->copyRectToScreen((const byte *)pixels, pitch, 0, 0, w, h);
-			g_system->updateScreen(); 
-		}
-	}
+	void updateScreen();
 
 	/**
 	 * Copys a sub-section of another surface into the current one.
@@ -262,7 +271,7 @@ public:
 class MSurfaceMADS: public MSurface {
 	friend class MSurface;
 protected:
-	MSurfaceMADS(bool isScreen = false): MSurface(isScreen) {}
+	MSurfaceMADS(): MSurface() {}
 	MSurfaceMADS(int width, int height): MSurface(width, height) {}
 public:
 	virtual void loadCodes(Common::SeekableReadStream *source);
@@ -274,7 +283,7 @@ public:
 class MSurfaceNebular: public MSurfaceMADS {
 	friend class MSurface;
 protected:
-	MSurfaceNebular(bool isScreen = false): MSurfaceMADS(isScreen) {}
+	MSurfaceNebular(): MSurfaceMADS() {}
 	MSurfaceNebular(int width, int height): MSurfaceMADS(width, height) {}
 private:
 	void loadBackgroundStream(Common::SeekableReadStream *source, RGBList **palData);
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 10c210c..dc2b145 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -41,7 +41,11 @@ bool GameNebular::checkCopyProtection() {
 	if (!ConfMan.getBool("copy_protection"))
 		return true;
 
-	CopyProtectionDialog::show(_vm);
+	MessageDialog *dlg = new MessageDialog(_vm, 40, "Line 1", "Line 2", nullptr);
+	dlg->show();
+	delete dlg;
+
+	//CopyProtectionDialog::show(_vm);
 	return false;
 }
 
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 82ffa4e..8ec43b9 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -118,27 +118,6 @@ void Palette::reset() {
 	WHITE = palIndexFromRgb(255, 255, 255, palData);
 }
 
-void Palette::fadeIn(int numSteps, uint delayAmount, RGBList *destPalette) {
-	fadeIn(numSteps, delayAmount, destPalette->data(), destPalette->size());
-}
-
-void Palette::fadeIn(int numSteps, uint delayAmount, byte *destPalette, int numColors) {
-	if (_fading_in_progress)
-		return;
-
-	_fading_in_progress = true;
-	byte blackPalette[PALETTE_SIZE];
-	Common::fill(&blackPalette[0], &blackPalette[PALETTE_SIZE], 0);
-
-	// Initially set the black palette
-	_vm->_palette->setPalette(blackPalette, 0, numColors);
-
-	// Handle the actual fading
-	fadeRange(blackPalette, destPalette, 0, numColors - 1, numSteps, delayAmount);
-
-	_fading_in_progress = false;
-}
-
 void Palette::resetColorCounts() {
 	Common::fill(&_usageCount[0], &_usageCount[PALETTE_COUNT], 0);
 }
@@ -211,33 +190,6 @@ void Palette::deleteAllRanges() {
 		_usageCount[colIndex] = 0;
 }
 
-void Palette::fadeRange(byte *srcPal, byte *destPal,  int startIndex, int endIndex, 
-					 int numSteps, uint delayAmount) {
-	byte tempPal[256 * 3];
-
-	// perform the fade
-	for(int stepCtr = 1; stepCtr <= numSteps; ++stepCtr) {
-		// Delay the specified amount
-		uint32 startTime = g_system->getMillis();
-		while ((g_system->getMillis() - startTime) < delayAmount) {
-			_vm->_events->handleEvents();
-			g_system->delayMillis(10);
-		}
-
-		for (int i = startIndex; i <= endIndex; ++i) {
-			// Handle the intermediate rgb values for fading
-			tempPal[i * 3] = (byte) (srcPal[i * 3] + (destPal[i * 3] - srcPal[i * 3]) * stepCtr / numSteps);   
-			tempPal[i * 3 + 1] = (byte) (srcPal[i * 3 + 1] + (destPal[i * 3 + 1] - srcPal[i * 3 + 1]) * stepCtr / numSteps); 
-			tempPal[i * 3 + 2] = (byte) (srcPal[i * 3 + 2] + (destPal[i * 3 + 2] - srcPal[i * 3 + 2]) * stepCtr / numSteps); 
-		}
-		
-		_vm->_palette->setPalette(&tempPal[startIndex * 3], startIndex, endIndex - startIndex + 1);
-	}
-
-	// Make sure the end palette exactly matches what is wanted
-	_vm->_palette->setPalette(&destPal[startIndex * 3], startIndex, endIndex - startIndex + 1);
-}
-
 void Palette::setGradient(byte *palette, int start, int count, int rgbValue1, int rgbValue2) {
 	int rgbCtr = 0;
 	int rgbCurrent = rgbValue2;
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 53620d8..9a4e451 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -78,12 +78,6 @@ public:
 class Palette {
 private:
 	/**
-	 * Support method used by the fading code
-	 */
-	void fadeRange(byte *srcPal, byte *destPal,  int startIndex, int endIndex, 
-		int numSteps, uint delayAmount);
-
-	/**
 	 * Initialises a stanadrd range of colours for the given palette
 	 */
 	void initRange(byte *palette);
@@ -127,16 +121,6 @@ public:
 	 */
 	uint8 palIndexFromRgb(byte r, byte g, byte b, byte *paletteData = nullptr);
 
-	/**
-	 * Performs a fade in
-	 */
-	void fadeIn(int numSteps, uint delayAmount, byte *destPalette, int numColors);
-
-	/**
-	 * Performs a fade in
-	 */
-	void fadeIn(int numSteps, uint delayAmount, RGBList *destPalette);
-
 	// Methods used for reference counting color usage
 	/**
 	 * Resets the usage counts for the palette


Commit: 6b774d228495e2dc9de08520a3064889d439335d
    https://github.com/scummvm/scummvm/commit/6b774d228495e2dc9de08520a3064889d439335d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-22T18:21:18-05:00

Commit Message:
MADS: Copy protection dialog is starting to be displayed

Changed paths:
    engines/mads/dialogs.cpp
    engines/mads/dialogs.h
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/dialogs_nebular.h
    engines/mads/nebular/game_nebular.cpp



diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index ebb2141..d5a6bfd 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -34,7 +34,7 @@ Dialog::Dialog(MADSEngine *vm): _vm(vm), _savedSurface(nullptr),
 }
 
 Dialog::~Dialog() {
-	delete _savedSurface;
+	restore(_vm->_screen);
 }
 
 
@@ -46,9 +46,11 @@ void Dialog::save(MSurface *s) {
 }
 
 void Dialog::restore(MSurface *s) {
-	_savedSurface->copyTo(s, _position);
-	delete _savedSurface;
-	_savedSurface = nullptr;
+	if (_savedSurface) {
+		_savedSurface->copyTo(s, _position);
+		delete _savedSurface;
+		_savedSurface = nullptr;
+	}
 }
 
 void Dialog::draw() {
@@ -109,26 +111,28 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName,
 	_numLines = 0;
 	Common::fill(&_lineXp[0], &_lineXp[TEXT_DIALOG_MAX_LINES], 0);
 	
+	// Save the high end of the palette, and set up the entries for dialog display
 	Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3], 
 		&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3 + 8 * 3], 
 		&_savedPalette[0]);
-	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_CONTENT1, 2, 0x24, 0x20);
-	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_EDGE, 2, 0x27, 0x1C);
-	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FC, 2, 0x24, 0x20);
-	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FE, 1, 0x37, 0x37);
+	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_CONTENT1, 2, 0x90, 0x80);
+	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_EDGE, 2, 0x9C, 0x70);
+	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FC, 2, 0x90, 0x80);
+	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FE, 1, 0xDC, 0xDC);
 
 	_vm->_palette->setPalette(_vm->_palette->_mainPalette + (TEXTDIALOG_CONTENT1 * 3),
 		TEXTDIALOG_CONTENT1, 8);
 }
 
 TextDialog::~TextDialog() {
+	restorePalette();
 }
 
 void TextDialog::addLine(const Common::String &line, bool underline) {
 	if (_lineWidth > 0 || _currentX > 0)
 		incNumLines();
 
-	int stringWidth = _vm->_font->getWidth(line);
+	int stringWidth = _vm->_font->getWidth(line, 1);
 	if (stringWidth >= _innerWidth || (int)line.size() >= _lineSize) {
 		wordWrap(line);
 	} else {
@@ -249,17 +253,17 @@ void TextDialog::draw() {
 				_position.x + _width - 4);
 		} else {
 			// Draw a text line
-			int xp = (_lineXp[lineNum] & 0x7F) + 5;
+			int xp = (_lineXp[lineNum] & 0x7F) + _position.x + 5;
 			int yp = lineYp;
 			if (_lineXp[lineNum] & 0x40)
 				++yp;
 
 			_vm->_font->writeString(_vm->_screen, _lines[lineNum], 
-				Common::Point(xp, yp), 1);
+				Common::Point(xp, yp), 0, 1);
 
 			if (_lineXp[lineNum] & 0x80) {
 				// Draw an underline under the text
-				int lineWidth = _vm->_font->getWidth(_lines[lineNum]);
+				int lineWidth = _vm->_font->getWidth(_lines[lineNum], 1);
 				_vm->_screen->setColor(TEXTDIALOG_BLACK);
 				_vm->_screen->hLine(xp, yp + _vm->_font->getHeight(), xp + lineWidth);
 			}
@@ -269,6 +273,12 @@ void TextDialog::draw() {
 	}
 }
 
+void TextDialog::restorePalette() {
+	Common::copy(&_savedPalette[0], &_savedPalette[8 * 3],
+		&_vm->_palette->_mainPalette[248 * 3]);
+	_vm->_palette->setPalette(_vm->_palette->_mainPalette, 248, 8);
+}
+
 /*------------------------------------------------------------------------*/
 
 MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...): 
@@ -286,7 +296,13 @@ MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...):
 }
 
 void MessageDialog::show() {
+	draw();
+	_vm->_events->showCursor();
 
+	while (!_vm->shouldQuit() && !_vm->_events->_keyPressed &&
+			!_vm->_events->_mouseClicked) {
+		_vm->_events->delay(1);
+	}
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index 407f6d3..163d66e 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -99,6 +99,11 @@ private:
 	 * Append text to the currently end line.
 	 */
 	void appendLine(const Common::String &line);
+
+	/**
+	 * Clean up after finishing displaying the dialog
+	 */
+	void restorePalette();
 protected:
 	Common::String _fontName;
 	int _innerWidth;
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 3c50063..89d1560 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -37,6 +37,8 @@ EventsManager::EventsManager(MADSEngine *vm) {
 	_cursorSprites = nullptr;
 	_gameCounter = 0;
 	_priorFrameTime = 0;
+	_keyPressed = false;
+	_mouseClicked = false;
 }
 
 EventsManager::~EventsManager() {
@@ -72,9 +74,6 @@ void EventsManager::changeCursor() {
 
 void EventsManager::pollEvents() {
 	checkForNextFrameCounter();
-	_mouseClicked = false;
-	_mouseReleased = false;
-	_keyPressed = false;
 
 	Common::Event event;
 	while (g_system->getEventManager()->pollEvent(event)) {
@@ -82,7 +81,6 @@ void EventsManager::pollEvents() {
 		switch (event.type) {
 		case Common::EVENT_QUIT:
 		case Common::EVENT_RTL:
-		case Common::EVENT_KEYUP:
 			return;
 
 		case Common::EVENT_KEYDOWN:
@@ -95,13 +93,16 @@ void EventsManager::pollEvents() {
 				_keyPressed = true;
 			}
 			return;
+		case Common::EVENT_KEYUP:
+			_keyPressed = false;
+			return;
 		case Common::EVENT_LBUTTONDOWN:
 		case Common::EVENT_RBUTTONDOWN:
 			_mouseClicked = true;
 			return;
 		case Common::EVENT_LBUTTONUP:
 		case Common::EVENT_RBUTTONUP:
-			_mouseReleased = true;
+			_mouseClicked = false;
 			return;
 		case Common::EVENT_MOUSEMOVE:
 			_mousePos = event.mouse;
diff --git a/engines/mads/events.h b/engines/mads/events.h
index fefc64d..4705e62 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -55,7 +55,6 @@ private:
 public:
 	SpriteAsset *_cursorSprites;
 	bool _mouseClicked;
-	bool _mouseReleased;
 	bool _keyPressed;
 public:
 	/**
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 76b6162..95a485d 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -31,13 +31,6 @@ namespace MADS {
 
 namespace Nebular {
 
-bool CopyProtectionDialog::show(MADSEngine *vm) {
-	CopyProtectionDialog *dlg = new CopyProtectionDialog(vm, false);
-
-	delete dlg;
-	return true;
-}
-
 CopyProtectionDialog::CopyProtectionDialog(MADSEngine *vm, bool priorAnswerWrong):
 		TextDialog(vm, FONT_INTERFACE, Common::Point(-1, -1), 32) {
 	getHogAnusEntry(_hogEntry);
@@ -76,6 +69,20 @@ CopyProtectionDialog::CopyProtectionDialog(MADSEngine *vm, bool priorAnswerWrong
 	wordWrap("                    ");
 	wordWrap("\n");
 
+	// TODO: Rest of setup
+}
+
+bool CopyProtectionDialog::show() {
+	draw();
+	_vm->_events->showCursor();
+
+	// TODO: Replace with text input
+	while (!_vm->shouldQuit() && !_vm->_events->_keyPressed &&
+			!_vm->_events->_mouseClicked) {
+		_vm->_events->delay(1);
+	}
+
+	return true;
 }
 
 bool CopyProtectionDialog::getHogAnusEntry(HOGANUS &entry) {
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index 7a63397..53f377a 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -44,19 +44,19 @@ private:
 	HOGANUS _hogEntry;
 
 	/**
-	 * Constructor
-	 */
-	CopyProtectionDialog(MADSEngine *vm, bool priorAnswerWrong);
-
-	/**
 	 * Get a random copy protection entry from the HOGANUS resource
 	 */
 	bool getHogAnusEntry(HOGANUS &entry);
 public:
 	/**
+	 * Constructor
+	 */
+	CopyProtectionDialog(MADSEngine *vm, bool priorAnswerWrong);
+
+	/**
 	 * Show the dialog
 	 */
-	static bool show(MADSEngine *vm);
+	bool show();
 };
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index dc2b145..bf52af3 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -41,11 +41,10 @@ bool GameNebular::checkCopyProtection() {
 	if (!ConfMan.getBool("copy_protection"))
 		return true;
 
-	MessageDialog *dlg = new MessageDialog(_vm, 40, "Line 1", "Line 2", nullptr);
+	CopyProtectionDialog *dlg = new CopyProtectionDialog(_vm, false);
 	dlg->show();
 	delete dlg;
 
-	//CopyProtectionDialog::show(_vm);
 	return false;
 }
 


Commit: 1d80edb2dd092b7e91805f359f0e2a7d470ed7c4
    https://github.com/scummvm/scummvm/commit/1d80edb2dd092b7e91805f359f0e2a7d470ed7c4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-23T13:39:53-05:00

Commit Message:
MADS: Fixes for the display of dialogs

Changed paths:
    engines/mads/dialogs.cpp
    engines/mads/dialogs.h
    engines/mads/msurface.cpp
    engines/mads/msurface.h
    engines/mads/nebular/dialogs_nebular.cpp



diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index d5a6bfd..c6049c3 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -62,13 +62,19 @@ void Dialog::draw() {
 	_vm->_screen->fillRect(Common::Rect(_position.x, _position.y,
 		_position.x + _width, _position.y + _height), TEXTDIALOG_BACKGROUND);
 
-	// Draw the outer edge line
-	_vm->_screen->frameRect(Common::Rect(_position.x, _position.y,
-		_position.x + _width, _position.y + _height), TEXTDIALOG_EDGE);
+	// Draw the outer edge lines
+	_vm->_screen->hLine(_position.x + 1, _position.y + _height - 2,
+		_position.x + _width - 2, TEXTDIALOG_EDGE);
+	_vm->_screen->hLine(_position.x, _position.y + _height - 1,
+		_position.x + _width - 1, TEXTDIALOG_EDGE);
+	_vm->_screen->vLine(_position.x + _width - 2, _position.y + 2,
+		_position.y + _height - 2, TEXTDIALOG_EDGE);
+	_vm->_screen->vLine(_position.x + _width - 1, _position.y + 1,
+		_position.y + _height - 1, TEXTDIALOG_EDGE);
 
 	// Draw the gravelly dialog content
 	drawContent(Common::Rect(_position.x + 2, _position.y + 2,
-		_position.x + _width - 4, _position.y + _height - 4), 0,
+		_position.x + _width - 2, _position.y + _height - 2), 0,
 		TEXTDIALOG_CONTENT1, TEXTDIALOG_CONTENT2);
 }
 
@@ -86,7 +92,7 @@ void Dialog::drawContent(const Common::Rect &r, int seed, byte color1, byte colo
 			seedAdjust = (seedAdjust >> 3) | ((seedAdjust & 7) << 13);
 			currSeed += seedAdjust;
 
-			*destP++ = (currSeed & 0x10) ? color1 : color2;
+			*destP++ = (currSeed & 0x10) ? color2 : color1;
 		}
 	}
 }
@@ -110,7 +116,9 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName,
 	_currentX = 0;
 	_numLines = 0;
 	Common::fill(&_lineXp[0], &_lineXp[TEXT_DIALOG_MAX_LINES], 0);
-	
+	_askLineNum = -1;
+	_askXp = 0;
+
 	// Save the high end of the palette, and set up the entries for dialog display
 	Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3], 
 		&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3 + 8 * 3], 
@@ -221,6 +229,12 @@ void TextDialog::appendLine(const Common::String &line) {
 	_lines[_numLines] += line;
 }
 
+void TextDialog::addInput() {
+	_askXp = _currentX + 1;
+	_askLineNum = _numLines;
+	incNumLines();
+}
+
 void TextDialog::draw() {
 	if (!_lineWidth)
 		--_numLines;
@@ -237,8 +251,6 @@ void TextDialog::draw() {
 	if ((_position.y + _height) > _vm->_screen->getHeight())
 		_position.y = _vm->_screen->getHeight() - (_position.y + _height);
 
-//	int askYp = (_vm->_font->getHeight() + 1) * _vm->_font->getHeight() + 3; 
-
 	// Draw the underlying dialog
 	Dialog::draw();
 
@@ -247,10 +259,9 @@ void TextDialog::draw() {
 	for (int lineNum = 0; lineNum < _numLines; ++lineNum) {
 		if (_lineXp[lineNum] == -1) {
 			// Draw a line across the entire dialog
-			_vm->_screen->setColor(TEXTDIALOG_BLACK);
 			_vm->_screen->hLine(_position.x + 2, 
 				lineYp + (_vm->_font->getHeight() + 1)  / 2,
-				_position.x + _width - 4);
+				_position.x + _width - 4, TEXTDIALOG_BLACK);
 		} else {
 			// Draw a text line
 			int xp = (_lineXp[lineNum] & 0x7F) + _position.x + 5;
@@ -264,8 +275,8 @@ void TextDialog::draw() {
 			if (_lineXp[lineNum] & 0x80) {
 				// Draw an underline under the text
 				int lineWidth = _vm->_font->getWidth(_lines[lineNum], 1);
-				_vm->_screen->setColor(TEXTDIALOG_BLACK);
-				_vm->_screen->hLine(xp, yp + _vm->_font->getHeight(), xp + lineWidth);
+				_vm->_screen->hLine(xp, yp + _vm->_font->getHeight(), xp + lineWidth,
+					TEXTDIALOG_BLACK);
 			}
 		}
 
@@ -273,6 +284,18 @@ void TextDialog::draw() {
 	}
 }
 
+void TextDialog::drawWithInput() {
+	int innerWidth = _innerWidth;
+	int lineHeight = _vm->_font->getHeight() + 1;
+	int xp = _position.x + 5;
+
+	// Draw the content of the dialog
+	drawContent(Common::Rect(_position.x + 2, _position.y + 2,
+		_position.x + _width - 2, _position.y + _height - 2), 0,
+		TEXTDIALOG_CONTENT1, TEXTDIALOG_CONTENT2);
+
+}
+
 void TextDialog::restorePalette() {
 	Common::copy(&_savedPalette[0], &_savedPalette[8 * 3],
 		&_vm->_palette->_mainPalette[248 * 3]);
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index 163d66e..0945ad9 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -126,6 +126,11 @@ protected:
 	 * Adds one or more lines, word wrapping the passed text
 	 */
 	void wordWrap(const Common::String &line);
+
+	/**
+	 * Adds an input area following previously added text
+	 */
+	void addInput();
 public:
 	/**
 	 * Constructor
@@ -146,6 +151,11 @@ public:
 	 * Draw the dialog
 	 */
 	virtual void draw();
+
+	/**
+	 * Draw the dialog along with any input box
+	 */
+	void drawWithInput();
 };
 
 class MessageDialog: protected TextDialog {
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 0846470..a9561cd 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -66,77 +66,6 @@ void MSurface::setSize(int width, int height) {
 	Graphics::Surface::create(width, height, Graphics::PixelFormat::createFormatCLUT8());
 }
 
-void MSurface::vLine(int x, int y1, int y2) {
-	Graphics::Surface::vLine(x, y1, y2, _color);
-}
-
-void MSurface::hLine(int x1, int x2, int y) {
-	Graphics::Surface::hLine(x1, y, x2, _color);
-}
-
-void MSurface::vLineXor(int x, int y1, int y2) {
-	// Clipping
-	if (x < 0 || x >= w)
-		return;
-
-	if (y2 < y1)
-		SWAP(y2, y1);
-
-	if (y1 < 0)
-		y1 = 0;
-	if (y2 >= h)
-		y2 = h - 1;
-
-	byte *ptr = (byte *)getBasePtr(x, y1);
-	while (y1++ <= y2) {
-		*ptr ^= 0xFF;
-		ptr += pitch;
-	}
-
-}
-
-void MSurface::hLineXor(int x1, int x2, int y) {
-	// Clipping
-	if (y < 0 || y >= h)
-		return;
-
-	if (x2 < x1)
-		SWAP(x2, x1);
-
-	if (x1 < 0)
-		x1 = 0;
-	if (x2 >= w)
-		x2 = w - 1;
-
-	if (x2 < x1)
-		return;
-
-	byte *ptr = (byte *)getBasePtr(x1, y);
-	while (x1++ <= x2)
-		*ptr++ ^= 0xFF;
-
-}
-
-void MSurface::line(const Common::Point &startPos, const Common::Point &endPos, byte color) {
-	Graphics::Surface::drawLine(startPos.x, startPos.y, endPos.x, endPos.y, color);
-}
-
-void MSurface::frameRect(const Common::Rect &r) {
-	Graphics::Surface::frameRect(r, _color);
-}
-
-void MSurface::frameRect(const Common::Rect &r, byte color) {
-	Graphics::Surface::frameRect(r, color);
-}
-
-void MSurface::fillRect(const Common::Rect &r) {
-	Graphics::Surface::fillRect(r, _color);
-}
-
-void MSurface::fillRect(const Common::Rect &r, byte color) {
-	Graphics::Surface::fillRect(r, color);
-}
-
 int MSurface::scaleValue(int value, int scale, int err) {
 	int scaled = 0;
 	while (value--) {
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index 2e4ca7e..3904aa1 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -67,8 +67,6 @@ public:
 	 * Create a surface
 	 */
 	static MSurface *init(int width, int height);
-private:
-	byte _color;
 protected:
 	/**
 	 * Basic constructor
@@ -96,36 +94,6 @@ public:
 	void setSize(int width, int height);
 
 	/**
-	 * Sets the color used for drawing on the surface
-	 */
-	void setColor(byte value) { _color = value; }
-
-	/**
-	 * Returns the currently active color
-	 */
-	byte getColor() const { return _color; }
-	
-	/**
-	 * Draws a vertical line using the currently set color
-	 */
-	void vLine(int x, int y1, int y2);
-
-	/**
-	 * Draws a horizontal line using the currently set color
-	 */
-	void hLine(int x1, int x2, int y);
-
-	/**
-	 * Draws a vertical line using an Xor on each pixel
-	 */
-	void vLineXor(int x, int y1, int y2);
-
-	/**
-	 * Draws a horizontal line using an Xor on each pixel
-	 */
-	void hLineXor(int x1, int x2, int y);
-
-	/**
 	 * Draws an arbitrary line on the screen using a specified color
 	 * @param startPos		Starting position
 	 * @param endPos		Ending position
@@ -134,32 +102,6 @@ public:
 	void line(const Common::Point &startPos, const Common::Point &endPos, byte color);
 
 	/**
-	 * Draws a rectangular frame using the currently set color
-	 * @param r		Bounds for rectangle
-	 */
-	void frameRect(const Common::Rect &r);
-
-	/**
-	 * Draws a rectangular frame using the currently set color
-	 * @param r		Bounds for rectangle
-	 * @param color	Color to use
-	 */
-	void frameRect(const Common::Rect &r, byte color);
-
-	/**
-	 * Draws a filled in box using the currently set color
-	 * @param r		Bounds for rectangle
-	 */
-	void fillRect(const Common::Rect &r);
-
-	/**
-	 * Draws a filled in box using the currently set color
-	 * @param r		Bounds for rectangle
-	 * @param color	Color to use
-	 */
-	void fillRect(const Common::Rect &r, byte color);
-
-	/**
 	 * Draws a sprite
 	 * @param pt		Position to draw sprite at
 	 * @param info		General sprite details
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 95a485d..6d2321e 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -67,9 +67,8 @@ CopyProtectionDialog::CopyProtectionDialog(MADSEngine *vm, bool priorAnswerWrong
 	wordWrap("right into this really COOL adventure game!\n");
 	wordWrap("\n");
 	wordWrap("                    ");
+	addInput();
 	wordWrap("\n");
-
-	// TODO: Rest of setup
 }
 
 bool CopyProtectionDialog::show() {


Commit: 8c9420a8349b0cdb93dcace36c2bd5f93e03476f
    https://github.com/scummvm/scummvm/commit/8c9420a8349b0cdb93dcace36c2bd5f93e03476f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-23T19:33:26-05:00

Commit Message:
MADS: Added game initialisation code

Changed paths:
  A engines/mads/scene.cpp
  A engines/mads/scene.h
    engines/mads/dialogs.cpp
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/module.mk
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/game_nebular.h



diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index c6049c3..34a0b86 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -285,15 +285,16 @@ void TextDialog::draw() {
 }
 
 void TextDialog::drawWithInput() {
-	int innerWidth = _innerWidth;
-	int lineHeight = _vm->_font->getHeight() + 1;
-	int xp = _position.x + 5;
+	//int innerWidth = _innerWidth;
+	//int lineHeight = _vm->_font->getHeight() + 1;
+	//int xp = _position.x + 5;
 
 	// Draw the content of the dialog
 	drawContent(Common::Rect(_position.x + 2, _position.y + 2,
 		_position.x + _width - 2, _position.y + _height - 2), 0,
 		TEXTDIALOG_CONTENT1, TEXTDIALOG_CONTENT2);
-
+	
+	error("TODO: drawWithInput");
 }
 
 void TextDialog::restorePalette() {
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 89d1560..23d2e72 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -42,7 +42,7 @@ EventsManager::EventsManager(MADSEngine *vm) {
 }
 
 EventsManager::~EventsManager() {
-	delete _cursorSprites;
+	freeCursors();
 }
 
 void EventsManager::loadCursors(const Common::String &spritesName) {
@@ -68,8 +68,22 @@ void EventsManager::hideCursor() {
 	CursorMan.showMouse(false);
 }
 
+void EventsManager::resetCursor() {
+	CursorType cursorId = (CursorType)MIN(_cursorSprites->getCount(), (int)CURSOR_WAIT);
+	_newCursorId = cursorId;
+	if (_cursorId != _newCursorId) {
+		changeCursor();
+		_cursorId = _newCursorId;
+	}
+}
+
 void EventsManager::changeCursor() {
+	warning("TODO: changeCursor");
+}
 
+void EventsManager::freeCursors() {
+	delete _cursorSprites;
+	_cursorSprites = nullptr;
 }
 
 void EventsManager::pollEvents() {
diff --git a/engines/mads/events.h b/engines/mads/events.h
index 4705e62..01f4817 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -93,6 +93,16 @@ public:
 	void hideCursor();
 
 	/**
+	 * Resets the cursor, if necessary
+	 */
+	void resetCursor();
+
+	/**
+	 * Free currently loaded cursors
+	 */
+	void freeCursors();
+
+	/**
 	 * Poll any pending events
 	 */
 	void pollEvents();
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 774ec98..aa0d1dc 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -26,6 +26,7 @@
 #include "mads/nebular/game_nebular.h"
 #include "mads/graphics.h"
 #include "mads/msurface.h"
+#include "mads/resources.h"
 
 namespace MADS {
 
@@ -38,15 +39,66 @@ Game *Game::init(MADSEngine *vm) {
 
 Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr) {
 	_sectionNumber = _priorSectionNumber = 0;
+	_difficultyLevel = DIFFICULTY_HARD;
+	_saveSlot = -1;
+	_statusFlag = 0;
+	_sectionHandler = nullptr;
 }
 
 Game::~Game() {
 	delete _surface;
+	delete _sectionHandler;
 }
 
 void Game::run() {
-	if (!checkCopyProtection())
-		return;
+	int protectionResult = checkCopyProtection();
+	switch (protectionResult) {
+	case 1:
+		// Copy protection failed
+		_scene._nextSceneId = 804;
+		initialiseGlobals();
+		_globalFlags[5] = 0xFFFF;
+		_saveSlot = -1;
+		break;
+	case 2:
+		_statusFlag = 0;
+		break;
+	default:
+		break;
+	}
+
+	if (_saveSlot == -1 && protectionResult != -1 && protectionResult != -2) {
+		initSection(_scene._sectionNum);
+		_statusFlag = _scene._sectionNum != 1;
+		_pendingDialog = DIALOG_DIFFICULTY;
+
+		showDialog();
+		_pendingDialog = DIALOG_NONE;
+
+		_vm->_events->freeCursors();
+		_scene._priorSectionNum = 0;
+		_scene._priorSceneId = 0;
+		_scene._sectionNum2 = -1;
+		_scene._currentSceneId = -1;
+	}
+
+	if (protectionResult != 1 && protectionResult != 2) {
+		initialiseGlobals();
+
+		if (_saveSlot != -1) {
+			warning("TODO: loadGame(\"REX.SAV\", 210)");
+			_statusFlag = false;
+		}
+	}
+
+	if (_statusFlag)
+		gameLoop();
+}
+
+void Game::gameLoop() {
+	setSectionHandler();
+
+	// TODO: More stuff
 }
 
 void Game::initSection(int sectionNumber) {
@@ -61,4 +113,73 @@ void Game::initSection(int sectionNumber) {
 		CURSOR_ARROW : CURSOR_WAIT);
 }
 
+void Game::loadObjects() {
+	File f("*OBJECTS.DAT");
+
+	// Get the total numer of inventory objects
+	int count = f.readUint16LE();
+	_objects.reserve(count);
+
+	// Read in each object
+	for (int i = 0; i < count; ++i) {
+		InventoryObject obj;
+		obj.load(f);
+		_objects.push_back(obj);
+
+		// If it's for the player's inventory, add the index to the inventory list
+		if (obj._roomNumber == PLAYER_INVENTORY) {
+			_inventoryList.push_back(i);
+			assert(_inventoryList.size() <= 32);
+		}
+	}
+}
+
+void Game::setObjectData(int objIndex, int id, const byte *p) {
+	// TODO: This whole method seems weird. Check it out more thoroughly once
+	// more of the engine is implemented
+	for (int i = 0; i < (int)_objects.size(); ++i) {
+		InventoryObject &obj = _objects[i];
+		if (obj._vocabList[0]._actionFlags1 <= i)
+			break;
+
+		if (obj._mutilateString[6 + i] == id) {
+			_objects[objIndex]._objFolder = p;
+		}
+	}
+}
+
+void Game::setObjectRoom(int objectId, int roomNumber) {
+	warning("TODO: setObjectRoom");
+}
+
+void Game::loadResourceSequence(const Common::String prefix, int v) {
+	warning("TODO: loadResourceSequence");
+}
+
+/*------------------------------------------------------------------------*/
+
+void InventoryObject::load(Common::SeekableReadStream &f) {
+	_descId = f.readUint16LE();
+	_roomNumber = f.readUint16LE();
+	_article = f.readByte();
+	_vocabCount = f.readByte();
+	
+	for (int i = 0; i < 3; ++i) {
+		_vocabList[i]._actionFlags1 = f.readByte();
+		_vocabList[i]._actionFlags2 = f.readByte();
+		_vocabList[i]._vocabId = f.readByte();
+	}
+
+	f.skip(4);	// field12
+	f.read(&_mutilateString[0], 10);
+	f.skip(16);
+}
+
+/*------------------------------------------------------------------------*/
+
+Player::Player() {
+	_direction = 8;
+	_newDirection = 8;
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/game.h b/engines/mads/game.h
index bb15a8e..9dd7ca0 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -24,28 +24,136 @@
 #define MADS_GAME_H
 
 #include "common/scummsys.h"
+#include "mads/scene.h"
 
 namespace MADS {
 
 class MADSEngine;
 
+enum {
+	PLAYER_INVENTORY = 2
+};
+
+enum Difficulty {
+	DIFFICULTY_HARD = 1, DIFFICULTY_MEDIUM = 2, DIFFICULTY_EASY = 3
+};
+
+enum DialogId {
+	DIALOG_NONE = 0, DIALOG_GAME_MENU = 1, DIALOG_SAVE = 2, DIALOG_RESTORE = 3,
+	DIALOG_OPTIONS = 4, DIALOG_DIFFICULTY = 5, DIALOG_ERROR = 6
+};
+
+class InventoryObject {
+public:
+	int _descId;
+	int _roomNumber;
+	int _article;
+	int _vocabCount;
+	struct {
+		int _actionFlags1;
+		int _actionFlags2;
+		int _vocabId;
+	} _vocabList[3];
+	char _mutilateString[10];	// ???
+	const byte *_objFolder;		// ???
+
+	/**
+	 * Loads the data for a given object
+	 */
+	void load(Common::SeekableReadStream &f);
+};
+
+class Player {
+public:
+	int _direction;
+	int _newDirection;
+public:
+	Player();
+};
+
+class SectionHandler {
+protected:
+	MADSEngine *_vm;
+public:
+	SectionHandler(MADSEngine *vm): _vm(vm) {}
+
+	virtual void loadSection() = 0;
+	virtual void sectionPtr2() = 0;
+	virtual void sectionPtr3() = 0;
+};
+
 class Game {
+private:
+	/**
+	 * Main game loop
+	 */
+	void gameLoop();
 protected:
 	MADSEngine *_vm;
 	MSurface *_surface;
+	Difficulty _difficultyLevel;
+	Common::Array<uint16> _globalFlags;
+	Common::Array<InventoryObject> _objects;
+	Common::Array<int> _inventoryList;
+	Player _player;
+	Scene _scene;
+	int _saveSlot;
+	int _statusFlag;
+	DialogId _pendingDialog;
+
+	SectionHandler *_sectionHandler;
 
+	/**
+	 * Constructor
+	 */
 	Game(MADSEngine *vm);
 
 	/**
-	 * Perform any copy protection check
+	 * Loads the game's object list
+	 */
+	void loadObjects();
+
+	/**
+	 * Set the associated data? pointer with an inventory object
 	 */
-	virtual bool checkCopyProtection() = 0;
+	void setObjectData(int objIndex, int id, const byte *p);
+
+	/**
+	 * Sets the room number
+	 */
+	void setObjectRoom(int objectId, int roomNumber);
 
 	/**
 	 * Initialises the current section number of the game
 	 */
 	void initSection(int sectionNumber);
 
+	void loadResourceSequence(const Common::String prefix, int v);
+
+	//@{
+	/** @name Virtual Method list */
+
+	/**
+	 * Perform any copy protection check
+	 */
+	virtual int checkCopyProtection() = 0;
+
+	/**
+	 * Initialises global variables for a new game
+	 */
+	virtual void initialiseGlobals() = 0;
+
+	/**
+	 * Show a game dialog
+	 */
+	virtual void showDialog() = 0;
+
+	/**
+	 * Set up the section handler specific to each section
+	 */
+	virtual void setSectionHandler() = 0;
+	//@}
+
 public:
 	static Game *init(MADSEngine *vm);
 public:
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 0b5f4c7..9219d04 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -18,6 +18,7 @@ MODULE_OBJS := \
 	msurface.o \
 	palette.o \
 	resources.o \
+	scene.o \
 	sound.o \
 	user_interface.o
 
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index bf52af3..2e27eae 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -37,15 +37,153 @@ GameNebular::GameNebular(MADSEngine *vm): Game(vm) {
 	_surface =MSurface::init(MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT);
 }
 
-bool GameNebular::checkCopyProtection() {
+int GameNebular::checkCopyProtection() {
 	if (!ConfMan.getBool("copy_protection"))
 		return true;
 
+	/* DEBUG: Disabled for now
 	CopyProtectionDialog *dlg = new CopyProtectionDialog(_vm, false);
 	dlg->show();
 	delete dlg;
+	*/
 
-	return false;
+	// DEBUG: Return that copy protection failed
+	return 1;
+}
+
+void GameNebular::initialiseGlobals() {
+	// Allocate globals space
+	_globalFlags.resize(210);
+	for (int i = 0; i < 210; ++i)
+		_globalFlags[i] = 0;
+
+	// Set specific values needed by the game
+	_globalFlags[4] = 8;
+	_globalFlags[33] = 1;
+	_globalFlags[10] = 0xFFFF;
+	_globalFlags[13] = 0xFFFF;
+	_globalFlags[15] = 0xFFFF;
+	_globalFlags[19] = 0xFFFF;
+	_globalFlags[20] = 0xFFFF;
+	_globalFlags[21] = 0xFFFF;
+	_globalFlags[95] = 0xFFFF;
+
+	setObjectData(3, 17, nullptr);
+
+	// Put the values 0 through 3 in a random order in global slots 83 to 86
+	for (int i = 0; i < 4;) {
+		int randomVal = _vm->getRandomNumber(3);
+		_globalFlags[83 + i] = randomVal;
+
+		bool flag = false;
+		for (int idx2 = 0; idx2 < i; ++idx2) {
+			if (_globalFlags[83 + idx2] == randomVal)
+				flag = true;
+		}
+
+		if (!flag)
+			++i;
+	}
+
+	// Put the values 0 through 3 in a random order in global slots 87 to 90
+	for (int i = 0; i < 4;) {
+		int randomVal = _vm->getRandomNumber(3);
+		_globalFlags[87 + i] = randomVal;
+
+		bool flag = false;
+		for (int idx2 = 0; idx2 < i; ++idx2) {
+			if (_globalFlags[87 + idx2] == randomVal)
+				flag = true;
+		}
+
+		if (!flag)
+			++i;
+	}
+
+	_globalFlags[120] = 501;
+	_globalFlags[121] = 0xFFFF;
+	_globalFlags[55] = 0xFFFF;
+	_globalFlags[119] = 1;
+	_globalFlags[134] = 4;
+
+	// Fill out the globals 200 to 209 with unique random values less than 10000
+	for (int i = 0; i < 10; ++i) {
+		int randomVal = _vm->getRandomNumber(9999);
+		_globalFlags[200 + i] = randomVal;
+
+		bool flag = false;
+		for (int idx2 = 0; idx2 < i; ++idx2) {
+			if (_globalFlags[200 + idx2] == randomVal)
+				flag = true;
+		}
+
+		if (!flag)
+			++i;
+	}
+
+	// Difficulty level control
+	switch (_difficultyLevel) {
+	case DIFFICULTY_HARD:
+		_globalFlags[35] = 0;
+		setObjectRoom(9, 1);
+		setObjectRoom(50, 1);
+		_globalFlags[137] = 5;
+		_globalFlags[136] = 0;
+		break;
+	case DIFFICULTY_MEDIUM:
+		_globalFlags[35] = 0;
+		setObjectRoom(8, 1);
+		_globalFlags[137] = 0xFFFF;
+		_globalFlags[136] = 6;
+		break;
+	case DIFFICULTY_EASY:
+		_globalFlags[35] = 2;
+		setObjectRoom(8, 1);
+		setObjectRoom(27, 1);
+		break;
+	default:
+		break;
+	}
+
+	_player._direction = 8;
+	_player._newDirection = 8;
+
+	loadResourceSequence("RXM", 1);
+	loadResourceSequence("ROX", 1);
+}
+
+void GameNebular::showDialog() {
+	warning("TODO: showDialog");
+}
+
+void GameNebular::setSectionHandler() {
+	delete _sectionHandler;
+
+	switch (_scene._sectionNum) {
+	case 1:
+		_sectionHandler = new Section1Handler(_vm);
+		break;
+	case 2:
+		_sectionHandler = new Section2Handler(_vm);
+		break;
+	case 3:
+		_sectionHandler = new Section3Handler(_vm);
+		break;
+	case 4:
+		_sectionHandler = new Section4Handler(_vm);
+		break;
+	case 5:
+		_sectionHandler = new Section5Handler(_vm);
+		break;
+	case 6:
+		_sectionHandler = new Section6Handler(_vm);
+		break;
+	case 7:
+		_sectionHandler = new Section7Handler(_vm);
+		break;
+	default:
+		break;
+	}
 }
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index b0f088f..b7f47aa 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -35,9 +35,35 @@ class GameNebular: public Game {
 protected:
 	GameNebular(MADSEngine *vm);
 
-	virtual bool checkCopyProtection();
+	virtual int checkCopyProtection();
+
+	virtual void initialiseGlobals();
+
+	virtual void showDialog();
+
+	virtual void setSectionHandler();
 };
 
+
+class Section1Handler: public SectionHandler {
+public:
+	Section1Handler(MADSEngine *vm): SectionHandler(vm) {}
+
+	// TODO: Properly implement handler methods
+	virtual void loadSection() {}
+	virtual void sectionPtr2() {}
+	virtual void sectionPtr3() {}
+};
+
+// TODO: Properly implement handler classes
+typedef Section1Handler Section2Handler;
+typedef Section1Handler Section3Handler;
+typedef Section1Handler Section4Handler;
+typedef Section1Handler Section5Handler;
+typedef Section1Handler Section6Handler;
+typedef Section1Handler Section7Handler;
+
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
new file mode 100644
index 0000000..f6bbf32
--- /dev/null
+++ b/engines/mads/scene.cpp
@@ -0,0 +1,37 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "mads/scene.h"
+
+namespace MADS {
+
+Scene::Scene() {
+	_sectionNum = 1;
+	_sectionNum2 = -1;
+	_priorSectionNum = 0;
+	_priorSceneId = 0;
+	_nextSceneId = 0;
+	_currentSceneId = 0;
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
new file mode 100644
index 0000000..a5359a9
--- /dev/null
+++ b/engines/mads/scene.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_SCENE_H
+#define MADS_SCENE_H
+
+#include "common/scummsys.h"
+
+namespace MADS {
+
+class Scene {
+public:
+	int _priorSectionNum;
+	int _sectionNum;
+	int _sectionNum2;
+	int _priorSceneId;
+	int _nextSceneId;
+	int _currentSceneId;
+	
+	Scene();
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_SCENE_H */


Commit: 8ee283d921ec88bad61469e136a31aef0ff5b9ca
    https://github.com/scummvm/scummvm/commit/8ee283d921ec88bad61469e136a31aef0ff5b9ca
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-23T21:34:20-05:00

Commit Message:
MADS: Implemented sound player logic and outer game loop

Changed paths:
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/nebular/game_nebular.h
    engines/mads/palette.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/sound.cpp
    engines/mads/sound.h



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index aa0d1dc..3acbd41 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -43,6 +43,7 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr) {
 	_saveSlot = -1;
 	_statusFlag = 0;
 	_sectionHandler = nullptr;
+	_v1 = _v2 = 0;
 }
 
 Game::~Game() {
@@ -96,9 +97,30 @@ void Game::run() {
 }
 
 void Game::gameLoop() {
-	setSectionHandler();
+	while (!_vm->shouldQuit() && _statusFlag) {
+		setSectionHandler();
+		_sectionHandler->preLoadSection();
+		initSection(_scene._sectionNum);
+		_sectionHandler->postLoadSection();
+
+		_scene.clearSprites(true);
+
+		if (_scene._sectionNum == _scene._sectionNum2) {
+			sectionLoop();
+		}
+
+		// TODO: Extra reset methods
+		_vm->_events->resetCursor();
+		_vm->_events->freeCursors();
+		_vm->_sound->closeDriver();
+
+	}
+
+	_vm->_palette->close();
+}
+
+void Game::sectionLoop() {
 
-	// TODO: More stuff
 }
 
 void Game::initSection(int sectionNumber) {
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 9dd7ca0..4a8daed 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -77,9 +77,9 @@ protected:
 public:
 	SectionHandler(MADSEngine *vm): _vm(vm) {}
 
-	virtual void loadSection() = 0;
+	virtual void preLoadSection() = 0;
 	virtual void sectionPtr2() = 0;
-	virtual void sectionPtr3() = 0;
+	virtual void postLoadSection() = 0;
 };
 
 class Game {
@@ -88,6 +88,11 @@ private:
 	 * Main game loop
 	 */
 	void gameLoop();
+
+	/**
+	 * Inner game loop for executing gameplay within a game section
+	 */
+	void sectionLoop();
 protected:
 	MADSEngine *_vm;
 	MSurface *_surface;
@@ -100,8 +105,9 @@ protected:
 	int _saveSlot;
 	int _statusFlag;
 	DialogId _pendingDialog;
-
 	SectionHandler *_sectionHandler;
+	int _v1;
+	int _v2;
 
 	/**
 	 * Constructor
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index b7f47aa..31bd4ae 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -50,9 +50,9 @@ public:
 	Section1Handler(MADSEngine *vm): SectionHandler(vm) {}
 
 	// TODO: Properly implement handler methods
-	virtual void loadSection() {}
+	virtual void preLoadSection() {}
 	virtual void sectionPtr2() {}
-	virtual void sectionPtr3() {}
+	virtual void postLoadSection() {}
 };
 
 // TODO: Properly implement handler classes
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 9a4e451..b5588fe 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -178,6 +178,13 @@ public:
 	 */
 	void setLowRange();
 
+	/**
+	 * Set up the palette as the game ends
+	 */
+	void close() {
+		warning("TODO: Palette::close");
+	}
+
 	// Color indexes
 	uint8 BLACK;
 	uint8 BLUE;
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index f6bbf32..cf7ba6c 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -34,4 +34,44 @@ Scene::Scene() {
 	_currentSceneId = 0;
 }
 
+void Scene::clearSprites(bool flag) {
+	for (int i = 0; i < TEXT_DISPLAY_COUNT; ++i)
+		_textDisplay[i]._active = false;
+
+	if (flag)
+		_spriteList.clear();
+
+	_spriteSlots.clear();
+	_spriteSlots.push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1));
+}
+
+/*------------------------------------------------------------------------*/
+
+SpriteSlot::SpriteSlot() {
+	_spriteType = ST_NONE;
+	_seqIndex = 0;
+	_spriteListIndex = 0;
+	_frameNumber = 0;
+	_depth = 0;
+	_scale = 0;
+}
+
+SpriteSlot::SpriteSlot(SpriteType type, int seqIndex) {
+	_spriteType = type;
+	_seqIndex = seqIndex;
+	_spriteListIndex = 0;
+	_frameNumber = 0;
+	_depth = 0;
+	_scale = 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+TextDisplay::TextDisplay() {
+	_active = false;
+	_spacing = 0;
+	_expire = 0;
+	_col1 = _col2 = 0;
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index a5359a9..e2afd08 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -24,9 +24,47 @@
 #define MADS_SCENE_H
 
 #include "common/scummsys.h"
+#include "common/array.h"
+#include "common/rect.h"
 
 namespace MADS {
 
+enum SpriteType {
+	ST_NONE = 0, ST_FOREGROUND = 1, ST_BACKGROUND = -4, 
+	ST_FULL_SCREEN_REFRESH = -2, ST_EXPIRED = -1
+};
+
+class SpriteSlot {
+public:
+	SpriteType _spriteType;
+	int _seqIndex;
+	int _spriteListIndex;
+	int _frameNumber;
+	Common::Point _position;
+	int _depth;
+	int _scale;
+public:
+	SpriteSlot();
+	SpriteSlot(SpriteType type, int seqIndex);
+};
+
+class TextDisplay {
+public:
+	bool _active;
+	int _spacing;
+	Common::Rect _bounds;
+	int _expire;
+	int _col1;
+	int _col2;
+	Common::String _fontName;
+	Common::String _msg;
+
+	TextDisplay();
+};
+
+#define SPRITE_COUNT 50
+#define TEXT_DISPLAY_COUNT 40
+
 class Scene {
 public:
 	int _priorSectionNum;
@@ -35,8 +73,21 @@ public:
 	int _priorSceneId;
 	int _nextSceneId;
 	int _currentSceneId;
-	
+	TextDisplay _textDisplay[TEXT_DISPLAY_COUNT];
+	Common::Array<SpriteSlot> _spriteSlots;
+	Common::Array<int> _spriteList;
+	int _spriteListIndex;
+
+	/**
+	 * Constructor
+	 */
 	Scene();
+
+	/**
+	 * Initialise the sprite data
+	 * @param flag		Also reset sprite list
+	 */
+	void clearSprites(bool flag);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index 46ba997..8608abf 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -24,29 +24,89 @@
 #include "audio/decoders/raw.h"
 #include "common/memstream.h"
 #include "mads/sound.h"
+#include "mads/mads.h"
+#include "mads/nebular/sound_nebular.h"
 
 namespace MADS {
 
 SoundManager::SoundManager(MADSEngine *vm, Audio::Mixer *mixer) {
 	_vm = vm;
 	_mixer = mixer;
-	_asound = nullptr;
+	_driver = nullptr;
+	_pollSoundEnabled = false;
+	_soundPollFlag = false;
+	_newSoundsPaused = false;
 }
 
 SoundManager::~SoundManager() {
-	delete _asound;
+	delete _driver;
 }
 
-void SoundManager::test() {
-	_asound = new Nebular::ASound1(_mixer);
-	_asound->command(5);
-	_asound->command(28);
-	_asound->command(19);
+void SoundManager::init(int sectionNumber) {
+	assert(sectionNumber > 0 && sectionNumber < 10);
+
+	switch (_vm->getGameID()) {
+	case GType_RexNebular:
+		// TODO: Other Rex Adlib section drivers
+		assert(sectionNumber == 1);
+		_driver = new Nebular::ASound1(_mixer);
+		break;
+
+	default:
+		error("Unknown game");
+	}
+}
+
+void SoundManager::closeDriver() {
+	if (_driver) {
+		command(0);
+		setEnabled(false);
+		stop();
+
+		removeDriver();
+	}
+}
+
+void SoundManager::removeDriver() {
+	delete _driver;
+	_driver = nullptr;
+}
+
+void SoundManager::setEnabled(bool flag) {
+	_pollSoundEnabled = flag;
+	_soundPollFlag = false;
+}
+
+void SoundManager::queueNewCommands() {
+	_newSoundsPaused = true;
+}
+
+void SoundManager::startQueuedCommands() {
+	_newSoundsPaused = false;
+
+	while (!_queuedCommands.empty()) {
+		int commandId = _queuedCommands.front();
+		command(commandId);
+	}
+}
+
+void SoundManager::command(int commandId, int param) {
+	if (_newSoundsPaused) {
+		if (_queuedCommands.size() < 8)
+			_queuedCommands.push(commandId);
+	} else if (_driver) {
+		_driver->command(commandId, param);
+	}
+}
+
+void SoundManager::stop() {
+	if (_driver)
+		_driver->stop();
 }
 
-void SoundManager::poll() {
-	if (_asound)
-		_asound->poll();
+void SoundManager::noise() {
+	if (_driver)
+		_driver->noise();
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/sound.h b/engines/mads/sound.h
index 7a9a4ef..51213f0 100644
--- a/engines/mads/sound.h
+++ b/engines/mads/sound.h
@@ -24,6 +24,7 @@
 #define MADS_SOUND_H
 
 #include "common/scummsys.h"
+#include "common/queue.h"
 #include "audio/audiostream.h"
 #include "audio/mixer.h"
 #include "mads/nebular/sound_nebular.h"
@@ -36,13 +37,65 @@ class SoundManager {
 private:
 	MADSEngine *_vm;
 	Audio::Mixer *_mixer;
-	Nebular::ASound *_asound;
+	Nebular::ASound *_driver;
+	bool _pollSoundEnabled;
+	bool _soundPollFlag;
+	bool _newSoundsPaused;
+	Common::Queue<int> _queuedCommands;
 public:
 	SoundManager(MADSEngine *vm, Audio::Mixer *mixer);
 	~SoundManager();
-	
-	void test();
-	void poll();
+
+	/**
+	 * Initialises the sound driver for a given game section
+	 */
+	void init(int sectionNumber);
+
+	/**
+	 * Stop any currently active sound and remove the driver
+	 */
+	void closeDriver();
+
+	/**
+	 * Remove the driver
+	 */
+	void removeDriver();
+
+	/**
+	 * Sets the enabled status of the sound
+	 * @flag		True if sound should be enabled
+	 */
+	void setEnabled(bool flag);
+
+	/**
+	 * Temporarily pause the playback of any new sound commands
+	 */
+	void queueNewCommands();
+
+	/**
+	 * Stop queueing sound commands, and execute any previously queued ones
+	 */
+	void startQueuedCommands();
+
+	//@{
+	/**
+	 * Executes a command on the sound driver
+	 * @param commandid		Command Id to execute
+	 * @param param			Optional paramater specific to a few commands
+	 */
+	void command(int commandId, int param = 0);
+
+	/**
+	 * Stops any currently playing sound
+	 */
+	void stop();
+
+	/**
+	 * Noise
+	 * Some sort of random noise generation?
+	 */
+	void noise();
+	//@}
 };
 
 } // End of namespace MADS


Commit: 37b788b7ddb679f32653be326ae96ad9132feb1f
    https://github.com/scummvm/scummvm/commit/37b788b7ddb679f32653be326ae96ad9132feb1f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-24T00:20:53-05:00

Commit Message:
MADS: Added skeleton framework for game scene classes

Changed paths:
  A engines/mads/nebular/nebular_scenes.cpp
  A engines/mads/nebular/nebular_scenes.h
  A engines/mads/nebular/nebular_scenes8.cpp
  A engines/mads/nebular/nebular_scenes8.h
    engines/mads/dialogs.cpp
    engines/mads/dialogs.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/module.mk
    engines/mads/palette.cpp
    engines/mads/palette.h
    engines/mads/scene.cpp
    engines/mads/scene.h



diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index 34a0b86..fd42eb5 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -329,4 +329,16 @@ void MessageDialog::show() {
 	}
 }
 
+/*------------------------------------------------------------------------*/
+
+Dialogs *Dialogs::init(MADSEngine *vm) {
+	if (vm->getGameID() == GType_RexNebular)
+		return new Dialogs(vm);
+
+	error("Unknown game");
+}
+
+Dialogs::Dialogs(MADSEngine *vm): _vm(vm) {
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index 0945ad9..f77590d 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -168,6 +168,23 @@ public:
 	void show();
 };
 
+enum DialogId {
+	DIALOG_NONE = 0, DIALOG_GAME_MENU = 1, DIALOG_SAVE = 2, DIALOG_RESTORE = 3,
+	DIALOG_OPTIONS = 4, DIALOG_DIFFICULTY = 5, DIALOG_ERROR = 6
+};
+
+class Dialogs {
+private:
+	MADSEngine *_vm;
+
+	Dialogs(MADSEngine *vm);
+public:
+	static Dialogs *init(MADSEngine *vm);
+public:
+	Common::Point _defaultPosition;
+	DialogId _pendingDialog;
+};
+
 } // End of namespace MADS
 
 #endif /* MADS_DIALOGS_H */
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 3acbd41..14dbcde 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -37,13 +37,15 @@ Game *Game::init(MADSEngine *vm) {
 	return nullptr;
 }
 
-Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr) {
+Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _scene(vm) {
 	_sectionNumber = _priorSectionNumber = 0;
 	_difficultyLevel = DIFFICULTY_HARD;
 	_saveSlot = -1;
 	_statusFlag = 0;
 	_sectionHandler = nullptr;
 	_v1 = _v2 = 0;
+	_v3 = _v4 = 0;
+	_v5 = _v6 = 0;
 }
 
 Game::~Game() {
@@ -71,15 +73,15 @@ void Game::run() {
 	if (_saveSlot == -1 && protectionResult != -1 && protectionResult != -2) {
 		initSection(_scene._sectionNum);
 		_statusFlag = _scene._sectionNum != 1;
-		_pendingDialog = DIALOG_DIFFICULTY;
+		_vm->_dialogs->_pendingDialog = DIALOG_DIFFICULTY;
 
 		showDialog();
-		_pendingDialog = DIALOG_NONE;
+		_vm->_dialogs->_pendingDialog = DIALOG_NONE;
 
 		_vm->_events->freeCursors();
 		_scene._priorSectionNum = 0;
 		_scene._priorSceneId = 0;
-		_scene._sectionNum2 = -1;
+		_scene._sectionNumPrior = -1;
 		_scene._currentSceneId = -1;
 	}
 
@@ -105,7 +107,7 @@ void Game::gameLoop() {
 
 		_scene.clearSprites(true);
 
-		if (_scene._sectionNum == _scene._sectionNum2) {
+		if (_scene._sectionNum == _scene._sectionNumPrior) {
 			sectionLoop();
 		}
 
@@ -113,14 +115,47 @@ void Game::gameLoop() {
 		_vm->_events->resetCursor();
 		_vm->_events->freeCursors();
 		_vm->_sound->closeDriver();
-
 	}
 
 	_vm->_palette->close();
 }
 
 void Game::sectionLoop() {
-
+	while (!_vm->shouldQuit() && _statusFlag && _scene._sectionNum == _scene._sectionNumPrior) {
+
+		if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globalFlags[5]) {
+			_v1 = 3;
+			_player._spritesChanged = true;
+			_v5 = 0;
+			_v6 = 0;
+			_vm->_events->resetCursor();
+
+			_quotes = nullptr;
+			_scene.clearVocab();
+			_scene.loadScene();
+
+			_v4 = 0;
+			_player._stepEnabled = true;
+			_player._visible = true;
+			_vm->_dialogs->_defaultPosition = Common::Point(-1, -1);
+			_scene.addVisitedScene(_scene._nextSceneId);
+
+			// TODO: main section loop logic goes here
+
+			// Clear the scene
+			_scene.free();
+			_scene._sectionNum = _scene._nextSceneId / 100;
+
+			// TODO: sub_1DD46(3)
+
+			// Check whether to show a dialog
+			if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globalFlags[5]) {
+				_scene.releasePlayerSprites();
+				showDialog();
+				_vm->_dialogs->_pendingDialog = DIALOG_NONE;
+			}
+		}
+	}
 }
 
 void Game::initSection(int sectionNumber) {
@@ -202,6 +237,10 @@ void InventoryObject::load(Common::SeekableReadStream &f) {
 Player::Player() {
 	_direction = 8;
 	_newDirection = 8;
+	_spritesLoaded = false;
+	_spriteListStart = _numSprites = 0;
+	_stepEnabled = false;
+	_visible = false;
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 4a8daed..58b6ff9 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -38,11 +38,6 @@ enum Difficulty {
 	DIFFICULTY_HARD = 1, DIFFICULTY_MEDIUM = 2, DIFFICULTY_EASY = 3
 };
 
-enum DialogId {
-	DIALOG_NONE = 0, DIALOG_GAME_MENU = 1, DIALOG_SAVE = 2, DIALOG_RESTORE = 3,
-	DIALOG_OPTIONS = 4, DIALOG_DIFFICULTY = 5, DIALOG_ERROR = 6
-};
-
 class InventoryObject {
 public:
 	int _descId;
@@ -67,6 +62,12 @@ class Player {
 public:
 	int _direction;
 	int _newDirection;
+	bool _spritesLoaded;
+	int _spriteListStart;
+	int _numSprites;
+	bool _stepEnabled;
+	bool _spritesChanged;
+	bool _visible;
 public:
 	Player();
 };
@@ -76,6 +77,7 @@ protected:
 	MADSEngine *_vm;
 public:
 	SectionHandler(MADSEngine *vm): _vm(vm) {}
+	virtual ~SectionHandler() {}
 
 	virtual void preLoadSection() = 0;
 	virtual void sectionPtr2() = 0;
@@ -104,10 +106,14 @@ protected:
 	Scene _scene;
 	int _saveSlot;
 	int _statusFlag;
-	DialogId _pendingDialog;
 	SectionHandler *_sectionHandler;
 	int _v1;
 	int _v2;
+	int _v3;
+	int _v4;
+	int _v5;
+	int _v6;
+	byte *_quotes;
 
 	/**
 	 * Constructor
@@ -172,6 +178,8 @@ public:
 	 * Run the game
 	 */
 	void run();
+
+	Player &player() { return _player; }
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 3a121d0..db73ec7 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -43,6 +43,7 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :
 	_textWindowStill = false;
 
 	_debugger = nullptr;
+	_dialogs = nullptr;
 	_events = nullptr;
 	_font = nullptr;
 	_game = nullptr;
@@ -55,6 +56,7 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :
 
 MADSEngine::~MADSEngine() {
 	delete _debugger;
+	delete _dialogs;
 	delete _events;
 	delete _font;
 	delete _game;
@@ -77,6 +79,7 @@ void MADSEngine::initialise() {
 
 	ResourcesManager::init(this);
 	_debugger = new Debugger(this);
+	_dialogs = Dialogs::init(this);
 	_events = new EventsManager(this);
 	_palette = new Palette(this);
 	_font = new Font(this);
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index 5166b7b..b3a05dc 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -31,6 +31,7 @@
 #include "engines/engine.h"
 #include "graphics/surface.h"
 #include "mads/debugger.h"
+#include "mads/dialogs.h"
 #include "mads/events.h"
 #include "mads/font.h"
 #include "mads/game.h"
@@ -88,6 +89,7 @@ protected:
 	virtual bool hasFeature(EngineFeature f) const;
 public:
 	Debugger *_debugger;
+	Dialogs *_dialogs;
 	EventsManager *_events;
 	Font *_font;
 	Game *_game;
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 9219d04..a729533 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -4,6 +4,8 @@ MODULE_OBJS := \
 	nebular/dialogs_nebular.o \
 	nebular/game_nebular.o \
 	nebular/sound_nebular.o \
+	nebular/nebular_scenes.o \
+	nebular/nebular_scenes8.o \
 	assets.o \
 	compression.o \
 	debugger.o \
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
new file mode 100644
index 0000000..efd831a
--- /dev/null
+++ b/engines/mads/nebular/nebular_scenes.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/scummsys.h"
+#include "common/config-manager.h"
+#include "mads/mads.h"
+#include "mads/scene.h"
+#include "mads/nebular/nebular_scenes.h"
+#include "mads/nebular/nebular_scenes8.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+SceneLogic *SceneFactory::createScene(Scene *scene) {
+	scene->addActiveVocab(NOUN_DROP);
+	scene->addActiveVocab(NOUN_DOLLOP);
+	scene->addActiveVocab(NOUN_DASH);
+	scene->addActiveVocab(NOUN_SPLASH);
+	scene->addActiveVocab(NOUN_ALCOHOL);
+
+	// TODO: Implement all the game scenes
+	assert(scene->_nextSceneId == 804);
+
+	return new Scene804(scene);
+}
+
+} // End of namespace Nebular
+
+} // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
new file mode 100644
index 0000000..28d24f0
--- /dev/null
+++ b/engines/mads/nebular/nebular_scenes.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_NEBULAR_SCENES_H
+#define MADS_NEBULAR_SCENES_H
+
+#include "common/scummsys.h"
+#include "mads/game.h"
+#include "mads/scene.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+enum Noun {
+	NOUN_BLOWGUN		= 0x29,
+	NOUN_BURGER			= 0x35,
+	NOUN_CHAIR			= 0x47,
+	NOUN_DEAD_FISH		= 0x65,
+	NOUN_DOOR			= 0x6E,
+	NOUN_EAT			= 0x75,
+	NOUN_EXAMINE		= 0x7D,
+	NOUN_FRONT_WINDOW	= 0x8E,
+	NOUN_FUZZY_DICE		= 0x91,
+	NOUN_HOSE_DOWN		= 0x0A6,
+	NOUN_HOTPANTS		= 0x0A7,
+	NOUN_HULL			= 0x0A8,
+	NOUN_HURL			= 0x0A9,
+	NOUN_IGNITE			= 0x0B4,
+	NOUN_INFLATE		= 0x0B5,
+	NOUN_INSERT			= 0x0B6,
+	NOUN_INSPECT		= 0x0B7,
+	NOUN_JUNGLE			= 0x0B8,
+	NOUN_LIFE_SUPPORT_SECTION  = 0x0CC,
+	NOUN_LOG			= 0x0D0,
+	NOUN_LOOK_AT		= 0x0D1,
+	NOUN_LOOK_IN		= 0x0D2,
+	NOUN_LOOK_THROUGH	= 0x0D3,
+	NOUN_MONKEY			= 0x0E3,
+	NOUN_OUTER_HULL		= 0x0F8,
+	NOUN_OUTSIDE		= 0x0F9,
+	NOUN_PEER_THROUGH	= 0x103,
+	NOUN_PLANT_STALK	= 0x10F,
+	NOUN_READ			= 0x11F,
+	NOUN_REFRIDGERATOR	= 0x122,
+	NOUN_ROBO_KITCHEN	= 0x127,
+	NOUN_SHIELD_ACCESS_PANEL  = 0x135,
+	NOUN_SHIELD_MODULATOR	= 0x137,
+	NOUN_SHOOT			= 0x13A,
+	NOUN_SIT_IN			= 0x13F,
+	NOUN_SMELL			= 0x147,
+	NOUN_STUFFED_FISH	= 0x157,
+	NOUN_VIEW_SCREEN	= 0x180,
+	NOUN_CAPTIVE_CREATURE	= 0x1C3,
+	NOUN_NATIVE_WOMAN	= 0x1DC,
+	NOUN_ALCOHOL		= 0x310,
+	NOUN_DOLLOP			= 0x3AC,
+	NOUN_DROP			= 0x3AD,
+	NOUN_DASH			= 0x3AE,
+	NOUN_SPLASH			= 0x3AF
+};
+
+class SceneFactory {
+public:
+	static SceneLogic *createScene(Scene *scene);
+};
+
+} // End of namespace Nebular
+
+} // End of namespace MADS
+
+#endif /* MADS_NEBULAR_SCENES_H */
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
new file mode 100644
index 0000000..8feabc8
--- /dev/null
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/scummsys.h"
+#include "mads/nebular/nebular_scenes8.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+void Scene804::setup() {
+}
+
+void Scene804::enter() {
+}
+
+void Scene804::step() {
+}
+
+void Scene804::preActions() {
+}
+
+void Scene804::actions() {
+}
+
+void Scene804::postActions() {
+}
+
+} // End of namespace Nebular
+
+} // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes8.h b/engines/mads/nebular/nebular_scenes8.h
new file mode 100644
index 0000000..11bb8b0
--- /dev/null
+++ b/engines/mads/nebular/nebular_scenes8.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_NEBULAR_SCENES8_H
+#define MADS_NEBULAR_SCENES8_H
+
+#include "common/scummsys.h"
+#include "mads/game.h"
+#include "mads/scene.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+class Scene804: public SceneLogic {
+public:
+	Scene804(Scene *scene): SceneLogic(scene) {}
+
+	virtual void setup();
+
+	virtual void enter();
+
+	virtual void step();
+
+	virtual void preActions();
+
+	virtual void actions();
+
+	virtual void postActions();
+};
+
+} // End of namespace Nebular
+
+} // End of namespace MADS
+
+#endif /* MADS_NEBULAR_SCENES8_H */
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 8ec43b9..5438c78 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -293,7 +293,7 @@ void Palette::initRange(byte *palette) {
 		int varE = vbx;
 		int var10 = vdx;
 		do {
-			int vdx = 0;
+			vdx = 0;
 			do {
 				int vcx = 0;
 				int var4 = vdx;
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index b5588fe..14cebc7 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -24,6 +24,7 @@
 #define MADS_PALETTE_H
 
 #include "common/scummsys.h"
+#include "common/stream.h"
 
 namespace MADS {
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index cf7ba6c..46190d1 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -22,16 +22,26 @@
 
 #include "common/scummsys.h"
 #include "mads/scene.h"
+#include "mads/mads.h"
+#include "mads/nebular/nebular_scenes.h"
 
 namespace MADS {
 
-Scene::Scene() {
+Scene::Scene(MADSEngine *vm): _vm(vm) {
 	_sectionNum = 1;
-	_sectionNum2 = -1;
+	_sectionNumPrior = -1;
 	_priorSectionNum = 0;
 	_priorSceneId = 0;
 	_nextSceneId = 0;
 	_currentSceneId = 0;
+	_vocabCount = 0;
+	_vocabBuffer = nullptr;
+	_sceneLogic = nullptr;
+}
+
+Scene::~Scene() {
+	delete[] _vocabBuffer;
+	delete _sceneLogic;
 }
 
 void Scene::clearSprites(bool flag) {
@@ -45,6 +55,86 @@ void Scene::clearSprites(bool flag) {
 	_spriteSlots.push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1));
 }
 
+/**
+ * Releases any sprites used by the player
+ */
+void Scene::releasePlayerSprites() {
+	Player &player = _vm->_game->player();
+
+	if (player._spritesLoaded && player._numSprites > 0) {
+		int spriteEnd = player._spriteListStart + player._numSprites - 1;
+		do {
+			deleteSpriteEntry(spriteEnd);
+		} while (--spriteEnd >= player._spriteListStart);
+	}
+}
+
+void Scene::deleteSpriteEntry(int listIndex) {
+	delete _spriteList[listIndex];
+	_spriteList.remove_at(listIndex);
+}
+
+void Scene::clearDynamicHotspots() {
+	_dynamicHotspots.clear();
+	_dynamicHotspotsChanged = false;
+}
+
+void Scene::clearVocab() {
+	freeVocab();
+	_vocabCount = 0;
+}
+
+void Scene::freeVocab() {
+	delete[] _vocabBuffer;
+	_vocabBuffer = nullptr;
+}
+
+void Scene::addActiveVocab(int vocabId) {
+	if (activeVocabIndexOf(vocabId) == -1) {
+		assert(_activeVocabs.size() < 200);
+		_activeVocabs.push_back(vocabId);
+	}
+}
+
+int Scene::activeVocabIndexOf(int vocabId) {
+	for (uint i = 0; i < _activeVocabs.size(); ++i) {
+		if (_activeVocabs[i] == vocabId)
+			return i;
+	}
+
+	return -1;
+}
+
+void Scene::addVisitedScene(int sceneId) {
+	if (!visitedScenesExists(sceneId))
+		_visitedScenes.push_back(sceneId);
+}
+
+bool Scene::visitedScenesExists(int sceneId) {
+	for (int i = 0; i < _visitedScenes.size(); ++i) {
+		if (_visitedScenes[i] == sceneId)
+			return true;
+	}
+
+	return false;
+}
+
+void Scene::loadScene() {
+	delete _sceneLogic;
+
+	switch (_vm->getGameID()) {
+	case GType_RexNebular:
+		_sceneLogic = Nebular::SceneFactory::createScene(this);
+		break;
+	default:
+		error("Unknown game");
+	}
+}
+
+void Scene::free() {
+	warning("TODO: Scene::free");
+}
+
 /*------------------------------------------------------------------------*/
 
 SpriteSlot::SpriteSlot() {
@@ -74,4 +164,15 @@ TextDisplay::TextDisplay() {
 	_col1 = _col2 = 0;
 }
 
+/*------------------------------------------------------------------------*/
+
+DynamicHotspot::DynamicHotspot() {
+	_seqIndex = 0;
+	_facing = 0;
+	_descId = 0;
+	_field14 = 0;
+	_articleNumber = 0;
+	_cursor = 0;
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index e2afd08..9f4f392 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -26,6 +26,7 @@
 #include "common/scummsys.h"
 #include "common/array.h"
 #include "common/rect.h"
+#include "mads/assets.h"
 
 namespace MADS {
 
@@ -62,32 +63,159 @@ public:
 	TextDisplay();
 };
 
+class DynamicHotspot {
+public:
+	int _seqIndex;
+	Common::Rect _bounds;
+	Common::Point _feetPos;
+	int _facing;
+	int _descId;
+	int _field14;
+	int _articleNumber;
+	int _cursor;
+
+	DynamicHotspot();
+};
+
 #define SPRITE_COUNT 50
 #define TEXT_DISPLAY_COUNT 40
+#define DYNAMIC_HOTSPOT_COUNT 8
+
+class MADSEngine;
+class Scene;
+
+class SceneLogic {
+protected:
+	Scene *_scene;
+public:
+	/**
+	 * Constructor
+	 */
+	SceneLogic(Scene *scene): _scene(scene) {}
+
+	/**
+	 * Called to initially setup a scene
+	 */
+	virtual void setup() = 0;
+
+	/**
+	 * Called as the scene is entered (made active)
+	 */
+	virtual void enter() = 0;
+
+	/**
+	 * Called one per frame
+	 */
+	virtual void step() = 0;
+
+	/**
+	 * Called before an action is started
+	 */
+	virtual void preActions() = 0;
+
+	/**
+	 * Handles scene actions
+	 */
+	virtual void actions() = 0;
+
+	/**
+	 * Post-action handling
+	 */
+	virtual void postActions() = 0;
+};
 
 class Scene {
+private:
+	/**
+	 * Free the voculary list buffer
+	 */
+	void freeVocab();
+
+	/**
+	 * Return the index of a given Vocab in the active vocab list
+	 */
+	int activeVocabIndexOf(int vocabId);
+
+	/**
+	 * Returns true if a given Scene Id exists in the listed of previously visited scenes.
+	 */
+	bool visitedScenesExists(int sceneId);
+protected:
+	MADSEngine *_vm;
 public:
+	SceneLogic *_sceneLogic;
 	int _priorSectionNum;
 	int _sectionNum;
-	int _sectionNum2;
+	int _sectionNumPrior;
 	int _priorSceneId;
 	int _nextSceneId;
 	int _currentSceneId;
 	TextDisplay _textDisplay[TEXT_DISPLAY_COUNT];
 	Common::Array<SpriteSlot> _spriteSlots;
-	Common::Array<int> _spriteList;
+	Common::Array<SpriteAsset *> _spriteList;
 	int _spriteListIndex;
+	Common::Array<DynamicHotspot> _dynamicHotspots;
+	bool _dynamicHotspotsChanged;
+	byte *_vocabBuffer;
+	int _vocabCount;
+	Common::Array<int> _activeVocabs;
+	Common::Array<int> _visitedScenes;
 
 	/**
 	 * Constructor
 	 */
-	Scene();
+	Scene(MADSEngine *vm);
+
+	/**
+	 * Destructor
+	 */
+	~Scene();
 
 	/**
 	 * Initialise the sprite data
 	 * @param flag		Also reset sprite list
 	 */
 	void clearSprites(bool flag);
+
+	/**
+	 * Delete any sprites used by the player
+	 */
+	void releasePlayerSprites();
+
+	/**
+	 * Delete a sprite entry
+	 */
+	void deleteSpriteEntry(int listIndex);
+
+	/**
+	 * Clear the dynamic hotspot list
+	 */
+	void clearDynamicHotspots();
+
+	/**
+	 * Clear the vocabulary list
+	 */
+	void clearVocab();
+
+	/**
+	 * Add a given vocab entry to the active list
+	 */
+	void addActiveVocab(int vocabId);
+
+	/**
+	 * Add a scene to the visited scene list if it doesn't already exist
+	 */
+	void addVisitedScene(int sceneId);
+
+	/**
+	 * Loads the scene logic for a given scene
+	 */
+	void loadScene();
+
+	/**
+	 * Clear the data for the scene
+	 */
+	void free();
 };
 
 } // End of namespace MADS


Commit: 4c867aa62fea19f2bff7d3aa632b340aae110306
    https://github.com/scummvm/scummvm/commit/4c867aa62fea19f2bff7d3aa632b340aae110306
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-24T00:38:49-05:00

Commit Message:
MADS: Shift some fields and methods to Dialogs and Game classes

Changed paths:
    engines/mads/dialogs.cpp
    engines/mads/dialogs.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/nebular/dialogs_nebular.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/game_nebular.h
    engines/mads/scene.cpp
    engines/mads/scene.h



diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index fd42eb5..c865e04 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -333,7 +333,7 @@ void MessageDialog::show() {
 
 Dialogs *Dialogs::init(MADSEngine *vm) {
 	if (vm->getGameID() == GType_RexNebular)
-		return new Dialogs(vm);
+		return new Nebular::DialogsNebular(vm);
 
 	error("Unknown game");
 }
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index f77590d..a915ed3 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -174,7 +174,7 @@ enum DialogId {
 };
 
 class Dialogs {
-private:
+protected:
 	MADSEngine *_vm;
 
 	Dialogs(MADSEngine *vm);
@@ -183,6 +183,8 @@ public:
 public:
 	Common::Point _defaultPosition;
 	DialogId _pendingDialog;
+
+	virtual void showDialog() = 0;
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 14dbcde..4e0be59 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -75,7 +75,7 @@ void Game::run() {
 		_statusFlag = _scene._sectionNum != 1;
 		_vm->_dialogs->_pendingDialog = DIALOG_DIFFICULTY;
 
-		showDialog();
+		_vm->_dialogs->showDialog();
 		_vm->_dialogs->_pendingDialog = DIALOG_NONE;
 
 		_vm->_events->freeCursors();
@@ -138,7 +138,7 @@ void Game::sectionLoop() {
 			_player._stepEnabled = true;
 			_player._visible = true;
 			_vm->_dialogs->_defaultPosition = Common::Point(-1, -1);
-			_scene.addVisitedScene(_scene._nextSceneId);
+			addVisitedScene(_scene._nextSceneId);
 
 			// TODO: main section loop logic goes here
 
@@ -151,7 +151,7 @@ void Game::sectionLoop() {
 			// Check whether to show a dialog
 			if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globalFlags[5]) {
 				_scene.releasePlayerSprites();
-				showDialog();
+				_vm->_dialogs->showDialog();
 				_vm->_dialogs->_pendingDialog = DIALOG_NONE;
 			}
 		}
@@ -213,6 +213,20 @@ void Game::loadResourceSequence(const Common::String prefix, int v) {
 	warning("TODO: loadResourceSequence");
 }
 
+void Game::addVisitedScene(int sceneId) {
+	if (!visitedScenesExists(sceneId))
+		_visitedScenes.push_back(sceneId);
+}
+
+bool Game::visitedScenesExists(int sceneId) {
+	for (int i = 0; i < _visitedScenes.size(); ++i) {
+		if (_visitedScenes[i] == sceneId)
+			return true;
+	}
+
+	return false;
+}
+
 /*------------------------------------------------------------------------*/
 
 void InventoryObject::load(Common::SeekableReadStream &f) {
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 58b6ff9..e2b8dee 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -95,6 +95,16 @@ private:
 	 * Inner game loop for executing gameplay within a game section
 	 */
 	void sectionLoop();
+
+	/**
+	 * Returns true if a given Scene Id exists in the listed of previously visited scenes.
+	 */
+	bool visitedScenesExists(int sceneId);
+
+	/**
+	 * Adds a scene Id to the list of previously visited scenes, if it doesn't already exist
+	 */
+	void addVisitedScene(int sceneId);
 protected:
 	MADSEngine *_vm;
 	MSurface *_surface;
@@ -107,13 +117,14 @@ protected:
 	int _saveSlot;
 	int _statusFlag;
 	SectionHandler *_sectionHandler;
+	Common::Array<int> _visitedScenes;
+	byte *_quotes;
 	int _v1;
 	int _v2;
 	int _v3;
 	int _v4;
 	int _v5;
 	int _v6;
-	byte *_quotes;
 
 	/**
 	 * Constructor
@@ -156,11 +167,6 @@ protected:
 	virtual void initialiseGlobals() = 0;
 
 	/**
-	 * Show a game dialog
-	 */
-	virtual void showDialog() = 0;
-
-	/**
 	 * Set up the section handler specific to each section
 	 */
 	virtual void setSectionHandler() = 0;
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index 53f377a..d4e4fe9 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -31,6 +31,16 @@ namespace MADS {
 
 namespace Nebular {
 
+class DialogsNebular: public Dialogs {
+	friend class Dialogs;
+protected:
+	DialogsNebular(MADSEngine *vm): Dialogs(vm) {}
+public:
+	virtual void showDialog() {
+		warning("TODO: showDialog");
+	}
+};
+
 struct HOGANUS {
 	int _bookId;
 	int _pageNum;
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 2e27eae..6e2b77d 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -152,10 +152,6 @@ void GameNebular::initialiseGlobals() {
 	loadResourceSequence("ROX", 1);
 }
 
-void GameNebular::showDialog() {
-	warning("TODO: showDialog");
-}
-
 void GameNebular::setSectionHandler() {
 	delete _sectionHandler;
 
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index 31bd4ae..9232b26 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -39,8 +39,6 @@ protected:
 
 	virtual void initialiseGlobals();
 
-	virtual void showDialog();
-
 	virtual void setSectionHandler();
 };
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 46190d1..406c3cc 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -34,7 +34,6 @@ Scene::Scene(MADSEngine *vm): _vm(vm) {
 	_priorSceneId = 0;
 	_nextSceneId = 0;
 	_currentSceneId = 0;
-	_vocabCount = 0;
 	_vocabBuffer = nullptr;
 	_sceneLogic = nullptr;
 }
@@ -81,7 +80,7 @@ void Scene::clearDynamicHotspots() {
 
 void Scene::clearVocab() {
 	freeVocab();
-	_vocabCount = 0;
+	_activeVocabs.clear();
 }
 
 void Scene::freeVocab() {
@@ -105,20 +104,6 @@ int Scene::activeVocabIndexOf(int vocabId) {
 	return -1;
 }
 
-void Scene::addVisitedScene(int sceneId) {
-	if (!visitedScenesExists(sceneId))
-		_visitedScenes.push_back(sceneId);
-}
-
-bool Scene::visitedScenesExists(int sceneId) {
-	for (int i = 0; i < _visitedScenes.size(); ++i) {
-		if (_visitedScenes[i] == sceneId)
-			return true;
-	}
-
-	return false;
-}
-
 void Scene::loadScene() {
 	delete _sceneLogic;
 
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 9f4f392..775517b 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -136,10 +136,6 @@ private:
 	 */
 	int activeVocabIndexOf(int vocabId);
 
-	/**
-	 * Returns true if a given Scene Id exists in the listed of previously visited scenes.
-	 */
-	bool visitedScenesExists(int sceneId);
 protected:
 	MADSEngine *_vm;
 public:
@@ -157,9 +153,7 @@ public:
 	Common::Array<DynamicHotspot> _dynamicHotspots;
 	bool _dynamicHotspotsChanged;
 	byte *_vocabBuffer;
-	int _vocabCount;
 	Common::Array<int> _activeVocabs;
-	Common::Array<int> _visitedScenes;
 
 	/**
 	 * Constructor
@@ -203,11 +197,6 @@ public:
 	void addActiveVocab(int vocabId);
 
 	/**
-	 * Add a scene to the visited scene list if it doesn't already exist
-	 */
-	void addVisitedScene(int sceneId);
-
-	/**
 	 * Loads the scene logic for a given scene
 	 */
 	void loadScene();


Commit: cc16e42f2029955e066450d63bfb666b9ab47109
    https://github.com/scummvm/scummvm/commit/cc16e42f2029955e066450d63bfb666b9ab47109
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-24T20:05:35-05:00

Commit Message:
MADS: Beginnings of scene-specific data loading

Changed paths:
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/resources.cpp
    engines/mads/resources.h
    engines/mads/scene.cpp
    engines/mads/scene.h



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 4e0be59..bff0e6e 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -132,7 +132,7 @@ void Game::sectionLoop() {
 
 			_quotes = nullptr;
 			_scene.clearVocab();
-			_scene.loadScene();
+			_scene.loadSceneLogic();
 
 			_v4 = 0;
 			_player._stepEnabled = true;
@@ -219,7 +219,7 @@ void Game::addVisitedScene(int sceneId) {
 }
 
 bool Game::visitedScenesExists(int sceneId) {
-	for (int i = 0; i < _visitedScenes.size(); ++i) {
+	for (uint i = 0; i < _visitedScenes.size(); ++i) {
 		if (_visitedScenes[i] == sceneId)
 			return true;
 	}
diff --git a/engines/mads/game.h b/engines/mads/game.h
index e2b8dee..4735615 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -109,9 +109,6 @@ protected:
 	MADSEngine *_vm;
 	MSurface *_surface;
 	Difficulty _difficultyLevel;
-	Common::Array<uint16> _globalFlags;
-	Common::Array<InventoryObject> _objects;
-	Common::Array<int> _inventoryList;
 	Player _player;
 	Scene _scene;
 	int _saveSlot;
@@ -177,6 +174,9 @@ public:
 public:
 	int _sectionNumber;
 	int _priorSectionNumber;
+	Common::Array<uint16> _globalFlags;
+	Common::Array<InventoryObject> _objects;
+	Common::Array<int> _inventoryList;
 public:
 	virtual ~Game();
 
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index db73ec7..f7fe03e 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -77,7 +77,7 @@ void MADSEngine::initialise() {
 	MSurface::setVm(this);
 	MSprite::setVm(this);
 
-	ResourcesManager::init(this);
+	Resources::init(this);
 	_debugger = new Debugger(this);
 	_dialogs = Dialogs::init(this);
 	_events = new EventsManager(this);
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index b3a05dc..44630ca 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -94,7 +94,7 @@ public:
 	Font *_font;
 	Game *_game;
 	Palette *_palette;
-	ResourcesManager *_resources;
+	Resources *_resources;
 	MSurface *_screen;
 	SoundManager *_sound;
 	UserInterface *_userInterface;
diff --git a/engines/mads/resources.cpp b/engines/mads/resources.cpp
index fe021fc..9f856ee 100644
--- a/engines/mads/resources.cpp
+++ b/engines/mads/resources.cpp
@@ -88,19 +88,6 @@ public:
 	virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const;
 };
 
-void ResourcesManager::init(MADSEngine *vm) {
-	SearchMan.add("HAG", new HagArchive());
-}
-
-/*------------------------------------------------------------------------*/
-
-void File::openFile(const Common::String &filename) {
-	if (!Common::File::open(filename))
-		error("Could not open file - %s", filename.c_str());
-}
-
-/*------------------------------------------------------------------------*/
-
 const char *const MADSCONCAT_STRING = "MADSCONCAT";
 
 HagArchive::HagArchive() {
@@ -282,4 +269,45 @@ ResourceType HagArchive::getResourceType(const Common::String &resourceName) con
 	return RESTYPE_NO_EXT;
 }
 
+/*------------------------------------------------------------------------*/
+
+void Resources::init(MADSEngine *vm) {
+	SearchMan.add("HAG", new HagArchive());
+}
+
+Common::String Resources::formatName(RESPREFIX resType, int id, const Common::String &ext) {
+	Common::String result = "*";
+
+	if (resType == 3 && !id) {
+		id = id / 100;
+	}
+
+	if (!ext.empty()) {
+		switch (resType) {
+		case RESPREFIX_GL:
+			result += "GL000";
+			break;
+		case RESPREFIX_SC:
+			result += Common::String::format("SC%.3d", id);
+			break;
+		case RESPREFIX_RM:
+			result += Common::String::format("RM%.3d", id);
+			break;
+		default:
+			break;
+		}
+
+		result += ext;
+	}
+
+	return result;
+}
+
+/*------------------------------------------------------------------------*/
+
+void File::openFile(const Common::String &filename) {
+	if (!Common::File::open(filename))
+		error("Could not open file - %s", filename.c_str());
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/resources.h b/engines/mads/resources.h
index f4b7009..033157e 100644
--- a/engines/mads/resources.h
+++ b/engines/mads/resources.h
@@ -31,12 +31,22 @@ namespace MADS {
 
 class MADSEngine;
 
-class ResourcesManager {
+enum RESPREFIX {
+	RESPREFIX_GL = 1, RESPREFIX_SC = 2, RESPREFIX_RM = 3
+};
+
+enum EXTTYPE {
+	EXT_SS = 1, EXT_AA = 2, EXT_DAT = 3, EXT_HH = 4, EXT_ART = 5, EXT_INT = 6
+};
+
+class Resources {
 public:
 	/**
 	 * Instantiates the resource manager
 	 */
 	static void init(MADSEngine *vm);
+
+	static Common::String formatName(RESPREFIX resType, int id, const Common::String &ext);
 };
 
 /**
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 406c3cc..19071d1 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -36,6 +36,17 @@ Scene::Scene(MADSEngine *vm): _vm(vm) {
 	_currentSceneId = 0;
 	_vocabBuffer = nullptr;
 	_sceneLogic = nullptr;
+
+	_verbList.push_back(VerbInit(VERB_LOOK, 2, 0));
+	_verbList.push_back(VerbInit(VERB_TAKE, 2, 0));
+	_verbList.push_back(VerbInit(VERB_PUSH, 2, 0));
+	_verbList.push_back(VerbInit(VERB_OPEN, 2, 0));
+	_verbList.push_back(VerbInit(VERB_PUT, 1, -1));
+	_verbList.push_back(VerbInit(VERB_TALKTO, 2, 0));
+	_verbList.push_back(VerbInit(VERB_GIVE, 1, 2));
+	_verbList.push_back(VerbInit(VERB_PULL, 2, 0));
+	_verbList.push_back(VerbInit(VERB_CLOSE, 2, 0));
+	_verbList.push_back(VerbInit(VERB_THROW, 1, 2));
 }
 
 Scene::~Scene() {
@@ -104,7 +115,17 @@ int Scene::activeVocabIndexOf(int vocabId) {
 	return -1;
 }
 
-void Scene::loadScene() {
+void Scene::clearSequenceList() {
+	_sequenceList.clear();
+}
+
+void Scene::clearMessageList() {
+	_messageList.clear();
+	_talkFont = "*FONTCONV.FF";
+	_textSpacing  = -1;
+}
+
+void Scene::loadSceneLogic() {
 	delete _sceneLogic;
 
 	switch (_vm->getGameID()) {
@@ -116,6 +137,31 @@ void Scene::loadScene() {
 	}
 }
 
+void Scene::loadHotspots() {
+	File f(Resources::formatName(RESPREFIX_RM, _currentSceneId, ".HH"));
+	int count = f.readUint16LE();
+
+	_hotspotList.clear();
+	for (int i = 0; i < count; ++i)
+		_hotspotList.push_back(Hotspot(f));
+}
+
+void Scene::loadVocab() {
+	// Add all the verbs to the active vocab list
+	for (uint i = 0; i < _verbList.size(); ++i)
+		addActiveVocab(_verbList[i]._id);
+
+	// Load the vocabs for any object descriptions and custom actions
+	for (uint objIndex = 0; objIndex < _vm->_game->_objects.size(); ++objIndex) {
+		InventoryObject &io = _vm->_game->_objects[objIndex];
+		addActiveVocab(io._descId);
+
+		if (io._vocabCount > 0) {
+			// TODO
+		}
+	}
+}
+
 void Scene::free() {
 	warning("TODO: Scene::free");
 }
@@ -160,4 +206,69 @@ DynamicHotspot::DynamicHotspot() {
 	_cursor = 0;
 }
 
+/*------------------------------------------------------------------------*/
+
+SequenceEntry::SequenceEntry() {
+	_spriteListIndex = 0;
+	_flipped =0;
+	_frameIndex = 0;
+	_frameStart = 0;
+	_numSprites = 0;
+	_animType = 0;
+	_frameInc = 0;
+	_depth = 0;
+	_scale = 0;
+	_dynamicHotspotIndex = -1;
+	_triggerCountdown = 0;
+	_doneFlag = 0;
+	_entries._count = 0;
+	_abortMode = 0;
+	_actionNouns[0] = _actionNouns[1] = _actionNouns[2] = 0;
+	_numTicks = 0;
+	_extraTicks = 0;
+	_timeout = 0;
+}
+
+KernelMessage::KernelMessage() {
+	_flags = 0;
+	_seqInex = 0;
+	_asciiChar = '\0';
+	_asciiChar2 = '\0';
+	_colors = 0;
+	Common::Point _posiition;
+	_msgOffset = 0;
+	_numTicks = 0;
+	_frameTimer2 = 0;
+	_frameTimer = 0;
+	_timeout = 0;
+	_field1C = 0;
+	_abortMode = 0;
+	_nounList[0] = _nounList[1] = _nounList[2] = 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+Hotspot::Hotspot() {
+	_facing = 0;
+	_articleNumber = 0;
+	_cursor = 0;
+	_vocabId = 0;
+	_verbId = 0;
+}
+
+Hotspot::Hotspot(Common::SeekableReadStream &f) {
+	_bounds.left = f.readSint16LE();
+	_bounds.top = f.readSint16LE();
+	_bounds.right = f.readSint16LE();
+	_bounds.bottom = f.readSint16LE();
+	_feetPos.x = f.readSint16LE();
+	_feetPos.y = f.readSint16LE();
+	_facing = f.readByte();
+	_articleNumber = f.readByte();
+	f.skip(1);
+	_cursor = f.readByte();
+	_vocabId = f.readUint16LE();
+	_verbId = f.readUint16LE();
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 775517b..27bcdb1 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -30,6 +30,30 @@
 
 namespace MADS {
 
+enum {
+	VERB_LOOK        = 3,
+	VERB_TAKE        = 4,
+	VERB_PUSH        = 5,
+	VERB_OPEN        = 6,
+	VERB_PUT         = 7,
+	VERB_TALKTO      = 8,
+	VERB_GIVE        = 9,
+	VERB_PULL        = 10,
+	VERB_CLOSE       = 11,
+	VERB_THROW       = 12,
+	VERB_WALKTO      = 13
+};
+
+class VerbInit {
+public:
+	int _id;
+	int _action1;
+	int _action2;
+
+	VerbInit() {}
+	VerbInit(int id, int action1, int action2): _id(id), _action1(action1), _action2(action2) {}
+};
+
 enum SpriteType {
 	ST_NONE = 0, ST_FOREGROUND = 1, ST_BACKGROUND = -4, 
 	ST_FULL_SCREEN_REFRESH = -2, ST_EXPIRED = -1
@@ -77,6 +101,73 @@ public:
 	DynamicHotspot();
 };
 
+class SequenceEntry {
+public:
+	int _spriteListIndex;
+	int _flipped;
+	int _frameIndex;
+	int _frameStart;
+	int _numSprites;
+	int _animType;
+	int _frameInc;
+	int _depth;
+	int _scale;
+	int _dynamicHotspotIndex;
+	
+	Common::Point _msgPos;
+
+	int _triggerCountdown;
+	bool _doneFlag;
+	struct {
+		int _count;
+		int _mode[5];
+		int _frameIndex[5];
+		int _abortVal[5];
+	} _entries;
+	int _abortMode;
+	int _actionNouns[3];
+	int _numTicks;
+	int _extraTicks;
+	int _timeout;
+
+	SequenceEntry();
+};
+
+class KernelMessage {
+public:
+	int _flags;
+	int _seqInex;
+	char _asciiChar;
+	char _asciiChar2;
+	int _colors;
+	Common::Point _posiition;
+	int _msgOffset;
+	int _numTicks;
+	int _frameTimer2;
+	int _frameTimer;
+	int _timeout;
+	int _field1C;
+	int _abortMode;
+	int _nounList[3];
+	Common::String _msg;
+
+	KernelMessage();
+};
+
+class Hotspot {
+public:
+	Common::Rect _bounds;
+	Common::Point _feetPos;
+	int _facing;
+	int _articleNumber;
+	int _cursor;
+	int _vocabId;
+	int _verbId;
+
+	Hotspot();
+	Hotspot(Common::SeekableReadStream &f);
+};
+
 #define SPRITE_COUNT 50
 #define TEXT_DISPLAY_COUNT 40
 #define DYNAMIC_HOTSPOT_COUNT 8
@@ -146,6 +237,7 @@ public:
 	int _priorSceneId;
 	int _nextSceneId;
 	int _currentSceneId;
+	Common::Array<VerbInit> _verbList;
 	TextDisplay _textDisplay[TEXT_DISPLAY_COUNT];
 	Common::Array<SpriteSlot> _spriteSlots;
 	Common::Array<SpriteAsset *> _spriteList;
@@ -154,6 +246,11 @@ public:
 	bool _dynamicHotspotsChanged;
 	byte *_vocabBuffer;
 	Common::Array<int> _activeVocabs;
+	Common::Array<SequenceEntry> _sequenceList;
+	Common::Array<KernelMessage> _messageList;
+	Common::String _talkFont;
+	int _textSpacing;
+	Common::Array<Hotspot> _hotspotList;
 
 	/**
 	 * Constructor
@@ -197,9 +294,29 @@ public:
 	void addActiveVocab(int vocabId);
 
 	/**
+	 * Clear the sequence list
+	 */
+	void clearSequenceList();
+
+	/**
+	 * Clear the message list
+	 */
+	void clearMessageList();
+
+	/**
 	 * Loads the scene logic for a given scene
 	 */
-	void loadScene();
+	void loadSceneLogic();
+
+	/**
+	 * Loads the hotstpots for the scene
+	 */
+	void loadHotspots();
+
+	/**
+	 * Loads the vocab list
+	 */
+	void loadVocab();
 
 	/**
 	 * Clear the data for the scene


Commit: c9057bd6a8ee2b039e2ba528b1e2e59814b8ef88
    https://github.com/scummvm/scummvm/commit/c9057bd6a8ee2b039e2ba528b1e2e59814b8ef88
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-25T09:21:19-05:00

Commit Message:
MADS: Moved scene data classes into their own code file

Changed paths:
  A engines/mads/scene_data.cpp
  A engines/mads/scene_data.h
    engines/mads/events.cpp
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/module.mk
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/game_nebular.h
    engines/mads/palette.cpp
    engines/mads/palette.h
    engines/mads/scene.cpp
    engines/mads/scene.h



diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 23d2e72..8f177f2 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -46,6 +46,7 @@ EventsManager::~EventsManager() {
 }
 
 void EventsManager::loadCursors(const Common::String &spritesName) {
+	delete _cursorSprites;
 	_cursorSprites = new SpriteAsset(_vm, spritesName, 0x4000);
 }
 
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index bff0e6e..9b60302 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -43,9 +43,14 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _scene(vm) {
 	_saveSlot = -1;
 	_statusFlag = 0;
 	_sectionHandler = nullptr;
+	_sectionNumber = 1;
+	_priorSectionNumber = 0;
+	_currentSectionNumber = -1;
 	_v1 = _v2 = 0;
 	_v3 = _v4 = 0;
 	_v5 = _v6 = 0;
+	_aaName = "*I0.AA";
+	_playerSpritesFlag = false;
 }
 
 Game::~Game() {
@@ -54,6 +59,7 @@ Game::~Game() {
 }
 
 void Game::run() {
+	_statusFlag = true;
 	int protectionResult = checkCopyProtection();
 	switch (protectionResult) {
 	case 1:
@@ -71,17 +77,16 @@ void Game::run() {
 	}
 
 	if (_saveSlot == -1 && protectionResult != -1 && protectionResult != -2) {
-		initSection(_scene._sectionNum);
-		_statusFlag = _scene._sectionNum != 1;
-		_vm->_dialogs->_pendingDialog = DIALOG_DIFFICULTY;
+		initSection(_sectionNumber);
+		_statusFlag = true;
 
+		_vm->_dialogs->_pendingDialog = DIALOG_DIFFICULTY;
 		_vm->_dialogs->showDialog();
 		_vm->_dialogs->_pendingDialog = DIALOG_NONE;
 
-		_vm->_events->freeCursors();
-		_scene._priorSectionNum = 0;
+		_priorSectionNumber = 0;
+		_priorSectionNumber = -1;
 		_scene._priorSceneId = 0;
-		_scene._sectionNumPrior = -1;
 		_scene._currentSceneId = -1;
 	}
 
@@ -102,12 +107,12 @@ void Game::gameLoop() {
 	while (!_vm->shouldQuit() && _statusFlag) {
 		setSectionHandler();
 		_sectionHandler->preLoadSection();
-		initSection(_scene._sectionNum);
+		initSection(_sectionNumber);
 		_sectionHandler->postLoadSection();
 
 		_scene.clearSprites(true);
 
-		if (_scene._sectionNum == _scene._sectionNumPrior) {
+		if (_sectionNumber == _currentSectionNumber) {
 			sectionLoop();
 		}
 
@@ -121,49 +126,72 @@ void Game::gameLoop() {
 }
 
 void Game::sectionLoop() {
-	while (!_vm->shouldQuit() && _statusFlag && _scene._sectionNum == _scene._sectionNumPrior) {
+	while (!_vm->shouldQuit() && _statusFlag && _sectionNumber == _currentSectionNumber) {
+		_v1 = 3;
+		_player._spritesChanged = true;
+		_v5 = 0;
+		_v6 = 0;
+		_vm->_events->resetCursor();
 
-		if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globalFlags[5]) {
-			_v1 = 3;
-			_player._spritesChanged = true;
-			_v5 = 0;
-			_v6 = 0;
-			_vm->_events->resetCursor();
+		_quotes = nullptr;
+		_scene.clearVocab();
+		_scene.loadSceneLogic();
 
-			_quotes = nullptr;
-			_scene.clearVocab();
-			_scene.loadSceneLogic();
+		_v4 = 0;
+		_player._stepEnabled = true;
+		_player._visible = true;
+		_vm->_dialogs->_defaultPosition = Common::Point(-1, -1);
+		addVisitedScene(_scene._nextSceneId);
 
-			_v4 = 0;
-			_player._stepEnabled = true;
-			_player._visible = true;
-			_vm->_dialogs->_defaultPosition = Common::Point(-1, -1);
-			addVisitedScene(_scene._nextSceneId);
+		_scene._screenObjects._v8333C = -1;
+		_scene._screenObjects._v832EC = 0;
+		_scene._screenObjects._yp = 0;
+		_v3 = -1;
 
-			// TODO: main section loop logic goes here
+		_scene._sceneLogic->setup();
+		if (_player._spritesChanged || _v3) {
+			if (_player._spritesLoaded)
+				_scene.releasePlayerSprites();
+			_vm->_palette->resetGamePalette(18, 10);
+			_scene.clearSprites(true);
+		} else {
+			_vm->_palette->initGamePalette();
+		}
 
-			// Clear the scene
-			_scene.free();
-			_scene._sectionNum = _scene._nextSceneId / 100;
+		// TODO: Further palette init
+		
+		//_scene.loadScene(_aaName, _scene._nextSceneId, 0);
+		_vm->_sound->queueNewCommands();
+		if (!_player._spritesLoaded) {
+			_player.loadSprites("");
+			_playerSpritesFlag = false;
+		}
 
-			// TODO: sub_1DD46(3)
 
-			// Check whether to show a dialog
-			if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globalFlags[5]) {
-				_scene.releasePlayerSprites();
-				_vm->_dialogs->showDialog();
-				_vm->_dialogs->_pendingDialog = DIALOG_NONE;
-			}
+		// TODO: main section loop logic goes here
+
+		// Clear the scene
+		_scene.free();
+		_sectionNumber = _scene._nextSceneId / 100;
+
+		// TODO: sub_1DD46(3)
+
+		// Check whether to show a dialog
+		if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globalFlags[5]) {
+			_scene.releasePlayerSprites();
+			_vm->_dialogs->showDialog();
+			_vm->_dialogs->_pendingDialog = DIALOG_NONE;
 		}
 	}
 }
 
 void Game::initSection(int sectionNumber) {
-	_priorSectionNumber = _sectionNumber;
-	_sectionNumber = sectionNumber;
+	_priorSectionNumber = _currentSectionNumber;
+	_currentSectionNumber = sectionNumber;
 
 	_vm->_palette->resetGamePalette(18, 10);
 	_vm->_palette->setLowRange();
+	_vm->_events->loadCursors("*CURSOR.SS");
 	
 	assert(_vm->_events->_cursorSprites);
 	_vm->_events->setCursor2((_vm->_events->_cursorSprites->getCount() <= 1) ? 
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 4735615..fbac20c 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -70,6 +70,10 @@ public:
 	bool _visible;
 public:
 	Player();
+
+	void loadSprites(const Common::String &prefix) {
+		warning("TODO: Player::loadSprites");
+	}
 };
 
 class SectionHandler {
@@ -122,6 +126,8 @@ protected:
 	int _v4;
 	int _v5;
 	int _v6;
+	Common::String _aaName;
+	bool _playerSpritesFlag;
 
 	/**
 	 * Constructor
@@ -174,6 +180,7 @@ public:
 public:
 	int _sectionNumber;
 	int _priorSectionNumber;
+	int _currentSectionNumber;
 	Common::Array<uint16> _globalFlags;
 	Common::Array<InventoryObject> _objects;
 	Common::Array<int> _inventoryList;
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index a729533..09adc9c 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -21,6 +21,7 @@ MODULE_OBJS := \
 	palette.o \
 	resources.o \
 	scene.o \
+	scene_data.o \
 	sound.o \
 	user_interface.o
 
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 6e2b77d..34fe0c7 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -155,7 +155,7 @@ void GameNebular::initialiseGlobals() {
 void GameNebular::setSectionHandler() {
 	delete _sectionHandler;
 
-	switch (_scene._sectionNum) {
+	switch (_sectionNumber) {
 	case 1:
 		_sectionHandler = new Section1Handler(_vm);
 		break;
@@ -177,6 +177,9 @@ void GameNebular::setSectionHandler() {
 	case 7:
 		_sectionHandler = new Section7Handler(_vm);
 		break;
+	case 8:
+		_sectionHandler = new Section8Handler(_vm);
+		break;
 	default:
 		break;
 	}
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index 9232b26..6395ba0 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -60,7 +60,7 @@ typedef Section1Handler Section4Handler;
 typedef Section1Handler Section5Handler;
 typedef Section1Handler Section6Handler;
 typedef Section1Handler Section7Handler;
-
+typedef Section1Handler Section8Handler;
 
 } // End of namespace Nebular
 
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 5438c78..7c51842 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -283,6 +283,10 @@ void Palette::resetGamePalette(int lowRange, int highRange) {
 	}
 }
 
+void Palette::initGamePalette() {
+	// TODO
+}
+
 void Palette::initRange(byte *palette) {
 	int var6 = 0;
 	int vdx = 0;
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 14cebc7..d0d7007 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -175,6 +175,11 @@ public:
 	void resetGamePalette(int v1, int v2);
 
 	/**
+	 * Initialises game palette
+	 */
+	void initGamePalette();
+
+	/**
 	 * Set the first four palette entries with preset values
 	 */
 	void setLowRange();
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 19071d1..09e965b 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -28,9 +28,6 @@
 namespace MADS {
 
 Scene::Scene(MADSEngine *vm): _vm(vm) {
-	_sectionNum = 1;
-	_sectionNumPrior = -1;
-	_priorSectionNum = 0;
 	_priorSceneId = 0;
 	_nextSceneId = 0;
 	_currentSceneId = 0;
@@ -47,6 +44,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm) {
 	_verbList.push_back(VerbInit(VERB_PULL, 2, 0));
 	_verbList.push_back(VerbInit(VERB_CLOSE, 2, 0));
 	_verbList.push_back(VerbInit(VERB_THROW, 1, 2));
+	Common::fill((byte *)&_nullPalette[0], (byte *)&_nullPalette[3], 0);
 }
 
 Scene::~Scene() {
@@ -156,16 +154,43 @@ void Scene::loadVocab() {
 		InventoryObject &io = _vm->_game->_objects[objIndex];
 		addActiveVocab(io._descId);
 
-		if (io._vocabCount > 0) {
-			// TODO
+		for (int vocabIndex = 0; vocabIndex <io._vocabCount; ++vocabIndex) {
+			addActiveVocab(io._vocabList[vocabIndex]._vocabId);
 		}
 	}
+
+	// Load scene hotspot list vocabs and verbs
+	for (uint i = 0; i < _hotspotList.size(); ++i) {
+		addActiveVocab(_hotspotList[i]._vocabId);
+		if (_hotspotList[i]._verbId)
+			addActiveVocab(_hotspotList[i]._verbId);
+	}
+
+	loadVocabStrings();
+}
+
+void Scene::loadVocabStrings() {
+	freeVocab();
+	File f("*VOCAB.DAT");
+
+	byte *d = new byte[ f.size()];
+	f.read(d, f.size());
+
+
+	int vocabId = 1;
+	for (uint strIndex = 0; strIndex < _activeVocabs.size(); ++strIndex) {
+
+	}
 }
 
 void Scene::free() {
 	warning("TODO: Scene::free");
 }
 
+void Scene::setPalette(RGB4 *p) {
+	_scenePalette = p;
+}
+
 /*------------------------------------------------------------------------*/
 
 SpriteSlot::SpriteSlot() {
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 27bcdb1..0e788c9 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -27,194 +27,10 @@
 #include "common/array.h"
 #include "common/rect.h"
 #include "mads/assets.h"
+#include "mads/scene_data.h"
 
 namespace MADS {
 
-enum {
-	VERB_LOOK        = 3,
-	VERB_TAKE        = 4,
-	VERB_PUSH        = 5,
-	VERB_OPEN        = 6,
-	VERB_PUT         = 7,
-	VERB_TALKTO      = 8,
-	VERB_GIVE        = 9,
-	VERB_PULL        = 10,
-	VERB_CLOSE       = 11,
-	VERB_THROW       = 12,
-	VERB_WALKTO      = 13
-};
-
-class VerbInit {
-public:
-	int _id;
-	int _action1;
-	int _action2;
-
-	VerbInit() {}
-	VerbInit(int id, int action1, int action2): _id(id), _action1(action1), _action2(action2) {}
-};
-
-enum SpriteType {
-	ST_NONE = 0, ST_FOREGROUND = 1, ST_BACKGROUND = -4, 
-	ST_FULL_SCREEN_REFRESH = -2, ST_EXPIRED = -1
-};
-
-class SpriteSlot {
-public:
-	SpriteType _spriteType;
-	int _seqIndex;
-	int _spriteListIndex;
-	int _frameNumber;
-	Common::Point _position;
-	int _depth;
-	int _scale;
-public:
-	SpriteSlot();
-	SpriteSlot(SpriteType type, int seqIndex);
-};
-
-class TextDisplay {
-public:
-	bool _active;
-	int _spacing;
-	Common::Rect _bounds;
-	int _expire;
-	int _col1;
-	int _col2;
-	Common::String _fontName;
-	Common::String _msg;
-
-	TextDisplay();
-};
-
-class DynamicHotspot {
-public:
-	int _seqIndex;
-	Common::Rect _bounds;
-	Common::Point _feetPos;
-	int _facing;
-	int _descId;
-	int _field14;
-	int _articleNumber;
-	int _cursor;
-
-	DynamicHotspot();
-};
-
-class SequenceEntry {
-public:
-	int _spriteListIndex;
-	int _flipped;
-	int _frameIndex;
-	int _frameStart;
-	int _numSprites;
-	int _animType;
-	int _frameInc;
-	int _depth;
-	int _scale;
-	int _dynamicHotspotIndex;
-	
-	Common::Point _msgPos;
-
-	int _triggerCountdown;
-	bool _doneFlag;
-	struct {
-		int _count;
-		int _mode[5];
-		int _frameIndex[5];
-		int _abortVal[5];
-	} _entries;
-	int _abortMode;
-	int _actionNouns[3];
-	int _numTicks;
-	int _extraTicks;
-	int _timeout;
-
-	SequenceEntry();
-};
-
-class KernelMessage {
-public:
-	int _flags;
-	int _seqInex;
-	char _asciiChar;
-	char _asciiChar2;
-	int _colors;
-	Common::Point _posiition;
-	int _msgOffset;
-	int _numTicks;
-	int _frameTimer2;
-	int _frameTimer;
-	int _timeout;
-	int _field1C;
-	int _abortMode;
-	int _nounList[3];
-	Common::String _msg;
-
-	KernelMessage();
-};
-
-class Hotspot {
-public:
-	Common::Rect _bounds;
-	Common::Point _feetPos;
-	int _facing;
-	int _articleNumber;
-	int _cursor;
-	int _vocabId;
-	int _verbId;
-
-	Hotspot();
-	Hotspot(Common::SeekableReadStream &f);
-};
-
-#define SPRITE_COUNT 50
-#define TEXT_DISPLAY_COUNT 40
-#define DYNAMIC_HOTSPOT_COUNT 8
-
-class MADSEngine;
-class Scene;
-
-class SceneLogic {
-protected:
-	Scene *_scene;
-public:
-	/**
-	 * Constructor
-	 */
-	SceneLogic(Scene *scene): _scene(scene) {}
-
-	/**
-	 * Called to initially setup a scene
-	 */
-	virtual void setup() = 0;
-
-	/**
-	 * Called as the scene is entered (made active)
-	 */
-	virtual void enter() = 0;
-
-	/**
-	 * Called one per frame
-	 */
-	virtual void step() = 0;
-
-	/**
-	 * Called before an action is started
-	 */
-	virtual void preActions() = 0;
-
-	/**
-	 * Handles scene actions
-	 */
-	virtual void actions() = 0;
-
-	/**
-	 * Post-action handling
-	 */
-	virtual void postActions() = 0;
-};
-
 class Scene {
 private:
 	/**
@@ -227,13 +43,14 @@ private:
 	 */
 	int activeVocabIndexOf(int vocabId);
 
+	/**
+	 * Secondary loading vocab list
+	 */
+	void loadVocabStrings();
 protected:
 	MADSEngine *_vm;
 public:
 	SceneLogic *_sceneLogic;
-	int _priorSectionNum;
-	int _sectionNum;
-	int _sectionNumPrior;
 	int _priorSceneId;
 	int _nextSceneId;
 	int _currentSceneId;
@@ -251,6 +68,9 @@ public:
 	Common::String _talkFont;
 	int _textSpacing;
 	Common::Array<Hotspot> _hotspotList;
+	ScreenObjects _screenObjects;
+	RGB4 *_scenePalette;
+	RGB4 _nullPalette[2];
 
 	/**
 	 * Constructor
@@ -317,6 +137,11 @@ public:
 	 * Loads the vocab list
 	 */
 	void loadVocab();
+	
+	/**
+	 * Set the scene palette
+	 */
+	void setPalette(RGB4 *p);
 
 	/**
 	 * Clear the data for the scene
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
new file mode 100644
index 0000000..6821395
--- /dev/null
+++ b/engines/mads/scene_data.cpp
@@ -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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/scummsys.h"
+#include "mads/scene.h"
+#include "mads/mads.h"
+#include "mads/nebular/nebular_scenes.h"
+
+namespace MADS {
+
+SpriteSlot::SpriteSlot() {
+	_spriteType = ST_NONE;
+	_seqIndex = 0;
+	_spriteListIndex = 0;
+	_frameNumber = 0;
+	_depth = 0;
+	_scale = 0;
+}
+
+SpriteSlot::SpriteSlot(SpriteType type, int seqIndex) {
+	_spriteType = type;
+	_seqIndex = seqIndex;
+	_spriteListIndex = 0;
+	_frameNumber = 0;
+	_depth = 0;
+	_scale = 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+TextDisplay::TextDisplay() {
+	_active = false;
+	_spacing = 0;
+	_expire = 0;
+	_col1 = _col2 = 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+DynamicHotspot::DynamicHotspot() {
+	_seqIndex = 0;
+	_facing = 0;
+	_descId = 0;
+	_field14 = 0;
+	_articleNumber = 0;
+	_cursor = 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+SequenceEntry::SequenceEntry() {
+	_spriteListIndex = 0;
+	_flipped =0;
+	_frameIndex = 0;
+	_frameStart = 0;
+	_numSprites = 0;
+	_animType = 0;
+	_frameInc = 0;
+	_depth = 0;
+	_scale = 0;
+	_dynamicHotspotIndex = -1;
+	_triggerCountdown = 0;
+	_doneFlag = 0;
+	_entries._count = 0;
+	_abortMode = 0;
+	_actionNouns[0] = _actionNouns[1] = _actionNouns[2] = 0;
+	_numTicks = 0;
+	_extraTicks = 0;
+	_timeout = 0;
+}
+
+KernelMessage::KernelMessage() {
+	_flags = 0;
+	_seqInex = 0;
+	_asciiChar = '\0';
+	_asciiChar2 = '\0';
+	_colors = 0;
+	Common::Point _posiition;
+	_msgOffset = 0;
+	_numTicks = 0;
+	_frameTimer2 = 0;
+	_frameTimer = 0;
+	_timeout = 0;
+	_field1C = 0;
+	_abortMode = 0;
+	_nounList[0] = _nounList[1] = _nounList[2] = 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+Hotspot::Hotspot() {
+	_facing = 0;
+	_articleNumber = 0;
+	_cursor = 0;
+	_vocabId = 0;
+	_verbId = 0;
+}
+
+Hotspot::Hotspot(Common::SeekableReadStream &f) {
+	_bounds.left = f.readSint16LE();
+	_bounds.top = f.readSint16LE();
+	_bounds.right = f.readSint16LE();
+	_bounds.bottom = f.readSint16LE();
+	_feetPos.x = f.readSint16LE();
+	_feetPos.y = f.readSint16LE();
+	_facing = f.readByte();
+	_articleNumber = f.readByte();
+	f.skip(1);
+	_cursor = f.readByte();
+	_vocabId = f.readUint16LE();
+	_verbId = f.readUint16LE();
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
new file mode 100644
index 0000000..a4950db
--- /dev/null
+++ b/engines/mads/scene_data.h
@@ -0,0 +1,227 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_SCENE_DATA_H
+#define MADS_SCENE_DATA_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+#include "common/rect.h"
+#include "mads/assets.h"
+
+namespace MADS {
+
+enum {
+	VERB_LOOK        = 3,
+	VERB_TAKE        = 4,
+	VERB_PUSH        = 5,
+	VERB_OPEN        = 6,
+	VERB_PUT         = 7,
+	VERB_TALKTO      = 8,
+	VERB_GIVE        = 9,
+	VERB_PULL        = 10,
+	VERB_CLOSE       = 11,
+	VERB_THROW       = 12,
+	VERB_WALKTO      = 13
+};
+
+class VerbInit {
+public:
+	int _id;
+	int _action1;
+	int _action2;
+
+	VerbInit() {}
+	VerbInit(int id, int action1, int action2): _id(id), _action1(action1), _action2(action2) {}
+};
+
+class ScreenObjects {
+public:
+	int _v8333C;
+	int _v832EC;
+	int _yp;
+};
+
+enum SpriteType {
+	ST_NONE = 0, ST_FOREGROUND = 1, ST_BACKGROUND = -4, 
+	ST_FULL_SCREEN_REFRESH = -2, ST_EXPIRED = -1
+};
+
+class SpriteSlot {
+public:
+	SpriteType _spriteType;
+	int _seqIndex;
+	int _spriteListIndex;
+	int _frameNumber;
+	Common::Point _position;
+	int _depth;
+	int _scale;
+public:
+	SpriteSlot();
+	SpriteSlot(SpriteType type, int seqIndex);
+};
+
+class TextDisplay {
+public:
+	bool _active;
+	int _spacing;
+	Common::Rect _bounds;
+	int _expire;
+	int _col1;
+	int _col2;
+	Common::String _fontName;
+	Common::String _msg;
+
+	TextDisplay();
+};
+
+class DynamicHotspot {
+public:
+	int _seqIndex;
+	Common::Rect _bounds;
+	Common::Point _feetPos;
+	int _facing;
+	int _descId;
+	int _field14;
+	int _articleNumber;
+	int _cursor;
+
+	DynamicHotspot();
+};
+
+class SequenceEntry {
+public:
+	int _spriteListIndex;
+	int _flipped;
+	int _frameIndex;
+	int _frameStart;
+	int _numSprites;
+	int _animType;
+	int _frameInc;
+	int _depth;
+	int _scale;
+	int _dynamicHotspotIndex;
+	
+	Common::Point _msgPos;
+
+	int _triggerCountdown;
+	bool _doneFlag;
+	struct {
+		int _count;
+		int _mode[5];
+		int _frameIndex[5];
+		int _abortVal[5];
+	} _entries;
+	int _abortMode;
+	int _actionNouns[3];
+	int _numTicks;
+	int _extraTicks;
+	int _timeout;
+
+	SequenceEntry();
+};
+
+class KernelMessage {
+public:
+	int _flags;
+	int _seqInex;
+	char _asciiChar;
+	char _asciiChar2;
+	int _colors;
+	Common::Point _posiition;
+	int _msgOffset;
+	int _numTicks;
+	int _frameTimer2;
+	int _frameTimer;
+	int _timeout;
+	int _field1C;
+	int _abortMode;
+	int _nounList[3];
+	Common::String _msg;
+
+	KernelMessage();
+};
+
+class Hotspot {
+public:
+	Common::Rect _bounds;
+	Common::Point _feetPos;
+	int _facing;
+	int _articleNumber;
+	int _cursor;
+	int _vocabId;
+	int _verbId;
+
+	Hotspot();
+	Hotspot(Common::SeekableReadStream &f);
+};
+
+#define SPRITE_COUNT 50
+#define TEXT_DISPLAY_COUNT 40
+#define DYNAMIC_HOTSPOT_COUNT 8
+
+class MADSEngine;
+class Scene;
+
+class SceneLogic {
+protected:
+	Scene *_scene;
+public:
+	/**
+	 * Constructor
+	 */
+	SceneLogic(Scene *scene): _scene(scene) {}
+
+	/**
+	 * Called to initially setup a scene
+	 */
+	virtual void setup() = 0;
+
+	/**
+	 * Called as the scene is entered (made active)
+	 */
+	virtual void enter() = 0;
+
+	/**
+	 * Called one per frame
+	 */
+	virtual void step() = 0;
+
+	/**
+	 * Called before an action is started
+	 */
+	virtual void preActions() = 0;
+
+	/**
+	 * Handles scene actions
+	 */
+	virtual void actions() = 0;
+
+	/**
+	 * Post-action handling
+	 */
+	virtual void postActions() = 0;
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_SCENE_DATA_H */


Commit: 9eaab29afedf9eceee50f882b64cb39a14e616a2
    https://github.com/scummvm/scummvm/commit/9eaab29afedf9eceee50f882b64cb39a14e616a2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-25T19:52:35-05:00

Commit Message:
MADS: Starting to refactor some Scene array fields as separate classes

Changed paths:
  A engines/mads/game_data.cpp
  A engines/mads/game_data.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/module.mk
    engines/mads/nebular/game_nebular.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h
    engines/mads/sound.cpp
    engines/mads/sound.h



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 9b60302..2a45c3e 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -23,6 +23,7 @@
 #include "common/scummsys.h"
 #include "mads/mads.h"
 #include "mads/game.h"
+#include "mads/game_data.h"
 #include "mads/nebular/game_nebular.h"
 #include "mads/graphics.h"
 #include "mads/msurface.h"
@@ -37,7 +38,8 @@ Game *Game::init(MADSEngine *vm) {
 	return nullptr;
 }
 
-Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _scene(vm) {
+Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr),
+		_objects(vm), _scene(vm) {
 	_sectionNumber = _priorSectionNumber = 0;
 	_difficultyLevel = DIFFICULTY_HARD;
 	_saveSlot = -1;
@@ -110,7 +112,7 @@ void Game::gameLoop() {
 		initSection(_sectionNumber);
 		_sectionHandler->postLoadSection();
 
-		_scene.clearSprites(true);
+		_scene._spriteSlots.clear(true);
 
 		if (_sectionNumber == _currentSectionNumber) {
 			sectionLoop();
@@ -141,7 +143,7 @@ void Game::sectionLoop() {
 		_player._stepEnabled = true;
 		_player._visible = true;
 		_vm->_dialogs->_defaultPosition = Common::Point(-1, -1);
-		addVisitedScene(_scene._nextSceneId);
+		_visitedScenes.add(_scene._nextSceneId);
 
 		_scene._screenObjects._v8333C = -1;
 		_scene._screenObjects._v832EC = 0;
@@ -151,17 +153,18 @@ void Game::sectionLoop() {
 		_scene._sceneLogic->setup();
 		if (_player._spritesChanged || _v3) {
 			if (_player._spritesLoaded)
-				_scene.releasePlayerSprites();
+				_scene._spriteSlots.releasePlayerSprites();
 			_vm->_palette->resetGamePalette(18, 10);
-			_scene.clearSprites(true);
+			_scene._spriteSlots.clear(true);
 		} else {
 			_vm->_palette->initGamePalette();
 		}
 
 		// TODO: Further palette init
 		
-		//_scene.loadScene(_aaName, _scene._nextSceneId, 0);
-		_vm->_sound->queueNewCommands();
+		_scene.loadScene(_scene._nextSceneId, _aaName, 0);
+		_vm->_sound->pauseNewCommands();
+
 		if (!_player._spritesLoaded) {
 			_player.loadSprites("");
 			_playerSpritesFlag = false;
@@ -178,7 +181,7 @@ void Game::sectionLoop() {
 
 		// Check whether to show a dialog
 		if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globalFlags[5]) {
-			_scene.releasePlayerSprites();
+			_scene._spriteSlots.releasePlayerSprites();
 			_vm->_dialogs->showDialog();
 			_vm->_dialogs->_pendingDialog = DIALOG_NONE;
 		}
@@ -198,91 +201,8 @@ void Game::initSection(int sectionNumber) {
 		CURSOR_ARROW : CURSOR_WAIT);
 }
 
-void Game::loadObjects() {
-	File f("*OBJECTS.DAT");
-
-	// Get the total numer of inventory objects
-	int count = f.readUint16LE();
-	_objects.reserve(count);
-
-	// Read in each object
-	for (int i = 0; i < count; ++i) {
-		InventoryObject obj;
-		obj.load(f);
-		_objects.push_back(obj);
-
-		// If it's for the player's inventory, add the index to the inventory list
-		if (obj._roomNumber == PLAYER_INVENTORY) {
-			_inventoryList.push_back(i);
-			assert(_inventoryList.size() <= 32);
-		}
-	}
-}
-
-void Game::setObjectData(int objIndex, int id, const byte *p) {
-	// TODO: This whole method seems weird. Check it out more thoroughly once
-	// more of the engine is implemented
-	for (int i = 0; i < (int)_objects.size(); ++i) {
-		InventoryObject &obj = _objects[i];
-		if (obj._vocabList[0]._actionFlags1 <= i)
-			break;
-
-		if (obj._mutilateString[6 + i] == id) {
-			_objects[objIndex]._objFolder = p;
-		}
-	}
-}
-
-void Game::setObjectRoom(int objectId, int roomNumber) {
-	warning("TODO: setObjectRoom");
-}
-
 void Game::loadResourceSequence(const Common::String prefix, int v) {
 	warning("TODO: loadResourceSequence");
 }
 
-void Game::addVisitedScene(int sceneId) {
-	if (!visitedScenesExists(sceneId))
-		_visitedScenes.push_back(sceneId);
-}
-
-bool Game::visitedScenesExists(int sceneId) {
-	for (uint i = 0; i < _visitedScenes.size(); ++i) {
-		if (_visitedScenes[i] == sceneId)
-			return true;
-	}
-
-	return false;
-}
-
-/*------------------------------------------------------------------------*/
-
-void InventoryObject::load(Common::SeekableReadStream &f) {
-	_descId = f.readUint16LE();
-	_roomNumber = f.readUint16LE();
-	_article = f.readByte();
-	_vocabCount = f.readByte();
-	
-	for (int i = 0; i < 3; ++i) {
-		_vocabList[i]._actionFlags1 = f.readByte();
-		_vocabList[i]._actionFlags2 = f.readByte();
-		_vocabList[i]._vocabId = f.readByte();
-	}
-
-	f.skip(4);	// field12
-	f.read(&_mutilateString[0], 10);
-	f.skip(16);
-}
-
-/*------------------------------------------------------------------------*/
-
-Player::Player() {
-	_direction = 8;
-	_newDirection = 8;
-	_spritesLoaded = false;
-	_spriteListStart = _numSprites = 0;
-	_stepEnabled = false;
-	_visible = false;
-}
-
 } // End of namespace MADS
diff --git a/engines/mads/game.h b/engines/mads/game.h
index fbac20c..4797908 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "mads/scene.h"
+#include "mads/game_data.h"
 
 namespace MADS {
 
@@ -38,56 +39,6 @@ enum Difficulty {
 	DIFFICULTY_HARD = 1, DIFFICULTY_MEDIUM = 2, DIFFICULTY_EASY = 3
 };
 
-class InventoryObject {
-public:
-	int _descId;
-	int _roomNumber;
-	int _article;
-	int _vocabCount;
-	struct {
-		int _actionFlags1;
-		int _actionFlags2;
-		int _vocabId;
-	} _vocabList[3];
-	char _mutilateString[10];	// ???
-	const byte *_objFolder;		// ???
-
-	/**
-	 * Loads the data for a given object
-	 */
-	void load(Common::SeekableReadStream &f);
-};
-
-class Player {
-public:
-	int _direction;
-	int _newDirection;
-	bool _spritesLoaded;
-	int _spriteListStart;
-	int _numSprites;
-	bool _stepEnabled;
-	bool _spritesChanged;
-	bool _visible;
-public:
-	Player();
-
-	void loadSprites(const Common::String &prefix) {
-		warning("TODO: Player::loadSprites");
-	}
-};
-
-class SectionHandler {
-protected:
-	MADSEngine *_vm;
-public:
-	SectionHandler(MADSEngine *vm): _vm(vm) {}
-	virtual ~SectionHandler() {}
-
-	virtual void preLoadSection() = 0;
-	virtual void sectionPtr2() = 0;
-	virtual void postLoadSection() = 0;
-};
-
 class Game {
 private:
 	/**
@@ -99,26 +50,15 @@ private:
 	 * Inner game loop for executing gameplay within a game section
 	 */
 	void sectionLoop();
-
-	/**
-	 * Returns true if a given Scene Id exists in the listed of previously visited scenes.
-	 */
-	bool visitedScenesExists(int sceneId);
-
-	/**
-	 * Adds a scene Id to the list of previously visited scenes, if it doesn't already exist
-	 */
-	void addVisitedScene(int sceneId);
 protected:
 	MADSEngine *_vm;
 	MSurface *_surface;
 	Difficulty _difficultyLevel;
 	Player _player;
-	Scene _scene;
 	int _saveSlot;
 	int _statusFlag;
 	SectionHandler *_sectionHandler;
-	Common::Array<int> _visitedScenes;
+	VisitedScenes _visitedScenes;
 	byte *_quotes;
 	int _v1;
 	int _v2;
@@ -135,21 +75,6 @@ protected:
 	Game(MADSEngine *vm);
 
 	/**
-	 * Loads the game's object list
-	 */
-	void loadObjects();
-
-	/**
-	 * Set the associated data? pointer with an inventory object
-	 */
-	void setObjectData(int objIndex, int id, const byte *p);
-
-	/**
-	 * Sets the room number
-	 */
-	void setObjectRoom(int objectId, int roomNumber);
-
-	/**
 	 * Initialises the current section number of the game
 	 */
 	void initSection(int sectionNumber);
@@ -182,8 +107,8 @@ public:
 	int _priorSectionNumber;
 	int _currentSectionNumber;
 	Common::Array<uint16> _globalFlags;
-	Common::Array<InventoryObject> _objects;
-	Common::Array<int> _inventoryList;
+	InventoryObjects _objects;
+	Scene _scene;
 public:
 	virtual ~Game();
 
diff --git a/engines/mads/game_data.cpp b/engines/mads/game_data.cpp
new file mode 100644
index 0000000..df4a902
--- /dev/null
+++ b/engines/mads/game_data.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/game.h"
+#include "mads/nebular/game_nebular.h"
+#include "mads/graphics.h"
+#include "mads/msurface.h"
+#include "mads/resources.h"
+
+namespace MADS {
+
+void VisitedScenes::add(int sceneId) {
+	if (!exists(sceneId))
+		push_back(sceneId);
+}
+
+bool VisitedScenes::exists(int sceneId) {
+	for (uint i = 0; i < size(); ++i) {
+		if ((*this)[i] == sceneId)
+			return true;
+	}
+
+	return false;
+}
+
+void InventoryObject::load(Common::SeekableReadStream &f) {
+	_descId = f.readUint16LE();
+	_roomNumber = f.readUint16LE();
+	_article = f.readByte();
+	_vocabCount = f.readByte();
+	
+	for (int i = 0; i < 3; ++i) {
+		_vocabList[i]._actionFlags1 = f.readByte();
+		_vocabList[i]._actionFlags2 = f.readByte();
+		_vocabList[i]._vocabId = f.readByte();
+	}
+
+	f.skip(4);	// field12
+	f.read(&_mutilateString[0], 10);
+	f.skip(16);
+}
+
+/*------------------------------------------------------------------------*/
+
+void InventoryObjects::load() {
+	File f("*OBJECTS.DAT");
+
+	// Get the total numer of inventory objects
+	int count = f.readUint16LE();
+	reserve(count);
+
+	// Read in each object
+	for (int i = 0; i < count; ++i) {
+		InventoryObject obj;
+		obj.load(f);
+		push_back(obj);
+
+		// If it's for the player's inventory, add the index to the inventory list
+		if (obj._roomNumber == PLAYER_INVENTORY) {
+			_inventoryList.push_back(i);
+			assert(_inventoryList.size() <= 32);
+		}
+	}
+}
+
+void InventoryObjects::setData(int objIndex, int id, const byte *p) {
+	// TODO: This whole method seems weird. Check it out more thoroughly once
+	// more of the engine is implemented
+	for (int i = 0; i < (int)size(); ++i) {
+		InventoryObject &obj = (*this)[i];
+		if (obj._vocabList[0]._actionFlags1 <= i)
+			break;
+
+		if (obj._mutilateString[6 + i] == id) {
+			(*this)[objIndex]._objFolder = p;
+		}
+	}
+}
+
+void InventoryObjects::setRoom(int objectId, int roomNumber) {
+	warning("TODO: setObjectRoom");
+}
+
+/*------------------------------------------------------------------------*/
+
+Player::Player() {
+	_direction = 8;
+	_newDirection = 8;
+	_spritesLoaded = false;
+	_spritesStart = _numSprites = 0;
+	_stepEnabled = false;
+	_visible = false;
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/game_data.h b/engines/mads/game_data.h
new file mode 100644
index 0000000..2d2badd
--- /dev/null
+++ b/engines/mads/game_data.h
@@ -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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_GAME_DATA_H
+#define MADS_GAME_DATA_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+
+namespace MADS {
+
+class MADSEngine;
+class Game;
+
+class VisitedScenes: public Common::Array<int> {
+public:
+	/**
+	 * Returns true if a given Scene Id exists in the listed of previously visited scenes.
+	 */
+	bool exists(int sceneId);
+
+	/**
+	 * Adds a scene Id to the list of previously visited scenes, if it doesn't already exist
+	 */
+	void add(int sceneId);
+};
+
+class InventoryObject {
+public:
+	int _descId;
+	int _roomNumber;
+	int _article;
+	int _vocabCount;
+	struct {
+		int _actionFlags1;
+		int _actionFlags2;
+		int _vocabId;
+	} _vocabList[3];
+	char _mutilateString[10];	// ???
+	const byte *_objFolder;		// ???
+
+	/**
+	 * Loads the data for a given object
+	 */
+	void load(Common::SeekableReadStream &f);
+};
+
+class InventoryObjects: public Common::Array<InventoryObject> {
+private:
+	MADSEngine *_vm;
+public:
+	Common::Array<int> _inventoryList;
+
+	/** 
+	 * Constructor
+	 */
+	InventoryObjects(MADSEngine *vm): _vm(vm) {}
+
+	/**
+	 * Loads the game's object list
+	 */
+	void load();
+
+	/**
+	 * Set the associated data? pointer with an inventory object
+	 */
+	void setData(int objIndex, int id, const byte *p);
+
+	/**
+	 * Sets the room number
+	 */
+	void setRoom(int objectId, int roomNumber);
+};
+
+class Player {
+public:
+	int _direction;
+	int _newDirection;
+	bool _spritesLoaded;
+	int _spritesStart;
+	int _numSprites;
+	bool _stepEnabled;
+	bool _spritesChanged;
+	bool _visible;
+public:
+	Player();
+
+	void loadSprites(const Common::String &prefix) {
+		warning("TODO: Player::loadSprites");
+	}
+};
+
+class SectionHandler {
+protected:
+	MADSEngine *_vm;
+public:
+	SectionHandler(MADSEngine *vm): _vm(vm) {}
+	virtual ~SectionHandler() {}
+
+	virtual void preLoadSection() = 0;
+	virtual void sectionPtr2() = 0;
+	virtual void postLoadSection() = 0;
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_GAME_DATA_H */
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 09adc9c..62441ab 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -14,6 +14,7 @@ MODULE_OBJS := \
 	events.o \
 	font.o \
 	game.o \
+	game_data.o \
 	graphics.o \
 	mads.o \
 	msprite.o \
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 34fe0c7..e777ff8 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -68,7 +68,7 @@ void GameNebular::initialiseGlobals() {
 	_globalFlags[21] = 0xFFFF;
 	_globalFlags[95] = 0xFFFF;
 
-	setObjectData(3, 17, nullptr);
+	_objects.setData(3, 17, nullptr);
 
 	// Put the values 0 through 3 in a random order in global slots 83 to 86
 	for (int i = 0; i < 4;) {
@@ -125,21 +125,21 @@ void GameNebular::initialiseGlobals() {
 	switch (_difficultyLevel) {
 	case DIFFICULTY_HARD:
 		_globalFlags[35] = 0;
-		setObjectRoom(9, 1);
-		setObjectRoom(50, 1);
+		_objects.setRoom(9, 1);
+		_objects.setRoom(50, 1);
 		_globalFlags[137] = 5;
 		_globalFlags[136] = 0;
 		break;
 	case DIFFICULTY_MEDIUM:
 		_globalFlags[35] = 0;
-		setObjectRoom(8, 1);
+		_objects.setRoom(8, 1);
 		_globalFlags[137] = 0xFFFF;
 		_globalFlags[136] = 6;
 		break;
 	case DIFFICULTY_EASY:
 		_globalFlags[35] = 2;
-		setObjectRoom(8, 1);
-		setObjectRoom(27, 1);
+		_objects.setRoom(8, 1);
+		_objects.setRoom(27, 1);
 		break;
 	default:
 		break;
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 09e965b..7bbb4e9 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -27,7 +27,7 @@
 
 namespace MADS {
 
-Scene::Scene(MADSEngine *vm): _vm(vm) {
+Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm) {
 	_priorSceneId = 0;
 	_nextSceneId = 0;
 	_currentSceneId = 0;
@@ -52,36 +52,6 @@ Scene::~Scene() {
 	delete _sceneLogic;
 }
 
-void Scene::clearSprites(bool flag) {
-	for (int i = 0; i < TEXT_DISPLAY_COUNT; ++i)
-		_textDisplay[i]._active = false;
-
-	if (flag)
-		_spriteList.clear();
-
-	_spriteSlots.clear();
-	_spriteSlots.push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1));
-}
-
-/**
- * Releases any sprites used by the player
- */
-void Scene::releasePlayerSprites() {
-	Player &player = _vm->_game->player();
-
-	if (player._spritesLoaded && player._numSprites > 0) {
-		int spriteEnd = player._spriteListStart + player._numSprites - 1;
-		do {
-			deleteSpriteEntry(spriteEnd);
-		} while (--spriteEnd >= player._spriteListStart);
-	}
-}
-
-void Scene::deleteSpriteEntry(int listIndex) {
-	delete _spriteList[listIndex];
-	_spriteList.remove_at(listIndex);
-}
-
 void Scene::clearDynamicHotspots() {
 	_dynamicHotspots.clear();
 	_dynamicHotspotsChanged = false;
@@ -135,6 +105,18 @@ void Scene::loadSceneLogic() {
 	}
 }
 
+void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
+	// Store the previously active scene number and set the new one
+	_priorSceneId = _currentSceneId;
+	_currentSceneId = sceneId;
+
+	_v1 = 0;
+	if (palFlag)
+		_vm->_palette->resetGamePalette(18, 10);
+
+
+}
+
 void Scene::loadHotspots() {
 	File f(Resources::formatName(RESPREFIX_RM, _currentSceneId, ".HH"));
 	int count = f.readUint16LE();
@@ -177,9 +159,9 @@ void Scene::loadVocabStrings() {
 	f.read(d, f.size());
 
 
-	int vocabId = 1;
+//	int vocabId = 1;
 	for (uint strIndex = 0; strIndex < _activeVocabs.size(); ++strIndex) {
-
+		// TODO: Rest of this method
 	}
 }
 
@@ -191,109 +173,4 @@ void Scene::setPalette(RGB4 *p) {
 	_scenePalette = p;
 }
 
-/*------------------------------------------------------------------------*/
-
-SpriteSlot::SpriteSlot() {
-	_spriteType = ST_NONE;
-	_seqIndex = 0;
-	_spriteListIndex = 0;
-	_frameNumber = 0;
-	_depth = 0;
-	_scale = 0;
-}
-
-SpriteSlot::SpriteSlot(SpriteType type, int seqIndex) {
-	_spriteType = type;
-	_seqIndex = seqIndex;
-	_spriteListIndex = 0;
-	_frameNumber = 0;
-	_depth = 0;
-	_scale = 0;
-}
-
-/*------------------------------------------------------------------------*/
-
-TextDisplay::TextDisplay() {
-	_active = false;
-	_spacing = 0;
-	_expire = 0;
-	_col1 = _col2 = 0;
-}
-
-/*------------------------------------------------------------------------*/
-
-DynamicHotspot::DynamicHotspot() {
-	_seqIndex = 0;
-	_facing = 0;
-	_descId = 0;
-	_field14 = 0;
-	_articleNumber = 0;
-	_cursor = 0;
-}
-
-/*------------------------------------------------------------------------*/
-
-SequenceEntry::SequenceEntry() {
-	_spriteListIndex = 0;
-	_flipped =0;
-	_frameIndex = 0;
-	_frameStart = 0;
-	_numSprites = 0;
-	_animType = 0;
-	_frameInc = 0;
-	_depth = 0;
-	_scale = 0;
-	_dynamicHotspotIndex = -1;
-	_triggerCountdown = 0;
-	_doneFlag = 0;
-	_entries._count = 0;
-	_abortMode = 0;
-	_actionNouns[0] = _actionNouns[1] = _actionNouns[2] = 0;
-	_numTicks = 0;
-	_extraTicks = 0;
-	_timeout = 0;
-}
-
-KernelMessage::KernelMessage() {
-	_flags = 0;
-	_seqInex = 0;
-	_asciiChar = '\0';
-	_asciiChar2 = '\0';
-	_colors = 0;
-	Common::Point _posiition;
-	_msgOffset = 0;
-	_numTicks = 0;
-	_frameTimer2 = 0;
-	_frameTimer = 0;
-	_timeout = 0;
-	_field1C = 0;
-	_abortMode = 0;
-	_nounList[0] = _nounList[1] = _nounList[2] = 0;
-}
-
-/*------------------------------------------------------------------------*/
-
-Hotspot::Hotspot() {
-	_facing = 0;
-	_articleNumber = 0;
-	_cursor = 0;
-	_vocabId = 0;
-	_verbId = 0;
-}
-
-Hotspot::Hotspot(Common::SeekableReadStream &f) {
-	_bounds.left = f.readSint16LE();
-	_bounds.top = f.readSint16LE();
-	_bounds.right = f.readSint16LE();
-	_bounds.bottom = f.readSint16LE();
-	_feetPos.x = f.readSint16LE();
-	_feetPos.y = f.readSint16LE();
-	_facing = f.readByte();
-	_articleNumber = f.readByte();
-	f.skip(1);
-	_cursor = f.readByte();
-	_vocabId = f.readUint16LE();
-	_verbId = f.readUint16LE();
-}
-
 } // End of namespace MADS
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 0e788c9..7db1077 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -55,10 +55,10 @@ public:
 	int _nextSceneId;
 	int _currentSceneId;
 	Common::Array<VerbInit> _verbList;
-	TextDisplay _textDisplay[TEXT_DISPLAY_COUNT];
-	Common::Array<SpriteSlot> _spriteSlots;
-	Common::Array<SpriteAsset *> _spriteList;
-	int _spriteListIndex;
+	Common::Array<TextDisplay> _textDisplay;
+	SpriteSlots _spriteSlots;
+	Common::Array<SpriteAsset *> _sprites;
+	int _spritesIndex;
 	Common::Array<DynamicHotspot> _dynamicHotspots;
 	bool _dynamicHotspotsChanged;
 	byte *_vocabBuffer;
@@ -71,6 +71,7 @@ public:
 	ScreenObjects _screenObjects;
 	RGB4 *_scenePalette;
 	RGB4 _nullPalette[2];
+	int _v1;
 
 	/**
 	 * Constructor
@@ -83,22 +84,6 @@ public:
 	~Scene();
 
 	/**
-	 * Initialise the sprite data
-	 * @param flag		Also reset sprite list
-	 */
-	void clearSprites(bool flag);
-
-	/**
-	 * Delete any sprites used by the player
-	 */
-	void releasePlayerSprites();
-
-	/**
-	 * Delete a sprite entry
-	 */
-	void deleteSpriteEntry(int listIndex);
-
-	/**
 	 * Clear the dynamic hotspot list
 	 */
 	void clearDynamicHotspots();
@@ -129,6 +114,14 @@ public:
 	void loadSceneLogic();
 
 	/**
+	 * Loads the resources associated with the given scene
+	 * @param sceneId		Scene to load
+	 * @param prefix		Prefix to use for retrieving animation data
+	 * @param palFlag		Flag for whether to reset the high/lo palette areas
+	 */
+	void loadScene(int sceneId, const Common::String &prefix, bool palFlag);
+
+	/**
 	 * Loads the hotstpots for the scene
 	 */
 	void loadHotspots();
@@ -143,6 +136,7 @@ public:
 	 */
 	void setPalette(RGB4 *p);
 
+
 	/**
 	 * Clear the data for the scene
 	 */
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 6821395..d0e40d4 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -21,7 +21,7 @@
  */
 
 #include "common/scummsys.h"
-#include "mads/scene.h"
+#include "mads/scene_data.h"
 #include "mads/mads.h"
 #include "mads/nebular/nebular_scenes.h"
 
@@ -30,7 +30,7 @@ namespace MADS {
 SpriteSlot::SpriteSlot() {
 	_spriteType = ST_NONE;
 	_seqIndex = 0;
-	_spriteListIndex = 0;
+	_spritesIndex = 0;
 	_frameNumber = 0;
 	_depth = 0;
 	_scale = 0;
@@ -39,7 +39,7 @@ SpriteSlot::SpriteSlot() {
 SpriteSlot::SpriteSlot(SpriteType type, int seqIndex) {
 	_spriteType = type;
 	_seqIndex = seqIndex;
-	_spriteListIndex = 0;
+	_spritesIndex = 0;
 	_frameNumber = 0;
 	_depth = 0;
 	_scale = 0;
@@ -47,6 +47,37 @@ SpriteSlot::SpriteSlot(SpriteType type, int seqIndex) {
 
 /*------------------------------------------------------------------------*/
 
+void SpriteSlots::clear(bool flag) {
+	_vm->_game->_scene._textDisplay.clear();
+
+	if (flag)
+		_vm->_game->_scene._sprites.clear();
+
+	Common::Array<SpriteSlot>::clear();
+	push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1));
+}
+
+/**
+ * Releases any sprites used by the player
+ */
+void SpriteSlots::releasePlayerSprites() {
+	Player &player = _vm->_game->player();
+
+	if (player._spritesLoaded && player._numSprites > 0) {
+		int spriteEnd = player._spritesStart + player._numSprites - 1;
+		do {
+			deleteEntry(spriteEnd);
+		} while (--spriteEnd >= player._spritesStart);
+	}
+}
+
+void SpriteSlots::deleteEntry(int index) {
+	remove_at(index);
+}
+
+
+/*------------------------------------------------------------------------*/
+
 TextDisplay::TextDisplay() {
 	_active = false;
 	_spacing = 0;
@@ -68,7 +99,7 @@ DynamicHotspot::DynamicHotspot() {
 /*------------------------------------------------------------------------*/
 
 SequenceEntry::SequenceEntry() {
-	_spriteListIndex = 0;
+	_spritesIndex = 0;
 	_flipped =0;
 	_frameIndex = 0;
 	_frameStart = 0;
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index a4950db..b464cba 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -30,6 +30,9 @@
 
 namespace MADS {
 
+class MADSEngine;
+class Scene;
+
 enum {
 	VERB_LOOK        = 3,
 	VERB_TAKE        = 4,
@@ -70,7 +73,7 @@ class SpriteSlot {
 public:
 	SpriteType _spriteType;
 	int _seqIndex;
-	int _spriteListIndex;
+	int _spritesIndex;
 	int _frameNumber;
 	Common::Point _position;
 	int _depth;
@@ -80,6 +83,30 @@ public:
 	SpriteSlot(SpriteType type, int seqIndex);
 };
 
+class SpriteSlots: public Common::Array<SpriteSlot> {
+private:
+	MADSEngine *_vm;
+public:
+	SpriteSlots(MADSEngine *vm): _vm(vm) {}
+
+	/**
+	 * Clears any pending slot data and schedules a full screen refresh.
+	 * @param flag		Also reset sprite list
+	 */
+	void clear(bool flag);
+
+	/**
+	 * Delete any sprites used by the player
+	 */
+	void releasePlayerSprites();
+
+	/**
+	 * Delete a sprite entry
+	 * @param index		Specifies the index in the array
+	 */
+	void deleteEntry(int index);
+};
+
 class TextDisplay {
 public:
 	bool _active;
@@ -110,7 +137,7 @@ public:
 
 class SequenceEntry {
 public:
-	int _spriteListIndex;
+	int _spritesIndex;
 	int _flipped;
 	int _frameIndex;
 	int _frameStart;
@@ -175,13 +202,6 @@ public:
 	Hotspot(Common::SeekableReadStream &f);
 };
 
-#define SPRITE_COUNT 50
-#define TEXT_DISPLAY_COUNT 40
-#define DYNAMIC_HOTSPOT_COUNT 8
-
-class MADSEngine;
-class Scene;
-
 class SceneLogic {
 protected:
 	Scene *_scene;
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index 8608abf..ea02390 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -77,7 +77,7 @@ void SoundManager::setEnabled(bool flag) {
 	_soundPollFlag = false;
 }
 
-void SoundManager::queueNewCommands() {
+void SoundManager::pauseNewCommands() {
 	_newSoundsPaused = true;
 }
 
diff --git a/engines/mads/sound.h b/engines/mads/sound.h
index 51213f0..0fd9ac1 100644
--- a/engines/mads/sound.h
+++ b/engines/mads/sound.h
@@ -70,7 +70,7 @@ public:
 	/**
 	 * Temporarily pause the playback of any new sound commands
 	 */
-	void queueNewCommands();
+	void pauseNewCommands();
 
 	/**
 	 * Stop queueing sound commands, and execute any previously queued ones


Commit: c49d7196fcabf18d9e97711f67b864808ca7848a
    https://github.com/scummvm/scummvm/commit/c49d7196fcabf18d9e97711f67b864808ca7848a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-25T23:10:51-05:00

Commit Message:
MADS: In progress implementation of loadScene

Changed paths:
    engines/mads/assets.cpp
    engines/mads/dialogs.cpp
    engines/mads/game.h
    engines/mads/mads.cpp
    engines/mads/msprite.cpp
    engines/mads/msprite.h
    engines/mads/msurface.cpp
    engines/mads/msurface.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/resources.cpp
    engines/mads/resources.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h
    engines/mads/user_interface.cpp



diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index 6ad313c..4c075d0 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -82,7 +82,7 @@ SpriteAsset::SpriteAsset(MADSEngine *vm, const Common::String &resourceName, int
 				_frameCount, frame.x, frame.y, frame.w, frame.h);
 		}
 
-		frame.frame = MSprite::init(spriteDataStream, Common::Point(frame.x, frame.y), 
+		frame.frame = new MSprite(spriteDataStream, Common::Point(frame.x, frame.y), 
 			frame.w, frame.h, false);
 		_frames.push_back(frame);
 	}
diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index c865e04..e4c7682 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -39,7 +39,7 @@ Dialog::~Dialog() {
 
 
 void Dialog::save(MSurface *s) {
-	_savedSurface = MSurface::init(_width, _height);
+	_savedSurface = new MSurface(_width, _height);
 	s->copyTo(_savedSurface, 
 		Common::Rect(_position.x, _position.y, _position.x + _width, _position.y + _height),
 		Common::Point());
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 4797908..b8add9a 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -61,7 +61,6 @@ protected:
 	VisitedScenes _visitedScenes;
 	byte *_quotes;
 	int _v1;
-	int _v2;
 	int _v3;
 	int _v4;
 	int _v5;
@@ -109,6 +108,7 @@ public:
 	Common::Array<uint16> _globalFlags;
 	InventoryObjects _objects;
 	Scene _scene;
+	int _v2;
 public:
 	virtual ~Game();
 
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index f7fe03e..d78f37d 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -83,7 +83,7 @@ void MADSEngine::initialise() {
 	_events = new EventsManager(this);
 	_palette = new Palette(this);
 	_font = new Font(this);
-	_screen = MSurface::init(g_system->getWidth(), g_system->getHeight());
+	_screen = new MSurface(g_system->getWidth(), g_system->getHeight());
 	_sound = new SoundManager(this, _mixer);
 	_userInterface = UserInterface::init(this);
 	_game = Game::init(this);
diff --git a/engines/mads/msprite.cpp b/engines/mads/msprite.cpp
index b15796d..279192f 100644
--- a/engines/mads/msprite.cpp
+++ b/engines/mads/msprite.cpp
@@ -35,25 +35,13 @@ enum {
 	kMarker = 2
 };
 
-MADSEngine *MSprite::_vm;
-
-MSprite *MSprite::init(MSurface &s) {
-	return new MSprite(s);
-}
-
-MSprite *MSprite::init(Common::SeekableReadStream *source, const Common::Point &offset, 
-		int widthVal, int heightVal, bool decodeRle, uint8 encodingVal) {
-
-	return new MSprite(source, offset, widthVal, heightVal, decodeRle, encodingVal);
-}
-
-MSprite::MSprite(MSurface &s): _surface(s) {
+MSprite::MSprite(): MSurface() {
 	_encoding = 0;
 }
 
 MSprite::MSprite(Common::SeekableReadStream *source, const Common::Point &offset, 
 		int widthVal, int heightVal, bool decodeRle, uint8 encodingVal)
-		: _surface(*MSurface::init(widthVal, heightVal)), 
+		: MSurface(widthVal, heightVal), 
 		_encoding(encodingVal), _offset(offset) {
 
 	// Load the sprite data
@@ -69,14 +57,14 @@ void MSprite::loadSprite(Common::SeekableReadStream *source) {
 	byte *outp, *lineStart;
 	bool newLine = false;
 
-	outp = _surface.getData();
-	lineStart = _surface.getData();
+	outp = getData();
+	lineStart = getData();
 
 	while (1) {
 		byte cmd1, cmd2, count, pixel;
 
 		if (newLine) {
-			outp = lineStart + _surface.w;
+			outp = lineStart + getWidth();
 			lineStart = outp;
 			newLine = false;
 		}
diff --git a/engines/mads/msprite.h b/engines/mads/msprite.h
index bb21772..f2194da 100644
--- a/engines/mads/msprite.h
+++ b/engines/mads/msprite.h
@@ -95,24 +95,15 @@ struct SpriteFrameHeader {
 	uint32 reserved8;
 };
 
-class MSprite {
+class MSprite: public MSurface {
+private:
+	void loadSprite(Common::SeekableReadStream *source);
 public:
-	static MSprite *init(MSurface &s);
-	static MSprite *init(Common::SeekableReadStream *source, const Common::Point &offset, int widthVal, 
-		int heightVal, bool decodeRle = true, uint8 encodingVal = 0);
-protected:
-	static MADSEngine *_vm;
-
-	MSprite(MSurface &s);
+	MSprite();
 	MSprite(Common::SeekableReadStream *source, const Common::Point &offset, 
 		int widthVal, int heightVal, bool decodeRle = true, uint8 encodingVal = 0);
-
-	void loadSprite(Common::SeekableReadStream *source);
-public:
-	static void setVm(MADSEngine *vm) { _vm = vm; }
 	virtual ~MSprite();
 
-	MSurface &_surface;
 	Common::Point _pos;
 	Common::Point _offset;
 	uint8 _encoding;
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index a9561cd..4c17b3a 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -32,22 +32,6 @@ namespace MADS {
 
 MADSEngine *MSurface::_vm = nullptr;
 
-MSurface *MSurface::init() {
-	if (_vm->getGameID() == GType_RexNebular) {
-		return new MSurfaceNebular();
-	} else {
-		return new MSurfaceMADS();
-	}
-}
-
-MSurface *MSurface::init(int width, int height) {
-	if (_vm->getGameID() == GType_RexNebular) {
-		return new MSurfaceNebular(width, height);
-	} else {
-		return new MSurfaceMADS(width, height);
-	}
-}
-
 MSurface::MSurface() {
 	pixels = nullptr;
 }
@@ -120,7 +104,7 @@ void MSurface::drawSprite(const Common::Point &pt, SpriteInfo &info, const Commo
 		return;
 	int heightAmt = scaledHeight;
 
-	byte *src = info.sprite->_surface.getData();
+	byte *src = info.sprite->getData();
 	byte *dst = getBasePtr(x - info.hotX - clipX, y - info.hotY - clipY);
 
 	int status = kStatusSkip;
@@ -278,33 +262,7 @@ void MSurface::translate(RGBList *list, bool isTransparent) {
 }
 
 /*------------------------------------------------------------------------*/
-
-void MSurfaceMADS::loadCodes(Common::SeekableReadStream *source) {
-	if (!source) {
-		free();
-		return;
-	}
-
-	uint16 width = MADS_SCREEN_WIDTH;
-	uint16 height = MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT;
-	byte *walkMap = new byte[source->size()];
-
-	setSize(width, height);
-	source->read(walkMap, source->size());
-
-	byte *ptr = (byte *)getBasePtr(0, 0);
-
-	for (int y = 0; y < height; y++) {
-		for (int x = 0; x < width; x++) {
-			int ofs = x + (y * width);
-			if ((walkMap[ofs / 8] << (ofs % 8)) & 0x80)
-				*ptr++ = 1;		// walkable
-			else
-				*ptr++ = 0;
-		}
-	}
-}
-
+/*
 void MSurfaceMADS::loadBackground(int roomNumber, RGBList **palData) {
 	// clear previous data
 	empty();
@@ -386,7 +344,7 @@ void MSurfaceMADS::loadBackground(int roomNumber, RGBList **palData) {
 	for (i = 0; i < tileCount; i++) {
 		tileDataUncomp->seek(i * 4, SEEK_SET);
 		uint32 tileOfs = tileDataUncomp->readUint32LE();
-		MSurface *newTile = MSurface::init(tileWidth, tileHeight);
+		MSurface *newTile = new MSurface(tileWidth, tileHeight);
 
 		if (i == tileCount - 1)
 			compressedTileDataSize = tileDataComp->size() - tileOfs;
@@ -454,7 +412,7 @@ void MSurfaceMADS::loadInterface(int index, RGBList **palData) {
 	delete intStream;
 }
 
-/*------------------------------------------------------------------------*/
+------------------------------------------------------------------------
 
 void MSurfaceNebular::loadBackground(int roomNumber, RGBList **palData) {
 	// clear previous data
@@ -504,5 +462,6 @@ void MSurfaceNebular::loadBackgroundStream(Common::SeekableReadStream *source, R
 	
 	delete sourceUnc;
 }
+*/
 
 } // End of namespace MADS
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index 3904aa1..209ac97 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -50,24 +50,19 @@ struct SpriteInfo {
  * MADS graphics surface
  */
 class MSurface : public Graphics::Surface {
-public:
+private:
 	static MADSEngine *_vm;
-
+public:
 	/**
-	 * Sets the engine reference
+	 * Sets the engine refrence used all surfaces
 	 */
 	static void setVm(MADSEngine *vm) { _vm = vm; }
 
 	/**
-	 * Create a new surface.
-	 */
-	static MSurface *init();
-
-	/**
-	 * Create a surface
+	 * Helper method for calculating new dimensions when scaling a sprite
 	 */
-	static MSurface *init(int width, int height);
-protected:
+	static int scaleValue(int value, int scale, int err);	
+public:
 	/**
 	 * Basic constructor
 	 */
@@ -77,12 +72,7 @@ protected:
 	 * Constructor for a surface with fixed dimensions
 	 */
 	MSurface(int width, int height);
-public:
-	/**
-	 * Helper method for calculating new dimensions when scaling a sprite
-	 */
-	static int scaleValue(int value, int scale, int err);	
-public:
+
 	/**
 	 * Destructor
 	 */
@@ -182,55 +172,6 @@ public:
 	 * Translates the data of a surface using a specified RGBList translation matrix.
 	 */
 	void translate(RGBList *list, bool isTransparent = false);
-
-	// Base virtual methods
-	/**
-	 * Loads a background by scene name
-	 */
-	virtual void loadBackground(const Common::String &sceneName) {}
-
-	/**
-	 * Load background by room number
-	 */
-	virtual void loadBackground(int roomNumber, RGBList **palData) = 0;
-
-	/**
-	 * Load background from a passed stream
-	 */
-	virtual void loadBackground(Common::SeekableReadStream *source, RGBList **palData) {}
-
-	/**
-	 * Load scene codes from a passed stream
-	 */
-	virtual void loadCodes(Common::SeekableReadStream *source) = 0;
-
-	/**
-	 * Load a given user interface by index
-	 */
-	virtual void loadInterface(int index, RGBList **palData) {}
-};
-
-class MSurfaceMADS: public MSurface {
-	friend class MSurface;
-protected:
-	MSurfaceMADS(): MSurface() {}
-	MSurfaceMADS(int width, int height): MSurface(width, height) {}
-public:
-	virtual void loadCodes(Common::SeekableReadStream *source);
-	virtual void loadBackground(const Common::String &sceneName) {}
-	virtual void loadBackground(int roomNumber, RGBList **palData);
-	virtual void loadInterface(int index, RGBList **palData);
-};
-
-class MSurfaceNebular: public MSurfaceMADS {
-	friend class MSurface;
-protected:
-	MSurfaceNebular(): MSurfaceMADS() {}
-	MSurfaceNebular(int width, int height): MSurfaceMADS(width, height) {}
-private:
-	void loadBackgroundStream(Common::SeekableReadStream *source, RGBList **palData);
-public:
-	virtual void loadBackground(int roomNumber, RGBList **palData);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index e777ff8..c55abf5 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -34,7 +34,7 @@ namespace MADS {
 namespace Nebular {
 
 GameNebular::GameNebular(MADSEngine *vm): Game(vm) {
-	_surface =MSurface::init(MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT);
+	_surface = new MSurface(MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT);
 }
 
 int GameNebular::checkCopyProtection() {
diff --git a/engines/mads/resources.cpp b/engines/mads/resources.cpp
index 9f856ee..f24f7d2 100644
--- a/engines/mads/resources.cpp
+++ b/engines/mads/resources.cpp
@@ -303,6 +303,19 @@ Common::String Resources::formatName(RESPREFIX resType, int id, const Common::St
 	return result;
 }
 
+Common::String Resources::formatResource(const Common::String &resName, 
+		const Common::String &hagFilename) {
+	int v1 = 0, v2 = 0;
+
+	if (resName.hasPrefix("*")) {
+		// Resource file specified
+		error("TODO: formatResource");
+	} else {
+		// File outside of hag file
+		return resName;
+	}
+}
+
 /*------------------------------------------------------------------------*/
 
 void File::openFile(const Common::String &filename) {
diff --git a/engines/mads/resources.h b/engines/mads/resources.h
index 033157e..8fed0ab 100644
--- a/engines/mads/resources.h
+++ b/engines/mads/resources.h
@@ -47,6 +47,7 @@ public:
 	static void init(MADSEngine *vm);
 
 	static Common::String formatName(RESPREFIX resType, int id, const Common::String &ext);
+	static Common::String formatResource(const Common::String &resName, const Common::String &hagFilename);
 };
 
 /**
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 7bbb4e9..138cab5 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -33,6 +33,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm) {
 	_currentSceneId = 0;
 	_vocabBuffer = nullptr;
 	_sceneLogic = nullptr;
+	_sceneInfo = nullptr;
+	_scenePalette = nullptr;
 
 	_verbList.push_back(VerbInit(VERB_LOOK, 2, 0));
 	_verbList.push_back(VerbInit(VERB_TAKE, 2, 0));
@@ -50,6 +52,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm) {
 Scene::~Scene() {
 	delete[] _vocabBuffer;
 	delete _sceneLogic;
+	delete _sceneInfo;
 }
 
 void Scene::clearDynamicHotspots() {
@@ -84,11 +87,11 @@ int Scene::activeVocabIndexOf(int vocabId) {
 }
 
 void Scene::clearSequenceList() {
-	_sequenceList.clear();
+	_sequences.clear();
 }
 
 void Scene::clearMessageList() {
-	_messageList.clear();
+	_messages.clear();
 	_talkFont = "*FONTCONV.FF";
 	_textSpacing  = -1;
 }
@@ -114,16 +117,22 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	if (palFlag)
 		_vm->_palette->resetGamePalette(18, 10);
 
+	_spriteSlots.clear(false);
+	_sequences.clear();
+	_messages.clear();
 
+	setPalette(_nullPalette);
+	_sceneInfo = SceneInfo::load(_vm, _currentSceneId, _v1, Common::String(), _vm->_game->_v2 ? 17 : 16,
+		_depthSurface, _backgroundSurface);
 }
 
 void Scene::loadHotspots() {
 	File f(Resources::formatName(RESPREFIX_RM, _currentSceneId, ".HH"));
 	int count = f.readUint16LE();
 
-	_hotspotList.clear();
+	_hotspots.clear();
 	for (int i = 0; i < count; ++i)
-		_hotspotList.push_back(Hotspot(f));
+		_hotspots.push_back(Hotspot(f));
 }
 
 void Scene::loadVocab() {
@@ -142,10 +151,10 @@ void Scene::loadVocab() {
 	}
 
 	// Load scene hotspot list vocabs and verbs
-	for (uint i = 0; i < _hotspotList.size(); ++i) {
-		addActiveVocab(_hotspotList[i]._vocabId);
-		if (_hotspotList[i]._verbId)
-			addActiveVocab(_hotspotList[i]._verbId);
+	for (uint i = 0; i < _hotspots.size(); ++i) {
+		addActiveVocab(_hotspots[i]._vocabId);
+		if (_hotspots[i]._verbId)
+			addActiveVocab(_hotspots[i]._verbId);
 	}
 
 	loadVocabStrings();
@@ -170,7 +179,7 @@ void Scene::free() {
 }
 
 void Scene::setPalette(RGB4 *p) {
-	_scenePalette = p;
+//	_scenePalette = p;
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 7db1077..efe89c2 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -27,6 +27,7 @@
 #include "common/array.h"
 #include "common/rect.h"
 #include "mads/assets.h"
+#include "mads/msurface.h"
 #include "mads/scene_data.h"
 
 namespace MADS {
@@ -63,15 +64,18 @@ public:
 	bool _dynamicHotspotsChanged;
 	byte *_vocabBuffer;
 	Common::Array<int> _activeVocabs;
-	Common::Array<SequenceEntry> _sequenceList;
-	Common::Array<KernelMessage> _messageList;
+	Common::Array<SequenceEntry> _sequences;
+	Common::Array<KernelMessage> _messages;
 	Common::String _talkFont;
 	int _textSpacing;
-	Common::Array<Hotspot> _hotspotList;
+	Common::Array<Hotspot> _hotspots;
 	ScreenObjects _screenObjects;
-	RGB4 *_scenePalette;
+	ScenePalette *_scenePalette;
 	RGB4 _nullPalette[2];
 	int _v1;
+	SceneInfo *_sceneInfo;
+	MSurface _backgroundSurface;
+	MSurface _depthSurface;
 
 	/**
 	 * Constructor
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index d0e40d4..aac7075 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -23,6 +23,7 @@
 #include "common/scummsys.h"
 #include "mads/scene_data.h"
 #include "mads/mads.h"
+#include "mads/resources.h"
 #include "mads/nebular/nebular_scenes.h"
 
 namespace MADS {
@@ -161,4 +162,176 @@ Hotspot::Hotspot(Common::SeekableReadStream &f) {
 	_verbId = f.readUint16LE();
 }
 
+/*------------------------------------------------------------------------*/
+
+void ARTHeader::load(Common::SeekableReadStream &f) {
+	_width = f.readUint16LE();
+	_height = f.readUint16LE();
+
+	_palCount = f.readUint16LE();
+	for (int i = 0; i < 256; ++i) {
+		RGB6 rgb;
+		rgb.r = f.readByte();
+		rgb.g = f.readByte();
+		rgb.b = f.readByte();
+		f.read(&rgb.unused[0], 3);
+
+		_palette.push_back(rgb);
+	}
+
+	int palCount = f.readUint16LE();
+	for (int i = 0; i < palCount; ++i) {
+		RGB4 rgb;
+		rgb.r = f.readByte();
+		rgb.g = f.readByte();
+		rgb.b = f.readByte();
+		rgb.u = f.readByte();
+
+		_palData.push_back(rgb);
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+SceneInfo *SceneInfo::load(MADSEngine *vm, int sceneId, int v1, const Common::String &resName,
+		int v3, MSurface &depthSurface, MSurface &bgSurface) {
+	return new SceneInfo(vm, sceneId, v1, resName, v3, depthSurface, bgSurface);
+}
+
+SceneInfo::SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &resName,
+		int flags, MSurface &depthSurface, MSurface &bgSurface) {
+	bool flag = true;
+	bool sceneFlag = sceneId >= 0;
+	bool ssFlag = false, wsFlag = false;
+	int handle = 0;
+	
+	SpriteAsset *spriteSets[10];
+	int xpList[10];
+	Common::fill(&spriteSets[0], &spriteSets[10], (SpriteAsset *)nullptr);
+	Common::fill(&xpList[0], &xpList[10], -1);
+
+	// Figure out the resource to use
+	Common::String resourceName;
+	if (sceneFlag) {
+		resourceName = Resources::formatName(RESPREFIX_RM, sceneId, ".DAT");
+	} else {
+		resourceName = "*" + Resources::formatResource(resName, resName);
+	}
+
+	// Open the scene info resource for access
+	File infoFile(resName);
+
+	// Read in basic data
+	_sceneId = infoFile.readUint16LE();
+	_artFileNum = infoFile.readUint16LE();
+	_depthStyle = infoFile.readUint16LE();
+	_width = infoFile.readUint16LE();
+	_height = infoFile.readUint16LE();
+	infoFile.skip(24);
+	_nodeCount = infoFile.readUint16LE();
+	_yBandsEnd = infoFile.readUint16LE();
+	_yBandsStart = infoFile.readUint16LE();
+	_maxScale = infoFile.readUint16LE();
+	_minScale = infoFile.readUint16LE();
+	for (int i = 0; i < 15; ++i)
+		_depthList[i] = infoFile.readUint16LE();
+	_field4A = infoFile.readUint16LE();
+
+	// Load the set of objects that are associated with the scene
+	for (int i = 0; i < 20; ++i) {
+		InventoryObject obj;
+		obj.load(infoFile);
+		_objects.push_back(obj);
+	}
+
+	int setCount  = infoFile.readUint16LE();
+	int field40E = infoFile.readUint16LE();
+
+	for (int i = 0; i < 20; ++i) {
+		char name[64];
+		infoFile.read(name, 64);
+		_setNames.push_back(Common::String(name));
+	}
+
+	infoFile.close();
+	int width = _width;
+	int height = _height;
+
+	if (!bgSurface.getPixels()) {
+		bgSurface.setSize(width, height);
+		ssFlag = true;
+	}
+
+	if (_depthStyle == 2)
+		width >>= 2;
+	if (!depthSurface.getPixels()) {
+		depthSurface.setSize(width, height);
+		wsFlag = true;
+	}
+
+	// Load the depth surface with the scene codes
+	loadCodes(depthSurface);
+
+	// Get the ART resource
+	if (sceneFlag) {
+		resourceName = Resources::formatName(RESPREFIX_RM, sceneId, ".ART");
+	} else {
+		resourceName = "*" + Resources::formatResource(resName, resName);
+	}
+
+	// Load in the ART header and palette
+	File artFile(resourceName);
+	ARTHeader artHeader;
+	artHeader.load(artFile);
+	artFile.close();
+
+	// Copy out the palette data
+	for (int i = 0; i < artHeader._palData.size(); ++i)
+		_palette.push_back(artHeader._palData[i]);
+/*
+	if (!(flags & 1)) {
+		if (_vm->_game->_scene->_scenePalette) {
+			//_vm->_game->_scene->_scenePalette->clean(&artHeader._palCount);
+			//_vm->_game->_scene->_scenePalette->process(&artHeader._palCount)
+		}
+	}
+	*/
+	warning("TODO");
+}
+
+void SceneInfo::loadCodes(MSurface &depthSurface) {
+	File f(Resources::formatName(RESPREFIX_RM, _sceneId, ".DAT"));
+
+	uint16 width = _width;
+	uint16 height = _height;
+	byte *walkMap = new byte[f.size()];
+
+	depthSurface.setSize(width, height);
+	f.read(walkMap, f.size());
+
+	byte *ptr = (byte *)depthSurface.getPixels();
+
+	for (int y = 0; y < height; y++) {
+		for (int x = 0; x < width; x++) {
+			int ofs = x + (y * width);
+			if ((walkMap[ofs / 8] << (ofs % 8)) & 0x80)
+				*ptr++ = 1;		// walkable
+			else
+				*ptr++ = 0;
+		}
+	}
+
+	delete[] walkMap;
+}
+
+/*------------------------------------------------------------------------*/
+
+void ScenePalette::clean(int *palCount) {
+	warning("TODO: ScenePalette::clean");
+}
+
+void ScenePalette::process(int *palCount) {
+	warning("TODO: ScenePalette::process");
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index b464cba..2fcd3f9 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -25,8 +25,11 @@
 
 #include "common/scummsys.h"
 #include "common/array.h"
+#include "common/str.h"
+#include "common/str-array.h"
 #include "common/rect.h"
 #include "mads/assets.h"
+#include "mads/game_data.h"
 
 namespace MADS {
 
@@ -242,6 +245,70 @@ public:
 	virtual void postActions() = 0;
 };
 
+struct RGB6 {
+	byte r;
+	byte g;
+	byte b;
+	byte unused[3];
+};
+
+struct ARTHeader {
+	int _width;
+	int _height;
+	int _palCount;
+	Common::Array<RGB6> _palette;
+	Common::Array<RGB4> _palData;
+
+	void load(Common::SeekableReadStream &f);
+};
+
+/**
+ * Handles general data for a given scene
+ */
+class SceneInfo {
+private:
+	MADSEngine *_vm;
+
+	SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &resName,
+		int v3, MSurface &depthSurface, MSurface &bgSurface);
+
+	/**
+	 * Loads the given surface with depth information of a given scene
+	 */
+	void loadCodes(MSurface &depthSurface);
+public:
+	int _sceneId;
+	int _artFileNum;
+	int _depthStyle;
+	int _width;
+	int _height;
+
+	int _nodeCount;
+	int _yBandsEnd;
+	int _yBandsStart;
+	int _maxScale;
+	int _minScale;
+	int _depthList[15];
+	int _field4A;
+
+	int _field4C;
+	Common::Array<InventoryObject> _objects;
+	Common::StringArray _setNames;
+	Common::Array<RGB4> _palette;
+public:
+	/**
+	 * Instantiates the class and loads the data
+	 */
+	static SceneInfo *load(MADSEngine *vm, int sceneId, int flags, 
+		const Common::String &resName, int v3, MSurface &depthSurface, MSurface &bgSurface);
+};
+
+class ScenePalette {
+public:
+	void clean(int *palCount);
+	void process(int *palCount);
+};
+
 } // End of namespace MADS
 
 #endif /* MADS_SCENE_DATA_H */
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 2af134a..3bbf6a0 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -33,7 +33,7 @@ UserInterface *UserInterface::init(MADSEngine *vm) {
 }
 
 UserInterface::UserInterface(MADSEngine *vm): _vm(vm), _surface(
-	MSurface::init(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT)) {
+	new MSurface(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT)) {
 }
 
 UserInterface::~UserInterface() {


Commit: badb8d97444767b7d8fea0f877ac044249696a5f
    https://github.com/scummvm/scummvm/commit/badb8d97444767b7d8fea0f877ac044249696a5f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-02-28T20:37:42-05:00

Commit Message:
MADS: More work implementing scene info loading

Changed paths:
    engines/mads/dialogs.h
    engines/mads/game.cpp
    engines/mads/msurface.cpp
    engines/mads/msurface.h
    engines/mads/nebular/sound_nebular.cpp
    engines/mads/nebular/sound_nebular.h
    engines/mads/palette.cpp
    engines/mads/palette.h
    engines/mads/resources.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index a915ed3..0f9a098 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -67,7 +67,7 @@ public:
 	/**
 	 * Destructor
 	 */
-	~Dialog();
+	virtual ~Dialog();
 };
 
 enum {
@@ -145,7 +145,7 @@ public:
 	/**
 	 * Destructor
 	 */
-	~TextDialog();
+	virtual ~TextDialog();
 
 	/**
 	 * Draw the dialog
@@ -162,6 +162,8 @@ class MessageDialog: protected TextDialog {
 public:
 	MessageDialog(MADSEngine *vm, int lines, ...);
 
+	virtual ~MessageDialog() {}
+
 	/**
 	 * Show the dialog, and wait until a key or mouse press.
 	 */
@@ -184,6 +186,8 @@ public:
 	Common::Point _defaultPosition;
 	DialogId _pendingDialog;
 
+	virtual ~Dialogs() {}
+
 	virtual void showDialog() = 0;
 };
 
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 2a45c3e..08d548e 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -160,7 +160,7 @@ void Game::sectionLoop() {
 			_vm->_palette->initGamePalette();
 		}
 
-		// TODO: Further palette init
+		_vm->_palette->_paletteUsage.load(3, 0xF0, 0xF1, 0xF2);
 		
 		_scene.loadScene(_scene._nextSceneId, _aaName, 0);
 		_vm->_sound->pauseNewCommands();
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 4c17b3a..ca75a50 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -249,219 +249,14 @@ void MSurface::copyFrom(MSurface *src, const Common::Rect &srcBounds,
 	}
 }
 
-void MSurface::translate(RGBList *list, bool isTransparent) {
-	byte *p = getBasePtr(0, 0);
-	byte *palIndexes = list->palIndexes();
-
-	for (int i = 0; i < getWidth() * getHeight(); ++i, ++p) {
-		if (!isTransparent || (*p != 0)) {
-			assert(*p < list->size());
-			*p = palIndexes[*p];
-		}
-	}
-}
-
-/*------------------------------------------------------------------------*/
-/*
-void MSurfaceMADS::loadBackground(int roomNumber, RGBList **palData) {
-	// clear previous data
-	empty();
-
-	// Get a MadsPack reference to the tile set and mapping
-	char resourceName[20];
-	int i;
-
-	// Uncompressed tile map resource
-	sprintf(resourceName, "rm%d.mm", roomNumber);
-	MadsPack tileMapFile(resourceName, _vm);
-	Common::SeekableReadStream *mapStream = tileMapFile.getItemStream(0);
-
-	// Get the details of the tiles and map
-	mapStream->readUint32LE();
-	int tileCountX = mapStream->readUint16LE();
-	int tileCountY = mapStream->readUint16LE();
-	int tileWidthMap = mapStream->readUint16LE();
-	int tileHeightMap = mapStream->readUint16LE();
-	int screenWidth = mapStream->readUint16LE();
-	int screenHeight = mapStream->readUint16LE();
-	int tileCountMap = tileCountX * tileCountY;
-	delete mapStream;
-
-	// Obtain tile map information
-	typedef Common::List<Common::SharedPtr<MSurface> > TileSetList;
-	typedef TileSetList::iterator TileSetIterator;
-	TileSetList tileSet;
-	uint16 *tileMap = new uint16[tileCountMap];
-	mapStream = tileMapFile.getItemStream(1);
-	for (i = 0; i < tileCountMap; ++i)
-		tileMap[i] = mapStream->readUint16LE();
-	delete mapStream;
-
-//	_vm->_resources->toss(resourceName);
-
-	// --------------------------------------------------------------------------------
-
-	// Tile map data, which needs to be kept compressed, as the tile offsets refer to
-	// the compressed data. Each tile is then uncompressed separately
-	sprintf(resourceName, "rm%d.tt", roomNumber);
-	Common::SeekableReadStream *tileDataComp = nullptr; //_vm->_resources->get(resourceName);
-	MadsPack tileData(tileDataComp);
-	Common::SeekableReadStream *tileDataUncomp = tileData.getItemStream(0);
-
-	// Validate that the data matches between the tiles and tile map file and is valid
-	int tileCount = tileDataUncomp->readUint16LE();
-	int tileWidth = tileDataUncomp->readUint16LE();
-	int tileHeight = tileDataUncomp->readUint16LE();
-	delete tileDataUncomp;
-	assert(tileCountMap == tileCount);
-	assert(tileWidth == tileWidthMap);
-	assert(tileHeight == tileHeightMap);
-	assert(screenWidth == _vm->_screen->getWidth());
-	assert(screenHeight <= _vm->_screen->getHeight());
-
-	// --------------------------------------------------------------------------------
-
-	// Get the palette to use
-	tileDataUncomp = tileData.getItemStream(2);
-	// Set palette
-	if (!palData) {
-		_vm->_palette->loadPalette(tileDataUncomp, 4);
-	} else {
-		int numColors;
-		byte *rgbList = _vm->_palette->decodePalette(tileDataUncomp, &numColors);
-		*palData = new RGBList(numColors, rgbList, true);
-	}
-	delete tileDataUncomp;
-
-	// --------------------------------------------------------------------------------
-
-	// Get tile data
-
-	tileDataUncomp = tileData.getItemStream(1);
-	FabDecompressor fab;
-	uint32 compressedTileDataSize = 0;
-
-	for (i = 0; i < tileCount; i++) {
-		tileDataUncomp->seek(i * 4, SEEK_SET);
-		uint32 tileOfs = tileDataUncomp->readUint32LE();
-		MSurface *newTile = new MSurface(tileWidth, tileHeight);
+void MSurface::translate(Common::Array<RGB6> &palette) {
+	for (int y = 0; y < this->h; ++y) {
+		byte *pDest = getBasePtr(0, y);
 
-		if (i == tileCount - 1)
-			compressedTileDataSize = tileDataComp->size() - tileOfs;
-		else
-			compressedTileDataSize = tileDataUncomp->readUint32LE() - tileOfs;
-
-		//printf("Tile: %i, compressed size: %i\n", i, compressedTileDataSize);
-
-		newTile->empty();
-
-		byte *compressedTileData = new byte[compressedTileDataSize];
-
-		tileDataComp->seek(tileData.getDataOffset() + tileOfs, SEEK_SET);
-		tileDataComp->read(compressedTileData, compressedTileDataSize);
-
-		fab.decompress(compressedTileData, compressedTileDataSize, newTile->getData(), 
-			tileWidth * tileHeight);
-		tileSet.push_back(TileSetList::value_type(newTile));
-		delete[] compressedTileData;
-	}
-
-	delete tileDataUncomp;
-
-	// --------------------------------------------------------------------------------
-
-	// Loop through the mapping data to place the tiles on the screen
-	
-	uint16 *tIndex = &tileMap[0];
-	for (int y = 0; y < tileCountY; y++) {
-		for (int x = 0; x < tileCountX; x++) {
-			int tileIndex = *tIndex++;
-			assert(tileIndex < tileCount);
-			TileSetIterator tile = tileSet.begin();
-			for (i = 0; i < tileIndex; i++)
-				++tile;
-			((*tile).get())->copyTo(this, Common::Point(x * tileWidth, y * tileHeight));
+		for (int x = 0; x < this->w; ++x, ++pDest) {
+			*pDest = palette[*pDest].palIndex;
 		}
 	}
-	tileSet.clear();
-//	_vm->_resources->toss(resourceName);
-}
-
-void MSurfaceMADS::loadInterface(int index, RGBList **palData) {
-	char resourceName[20];
-	sprintf(resourceName, "i%d.int", index);
-	MadsPack intFile(resourceName, _vm);
-	byte *palette = new byte[16 * 3];
-
-	// Chunk 0, palette
-	Common::SeekableReadStream *intStream = intFile.getItemStream(0);
-	
-	for (int i = 0; i < 16; i++) {
-		palette[i * 3] = intStream->readByte() << 2;
-		palette[i * 3 + 1] = intStream->readByte() << 2;
-		palette[i * 3 + 2] = intStream->readByte() << 2;
-		intStream->skip(3);
-	}
-	*palData = new RGBList(16, palette, true);
-	delete intStream;
-
-	// Chunk 1, data
-	intStream = intFile.getItemStream(1);
-	setSize(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
-	intStream->read(pixels, MADS_SCREEN_WIDTH * MADS_INTERFACE_HEIGHT);
-	delete intStream;
-}
-
-------------------------------------------------------------------------
-
-void MSurfaceNebular::loadBackground(int roomNumber, RGBList **palData) {
-	// clear previous data
-	empty();
-
-	Common::String resourceName = Common::String::format("rm%d.art", roomNumber);
-	Common::SeekableReadStream *stream = nullptr; //_vm->_resources->get(resourceName);	
-	loadBackgroundStream(stream, palData);
-
-//	_vm->_resources->toss(resourceName);
-}
-
-void MSurfaceNebular::loadBackgroundStream(Common::SeekableReadStream *source, RGBList **palData) {
-	MadsPack packData(source);
-	Common::MemoryReadStream *sourceUnc = packData.getItemStream(0);
-
-	int sceneWidth = sourceUnc->readUint16LE();
-	int sceneHeight = sourceUnc->readUint16LE();
-	int sceneSize = sceneWidth * sceneHeight;
-	if (sceneWidth > this->getWidth()) {
-		warning("Background width is %i, too large to fit in screen. Setting it to %i", sceneWidth, getWidth());
-		sceneWidth = this->getWidth();
-		sceneSize = sceneWidth * sceneHeight;
-	}
-	if (sceneHeight > getHeight()) {
-		warning("Background height is %i, too large to fit in screen.Setting it to %i", sceneHeight, getHeight());
-		sceneHeight = getHeight();
-		sceneSize = sceneWidth * sceneHeight;
-	}
-
-	// Set palette
-	if (!palData) {
-		_vm->_palette->loadPalette(sourceUnc, 4);
-	} else {
-		int numColors;
-		byte *rgbList = _vm->_palette->decodePalette(sourceUnc, &numColors);
-		*palData = new RGBList(numColors, rgbList, true);
-	}
-	delete sourceUnc;
-
-	// Get the raw data for the background
-	sourceUnc = packData.getItemStream(1);
-	assert((int)sourceUnc->size() >= sceneSize);
-
-	byte *pData = (byte *)pixels;
-	sourceUnc->read(pData, sceneSize);
-	
-	delete sourceUnc;
 }
-*/
 
 } // End of namespace MADS
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index 209ac97..7f4cec3 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -169,9 +169,9 @@ public:
 	}
 
 	/**
-	 * Translates the data of a surface using a specified RGBList translation matrix.
+	 * Translates the pixels of an image used the passed palette with RGB mapping
 	 */
-	void translate(RGBList *list, bool isTransparent = false);
+	void translate(Common::Array<RGB6> &palette);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp
index dba4b36..5f1d805 100644
--- a/engines/mads/nebular/sound_nebular.cpp
+++ b/engines/mads/nebular/sound_nebular.cpp
@@ -300,10 +300,10 @@ byte *ASound::loadData(int offset, int size) {
 
 void ASound::playSound(int offset, int size) {
 	// Load the specified data block
-	playSound(loadData(offset, size));
+	playSoundData(loadData(offset, size));
 }
 
-void ASound::playSound(byte *pData, int startingChannel) {
+void ASound::playSoundData(byte *pData, int startingChannel) {
 	// Scan for a high level free channel
 	for (int i = startingChannel; i < ADLIB_CHANNEL_COUNT; ++i) {
 		if (!_channels[i]._activeCount) {
@@ -1020,7 +1020,7 @@ int ASound1::command19() {
 int ASound1::command20() {
 	byte *pData = loadData(0xD18, 28);
 	if (!isSoundActive(pData))
-		playSound(pData);
+		playSoundData(pData);
 	return 0;
 }
 
@@ -1034,7 +1034,7 @@ int ASound1::command22() {
 	pData[6] = (getRandomNumber() & 7) + 85;
 
 	if (!isSoundActive(pData))
-		playSound(pData);
+		playSoundData(pData);
 
 	return 0;
 }
@@ -1055,7 +1055,7 @@ int ASound1::command24() {
 int ASound1::command25() {
 	byte *pData = loadData(0xD82, 16);
 	if (!isSoundActive(pData))
-		playSound(pData);
+		playSoundData(pData);
 
 	return 0;
 }
@@ -1091,7 +1091,7 @@ int ASound1::command29() {
 	pData[7] = pData[13] = pData[21] = pData[27] = v;
 
 	if (!isSoundActive(pData))
-		playSound(pData, 0);
+		playSoundData(pData, 0);
 
 	return 0;
 }
@@ -1101,7 +1101,7 @@ int ASound1::command30() {
 	pData[7] = (command2627293032() + 0x40) & 0xFF;
 
 	if (!isSoundActive(pData))
-		playSound(pData, 0);
+		playSoundData(pData, 0);
 
 	return 0;
 }
@@ -1109,7 +1109,7 @@ int ASound1::command30() {
 int ASound1::command31() {
 	byte *pData = loadData(0xDAE, 14);
 	if (!isSoundActive(pData))
-		playSound(pData);
+		playSoundData(pData);
 
 	return 0;
 }
@@ -1121,7 +1121,7 @@ int ASound1::command32() {
 	pData[11] = pData[19] = pData[27] = pData[35] = v >> 8;
 
 	if (!isSoundActive(pData))
-		playSound(pData, 0);
+		playSoundData(pData, 0);
 
 	return 0;
 }
@@ -1139,7 +1139,7 @@ int ASound1::command34() {
 
 	byte *pData = loadData(0xDD0, 22);
 	pData[8] = pData[15] = v;
-	playSound(pData);
+	playSoundData(pData);
 	return 0;
 }
 
diff --git a/engines/mads/nebular/sound_nebular.h b/engines/mads/nebular/sound_nebular.h
index c7a2862..caafdca 100644
--- a/engines/mads/nebular/sound_nebular.h
+++ b/engines/mads/nebular/sound_nebular.h
@@ -228,7 +228,7 @@ protected:
 	 * @param pData		Pointer to data block containing sound data
 	 * @param startingChannel	Channel to start scan from
 	 */
-	void playSound(byte *pData, int startingChannel = ADLIB_CHANNEL_COUNT);
+	void playSoundData(byte *pData, int startingChannel = ADLIB_CHANNEL_MIDWAY);
 
 	/**
 	 * Checks to see whether the given block of data is already loaded into a channel.
@@ -312,7 +312,7 @@ public:
 	 * @param commandId		Player ommand to execute.
 	 * @param param			Optional parameter used by a few commands
 	 */
-	virtual int command(int commandId, int param = 0) = 0;
+	virtual int command(int commandId, int param) = 0;
 
 	/**
 	 * Stop all currently playing sounds
@@ -402,7 +402,7 @@ private:
 public:
 	ASound1(Audio::Mixer *mixer);
 
-	virtual int command(int commandId, int param = 0);
+	virtual int command(int commandId, int param);
 };
 
 } // End of namespace Nebular
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 7c51842..aca1298 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -28,6 +28,15 @@
 
 namespace MADS {
 
+void RGB6::load(Common::SeekableReadStream *f) {
+	r = f->readByte();
+	g = f->readByte();
+	b = f->readByte();
+	palIndex = f->readByte();
+	u2 = f->readByte();
+	flags = f->readByte();
+}
+
 RGBList::RGBList(int numEntries, byte *srcData, bool freeData) {
 	_size = numEntries;
 	assert(numEntries <= PALETTE_COUNT);
@@ -52,6 +61,111 @@ RGBList::~RGBList() {
 
 /*------------------------------------------------------------------------*/
 
+PaletteUsage::PaletteUsage() {
+}
+
+void PaletteUsage::load(int count, ...) {
+	va_list va;
+	va_start(va, count);
+
+	_data.clear();
+	for (int i = 0; i < count; ++i)
+		_data.push_back(va_arg(va, int));
+
+	va_end(va);
+}
+
+
+void PaletteUsage::getKeyEntries(Common::Array<RGB6> &palette) {
+	_data.clear();
+
+	 for (uint i = 0; i < palette.size(); ++i) {
+		 byte *uPtr = &palette[i].flags;
+		 if ((*uPtr & 0x10) && _data.size() < 3) {
+			 _data.push_back(i);
+		 }
+	 }
+}
+
+void PaletteUsage::prioritize(Common::Array<RGB6> &palette) {
+	int lst[3];
+
+	for (uint i = 0; i < _data.size(); ++i) {
+		RGB6 &palEntry = palette[_data[i]];
+		lst[i] = rgbMerge(palEntry);
+	}
+	
+	prioritizeFromList(lst);
+}
+
+int PaletteUsage::rgbMerge(RGB6 &palEntry) {
+	return palEntry.r * 38 + palEntry.g * 76 + palEntry.b * 14;
+}
+
+void PaletteUsage::prioritizeFromList(int lst[3]) {
+	int idx1 = _data.size() - 1;
+	bool continueFlag;
+	int count2;
+
+	do {
+		continueFlag = false;
+		count2 = 0;
+
+		if (idx1 > 0) {
+			int numEntries = _data.size() - 1;
+			int usageIndex = 0, lstIndex = 0;
+
+			do {
+				if (lst[lstIndex] < lst[lstIndex + 1]) {
+					int lstVal = lst[lstIndex];
+					int usageVal = _data[usageIndex];
+
+					if (numEntries > 0) {
+						Common::copy(&lst[lstIndex + 1], &lst[lstIndex + numEntries], &lst[lstIndex]);
+						_data.remove_at(usageIndex);
+						_data.push_back(0);
+					}
+					
+					int newIdx = 0;
+					if (idx1 > 0 && !continueFlag) {
+						for (newIdx = 0; newIdx <= idx1; ++newIdx) {
+							if (lst[newIdx] > lstVal)
+								break;
+						}
+					}
+
+					continueFlag = true;
+					int idxDiff = _data.size() - newIdx - 1;
+					if (idxDiff > 0) {
+						Common::copy_backward(&lst[0], &lst[2], &lst[1]);
+						_data.remove_at(2);
+						_data.insert_at(0, 0);
+					}
+
+					lst[newIdx] = lstVal;
+					_data[newIdx] = usageVal;
+				}
+
+				++usageIndex;
+				--numEntries;
+				++lstIndex;
+				++count2;
+			} while (count2 > idx1 && !continueFlag);
+		}
+	} while (continueFlag);
+}
+
+void PaletteUsage::transform(Common::Array<RGB6> &palette) {
+	if (!empty()) {
+		for (uint i = 0; i < _data.size(); ++i) {
+			int palIndex = _data[i];
+			_data[i] = palette[palIndex].palIndex;
+		}
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
 #define VGA_COLOR_TRANS(x) (x == 0x3f ? 255 : x << 2)
 
 Palette::Palette(MADSEngine *vm) : _vm(vm) {
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index d0d7007..820e50f 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -37,6 +37,17 @@ struct RGB4 {
 	byte u;
 };
 
+struct RGB6 {
+	byte r;
+	byte g;
+	byte b;
+	byte palIndex;
+	byte u2;
+	byte flags;
+
+	void load(Common::SeekableReadStream *f);
+};
+
 /**
  * Used to store a list of RGB values
  */
@@ -73,6 +84,44 @@ public:
 	int size() const { return _size; }
 };
 
+class PaletteUsage {
+private:
+	Common::Array<int> _data;
+
+	int rgbMerge(RGB6 &palEntry);
+
+	void prioritizeFromList(int lst[3]);
+public:
+	PaletteUsage();
+
+	void load(int count, ...);
+
+	/**
+	 * Returns whether the usage list is empty
+	 */
+	bool empty() const { return _data.size() == 0;  }
+
+	/**
+	 * Gets key entries from the passed palette
+	 * @param palette	6-bit per entry read in palette
+	 */
+	void getKeyEntries(Common::Array<RGB6> &palette);
+
+	/**
+	 * Prioritizes the palette index list based on the intensity of the
+	 * RGB values of the palette entries that they refer to
+	 */
+	void prioritize(Common::Array<RGB6> &palette);
+
+	bool process(Common::Array<RGB6> &palette, int v) {
+		warning("TODO: PaletteUsage::process");
+		return 0;
+	}
+
+	void transform(Common::Array<RGB6> &palette);
+};
+
+
 #define PALETTE_COUNT 256
 #define PALETTE_SIZE (256 * 3)
 
@@ -95,6 +144,7 @@ protected:
 public:
 	byte _mainPalette[PALETTE_SIZE];
 	RGB4 _gamePalette[PALETTE_COUNT];
+	PaletteUsage _paletteUsage;
 public:
 	/**
 	 * Constructor
diff --git a/engines/mads/resources.cpp b/engines/mads/resources.cpp
index f24f7d2..8cfc1a2 100644
--- a/engines/mads/resources.cpp
+++ b/engines/mads/resources.cpp
@@ -305,7 +305,7 @@ Common::String Resources::formatName(RESPREFIX resType, int id, const Common::St
 
 Common::String Resources::formatResource(const Common::String &resName, 
 		const Common::String &hagFilename) {
-	int v1 = 0, v2 = 0;
+//	int v1 = 0, v2 = 0;
 
 	if (resName.hasPrefix("*")) {
 		// Resource file specified
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 138cab5..e9ae3e6 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -34,7 +34,6 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm) {
 	_vocabBuffer = nullptr;
 	_sceneLogic = nullptr;
 	_sceneInfo = nullptr;
-	_scenePalette = nullptr;
 
 	_verbList.push_back(VerbInit(VERB_LOOK, 2, 0));
 	_verbList.push_back(VerbInit(VERB_TAKE, 2, 0));
@@ -46,7 +45,6 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm) {
 	_verbList.push_back(VerbInit(VERB_PULL, 2, 0));
 	_verbList.push_back(VerbInit(VERB_CLOSE, 2, 0));
 	_verbList.push_back(VerbInit(VERB_THROW, 1, 2));
-	Common::fill((byte *)&_nullPalette[0], (byte *)&_nullPalette[3], 0);
 }
 
 Scene::~Scene() {
@@ -121,7 +119,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	_sequences.clear();
 	_messages.clear();
 
-	setPalette(_nullPalette);
+	// TODO: palletteUsage reset?  setPalette(_nullPalette);
 	_sceneInfo = SceneInfo::load(_vm, _currentSceneId, _v1, Common::String(), _vm->_game->_v2 ? 17 : 16,
 		_depthSurface, _backgroundSurface);
 }
@@ -178,8 +176,4 @@ void Scene::free() {
 	warning("TODO: Scene::free");
 }
 
-void Scene::setPalette(RGB4 *p) {
-//	_scenePalette = p;
-}
-
 } // End of namespace MADS
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index efe89c2..a1edff5 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -70,8 +70,6 @@ public:
 	int _textSpacing;
 	Common::Array<Hotspot> _hotspots;
 	ScreenObjects _screenObjects;
-	ScenePalette *_scenePalette;
-	RGB4 _nullPalette[2];
 	int _v1;
 	SceneInfo *_sceneInfo;
 	MSurface _backgroundSurface;
@@ -134,12 +132,6 @@ public:
 	 * Loads the vocab list
 	 */
 	void loadVocab();
-	
-	/**
-	 * Set the scene palette
-	 */
-	void setPalette(RGB4 *p);
-
 
 	/**
 	 * Clear the data for the scene
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index aac7075..e0c25d8 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -23,6 +23,7 @@
 #include "common/scummsys.h"
 #include "mads/scene_data.h"
 #include "mads/mads.h"
+#include "mads/compression.h"
 #include "mads/resources.h"
 #include "mads/nebular/nebular_scenes.h"
 
@@ -126,7 +127,6 @@ KernelMessage::KernelMessage() {
 	_asciiChar = '\0';
 	_asciiChar2 = '\0';
 	_colors = 0;
-	Common::Point _posiition;
 	_msgOffset = 0;
 	_numTicks = 0;
 	_frameTimer2 = 0;
@@ -164,28 +164,28 @@ Hotspot::Hotspot(Common::SeekableReadStream &f) {
 
 /*------------------------------------------------------------------------*/
 
-void ARTHeader::load(Common::SeekableReadStream &f) {
-	_width = f.readUint16LE();
-	_height = f.readUint16LE();
+void ARTHeader::load(Common::SeekableReadStream *f) {
+	// Read in dimensions of image
+	_width = f->readUint16LE();
+	_height = f->readUint16LE();
 
-	_palCount = f.readUint16LE();
-	for (int i = 0; i < 256; ++i) {
+	// Read in palette information
+	int palCount = f->readUint16LE();
+	for (int i = 0; i < palCount; ++i) {
 		RGB6 rgb;
-		rgb.r = f.readByte();
-		rgb.g = f.readByte();
-		rgb.b = f.readByte();
-		f.read(&rgb.unused[0], 3);
-
+		rgb.load(f);
 		_palette.push_back(rgb);
 	}
+	f->skip(6 * (256 - palCount));
 
-	int palCount = f.readUint16LE();
+	// Read unknown???
+	palCount = f->readUint16LE();
 	for (int i = 0; i < palCount; ++i) {
 		RGB4 rgb;
-		rgb.r = f.readByte();
-		rgb.g = f.readByte();
-		rgb.b = f.readByte();
-		rgb.u = f.readByte();
+		rgb.r = f->readByte();
+		rgb.g = f->readByte();
+		rgb.b = f->readByte();
+		rgb.u = f->readByte();
 
 		_palData.push_back(rgb);
 	}
@@ -203,12 +203,9 @@ SceneInfo::SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &
 	bool flag = true;
 	bool sceneFlag = sceneId >= 0;
 	bool ssFlag = false, wsFlag = false;
-	int handle = 0;
 	
-	SpriteAsset *spriteSets[10];
-	int xpList[10];
-	Common::fill(&spriteSets[0], &spriteSets[10], (SpriteAsset *)nullptr);
-	Common::fill(&xpList[0], &xpList[10], -1);
+	Common::Array<SpriteAsset *> spriteSets;
+	Common::Array<int> xpList;
 
 	// Figure out the resource to use
 	Common::String resourceName;
@@ -281,21 +278,53 @@ SceneInfo::SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &
 
 	// Load in the ART header and palette
 	File artFile(resourceName);
+	MadsPack artResource(&artFile);
+	Common::SeekableReadStream *stream = artResource.getItemStream(0);
+
 	ARTHeader artHeader;
-	artHeader.load(artFile);
+	artHeader.load(stream);
 	artFile.close();
 
 	// Copy out the palette data
-	for (int i = 0; i < artHeader._palData.size(); ++i)
+	for (uint i = 0; i < artHeader._palData.size(); ++i)
 		_palette.push_back(artHeader._palData[i]);
-/*
+
 	if (!(flags & 1)) {
-		if (_vm->_game->_scene->_scenePalette) {
-			//_vm->_game->_scene->_scenePalette->clean(&artHeader._palCount);
-			//_vm->_game->_scene->_scenePalette->process(&artHeader._palCount)
+		if (!_vm->_palette->_paletteUsage.empty()) {
+			_vm->_palette->_paletteUsage.getKeyEntries(artHeader._palette);
+			_vm->_palette->_paletteUsage.prioritize(artHeader._palette);
+		}
+
+		_field4C = _vm->_palette->_paletteUsage.process(artHeader._palette, 0xF800);
+		if (_field4C > 0) {
+			_vm->_palette->_paletteUsage.transform(artHeader._palette);
+
+			for (uint i = 0; i < _palette.size(); ++i) {
+				byte g = _palette[i].g;
+				_palette[g].b = artHeader._palette[g].palIndex;
+			}
 		}
 	}
-	*/
+
+	// Read in the background surface data
+	assert(_width == bgSurface.w && _height == bgSurface.h);
+	stream->read(bgSurface.getPixels(), bgSurface.w * bgSurface.h);
+
+	if (flags & 1) {
+		for (uint i = 0; i < _setNames.size(); ++i) {
+			Common::String setResName;
+			if (sceneFlag || resName.hasPrefix("*"))
+				setResName += "*";
+			setResName += _setNames[i];
+
+			SpriteAsset *sprites = new SpriteAsset(_vm, setResName, flags);
+			spriteSets.push_back(sprites);
+			xpList.push_back(-1); // TODO:: sprites->_field6
+		}
+	}
+
+
+
 	warning("TODO");
 }
 
@@ -326,12 +355,4 @@ void SceneInfo::loadCodes(MSurface &depthSurface) {
 
 /*------------------------------------------------------------------------*/
 
-void ScenePalette::clean(int *palCount) {
-	warning("TODO: ScenePalette::clean");
-}
-
-void ScenePalette::process(int *palCount) {
-	warning("TODO: ScenePalette::process");
-}
-
 } // End of namespace MADS
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 2fcd3f9..74a1ff8 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -215,6 +215,11 @@ public:
 	SceneLogic(Scene *scene): _scene(scene) {}
 
 	/**
+	 * Destructor
+	 */
+	virtual ~SceneLogic() {}
+
+	/**
 	 * Called to initially setup a scene
 	 */
 	virtual void setup() = 0;
@@ -245,21 +250,13 @@ public:
 	virtual void postActions() = 0;
 };
 
-struct RGB6 {
-	byte r;
-	byte g;
-	byte b;
-	byte unused[3];
-};
-
 struct ARTHeader {
 	int _width;
 	int _height;
-	int _palCount;
 	Common::Array<RGB6> _palette;
 	Common::Array<RGB4> _palData;
 
-	void load(Common::SeekableReadStream &f);
+	void load(Common::SeekableReadStream *f);
 };
 
 /**
@@ -303,12 +300,6 @@ public:
 		const Common::String &resName, int v3, MSurface &depthSurface, MSurface &bgSurface);
 };
 
-class ScenePalette {
-public:
-	void clean(int *palCount);
-	void process(int *palCount);
-};
-
 } // End of namespace MADS
 
 #endif /* MADS_SCENE_DATA_H */


Commit: 7880ae0b18c3e2a25ed1c4a2bc42e22066d1ff3e
    https://github.com/scummvm/scummvm/commit/7880ae0b18c3e2a25ed1c4a2bc42e22066d1ff3e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-01T17:28:24-05:00

Commit Message:
Merge branch 'master' into mads

Changed paths:
  A backends/platform/android/org/scummvm/scummvm/ScummVMEventsHoneycomb.java
    Makefile.common
    README
    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/qdm2.cpp
    audio/decoders/qdm2.h
    audio/decoders/qdm2data.h
    audio/decoders/raw.cpp
    audio/decoders/raw.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/decoders/xa.cpp
    audio/decoders/xa.h
    audio/fmopl.cpp
    audio/fmopl.h
    audio/mididrv.cpp
    audio/mididrv.h
    audio/midiparser.cpp
    audio/midiparser.h
    audio/midiparser_qt.cpp
    audio/midiparser_qt.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/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/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/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.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/gph/gph-events.cpp
    backends/events/gph/gph-events.h
    backends/events/linuxmotosdl/linuxmotosdl-events.cpp
    backends/events/linuxmotosdl/linuxmotosdl-events.h
    backends/events/maemosdl/maemosdl-events.cpp
    backends/events/maemosdl/maemosdl-events.h
    backends/events/openpandora/op-events.cpp
    backends/events/openpandora/op-events.h
    backends/events/ps3sdl/ps3sdl-events.cpp
    backends/events/ps3sdl/ps3sdl-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/n64/romfsstream.cpp
    backends/fs/n64/romfsstream.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/ps3/ps3-fs-factory.cpp
    backends/fs/ps3/ps3-fs-factory.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/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/maemosdl/maemosdl-graphics.cpp
    backends/graphics/maemosdl/maemosdl-graphics.h
    backends/graphics/null/null-graphics.h
    backends/graphics/opengl/opengl-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/sdl/sdl-graphics.cpp
    backends/graphics/sdl/sdl-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/keymapper/action.cpp
    backends/keymapper/action.h
    backends/keymapper/hardware-input.cpp
    backends/keymapper/hardware-input.h
    backends/keymapper/keymap.cpp
    backends/keymapper/keymap.h
    backends/keymapper/keymapper-defaults.h
    backends/keymapper/keymapper.cpp
    backends/keymapper/keymapper.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/sndio.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/nullmixer/nullsdl-mixer.cpp
    backends/mixer/nullmixer/nullsdl-mixer.h
    backends/mixer/sdl/sdl-mixer.cpp
    backends/mixer/sdl/sdl-mixer.h
    backends/mixer/sdl13/sdl13-mixer.cpp
    backends/mixer/sdl13/sdl13-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/android.mk
    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/org/scummvm/scummvm/ScummVMActivity.java
    backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java
    backends/platform/android/texture.cpp
    backends/platform/android/texture.h
    backends/platform/dc/DCLauncherDialog.h
    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/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/blitters.cpp
    backends/platform/ds/arm9/source/blitters.h
    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.cpp
    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.cpp
    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/gph/gph-backend.cpp
    backends/platform/gph/gph-hw.cpp
    backends/platform/gph/gph-hw.h
    backends/platform/gph/gph-main.cpp





Commit: 7f8b2025c0f4e8ee3378b4c7317f31bf31e889ec
    https://github.com/scummvm/scummvm/commit/7f8b2025c0f4e8ee3378b4c7317f31bf31e889ec
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-01T20:19:02-05:00

Commit Message:
MADS: Basic scne info loading is now working

Changed paths:
    engines/mads/assets.cpp
    engines/mads/assets.h
    engines/mads/game_data.cpp
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index 4c075d0..f7188e9 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -49,8 +49,6 @@ SpriteAsset::SpriteAsset(MADSEngine *vm, const Common::String &resourceName, int
 		spriteStream->readUint16LE();
 	}
 	_frameCount = spriteStream->readUint16LE();
-	// we skip the rest of the data
-	delete spriteStream;
 
 	// Get the palette data
 	spriteStream = sprites.getItemStream(2);
@@ -64,7 +62,6 @@ SpriteAsset::SpriteAsset(MADSEngine *vm, const Common::String &resourceName, int
 	delete[] palData;
 	delete spriteStream;
 
-	spriteStream = sprites.getItemStream(1);
 	Common::SeekableReadStream *spriteDataStream = sprites.getItemStream(3);
 
 	SpriteAssetFrame frame;
@@ -87,9 +84,13 @@ SpriteAsset::SpriteAsset(MADSEngine *vm, const Common::String &resourceName, int
 		_frames.push_back(frame);
 	}
 
-	delete spriteStream;
 	delete spriteDataStream;
 	file.close();
 }
 
+void SpriteAsset::drawScaled(int frameNumber, MSurface &depthSurface, MSurface &destSurface,
+		int scale, int depth, const Common::Point &pos) {
+	warning("TODO: SpriteAsset::drawScaled");
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/assets.h b/engines/mads/assets.h
index c64209e..5964036 100644
--- a/engines/mads/assets.h
+++ b/engines/mads/assets.h
@@ -62,6 +62,9 @@ public:
 	MSprite *getFrame(int frameIndex);
 	byte *getPalette() { return _palette; }
 	int getColorCount() { return _colorCount; }
+
+	void drawScaled(int frameNumber, MSurface &depthSurface, MSurface &destSurface,
+		int scale, int depth, const Common::Point &pos);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/game_data.cpp b/engines/mads/game_data.cpp
index df4a902..e39b85c 100644
--- a/engines/mads/game_data.cpp
+++ b/engines/mads/game_data.cpp
@@ -53,7 +53,7 @@ void InventoryObject::load(Common::SeekableReadStream &f) {
 	for (int i = 0; i < 3; ++i) {
 		_vocabList[i]._actionFlags1 = f.readByte();
 		_vocabList[i]._actionFlags2 = f.readByte();
-		_vocabList[i]._vocabId = f.readByte();
+		_vocabList[i]._vocabId = f.readUint16LE();
 	}
 
 	f.skip(4);	// field12
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index e0c25d8..8fe03f2 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -193,6 +193,18 @@ void ARTHeader::load(Common::SeekableReadStream *f) {
 
 /*------------------------------------------------------------------------*/
 
+void SceneInfo::SpriteInfo::load(Common::SeekableReadStream *f) {
+	f->skip(3);
+	_spriteSetIndex = f->readByte();
+	f->skip(2);
+	_position.x = f->readSint16LE();
+	_position.y = f->readSint16LE();
+	_depth = f->readByte();
+	_scale = f->readByte();
+}
+
+/*------------------------------------------------------------------------*/
+
 SceneInfo *SceneInfo::load(MADSEngine *vm, int sceneId, int v1, const Common::String &resName,
 		int v3, MSurface &depthSurface, MSurface &bgSurface) {
 	return new SceneInfo(vm, sceneId, v1, resName, v3, depthSurface, bgSurface);
@@ -200,13 +212,9 @@ SceneInfo *SceneInfo::load(MADSEngine *vm, int sceneId, int v1, const Common::St
 
 SceneInfo::SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &resName,
 		int flags, MSurface &depthSurface, MSurface &bgSurface) {
-	bool flag = true;
+	_vm = vm;
 	bool sceneFlag = sceneId >= 0;
-	bool ssFlag = false, wsFlag = false;
 	
-	Common::Array<SpriteAsset *> spriteSets;
-	Common::Array<int> xpList;
-
 	// Figure out the resource to use
 	Common::String resourceName;
 	if (sceneFlag) {
@@ -216,54 +224,70 @@ SceneInfo::SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &
 	}
 
 	// Open the scene info resource for access
-	File infoFile(resName);
+	File infoFile(resourceName);
+	MadsPack infoPack(&infoFile);
 
 	// Read in basic data
-	_sceneId = infoFile.readUint16LE();
-	_artFileNum = infoFile.readUint16LE();
-	_depthStyle = infoFile.readUint16LE();
-	_width = infoFile.readUint16LE();
-	_height = infoFile.readUint16LE();
-	infoFile.skip(24);
-	_nodeCount = infoFile.readUint16LE();
-	_yBandsEnd = infoFile.readUint16LE();
-	_yBandsStart = infoFile.readUint16LE();
-	_maxScale = infoFile.readUint16LE();
-	_minScale = infoFile.readUint16LE();
+	Common::SeekableReadStream *infoStream = infoPack.getItemStream(0);
+	_sceneId = infoStream->readUint16LE();
+	_artFileNum = infoStream->readUint16LE();
+	_depthStyle = infoStream->readUint16LE();
+	_width = infoStream->readUint16LE();
+	_height = infoStream->readUint16LE();
+	infoStream->skip(24);
+	_nodeCount = infoStream->readUint16LE();
+	_yBandsEnd = infoStream->readUint16LE();
+	_yBandsStart = infoStream->readUint16LE();
+	_maxScale = infoStream->readUint16LE();
+	_minScale = infoStream->readUint16LE();
 	for (int i = 0; i < 15; ++i)
-		_depthList[i] = infoFile.readUint16LE();
-	_field4A = infoFile.readUint16LE();
+		_depthList[i] = infoStream->readUint16LE();
+	_field4A = infoStream->readUint16LE();
 
 	// Load the set of objects that are associated with the scene
 	for (int i = 0; i < 20; ++i) {
 		InventoryObject obj;
-		obj.load(infoFile);
+		obj.load(*infoStream);
 		_objects.push_back(obj);
 	}
 
-	int setCount  = infoFile.readUint16LE();
-	int field40E = infoFile.readUint16LE();
+	int spriteSetsCount  = infoStream->readUint16LE();
+	int spriteInfoCount = infoStream->readUint16LE();
 
-	for (int i = 0; i < 20; ++i) {
+	// Load in sprite sets 
+	Common::StringArray setNames;
+	for (int i = 0; i < 10; ++i) {
 		char name[64];
-		infoFile.read(name, 64);
-		_setNames.push_back(Common::String(name));
+		infoStream->read(name, 64);
+
+		if (i < spriteSetsCount)
+			setNames.push_back(Common::String(name));
 	}
 
+	// Load in sprite draw information
+	Common::Array<SpriteInfo> spriteInfo;
+	for (int i = 0; i < 50; ++i) {
+		SpriteInfo info;
+		info.load(infoStream);
+
+		if (i < spriteInfoCount)
+			spriteInfo.push_back(info);
+	}
+
+	delete infoStream;
 	infoFile.close();
+
 	int width = _width;
 	int height = _height;
 
 	if (!bgSurface.getPixels()) {
 		bgSurface.setSize(width, height);
-		ssFlag = true;
 	}
 
 	if (_depthStyle == 2)
 		width >>= 2;
 	if (!depthSurface.getPixels()) {
 		depthSurface.setSize(width, height);
-		wsFlag = true;
 	}
 
 	// Load the depth surface with the scene codes
@@ -271,7 +295,7 @@ SceneInfo::SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &
 
 	// Get the ART resource
 	if (sceneFlag) {
-		resourceName = Resources::formatName(RESPREFIX_RM, sceneId, ".ART");
+		resourceName = Resources::formatName(RESPREFIX_RM, _artFileNum, ".ART");
 	} else {
 		resourceName = "*" + Resources::formatResource(resName, resName);
 	}
@@ -283,6 +307,7 @@ SceneInfo::SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &
 
 	ARTHeader artHeader;
 	artHeader.load(stream);
+	delete stream;
 	artFile.close();
 
 	// Copy out the palette data
@@ -310,12 +335,15 @@ SceneInfo::SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &
 	assert(_width == bgSurface.w && _height == bgSurface.h);
 	stream->read(bgSurface.getPixels(), bgSurface.w * bgSurface.h);
 
+	Common::Array<SpriteAsset *> spriteSets;
+	Common::Array<int> xpList;
+
 	if (flags & 1) {
-		for (uint i = 0; i < _setNames.size(); ++i) {
+		for (uint i = 0; i < setNames.size(); ++i) {
 			Common::String setResName;
 			if (sceneFlag || resName.hasPrefix("*"))
 				setResName += "*";
-			setResName += _setNames[i];
+			setResName += setNames[i];
 
 			SpriteAsset *sprites = new SpriteAsset(_vm, setResName, flags);
 			spriteSets.push_back(sprites);
@@ -323,9 +351,22 @@ SceneInfo::SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &
 		}
 	}
 
+	warning("TODO: sub_201E4(xpList, namesCount, &pal data2");
+
+	for (uint i = 0; i < spriteInfo.size(); ++i) {
+		SpriteInfo &si = spriteInfo[i];
+		SpriteAsset *asset = spriteSets[si._spriteSetIndex];
+		assert(asset && _depthStyle != 2);
 
+		asset->drawScaled(asset->getCount(), depthSurface, bgSurface,
+			si._scale, si._depth, si._position);
+	}
 
-	warning("TODO");
+	// Free the sprite sets
+	for (int i = (int)spriteSets.size() - 1; i >= 0; --i) {
+		warning("TODO: sub_201C8 SPRITE_SET.field_6");
+		delete spriteSets[i];
+	}
 }
 
 void SceneInfo::loadCodes(MSurface &depthSurface) {
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 74a1ff8..bcdd50a 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -263,6 +263,15 @@ struct ARTHeader {
  * Handles general data for a given scene
  */
 class SceneInfo {
+	class SpriteInfo {
+	public:
+		int _spriteSetIndex;
+		Common::Point _position;
+		int _depth;
+		int _scale;
+
+		void load(Common::SeekableReadStream *f);
+	};
 private:
 	MADSEngine *_vm;
 
@@ -290,7 +299,6 @@ public:
 
 	int _field4C;
 	Common::Array<InventoryObject> _objects;
-	Common::StringArray _setNames;
 	Common::Array<RGB4> _palette;
 public:
 	/**


Commit: 411a4054006be03c0c465b2707c5ef7c50eb87a1
    https://github.com/scummvm/scummvm/commit/411a4054006be03c0c465b2707c5ef7c50eb87a1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-01T22:53:08-05:00

Commit Message:
MADS: Further fixes for SceneInfo data loading

Changed paths:
    engines/mads/scene.cpp
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index e9ae3e6..c640ff8 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -120,7 +120,8 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	_messages.clear();
 
 	// TODO: palletteUsage reset?  setPalette(_nullPalette);
-	_sceneInfo = SceneInfo::load(_vm, _currentSceneId, _v1, Common::String(), _vm->_game->_v2 ? 17 : 16,
+	_sceneInfo = SceneInfo::init(_vm);
+	_sceneInfo->load(_currentSceneId, _v1, Common::String(), _vm->_game->_v2 ? 17 : 16,
 		_depthSurface, _backgroundSurface);
 }
 
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 8fe03f2..0204699 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -205,14 +205,17 @@ void SceneInfo::SpriteInfo::load(Common::SeekableReadStream *f) {
 
 /*------------------------------------------------------------------------*/
 
-SceneInfo *SceneInfo::load(MADSEngine *vm, int sceneId, int v1, const Common::String &resName,
-		int v3, MSurface &depthSurface, MSurface &bgSurface) {
-	return new SceneInfo(vm, sceneId, v1, resName, v3, depthSurface, bgSurface);
+SceneInfo *SceneInfo::init(MADSEngine *vm) {
+	if (vm->getGameID() == GType_RexNebular) {
+		return new SceneInfoNebular(vm);
+	}
+	else {
+		return new SceneInfo(vm);
+	}
 }
 
-SceneInfo::SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &resName,
+void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
 		int flags, MSurface &depthSurface, MSurface &bgSurface) {
-	_vm = vm;
 	bool sceneFlag = sceneId >= 0;
 	
 	// Figure out the resource to use
@@ -308,7 +311,6 @@ SceneInfo::SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &
 	ARTHeader artHeader;
 	artHeader.load(stream);
 	delete stream;
-	artFile.close();
 
 	// Copy out the palette data
 	for (uint i = 0; i < artHeader._palData.size(); ++i)
@@ -333,8 +335,13 @@ SceneInfo::SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &
 
 	// Read in the background surface data
 	assert(_width == bgSurface.w && _height == bgSurface.h);
+	stream = artResource.getItemStream(1);
 	stream->read(bgSurface.getPixels(), bgSurface.w * bgSurface.h);
 
+	// Close the ART file
+	delete stream;
+	artFile.close();
+
 	Common::Array<SpriteAsset *> spriteSets;
 	Common::Array<int> xpList;
 
@@ -371,13 +378,17 @@ SceneInfo::SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &
 
 void SceneInfo::loadCodes(MSurface &depthSurface) {
 	File f(Resources::formatName(RESPREFIX_RM, _sceneId, ".DAT"));
+	MadsPack codesPack(&f);
+	Common::SeekableReadStream *stream = codesPack.getItemStream(0);
 
 	uint16 width = _width;
 	uint16 height = _height;
-	byte *walkMap = new byte[f.size()];
+	byte *walkMap = new byte[stream->size()];
 
 	depthSurface.setSize(width, height);
-	f.read(walkMap, f.size());
+	stream->read(walkMap, f.size());
+	delete stream;
+	f.close();
 
 	byte *ptr = (byte *)depthSurface.getPixels();
 
@@ -396,4 +407,30 @@ void SceneInfo::loadCodes(MSurface &depthSurface) {
 
 /*------------------------------------------------------------------------*/
 
+void SceneInfoNebular::loadCodes(MSurface &depthSurface) {
+	File f(Resources::formatName(RESPREFIX_RM, _sceneId, ".DAT"));
+	MadsPack codesPack(&f);
+	Common::SeekableReadStream *stream = codesPack.getItemStream(0);
+
+	byte *destP = depthSurface.getData();
+	byte *endP = depthSurface.getBasePtr(0, depthSurface.h);
+
+	byte runLength = stream->readByte();
+	while (destP < endP && runLength > 0) {
+		byte runValue = stream->readByte();
+
+		// Write out the run length
+		Common::fill(destP, destP + runLength, runValue);
+		destP += runLength;
+
+		// Get the next run length
+		runLength = stream->readByte();
+	}
+
+	if (destP < endP)
+		Common::fill(destP, endP, 0);
+	delete stream;
+	f.close();
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index bcdd50a..1b98b9d 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -272,16 +272,18 @@ class SceneInfo {
 
 		void load(Common::SeekableReadStream *f);
 	};
-private:
+protected:
 	MADSEngine *_vm;
 
-	SceneInfo(MADSEngine *vm, int sceneId, int v1, const Common::String &resName,
-		int v3, MSurface &depthSurface, MSurface &bgSurface);
-
+	/**
+	 * Constructor
+	 */
+	SceneInfo(MADSEngine *vm) : _vm(vm) {}
+	
 	/**
 	 * Loads the given surface with depth information of a given scene
 	 */
-	void loadCodes(MSurface &depthSurface);
+	virtual void loadCodes(MSurface &depthSurface);
 public:
 	int _sceneId;
 	int _artFileNum;
@@ -302,10 +304,31 @@ public:
 	Common::Array<RGB4> _palette;
 public:
 	/**
-	 * Instantiates the class and loads the data
+	 * Destructor
 	 */
-	static SceneInfo *load(MADSEngine *vm, int sceneId, int flags, 
-		const Common::String &resName, int v3, MSurface &depthSurface, MSurface &bgSurface);
+	virtual ~SceneInfo() {}
+
+	/**
+	 * Instantiates the class
+	 */
+	static SceneInfo *init(MADSEngine *vm);
+
+	/**
+	 loads the data
+	 */
+	void load(int sceneId, int flags, const Common::String &resName, int v3, 
+		MSurface &depthSurface, MSurface &bgSurface);
+};
+
+class SceneInfoNebular : public SceneInfo {
+	friend class SceneInfo;
+protected:
+	virtual void loadCodes(MSurface &depthSurface);
+
+	/**
+	* Constructor
+	*/
+	SceneInfoNebular(MADSEngine *vm) : SceneInfo(vm) {}
 };
 
 } // End of namespace MADS


Commit: 4bd1217dafbc2c28b731bd58d4ebd7b0b16a712e
    https://github.com/scummvm/scummvm/commit/4bd1217dafbc2c28b731bd58d4ebd7b0b16a712e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-02T10:49:20-05:00

Commit Message:
MADS: Added loading for scene nodes and hotspost

Changed paths:
    engines/mads/events.h
    engines/mads/mads.h
    engines/mads/palette.cpp
    engines/mads/palette.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/events.h b/engines/mads/events.h
index 01f4817..0e990c5 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -116,6 +116,11 @@ public:
 	 * Delay for a given number of frames
 	 */
 	void delay(int amount);
+
+	/**
+	 * Gets the current frame counter
+	 */
+	uint32 getFrameCounter() const { return _gameCounter; }
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index 44630ca..92758b7 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -75,10 +75,6 @@ private:
 	const MADSGameDescription *_gameDescription;
 	Common::RandomSource _randomSource;
 
-	bool _easyMouse;
-	bool _invObjectStill;
-	bool _textWindowStill;
-
 	/**
 	 * Handles basic initialisation
 	 */
@@ -98,6 +94,9 @@ public:
 	MSurface *_screen;
 	SoundManager *_sound;
 	UserInterface *_userInterface;
+	bool _easyMouse;
+	bool _invObjectStill;
+	bool _textWindowStill;
 
 public:
 	MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc);
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index aca1298..b26329a 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -68,9 +68,11 @@ void PaletteUsage::load(int count, ...) {
 	va_list va;
 	va_start(va, count);
 
-	_data.clear();
+	if (count > (int)_data.size())
+		_data.resize(count);
+
 	for (int i = 0; i < count; ++i)
-		_data.push_back(va_arg(va, int));
+		_data[i] = va_arg(va, int);
 
 	va_end(va);
 }
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 820e50f..18b058c 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -30,6 +30,8 @@ namespace MADS {
 
 class MADSEngine;
 
+#define PALETTE_USAGE_COUNT 4
+
 struct RGB4 {
 	byte r;
 	byte g;
@@ -143,6 +145,7 @@ protected:
 	void reset();
 public:
 	byte _mainPalette[PALETTE_SIZE];
+	byte _savedPalette[PALETTE_SIZE];
 	RGB4 _gamePalette[PALETTE_COUNT];
 	PaletteUsage _paletteUsage;
 public:
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index c640ff8..af53710 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -22,6 +22,7 @@
 
 #include "common/scummsys.h"
 #include "mads/scene.h"
+#include "mads/compression.h"
 #include "mads/mads.h"
 #include "mads/nebular/nebular_scenes.h"
 
@@ -34,6 +35,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm) {
 	_vocabBuffer = nullptr;
 	_sceneLogic = nullptr;
 	_sceneInfo = nullptr;
+	_animFlag = false;
+	_animVal1 = 0;
 
 	_verbList.push_back(VerbInit(VERB_LOOK, 2, 0));
 	_verbList.push_back(VerbInit(VERB_TAKE, 2, 0));
@@ -123,15 +126,46 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	_sceneInfo = SceneInfo::init(_vm);
 	_sceneInfo->load(_currentSceneId, _v1, Common::String(), _vm->_game->_v2 ? 17 : 16,
 		_depthSurface, _backgroundSurface);
+
+	// Initialise palette animation for the scene
+	initPaletteAnimation(_sceneInfo->_palAnimData, false);
+
+	// Copy over nodes
+	_nodes.clear();
+	for (uint i = 0; i < _sceneInfo->_nodes.size(); ++i)
+		_nodes.push_back(_sceneInfo->_nodes[i]);
+
+	// Load hotspots
+	loadHotspots();
+
+	// Load vocab
+	loadVocab();
+
+	// Load palette usage
+	_vm->_palette->_paletteUsage.load(1, 0xF);
+
+	// Load interface
+	int flags = _vm->_game->_v2 ? 0x4101 : 0x4100;
+	if (!_vm->_textWindowStill)
+		flags |= 0x200;
+	// TODO
 }
 
 void Scene::loadHotspots() {
 	File f(Resources::formatName(RESPREFIX_RM, _currentSceneId, ".HH"));
-	int count = f.readUint16LE();
+	MadsPack madsPack(&f);
+
+	Common::SeekableReadStream *stream = madsPack.getItemStream(0);
+	int count = stream->readUint16LE();
+	delete stream;
 
+	stream = madsPack.getItemStream(1);
 	_hotspots.clear();
 	for (int i = 0; i < count; ++i)
-		_hotspots.push_back(Hotspot(f));
+		_hotspots.push_back(Hotspot(*stream));
+
+	delete stream;
+	f.close();
 }
 
 void Scene::loadVocab() {
@@ -163,14 +197,42 @@ void Scene::loadVocabStrings() {
 	freeVocab();
 	File f("*VOCAB.DAT");
 
-	byte *d = new byte[ f.size()];
-	f.read(d, f.size());
-
+	char *textStrings = new char[f.size()];
+	f.read(textStrings, f.size());
 
-//	int vocabId = 1;
 	for (uint strIndex = 0; strIndex < _activeVocabs.size(); ++strIndex) {
-		// TODO: Rest of this method
+		const char *s = textStrings;
+		for (int vocabIndex = 0; vocabIndex < _activeVocabs[strIndex]; ++vocabIndex)
+			s += strlen(s) + 1;
+
+		_vocabStrings.push_back(s);
 	}
+
+	delete[] textStrings;
+	f.close();
+}
+
+void Scene::initPaletteAnimation(Common::Array<RGB4> &animData, bool animFlag) {
+	// Initialise the animation palette and ticks list
+	_animTicksList.clear();
+	_animPalData.clear();
+
+	for (uint i = 0; i < animData.size(); ++i) {
+		_animTicksList.push_back(_vm->_events->getFrameCounter());
+		_animPalData.push_back(animData[i]);
+	}
+
+	// Save the initial starting palette
+	Common::copy(&_vm->_palette->_mainPalette[0], &_vm->_palette->_mainPalette[PALETTE_SIZE],
+		&_vm->_palette->_savedPalette[0]);
+
+	// Calculate total
+	_animCount = 0;
+	for (uint i = 0; i < _animPalData.size(); ++i)
+		_animCount += _animPalData[i].r;
+
+	_animVal1 = (_animCount > 16) ? 3 : 0;
+	_animFlag = animFlag;
 }
 
 void Scene::free() {
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index a1edff5..6bbab0f 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -48,6 +48,11 @@ private:
 	 * Secondary loading vocab list
 	 */
 	void loadVocabStrings();
+
+	/*
+	 * Initialises the data for palette animation within the scene
+	 */
+	void initPaletteAnimation(Common::Array<RGB4> &animData, bool animFlag);
 protected:
 	MADSEngine *_vm;
 public:
@@ -74,6 +79,13 @@ public:
 	SceneInfo *_sceneInfo;
 	MSurface _backgroundSurface;
 	MSurface _depthSurface;
+	bool _animFlag;
+	int _animVal1;
+	int _animCount;
+	Common::Array<uint32> _animTicksList;
+	Common::Array<RGB4> _animPalData;
+	SceneNodeList _nodes;
+	Common::StringArray _vocabStrings;
 
 	/**
 	 * Constructor
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 0204699..07a2ae8 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -187,12 +187,21 @@ void ARTHeader::load(Common::SeekableReadStream *f) {
 		rgb.b = f->readByte();
 		rgb.u = f->readByte();
 
-		_palData.push_back(rgb);
+		_palAnimData.push_back(rgb);
 	}
 }
 
 /*------------------------------------------------------------------------*/
 
+void SceneNode::load(Common::SeekableReadStream *f) {
+	_walkPos.x = f->readSint16LE();
+	_walkPos.y = f->readSint16LE();
+	for (int i = 0; i < MAX_ROUTE_NODES; ++i)
+		_indexes[i] = f->readUint16LE();
+}
+
+/*------------------------------------------------------------------------*/
+
 void SceneInfo::SpriteInfo::load(Common::SeekableReadStream *f) {
 	f->skip(3);
 	_spriteSetIndex = f->readByte();
@@ -237,21 +246,25 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
 	_depthStyle = infoStream->readUint16LE();
 	_width = infoStream->readUint16LE();
 	_height = infoStream->readUint16LE();
+
 	infoStream->skip(24);
-	_nodeCount = infoStream->readUint16LE();
+
+	int nodeCount = infoStream->readUint16LE();
 	_yBandsEnd = infoStream->readUint16LE();
 	_yBandsStart = infoStream->readUint16LE();
 	_maxScale = infoStream->readUint16LE();
 	_minScale = infoStream->readUint16LE();
-	for (int i = 0; i < 15; ++i)
+	for (int i = 0; i < DEPTH_BANDS_SIZE; ++i)
 		_depthList[i] = infoStream->readUint16LE();
 	_field4A = infoStream->readUint16LE();
 
 	// Load the set of objects that are associated with the scene
 	for (int i = 0; i < 20; ++i) {
-		InventoryObject obj;
-		obj.load(*infoStream);
-		_objects.push_back(obj);
+		SceneNode node;
+		node.load(infoStream);
+		
+		if (i < nodeCount)
+			_nodes.push_back(node);
 	}
 
 	int spriteSetsCount  = infoStream->readUint16LE();
@@ -313,8 +326,8 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
 	delete stream;
 
 	// Copy out the palette data
-	for (uint i = 0; i < artHeader._palData.size(); ++i)
-		_palette.push_back(artHeader._palData[i]);
+	for (uint i = 0; i < artHeader._palAnimData.size(); ++i)
+		_palAnimData.push_back(artHeader._palAnimData[i]);
 
 	if (!(flags & 1)) {
 		if (!_vm->_palette->_paletteUsage.empty()) {
@@ -326,9 +339,9 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
 		if (_field4C > 0) {
 			_vm->_palette->_paletteUsage.transform(artHeader._palette);
 
-			for (uint i = 0; i < _palette.size(); ++i) {
-				byte g = _palette[i].g;
-				_palette[g].b = artHeader._palette[g].palIndex;
+			for (uint i = 0; i < _palAnimData.size(); ++i) {
+				byte g = _palAnimData[i].g;
+				_palAnimData[g].b = artHeader._palAnimData[g].u;
 			}
 		}
 	}
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 1b98b9d..2fe5c84 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -50,6 +50,9 @@ enum {
 	VERB_WALKTO      = 13
 };
 
+#define DEPTH_BANDS_SIZE 15
+#define MAX_ROUTE_NODES 22
+
 class VerbInit {
 public:
 	int _id;
@@ -254,10 +257,28 @@ struct ARTHeader {
 	int _width;
 	int _height;
 	Common::Array<RGB6> _palette;
-	Common::Array<RGB4> _palData;
+	Common::Array<RGB4> _palAnimData;
+
+	void load(Common::SeekableReadStream *f);
+};
+
+class SceneNode {
+public:
+	Common::Point _walkPos;
+	int _indexes[MAX_ROUTE_NODES];
+	bool _active;
 
+	/**
+	 * Constructor
+	 */
+	SceneNode() : _active(false) {}
+
+	/**
+	 * Loads the scene node
+	 */
 	void load(Common::SeekableReadStream *f);
 };
+typedef Common::Array<SceneNode> SceneNodeList;
 
 /**
  * Handles general data for a given scene
@@ -291,17 +312,16 @@ public:
 	int _width;
 	int _height;
 
-	int _nodeCount;
 	int _yBandsEnd;
 	int _yBandsStart;
 	int _maxScale;
 	int _minScale;
-	int _depthList[15];
+	int _depthList[DEPTH_BANDS_SIZE];
 	int _field4A;
 
 	int _field4C;
-	Common::Array<InventoryObject> _objects;
-	Common::Array<RGB4> _palette;
+	Common::Array<RGB4> _palAnimData;
+	SceneNodeList _nodes;
 public:
 	/**
 	 * Destructor


Commit: 7912f81f2cef0a3dfad86d1a87d68771c13f7744
    https://github.com/scummvm/scummvm/commit/7912f81f2cef0a3dfad86d1a87d68771c13f7744
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-02T11:38:56-05:00

Commit Message:
MADS: Added skeleton file for animation class

Changed paths:
    engines/mads/module.mk
    engines/mads/palette.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.h



diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 62441ab..94c231e 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS := \
 	nebular/sound_nebular.o \
 	nebular/nebular_scenes.o \
 	nebular/nebular_scenes8.o \
+	animation.o \
 	assets.o \
 	compression.o \
 	debugger.o \
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index b26329a..aca1298 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -68,11 +68,9 @@ void PaletteUsage::load(int count, ...) {
 	va_list va;
 	va_start(va, count);
 
-	if (count > (int)_data.size())
-		_data.resize(count);
-
+	_data.clear();
 	for (int i = 0; i < count; ++i)
-		_data[i] = va_arg(va, int);
+		_data.push_back(va_arg(va, int));
 
 	va_end(va);
 }
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index af53710..eaa1cab 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -148,7 +148,8 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	int flags = _vm->_game->_v2 ? 0x4101 : 0x4100;
 	if (!_vm->_textWindowStill)
 		flags |= 0x200;
-	// TODO
+	_animation = Animation::init(_vm, this);
+	
 }
 
 void Scene::loadHotspots() {
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 6bbab0f..7a7959e 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -29,6 +29,7 @@
 #include "mads/assets.h"
 #include "mads/msurface.h"
 #include "mads/scene_data.h"
+#include "mads/animation.h"
 
 namespace MADS {
 
@@ -79,6 +80,7 @@ public:
 	SceneInfo *_sceneInfo;
 	MSurface _backgroundSurface;
 	MSurface _depthSurface;
+	MSurface _interfaceSurface;
 	bool _animFlag;
 	int _animVal1;
 	int _animCount;
@@ -86,6 +88,7 @@ public:
 	Common::Array<RGB4> _animPalData;
 	SceneNodeList _nodes;
 	Common::StringArray _vocabStrings;
+	Animation *_animation;
 
 	/**
 	 * Constructor
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 2fe5c84..c646215 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -50,9 +50,19 @@ enum {
 	VERB_WALKTO      = 13
 };
 
+enum MadsActionMode { ACTMODE_NONE = 0, ACTMODE_VERB = 1, ACTMODE_OBJECT = 3, ACTMODE_TALK = 6 };
+enum MadsActionMode2 { ACTMODE2_0 = 0, ACTMODE2_2 = 2, ACTMODE2_4 = 4, ACTMODE2_5 = 5 };
+enum AbortTimerMode { ABORTMODE_0 = 0, ABORTMODE_1 = 1, ABORTMODE_2 = 2 };
+
 #define DEPTH_BANDS_SIZE 15
 #define MAX_ROUTE_NODES 22
 
+struct ActionDetails {
+	int verbId;
+	int objectNameId;
+	int indirectObjectId;
+};
+
 class VerbInit {
 public:
 	int _id;
@@ -75,15 +85,19 @@ enum SpriteType {
 	ST_FULL_SCREEN_REFRESH = -2, ST_EXPIRED = -1
 };
 
-class SpriteSlot {
+class SpriteSlotSubset {
 public:
-	SpriteType _spriteType;
-	int _seqIndex;
 	int _spritesIndex;
 	int _frameNumber;
 	Common::Point _position;
 	int _depth;
 	int _scale;
+};
+
+class SpriteSlot: public SpriteSlotSubset {
+public:
+	SpriteType _spriteType;
+	int _seqIndex;
 public:
 	SpriteSlot();
 	SpriteSlot(SpriteType type, int seqIndex);


Commit: e17fdb5aaba0c4a4482367282fdc1df56f4b6115
    https://github.com/scummvm/scummvm/commit/e17fdb5aaba0c4a4482367282fdc1df56f4b6115
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-02T11:41:46-05:00

Commit Message:
MADS: Actually added new animation files

Changed paths:
  A engines/mads/animation.cpp
  A engines/mads/animation.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
new file mode 100644
index 0000000..f5144c3
--- /dev/null
+++ b/engines/mads/animation.cpp
@@ -0,0 +1,37 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 "mads/animation.h"
+
+namespace MADS {
+
+Animation *Animation::init(MADSEngine *vm, Scene *scene) {
+	return new Animation(vm, scene);
+}
+
+void Animation::load(MSurface *sceneSurface, MSurface *interfaceSurface, int sceneId,
+		int flags, byte *palette, SceneInfo *sceneInfo) {
+
+}
+
+
+} // End of namespace MADS
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
new file mode 100644
index 0000000..cc46143
--- /dev/null
+++ b/engines/mads/animation.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_ANIMATION_H
+#define MADS_ANIMATION_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+#include "common/rect.h"
+#include "mads/msurface.h"
+#include "mads/scene_data.h"
+
+namespace MADS {
+
+class MADSEngine;
+class Scene;
+
+class Animation {
+private:
+	MADSEngine *_vm;
+	Scene *_scene;
+protected:
+	Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) {}
+public:
+	static Animation *init(MADSEngine *vm, Scene *scene);
+public:
+	/**
+	 * Loads animation data
+	 */
+	void load(MSurface *sceneSurface, MSurface *interfaceSurface, int sceneId, int flags, 
+		byte *palette, SceneInfo *sceneInfo);
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_ANIMATION_H */


Commit: cc810add7479b024138f31fc559f5a9cf7f7a459
    https://github.com/scummvm/scummvm/commit/cc810add7479b024138f31fc559f5a9cf7f7a459
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-02T16:42:39-05:00

Commit Message:
MADS: In progress implementing animation loader

Changed paths:
    engines/mads/animation.cpp
    engines/mads/animation.h
    engines/mads/font.cpp
    engines/mads/font.h
    engines/mads/graphics.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h
    engines/mads/sound.cpp
    engines/mads/sound.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index f5144c3..dd62e7b 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -21,17 +21,255 @@
  */
 
 #include "mads/animation.h"
+#include "mads/compression.h"
+
+#define FILENAME_SIZE 64
 
 namespace MADS {
+	
+AAHeader::AAHeader(Common::SeekableReadStream *f) {
+	_spriteListCount = f->readUint16LE();
+	_miscEntriesCount = f->readUint16LE();
+	_frameEntriesCount = f->readUint16LE();
+	_messagesCount = f->readUint16LE();
+	f->skip(1);
+	_flags = f->readByte();
+
+	f->skip(2);
+	_animMode = f->readUint16LE();
+	_roomNumber = f->readUint16LE();
+	f->skip(2);
+	_field12 = f->readUint16LE() != 0;
+	_spriteListIndex = f->readUint16LE();
+	_scrollPosition.x = f->readSint16LE();
+	_scrollPosition.y = f->readSint16LE();
+	_scrollTicks = f->readUint16LE();
+	f->skip(8);
+
+	char buffer[FILENAME_SIZE];
+	f->read(buffer, FILENAME_SIZE);
+	buffer[FILENAME_SIZE] = '\0';
+	_interfaceFile = Common::String(buffer);
+
+	for (int i = 0; i < 10; ++i) {
+		f->read(buffer, FILENAME_SIZE);
+		buffer[FILENAME_SIZE] = '\0';
+		_spriteSetNames[i] = Common::String(buffer);
+	}
+
+	f->skip(81);
+	f->read(buffer, FILENAME_SIZE);
+	buffer[FILENAME_SIZE] = '\0';
+	_lbmFilename = Common::String(buffer);
+
+	f->skip(365);
+	f->read(buffer, FILENAME_SIZE);
+	buffer[FILENAME_SIZE] = '\0';
+	_spritesFilename = Common::String(buffer);
+
+	f->skip(48);
+	f->read(buffer, FILENAME_SIZE);
+	buffer[FILENAME_SIZE] = '\0';
+	_soundName = Common::String(buffer);
+
+	f->skip(13);
+	f->read(buffer, FILENAME_SIZE);
+	buffer[FILENAME_SIZE] = '\0';
+	_dsrName = Common::String(buffer);
+
+	f->read(buffer, FILENAME_SIZE);
+	buffer[FILENAME_SIZE] = '\0';
+	Common::String fontResource(buffer);
+}
+
+/*------------------------------------------------------------------------*/
+
+void AnimMessage::load(Common::SeekableReadStream *f) {
+	_soundId = f->readSint16LE();
+
+	char buffer[64];
+	f->read(&buffer[0], 64);
+	_msg = Common::String(buffer);
+	f->skip(4);
+	_pos.x = f->readSint16LE();
+	_pos.y = f->readSint16LE();
+	_flags = f->readUint16LE();
+	_rgb1[0] = f->readByte() << 2;
+	_rgb1[1] = f->readByte() << 2;
+	_rgb1[2] = f->readByte() << 2;
+	_rgb2[0] = f->readByte() << 2;
+	_rgb2[1] = f->readByte() << 2;
+	_rgb2[2] = f->readByte() << 2;
+	f->skip(2);	// Space for kernelMsgIndex
+	_kernelMsgIndex = -1;
+	f->skip(6);
+	_startFrame = f->readUint16LE();
+	_endFrame = f->readUint16LE();
+	f->skip(2);
+}
+
+void AnimFrameEntry::load(Common::SeekableReadStream *f) {
+	_frameNumber = f->readUint16LE();
+	_seqIndex = f->readByte();
+	_spriteSlot._spritesIndex = f->readByte();
+	_spriteSlot._frameNumber = f->readUint16LE();
+	_spriteSlot._position.x = f->readSint16LE();
+	_spriteSlot._position.y = f->readSint16LE();
+	_spriteSlot._depth = f->readSByte();
+	_spriteSlot._scale = (int8)f->readByte();
+}
+
+/*------------------------------------------------------------------------*/
+
+void AnimMiscEntry::load(Common::SeekableReadStream *f) {
+	_soundId = f->readByte();
+	_msgIndex = f->readSByte();
+	_numTicks = f->readUint16LE();
+	_posAdjust.x = f->readSint16LE();
+	_posAdjust.y = f->readSint16LE();
+	_scrollPos.x = f->readSint16LE();
+	_scrollPos.y = f->readSint16LE();
+}
+
+/*------------------------------------------------------------------------*/
 
 Animation *Animation::init(MADSEngine *vm, Scene *scene) {
 	return new Animation(vm, scene);
 }
 
-void Animation::load(MSurface *sceneSurface, MSurface *interfaceSurface, int sceneId,
-		int flags, byte *palette, SceneInfo *sceneInfo) {
+void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
+		const Common::String &resName, int flags, Common::Array<RGB4> *palAnimData, 
+		SceneInfo *sceneInfo) {
+	Common::String resourceName = resName;
+	if (!resourceName.contains("."))
+		resourceName += ".AA";
+
+	File f(resourceName);
+	MadsPack madsPack(&f);
 
+	Common::SeekableReadStream *stream = madsPack.getItemStream(0);
+	AAHeader aaHeader(stream);
+	delete stream;
+
+	if (aaHeader._animMode == 4)
+		flags |= 0x4000;
+
+	if (flags & 0x100) {
+		loadInterface(interfaceSurface, depthSurface, aaHeader, flags, palAnimData, sceneInfo);
+	}
+	if (flags & 0x200) {
+		// No data
+		aaHeader._messagesCount = 0;
+		aaHeader._frameEntriesCount = 0;
+		aaHeader._miscEntriesCount = 0;
+	}
+
+	// Initialize the reference list
+	for (int i = 0; i < aaHeader._spriteListCount; ++i)
+		_spriteListIndexes.push_back(-1);
+
+	if (aaHeader._messagesCount > 0) {
+		// Chunk 2: Following is a list of any messages for the animation
+		Common::SeekableReadStream *msgStream = madsPack.getItemStream(1);
+
+		for (int i = 0; i < aaHeader._messagesCount; ++i) {
+			AnimMessage rec;
+			rec.load(msgStream);
+			_messages.push_back(rec);
+		}
+
+		delete msgStream;
+	}
+
+	if (aaHeader._frameEntriesCount > 0) {
+		// Chunk 3: animation frame info
+		Common::SeekableReadStream *frameStream = madsPack.getItemStream(2);
+
+		for (int i = 0; i < aaHeader._frameEntriesCount; i++) {
+			AnimFrameEntry rec;
+			rec.load(frameStream);
+			_frameEntries.push_back(rec);
+		}
+
+		delete frameStream;
+	}
+	
+	if (aaHeader._miscEntriesCount > 0) {
+		// Chunk 4: Misc Data
+		Common::SeekableReadStream *miscStream = madsPack.getItemStream(3);
+
+		for (int i = 0; i < aaHeader._miscEntriesCount; ++i) {
+			AnimMiscEntry rec;
+			rec.load(miscStream);
+			_miscEntries.push_back(rec);
+		}
+
+		delete miscStream;
+	}
+	/*
+	// If the animation specifies a font, then load it for access
+	if (_flags & ANIM_CUSTOM_FONT) {
+		Common::String fontName;
+		if (madsRes)
+			fontName += "*";
+		fontName += fontResource;
+
+		if (fontName != "")
+			_font = _vm->_font->getFont(fontName.c_str());
+		else
+			warning("Attempted to set a font with an empty name");
+	}
+
+	// If a speech file is specified, then load it
+	if (!_dsrName.empty())
+		_vm->_sound->loadDSRFile(_dsrName.c_str());
+
+	// Load all the sprite sets for the animation
+	for (int i = 0; i < spriteListCount; ++i) {
+		if (_field12 && (i == _spriteListIndex))
+			// Skip over field, since it's manually loaded
+			continue;
+
+		_spriteListIndexes[i] = _view->_spriteSlots.addSprites(_spriteSetNames[i].c_str());
+	}
+
+
+	if (_field12) {
+		Common::String resName;
+		if (madsRes)
+			resName += "*";
+		resName += _spriteSetNames[_spriteListIndex];
+
+		_spriteListIndexes[_spriteListIndex] = _view->_spriteSlots.addSprites(resName.c_str());
+	}
+	*/
+	f.close();
 }
 
 
+void Animation::loadInterface(InterfaceSurface &interfaceSurface, MSurface &depthSurface,
+		AAHeader &header, int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo) {
+	_scene->_depthStyle = 0;
+	if (header._animMode <= 2) {
+		sceneInfo->load(header._roomNumber, flags, header._interfaceFile, 0, depthSurface, interfaceSurface);
+		_scene->_depthStyle = sceneInfo->_depthStyle == 2 ? 1 : 0;
+		if (palAnimData) {
+			palAnimData->clear();
+			for (uint i = 0; i < sceneInfo->_palAnimData.size(); ++i)
+				palAnimData->push_back(sceneInfo->_palAnimData[i]);
+		}
+	}
+	else if (header._animMode == 4) {
+		// Load a scene interface
+		Common::String resourceName = "*" + header._interfaceFile;
+		interfaceSurface.load(_vm, resourceName);
+
+		if (palAnimData)
+			palAnimData->clear();
+	}
+	else {
+		// Original has useless code here
+	}
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index cc46143..1e542da 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -31,23 +31,102 @@
 
 namespace MADS {
 
+enum AnimFlag { ANIM_CUSTOM_FONT = 0x20 };
+
 class MADSEngine;
 class Scene;
 
+class AnimMessage {
+public:
+	int16 _soundId;
+	Common::String _msg;
+	Common::Point _pos;
+	byte _rgb1[3], _rgb2[3];
+	int _flags;
+	int _startFrame, _endFrame;
+	int _kernelMsgIndex;
+
+	/**
+	 * Loads data for the message from a stream
+	 */
+	void load(Common::SeekableReadStream *f);
+};
+
+class AnimFrameEntry {
+public:
+	int _frameNumber;
+	int _seqIndex;
+	SpriteSlotSubset _spriteSlot;
+
+	/**
+	 * Loads data for the record
+	 */
+	void load(Common::SeekableReadStream *f);
+};
+
+class AnimMiscEntry {
+public:
+	int _soundId;
+	int _msgIndex;
+	int _numTicks;
+	Common::Point _posAdjust;
+	Common::Point _scrollPos;
+
+	/**
+	* Loads data for the record
+	*/
+	void load(Common::SeekableReadStream *f);
+};
+
+class AAHeader {
+public:
+	int _spriteListCount;
+	int _miscEntriesCount;
+	int _frameEntriesCount;
+	int _messagesCount;
+	byte _flags;
+	int _animMode;
+	int _roomNumber;
+	int _field12;
+	int _spriteListIndex;
+	Common::Point _scrollPosition;
+	uint32 _scrollTicks;
+	Common::String _interfaceFile;
+	Common::StringArray _spriteSetNames;
+	Common::String _lbmFilename;
+	Common::String _spritesFilename;
+	Common::String _soundName;
+	Common::String _dsrName;
+	Common::String _fontResource;
+
+	/**
+	 * Loads the data for a animation file header
+	 */
+	AAHeader(Common::SeekableReadStream *f);
+};
+
 class Animation {
 private:
 	MADSEngine *_vm;
 	Scene *_scene;
+
+	void loadInterface(InterfaceSurface &interfaceSurface, MSurface &depthSurface,
+		AAHeader &header, int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo);
 protected:
 	Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) {}
 public:
 	static Animation *init(MADSEngine *vm, Scene *scene);
 public:
+	Common::Array<int> _spriteListIndexes;
+	Common::Array<AnimMessage> _messages;
+	Common::Array<AnimFrameEntry> _frameEntries;
+	Common::Array<AnimMiscEntry> _miscEntries;
+public:
 	/**
 	 * Loads animation data
 	 */
-	void load(MSurface *sceneSurface, MSurface *interfaceSurface, int sceneId, int flags, 
-		byte *palette, SceneInfo *sceneInfo);
+	void load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, const Common::String &resName,
+		int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/font.cpp b/engines/mads/font.cpp
index 5254150..10d51fb 100644
--- a/engines/mads/font.cpp
+++ b/engines/mads/font.cpp
@@ -205,4 +205,10 @@ int Font::getBpp(int charWidth) {
 		return 1;
 }
 
+Font *Font::getFont(const Common::String &fontName) {
+	Font *font = new Font(_vm);
+	font->setFont(fontName);
+	return font;
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/font.h b/engines/mads/font.h
index 3deb3f4..c642831 100644
--- a/engines/mads/font.h
+++ b/engines/mads/font.h
@@ -68,6 +68,11 @@ public:
 	int writeString(MSurface *surface, const Common::String &msg, const Common::Point &pt, int width = 0, int spaceWidth = -1) {
 		return write(surface, msg, pt, width, spaceWidth, _fontColors);
 	}
+
+	/**
+	 * Returns a new Font instance using the specified font name
+	 */
+	Font *getFont(const Common::String &fontName);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/graphics.h b/engines/mads/graphics.h
index 87cd8be..cadbbc8 100644
--- a/engines/mads/graphics.h
+++ b/engines/mads/graphics.h
@@ -29,7 +29,6 @@ namespace MADS {
 
 #define MADS_SCREEN_WIDTH 320
 #define MADS_SCREEN_HEIGHT 200
-#define MADS_INTERFACE_HEIGHT 44
 
 } // End of namespace MADS
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index eaa1cab..e6c02b8 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -37,6 +37,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm) {
 	_sceneInfo = nullptr;
 	_animFlag = false;
 	_animVal1 = 0;
+	_depthStyle = 0;
 
 	_verbList.push_back(VerbInit(VERB_LOOK, 2, 0));
 	_verbList.push_back(VerbInit(VERB_TAKE, 2, 0));
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 7a7959e..2c5880a 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -80,7 +80,7 @@ public:
 	SceneInfo *_sceneInfo;
 	MSurface _backgroundSurface;
 	MSurface _depthSurface;
-	MSurface _interfaceSurface;
+	InterfaceSurface _interfaceSurface;
 	bool _animFlag;
 	int _animVal1;
 	int _animCount;
@@ -89,6 +89,7 @@ public:
 	SceneNodeList _nodes;
 	Common::StringArray _vocabStrings;
 	Animation *_animation;
+	int _depthStyle;
 
 	/**
 	 * Constructor
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 07a2ae8..cec3e45 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -24,6 +24,7 @@
 #include "mads/scene_data.h"
 #include "mads/mads.h"
 #include "mads/compression.h"
+#include "mads/graphics.h"
 #include "mads/resources.h"
 #include "mads/nebular/nebular_scenes.h"
 
@@ -214,6 +215,34 @@ void SceneInfo::SpriteInfo::load(Common::SeekableReadStream *f) {
 
 /*------------------------------------------------------------------------*/
 
+void InterfaceSurface::load(MADSEngine *vm, const Common::String &resName) {
+	File f(resName);
+	MadsPack madsPack(&f);
+
+	// Load in the palette
+	Common::SeekableReadStream *palStream = madsPack.getItemStream(0);
+
+	RGB4 *gamePalP = &vm->_palette->_gamePalette[0];
+	byte *palP = &vm->_palette->_mainPalette[0];
+
+	for (int i = 0; i < 16; ++i, gamePalP++, palP += 3) {
+		palP[0] = palStream->readByte();
+		palP[1] = palStream->readByte();
+		palP[2] = palStream->readByte();
+		gamePalP->r |= 1;
+		palStream->skip(3);
+	}
+	delete palStream;
+
+	// set the size for the interface
+	setSize(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
+	Common::SeekableReadStream *pixelsStream = madsPack.getItemStream(1);
+	pixelsStream->read(getData(), MADS_SCREEN_WIDTH * MADS_INTERFACE_HEIGHT);
+	delete pixelsStream;
+}
+
+/*------------------------------------------------------------------------*/
+
 SceneInfo *SceneInfo::init(MADSEngine *vm) {
 	if (vm->getGameID() == GType_RexNebular) {
 		return new SceneInfoNebular(vm);
@@ -356,7 +385,7 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
 	artFile.close();
 
 	Common::Array<SpriteAsset *> spriteSets;
-	Common::Array<int> xpList;
+	Common::Array<int> indexList;
 
 	if (flags & 1) {
 		for (uint i = 0; i < setNames.size(); ++i) {
@@ -367,11 +396,11 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
 
 			SpriteAsset *sprites = new SpriteAsset(_vm, setResName, flags);
 			spriteSets.push_back(sprites);
-			xpList.push_back(-1); // TODO:: sprites->_field6
+			indexList.push_back(-1); // TODO:: sprites->_field6
 		}
 	}
 
-	warning("TODO: sub_201E4(xpList, namesCount, &pal data2");
+	warning("TODO: sub_201E4(indexList, namesCount, &pal data2");
 
 	for (uint i = 0; i < spriteInfo.size(); ++i) {
 		SpriteInfo &si = spriteInfo[i];
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index c646215..23eee34 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -54,6 +54,9 @@ enum MadsActionMode { ACTMODE_NONE = 0, ACTMODE_VERB = 1, ACTMODE_OBJECT = 3, AC
 enum MadsActionMode2 { ACTMODE2_0 = 0, ACTMODE2_2 = 2, ACTMODE2_4 = 4, ACTMODE2_5 = 5 };
 enum AbortTimerMode { ABORTMODE_0 = 0, ABORTMODE_1 = 1, ABORTMODE_2 = 2 };
 
+#define MADS_INTERFACE_HEIGHT 44
+#define MADS_SCENE_HEIGHT (MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT)
+
 #define DEPTH_BANDS_SIZE 15
 #define MAX_ROUTE_NODES 22
 
@@ -294,6 +297,11 @@ public:
 };
 typedef Common::Array<SceneNode> SceneNodeList;
 
+class InterfaceSurface : public MSurface {
+public:
+	void load(MADSEngine *vm, const Common::String &resName);
+};
+
 /**
  * Handles general data for a given scene
  */
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index ea02390..ae33846 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -90,6 +90,10 @@ void SoundManager::startQueuedCommands() {
 	}
 }
 
+void SoundManager::loadDSRFile(const Common::String &filename) {
+	error("TODO: SoundManager::loadDSRFile");
+}
+
 void SoundManager::command(int commandId, int param) {
 	if (_newSoundsPaused) {
 		if (_queuedCommands.size() < 8)
diff --git a/engines/mads/sound.h b/engines/mads/sound.h
index 0fd9ac1..1fe322d 100644
--- a/engines/mads/sound.h
+++ b/engines/mads/sound.h
@@ -77,6 +77,11 @@ public:
 	 */
 	void startQueuedCommands();
 
+	/**
+	 * Loads a DSR resource
+	 */
+	void loadDSRFile(const Common::String &filename);
+
 	//@{
 	/**
 	 * Executes a command on the sound driver


Commit: d5b5cbbb686596f50cdb9ea072c9178775ada720
    https://github.com/scummvm/scummvm/commit/d5b5cbbb686596f50cdb9ea072c9178775ada720
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-02T17:49:52-05:00

Commit Message:
MADS: Implemented rest of animation loading

Changed paths:
    engines/mads/animation.cpp
    engines/mads/animation.h
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h
    engines/mads/sound.cpp
    engines/mads/sound.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index dd62e7b..339ee72 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -39,7 +39,7 @@ AAHeader::AAHeader(Common::SeekableReadStream *f) {
 	_animMode = f->readUint16LE();
 	_roomNumber = f->readUint16LE();
 	f->skip(2);
-	_field12 = f->readUint16LE() != 0;
+	_manualFlag = f->readUint16LE() != 0;
 	_spriteListIndex = f->readUint16LE();
 	_scrollPosition.x = f->readSint16LE();
 	_scrollPosition.y = f->readSint16LE();
@@ -137,9 +137,19 @@ Animation *Animation::init(MADSEngine *vm, Scene *scene) {
 	return new Animation(vm, scene);
 }
 
+Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) {
+	_font = nullptr;
+}
+
+Animation::~Animation() {
+	delete _font;
+	for (uint i = 0; i < _spriteSets.size(); ++i)
+		delete _spriteSets[i];
+}
+
 void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
-		const Common::String &resName, int flags, Common::Array<RGB4> *palAnimData, 
-		SceneInfo *sceneInfo) {
+	const Common::String &resName, int flags, Common::Array<RGB4> *palAnimData,
+	SceneInfo *sceneInfo) {
 	Common::String resourceName = resName;
 	if (!resourceName.contains("."))
 		resourceName += ".AA";
@@ -165,9 +175,11 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 	}
 
 	// Initialize the reference list
+	_spriteListIndexes.clear();
 	for (int i = 0; i < aaHeader._spriteListCount; ++i)
 		_spriteListIndexes.push_back(-1);
 
+	_messages.clear();
 	if (aaHeader._messagesCount > 0) {
 		// Chunk 2: Following is a list of any messages for the animation
 		Common::SeekableReadStream *msgStream = madsPack.getItemStream(1);
@@ -181,6 +193,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 		delete msgStream;
 	}
 
+	_frameEntries.clear();
 	if (aaHeader._frameEntriesCount > 0) {
 		// Chunk 3: animation frame info
 		Common::SeekableReadStream *frameStream = madsPack.getItemStream(2);
@@ -194,6 +207,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 		delete frameStream;
 	}
 	
+	_miscEntries.clear();
 	if (aaHeader._miscEntriesCount > 0) {
 		// Chunk 4: Misc Data
 		Common::SeekableReadStream *miscStream = madsPack.getItemStream(3);
@@ -206,43 +220,55 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 
 		delete miscStream;
 	}
-	/*
+	
 	// If the animation specifies a font, then load it for access
-	if (_flags & ANIM_CUSTOM_FONT) {
-		Common::String fontName;
-		if (madsRes)
-			fontName += "*";
-		fontName += fontResource;
-
-		if (fontName != "")
-			_font = _vm->_font->getFont(fontName.c_str());
-		else
-			warning("Attempted to set a font with an empty name");
+	delete _font;
+	if (aaHeader._flags & ANIM_CUSTOM_FONT) {
+		Common::String fontName = "*" + aaHeader._fontResource;
+		_font = _vm->_font->getFont(fontName.c_str());
+	} else {
+		_font = nullptr;
 	}
-
-	// If a speech file is specified, then load it
-	if (!_dsrName.empty())
-		_vm->_sound->loadDSRFile(_dsrName.c_str());
-
+	
 	// Load all the sprite sets for the animation
-	for (int i = 0; i < spriteListCount; ++i) {
-		if (_field12 && (i == _spriteListIndex))
-			// Skip over field, since it's manually loaded
-			continue;
+	for (uint i = 0; i < _spriteSets.size(); ++i)
+		delete _spriteSets[i];
+	_spriteSets.clear();
+	_spriteSets.resize(aaHeader._spriteListCount);
 
-		_spriteListIndexes[i] = _view->_spriteSlots.addSprites(_spriteSetNames[i].c_str());
+	for (int i = 0; i < aaHeader._spriteListCount; ++i) {
+		if (aaHeader._manualFlag && (i == aaHeader._spriteListIndex)) {
+			// Skip over field, since it's manually loaded
+			_spriteSets[i] = nullptr;
+		} else {
+			_spriteSets[i] = new SpriteAsset(_vm, aaHeader._spriteSetNames[i], flags);
+		}
 	}
 
+	if (aaHeader._manualFlag) {
+		Common::String resName = "*" + aaHeader._spriteSetNames[aaHeader._spriteListIndex];
+		SpriteAsset *sprites = new SpriteAsset(_vm, resName, flags);
+		_spriteSets[aaHeader._spriteListIndex] = sprites;
+
+		_spriteListIndexes[aaHeader._spriteListIndex] = _scene->_sprites.add(sprites);
+	}
 
-	if (_field12) {
-		Common::String resName;
-		if (madsRes)
-			resName += "*";
-		resName += _spriteSetNames[_spriteListIndex];
+	// TODO: List var_420/var_422 population that seems to overwrite other structures?
 
-		_spriteListIndexes[_spriteListIndex] = _view->_spriteSlots.addSprites(resName.c_str());
+	if (aaHeader._animMode == 4) {
+		// Remaps the sprite list indexes for frames to the loaded sprite list indexes
+		for (uint i = 0; i < _frameEntries.size(); ++i) {
+			int spriteListIndex = _frameEntries[i]._spriteSlot._spritesIndex;
+			_frameEntries[i]._spriteSlot._spritesIndex = _spriteListIndexes[spriteListIndex];
+		}
+	} else {
+		// Remaps the sprite list indexes for frames to the loaded sprite list indexes
+		for (uint i = 0; i < _frameEntries.size(); ++i) {
+			int spriteListIndex = _frameEntries[i]._spriteSlot._spritesIndex;
+			_frameEntries[i]._spriteSlot._spritesIndex = _spriteListIndexes[spriteListIndex];
+		}
 	}
-	*/
+
 	f.close();
 }
 
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 1e542da..d96e89b 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -28,6 +28,7 @@
 #include "common/rect.h"
 #include "mads/msurface.h"
 #include "mads/scene_data.h"
+#include "mads/font.h"
 
 namespace MADS {
 
@@ -87,7 +88,7 @@ public:
 	byte _flags;
 	int _animMode;
 	int _roomNumber;
-	int _field12;
+	bool _manualFlag;
 	int _spriteListIndex;
 	Common::Point _scrollPosition;
 	uint32 _scrollTicks;
@@ -113,7 +114,7 @@ private:
 	void loadInterface(InterfaceSurface &interfaceSurface, MSurface &depthSurface,
 		AAHeader &header, int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo);
 protected:
-	Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) {}
+	Animation(MADSEngine *vm, Scene *scene);
 public:
 	static Animation *init(MADSEngine *vm, Scene *scene);
 public:
@@ -121,7 +122,14 @@ public:
 	Common::Array<AnimMessage> _messages;
 	Common::Array<AnimFrameEntry> _frameEntries;
 	Common::Array<AnimMiscEntry> _miscEntries;
+	Common::Array<SpriteAsset *> _spriteSets;
+	Font *_font;
 public:
+	/*
+	 * Destructor
+	 */
+	~Animation();
+
 	/**
 	 * Loads animation data
 	 */
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 2c5880a..03980f7 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -64,7 +64,7 @@ public:
 	Common::Array<VerbInit> _verbList;
 	Common::Array<TextDisplay> _textDisplay;
 	SpriteSlots _spriteSlots;
-	Common::Array<SpriteAsset *> _sprites;
+	SpriteSets _sprites;
 	int _spritesIndex;
 	Common::Array<DynamicHotspot> _dynamicHotspots;
 	bool _dynamicHotspotsChanged;
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index cec3e45..db22375 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -78,6 +78,19 @@ void SpriteSlots::deleteEntry(int index) {
 	remove_at(index);
 }
 
+/*------------------------------------------------------------------------*/
+
+int SpriteSets::add(SpriteAsset *asset, int idx) {
+	if (!idx)
+		idx = size();
+
+	if (idx >= (size() + 1))
+		resize(idx + 1);
+	delete (*this)[idx];
+	(*this)[idx] = asset;
+
+	return idx;
+}
 
 /*------------------------------------------------------------------------*/
 
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 23eee34..87fddfe 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -130,6 +130,14 @@ public:
 	void deleteEntry(int index);
 };
 
+class SpriteSets: public Common::Array<SpriteAsset *> {
+public:
+	/**
+	 * Add a sprite asset to the list
+	 */
+	int add(SpriteAsset *asset, int idx = 0);
+};
+
 class TextDisplay {
 public:
 	bool _active;
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index ae33846..ea02390 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -90,10 +90,6 @@ void SoundManager::startQueuedCommands() {
 	}
 }
 
-void SoundManager::loadDSRFile(const Common::String &filename) {
-	error("TODO: SoundManager::loadDSRFile");
-}
-
 void SoundManager::command(int commandId, int param) {
 	if (_newSoundsPaused) {
 		if (_queuedCommands.size() < 8)
diff --git a/engines/mads/sound.h b/engines/mads/sound.h
index 1fe322d..0fd9ac1 100644
--- a/engines/mads/sound.h
+++ b/engines/mads/sound.h
@@ -77,11 +77,6 @@ public:
 	 */
 	void startQueuedCommands();
 
-	/**
-	 * Loads a DSR resource
-	 */
-	void loadDSRFile(const Common::String &filename);
-
 	//@{
 	/**
 	 * Executes a command on the sound driver


Commit: 4931c8257df6d5dbc3d7fa1bc2b85f859cec17d9
    https://github.com/scummvm/scummvm/commit/4931c8257df6d5dbc3d7fa1bc2b85f859cec17d9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-02T18:37:09-05:00

Commit Message:
MADS: Further animation loading and final section of scene loading code

Changed paths:
    engines/mads/animation.cpp
    engines/mads/animation.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 339ee72..ebb2289 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -23,12 +23,12 @@
 #include "mads/animation.h"
 #include "mads/compression.h"
 
-#define FILENAME_SIZE 64
+#define FILENAME_SIZE 13
 
 namespace MADS {
 	
 AAHeader::AAHeader(Common::SeekableReadStream *f) {
-	_spriteListCount = f->readUint16LE();
+	_spriteSetsCount = f->readUint16LE();
 	_miscEntriesCount = f->readUint16LE();
 	_frameEntriesCount = f->readUint16LE();
 	_messagesCount = f->readUint16LE();
@@ -43,43 +43,43 @@ AAHeader::AAHeader(Common::SeekableReadStream *f) {
 	_spriteListIndex = f->readUint16LE();
 	_scrollPosition.x = f->readSint16LE();
 	_scrollPosition.y = f->readSint16LE();
-	_scrollTicks = f->readUint16LE();
-	f->skip(8);
+	_scrollTicks = f->readUint32LE();
+	f->skip(6);
 
 	char buffer[FILENAME_SIZE];
 	f->read(buffer, FILENAME_SIZE);
-	buffer[FILENAME_SIZE] = '\0';
+	buffer[FILENAME_SIZE - 1] = '\0';
 	_interfaceFile = Common::String(buffer);
 
 	for (int i = 0; i < 10; ++i) {
 		f->read(buffer, FILENAME_SIZE);
-		buffer[FILENAME_SIZE] = '\0';
-		_spriteSetNames[i] = Common::String(buffer);
+		buffer[FILENAME_SIZE - 1] = '\0';
+		_spriteSetNames.push_back(Common::String(buffer));
 	}
 
 	f->skip(81);
 	f->read(buffer, FILENAME_SIZE);
-	buffer[FILENAME_SIZE] = '\0';
+	buffer[FILENAME_SIZE - 1] = '\0';
 	_lbmFilename = Common::String(buffer);
 
 	f->skip(365);
 	f->read(buffer, FILENAME_SIZE);
-	buffer[FILENAME_SIZE] = '\0';
+	buffer[FILENAME_SIZE - 1] = '\0';
 	_spritesFilename = Common::String(buffer);
 
 	f->skip(48);
 	f->read(buffer, FILENAME_SIZE);
-	buffer[FILENAME_SIZE] = '\0';
+	buffer[FILENAME_SIZE - 1] = '\0';
 	_soundName = Common::String(buffer);
 
 	f->skip(13);
 	f->read(buffer, FILENAME_SIZE);
-	buffer[FILENAME_SIZE] = '\0';
+	buffer[FILENAME_SIZE - 1] = '\0';
 	_dsrName = Common::String(buffer);
 
 	f->read(buffer, FILENAME_SIZE);
-	buffer[FILENAME_SIZE] = '\0';
-	Common::String fontResource(buffer);
+	buffer[FILENAME_SIZE - 1] = '\0';
+	_fontResource = Common::String(buffer);
 }
 
 /*------------------------------------------------------------------------*/
@@ -176,7 +176,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 
 	// Initialize the reference list
 	_spriteListIndexes.clear();
-	for (int i = 0; i < aaHeader._spriteListCount; ++i)
+	for (int i = 0; i < aaHeader._spriteSetsCount; ++i)
 		_spriteListIndexes.push_back(-1);
 
 	_messages.clear();
@@ -234,9 +234,9 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 	for (uint i = 0; i < _spriteSets.size(); ++i)
 		delete _spriteSets[i];
 	_spriteSets.clear();
-	_spriteSets.resize(aaHeader._spriteListCount);
+	_spriteSets.resize(aaHeader._spriteSetsCount);
 
-	for (int i = 0; i < aaHeader._spriteListCount; ++i) {
+	for (int i = 0; i < aaHeader._spriteSetsCount; ++i) {
 		if (aaHeader._manualFlag && (i == aaHeader._spriteListIndex)) {
 			// Skip over field, since it's manually loaded
 			_spriteSets[i] = nullptr;
@@ -272,7 +272,6 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 	f.close();
 }
 
-
 void Animation::loadInterface(InterfaceSurface &interfaceSurface, MSurface &depthSurface,
 		AAHeader &header, int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo) {
 	_scene->_depthStyle = 0;
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index d96e89b..ce145cdd 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -81,7 +81,7 @@ public:
 
 class AAHeader {
 public:
-	int _spriteListCount;
+	int _spriteSetsCount;
 	int _miscEntriesCount;
 	int _frameEntriesCount;
 	int _messagesCount;
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index e6c02b8..23c118e 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -149,8 +149,24 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	int flags = _vm->_game->_v2 ? 0x4101 : 0x4100;
 	if (!_vm->_textWindowStill)
 		flags |= 0x200;
+
 	_animation = Animation::init(_vm, this);
+	MSurface surface;
+	_animation->load(surface, _interfaceSurface, prefix, flags, nullptr, nullptr);
 	
+	_vm->_palette->_paletteUsage.load(0);
+
+	_bandsRange = _sceneInfo->_yBandsEnd - _sceneInfo->_yBandsStart;
+	_scaleRange = _sceneInfo->_maxScale - _sceneInfo->_minScale;
+
+	_spriteSlots.clear(false);
+	_screenY = 0;
+	_interfaceY = MADS_SCENE_HEIGHT;
+	_spritesCount = _sprites.size();
+
+	warning("TODO: sub_1EA80 / showMouse");
+
+	warning("TODO: inventory_anim_allocate");
 }
 
 void Scene::loadHotspots() {
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 03980f7..4968291 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -90,6 +90,11 @@ public:
 	Common::StringArray _vocabStrings;
 	Animation *_animation;
 	int _depthStyle;
+	int _bandsRange;
+	int _scaleRange;
+	int _screenY;
+	int _interfaceY;
+	int _spritesCount;
 
 	/**
 	 * Constructor
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index db22375..d7aaa62 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -84,7 +84,7 @@ int SpriteSets::add(SpriteAsset *asset, int idx) {
 	if (!idx)
 		idx = size();
 
-	if (idx >= (size() + 1))
+	if (idx >= (int)(size() + 1))
 		resize(idx + 1);
 	delete (*this)[idx];
 	(*this)[idx] = asset;
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 87fddfe..557a6aa 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -55,7 +55,7 @@ enum MadsActionMode2 { ACTMODE2_0 = 0, ACTMODE2_2 = 2, ACTMODE2_4 = 4, ACTMODE2_
 enum AbortTimerMode { ABORTMODE_0 = 0, ABORTMODE_1 = 1, ABORTMODE_2 = 2 };
 
 #define MADS_INTERFACE_HEIGHT 44
-#define MADS_SCENE_HEIGHT (MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT)
+#define MADS_SCENE_HEIGHT 156
 
 #define DEPTH_BANDS_SIZE 15
 #define MAX_ROUTE_NODES 22


Commit: b816b9990d98633794f42ba49aeb971d6f9d930b
    https://github.com/scummvm/scummvm/commit/b816b9990d98633794f42ba49aeb971d6f9d930b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-02T19:29:54-05:00

Commit Message:
MADS: Added skeleton class for actions

Changed paths:
  A engines/mads/action.cpp
  A engines/mads/action.h
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/module.mk
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
new file mode 100644
index 0000000..d27bd85
--- /dev/null
+++ b/engines/mads/action.cpp
@@ -0,0 +1,340 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "mads/action.h"
+#include "mads/scene.h"
+
+namespace MADS {
+
+MadsAction::MadsAction(Scene *scene) : _scene(scene) {
+	clear();
+	_currentAction = VERB_NONE;
+	_startWalkFlag = false;
+	_statusTextIndex = -1;
+	_selectedAction = 0;
+	_inProgress = false;
+}
+
+void MadsAction::clear() {
+	_v83338 = 1;
+	_actionMode = ACTMODE_NONE;
+	_actionMode2 = ACTMODE2_0;
+	_v86F42 = 0;
+	_v86F4E = 0;
+	_articleNumber = 0;
+	_lookFlag = false;
+	_v86F4A = 0;
+	_statusText[0] = '\0';
+	_selectedRow = -1;
+	_hotspotId = -1;
+	_v86F3A = -1;
+	_v86F4C = -1;
+	_action.verbId = -1;
+	_action.objectNameId = -1;
+	_action.indirectObjectId = -1;
+	_textChanged = true;
+	_walkFlag = false;
+}
+
+void MadsAction::appendVocab(int vocabId, bool capitalise) {
+	/*
+	char *s = _statusText + strlen(_statusText);
+	vocabStr = _madsVm->globals()->getVocab(vocabId);
+	strcpy(s, vocabStr);
+	if (capitalise)
+		*s = toupper(*s);
+
+	strcat(s, " ");
+	*/
+}
+
+void MadsAction::set() {
+	/*
+	int hotspotCount = _madsVm->scene()->getSceneResources().hotspots->size();
+	bool flag = false; // FIXME: unused
+	strcpy(_statusText, "");
+
+	_currentAction = -1;
+	_action.objectNameId = -1;
+	_action.indirectObjectId = -1;
+
+	if (_actionMode == ACTMODE_TALK) {
+		// Handle showing the conversation selection. Rex at least doesn't actually seem to use this
+		if (_selectedRow >= 0) {
+			const char *desc = _madsVm->_converse[_selectedRow].desc;
+			if (desc)
+				strcpy(_statusText, desc);
+		}
+	} else if (_lookFlag && (_selectedRow == 0)) {
+		// Two 'look' actions in succession, so the action becomes 'Look around'
+		strcpy(_statusText, lookAroundStr);
+	} else {
+		if ((_actionMode == ACTMODE_OBJECT) && (_selectedRow >= 0) && (_flags1 == 2) && (_flags2 == 0)) {
+			// Use/to action
+			int selectedObject = _madsVm->scene()->getInterface()->getSelectedObject();
+			MadsObject *objEntry = _madsVm->globals()->getObject(selectedObject);
+
+			_action.objectNameId = objEntry->_descId;
+			_currentAction = objEntry->_vocabList[_selectedRow].vocabId;
+
+			// Set up the status text stirng
+			strcpy(_statusText, useStr);
+			appendVocab(_action.objectNameId);
+			strcpy(_statusText, toStr);
+			appendVocab(_currentAction);
+		} else {
+			// Handling for if an action has been selected
+			if (_selectedRow >= 0) {
+				if (_actionMode == ACTMODE_VERB) {
+					// Standard verb action
+					_currentAction = verbList[_selectedRow].verb;
+				} else {
+					// Selected action on an inventory object
+					int selectedObject = _madsVm->scene()->getInterface()->getSelectedObject();
+					MadsObject *objEntry = _madsVm->globals()->getObject(selectedObject);
+
+					_currentAction = objEntry->_vocabList[_selectedRow].vocabId;
+				}
+
+				appendVocab(_currentAction, true);
+
+				if (_currentAction == kVerbLook) {
+					// Add in the word 'add'
+					strcat(_statusText, atStr);
+					strcat(_statusText, " ");
+				}
+			}
+
+			// Handling for if a hotspot has been selected/highlighted
+			if ((_hotspotId >= 0) && (_selectedRow >= 0) && (_articleNumber > 0) && (_flags1 == 2)) {
+				flag = true;
+
+				strcat(_statusText, englishMADSArticleList[_articleNumber]);
+				strcat(_statusText, " ");
+			}
+
+			if (_hotspotId >= 0) {
+				if (_selectedRow < 0) {
+					int verbId;
+
+					if (_hotspotId < hotspotCount) {
+						// Get the verb Id from the hotspot
+						verbId = (*_madsVm->scene()->getSceneResources().hotspots)[_hotspotId].getVerbID();
+					} else {
+						// Get the verb Id from the scene object
+						verbId = (*_madsVm->scene()->getSceneResources().dynamicHotspots)[_hotspotId - hotspotCount].getVerbID();
+					}
+
+					if (verbId > 0) {
+						// Set the specified action
+						_currentAction = verbId;
+						appendVocab(_currentAction, true);
+					} else {
+						// Default to a standard 'walk to'
+						_currentAction = kVerbWalkTo;
+						strcat(_statusText, walkToStr);
+					}
+				}
+
+				if ((_actionMode2 == ACTMODE2_2) || (_actionMode2 == ACTMODE2_5)) {
+					// Get name from given inventory object
+					int objectId = _madsVm->scene()->getInterface()->getInventoryObject(_hotspotId);
+					_action.objectNameId = _madsVm->globals()->getObject(objectId)->_descId;
+				} else if (_hotspotId < hotspotCount) {
+					// Get name from scene hotspot
+					_action.objectNameId = (*_madsVm->scene()->getSceneResources().hotspots)[_hotspotId].getVocabID();
+				} else {
+					// Get name from temporary scene hotspot
+					_action.objectNameId = (*_madsVm->scene()->getSceneResources().dynamicHotspots)[_hotspotId].getVocabID();
+				}
+				appendVocab(_action.objectNameId);
+			}
+		}
+
+		if ((_hotspotId >= 0) && (_articleNumber > 0) && !flag) {
+			if (_articleNumber == -1) {
+				if (_v86F3A >= 0) {
+					int articleNum = 0;
+
+					if ((_v86F42 == 2) || (_v86F42 == 5)) {
+						int objectId = _madsVm->scene()->getInterface()->getInventoryObject(_hotspotId);
+						articleNum = _madsVm->globals()->getObject(objectId)->_article;
+					} else if (_v86F3A < hotspotCount) {
+						articleNum = (*_madsVm->scene()->getSceneResources().hotspots)[_hotspotId].getArticle();
+					} else {
+
+					}
+				}
+
+			} else if ((_articleNumber == kVerbLook) || (_vm->getGameType() != GType_RexNebular) ||
+				(strcmp(_madsVm->globals()->getVocab(_action.indirectObjectId), fenceStr) != 0)) {
+				// Write out the article
+				strcat(_statusText, englishMADSArticleList[_articleNumber]);
+			} else {
+				// Special case for a 'fence' entry in Rex Nebular
+				strcat(_statusText, overStr);
+			}
+
+			strcat(_statusText, " ");
+		}
+
+		// Append object description if necessary
+		if (_v86F3A >= 0)
+			appendVocab(_action.indirectObjectId);
+
+		// Remove any trailing space character
+		int statusLen = strlen(_statusText);
+		if ((statusLen > 0) && (_statusText[statusLen - 1] == ' '))
+			_statusText[statusLen - 1] = '\0';
+	}
+
+	_textChanged = true;
+	*/
+}
+
+void MadsAction::refresh() {
+	/*
+	// Exit immediately if nothing has changed
+	if (!_textChanged)
+		return;
+
+	// Remove any old copy of the status text
+	if (_statusTextIndex >= 0) {
+		_owner._textDisplay.expire(_statusTextIndex);
+		_statusTextIndex = -1;
+	}
+
+	if (_statusText[0] != '\0') {
+		if ((_owner._screenObjects._v832EC == 0) || (_owner._screenObjects._v832EC == 2)) {
+			Font *font = _madsVm->_font->getFont(FONT_MAIN_MADS);
+			int textSpacing = -1;
+
+			int strWidth = font->getWidth(_statusText);
+			if (strWidth > 320) {
+				// Too large to fit, so fall back on interface font
+				font = _madsVm->_font->getFont(FONT_INTERFACE_MADS);
+				strWidth = font->getWidth(_statusText, 0);
+				textSpacing = 0;
+			}
+
+			// Add a new text display entry to display the status text at the bottom of the screen area
+			uint colors = (_vm->getGameType() == GType_DragonSphere) ? 0x0300 : 0x0003;
+
+			_statusTextIndex = _owner._textDisplay.add(160 - (strWidth / 2),
+				MADS_SURFACE_HEIGHT + _owner._posAdjust.y - 13, colors, textSpacing, _statusText, font);
+		}
+	}
+
+	_textChanged = false;
+	*/
+}
+
+void MadsAction::startAction() {
+	/*
+	_madsVm->_player.moveComplete();
+
+	_inProgress = true;
+	_v8453A = ABORTMODE_0;
+	_savedFields.selectedRow = _selectedRow;
+	_savedFields.articleNumber = _articleNumber;
+	_savedFields.actionMode = _actionMode;
+	_savedFields.actionMode2 = _actionMode2;
+	_savedFields.lookFlag = _lookFlag;
+	int savedHotspotId = _hotspotId;
+	int savedV86F3A = _v86F3A;
+	int savedV86F42 = _v86F42;
+
+	// Copy the action to be active
+	_activeAction = _action;
+	strcpy(_dialogTitle, _statusText);
+
+	if ((_savedFields.actionMode2 == ACTMODE2_4) && (savedV86F42 == 0))
+		_v8453A = ABORTMODE_1;
+
+	_startWalkFlag = false;
+	int hotspotId = -1;
+	HotSpotList &dynHotspots = *_madsVm->scene()->getSceneResources().dynamicHotspots;
+	HotSpotList &hotspots = *_madsVm->scene()->getSceneResources().hotspots;
+
+	if (!_savedFields.lookFlag && (_madsVm->scene()->_screenObjects._v832EC != 1)) {
+		if (_savedFields.actionMode2 == ACTMODE2_4)
+			hotspotId = savedHotspotId;
+		else if (savedV86F42 == 4)
+			hotspotId = savedV86F3A;
+
+		if (hotspotId >= hotspots.size()) {
+			HotSpot &hs = dynHotspots[hotspotId - hotspots.size()];
+			if ((hs.getFeetX() == -1) || (hs.getFeetX() == -3)) {
+				if (_v86F4A && ((hs.getFeetX() == -3) || (_savedFields.selectedRow < 0))) {
+					_startWalkFlag = true;
+					_madsVm->scene()->_destPos = _madsVm->scene()->_customDest;
+				}
+			} else if ((hs.getFeetX() >= 0) && ((_savedFields.actionMode == ACTMODE_NONE) || (hs.getCursor() < 2))) {
+				_startWalkFlag = true;
+				_madsVm->scene()->_destPos.x = hs.getFeetX();
+				_madsVm->scene()->_destPos.y = hs.getFeetY();
+			}
+			_madsVm->scene()->_destFacing = hs.getFacing();
+			hotspotId = -1;
+		}
+	}
+
+	if (hotspotId >= 0) {
+		HotSpot &hs = hotspots[hotspotId];
+		if ((hs.getFeetX() == -1) || (hs.getFeetX() == -3)) {
+			if (_v86F4A && ((hs.getFeetX() == -3) || (_savedFields.selectedRow < 0))) {
+				_startWalkFlag = true;
+				_madsVm->scene()->_destPos = _madsVm->scene()->_customDest;
+			}
+		} else if ((hs.getFeetX() >= 0) && ((_savedFields.actionMode == ACTMODE_NONE) || (hs.getCursor() < 2))) {
+			_startWalkFlag = true;
+			_madsVm->scene()->_destPos.x = hs.getFeetX();
+			_madsVm->scene()->_destPos.y = hs.getFeetY();
+		}
+		_madsVm->scene()->_destFacing = hs.getFacing();
+	}
+
+	_walkFlag = _startWalkFlag;
+	*/
+}
+
+void MadsAction::checkAction() {
+	/*
+	if (isAction(kVerbLookAt) || isAction(kVerbThrow))
+		_startWalkFlag = 0;
+	*/
+}
+
+bool MadsAction::isAction(int verbId, int objectNameId, int indirectObjectId) {
+	/*
+	if (_activeAction.verbId != verbId)
+		return false;
+	if ((objectNameId != 0) && (_activeAction.objectNameId != objectNameId))
+		return false;
+	if ((indirectObjectId != 0) && (_activeAction.indirectObjectId != indirectObjectId))
+		return false;
+	*/
+	return true;
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/action.h b/engines/mads/action.h
new file mode 100644
index 0000000..a29d43b
--- /dev/null
+++ b/engines/mads/action.h
@@ -0,0 +1,113 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_ACTION_H
+#define MADS_ACTION_H
+
+#include "common/scummsys.h"
+
+namespace MADS {
+
+enum ActionMode { ACTMODE_NONE = 0, ACTMODE_VERB = 1, ACTMODE_OBJECT = 3, ACTMODE_TALK = 6 };
+enum ActionMode2 { ACTMODE2_0 = 0, ACTMODE2_2 = 2, ACTMODE2_4 = 4, ACTMODE2_5 = 5 };
+enum AbortTimerMode { ABORTMODE_0 = 0, ABORTMODE_1 = 1, ABORTMODE_2 = 2 };
+
+enum {
+	VERB_NONE = 0,
+	VERB_LOOK = 3,
+	VERB_TAKE = 4,
+	VERB_PUSH = 5,
+	VERB_OPEN = 6,
+	VERB_PUT = 7,
+	VERB_TALKTO = 8,
+	VERB_GIVE = 9,
+	VERB_PULL = 10,
+	VERB_CLOSE = 11,
+	VERB_THROW = 12,
+	VERB_WALKTO = 13
+};
+
+class Scene;
+
+struct ActionDetails {
+	int verbId;
+	int objectNameId;
+	int indirectObjectId;
+};
+
+struct MadsActionSavedFields {
+	int articleNumber;
+	int actionMode;
+	int actionMode2;
+	bool lookFlag;
+	int selectedRow;
+};
+
+class MadsAction {
+private:
+	Scene *_scene;
+	char _statusText[100];
+	char _dialogTitle[100];
+
+	void appendVocab(int vocabId, bool capitalise = false);
+public:
+	ActionDetails _action, _activeAction;
+	int _currentAction;
+	int8 _flags1, _flags2;
+	ActionMode _actionMode;
+	ActionMode2 _actionMode2;
+	int _articleNumber;
+	bool _lookFlag;
+	int _selectedRow;
+	bool _textChanged;
+	int _selectedAction;
+	bool _startWalkFlag;
+	int _statusTextIndex;
+	int _hotspotId;
+	MadsActionSavedFields _savedFields;
+	bool _walkFlag;
+
+	// Unknown fields
+	int16 _v86F3A;
+	int16 _v86F42;
+	int16 _v86F4E;
+	bool _v86F4A;
+	int16 _v86F4C;
+	int _v83338;
+	bool _inProgress;
+	AbortTimerMode _v8453A;
+
+public:
+	MadsAction(Scene *scene);
+
+	void clear();
+	void set();
+	const char *statusText() const { return _statusText; }
+	void refresh();
+	void startAction();
+	void checkAction();
+	bool isAction(int verbId, int objectNameId = 0, int indirectObjectId = 0);
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_ACTION_H */
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 8f177f2..5d905ca 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -157,4 +157,10 @@ void EventsManager::delay(int cycles) {
 	}
 }
 
+void EventsManager::initVars() {
+	_mousePos = Common::Point(-1, -1);
+	_vD4 = _vCC;
+	_vD2 = _vD8 = 0;
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/events.h b/engines/mads/events.h
index 0e990c5..2a8ae84 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -42,6 +42,10 @@ private:
 	uint32 _gameCounter;
 	uint32 _priorFrameTime;
 	Common::Point _mousePos;
+	int _vCC;
+	int _vD4;
+	int _vD8;
+	int _vD2;
 
 	/**
 	 * Updates the cursor image when the current cursor changes
@@ -121,6 +125,8 @@ public:
 	 * Gets the current frame counter
 	 */
 	uint32 getFrameCounter() const { return _gameCounter; }
+
+	void initVars();
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 08d548e..a3351f5a 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -24,10 +24,11 @@
 #include "mads/mads.h"
 #include "mads/game.h"
 #include "mads/game_data.h"
-#include "mads/nebular/game_nebular.h"
+#include "mads/events.h"
 #include "mads/graphics.h"
 #include "mads/msurface.h"
 #include "mads/resources.h"
+#include "mads/nebular/game_nebular.h"
 
 namespace MADS {
 
@@ -170,6 +171,10 @@ void Game::sectionLoop() {
 			_playerSpritesFlag = false;
 		}
 
+		_vm->_events->initVars();
+		_scene._v1A = -1;
+		_scene._v1C = -1;
+		_objectHiliteVocabIdx = -1;
 
 		// TODO: main section loop logic goes here
 
diff --git a/engines/mads/game.h b/engines/mads/game.h
index b8add9a..562e0b9 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -67,6 +67,7 @@ protected:
 	int _v6;
 	Common::String _aaName;
 	bool _playerSpritesFlag;
+	int _objectHiliteVocabIdx;
 
 	/**
 	 * Constructor
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 94c231e..f27b808 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS := \
 	nebular/sound_nebular.o \
 	nebular/nebular_scenes.o \
 	nebular/nebular_scenes8.o \
+	action.o \
 	animation.o \
 	assets.o \
 	compression.o \
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 23c118e..90f5cbd 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -38,6 +38,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm) {
 	_animFlag = false;
 	_animVal1 = 0;
 	_depthStyle = 0;
+	_v1A = _v1C = 0;
 
 	_verbList.push_back(VerbInit(VERB_LOOK, 2, 0));
 	_verbList.push_back(VerbInit(VERB_TAKE, 2, 0));
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 4968291..bafe499 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -95,6 +95,8 @@ public:
 	int _screenY;
 	int _interfaceY;
 	int _spritesCount;
+	int _v1A;
+	int _v1C;
 
 	/**
 	 * Constructor
@@ -154,6 +156,7 @@ public:
 	 */
 	void loadVocab();
 
+
 	/**
 	 * Clear the data for the scene
 	 */
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 557a6aa..6be54cf 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -28,6 +28,7 @@
 #include "common/str.h"
 #include "common/str-array.h"
 #include "common/rect.h"
+#include "mads/action.h"
 #include "mads/assets.h"
 #include "mads/game_data.h"
 
@@ -36,36 +37,12 @@ namespace MADS {
 class MADSEngine;
 class Scene;
 
-enum {
-	VERB_LOOK        = 3,
-	VERB_TAKE        = 4,
-	VERB_PUSH        = 5,
-	VERB_OPEN        = 6,
-	VERB_PUT         = 7,
-	VERB_TALKTO      = 8,
-	VERB_GIVE        = 9,
-	VERB_PULL        = 10,
-	VERB_CLOSE       = 11,
-	VERB_THROW       = 12,
-	VERB_WALKTO      = 13
-};
-
-enum MadsActionMode { ACTMODE_NONE = 0, ACTMODE_VERB = 1, ACTMODE_OBJECT = 3, ACTMODE_TALK = 6 };
-enum MadsActionMode2 { ACTMODE2_0 = 0, ACTMODE2_2 = 2, ACTMODE2_4 = 4, ACTMODE2_5 = 5 };
-enum AbortTimerMode { ABORTMODE_0 = 0, ABORTMODE_1 = 1, ABORTMODE_2 = 2 };
-
 #define MADS_INTERFACE_HEIGHT 44
 #define MADS_SCENE_HEIGHT 156
 
 #define DEPTH_BANDS_SIZE 15
 #define MAX_ROUTE_NODES 22
 
-struct ActionDetails {
-	int verbId;
-	int objectNameId;
-	int indirectObjectId;
-};
-
 class VerbInit {
 public:
 	int _id;


Commit: 72163a233f980a385c432fbf66fd6bb21f6acdf2
    https://github.com/scummvm/scummvm/commit/72163a233f980a385c432fbf66fd6bb21f6acdf2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-02T20:06:21-05:00

Commit Message:
MADS: Moved Player class into it's own file

Changed paths:
  A engines/mads/player.cpp
  A engines/mads/player.h
    engines/mads/action.cpp
    engines/mads/action.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/game_data.cpp
    engines/mads/game_data.h
    engines/mads/module.mk
    engines/mads/scene.cpp
    engines/mads/scene.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index d27bd85..ce2cf6a 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -21,12 +21,13 @@
  */
 
 #include "common/scummsys.h"
+#include "mads/mads.h"
 #include "mads/action.h"
 #include "mads/scene.h"
 
 namespace MADS {
 
-MadsAction::MadsAction(Scene *scene) : _scene(scene) {
+MADSAction::MADSAction(MADSEngine *vm) : _vm(vm) {
 	clear();
 	_currentAction = VERB_NONE;
 	_startWalkFlag = false;
@@ -35,7 +36,7 @@ MadsAction::MadsAction(Scene *scene) : _scene(scene) {
 	_inProgress = false;
 }
 
-void MadsAction::clear() {
+void MADSAction::clear() {
 	_v83338 = 1;
 	_actionMode = ACTMODE_NONE;
 	_actionMode2 = ACTMODE2_0;
@@ -44,7 +45,6 @@ void MadsAction::clear() {
 	_articleNumber = 0;
 	_lookFlag = false;
 	_v86F4A = 0;
-	_statusText[0] = '\0';
 	_selectedRow = -1;
 	_hotspotId = -1;
 	_v86F3A = -1;
@@ -56,7 +56,7 @@ void MadsAction::clear() {
 	_walkFlag = false;
 }
 
-void MadsAction::appendVocab(int vocabId, bool capitalise) {
+void MADSAction::appendVocab(int vocabId, bool capitalise) {
 	/*
 	char *s = _statusText + strlen(_statusText);
 	vocabStr = _madsVm->globals()->getVocab(vocabId);
@@ -68,7 +68,7 @@ void MadsAction::appendVocab(int vocabId, bool capitalise) {
 	*/
 }
 
-void MadsAction::set() {
+void MADSAction::set() {
 	/*
 	int hotspotCount = _madsVm->scene()->getSceneResources().hotspots->size();
 	bool flag = false; // FIXME: unused
@@ -212,7 +212,7 @@ void MadsAction::set() {
 	*/
 }
 
-void MadsAction::refresh() {
+void MADSAction::refresh() {
 	/*
 	// Exit immediately if nothing has changed
 	if (!_textChanged)
@@ -249,7 +249,7 @@ void MadsAction::refresh() {
 	*/
 }
 
-void MadsAction::startAction() {
+void MADSAction::startAction() {
 	/*
 	_madsVm->_player.moveComplete();
 
@@ -318,14 +318,14 @@ void MadsAction::startAction() {
 	*/
 }
 
-void MadsAction::checkAction() {
+void MADSAction::checkAction() {
 	/*
 	if (isAction(kVerbLookAt) || isAction(kVerbThrow))
 		_startWalkFlag = 0;
 	*/
 }
 
-bool MadsAction::isAction(int verbId, int objectNameId, int indirectObjectId) {
+bool MADSAction::isAction(int verbId, int objectNameId, int indirectObjectId) {
 	/*
 	if (_activeAction.verbId != verbId)
 		return false;
diff --git a/engines/mads/action.h b/engines/mads/action.h
index a29d43b..c38b842 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -24,6 +24,7 @@
 #define MADS_ACTION_H
 
 #include "common/scummsys.h"
+#include "common/str.h"
 
 namespace MADS {
 
@@ -46,7 +47,7 @@ enum {
 	VERB_WALKTO = 13
 };
 
-class Scene;
+class MADSEngine;
 
 struct ActionDetails {
 	int verbId;
@@ -54,7 +55,7 @@ struct ActionDetails {
 	int indirectObjectId;
 };
 
-struct MadsActionSavedFields {
+struct MADSActionSavedFields {
 	int articleNumber;
 	int actionMode;
 	int actionMode2;
@@ -62,11 +63,11 @@ struct MadsActionSavedFields {
 	int selectedRow;
 };
 
-class MadsAction {
+class MADSAction {
 private:
-	Scene *_scene;
-	char _statusText[100];
-	char _dialogTitle[100];
+	MADSEngine *_vm;
+	Common::String _statusText;
+	Common::String _dialogTitle;
 
 	void appendVocab(int vocabId, bool capitalise = false);
 public:
@@ -83,7 +84,7 @@ public:
 	bool _startWalkFlag;
 	int _statusTextIndex;
 	int _hotspotId;
-	MadsActionSavedFields _savedFields;
+	MADSActionSavedFields _savedFields;
 	bool _walkFlag;
 
 	// Unknown fields
@@ -97,11 +98,11 @@ public:
 	AbortTimerMode _v8453A;
 
 public:
-	MadsAction(Scene *scene);
+	MADSAction(MADSEngine *vm);
 
 	void clear();
 	void set();
-	const char *statusText() const { return _statusText; }
+	const Common::String &statusText() const { return _statusText; }
 	void refresh();
 	void startAction();
 	void checkAction();
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index a3351f5a..2fa7010 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -39,8 +39,8 @@ Game *Game::init(MADSEngine *vm) {
 	return nullptr;
 }
 
-Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr),
-		_objects(vm), _scene(vm) {
+Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm), 
+		_scene(vm), _player(vm) {
 	_sectionNumber = _priorSectionNumber = 0;
 	_difficultyLevel = DIFFICULTY_HARD;
 	_saveSlot = -1;
@@ -176,6 +176,11 @@ void Game::sectionLoop() {
 		_scene._v1C = -1;
 		_objectHiliteVocabIdx = -1;
 
+		_scene._action.clear();
+		_player.turnToDestFacing();
+		_player._direction = _player._newDirection;
+		_player.moveComplete();
+
 		// TODO: main section loop logic goes here
 
 		// Clear the scene
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 562e0b9..88c5beb 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -26,6 +26,7 @@
 #include "common/scummsys.h"
 #include "mads/scene.h"
 #include "mads/game_data.h"
+#include "mads/player.h"
 
 namespace MADS {
 
@@ -62,7 +63,6 @@ protected:
 	byte *_quotes;
 	int _v1;
 	int _v3;
-	int _v4;
 	int _v5;
 	int _v6;
 	Common::String _aaName;
@@ -110,6 +110,7 @@ public:
 	InventoryObjects _objects;
 	Scene _scene;
 	int _v2;
+	int _v4;
 public:
 	virtual ~Game();
 
diff --git a/engines/mads/game_data.cpp b/engines/mads/game_data.cpp
index e39b85c..ba24ed9 100644
--- a/engines/mads/game_data.cpp
+++ b/engines/mads/game_data.cpp
@@ -102,15 +102,4 @@ void InventoryObjects::setRoom(int objectId, int roomNumber) {
 	warning("TODO: setObjectRoom");
 }
 
-/*------------------------------------------------------------------------*/
-
-Player::Player() {
-	_direction = 8;
-	_newDirection = 8;
-	_spritesLoaded = false;
-	_spritesStart = _numSprites = 0;
-	_stepEnabled = false;
-	_visible = false;
-}
-
 } // End of namespace MADS
diff --git a/engines/mads/game_data.h b/engines/mads/game_data.h
index 2d2badd..56ab366 100644
--- a/engines/mads/game_data.h
+++ b/engines/mads/game_data.h
@@ -91,24 +91,6 @@ public:
 	void setRoom(int objectId, int roomNumber);
 };
 
-class Player {
-public:
-	int _direction;
-	int _newDirection;
-	bool _spritesLoaded;
-	int _spritesStart;
-	int _numSprites;
-	bool _stepEnabled;
-	bool _spritesChanged;
-	bool _visible;
-public:
-	Player();
-
-	void loadSprites(const Common::String &prefix) {
-		warning("TODO: Player::loadSprites");
-	}
-};
-
 class SectionHandler {
 protected:
 	MADSEngine *_vm;
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index f27b808..f715e1a 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -22,6 +22,7 @@ MODULE_OBJS := \
 	msprite.o \
 	msurface.o \
 	palette.o \
+	player.o \
 	resources.o \
 	scene.o \
 	scene_data.o \
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
new file mode 100644
index 0000000..d88feea
--- /dev/null
+++ b/engines/mads/player.cpp
@@ -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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/player.h"
+
+namespace MADS {
+
+Player::Player(MADSEngine *vm): _vm(vm) {
+	_action = nullptr;
+	_direction = 8;
+	_newDirection = 8;
+	_destFacing = 0;
+	_spritesLoaded = false;
+	_spritesStart = _numSprites = 0;
+	_stepEnabled = false;
+	_visible = false;
+}
+
+void Player::reset() {
+	_action = &_vm->_game->_scene._action;
+	_destPos = _playerPos;
+	_destFacing = 5;
+	_newDirection = _direction;
+	_moving = false;
+	_v844C0 = _v844BE = 0;
+	_next = 0;
+	_routeCount = 0;
+
+	_vm->_game->_v4 = 0;
+	_action->_startWalkFlag = false;
+	_action->_walkFlag = false;
+}
+
+void Player::loadSprites(const Common::String &prefix) {
+	warning("TODO: Player::loadSprites");
+}
+
+void Player::turnToDestFacing() {
+	if (_destFacing != 5)
+		_newDirection = _destFacing;
+}
+
+void Player::moveComplete() {
+	reset();
+	_action->_inProgress = false;
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/player.h b/engines/mads/player.h
new file mode 100644
index 0000000..0466f7a
--- /dev/null
+++ b/engines/mads/player.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_PLAYER_H
+#define MADS_PLAYER_H
+
+#include "common/scummsys.h"
+#include "common/str.h"
+
+namespace MADS {
+
+class MADSEngine;
+class Action;
+
+class Player {
+private:
+	MADSEngine *_vm;
+	MADSAction *_action;
+
+	void reset();
+public:
+	int _direction;
+	int _newDirection;
+	int _destFacing;
+	bool _spritesLoaded;
+	int _spritesStart;
+	int _numSprites;
+	bool _stepEnabled;
+	bool _spritesChanged;
+	bool _visible;
+	Common::Point _playerPos;
+	Common::Point _destPos;
+	bool _moving;
+	int _v844C0, _v844BE;
+	int _next;
+	int _routeCount;
+
+public:
+	Player(MADSEngine *vm);
+
+	void loadSprites(const Common::String &prefix);
+
+	void turnToDestFacing();
+
+	void moveComplete();
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_PLAYER_H */
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 90f5cbd..2f12139 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -28,7 +28,7 @@
 
 namespace MADS {
 
-Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm) {
+Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm) {
 	_priorSceneId = 0;
 	_nextSceneId = 0;
 	_currentSceneId = 0;
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index bafe499..d3a6aee 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -97,6 +97,7 @@ public:
 	int _spritesCount;
 	int _v1A;
 	int _v1C;
+	MADSAction _action;
 
 	/**
 	 * Constructor


Commit: a0996b7384e5c3321af97347613120d2f90ab64e
    https://github.com/scummvm/scummvm/commit/a0996b7384e5c3321af97347613120d2f90ab64e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-02T20:50:35-05:00

Commit Message:
MADS: Implemented more of the multi-scene loop

Changed paths:
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/player.cpp
    engines/mads/player.h
    engines/mads/scene.cpp
    engines/mads/scene.h



diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 5d905ca..56bd87c 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -39,6 +39,7 @@ EventsManager::EventsManager(MADSEngine *vm) {
 	_priorFrameTime = 0;
 	_keyPressed = false;
 	_mouseClicked = false;
+	_currentTimer = 0;
 }
 
 EventsManager::~EventsManager() {
diff --git a/engines/mads/events.h b/engines/mads/events.h
index 2a8ae84..c4fb878 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -60,6 +60,7 @@ public:
 	SpriteAsset *_cursorSprites;
 	bool _mouseClicked;
 	bool _keyPressed;
+	uint32 _currentTimer;
 public:
 	/**
 	 * Constructor
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 2fa7010..64b41d2 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -54,6 +54,8 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 	_v5 = _v6 = 0;
 	_aaName = "*I0.AA";
 	_playerSpritesFlag = false;
+	_currentTimer = 0;
+	_updateSceneFlag = false;
 }
 
 Game::~Game() {
@@ -181,7 +183,65 @@ void Game::sectionLoop() {
 		_player._direction = _player._newDirection;
 		_player.moveComplete();
 
-		// TODO: main section loop logic goes here
+		switch (_vm->_screenFade) {
+		case SCREEN_FADE_SMOOTH:
+			_abortTimers2 = 2;
+			break;
+		case SCREEN_FADE_FAST:
+			_abortTimers2 = 20;
+			break;
+		default:
+			_abortTimers2 = 21;
+			break;
+		}
+		_abortTimers = 0;
+		_abortTimersMode2 = ABORTMODE_1;
+		_currentTimer = _vm->_events->_currentTimer;
+
+		// Call the scene logic for entering the given scene
+		_scene._sceneLogic->enter();
+
+		// Set player data
+		_player._destPos = _player._playerPos;
+		_player._newDirection = _player._direction;
+		_player._destFacing = _player._direction;
+		_player.setupFrame();
+		_player.updateFrame();
+		_player._visible3 = _player._visible;
+		_player._special = _scene.getDepthHighBits(_player._playerPos);
+		_player._priorTimer = _vm->_events->_currentTimer + _player._ticksAmount;
+		_player.idle();
+
+		warning("TODO: _selectedObject IF block");
+
+		_v1 = 5;
+		_scene._roomChanged = false;
+
+		if ((_v5 || _v6) && !_updateSceneFlag) {
+			_scene._currentSceneId = _scene._priorSceneId;
+			_updateSceneFlag = true;
+		}
+		else {
+			_updateSceneFlag = false;
+			_scene.loop();
+		}
+
+		_vm->_events->resetCursor();
+		_v1 = 3;
+
+		delete _quotes;
+		_quotes = nullptr;
+		delete _scene._animation;
+		_scene._animation = nullptr;
+
+		_scene._reloadSceneFlag = false;
+
+		warning("TODO: sub_1DD8C, sub_1DD7E");
+
+		if (!_playerSpritesFlag) {
+			_player._spritesLoaded = false;
+			_player._spritesChanged = true;
+		}
 
 		// Clear the scene
 		_scene.free();
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 88c5beb..cd727af 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -65,6 +65,7 @@ protected:
 	int _v3;
 	int _v5;
 	int _v6;
+	bool _updateSceneFlag;
 	Common::String _aaName;
 	bool _playerSpritesFlag;
 	int _objectHiliteVocabIdx;
@@ -111,6 +112,10 @@ public:
 	Scene _scene;
 	int _v2;
 	int _v4;
+	int _abortTimers;
+	int _abortTimers2;
+	AbortTimerMode _abortTimersMode2;
+	uint32 _currentTimer;
 public:
 	virtual ~Game();
 
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index d78f37d..e9fbf91 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -41,6 +41,7 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :
 	_easyMouse = true;
 	_invObjectStill = false;
 	_textWindowStill = false;
+	_screenFade = SCREEN_FADE_FAST;
 
 	_debugger = nullptr;
 	_dialogs = nullptr;
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index 92758b7..2d85236 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -67,6 +67,12 @@ enum {
 	GType_Riddle = 3
 };
 
+enum ScreenFade {
+	SCREEN_FADE_SMOOTH = 0,
+	SCREEN_FADE_MEDIUM = 1,
+	SCREEN_FADE_FAST = 2
+};
+
 struct MADSGameDescription;
 
 
@@ -97,7 +103,7 @@ public:
 	bool _easyMouse;
 	bool _invObjectStill;
 	bool _textWindowStill;
-
+	ScreenFade _screenFade;
 public:
 	MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc);
 	virtual ~MADSEngine();
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index d88feea..e09549c 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -35,6 +35,10 @@ Player::Player(MADSEngine *vm): _vm(vm) {
 	_spritesStart = _numSprites = 0;
 	_stepEnabled = false;
 	_visible = false;
+	_visible3 = false;
+	_special = 0;
+	_ticksAmount = 0;
+	_priorTimer = 0;
 }
 
 void Player::reset() {
@@ -66,4 +70,21 @@ void Player::moveComplete() {
 	_action->_inProgress = false;
 }
 
+void Player::setupFrame() {
+	resetActionList();
+	warning("TODO: Player::setupFrame");
+}
+
+void Player::updateFrame() {
+	warning("TODO: Player::updateFrame");
+}
+
+void Player::resetActionList() {
+	warning("TODO: Player::resetActionList");
+}
+
+void Player::idle() {
+	warning("TODO: Player::idle");
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 0466f7a..67766d8 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -37,6 +37,8 @@ private:
 	MADSAction *_action;
 
 	void reset();
+
+	void resetActionList();
 public:
 	int _direction;
 	int _newDirection;
@@ -47,13 +49,16 @@ public:
 	bool _stepEnabled;
 	bool _spritesChanged;
 	bool _visible;
+	bool _visible3;
 	Common::Point _playerPos;
 	Common::Point _destPos;
 	bool _moving;
 	int _v844C0, _v844BE;
 	int _next;
 	int _routeCount;
-
+	int _special;
+	int _ticksAmount;
+	uint32 _priorTimer;
 public:
 	Player(MADSEngine *vm);
 
@@ -62,6 +67,12 @@ public:
 	void turnToDestFacing();
 
 	void moveComplete();
+
+	void setupFrame();
+
+	void updateFrame();
+
+	void idle();
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 2f12139..2c6cb8a 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -39,6 +39,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm) {
 	_animVal1 = 0;
 	_depthStyle = 0;
 	_v1A = _v1C = 0;
+	_roomChanged = false;
+	_reloadSceneFlag = false;
 
 	_verbList.push_back(VerbInit(VERB_LOOK, 2, 0));
 	_verbList.push_back(VerbInit(VERB_TAKE, 2, 0));
@@ -254,6 +256,19 @@ void Scene::initPaletteAnimation(Common::Array<RGB4> &animData, bool animFlag) {
 	_animFlag = animFlag;
 }
 
+bool Scene::getDepthHighBits(const Common::Point &pt) {
+	if (_sceneInfo->_depthStyle == 2) {
+		return 0;
+	} else {
+		const byte *p = _depthSurface.getBasePtr(pt.x, pt.y);
+		return (*p & 0x70) >> 4;
+	}
+}
+
+void Scene::loop() {
+
+}
+
 void Scene::free() {
 	warning("TODO: Scene::free");
 }
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index d3a6aee..4da6fb2 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -98,6 +98,8 @@ public:
 	int _v1A;
 	int _v1C;
 	MADSAction _action;
+	bool _roomChanged;
+	bool _reloadSceneFlag;
 
 	/**
 	 * Constructor
@@ -157,6 +159,12 @@ public:
 	 */
 	void loadVocab();
 
+	bool getDepthHighBits(const Common::Point &pt);
+
+	/**
+	 * Main scene loop
+	 */
+	void loop();
 
 	/**
 	 * Clear the data for the scene


Commit: 3a842a079c668e9dfc52a6056119d4932e8ef56d
    https://github.com/scummvm/scummvm/commit/3a842a079c668e9dfc52a6056119d4932e8ef56d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-02T23:09:17-05:00

Commit Message:
MADS: Bulk of implementation of ScreenObjects::check

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h
    engines/mads/animation.cpp
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/player.cpp
    engines/mads/player.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index ce2cf6a..9a80807 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -337,4 +337,8 @@ bool MADSAction::isAction(int verbId, int objectNameId, int indirectObjectId) {
 	return true;
 }
 
+void MADSAction::checkActionAtMousePos() {
+	warning("TODO: checkActionAtMousePos");
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/action.h b/engines/mads/action.h
index c38b842..780168a 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -107,6 +107,8 @@ public:
 	void startAction();
 	void checkAction();
 	bool isAction(int verbId, int objectNameId = 0, int indirectObjectId = 0);
+	
+	void checkActionAtMousePos();
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index ebb2289..8ea95ee 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -287,7 +287,7 @@ void Animation::loadInterface(InterfaceSurface &interfaceSurface, MSurface &dept
 	else if (header._animMode == 4) {
 		// Load a scene interface
 		Common::String resourceName = "*" + header._interfaceFile;
-		interfaceSurface.load(_vm, resourceName);
+		interfaceSurface.load(resourceName);
 
 		if (palAnimData)
 			palAnimData->clear();
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 56bd87c..0c2e2f2 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -39,7 +39,13 @@ EventsManager::EventsManager(MADSEngine *vm) {
 	_priorFrameTime = 0;
 	_keyPressed = false;
 	_mouseClicked = false;
+	_mouseReleased = false;
 	_currentTimer = 0;
+	_mouseButtons = 0;
+	_vD2 = 0;
+	_vD4 = 0;
+	_vD6 = 0;
+	_vD8 = 0;
 }
 
 EventsManager::~EventsManager() {
@@ -115,6 +121,7 @@ void EventsManager::pollEvents() {
 		case Common::EVENT_LBUTTONDOWN:
 		case Common::EVENT_RBUTTONDOWN:
 			_mouseClicked = true;
+			_mouseButtons = 1;
 			return;
 		case Common::EVENT_LBUTTONUP:
 		case Common::EVENT_RBUTTONUP:
diff --git a/engines/mads/events.h b/engines/mads/events.h
index c4fb878..0a6913b 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -42,10 +42,7 @@ private:
 	uint32 _gameCounter;
 	uint32 _priorFrameTime;
 	Common::Point _mousePos;
-	int _vCC;
-	int _vD4;
-	int _vD8;
-	int _vD2;
+	Common::Point _currentPos;
 
 	/**
 	 * Updates the cursor image when the current cursor changes
@@ -59,8 +56,15 @@ private:
 public:
 	SpriteAsset *_cursorSprites;
 	bool _mouseClicked;
+	bool _mouseReleased;
+	byte _mouseButtons;
 	bool _keyPressed;
 	uint32 _currentTimer;
+	int _vCC;
+	int _vD2;
+	int _vD4;
+	int _vD6;
+	int _vD8;
 public:
 	/**
 	 * Constructor
@@ -118,6 +122,11 @@ public:
 	Common::Point mousePos() const { return _mousePos; }
 
 	/**
+	* Return the current mouse position
+	*/
+	Common::Point currentPos() const { return _currentPos; }
+
+	/**
 	 * Delay for a given number of frames
 	 */
 	void delay(int amount);
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 64b41d2..c90cf62 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -140,6 +140,7 @@ void Game::sectionLoop() {
 
 		_quotes = nullptr;
 		_scene.clearVocab();
+		_scene._dynamicHotspots.clear();
 		_scene.loadSceneLogic();
 
 		_v4 = 0;
@@ -148,7 +149,7 @@ void Game::sectionLoop() {
 		_vm->_dialogs->_defaultPosition = Common::Point(-1, -1);
 		_visitedScenes.add(_scene._nextSceneId);
 
-		_scene._screenObjects._v8333C = -1;
+		_scene._screenObjects._v8333C = true;
 		_scene._screenObjects._v832EC = 0;
 		_scene._screenObjects._yp = 0;
 		_v3 = -1;
diff --git a/engines/mads/game.h b/engines/mads/game.h
index cd727af..2bfa53d 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -55,7 +55,6 @@ protected:
 	MADSEngine *_vm;
 	MSurface *_surface;
 	Difficulty _difficultyLevel;
-	Player _player;
 	int _saveSlot;
 	int _statusFlag;
 	SectionHandler *_sectionHandler;
@@ -104,6 +103,7 @@ protected:
 public:
 	static Game *init(MADSEngine *vm);
 public:
+	Player _player;
 	int _sectionNumber;
 	int _priorSectionNumber;
 	int _currentSectionNumber;
@@ -123,8 +123,6 @@ public:
 	 * Run the game
 	 */
 	void run();
-
-	Player &player() { return _player; }
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index e09549c..4130ad2 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -39,6 +39,7 @@ Player::Player(MADSEngine *vm): _vm(vm) {
 	_special = 0;
 	_ticksAmount = 0;
 	_priorTimer = 0;
+	_unk3 = 0;
 }
 
 void Player::reset() {
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 67766d8..f82492f 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -59,6 +59,7 @@ public:
 	int _special;
 	int _ticksAmount;
 	uint32 _priorTimer;
+	int _unk3;
 public:
 	Player(MADSEngine *vm);
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 2c6cb8a..86b59cc 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -28,7 +28,8 @@
 
 namespace MADS {
 
-Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm) {
+Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm),
+		_dynamicHotspots(vm), _screenObjects(vm), _interface(vm) {
 	_priorSceneId = 0;
 	_nextSceneId = 0;
 	_currentSceneId = 0;
@@ -60,11 +61,6 @@ Scene::~Scene() {
 	delete _sceneInfo;
 }
 
-void Scene::clearDynamicHotspots() {
-	_dynamicHotspots.clear();
-	_dynamicHotspotsChanged = false;
-}
-
 void Scene::clearVocab() {
 	freeVocab();
 	_activeVocabs.clear();
@@ -155,7 +151,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 
 	_animation = Animation::init(_vm, this);
 	MSurface surface;
-	_animation->load(surface, _interfaceSurface, prefix, flags, nullptr, nullptr);
+	_animation->load(surface, _interface, prefix, flags, nullptr, nullptr);
 	
 	_vm->_palette->_paletteUsage.load(0);
 
@@ -266,7 +262,34 @@ bool Scene::getDepthHighBits(const Common::Point &pt) {
 }
 
 void Scene::loop() {
+	_nextSceneId = _currentSceneId;
+
+	while (!_vm->shouldQuit() && !_reloadSceneFlag && _nextSceneId == _currentSceneId) {
+		// Handle drawing a game frame
+		doFrame();
+
+		if (_vm->_dialogs->_pendingDialog != DIALOG_NONE && !_vm->_game->_abortTimers
+			&& _vm->_game->_player._stepEnabled)
+			_reloadSceneFlag = true;
+	}
+}
+
+void Scene::doFrame() {
+	Player &player = _vm->_game->_player;
+
+	if (_action._selectedAction || !player._stepEnabled) {
+		_action.clear();
+		_action._selectedAction = 0;
+	}
+
+	if (!_vm->_game->_abortTimers && !player._unk3) {
+		if (_dynamicHotspots._changed)
+			_dynamicHotspots.refresh();
+	}
+}
 
+void Scene::leftClick() {
+	warning("TODO: Scene::leftClick");
 }
 
 void Scene::free() {
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 4da6fb2..a02c4a5 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -54,6 +54,11 @@ private:
 	 * Initialises the data for palette animation within the scene
 	 */
 	void initPaletteAnimation(Common::Array<RGB4> &animData, bool animFlag);
+
+	/**
+	 * Handles a single frame within the game scene
+	 */
+	void doFrame();
 protected:
 	MADSEngine *_vm;
 public:
@@ -66,8 +71,7 @@ public:
 	SpriteSlots _spriteSlots;
 	SpriteSets _sprites;
 	int _spritesIndex;
-	Common::Array<DynamicHotspot> _dynamicHotspots;
-	bool _dynamicHotspotsChanged;
+	DynamicHotspots _dynamicHotspots;
 	byte *_vocabBuffer;
 	Common::Array<int> _activeVocabs;
 	Common::Array<SequenceEntry> _sequences;
@@ -80,7 +84,7 @@ public:
 	SceneInfo *_sceneInfo;
 	MSurface _backgroundSurface;
 	MSurface _depthSurface;
-	InterfaceSurface _interfaceSurface;
+	InterfaceSurface _interface;
 	bool _animFlag;
 	int _animVal1;
 	int _animCount;
@@ -112,11 +116,6 @@ public:
 	~Scene();
 
 	/**
-	 * Clear the dynamic hotspot list
-	 */
-	void clearDynamicHotspots();
-
-	/**
 	 * Clear the vocabulary list
 	 */
 	void clearVocab();
@@ -167,6 +166,11 @@ public:
 	void loop();
 
 	/**
+	 * Execute a click within the scene
+	 */
+	void leftClick();
+
+	/**
 	 * Clear the data for the scene
 	 */
 	void free();
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index d7aaa62..601d719 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -30,6 +30,114 @@
 
 namespace MADS {
 
+ScreenObject::ScreenObject() {
+	_category = CAT_NONE;
+	_descId = 0;
+	_layer = 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+ScreenObjects::ScreenObjects(MADSEngine *vm): _vm(vm) {
+	_v8333C = false;
+	_v832EC = 0;
+	_yp = 0;
+	_v7FECA = 0;
+	_v7FED6 = 0;
+	_v8332A = 0;
+	_selectedObject = 0;
+	_category = CAT_NONE;
+	_objectIndex = 0;
+	_released = false;
+}
+
+void ScreenObjects::add(const Common::Rect &bounds, ScrCategory category, int descId) {
+	assert(size() < 100);
+
+	ScreenObject so;
+	so._bounds = bounds;
+	so._category = category;
+	so._descId = descId;
+	so._layer = 0x1413;
+
+	push_back(so);
+}
+
+void ScreenObjects::check(bool scanFlag) {
+	Scene &scene = _vm->_game->_scene;
+
+	if (!_vm->_events->_mouseButtons || _v832EC)
+		_v7FECA = false;
+
+	if ((_vm->_events->_vD6 || _v8332A || _yp || _v8333C) && scanFlag) {
+		_selectedObject = scanBackwards(_vm->_events->currentPos(), LAYER_GUI);
+		if (_selectedObject > 0) {
+			_category = (ScrCategory)((*this)[_selectedObject - 1]._category & 7);
+			_objectIndex = (*this)[_selectedObject - 1]._descId;
+		}
+
+		// Handling for easy mouse
+		ScrCategory category = scene._interface._category;
+		if (_vm->_easyMouse && !_vm->_events->_vD4 && category != _category
+				&& scene._interface._category != CAT_NONE) {
+			_released = true;
+			if (category >= CAT_ACTION && category <= CAT_6) {
+				scene._interface.elementHighlighted();
+			} 
+		}
+
+		_released = _vm->_events->_mouseReleased;
+		if (_vm->_events->_vD2 || (_vm->_easyMouse && !_vm->_events->_vD4))
+			scene._interface._category = _category;
+
+		if (!_vm->_events->_mouseButtons || _vm->_easyMouse) {
+			if (category >= CAT_ACTION && category <= CAT_6) {
+				scene._interface.elementHighlighted();
+			}
+		}
+
+		if (_vm->_events->_mouseButtons || (_vm->_easyMouse && scene._action._v83338 > 1
+				&& scene._interface._category == CAT_INV_LIST) ||
+				(_vm->_easyMouse && scene._interface._category == CAT_HOTSPOT)) {
+			scene._action.checkActionAtMousePos();
+		}
+			
+		if (_vm->_events->_mouseReleased) {
+			scene.leftClick();
+			scene._interface._category = CAT_NONE;
+		}
+
+		if (_vm->_events->_mouseButtons || _vm->_easyMouse || _yp)
+			proc1();
+
+		if (_vm->_events->_mouseButtons || _vm->_easyMouse)
+			scene._action.set();
+
+		_v8333C = 0;
+	}
+
+	scene._action.refresh();
+
+	// Loop through image inter list
+	warning("TODO: iimageInterList loop");
+}
+
+int ScreenObjects::scanBackwards(const Common::Point &pt, int layer) {
+	for (int i = (int)size() - 1; i >= 0; --i) {
+		if ((*this)[i]._bounds.contains(pt) && ((*this)[i]._layer == layer))
+			return i + 1;
+	}
+
+	// Entry not found
+	return 0;
+}
+
+void ScreenObjects::proc1() {
+	warning("TODO: ScreenObjects::proc1");
+}
+
+/*------------------------------------------------------------------------*/
+
 SpriteSlot::SpriteSlot() {
 	_spriteType = ST_NONE;
 	_seqIndex = 0;
@@ -64,7 +172,7 @@ void SpriteSlots::clear(bool flag) {
  * Releases any sprites used by the player
  */
 void SpriteSlots::releasePlayerSprites() {
-	Player &player = _vm->_game->player();
+	Player &player = _vm->_game->_player;
 
 	if (player._spritesLoaded && player._numSprites > 0) {
 		int spriteEnd = player._spritesStart + player._numSprites - 1;
@@ -114,6 +222,34 @@ DynamicHotspot::DynamicHotspot() {
 
 /*------------------------------------------------------------------------*/
 
+DynamicHotspots::DynamicHotspots(MADSEngine *vm): _vm(vm) {
+	_changed = false;
+}
+
+void DynamicHotspots::clear() {
+	Common::Array<DynamicHotspot>::clear();
+	_changed = false;
+}
+
+void DynamicHotspots::refresh() {
+	Scene &scene = _vm->_game->_scene;
+
+	for (uint idx = 0; idx < size(); ++idx) {
+		DynamicHotspot &dh = (*this)[idx];
+
+		switch (scene._screenObjects._v832EC) {
+		case 0:
+		case 2:
+			scene._screenObjects.add(dh._bounds, CAT_12, dh._descId);
+			scene._screenObjects._v8333C = true;
+		default:
+			break;
+		}
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
 SequenceEntry::SequenceEntry() {
 	_spritesIndex = 0;
 	_flipped =0;
@@ -216,6 +352,16 @@ void SceneNode::load(Common::SeekableReadStream *f) {
 
 /*------------------------------------------------------------------------*/
 
+InterfaceSurface::InterfaceSurface(MADSEngine *vm): _vm(vm) {
+	_category = CAT_NONE;
+}
+
+void InterfaceSurface::elementHighlighted() {
+	warning("TODO: InterfaceSurface::elementHighlighted");
+}
+
+/*------------------------------------------------------------------------*/
+
 void SceneInfo::SpriteInfo::load(Common::SeekableReadStream *f) {
 	f->skip(3);
 	_spriteSetIndex = f->readByte();
@@ -228,15 +374,15 @@ void SceneInfo::SpriteInfo::load(Common::SeekableReadStream *f) {
 
 /*------------------------------------------------------------------------*/
 
-void InterfaceSurface::load(MADSEngine *vm, const Common::String &resName) {
+void InterfaceSurface::load(const Common::String &resName) {
 	File f(resName);
 	MadsPack madsPack(&f);
 
 	// Load in the palette
 	Common::SeekableReadStream *palStream = madsPack.getItemStream(0);
 
-	RGB4 *gamePalP = &vm->_palette->_gamePalette[0];
-	byte *palP = &vm->_palette->_mainPalette[0];
+	RGB4 *gamePalP = &_vm->_palette->_gamePalette[0];
+	byte *palP = &_vm->_palette->_mainPalette[0];
 
 	for (int i = 0; i < 16; ++i, gamePalP++, palP += 3) {
 		palP[0] = palStream->readByte();
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 6be54cf..8b874a1 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -43,6 +43,21 @@ class Scene;
 #define DEPTH_BANDS_SIZE 15
 #define MAX_ROUTE_NODES 22
 
+enum ScrCategory {
+	CAT_NONE = 0, CAT_ACTION = 1, CAT_INV_LIST = 2, CAT_INV_VOCAB = 3,
+	CAT_HOTSPOT = 4, CAT_INV_ANIM = 5, CAT_6 = 6, CAT_INV_SCROLLER = 7,
+	CAT_12 = 12
+};
+
+enum Layer {
+	LAYER_GUI = 19
+};
+
+enum SpriteType {
+	ST_NONE = 0, ST_FOREGROUND = 1, ST_BACKGROUND = -4,
+	ST_FULL_SCREEN_REFRESH = -2, ST_EXPIRED = -1
+};
+
 class VerbInit {
 public:
 	int _id;
@@ -53,16 +68,48 @@ public:
 	VerbInit(int id, int action1, int action2): _id(id), _action1(action1), _action2(action2) {}
 };
 
-class ScreenObjects {
+class ScreenObject {
+public:
+	Common::Rect _bounds;
+	ScrCategory _category;
+	int _descId;
+	int _layer;
+
+	ScreenObject();
+};
+
+class ScreenObjects: public Common::Array<ScreenObject> {
+private:
+	MADSEngine *_vm;
+
+	int scanBackwards(const Common::Point &pt, int layer);
+
+	void proc1();
 public:
-	int _v8333C;
 	int _v832EC;
+	int _v7FECA;
+	int _v7FED6;
+	int _v8332A;
 	int _yp;
-};
+	int _v8333C;
+	int _selectedObject;
+	ScrCategory _category;
+	int _objectIndex;
+	bool _released;
 
-enum SpriteType {
-	ST_NONE = 0, ST_FOREGROUND = 1, ST_BACKGROUND = -4, 
-	ST_FULL_SCREEN_REFRESH = -2, ST_EXPIRED = -1
+	/*
+	 * Constructor
+	 */
+	ScreenObjects(MADSEngine *vm);
+
+	/**
+	 * Add a new item to the list
+	 */
+	void add(const Common::Rect &bounds, ScrCategory category, int descId);
+
+	/**
+	 */
+	void check(bool scanFlag);
 };
 
 class SpriteSlotSubset {
@@ -143,6 +190,28 @@ public:
 	DynamicHotspot();
 };
 
+class DynamicHotspots : public Common::Array<DynamicHotspot> {
+private:
+	MADSEngine *_vm;
+public:
+	bool _changed;
+
+	/**
+	 * Constructor
+	 */
+	DynamicHotspots(MADSEngine *vm);
+
+	/**
+	 * Clear the list
+	 */
+	void clear();
+
+	/**
+	 * Refresh the list
+	 */
+	void refresh();
+};
+
 class SequenceEntry {
 public:
 	int _spritesIndex;
@@ -283,8 +352,22 @@ public:
 typedef Common::Array<SceneNode> SceneNodeList;
 
 class InterfaceSurface : public MSurface {
+private:
+	MADSEngine *_vm;
+public:
+	ScrCategory _category;
 public:
-	void load(MADSEngine *vm, const Common::String &resName);
+	/**
+	 * Constructor
+	 */
+	InterfaceSurface(MADSEngine *vm);
+
+	/**
+	 * Loads an interface from a specified resource
+	 */
+	void load(const Common::String &resName);
+
+	void elementHighlighted();
 };
 
 /**


Commit: d8026b9ef72d7ca22721486244309ccd4a003cae
    https://github.com/scummvm/scummvm/commit/d8026b9ef72d7ca22721486244309ccd4a003cae
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-03T00:42:41-05:00

Commit Message:
MADS: Implementing Scene::doFrame

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h
    engines/mads/events.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/player.cpp
    engines/mads/player.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 9a80807..134321f 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -34,6 +34,7 @@ MADSAction::MADSAction(MADSEngine *vm) : _vm(vm) {
 	_statusTextIndex = -1;
 	_selectedAction = 0;
 	_inProgress = false;
+	_savedSelectedRow = false;
 }
 
 void MADSAction::clear() {
@@ -49,9 +50,9 @@ void MADSAction::clear() {
 	_hotspotId = -1;
 	_v86F3A = -1;
 	_v86F4C = -1;
-	_action.verbId = -1;
-	_action.objectNameId = -1;
-	_action.indirectObjectId = -1;
+	_action._verbId = -1;
+	_action._objectNameId = -1;
+	_action._indirectObjectId = -1;
 	_textChanged = true;
 	_walkFlag = false;
 }
diff --git a/engines/mads/action.h b/engines/mads/action.h
index 780168a..da738ac 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -50,9 +50,9 @@ enum {
 class MADSEngine;
 
 struct ActionDetails {
-	int verbId;
-	int objectNameId;
-	int indirectObjectId;
+	int _verbId;
+	int _objectNameId;
+	int _indirectObjectId;
 };
 
 struct MADSActionSavedFields {
@@ -86,6 +86,7 @@ public:
 	int _hotspotId;
 	MADSActionSavedFields _savedFields;
 	bool _walkFlag;
+	bool _savedSelectedRow;
 
 	// Unknown fields
 	int16 _v86F3A;
diff --git a/engines/mads/events.h b/engines/mads/events.h
index 0a6913b..2782253 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -37,8 +37,6 @@ class MADSEngine;
 class EventsManager {
 private:
 	MADSEngine *_vm;
-	CursorType _cursorId;
-	CursorType _newCursorId;
 	uint32 _gameCounter;
 	uint32 _priorFrameTime;
 	Common::Point _mousePos;
@@ -55,6 +53,8 @@ private:
 	void checkForNextFrameCounter();
 public:
 	SpriteAsset *_cursorSprites;
+	CursorType _cursorId;
+	CursorType _newCursorId;
 	bool _mouseClicked;
 	bool _mouseReleased;
 	byte _mouseButtons;
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index c90cf62..3702768 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -56,6 +56,8 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 	_playerSpritesFlag = false;
 	_currentTimer = 0;
 	_updateSceneFlag = false;
+	_abortTimersMode = ABORTMODE_0;
+	_abortTimersMode2 = ABORTMODE_0;
 }
 
 Game::~Game() {
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 2bfa53d..148fc12 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -114,6 +114,7 @@ public:
 	int _v4;
 	int _abortTimers;
 	int _abortTimers2;
+	AbortTimerMode _abortTimersMode;
 	AbortTimerMode _abortTimersMode2;
 	uint32 _currentTimer;
 public:
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 4130ad2..b0f4b72 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -84,8 +84,39 @@ void Player::resetActionList() {
 	warning("TODO: Player::resetActionList");
 }
 
+void Player::setDest(const Common::Point &pt, int facing) {
+	warning("TODO: Player::setDest");
+}
+
+void Player::nextFrame() {
+	_priorTimer += _ticksAmount;
+	if (_vm->_events->_currentTimer >= _priorTimer) {
+		_priorTimer = _vm->_events->_currentTimer;
+		if (_moving) {
+			move();
+		} else {
+			idle();
+		}
+
+		postUpdate();
+		update();
+	}
+}
+
+void Player::move() {
+	warning("TODO: Player::move");
+}
+
 void Player::idle() {
 	warning("TODO: Player::idle");
 }
 
+void Player::postUpdate() {
+	warning("TODO: Player::postUpdate");
+}
+
+void Player::update() {
+	warning("TODO: Player::update");
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/player.h b/engines/mads/player.h
index f82492f..7792fb6 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -39,6 +39,12 @@ private:
 	void reset();
 
 	void resetActionList();
+
+	void move();
+
+	void postUpdate();
+ 
+	void update();
 public:
 	int _direction;
 	int _newDirection;
@@ -74,6 +80,10 @@ public:
 	void updateFrame();
 
 	void idle();
+
+	void setDest(const Common::Point &pt, int facing);
+
+	void nextFrame();
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 86b59cc..47b9bfa 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -42,6 +42,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm),
 	_v1A = _v1C = 0;
 	_roomChanged = false;
 	_reloadSceneFlag = false;
+	_destFacing = 0;
+	_freeAnimationFlag = false;
 
 	_verbList.push_back(VerbInit(VERB_LOOK, 2, 0));
 	_verbList.push_back(VerbInit(VERB_TAKE, 2, 0));
@@ -276,6 +278,7 @@ void Scene::loop() {
 
 void Scene::doFrame() {
 	Player &player = _vm->_game->_player;
+	bool flag = false;
 
 	if (_action._selectedAction || !player._stepEnabled) {
 		_action.clear();
@@ -285,6 +288,75 @@ void Scene::doFrame() {
 	if (!_vm->_game->_abortTimers && !player._unk3) {
 		if (_dynamicHotspots._changed)
 			_dynamicHotspots.refresh();
+
+		_screenObjects.check(player._stepEnabled && !_action._startWalkFlag &&
+				!_vm->_game->_abortTimers2);
+	}
+
+	if (_action._selectedAction && player._stepEnabled && !_action._startWalkFlag &&
+			!_vm->_game->_abortTimers && !player._unk3) {
+		_action.startAction();
+		if (_action._activeAction._verbId == Nebular::NOUN_LOOK_AT) {
+			_action._activeAction._verbId = VERB_LOOK;
+			_action._savedSelectedRow = false;
+		}
+
+		flag = true;
+	}
+
+	if (flag || (_vm->_game->_abortTimers && _vm->_game->_abortTimersMode == ABORTMODE_2)) {
+		doPreactions();
+	}
+
+	checkStartWalk();
+	if (!_vm->_game->_abortTimers2)
+		_vm->_events->_currentTimer = _vm->_events->getFrameCounter();
+
+	if ((_action._inProgress && !player._moving && !_action._startWalkFlag &&
+			player._newDirection == player._direction) ||
+			(_vm->_game->_abortTimers && _vm->_game->_abortTimersMode == ABORTMODE_0)) {
+		doAction();
+	}
+
+	if (_currentSceneId != _nextSceneId) {
+		_freeAnimationFlag = true;
+	} else {
+		doSceneStep();
+		checkKeyboard();
+
+		if (_currentSceneId != _nextSceneId) {
+			_freeAnimationFlag = true;
+		} else {
+			player.nextFrame();
+
+			// Cursor update code
+			CursorType cursorId = CURSOR_ARROW;
+			if (_action._v83338 == 1 && !_screenObjects._v7FECA &&
+					_screenObjects._category == CAT_HOTSPOT) {
+				int idx = _screenObjects._selectedObject - _interface._screenObjectsCount;
+				if (idx >= (int)_hotspots.size()) {
+					idx -= _hotspots.size();
+					_vm->_events->_newCursorId = _dynamicHotspots[idx]._cursor;
+				} else {
+					_vm->_events->_newCursorId = _hotspots[idx]._cursor;
+				}
+
+				cursorId = _vm->_events->_newCursorId == CURSOR_NONE ? 
+					CURSOR_ARROW : _vm->_events->_newCursorId;
+			}
+
+			if (!player._stepEnabled)
+				cursorId = CURSOR_WAIT;
+			if (cursorId >= _vm->_events->_cursorSprites->getCount())
+				cursorId = (CursorType)_vm->_events->_cursorSprites->getCount();
+			_vm->_events->_newCursorId = cursorId;
+
+			if (cursorId != _vm->_events->_cursorId) {
+				_vm->_events->setCursor(cursorId);
+			}
+
+			// TODO: Rest of Scene::doFrame
+		}
 	}
 }
 
@@ -292,6 +364,29 @@ void Scene::leftClick() {
 	warning("TODO: Scene::leftClick");
 }
 
+void Scene::doPreactions() {
+	warning("TODO: Scene::doPreactions");
+}
+
+void Scene::doAction() {
+	warning("TODO: Scene::doAction");
+}
+
+void Scene::checkStartWalk() {
+	if (_action._startWalkFlag && _action._walkFlag) {
+		_vm->_game->_player.setDest(_destPos, _destFacing);
+		_action._startWalkFlag = false;
+	}
+}
+
+void Scene::doSceneStep() {
+	warning("TODO: Scene::doSceneStep");
+}
+
+void Scene::checkKeyboard() {
+	warning("TODO: Scene::checkKeyboard");
+}
+
 void Scene::free() {
 	warning("TODO: Scene::free");
 }
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index a02c4a5..4b822d1 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -59,6 +59,16 @@ private:
 	 * Handles a single frame within the game scene
 	 */
 	void doFrame();
+
+	void doPreactions();
+
+	void doAction();
+
+	void checkStartWalk();
+
+	void doSceneStep();
+
+	void checkKeyboard();
 protected:
 	MADSEngine *_vm;
 public:
@@ -93,6 +103,7 @@ public:
 	SceneNodeList _nodes;
 	Common::StringArray _vocabStrings;
 	Animation *_animation;
+	bool _freeAnimationFlag;
 	int _depthStyle;
 	int _bandsRange;
 	int _scaleRange;
@@ -104,6 +115,8 @@ public:
 	MADSAction _action;
 	bool _roomChanged;
 	bool _reloadSceneFlag;
+	Common::Point _destPos;
+	int _destFacing;
 
 	/**
 	 * Constructor
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 601d719..10d346e 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -217,7 +217,7 @@ DynamicHotspot::DynamicHotspot() {
 	_descId = 0;
 	_field14 = 0;
 	_articleNumber = 0;
-	_cursor = 0;
+	_cursor = CURSOR_NONE;
 }
 
 /*------------------------------------------------------------------------*/
@@ -292,7 +292,7 @@ KernelMessage::KernelMessage() {
 Hotspot::Hotspot() {
 	_facing = 0;
 	_articleNumber = 0;
-	_cursor = 0;
+	_cursor = CURSOR_NONE;
 	_vocabId = 0;
 	_verbId = 0;
 }
@@ -307,7 +307,7 @@ Hotspot::Hotspot(Common::SeekableReadStream &f) {
 	_facing = f.readByte();
 	_articleNumber = f.readByte();
 	f.skip(1);
-	_cursor = f.readByte();
+	_cursor = (CursorType)f.readByte();
 	_vocabId = f.readUint16LE();
 	_verbId = f.readUint16LE();
 }
@@ -354,6 +354,7 @@ void SceneNode::load(Common::SeekableReadStream *f) {
 
 InterfaceSurface::InterfaceSurface(MADSEngine *vm): _vm(vm) {
 	_category = CAT_NONE;
+	_screenObjectsCount = 0;
 }
 
 void InterfaceSurface::elementHighlighted() {
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 8b874a1..c11c59a 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -30,6 +30,7 @@
 #include "common/rect.h"
 #include "mads/action.h"
 #include "mads/assets.h"
+#include "mads/events.h"
 #include "mads/game_data.h"
 
 namespace MADS {
@@ -185,7 +186,7 @@ public:
 	int _descId;
 	int _field14;
 	int _articleNumber;
-	int _cursor;
+	CursorType _cursor;
 
 	DynamicHotspot();
 };
@@ -271,7 +272,7 @@ public:
 	Common::Point _feetPos;
 	int _facing;
 	int _articleNumber;
-	int _cursor;
+	CursorType _cursor;
 	int _vocabId;
 	int _verbId;
 
@@ -356,6 +357,7 @@ private:
 	MADSEngine *_vm;
 public:
 	ScrCategory _category;
+	int _screenObjectsCount;
 public:
 	/**
 	 * Constructor


Commit: 3a3a295758a87817e9d66d3c06df56859ef55529
    https://github.com/scummvm/scummvm/commit/3a3a295758a87817e9d66d3c06df56859ef55529
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-03T20:53:27-05:00

Commit Message:
MADS: Implemented sequence list, improvements for sprite assets

Changed paths:
  A engines/mads/sequence.cpp
  A engines/mads/sequence.h
    engines/mads/assets.cpp
    engines/mads/assets.h
    engines/mads/module.mk
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index f7188e9..c968afc 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -25,72 +25,161 @@
 #include "mads/assets.h"
 #include "mads/compression.h"
 #include "mads/events.h"
+#include "mads/palette.h"
 
 namespace MADS {
 
-SpriteAsset::SpriteAsset(MADSEngine *vm, const Common::String &resourceName, int flags):
-		_vm(vm) {
+SpriteAsset::SpriteAsset(MADSEngine *vm, const Common::String &resourceName, int flags) :
+	_vm(vm) {
 	Common::String resName = resourceName;
 	if (!resName.hasSuffix(".SS"))
 		resName += ".SS";
-	
+
 	File file(resName);
-	MadsPack sprites(&file);
+	load(&file, flags);
+
+	file.close();
+}
+	
+SpriteAsset::SpriteAsset(MADSEngine *vm, Common::SeekableReadStream *stream, int flags) :
+		_vm(vm) {
+	load(stream, flags);
+}
 
+void SpriteAsset::load(Common::SeekableReadStream *stream, int flags) {
 	int curFrame = 0;
 	uint32 frameOffset = 0;
+	MadsPack sprite(stream);
 	_frameRate = 0;
 	_pixelSpeed = 0;
 	_maxWidth = 0;
 	_maxHeight = 0;
 
-	Common::SeekableReadStream *spriteStream = sprites.getItemStream(0);
-	for (int i = 0; i < 19; i++) {
-		spriteStream->readUint16LE();
-	}
+	Common::SeekableReadStream *spriteStream = sprite.getItemStream(0);
+	_mode = spriteStream->readByte();
+	spriteStream->skip(1);
+	int type1 = spriteStream->readUint16LE();
+	int type2 = spriteStream->readUint16LE();
+	_isBackground = (type1 != 0) && (type2 < 4);
+	spriteStream->skip(32);
 	_frameCount = spriteStream->readUint16LE();
 
+	if ((flags & SPRITE_SET_CHAR_INFO) == 0)
+		_charInfo = nullptr;
+	else
+		_charInfo = new SpriteSetCharInfo(spriteStream);
+
+	delete spriteStream;
+
 	// Get the palette data
-	spriteStream = sprites.getItemStream(2);
+	spriteStream = sprite.getItemStream(2);
 	int numColors = 0;
 	byte *palData = _vm->_palette->decodePalette(spriteStream, &numColors);
-
 	Common::copy(palData, &palData[numColors], &_palette[0]);
-	if (numColors < 256) 
-		Common::fill(&_palette[numColors * 3], &_palette[PALETTE_SIZE], 0);
+	if (numColors < 256)
+		Common::fill((byte *)&_palette[numColors], (byte *)&_palette[256], 0);
 	_colorCount = numColors;
 	delete[] palData;
 	delete spriteStream;
 
-	Common::SeekableReadStream *spriteDataStream = sprites.getItemStream(3);
-
+	spriteStream = sprite.getItemStream(1);
+	Common::SeekableReadStream *spriteDataStream = sprite.getItemStream(3);
 	SpriteAssetFrame frame;
+	Common::Array<int> frameSizes;
 	for (curFrame = 0; curFrame < _frameCount; curFrame++) {
-		frame.comp = 0;
+		frame._stream = 0;
+		frame._comp = 0;
 		frameOffset = spriteStream->readUint32LE();
 		_frameOffsets.push_back(frameOffset);
-		spriteStream->readUint32LE();	// frame size
-		frame.x = spriteStream->readUint16LE();
-		frame.y = spriteStream->readUint16LE();
-		frame.w = spriteStream->readUint16LE();
-		frame.h = spriteStream->readUint16LE();
-		if (curFrame == 0) {
-			debugN(kDebugGraphics, "%i frames, x = %i, y = %i, w = %i, h = %i\n", 
-				_frameCount, frame.x, frame.y, frame.w, frame.h);
+		uint32 frameSize = spriteStream->readUint32LE();
+		frameSizes.push_back(frameSize);
+
+		frame._bounds.left = spriteStream->readSint16LE();
+		frame._bounds.top  = spriteStream->readSint16LE();
+		frame._bounds.setWidth(spriteStream->readUint16LE());
+		frame._bounds.setHeight(spriteStream->readUint16LE());
+
+		if (curFrame == 0)
+			debugC(1, kDebugGraphics, "%i frames, x = %i, y = %i, w = %i, h = %i\n", 
+			_frameCount, frame._bounds.left, frame._bounds.top, 
+			frame._bounds.width(), frame._bounds.height());
+
+		if (_mode == 0) {
+			// Create a frame and decompress the raw pixel data
+			uint32 currPos = (uint32)spriteDataStream->pos();
+			frame._frame = new MSprite(spriteDataStream, 
+				Common::Point(frame._bounds.left, frame._bounds.top),
+				frame._bounds.width(), frame._bounds.height(), false);
+			assert((uint32)spriteDataStream->pos() == (currPos + frameSize));
 		}
 
-		frame.frame = new MSprite(spriteDataStream, Common::Point(frame.x, frame.y), 
-			frame.w, frame.h, false);
 		_frames.push_back(frame);
 	}
 
+	if (_mode != 0) {
+		// Handle decompressing Fab encoded data
+		for (curFrame = 0; curFrame < _frameCount; curFrame++) {
+			FabDecompressor fab;
+
+			int srcSize = (curFrame == (_frameCount - 1)) ? spriteDataStream->size() - _frameOffsets[curFrame] :
+				_frameOffsets[curFrame + 1] - _frameOffsets[curFrame];
+			byte *srcData = new byte[srcSize];
+			assert(srcData);
+			spriteDataStream->read(srcData, srcSize);
+
+			byte *destData = new byte[frameSizes[curFrame]];
+			assert(destData);
+
+			fab.decompress(srcData, srcSize, destData, frameSizes[curFrame]);
+
+			// Load the frame
+			Common::MemoryReadStream *rs = new Common::MemoryReadStream(destData, frameSizes[curFrame]);
+			_frames[curFrame]._frame = new MSprite(rs, 
+				Common::Point(_frames[curFrame]._bounds.left, _frames[curFrame]._bounds.top),
+				_frames[curFrame]._bounds.width(), _frames[curFrame]._bounds.height(), false);
+			delete rs;
+
+			delete[] srcData;
+			delete[] destData;
+		}
+	}
+
+	delete spriteStream;
 	delete spriteDataStream;
-	file.close();
 }
 
+MSprite *SpriteAsset::getFrame(int frameIndex) {
+	if ((uint)frameIndex < _frames.size()) {
+		return _frames[frameIndex]._frame;
+	} else {
+		debugC(kDebugGraphics, "SpriteAsset::getFrame: Invalid frame %d, out of %d", frameIndex, _frames.size());
+		return _frames[_frames.size() - 1]._frame;
+	}
+}
+
+
 void SpriteAsset::drawScaled(int frameNumber, MSurface &depthSurface, MSurface &destSurface,
 		int scale, int depth, const Common::Point &pos) {
 	warning("TODO: SpriteAsset::drawScaled");
 }
 
+/*------------------------------------------------------------------------*/
+
+SpriteSetCharInfo::SpriteSetCharInfo(Common::SeekableReadStream *s) {
+	_totalFrames = s->readByte();
+	s->skip(1);
+	_numEntries = s->readUint16LE();
+
+	for (int i = 0; i < 16; ++i)
+		_frameList[i] = s->readUint16LE();
+	for (int i = 0; i < 16; ++i)
+		_frameList2[i] = s->readUint16LE();
+	for (int i = 0; i < 16; ++i)
+		_ticksList[i] = s->readUint16LE();
+
+	_unk1 = s->readUint16LE();
+	_ticksAmount = s->readByte();
+	_yScale = s->readByte();
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/assets.h b/engines/mads/assets.h
index 5964036..7a6939b 100644
--- a/engines/mads/assets.h
+++ b/engines/mads/assets.h
@@ -31,11 +31,27 @@
 
 namespace MADS {
 
+#define SPRITE_SET_CHAR_INFO 4
+
 struct SpriteAssetFrame {
-	uint32 stream;
-	int x, y, w, h;
-	uint32 comp;
-	MSprite *frame;
+	uint32 _stream;
+	Common::Rect _bounds;
+	uint32 _comp;
+	MSprite *_frame;
+};
+
+class SpriteSetCharInfo {
+public:
+	SpriteSetCharInfo(Common::SeekableReadStream *s);
+
+	int _totalFrames;
+	int _numEntries;
+	int _frameList2[16];
+	int _frameList[16];
+	int _ticksList[16];
+	int _unk1;
+	int _ticksAmount;
+	int _yScale;
 };
 
 class SpriteAsset {
@@ -50,8 +66,26 @@ private:
 	Common::Array<uint32> _frameOffsets;
 	Common::Array<SpriteAssetFrame> _frames;
 	uint32 _frameStartOffset;
+	uint8 _mode;
+	bool _isBackground;
+
+	/**
+	 * Load the data for the asset
+	 */
+	void load(Common::SeekableReadStream *stream, int flags);
+public:
+	SpriteSetCharInfo *_charInfo;
 public:
+	/**
+	 * Constructor
+	 */
 	SpriteAsset(MADSEngine *vm, const Common::String &resourceName, int flags);
+
+	/**
+	 * Constructor
+	 */
+	SpriteAsset(MADSEngine *vm, Common::SeekableReadStream *stream, int flags);
+
 	int getCount() { return _frameCount; }
 	int getFrameRate() const { return _frameRate; }
 	int getPixelSpeed() const { return _pixelSpeed; }
@@ -62,6 +96,7 @@ public:
 	MSprite *getFrame(int frameIndex);
 	byte *getPalette() { return _palette; }
 	int getColorCount() { return _colorCount; }
+	bool isBackground() const { return _isBackground; }
 
 	void drawScaled(int frameNumber, MSurface &depthSurface, MSurface &destSurface,
 		int scale, int depth, const Common::Point &pos);
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index f715e1a..826e54f 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -26,6 +26,7 @@ MODULE_OBJS := \
 	resources.o \
 	scene.o \
 	scene_data.o \
+	sequence.o \
 	sound.o \
 	user_interface.o
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 47b9bfa..6efbdf5 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -29,7 +29,8 @@
 namespace MADS {
 
 Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm),
-		_dynamicHotspots(vm), _screenObjects(vm), _interface(vm) {
+		_dynamicHotspots(vm), _screenObjects(vm), _interface(vm),
+		_sequences(vm) {
 	_priorSceneId = 0;
 	_nextSceneId = 0;
 	_currentSceneId = 0;
@@ -355,6 +356,10 @@ void Scene::doFrame() {
 				_vm->_events->setCursor(cursorId);
 			}
 
+			if (!_vm->_game->_abortTimers)
+				_sequences.tick();
+
+
 			// TODO: Rest of Scene::doFrame
 		}
 	}
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 4b822d1..71bfe31 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -30,6 +30,7 @@
 #include "mads/msurface.h"
 #include "mads/scene_data.h"
 #include "mads/animation.h"
+#include "mads/sequence.h"
 
 namespace MADS {
 
@@ -84,7 +85,7 @@ public:
 	DynamicHotspots _dynamicHotspots;
 	byte *_vocabBuffer;
 	Common::Array<int> _activeVocabs;
-	Common::Array<SequenceEntry> _sequences;
+	SequenceList _sequences;
 	Common::Array<KernelMessage> _messages;
 	Common::String _talkFont;
 	int _textSpacing;
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 10d346e..6fa2f5b 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -223,54 +223,96 @@ DynamicHotspot::DynamicHotspot() {
 /*------------------------------------------------------------------------*/
 
 DynamicHotspots::DynamicHotspots(MADSEngine *vm): _vm(vm) {
-	_changed = false;
+	for (int i = 0; i < DYNAMIC_HOTSPOTS_SIZE; ++i) {
+		DynamicHotspot rec;
+		rec._active = false;
+		_entries.push_back(rec);
+	}
+
+	_changed = true;
+	_count = 0;
 }
 
-void DynamicHotspots::clear() {
-	Common::Array<DynamicHotspot>::clear();
-	_changed = false;
+int DynamicHotspots::add(int descId, int field14, int seqIndex, const Common::Rect &bounds) {
+	// Find a free slot
+	uint idx = 0;
+	while ((idx < _entries.size()) && _entries[idx]._active)
+		++idx;
+	if (idx == _entries.size())
+		error("DynamicHotspots overflow");
+
+	_entries[idx]._active = true;
+	_entries[idx]._descId = descId;
+	_entries[idx]._seqIndex = seqIndex;
+	_entries[idx]._bounds = bounds;
+	_entries[idx]._feetPos.x = -3;
+	_entries[idx]._feetPos.y = 0;
+	_entries[idx]._facing = 5;
+	_entries[idx]._field14 = field14;
+	_entries[idx]._articleNumber = 6;
+	_entries[idx]._cursor = CURSOR_NONE;
+
+	++_count;
+	_changed = true;
+
+	if (seqIndex >= 0)
+		_vm->_game->_scene._sequences[seqIndex]._dynamicHotspotIndex = idx;
+
+	return idx;
 }
 
-void DynamicHotspots::refresh() {
+int DynamicHotspots::setPosition(int index, int xp, int yp, int facing) {
+	if (index >= 0) {
+		_entries[index]._feetPos.x = xp;
+		_entries[index]._feetPos.y = yp;
+		_entries[index]._facing = facing;
+	}
+
+	return index;
+}
+
+int DynamicHotspots::setCursor(int index, CursorType cursor) {
+	if (index >= 0)
+		_entries[index]._cursor = cursor;
+
+	return index;
+}
+
+void DynamicHotspots::remove(int index) {
 	Scene &scene = _vm->_game->_scene;
 
-	for (uint idx = 0; idx < size(); ++idx) {
-		DynamicHotspot &dh = (*this)[idx];
+	if (_entries[index]._active) {
+		if (_entries[index]._seqIndex >= 0)
+			scene._sequences[_entries[index]._seqIndex]._dynamicHotspotIndex = -1;
+		_entries[index]._active = false;
 
-		switch (scene._screenObjects._v832EC) {
-		case 0:
-		case 2:
-			scene._screenObjects.add(dh._bounds, CAT_12, dh._descId);
-			scene._screenObjects._v8333C = true;
-		default:
-			break;
-		}
+		--_count;
+		_changed = true;
 	}
 }
 
-/*------------------------------------------------------------------------*/
+void DynamicHotspots::clear() {
+	for (uint i = 0; i < _entries.size(); ++i)
+		_entries[i]._active = false;
 
-SequenceEntry::SequenceEntry() {
-	_spritesIndex = 0;
-	_flipped =0;
-	_frameIndex = 0;
-	_frameStart = 0;
-	_numSprites = 0;
-	_animType = 0;
-	_frameInc = 0;
-	_depth = 0;
-	_scale = 0;
-	_dynamicHotspotIndex = -1;
-	_triggerCountdown = 0;
-	_doneFlag = 0;
-	_entries._count = 0;
-	_abortMode = 0;
-	_actionNouns[0] = _actionNouns[1] = _actionNouns[2] = 0;
-	_numTicks = 0;
-	_extraTicks = 0;
-	_timeout = 0;
+	_changed = false;
+	_count = 0;
 }
 
+void DynamicHotspots::reset() {
+	for (uint i = 0; i < _entries.size(); ++i)
+		remove(i);
+
+	_count = 0;
+	_changed = false;
+}
+
+void DynamicHotspots::refresh() {
+	error("DynamicHotspots::refresh");
+}
+
+/*------------------------------------------------------------------------*/
+
 KernelMessage::KernelMessage() {
 	_flags = 0;
 	_seqInex = 0;
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index c11c59a..dc59bff 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -153,6 +153,18 @@ public:
 	 * @param index		Specifies the index in the array
 	 */
 	void deleteEntry(int index);
+
+	SpriteAsset &getSprite(int idx) {
+		error("TODO");
+	}
+	void deleteTimer(int idx) { 
+		warning("TODO: SpriteSlots::deleteTimer"); 
+	}
+	int getIndex() {
+		warning("TODO: SpriteSlots::indexOf");
+		return -1;
+	}
+
 };
 
 class SpriteSets: public Common::Array<SpriteAsset *> {
@@ -179,6 +191,7 @@ public:
 
 class DynamicHotspot {
 public:
+	bool _active;
 	int _seqIndex;
 	Common::Rect _bounds;
 	Common::Point _feetPos;
@@ -191,60 +204,28 @@ public:
 	DynamicHotspot();
 };
 
-class DynamicHotspots : public Common::Array<DynamicHotspot> {
+#define DYNAMIC_HOTSPOTS_SIZE 8
+
+class DynamicHotspots {
 private:
 	MADSEngine *_vm;
+	Common::Array<DynamicHotspot> _entries;
+	int _count;
 public:
 	bool _changed;
-
-	/**
-	 * Constructor
-	 */
+public:
 	DynamicHotspots(MADSEngine *vm);
 
-	/**
-	 * Clear the list
-	 */
+	DynamicHotspot &operator[](uint idx) { return _entries[idx]; }
+	int add(int descId, int field14, int seqIndex, const Common::Rect &bounds);
+	int setPosition(int index, int xp, int yp, int facing);
+	int setCursor(int index, CursorType cursor);
+	void remove(int index);
 	void clear();
-
-	/**
-	 * Refresh the list
-	 */
+	void reset();
 	void refresh();
 };
 
-class SequenceEntry {
-public:
-	int _spritesIndex;
-	int _flipped;
-	int _frameIndex;
-	int _frameStart;
-	int _numSprites;
-	int _animType;
-	int _frameInc;
-	int _depth;
-	int _scale;
-	int _dynamicHotspotIndex;
-	
-	Common::Point _msgPos;
-
-	int _triggerCountdown;
-	bool _doneFlag;
-	struct {
-		int _count;
-		int _mode[5];
-		int _frameIndex[5];
-		int _abortVal[5];
-	} _entries;
-	int _abortMode;
-	int _actionNouns[3];
-	int _numTicks;
-	int _extraTicks;
-	int _timeout;
-
-	SequenceEntry();
-};
-
 class KernelMessage {
 public:
 	int _flags;
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
new file mode 100644
index 0000000..7c7b25d
--- /dev/null
+++ b/engines/mads/sequence.cpp
@@ -0,0 +1,370 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/assets.h"
+#include "mads/sequence.h"
+#include "mads/scene.h"
+
+namespace MADS {
+
+SequenceEntry::SequenceEntry() {
+	_spritesIndex = 0;
+	_flipped = 0;
+	_frameIndex = 0;
+	_frameStart = 0;
+	_numSprites = 0;
+	_animType = ANIMTYPE_NONE;
+	_frameInc = 0;
+	_depth = 0;
+	_scale = 0;
+	_dynamicHotspotIndex = -1;
+	_triggerCountdown = 0;
+	_doneFlag = 0;
+	_entries._count = 0;
+	_abortMode = ABORTMODE_0;
+	_actionNouns[0] = _actionNouns[1] = _actionNouns[2] = 0;
+	_numTicks = 0;
+	_extraTicks = 0;
+	_timeout = 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+#define TIMER_LIST_SIZE 30
+
+SequenceList::SequenceList(MADSEngine *vm) : _vm(vm) {
+	for (int i = 0; i < TIMER_LIST_SIZE; ++i) {
+		SequenceEntry rec;
+		rec._active = false;
+		rec._dynamicHotspotIndex = -1;
+		_entries.push_back(rec);
+	}
+}
+
+void SequenceList::clear() {
+	for (uint i = 0; i < _entries.size(); ++i) {
+		_entries[i]._active = false;
+		_entries[i]._dynamicHotspotIndex = -1;
+	}
+}
+
+bool SequenceList::addSubEntry(int index, SequenceSubEntryMode mode, int frameIndex, int abortVal) {
+	if (_entries[index]._entries._count >= TIMER_ENTRY_SUBSET_MAX)
+		return true;
+
+	int subIndex = _entries[index]._entries._count++;
+	_entries[index]._entries._mode[subIndex] = mode;
+	_entries[index]._entries._frameIndex[subIndex] = frameIndex;
+	_entries[index]._entries._abortVal[subIndex] = abortVal;
+
+	return false;
+}
+
+int SequenceList::add(int spriteListIndex, bool flipped, int frameIndex, int triggerCountdown, int delayTicks, int extraTicks, int numTicks,
+	int msgX, int msgY, bool nonFixed, char scale, uint8 depth, int frameInc, SpriteAnimType animType, int numSprites,
+	int frameStart) {
+	Scene &scene = _vm->_game->_scene;
+
+	// Find a free slot
+	uint seqIndex = 0;
+	while ((seqIndex < _entries.size()) && _entries[seqIndex]._active)
+		++seqIndex;
+	if (seqIndex == _entries.size())
+		error("TimerList full");
+
+	if (frameStart <= 0)
+		frameStart = 1;
+	if (numSprites == 0)
+		numSprites = scene._spriteSlots.getSprite(spriteListIndex).getCount();
+	if (frameStart == numSprites)
+		frameInc = 0;
+
+	// Set the list entry fields
+	_entries[seqIndex]._active = true;
+	_entries[seqIndex]._spritesIndex = spriteListIndex;
+	_entries[seqIndex]._flipped = flipped;
+	_entries[seqIndex]._frameIndex = frameIndex;
+	_entries[seqIndex]._frameStart = frameStart;
+	_entries[seqIndex]._numSprites = numSprites;
+	_entries[seqIndex]._animType = animType;
+	_entries[seqIndex]._frameInc = frameInc;
+	_entries[seqIndex]._depth = depth;
+	_entries[seqIndex]._scale = scale;
+	_entries[seqIndex]._nonFixed = nonFixed;
+	_entries[seqIndex]._msgPos.x = msgX;
+	_entries[seqIndex]._msgPos.y = msgY;
+	_entries[seqIndex]._numTicks = numTicks;
+	_entries[seqIndex]._extraTicks = extraTicks;
+
+	_entries[seqIndex]._timeout = _vm->_events->_currentTimer + delayTicks;
+
+	_entries[seqIndex]._triggerCountdown = triggerCountdown;
+	_entries[seqIndex]._doneFlag = false;
+	_entries[seqIndex]._field13 = 0;
+	_entries[seqIndex]._dynamicHotspotIndex = -1;
+	_entries[seqIndex]._entries._count = 0;
+	_entries[seqIndex]._abortMode = _vm->_game->_abortTimersMode2;
+
+	for (int i = 0; i < 3; ++i)
+		_entries[seqIndex]._actionNouns[i] = _actionNouns[i];
+
+	return seqIndex;
+}
+
+void SequenceList::remove(int seqIndex) {
+	Scene &scene = _vm->_game->_scene;
+
+	if (_entries[seqIndex]._active) {
+		if (_entries[seqIndex]._dynamicHotspotIndex >= 0)
+			scene._dynamicHotspots.remove(_entries[seqIndex]._dynamicHotspotIndex);
+	}
+
+	_entries[seqIndex]._active = false;
+	scene._spriteSlots.deleteTimer(seqIndex);
+}
+
+void SequenceList::setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot) {
+	Scene &scene = _vm->_game->_scene;
+	SequenceEntry &timerEntry = _entries[seqIndex];
+	SpriteAsset &spriteSet = scene._spriteSlots.getSprite(timerEntry._spritesIndex);
+
+	spriteSlot._spriteType = spriteSet.isBackground() ? ST_BACKGROUND : ST_FOREGROUND;
+	spriteSlot._seqIndex = seqIndex;
+	spriteSlot._spritesIndex = timerEntry._spritesIndex;
+	spriteSlot._frameNumber = (timerEntry._flipped ? 0x8000 : 0) | timerEntry._frameIndex;
+	spriteSlot._depth = timerEntry._depth;
+	spriteSlot._scale = timerEntry._scale;
+
+	if (!timerEntry._nonFixed) {
+		spriteSlot._position = timerEntry._msgPos;
+	} else {
+		spriteSlot._position = spriteSet.getFrame(timerEntry._frameIndex - 1)->_pos;
+	}
+}
+
+bool SequenceList::loadSprites(int seqIndex) {
+	Scene &scene = _vm->_game->_scene;
+	SequenceEntry &seqEntry = _entries[seqIndex];
+	int slotIndex;
+	bool result = false;
+	int idx = -1;
+
+	scene._spriteSlots.deleteTimer(seqIndex);
+	if (seqEntry._doneFlag) {
+		remove(seqIndex);
+		return false;
+	}
+
+	if (seqEntry._spritesIndex == -1) {
+		// Doesn't have an associated sprite anymore, so mark as done
+		seqEntry._doneFlag = true;
+	}
+	else if ((slotIndex = scene._spriteSlots.getIndex()) >= 0) {
+		SpriteSlot &spriteSlot = scene._spriteSlots[slotIndex];
+		setSpriteSlot(seqIndex, spriteSlot);
+
+		int x2 = 0, y2 = 0;
+
+		if ((seqEntry._field13 != 0) || (seqEntry._dynamicHotspotIndex >= 0)) {
+			SpriteAsset &spriteSet = scene._spriteSlots.getSprite(seqEntry._spritesIndex);
+			MSprite *frame = spriteSet.getFrame(seqEntry._frameIndex - 1);
+			int width = frame->getWidth() * seqEntry._scale / 200;
+			int height = frame->getHeight() * seqEntry._scale / 100;
+
+			warning("frame size %d x %d", width, height);
+
+			// TODO: Missing stuff here, and I'm not certain about the dynamic hotspot stuff below
+
+			if (seqEntry._dynamicHotspotIndex >= 0) {
+				DynamicHotspot &dynHotspot = scene._dynamicHotspots[seqEntry._dynamicHotspotIndex];
+
+				dynHotspot._bounds.left = MAX(x2 - width, 0);
+				dynHotspot._bounds.right = MAX(x2 - width, 319) - dynHotspot._bounds.left + 1;
+				dynHotspot._bounds.top = MAX(y2 - height, 0);
+				dynHotspot._bounds.bottom = MIN(y2, 155) - dynHotspot._bounds.top;
+
+				scene._dynamicHotspots._changed = true;
+			}
+		}
+
+		// Frame adjustments
+		if (seqEntry._frameStart != seqEntry._numSprites)
+			seqEntry._frameIndex += seqEntry._frameInc;
+
+		if (seqEntry._frameIndex >= seqEntry._frameStart) {
+			if (seqEntry._frameIndex > seqEntry._numSprites) {
+				result = true;
+				if (seqEntry._animType == ANIMTYPE_CYCLED) {
+					// Reset back to the starting frame (cyclic)
+					seqEntry._frameIndex = seqEntry._frameStart;
+				}
+				else {
+					// Switch into reverse mode
+					seqEntry._frameIndex = seqEntry._numSprites - 1;
+					seqEntry._frameInc = -1;
+				}
+			}
+		}
+		else {
+			// Currently in reverse mode and moved past starting frame
+			result = true;
+
+			if (seqEntry._animType == ANIMTYPE_CYCLED)
+			{
+				// Switch back to forward direction again
+				seqEntry._frameIndex = seqEntry._frameStart + 1;
+				seqEntry._frameInc = 1;
+			}
+			else {
+				// Otherwise reset back to last sprite for further reverse animating
+				seqEntry._frameIndex = seqEntry._numSprites;
+			}
+		}
+
+		if (result && (seqEntry._triggerCountdown != 0)) {
+			if (--seqEntry._triggerCountdown == 0)
+				seqEntry._doneFlag = true;
+		}
+	}
+	else {
+		// Out of sprite display slots, so mark entry as done
+		seqEntry._doneFlag = true;
+	}
+
+	if (seqEntry._entries._count > 0) {
+		for (int i = 0; i <= seqEntry._entries._count; ++i) {
+			switch (seqEntry._entries._mode[i]) {
+			case SM_0:
+			case SM_1:
+				if (((seqEntry._entries._mode[i] == SM_0) && seqEntry._doneFlag) ||
+					((seqEntry._entries._mode[i] == SM_1) && result))
+					idx = i;
+				break;
+
+			case SM_FRAME_INDEX: {
+				int v = seqEntry._entries._frameIndex[i];
+				if ((v == seqEntry._frameIndex) || (v == 0))
+					idx = i;
+				break;
+			}
+
+			default:
+				break;
+			}
+		}
+	}
+
+	if (idx >= 0) {
+		_vm->_game->_abortTimers = seqEntry._entries._abortVal[idx];
+		_vm->_game->_abortTimersMode = seqEntry._abortMode;
+	}
+
+	return result;
+}
+
+/**
+* Handles counting down entries in the timer list for action
+*/
+void SequenceList::tick() {
+	for (uint idx = 0; idx < _entries.size(); ++idx) {
+		if ((_vm->_game->_abortTimers2 == 0) && (_vm->_game->_abortTimers != 0))
+			break;
+
+		SequenceEntry &seqEntry = _entries[idx];
+		uint32 currentTimer = _vm->_events->_currentTimer;
+
+		if (!seqEntry._active || (currentTimer < seqEntry._timeout))
+			continue;
+
+		// Set the next timeout for the timer entry
+		seqEntry._timeout = currentTimer + seqEntry._numTicks;
+
+		// Action the sprite
+		if (loadSprites(idx)) {
+			seqEntry._timeout += seqEntry._extraTicks;
+		}
+	}
+}
+
+void SequenceList::delay(uint32 v1, uint32 v2) {
+	for (uint idx = 0; idx < _entries.size(); ++idx) {
+		if (_entries[idx]._active) {
+			_entries[idx]._timeout += v1 - v2;
+		}
+	}
+}
+
+void SequenceList::setAnimRange(int seqIndex, int startVal, int endVal) {
+	Scene &scene = _vm->_game->_scene;	
+	SequenceEntry &seqEntry = _entries[seqIndex];
+	SpriteAsset &spriteSet = scene._spriteSlots.getSprite(seqEntry._spritesIndex);
+	int numSprites = spriteSet.getCount();
+	int tempStart = startVal, tempEnd = endVal;
+
+	switch (startVal) {
+	case -2:
+		tempStart = numSprites;
+		break;
+	case -1:
+		tempStart = 1;
+		break;
+	}
+
+	switch (endVal) {
+	case -2:
+	case 0:
+		tempEnd = numSprites;
+		break;
+	case -1:
+		tempEnd = 1;
+		break;
+	default:
+		tempEnd = numSprites;
+		break;
+	}
+
+	seqEntry._frameStart = tempStart;
+	seqEntry._numSprites = tempEnd;
+
+	seqEntry._frameIndex = (seqEntry._frameInc < 0) ? tempStart : tempEnd;
+}
+
+void SequenceList::scan() {
+	Scene &scene = _vm->_game->_scene;
+
+	for (uint i = 0; i < _entries.size(); ++i) {
+		if (!_entries[i]._active && (_entries[i]._spritesIndex != -1)) {
+			int idx = scene._spriteSlots.getIndex();
+			setSpriteSlot(i, scene._spriteSlots[idx]);
+		}
+	}
+}
+
+/**
+* Sets the depth of the specified entry in the sequence list
+*/
+void SequenceList::setDepth(int seqIndex, int depth) {
+	_entries[seqIndex]._depth = depth;
+}
+} // End of namespace 
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
new file mode 100644
index 0000000..1b9aefe
--- /dev/null
+++ b/engines/mads/sequence.h
@@ -0,0 +1,109 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_SEQUENCE_H
+#define MADS_SEQUENCE_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+#include "common/rect.h"
+#include "mads/action.h"
+
+namespace MADS {
+
+class SpriteSlot;
+
+enum SequenceSubEntryMode { SM_0 = 0, SM_1 = 1, SM_FRAME_INDEX = 2 };
+
+enum SpriteAnimType { ANIMTYPE_NONE = 0, ANIMTYPE_CYCLED = 1, ANIMTYPE_REVERSIBLE = 2 };
+
+#define TIMER_ENTRY_SUBSET_MAX 5
+
+struct SequenceSubEntries {
+	int _count;
+	SequenceSubEntryMode _mode[TIMER_ENTRY_SUBSET_MAX];
+	int _frameIndex[TIMER_ENTRY_SUBSET_MAX];
+	int8 _abortVal[TIMER_ENTRY_SUBSET_MAX];
+};
+
+struct SequenceEntry {
+	bool _active;
+	int8 _spritesIndex;
+	bool _flipped;
+
+	int _frameIndex;
+	int _frameStart;
+	int _numSprites;
+
+	SpriteAnimType _animType;
+	int _frameInc;
+
+	int _depth;
+	int _scale;
+	int _dynamicHotspotIndex;
+
+	bool _nonFixed;
+	int _field13;
+
+	Common::Point _msgPos;
+	int _triggerCountdown;
+	bool _doneFlag;
+	SequenceSubEntries _entries;
+	AbortTimerMode _abortMode;
+
+	uint16 _actionNouns[3];
+	int _numTicks;
+	int _extraTicks;
+	uint32 _timeout;
+
+	SequenceEntry();
+};
+
+class MADSEngine;
+
+class SequenceList {
+private:
+	MADSEngine *_vm;
+	Common::Array<SequenceEntry> _entries;
+	int _actionNouns[3];
+public:
+	SequenceList(MADSEngine *vm);
+
+	SequenceEntry &operator[](int index) { return _entries[index]; }
+	void clear();
+	bool addSubEntry(int index, SequenceSubEntryMode mode, int frameIndex, int abortVal);
+	int add(int spriteListIndex, bool flipped, int frameIndex, int triggerCountdown, int delayTicks,
+		int extraTicks, int numTicks, int msgX, int msgY, bool nonFixed, char scale, uint8 depth,
+		int frameInc, SpriteAnimType animType, int numSprites, int frameStart);
+	void remove(int seqIndex);
+	void setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot);
+	bool loadSprites(int seqIndex);
+	void tick();
+	void delay(uint32 v1, uint32 v2);
+	void setAnimRange(int seqIndex, int startVal, int endVal);
+	void scan();
+	void setDepth(int seqIndex, int depth);
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_SEQUENCE_H */


Commit: 9e356dd945863a4c4dfa89f2a94dd1a56c2d03a6
    https://github.com/scummvm/scummvm/commit/9e356dd945863a4c4dfa89f2a94dd1a56c2d03a6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-03T23:40:23-05:00

Commit Message:
MADS: Implemented extra message and dirty area classes

Changed paths:
  A engines/mads/messages.cpp
  A engines/mads/messages.h
    engines/mads/animation.cpp
    engines/mads/animation.h
    engines/mads/debugger.cpp
    engines/mads/debugger.h
    engines/mads/font.cpp
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/module.mk
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 8ea95ee..0546fc3 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -297,4 +297,8 @@ void Animation::loadInterface(InterfaceSurface &interfaceSurface, MSurface &dept
 	}
 }
 
+void Animation::update() {
+	warning("TODO: Animation::update");
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index ce145cdd..1f0e1fd 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -135,6 +135,11 @@ public:
 	 */
 	void load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, const Common::String &resName,
 		int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo);
+
+	/**
+	 * Update the animation
+	 */
+	void update();
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp
index ceaeeaa..34b12c1 100644
--- a/engines/mads/debugger.cpp
+++ b/engines/mads/debugger.cpp
@@ -26,6 +26,8 @@
 namespace MADS {
 
 Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) {
+	_showMousePos = false;
+
 	DCmd_Register("continue",		WRAP_METHOD(Debugger, Cmd_Exit));
 }
 /*
@@ -46,4 +48,14 @@ static int strToInt(const char *s) {
 }
 */
 
+bool Debugger::Cmd_Mouse(int argc, const char **argv) {
+	if (argc < 2) {
+		DebugPrintf("Format: mouse [ on | off ]\n");
+	} else {
+		_showMousePos = strcmp(argv[1], "on") == 0;
+	}
+
+	return true;
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/debugger.h b/engines/mads/debugger.h
index 044151c..983b993 100644
--- a/engines/mads/debugger.h
+++ b/engines/mads/debugger.h
@@ -33,11 +33,13 @@ class MADSEngine;
 class Debugger : public GUI::Debugger {
 private:
 	MADSEngine *_vm;
+protected:
+	bool Cmd_Mouse(int argc, const char **argv);
+public:
+	bool _showMousePos;
 public:
 	Debugger(MADSEngine *vm);
 	virtual ~Debugger() {}
-
-protected:
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/font.cpp b/engines/mads/font.cpp
index 10d51fb..0ff0190 100644
--- a/engines/mads/font.cpp
+++ b/engines/mads/font.cpp
@@ -93,7 +93,6 @@ void Font::setColors(uint8 v1, uint8 v2, uint8 v3, uint8 v4) {
 	_fontColors[0] = v1;
 	_fontColors[1] = v2;
 	_fontColors[2] = v3;
-	_fontColors[3] = v4;
 }
 
 int Font::write(MSurface *surface, const Common::String &msg, const Common::Point &pt, int width, int spaceWidth, uint8 colors[]) {
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 3702768..479c48c 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -278,4 +278,22 @@ void Game::loadResourceSequence(const Common::String prefix, int v) {
 	warning("TODO: loadResourceSequence");
 }
 
+Common::String Game::getQuote(int quoteId) {
+	if (_quotes && *_quotes) {
+		// Loop through the list of quotes
+		char *p = (char *)_quotes;
+		while (*p) {
+			// Get a pointer to the quote Id after the string
+			char *idP = p + strlen(p) + 1;
+			if (READ_LE_UINT16(idP) == quoteId)
+				// Found the correct string, so return it
+				return Common::String(p);
+
+			p = idP + 2;
+		}
+	}
+
+	return Common::String();
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 148fc12..47eed34 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -124,6 +124,11 @@ public:
 	 * Run the game
 	 */
 	void run();
+
+	/**
+	 * Get a quote
+	 */
+	Common::String getQuote(int quoteId);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
new file mode 100644
index 0000000..c08f29f
--- /dev/null
+++ b/engines/mads/messages.cpp
@@ -0,0 +1,384 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/font.h"
+#include "mads/graphics.h"
+#include "mads/messages.h"
+#include "mads/scene_data.h"
+
+namespace MADS {
+
+KernelMessages::KernelMessages(MADSEngine *vm): _vm(vm) {
+	Scene &scene = _vm->_game->_scene;
+
+	for (int i = 0; i < KERNEL_MESSAGES_SIZE; ++i) {
+		KernelMessage rec;
+		_entries.push_back(rec);
+	}
+
+	scene._textSpacing = -1;
+	_talkFont = _vm->_font->getFont(FONT_CONVERSATION);
+	word_8469E = 0;
+}
+
+void KernelMessages::clear() {
+	Scene &scene = _vm->_game->_scene;
+
+	for (uint i = 0; i < _entries.size(); ++i)
+		_entries[i]._flags = 0;
+
+	scene._textSpacing = -1;
+	_talkFont = _vm->_font->getFont(FONT_CONVERSATION);
+}
+
+int KernelMessages::add(const Common::Point &pt, uint fontColor, uint8 flags, 
+		uint8 abortTimers, uint32 timeout, const Common::String &msg) {
+	Scene &scene = _vm->_game->_scene; 
+
+	// Find a free slot
+	uint idx = 0;
+	while ((idx < _entries.size()) && ((_entries[idx]._flags & KMSG_ACTIVE) != 0))
+		++idx;
+	if (idx == _entries.size()) {
+		if (abortTimers == 0)
+			return -1;
+
+		error("KernelMessages overflow");
+	}
+
+	KernelMessage &rec = _entries[idx];
+	rec._msg = msg;
+	rec._flags = flags | KMSG_ACTIVE;
+	rec._color1 = fontColor & 0xff;
+	rec._color2 = fontColor >> 8;
+	rec._position = pt;
+	rec._textDisplayIndex = -1;
+	rec._timeout = timeout;
+	rec._frameTimer = _vm->_game->_currentTimer;
+	rec._abortTimers = abortTimers;
+	rec._abortMode = _vm->_game->_abortTimersMode2;
+
+	rec._actionDetails = scene._action._activeAction;
+
+	if (flags & KMSG_PLAYER_TIMEOUT)
+		rec._frameTimer = _vm->_game->_player._ticksAmount + 
+			_vm->_game->_player._priorTimer;
+
+	return idx;
+}
+
+int KernelMessages::addQuote(int quoteId, int abortTimers, uint32 timeout) {
+	Common::String quoteStr = _vm->_game->getQuote(quoteId);
+	return add(Common::Point(), 0x1110, KMSG_PLAYER_TIMEOUT | KMSG_CENTER_ALIGN, abortTimers, timeout, quoteStr);
+}
+
+void KernelMessages::scrollMessage(int msgIndex, int numTicks, bool quoted) {
+	if (msgIndex < 0)
+		return;
+
+	_entries[msgIndex]._flags |= quoted ? (KMSG_SCROLL | KMSG_QUOTED) : KMSG_SCROLL;
+	_entries[msgIndex]._msgOffset = 0;
+	_entries[msgIndex]._numTicks = numTicks;
+	_entries[msgIndex]._frameTimer2 = _vm->_game->_currentTimer;
+
+	Common::String msg = _entries[msgIndex]._msg;
+	_entries[msgIndex]._asciiChar = msg[0];
+	_entries[msgIndex]._asciiChar2 = msg[1];
+
+	if (_entries[msgIndex]._flags & KMSG_PLAYER_TIMEOUT)
+		_entries[msgIndex]._frameTimer2 = _vm->_game->_player._ticksAmount + 
+		_vm->_game->_player._priorTimer;
+
+	_entries[msgIndex]._frameTimer = _entries[msgIndex]._frameTimer2;
+}
+
+void KernelMessages::setSeqIndex(int msgIndex, int seqIndex) {
+	if (msgIndex >= 0) {
+		_entries[msgIndex]._flags |= KMSG_SEQ_ENTRY;
+		_entries[msgIndex]._sequenceIndex = seqIndex;
+	}
+}
+
+void KernelMessages::remove(int msgIndex) {
+	KernelMessage &rec = _entries[msgIndex];
+	Scene &scene = _vm->_game->_scene;
+
+	if (rec._flags & KMSG_ACTIVE) {
+		if (rec._flags & KMSG_SCROLL) {
+			rec._msg.setChar(rec._asciiChar, rec._msgOffset);
+			rec._msg.setChar(rec._asciiChar2, rec._msgOffset + 1);
+		}
+
+		if (rec._textDisplayIndex >= 0)
+			scene._textDisplay.expire(rec._textDisplayIndex);
+
+		rec._flags &= ~KMSG_ACTIVE;
+	}
+}
+
+void KernelMessages::reset() {
+	for (uint i = 0; i < _entries.size(); ++i)
+		remove(i);
+
+	warning("TODO: KernelMessages::reset - sub_20454");
+}
+
+void KernelMessages::update() {
+	uint32 currentTimer = _vm->_game->_currentTimer;
+
+	for (uint i = 0; i < _entries.size(); ++i) {
+		if (((_entries[i]._flags & KMSG_ACTIVE) != 0) && 
+				(currentTimer >= _entries[i]._frameTimer))
+			processText(i);
+	}
+}
+
+void KernelMessages::processText(int msgIndex) {
+	Scene &scene = _vm->_game->_scene;
+	KernelMessage &msg = _entries[msgIndex];
+	uint32 currentTimer = _vm->_game->_currentTimer;
+	bool flag = false;
+
+	if ((msg._flags & KMSG_EXPIRE) != 0) {
+		scene._textDisplay.expire(msg._textDisplayIndex);
+		msg._flags &= !KMSG_ACTIVE;
+		return;
+	}
+
+	if ((msg._flags & KMSG_SCROLL) == 0) {
+		msg._timeout -= 3;
+	}
+
+	if (msg._flags & KMSG_SEQ_ENTRY) {
+		SequenceEntry &seqEntry = scene._sequences[msg._sequenceIndex];
+		if (seqEntry._doneFlag || !seqEntry._active)
+			msg._timeout = 0;
+	}
+
+	if ((msg._timeout <= 0) && (_vm->_game->_abortTimers == 0)) {
+		msg._flags |= KMSG_EXPIRE;
+		if (msg._abortTimers != 0) {
+			_vm->_game->_abortTimers = msg._abortTimers;
+			_vm->_game->_abortTimersMode = msg._abortMode;
+
+			if (_vm->_game->_abortTimersMode != ABORTMODE_1) {
+				scene._action._activeAction = msg._actionDetails;
+			}
+		}
+	}
+
+	msg._frameTimer = currentTimer + 3;
+	int x1 = 0, y1 = 0;
+
+	if (msg._flags & KMSG_SEQ_ENTRY) {
+		SequenceEntry &seqEntry = scene._sequences[msg._sequenceIndex];
+		if (!seqEntry._nonFixed) {
+			SpriteAsset &spriteSet = scene._spriteSlots.getSprite(seqEntry._spritesIndex);
+			MSprite *frame = spriteSet.getFrame(seqEntry._frameIndex - 1);
+			x1 = frame->getBounds().left;
+			y1 = frame->getBounds().top;
+		} else {
+			x1 = seqEntry._msgPos.x;
+			y1 = seqEntry._msgPos.y;
+		}
+	}
+
+	if (msg._flags & KMSG_PLAYER_TIMEOUT) {
+		if (word_8469E != 0) {
+			warning("TODO: KernelMessages::processText");
+			// TODO: Figure out various flags
+		} else {
+			x1 = 160;
+			y1 = 78;
+		}
+	}
+
+	x1 += msg._position.x;
+	y1 += msg._position.y;
+
+	if ((msg._flags & KMSG_SCROLL) && (msg._frameTimer >= currentTimer)) {
+		msg._msg.setChar(msg._asciiChar, msg._msgOffset);
+
+		++msg._msgOffset;
+		msg._msg.setChar(msg._asciiChar2, msg._msgOffset);
+		msg._asciiChar = msg._msg[msg._msgOffset];
+		msg._asciiChar2 = msg._msg[msg._msgOffset + 1];
+
+		if (!msg._asciiChar) {
+			// End of message
+			msg._msg.setChar('\0', msg._msgOffset);
+			msg._flags &= ~KMSG_SCROLL;
+		} else if (msg._flags & KMSG_QUOTED) {
+			msg._msg.setChar('"', msg._msgOffset);
+			msg._msg.setChar('\0', msg._msgOffset + 1);
+		}
+
+		msg._frameTimer = msg._frameTimer2 = currentTimer + msg._numTicks;
+		flag = true;
+	}
+
+	int strWidth = _talkFont->getWidth(msg._msg, scene._textSpacing);
+
+	if (msg._flags & (KMSG_RIGHT_ALIGN | KMSG_CENTER_ALIGN)) {
+		x1 -= (msg._flags & KMSG_CENTER_ALIGN) ? strWidth / 2 : strWidth;
+	}
+
+	// Make sure text appears entirely on-screen
+	int x2 = x1 + strWidth;
+	if (x2 > MADS_SCREEN_WIDTH)
+		x1 -= x2 - MADS_SCREEN_WIDTH;
+	if (x1 > (MADS_SCREEN_WIDTH - 1))
+		x1 = MADS_SCREEN_WIDTH - 1;
+	if (x1 < 0)
+		x1 = 0;
+
+	if (y1 >(MADS_SCENE_HEIGHT - 1))
+		y1 = MADS_SCENE_HEIGHT - 1;
+	if (y1 < 0)
+		y1 = 0;
+
+	if (msg._textDisplayIndex >= 0) {
+		TextDisplay &textEntry = scene._textDisplay[msg._textDisplayIndex];
+
+		if (flag || (textEntry._bounds.left != x1) || (textEntry._bounds.top != y1)) {
+			// Mark the associated text entry as deleted, so it can be re-created
+			scene._textDisplay.expire(msg._textDisplayIndex);
+			msg._textDisplayIndex = -1;
+		}
+	}
+
+	if (msg._textDisplayIndex < 0) {
+		// Need to create a new text display entry for this message
+		int idx = scene._textDisplay.add(x1, y1, msg._color1 | (msg._color2 << 8), 
+			scene._textSpacing, msg._msg, _talkFont);
+		if (idx >= 0)
+			msg._textDisplayIndex = idx;
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+TextDisplay::TextDisplay() {
+	_active = false;
+	_expire = 0;
+	_spacing = 0;
+	_color1 = 0;
+	_color2 = 0;
+	_font = nullptr;
+}
+
+/*------------------------------------------------------------------------*/
+
+TextDisplayList::TextDisplayList(MADSEngine *vm) : _vm(vm) {
+	for (int i = 0; i < TEXT_DISPLAY_SIZE; ++i) {
+		TextDisplay rec;
+		rec._active = false;
+		rec._expire = 0;
+		_entries.push_back(rec);
+	}
+}
+
+void TextDisplayList::clear() {
+	for (int i = 0; i < TEXT_DISPLAY_SIZE; ++i)
+		_entries[i]._active = false;
+}
+
+int TextDisplayList::add(int xp, int yp, uint fontColor, int charSpacing, 
+		const Common::String &msg, Font *font) {
+	int usedSlot = -1;
+
+	for (int idx = 0; idx < TEXT_DISPLAY_SIZE; ++idx) {
+		if (!_entries[idx]._active) {
+			usedSlot = idx;
+
+			_entries[idx]._bounds.left = xp;
+			_entries[idx]._bounds.top = yp;
+			_entries[idx]._font = font;
+			_entries[idx]._msg = msg;
+			_entries[idx]._bounds.setWidth(font->getWidth(msg, charSpacing));
+			_entries[idx]._bounds.setHeight(font->getHeight());
+			_entries[idx]._color1 = fontColor & 0xff;
+			_entries[idx]._color2 = fontColor >> 8;
+			_entries[idx]._spacing = charSpacing;
+			_entries[idx]._expire = 1;
+			_entries[idx]._active = true;
+			break;
+		}
+	}
+
+	return usedSlot;
+}
+
+void TextDisplayList::setDirtyAreas() {
+	Scene &scene = _vm->_game->_scene;
+
+	for (uint idx = 0, dirtyIdx = DIRTY_AREAS_TEXT_DISPLAY_IDX; dirtyIdx < DIRTY_AREAS_SIZE; ++idx, ++dirtyIdx) {
+		if ((_entries[idx]._expire >= 0) || !_entries[idx]._active)
+			scene._dirtyAreas[dirtyIdx]._active = false;
+		else {
+			scene._dirtyAreas[dirtyIdx]._textActive = true;
+			scene._dirtyAreas.setTextDisplay(dirtyIdx, _entries[idx]);
+		}
+	}
+}
+
+void TextDisplayList::setDirtyAreas2() {
+	Scene &scene = _vm->_game->_scene;
+
+	for (uint idx = 0, dirtyIdx = DIRTY_AREAS_TEXT_DISPLAY_IDX; dirtyIdx < DIRTY_AREAS_SIZE; ++idx, ++dirtyIdx) {
+		if (_entries[idx]._active && (_entries[idx]._expire >= 0)) {
+			scene._dirtyAreas.setTextDisplay(dirtyIdx, _entries[idx]);
+			scene._dirtyAreas[dirtyIdx]._textActive = (_entries[idx]._expire <= 0) ? 0 : 1;
+		}
+	}
+}
+
+void TextDisplayList::draw(MSurface *view) {
+	error("TODO");
+	/*
+	for (uint idx = 0; idx < _entries.size(); ++idx) {
+		if (_entries[idx]._active && (_entries[idx]._expire >= 0)) {
+			_entries[idx]._font->setColors(_entries[idx]._color1, _entries[idx]._color2, 0);
+			_entries[idx]._font->writeString(view, _entries[idx]._msg,
+				Common::Point(_entries[idx]._bounds.left, _entries[idx]._bounds.top), 
+				_entries[idx]._bounds.width(), _entries[idx]._spacing);
+		}
+	}
+	*/
+}
+
+void TextDisplayList::cleanUp() {
+	for (uint idx = 0; idx < _entries.size(); ++idx) {
+		if (_entries[idx]._expire < 0) {
+			_entries[idx]._active = false;
+			_entries[idx]._expire = 0;
+		}
+	}
+}
+
+void TextDisplayList::expire(int idx) {
+	_entries[idx]._expire = -1;
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/messages.h b/engines/mads/messages.h
new file mode 100644
index 0000000..b60ca8c
--- /dev/null
+++ b/engines/mads/messages.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_MESSAGES_H
+#define MADS_MESSAGES_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+#include "mads/action.h"
+#include "mads/font.h"
+#include "mads/msurface.h"
+
+namespace MADS {
+
+#define KERNEL_MESSAGES_SIZE 10
+#define INDEFINITE_TIMEOUT 9999999
+#define TEXT_DISPLAY_SIZE 40
+
+enum KernelMessageFlags {
+	KMSG_QUOTED = 1, KMSG_PLAYER_TIMEOUT = 2, KMSG_SEQ_ENTRY = 4, KMSG_SCROLL = 8, 
+	KMSG_RIGHT_ALIGN = 0x10, KMSG_CENTER_ALIGN = 0x20, KMSG_EXPIRE = 0x40, 
+	KMSG_ACTIVE = 0x80
+};
+
+class MADSEngine;
+
+class KernelMessage {
+public:
+	uint8 _flags;
+	int _sequenceIndex;
+	char _asciiChar;
+	char _asciiChar2;
+	int _color1;
+	int _color2;
+	Common::Point _position;
+	int _textDisplayIndex;
+	int _msgOffset;
+	int _numTicks;
+	uint32 _frameTimer2;
+	uint32 _frameTimer;
+	uint32 _timeout;
+	int _abortTimers;
+	AbortTimerMode _abortMode;
+	ActionDetails _actionDetails;
+	Common::String _msg;
+
+	KernelMessage();
+};
+
+class KernelMessages {
+private:
+	MADSEngine *_vm;
+	Common::Array<KernelMessage> _entries;
+	Font *_talkFont;
+public:
+	int word_8469E;
+public:
+	KernelMessages(MADSEngine *vm);
+
+	void clear();
+	int add(const Common::Point &pt, uint fontColor, uint8 flags, uint8 abortTimers, 
+		uint32 timeout, const Common::String &msg);
+	int addQuote(int quoteId, int abortTimers, uint32 timeout);
+	void scrollMessage(int msgIndex, int numTicks, bool quoted);
+	void setSeqIndex(int msgIndex, int seqIndex);
+	void remove(int msgIndex);
+	void reset();
+	void update();
+	void processText(int msgIndex);
+};
+
+class TextDisplay {
+public:
+	bool _active;
+	int _expire;
+	int _spacing;
+	Common::Rect _bounds;
+	uint8 _color1;
+	uint8 _color2;
+	Font *_font;
+	Common::String _msg;
+
+	TextDisplay();
+};
+
+#define TEXT_DISPLAY_SIZE 40
+
+class TextDisplayList {
+private:
+	MADSEngine *_vm;
+	Common::Array<TextDisplay> _entries;
+
+	/**
+	* Determine dirty areas for active text areas
+	*/
+	void setDirtyAreas2();
+public:
+	TextDisplayList(MADSEngine *vm);
+
+	/**
+	 * Item operator
+	 */
+	TextDisplay &operator[](int idx) {
+		return _entries[idx];
+	}
+
+	/**
+	 * Expire a given text display entry
+	 */
+	void expire(int idx);
+
+	int add(int xp, int yp, uint fontColor, int charSpacing, const Common::String &, Font *font);
+	void clear();
+	void draw(MSurface *view);
+	
+	/**
+	 * Determine dirty areas for active text areas
+	 */
+	void setDirtyAreas();
+
+	/**
+	* Deactivates any text display entries that are finished
+	*/
+	void cleanUp();
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_MESSAGES_H */
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 826e54f..36d0c49 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -19,6 +19,7 @@ MODULE_OBJS := \
 	game_data.o \
 	graphics.o \
 	mads.o \
+	messages.o \
 	msprite.o \
 	msurface.o \
 	palette.o \
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 6efbdf5..a0888f7 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -29,8 +29,8 @@
 namespace MADS {
 
 Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm),
-		_dynamicHotspots(vm), _screenObjects(vm), _interface(vm),
-		_sequences(vm) {
+		_dirtyAreas(_vm), _dynamicHotspots(vm), _interface(vm), _messages(vm), 
+		_screenObjects(vm), _sequences(vm), _textDisplay(vm) {
 	_priorSceneId = 0;
 	_nextSceneId = 0;
 	_currentSceneId = 0;
@@ -45,6 +45,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm),
 	_reloadSceneFlag = false;
 	_destFacing = 0;
 	_freeAnimationFlag = false;
+	_animation = nullptr;
+	_activeAnimation = nullptr;
 
 	_verbList.push_back(VerbInit(VERB_LOOK, 2, 0));
 	_verbList.push_back(VerbInit(VERB_TAKE, 2, 0));
@@ -356,9 +358,21 @@ void Scene::doFrame() {
 				_vm->_events->setCursor(cursorId);
 			}
 
-			if (!_vm->_game->_abortTimers)
+			if (!_vm->_game->_abortTimers) {
+				// Handle any active sequences
 				_sequences.tick();
 
+				// Handle any active animation
+				if (_activeAnimation)
+					_activeAnimation->update();
+			}
+
+			// If the debugget flag is set, show the mouse position
+			if (_vm->_debugger->_showMousePos) {
+				Common::Point pt = _vm->_events->mousePos();
+				Common::String msg = Common::String::format("(%d,%d)", pt.x, pt.y);
+				_messages.add(Common::Point(5, 5), 0x203, 0, 0, 1, msg);
+			}
 
 			// TODO: Rest of Scene::doFrame
 		}
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 71bfe31..f6eecbf 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -27,6 +27,7 @@
 #include "common/array.h"
 #include "common/rect.h"
 #include "mads/assets.h"
+#include "mads/messages.h"
 #include "mads/msurface.h"
 #include "mads/scene_data.h"
 #include "mads/animation.h"
@@ -78,7 +79,7 @@ public:
 	int _nextSceneId;
 	int _currentSceneId;
 	Common::Array<VerbInit> _verbList;
-	Common::Array<TextDisplay> _textDisplay;
+	TextDisplayList _textDisplay;
 	SpriteSlots _spriteSlots;
 	SpriteSets _sprites;
 	int _spritesIndex;
@@ -86,11 +87,12 @@ public:
 	byte *_vocabBuffer;
 	Common::Array<int> _activeVocabs;
 	SequenceList _sequences;
-	Common::Array<KernelMessage> _messages;
+	KernelMessages _messages;
 	Common::String _talkFont;
 	int _textSpacing;
 	Common::Array<Hotspot> _hotspots;
 	ScreenObjects _screenObjects;
+	DirtyAreas _dirtyAreas;
 	int _v1;
 	SceneInfo *_sceneInfo;
 	MSurface _backgroundSurface;
@@ -104,6 +106,7 @@ public:
 	SceneNodeList _nodes;
 	Common::StringArray _vocabStrings;
 	Animation *_animation;
+	Animation *_activeAnimation;
 	bool _freeAnimationFlag;
 	int _depthStyle;
 	int _bandsRange;
@@ -118,6 +121,7 @@ public:
 	bool _reloadSceneFlag;
 	Common::Point _destPos;
 	int _destFacing;
+	Common::Point _posAdjust;
 
 	/**
 	 * Constructor
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 6fa2f5b..985b961 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -202,11 +202,152 @@ int SpriteSets::add(SpriteAsset *asset, int idx) {
 
 /*------------------------------------------------------------------------*/
 
-TextDisplay::TextDisplay() {
-	_active = false;
-	_spacing = 0;
-	_expire = 0;
-	_col1 = _col2 = 0;
+void DirtyArea::setArea(int width, int height, int maxWidth, int maxHeight) {
+	if (_bounds.left % 2) {
+		--_bounds.left;
+		++width;
+	}
+
+	if (_bounds.left < 0)
+		_bounds.left = 0;
+	else if (_bounds.left > maxWidth)
+		_bounds.left = maxWidth;
+	int right = _bounds.left + width;
+	if (right < 0)
+		right = 0;
+	if (right > maxWidth)
+		right = maxWidth;
+
+	_bounds.right = right;
+	_bounds2.left = _bounds.width() / 2;
+	_bounds2.right = _bounds.left + (_bounds.width() + 1) / 2 - 1;
+
+	if (_bounds.top < 0)
+		_bounds.top = 0;
+	else if (_bounds.top > maxHeight)
+		_bounds.top = maxHeight;
+	int bottom = _bounds.top + height;
+	if (bottom < 0)
+		bottom = 0;
+	if (bottom > maxHeight)
+		bottom = maxHeight;
+
+	_bounds.bottom = bottom;
+	_bounds2.top = _bounds.height() / 2;
+	_bounds2.bottom = _bounds.top + (_bounds.height() + 1) / 2 - 1;
+
+	_active = true;
+}
+
+/*------------------------------------------------------------------------*/
+
+DirtyAreas::DirtyAreas(MADSEngine *vm) : _vm(vm) {
+	for (int i = 0; i < DIRTY_AREAS_SIZE; ++i) {
+		DirtyArea rec;
+		rec._active = false;
+		_entries.push_back(rec);
+	}
+}
+
+void DirtyAreas::setSpriteSlot(int dirtyIdx, const SpriteSlot &spriteSlot) {
+	int width, height;
+	DirtyArea &dirtyArea = _entries[dirtyIdx];
+	Scene &scene = _vm->_game->_scene;
+
+	if (spriteSlot._spriteType == ST_FULL_SCREEN_REFRESH) {
+		// Special entry to refresh the entire screen
+		dirtyArea._bounds.left = 0;
+		dirtyArea._bounds.top = 0;
+		width = MADS_SCREEN_WIDTH;
+		height = MADS_SCENE_HEIGHT;
+	} else {
+		// Standard sprite slots
+		dirtyArea._bounds.left = spriteSlot._position.x - scene._posAdjust.x;
+		dirtyArea._bounds.top = spriteSlot._position.y - scene._posAdjust.y;
+
+		SpriteAsset &spriteSet = scene._spriteSlots.getSprite(spriteSlot._spritesIndex);
+		MSprite *frame = spriteSet.getFrame(((spriteSlot._frameNumber & 0x7fff) - 1) & 0x7f);
+
+		if (spriteSlot._scale == -1) {
+			width = frame->getWidth();
+			height = frame->getHeight();
+		} else {
+			width = frame->getWidth() * spriteSlot._scale / 100;
+			height = frame->getHeight() * spriteSlot._scale / 100;
+
+			dirtyArea._bounds.left -= width / 2;
+			dirtyArea._bounds.top += -(height - 1);
+		}
+	}
+
+	dirtyArea.setArea(width, height, MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT);
+}
+
+void DirtyAreas::setTextDisplay(int dirtyIdx, const TextDisplay &textDisplay) {
+	DirtyArea &dirtyArea = _entries[dirtyIdx];
+	dirtyArea._bounds.left = textDisplay._bounds.left;
+	dirtyArea._bounds.top = textDisplay._bounds.top;
+
+	dirtyArea.setArea(textDisplay._bounds.width(), textDisplay._bounds.height(), 
+		MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT);
+}
+
+void DirtyAreas::merge(int startIndex, int count) {
+	error("TODO: DirtyAreas::merge");
+	if (startIndex >= count)
+		return;
+
+	for (int outerCtr = startIndex - 1, idx = 0; idx < count; ++outerCtr, ++idx) {
+		if (!_entries[outerCtr]._active)
+			continue;
+
+		for (int innerCtr = outerCtr + 1; innerCtr < count; ++innerCtr) {
+			if (!_entries[innerCtr]._active || !intersects(outerCtr, innerCtr))
+				continue;
+
+			if (_entries[outerCtr]._textActive && _entries[innerCtr]._textActive)
+				mergeAreas(outerCtr, innerCtr);
+		}
+	}
+}
+
+/**
+* Returns true if two dirty areas intersect
+*/
+bool DirtyAreas::intersects(int idx1, int idx2) {
+	return _entries[idx1]._bounds2.intersects(_entries[idx2]._bounds2);
+}
+
+void DirtyAreas::mergeAreas(int idx1, int idx2) {
+	DirtyArea &da1 = _entries[idx1];
+	DirtyArea &da2 = _entries[idx2];
+
+	da1._bounds.extend(da2._bounds);
+
+	da1._bounds2.left = da1._bounds.width() / 2;
+	da1._bounds2.right = da1._bounds.left + (da1._bounds.width() + 1) / 2 - 1;
+	da1._bounds2.top = da1._bounds.height() / 2;
+	da1._bounds2.bottom = da1._bounds.top + (da1._bounds.height() + 1) / 2 - 1;
+
+	da2._active = false;
+	da1._textActive = true;
+}
+
+void DirtyAreas::copy(MSurface *dest, MSurface *src, const Common::Point &posAdjust) {
+	for (uint i = 0; i < _entries.size(); ++i) {
+		const Common::Rect &srcBounds = _entries[i]._bounds;
+
+		Common::Rect bounds(srcBounds.left + posAdjust.x, srcBounds.top + posAdjust.y,
+			srcBounds.right + posAdjust.x, srcBounds.bottom + posAdjust.y);
+
+		if (_entries[i]._active && _entries[i]._bounds.isValidRect())
+			src->copyTo(dest, bounds, Common::Point(_entries[i]._bounds.left, _entries[i]._bounds.top));
+	}
+}
+
+void DirtyAreas::clear() {
+	for (uint i = 0; i < _entries.size(); ++i)
+		_entries[i]._active = false;
 }
 
 /*------------------------------------------------------------------------*/
@@ -315,18 +456,21 @@ void DynamicHotspots::refresh() {
 
 KernelMessage::KernelMessage() {
 	_flags = 0;
-	_seqInex = 0;
+	_sequenceIndex = 0;
 	_asciiChar = '\0';
 	_asciiChar2 = '\0';
-	_colors = 0;
+	_color1 = 0;
+	_color2 = 0;
 	_msgOffset = 0;
 	_numTicks = 0;
 	_frameTimer2 = 0;
 	_frameTimer = 0;
 	_timeout = 0;
-	_field1C = 0;
-	_abortMode = 0;
-	_nounList[0] = _nounList[1] = _nounList[2] = 0;
+	_abortTimers = 0;
+	_abortMode = ABORTMODE_0;
+	_actionDetails._verbId = 0;
+	_actionDetails._objectNameId = 0;
+	_actionDetails._indirectObjectId = 0;
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index dc59bff..f26069c 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -32,6 +32,7 @@
 #include "mads/assets.h"
 #include "mads/events.h"
 #include "mads/game_data.h"
+#include "mads/messages.h"
 
 namespace MADS {
 
@@ -44,6 +45,9 @@ class Scene;
 #define DEPTH_BANDS_SIZE 15
 #define MAX_ROUTE_NODES 22
 
+#define DIRTY_AREAS_SIZE 90
+#define DIRTY_AREAS_TEXT_DISPLAY_IDX 50
+
 enum ScrCategory {
 	CAT_NONE = 0, CAT_ACTION = 1, CAT_INV_LIST = 2, CAT_INV_VOCAB = 3,
 	CAT_HOTSPOT = 4, CAT_INV_ANIM = 5, CAT_6 = 6, CAT_INV_SCROLLER = 7,
@@ -175,20 +179,6 @@ public:
 	int add(SpriteAsset *asset, int idx = 0);
 };
 
-class TextDisplay {
-public:
-	bool _active;
-	int _spacing;
-	Common::Rect _bounds;
-	int _expire;
-	int _col1;
-	int _col2;
-	Common::String _fontName;
-	Common::String _msg;
-
-	TextDisplay();
-};
-
 class DynamicHotspot {
 public:
 	bool _active;
@@ -226,27 +216,6 @@ public:
 	void refresh();
 };
 
-class KernelMessage {
-public:
-	int _flags;
-	int _seqInex;
-	char _asciiChar;
-	char _asciiChar2;
-	int _colors;
-	Common::Point _posiition;
-	int _msgOffset;
-	int _numTicks;
-	int _frameTimer2;
-	int _frameTimer;
-	int _timeout;
-	int _field1C;
-	int _abortMode;
-	int _nounList[3];
-	Common::String _msg;
-
-	KernelMessage();
-};
-
 class Hotspot {
 public:
 	Common::Rect _bounds;
@@ -261,6 +230,46 @@ public:
 	Hotspot(Common::SeekableReadStream &f);
 };
 
+class DirtyArea {
+public:
+	Common::Rect _bounds;
+	Common::Rect _bounds2;
+	bool _textActive;
+	bool _active;
+
+	DirtyArea() { _active = false; }
+	void setArea(int width, int height, int maxWidth, int maxHeight);
+};
+
+class DirtyAreas {
+private:
+	MADSEngine *_vm;
+	Common::Array<DirtyArea> _entries;
+public:
+	DirtyAreas(MADSEngine *vm);
+
+	DirtyArea &operator[](uint idx) {
+		assert(idx < _entries.size());
+		return _entries[idx];
+	}
+
+	void setSpriteSlot(int dirtyIdx, const SpriteSlot &spriteSlot);
+
+	void setTextDisplay(int dirtyIdx, const TextDisplay &textDisplay);
+
+	/**
+	* Merge together any designated dirty areas that overlap
+	* @param startIndex	1-based starting dirty area starting index
+	* @param count			Number of entries to process
+	*/
+	void merge(int startIndex, int count);
+
+	bool intersects(int idx1, int idx2);
+	void mergeAreas(int idx1, int idx2);
+	void copy(MSurface *dest, MSurface *src, const Common::Point &posAdjust);
+	void clear();
+};
+
 class SceneLogic {
 protected:
 	Scene *_scene;


Commit: f6888eef1069ac5df07c3f4dcc3a30755bc4ebb0
    https://github.com/scummvm/scummvm/commit/f6888eef1069ac5df07c3f4dcc3a30755bc4ebb0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-04T09:33:57-05:00

Commit Message:
MADS: Implementation of timer functionality for Scene::doFrame

Changed paths:
    engines/mads/animation.cpp
    engines/mads/animation.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/messages.cpp
    engines/mads/messages.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h
    engines/mads/sequence.cpp
    engines/mads/sequence.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 0546fc3..941533f 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -179,7 +179,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 	for (int i = 0; i < aaHeader._spriteSetsCount; ++i)
 		_spriteListIndexes.push_back(-1);
 
-	_messages.clear();
+	_kernelMessages.clear();
 	if (aaHeader._messagesCount > 0) {
 		// Chunk 2: Following is a list of any messages for the animation
 		Common::SeekableReadStream *msgStream = madsPack.getItemStream(1);
@@ -187,7 +187,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 		for (int i = 0; i < aaHeader._messagesCount; ++i) {
 			AnimMessage rec;
 			rec.load(msgStream);
-			_messages.push_back(rec);
+			_kernelMessages.push_back(rec);
 		}
 
 		delete msgStream;
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 1f0e1fd..484856f 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -119,7 +119,7 @@ public:
 	static Animation *init(MADSEngine *vm, Scene *scene);
 public:
 	Common::Array<int> _spriteListIndexes;
-	Common::Array<AnimMessage> _messages;
+	Common::Array<AnimMessage> _kernelMessages;
 	Common::Array<AnimFrameEntry> _frameEntries;
 	Common::Array<AnimMiscEntry> _miscEntries;
 	Common::Array<SpriteAsset *> _spriteSets;
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 479c48c..025cf8d 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -54,7 +54,7 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 	_v5 = _v6 = 0;
 	_aaName = "*I0.AA";
 	_playerSpritesFlag = false;
-	_currentTimer = 0;
+	_priorFrameTimer = 0;
 	_updateSceneFlag = false;
 	_abortTimersMode = ABORTMODE_0;
 	_abortTimersMode2 = ABORTMODE_0;
@@ -199,7 +199,7 @@ void Game::sectionLoop() {
 		}
 		_abortTimers = 0;
 		_abortTimersMode2 = ABORTMODE_1;
-		_currentTimer = _vm->_events->_currentTimer;
+		_priorFrameTimer = _vm->_events->_currentTimer;
 
 		// Call the scene logic for entering the given scene
 		_scene._sceneLogic->enter();
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 47eed34..5330cd3 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -116,7 +116,7 @@ public:
 	int _abortTimers2;
 	AbortTimerMode _abortTimersMode;
 	AbortTimerMode _abortTimersMode2;
-	uint32 _currentTimer;
+	uint32 _priorFrameTimer;
 public:
 	virtual ~Game();
 
diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index c08f29f..cc618c4 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -75,7 +75,7 @@ int KernelMessages::add(const Common::Point &pt, uint fontColor, uint8 flags,
 	rec._position = pt;
 	rec._textDisplayIndex = -1;
 	rec._timeout = timeout;
-	rec._frameTimer = _vm->_game->_currentTimer;
+	rec._frameTimer = _vm->_game->_priorFrameTimer;
 	rec._abortTimers = abortTimers;
 	rec._abortMode = _vm->_game->_abortTimersMode2;
 
@@ -100,7 +100,7 @@ void KernelMessages::scrollMessage(int msgIndex, int numTicks, bool quoted) {
 	_entries[msgIndex]._flags |= quoted ? (KMSG_SCROLL | KMSG_QUOTED) : KMSG_SCROLL;
 	_entries[msgIndex]._msgOffset = 0;
 	_entries[msgIndex]._numTicks = numTicks;
-	_entries[msgIndex]._frameTimer2 = _vm->_game->_currentTimer;
+	_entries[msgIndex]._frameTimer2 = _vm->_game->_priorFrameTimer;
 
 	Common::String msg = _entries[msgIndex]._msg;
 	_entries[msgIndex]._asciiChar = msg[0];
@@ -145,7 +145,7 @@ void KernelMessages::reset() {
 }
 
 void KernelMessages::update() {
-	uint32 currentTimer = _vm->_game->_currentTimer;
+	uint32 currentTimer = _vm->_game->_priorFrameTimer;
 
 	for (uint i = 0; i < _entries.size(); ++i) {
 		if (((_entries[i]._flags & KMSG_ACTIVE) != 0) && 
@@ -157,7 +157,7 @@ void KernelMessages::update() {
 void KernelMessages::processText(int msgIndex) {
 	Scene &scene = _vm->_game->_scene;
 	KernelMessage &msg = _entries[msgIndex];
-	uint32 currentTimer = _vm->_game->_currentTimer;
+	uint32 currentTimer = _vm->_game->_priorFrameTimer;
 	bool flag = false;
 
 	if ((msg._flags & KMSG_EXPIRE) != 0) {
@@ -277,6 +277,12 @@ void KernelMessages::processText(int msgIndex) {
 	}
 }
 
+void KernelMessages::delay(uint32 priorFrameTime, uint32 currentTime) {
+	for (uint i = 0; i < _entries.size(); ++i) {
+		_entries[i]._timeout += currentTime - priorFrameTime;
+	}
+}
+
 /*------------------------------------------------------------------------*/
 
 TextDisplay::TextDisplay() {
diff --git a/engines/mads/messages.h b/engines/mads/messages.h
index b60ca8c..6967755 100644
--- a/engines/mads/messages.h
+++ b/engines/mads/messages.h
@@ -86,6 +86,7 @@ public:
 	void reset();
 	void update();
 	void processText(int msgIndex);
+	void delay(uint32 priorFrameTime, uint32 currentTime);
 };
 
 class TextDisplay {
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index a0888f7..4d62e64 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -29,7 +29,7 @@
 namespace MADS {
 
 Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm),
-		_dirtyAreas(_vm), _dynamicHotspots(vm), _interface(vm), _messages(vm), 
+		_dirtyAreas(_vm), _dynamicHotspots(vm), _interface(vm), _kernelMessages(vm), 
 		_screenObjects(vm), _sequences(vm), _textDisplay(vm) {
 	_priorSceneId = 0;
 	_nextSceneId = 0;
@@ -97,7 +97,7 @@ void Scene::clearSequenceList() {
 }
 
 void Scene::clearMessageList() {
-	_messages.clear();
+	_kernelMessages.clear();
 	_talkFont = "*FONTCONV.FF";
 	_textSpacing  = -1;
 }
@@ -125,7 +125,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 
 	_spriteSlots.clear(false);
 	_sequences.clear();
-	_messages.clear();
+	_kernelMessages.clear();
 
 	// TODO: palletteUsage reset?  setPalette(_nullPalette);
 	_sceneInfo = SceneInfo::init(_vm);
@@ -371,14 +371,45 @@ void Scene::doFrame() {
 			if (_vm->_debugger->_showMousePos) {
 				Common::Point pt = _vm->_events->mousePos();
 				Common::String msg = Common::String::format("(%d,%d)", pt.x, pt.y);
-				_messages.add(Common::Point(5, 5), 0x203, 0, 0, 1, msg);
+				_kernelMessages.add(Common::Point(5, 5), 0x203, 0, 0, 1, msg);
 			}
 
+			if (!_vm->_game->_abortTimers) {
+				if (_reloadSceneFlag || _currentSceneId != _nextSceneId)
+					_kernelMessages.reset();
+				_kernelMessages.update();
+			}
+
+			_vm->_game->_abortTimers2 = !_vm->_game->_abortTimers2;
+
+			warning("TODO: image_inter_list_call");
+
+			// Write any text needed by the interface
+			if (_vm->_game->_abortTimers2)
+				_interface.writeText();
+
+			// Draw any elements
+			drawElements(_vm->_game->_abortTimers2, _vm->_game->_abortTimers2);
+
+			// Handle message updates
+			if (_vm->_game->_abortTimers2) {
+				uint32 priorTime = _vm->_game->_priorFrameTimer;
+				uint32 newTime = _vm->_events->getFrameCounter();
+				_sequences.delay(newTime, priorTime);
+				_kernelMessages.delay(newTime, priorTime);
+			}
+
+			warning("TODO: sub_1DA5A");
+
 			// TODO: Rest of Scene::doFrame
 		}
 	}
 }
 
+void Scene::drawElements(bool transitionFlag, bool surfaceFlag) {
+
+}
+
 void Scene::leftClick() {
 	warning("TODO: Scene::leftClick");
 }
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index f6eecbf..483ecae 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -87,7 +87,7 @@ public:
 	byte *_vocabBuffer;
 	Common::Array<int> _activeVocabs;
 	SequenceList _sequences;
-	KernelMessages _messages;
+	KernelMessages _kernelMessages;
 	Common::String _talkFont;
 	int _textSpacing;
 	Common::Array<Hotspot> _hotspots;
@@ -184,6 +184,11 @@ public:
 	void loop();
 
 	/**
+	 * Draw all the elements onto the scene
+	 */
+	void drawElements(bool transitionFlag, bool surfaceFlag);
+
+	/**
 	 * Execute a click within the scene
 	 */
 	void leftClick();
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 985b961..5f60a1e 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -547,6 +547,10 @@ void InterfaceSurface::elementHighlighted() {
 	warning("TODO: InterfaceSurface::elementHighlighted");
 }
 
+void InterfaceSurface::writeText() {
+	warning("TODO: InterfaceSurface::writeText");
+}
+
 /*------------------------------------------------------------------------*/
 
 void SceneInfo::SpriteInfo::load(Common::SeekableReadStream *f) {
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index f26069c..b18eaff 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -360,6 +360,8 @@ public:
 	void load(const Common::String &resName);
 
 	void elementHighlighted();
+
+	void writeText();
 };
 
 /**
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 7c7b25d..8f25007 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -307,10 +307,10 @@ void SequenceList::tick() {
 	}
 }
 
-void SequenceList::delay(uint32 v1, uint32 v2) {
+void SequenceList::delay(uint32 priorFrameTime, uint32 currentTime) {
 	for (uint idx = 0; idx < _entries.size(); ++idx) {
 		if (_entries[idx]._active) {
-			_entries[idx]._timeout += v1 - v2;
+			_entries[idx]._timeout += currentTime - priorFrameTime;
 		}
 	}
 }
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index 1b9aefe..f73d48b 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -98,7 +98,7 @@ public:
 	void setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot);
 	bool loadSprites(int seqIndex);
 	void tick();
-	void delay(uint32 v1, uint32 v2);
+	void delay(uint32 priorFrameTime, uint32 currentTime);
 	void setAnimRange(int seqIndex, int startVal, int endVal);
 	void scan();
 	void setDepth(int seqIndex, int depth);


Commit: 1607a9104700e987cacfec41aaafd25d979aeb98
    https://github.com/scummvm/scummvm/commit/1607a9104700e987cacfec41aaafd25d979aeb98
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-04T20:06:48-05:00

Commit Message:
MADS: Finished remainder of Scene::doFrame

Changed paths:
    engines/mads/animation.cpp
    engines/mads/animation.h
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/player.cpp
    engines/mads/player.h
    engines/mads/scene.cpp
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 941533f..c97d707 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -139,6 +139,7 @@ Animation *Animation::init(MADSEngine *vm, Scene *scene) {
 
 Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) {
 	_font = nullptr;
+	_resetFlag = false;
 }
 
 Animation::~Animation() {
@@ -147,6 +148,31 @@ Animation::~Animation() {
 		delete _spriteSets[i];
 }
 
+void Animation::free() {
+	Scene &scene = _vm->_game->_scene;
+	Player &player = _vm->_game->_player;
+
+	if (!scene._freeAnimationFlag) {
+		scene._spriteSlots.fullRefresh(true);
+		scene._sequences.scan();
+	}
+
+	// Refresh the player
+	if (player._visible) {
+		player._forceRefresh = true;
+		player.update();
+	}
+
+	// Remove any kernel messages in use by the animation
+	for (uint i = 0; i < _messages.size(); ++i) {
+		int msgIndex = _messages[i]._kernelMsgIndex;
+		scene._kernelMessages.remove(msgIndex);
+	}
+
+	_resetFlag = false;
+	delete this;
+}
+
 void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 	const Common::String &resName, int flags, Common::Array<RGB4> *palAnimData,
 	SceneInfo *sceneInfo) {
@@ -179,7 +205,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 	for (int i = 0; i < aaHeader._spriteSetsCount; ++i)
 		_spriteListIndexes.push_back(-1);
 
-	_kernelMessages.clear();
+	_messages.clear();
 	if (aaHeader._messagesCount > 0) {
 		// Chunk 2: Following is a list of any messages for the animation
 		Common::SeekableReadStream *msgStream = madsPack.getItemStream(1);
@@ -187,7 +213,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 		for (int i = 0; i < aaHeader._messagesCount; ++i) {
 			AnimMessage rec;
 			rec.load(msgStream);
-			_kernelMessages.push_back(rec);
+			_messages.push_back(rec);
 		}
 
 		delete msgStream;
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 484856f..297abf4 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -119,11 +119,12 @@ public:
 	static Animation *init(MADSEngine *vm, Scene *scene);
 public:
 	Common::Array<int> _spriteListIndexes;
-	Common::Array<AnimMessage> _kernelMessages;
+	Common::Array<AnimMessage> _messages;
 	Common::Array<AnimFrameEntry> _frameEntries;
 	Common::Array<AnimMiscEntry> _miscEntries;
 	Common::Array<SpriteAsset *> _spriteSets;
 	Font *_font;
+	bool _resetFlag;
 public:
 	/*
 	 * Destructor
@@ -131,6 +132,11 @@ public:
 	~Animation();
 
 	/**
+	 * Releases scene resources used by the animation, and then deletes it
+	 */
+	void free();
+
+	/**
 	 * Loads animation data
 	 */
 	void load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, const Common::String &resName,
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 0c2e2f2..1acb081 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -35,7 +35,8 @@ namespace MADS {
 EventsManager::EventsManager(MADSEngine *vm) {
 	_vm = vm;
 	_cursorSprites = nullptr;
-	_gameCounter = 0;
+	_frameCounter = 0;
+	_frameNumber = 0;
 	_priorFrameTime = 0;
 	_keyPressed = false;
 	_mouseClicked = false;
@@ -140,7 +141,7 @@ void EventsManager::checkForNextFrameCounter() {
 	// Check for next game frame
 	uint32 milli = g_system->getMillis();
 	if ((milli - _priorFrameTime) >= GAME_FRAME_TIME) {
-		++_gameCounter;
+		++_frameCounter;
 		_priorFrameTime = milli;
 
 		// Give time to the debugger
@@ -165,6 +166,12 @@ void EventsManager::delay(int cycles) {
 	}
 }
 
+void EventsManager::waitForNextFrame() {
+	uint32 frameNum = getFrameCounter();
+	while (!_vm->shouldQuit() && !_vm->_game->_abortTimers && frameNum == _frameNumber)
+		delay(1);
+}
+
 void EventsManager::initVars() {
 	_mousePos = Common::Point(-1, -1);
 	_vD4 = _vCC;
diff --git a/engines/mads/events.h b/engines/mads/events.h
index 2782253..add8fc3 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -37,7 +37,8 @@ class MADSEngine;
 class EventsManager {
 private:
 	MADSEngine *_vm;
-	uint32 _gameCounter;
+	uint32 _frameCounter;
+	uint32 _frameNumber;
 	uint32 _priorFrameTime;
 	Common::Point _mousePos;
 	Common::Point _currentPos;
@@ -132,9 +133,14 @@ public:
 	void delay(int amount);
 
 	/**
+	 * Wait for the next frame
+	 */
+	void waitForNextFrame();
+
+	/**
 	 * Gets the current frame counter
 	 */
-	uint32 getFrameCounter() const { return _gameCounter; }
+	uint32 getFrameCounter() const { return _frameCounter; }
 
 	void initVars();
 };
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index b0f4b72..d19a0cb 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -40,6 +40,7 @@ Player::Player(MADSEngine *vm): _vm(vm) {
 	_ticksAmount = 0;
 	_priorTimer = 0;
 	_unk3 = 0;
+	_forceRefresh = false;
 }
 
 void Player::reset() {
@@ -80,6 +81,10 @@ void Player::updateFrame() {
 	warning("TODO: Player::updateFrame");
 }
 
+void Player::update() {
+	warning("TODO: Player::update");
+}
+
 void Player::resetActionList() {
 	warning("TODO: Player::resetActionList");
 }
@@ -115,8 +120,4 @@ void Player::postUpdate() {
 	warning("TODO: Player::postUpdate");
 }
 
-void Player::update() {
-	warning("TODO: Player::update");
-}
-
 } // End of namespace MADS
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 7792fb6..cff1313 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -43,8 +43,6 @@ private:
 	void move();
 
 	void postUpdate();
- 
-	void update();
 public:
 	int _direction;
 	int _newDirection;
@@ -66,6 +64,7 @@ public:
 	int _ticksAmount;
 	uint32 _priorTimer;
 	int _unk3;
+	bool _forceRefresh;
 public:
 	Player(MADSEngine *vm);
 
@@ -79,6 +78,8 @@ public:
 
 	void updateFrame();
 
+	void update();
+
 	void idle();
 
 	void setDest(const Common::Point &pt, int facing);
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 4d62e64..db252a9 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -368,10 +368,12 @@ void Scene::doFrame() {
 			}
 
 			// If the debugget flag is set, show the mouse position
+			int mouseTextIndex = 0;
 			if (_vm->_debugger->_showMousePos) {
 				Common::Point pt = _vm->_events->mousePos();
 				Common::String msg = Common::String::format("(%d,%d)", pt.x, pt.y);
-				_kernelMessages.add(Common::Point(5, 5), 0x203, 0, 0, 1, msg);
+				mouseTextIndex = _kernelMessages.add(Common::Point(5, 5), 
+					0x203, 0, 0, 1, msg);
 			}
 
 			if (!_vm->_game->_abortTimers) {
@@ -399,11 +401,26 @@ void Scene::doFrame() {
 				_kernelMessages.delay(newTime, priorTime);
 			}
 
-			warning("TODO: sub_1DA5A");
+			if (_vm->_debugger->_showMousePos)
+				// Mouse position display isn't persistent, so remove it
+				_kernelMessages.remove(mouseTextIndex);
 
-			// TODO: Rest of Scene::doFrame
+
+			warning("TODO: sub_1DA3E");
 		}
 	}
+
+	if (_vm->_game->_abortTimers2)
+		_animFlag = true;
+	_vm->_game->_abortTimers2 = 0;
+
+	if (_freeAnimationFlag) {
+		_activeAnimation->free();
+		_activeAnimation = nullptr;
+	}
+
+	// TODO: Verify correctness of frame wait
+
 }
 
 void Scene::drawElements(bool transitionFlag, bool surfaceFlag) {
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 5f60a1e..46ef2c3 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -186,6 +186,13 @@ void SpriteSlots::deleteEntry(int index) {
 	remove_at(index);
 }
 
+void SpriteSlots::fullRefresh(bool clearAll) {
+	if (clearAll)
+		Common::Array<SpriteSlot>::clear();
+
+	push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1));
+}
+
 /*------------------------------------------------------------------------*/
 
 int SpriteSets::add(SpriteAsset *asset, int idx) {
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index b18eaff..522cd17 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -158,6 +158,11 @@ public:
 	 */
 	void deleteEntry(int index);
 
+	/**
+	 * Adds a full screen refresh to the sprite slots
+	 */
+	void fullRefresh(bool clearAll = false);
+
 	SpriteAsset &getSprite(int idx) {
 		error("TODO");
 	}
@@ -168,7 +173,6 @@ public:
 		warning("TODO: SpriteSlots::indexOf");
 		return -1;
 	}
-
 };
 
 class SpriteSets: public Common::Array<SpriteAsset *> {


Commit: 568fc31b3090a70aa922479991540d4f5c2e918c
    https://github.com/scummvm/scummvm/commit/568fc31b3090a70aa922479991540d4f5c2e918c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-04T22:33:27-05:00

Commit Message:
MADS: Beginnings of code support for Scene::drawElements

Changed paths:
  A engines/mads/sprites.cpp
  A engines/mads/sprites.h
  R engines/mads/msprite.cpp
  R engines/mads/msprite.h
    engines/mads/assets.cpp
    engines/mads/assets.h
    engines/mads/dialogs.cpp
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/messages.cpp
    engines/mads/messages.h
    engines/mads/module.mk
    engines/mads/msurface.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index c968afc..ebedeb8 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -163,6 +163,15 @@ void SpriteAsset::drawScaled(int frameNumber, MSurface &depthSurface, MSurface &
 	warning("TODO: SpriteAsset::drawScaled");
 }
 
+void SpriteAsset::draw(MSurface *surface, int frameNumber, const Common::Point &pt) {
+	error("TODO: draw");
+}
+
+void SpriteAsset::depthDraw(MSurface *surface, MSurface *depthSurface, int frameNumber,
+		const Common::Point &pt, int depth) {
+	error("TODO: depthDraw");
+}
+
 /*------------------------------------------------------------------------*/
 
 SpriteSetCharInfo::SpriteSetCharInfo(Common::SeekableReadStream *s) {
diff --git a/engines/mads/assets.h b/engines/mads/assets.h
index 7a6939b..30676a1 100644
--- a/engines/mads/assets.h
+++ b/engines/mads/assets.h
@@ -25,14 +25,16 @@
 
 #include "common/scummsys.h"
 #include "common/array.h"
-#include "mads/msprite.h"
 #include "mads/palette.h"
-#include "mads/msprite.h"
 
 namespace MADS {
 
 #define SPRITE_SET_CHAR_INFO 4
 
+class MADSEngine;
+class MSprite;
+class MSurface;
+
 struct SpriteAssetFrame {
 	uint32 _stream;
 	Common::Rect _bounds;
@@ -100,6 +102,9 @@ public:
 
 	void drawScaled(int frameNumber, MSurface &depthSurface, MSurface &destSurface,
 		int scale, int depth, const Common::Point &pos);
+	void draw(MSurface *surface, int frameNumber, const Common::Point &pt);
+	void depthDraw(MSurface *surface, MSurface *depthSurface, int frameNumber, 
+		const Common::Point &pt, int depth);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index e4c7682..d159d48 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -34,7 +34,7 @@ Dialog::Dialog(MADSEngine *vm): _vm(vm), _savedSurface(nullptr),
 }
 
 Dialog::~Dialog() {
-	restore(_vm->_screen);
+	restore(&_vm->_screen);
 }
 
 
@@ -55,21 +55,21 @@ void Dialog::restore(MSurface *s) {
 
 void Dialog::draw() {
 	// Save the screen portion the dialog will overlap
-	save(_vm->_screen);
+	save(&_vm->_screen);
 
 	// Draw the dialog
 	// Fill entire content of dialog
-	_vm->_screen->fillRect(Common::Rect(_position.x, _position.y,
+	_vm->_screen.fillRect(Common::Rect(_position.x, _position.y,
 		_position.x + _width, _position.y + _height), TEXTDIALOG_BACKGROUND);
 
 	// Draw the outer edge lines
-	_vm->_screen->hLine(_position.x + 1, _position.y + _height - 2,
+	_vm->_screen.hLine(_position.x + 1, _position.y + _height - 2,
 		_position.x + _width - 2, TEXTDIALOG_EDGE);
-	_vm->_screen->hLine(_position.x, _position.y + _height - 1,
+	_vm->_screen.hLine(_position.x, _position.y + _height - 1,
 		_position.x + _width - 1, TEXTDIALOG_EDGE);
-	_vm->_screen->vLine(_position.x + _width - 2, _position.y + 2,
+	_vm->_screen.vLine(_position.x + _width - 2, _position.y + 2,
 		_position.y + _height - 2, TEXTDIALOG_EDGE);
-	_vm->_screen->vLine(_position.x + _width - 1, _position.y + 1,
+	_vm->_screen.vLine(_position.x + _width - 1, _position.y + 1,
 		_position.y + _height - 1, TEXTDIALOG_EDGE);
 
 	// Draw the gravelly dialog content
@@ -82,7 +82,7 @@ void Dialog::drawContent(const Common::Rect &r, int seed, byte color1, byte colo
 	uint16 currSeed = seed ? seed : 0xB78E;
 
 	for (int yp = 0; yp < r.height(); ++yp) {
-		byte *destP = _vm->_screen->getBasePtr(r.left, r.top + yp);
+		byte *destP = _vm->_screen.getBasePtr(r.left, r.top + yp);
 		
 		for (int xp = 0; xp < r.width(); ++xp) {
 			uint16 seedAdjust = currSeed;
@@ -246,10 +246,10 @@ void TextDialog::draw() {
 	if (_position.y == -1)
 		_position.y = 100 - (_height / 2);
 
-	if ((_position.x + _width) > _vm->_screen->getWidth())
-		_position.x = _vm->_screen->getWidth() - (_position.x + _width);
-	if ((_position.y + _height) > _vm->_screen->getHeight())
-		_position.y = _vm->_screen->getHeight() - (_position.y + _height);
+	if ((_position.x + _width) > _vm->_screen.getWidth())
+		_position.x = _vm->_screen.getWidth() - (_position.x + _width);
+	if ((_position.y + _height) > _vm->_screen.getHeight())
+		_position.y = _vm->_screen.getHeight() - (_position.y + _height);
 
 	// Draw the underlying dialog
 	Dialog::draw();
@@ -259,7 +259,7 @@ void TextDialog::draw() {
 	for (int lineNum = 0; lineNum < _numLines; ++lineNum) {
 		if (_lineXp[lineNum] == -1) {
 			// Draw a line across the entire dialog
-			_vm->_screen->hLine(_position.x + 2, 
+			_vm->_screen.hLine(_position.x + 2, 
 				lineYp + (_vm->_font->getHeight() + 1)  / 2,
 				_position.x + _width - 4, TEXTDIALOG_BLACK);
 		} else {
@@ -269,13 +269,13 @@ void TextDialog::draw() {
 			if (_lineXp[lineNum] & 0x40)
 				++yp;
 
-			_vm->_font->writeString(_vm->_screen, _lines[lineNum], 
+			_vm->_font->writeString(&_vm->_screen, _lines[lineNum], 
 				Common::Point(xp, yp), 0, 1);
 
 			if (_lineXp[lineNum] & 0x80) {
 				// Draw an underline under the text
 				int lineWidth = _vm->_font->getWidth(_lines[lineNum], 1);
-				_vm->_screen->hLine(xp, yp + _vm->_font->getHeight(), xp + lineWidth,
+				_vm->_screen.hLine(xp, yp + _vm->_font->getHeight(), xp + lineWidth,
 					TEXTDIALOG_BLACK);
 			}
 		}
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 1acb081..7fa31d7 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -148,7 +148,7 @@ void EventsManager::checkForNextFrameCounter() {
 		_vm->_debugger->onFrame();
 
 		// Display the frame
-		_vm->_screen->updateScreen();
+		_vm->_screen.updateScreen();
 
 		// Signal the ScummVM debugger
 		_vm->_debugger->onFrame();
diff --git a/engines/mads/events.h b/engines/mads/events.h
index add8fc3..f30e588 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -24,8 +24,8 @@
 #define MADS_EVENTS_H
 
 #include "common/scummsys.h"
-#include "mads/msprite.h"
 #include "mads/assets.h"
+#include "mads/sprites.h"
 
 namespace MADS {
 
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index e9fbf91..fd2aeba 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -27,10 +27,10 @@
 #include "engines/util.h"
 #include "mads/mads.h"
 #include "mads/graphics.h"
+#include "mads/msurface.h"
 #include "mads/resources.h"
 #include "mads/sound.h"
-#include "mads/msurface.h"
-#include "mads/msprite.h"
+#include "mads/sprites.h"
 
 namespace MADS {
 
@@ -50,7 +50,6 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :
 	_game = nullptr;
 	_palette = nullptr;
 	_resources = nullptr;
-	_screen = nullptr;
 	_sound = nullptr;
 	_userInterface = nullptr;
 }
@@ -63,7 +62,6 @@ MADSEngine::~MADSEngine() {
 	delete _game;
 	delete _palette;
 	delete _resources;
-	delete _screen;
 	delete _sound;
 	delete _userInterface;
 }
@@ -84,13 +82,13 @@ void MADSEngine::initialise() {
 	_events = new EventsManager(this);
 	_palette = new Palette(this);
 	_font = new Font(this);
-	_screen = new MSurface(g_system->getWidth(), g_system->getHeight());
+	_screen.setSize(g_system->getWidth(), g_system->getHeight());
 	_sound = new SoundManager(this, _mixer);
 	_userInterface = UserInterface::init(this);
 	_game = Game::init(this);
 
 	_events->loadCursors("*CURSOR.SS");
-	_screen->empty();
+	_screen.empty();
 }
 
 Common::Error MADSEngine::run() {
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index 2d85236..0d5e16a 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -97,7 +97,7 @@ public:
 	Game *_game;
 	Palette *_palette;
 	Resources *_resources;
-	MSurface *_screen;
+	MSurface _screen;
 	SoundManager *_sound;
 	UserInterface *_userInterface;
 	bool _easyMouse;
diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index cc618c4..3b6663e 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -301,13 +301,13 @@ TextDisplayList::TextDisplayList(MADSEngine *vm) : _vm(vm) {
 		TextDisplay rec;
 		rec._active = false;
 		rec._expire = 0;
-		_entries.push_back(rec);
+		push_back(rec);
 	}
 }
 
 void TextDisplayList::clear() {
 	for (int i = 0; i < TEXT_DISPLAY_SIZE; ++i)
-		_entries[i]._active = false;
+		(*this)[i]._active = false;
 }
 
 int TextDisplayList::add(int xp, int yp, uint fontColor, int charSpacing, 
@@ -315,20 +315,21 @@ int TextDisplayList::add(int xp, int yp, uint fontColor, int charSpacing,
 	int usedSlot = -1;
 
 	for (int idx = 0; idx < TEXT_DISPLAY_SIZE; ++idx) {
-		if (!_entries[idx]._active) {
+		TextDisplay &td = (*this)[idx];
+		if (!td._active) {
 			usedSlot = idx;
 
-			_entries[idx]._bounds.left = xp;
-			_entries[idx]._bounds.top = yp;
-			_entries[idx]._font = font;
-			_entries[idx]._msg = msg;
-			_entries[idx]._bounds.setWidth(font->getWidth(msg, charSpacing));
-			_entries[idx]._bounds.setHeight(font->getHeight());
-			_entries[idx]._color1 = fontColor & 0xff;
-			_entries[idx]._color2 = fontColor >> 8;
-			_entries[idx]._spacing = charSpacing;
-			_entries[idx]._expire = 1;
-			_entries[idx]._active = true;
+			td._bounds.left = xp;
+			td._bounds.top = yp;
+			td._font = font;
+			td._msg = msg;
+			td._bounds.setWidth(font->getWidth(msg, charSpacing));
+			td._bounds.setHeight(font->getHeight());
+			td._color1 = fontColor & 0xff;
+			td._color2 = fontColor >> 8;
+			td._spacing = charSpacing;
+			td._expire = 1;
+			td._active = true;
 			break;
 		}
 	}
@@ -340,11 +341,11 @@ void TextDisplayList::setDirtyAreas() {
 	Scene &scene = _vm->_game->_scene;
 
 	for (uint idx = 0, dirtyIdx = DIRTY_AREAS_TEXT_DISPLAY_IDX; dirtyIdx < DIRTY_AREAS_SIZE; ++idx, ++dirtyIdx) {
-		if ((_entries[idx]._expire >= 0) || !_entries[idx]._active)
+		if (((*this)[idx]._expire >= 0) || !(*this)[idx]._active)
 			scene._dirtyAreas[dirtyIdx]._active = false;
 		else {
 			scene._dirtyAreas[dirtyIdx]._textActive = true;
-			scene._dirtyAreas.setTextDisplay(dirtyIdx, _entries[idx]);
+			scene._dirtyAreas[dirtyIdx].setTextDisplay(&(*this)[idx]);
 		}
 	}
 }
@@ -353,9 +354,9 @@ void TextDisplayList::setDirtyAreas2() {
 	Scene &scene = _vm->_game->_scene;
 
 	for (uint idx = 0, dirtyIdx = DIRTY_AREAS_TEXT_DISPLAY_IDX; dirtyIdx < DIRTY_AREAS_SIZE; ++idx, ++dirtyIdx) {
-		if (_entries[idx]._active && (_entries[idx]._expire >= 0)) {
-			scene._dirtyAreas.setTextDisplay(dirtyIdx, _entries[idx]);
-			scene._dirtyAreas[dirtyIdx]._textActive = (_entries[idx]._expire <= 0) ? 0 : 1;
+		if ((*this)[idx]._active && ((*this)[idx]._expire >= 0)) {
+			scene._dirtyAreas[dirtyIdx].setTextDisplay(&(*this)[idx]);
+			scene._dirtyAreas[dirtyIdx]._textActive = ((*this)[idx]._expire <= 0) ? 0 : 1;
 		}
 	}
 }
@@ -375,16 +376,16 @@ void TextDisplayList::draw(MSurface *view) {
 }
 
 void TextDisplayList::cleanUp() {
-	for (uint idx = 0; idx < _entries.size(); ++idx) {
-		if (_entries[idx]._expire < 0) {
-			_entries[idx]._active = false;
-			_entries[idx]._expire = 0;
+	for (uint idx = 0; idx < size(); ++idx) {
+		if ((*this)[idx]._expire < 0) {
+			(*this)[idx]._active = false;
+			(*this)[idx]._expire = 0;
 		}
 	}
 }
 
 void TextDisplayList::expire(int idx) {
-	_entries[idx]._expire = -1;
+	(*this)[idx]._expire = -1;
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/messages.h b/engines/mads/messages.h
index 6967755..1357b98 100644
--- a/engines/mads/messages.h
+++ b/engines/mads/messages.h
@@ -105,10 +105,9 @@ public:
 
 #define TEXT_DISPLAY_SIZE 40
 
-class TextDisplayList {
+class TextDisplayList: public Common::Array<TextDisplay> {
 private:
 	MADSEngine *_vm;
-	Common::Array<TextDisplay> _entries;
 
 	/**
 	* Determine dirty areas for active text areas
@@ -118,13 +117,6 @@ public:
 	TextDisplayList(MADSEngine *vm);
 
 	/**
-	 * Item operator
-	 */
-	TextDisplay &operator[](int idx) {
-		return _entries[idx];
-	}
-
-	/**
 	 * Expire a given text display entry
 	 */
 	void expire(int idx);
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 36d0c49..2bff5b7 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -20,7 +20,6 @@ MODULE_OBJS := \
 	graphics.o \
 	mads.o \
 	messages.o \
-	msprite.o \
 	msurface.o \
 	palette.o \
 	player.o \
@@ -29,6 +28,7 @@ MODULE_OBJS := \
 	scene_data.o \
 	sequence.o \
 	sound.o \
+	sprites.o \
 	user_interface.o
 
 # This module can be built as a plugin
diff --git a/engines/mads/msprite.cpp b/engines/mads/msprite.cpp
deleted file mode 100644
index 279192f..0000000
--- a/engines/mads/msprite.cpp
+++ /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.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public 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/scummsys.h"
-#include "engines/util.h"
-#include "graphics/palette.h"
-#include "mads/mads.h"
-#include "mads/msurface.h"
-#include "mads/msprite.h"
-
-namespace MADS {
-
-enum {
-	kEndOfLine   = 0,
-	kEndOfSprite = 1,
-	kMarker = 2
-};
-
-MSprite::MSprite(): MSurface() {
-	_encoding = 0;
-}
-
-MSprite::MSprite(Common::SeekableReadStream *source, const Common::Point &offset, 
-		int widthVal, int heightVal, bool decodeRle, uint8 encodingVal)
-		: MSurface(widthVal, heightVal), 
-		_encoding(encodingVal), _offset(offset) {
-
-	// Load the sprite data
-	loadSprite(source);
-}
-
-MSprite::~MSprite() {
-}
-
-
-// TODO: The sprite outlines (pixel value 0xFD) are not shown
-void MSprite::loadSprite(Common::SeekableReadStream *source) {
-	byte *outp, *lineStart;
-	bool newLine = false;
-
-	outp = getData();
-	lineStart = getData();
-
-	while (1) {
-		byte cmd1, cmd2, count, pixel;
-
-		if (newLine) {
-			outp = lineStart + getWidth();
-			lineStart = outp;
-			newLine = false;
-		}
-
-		cmd1 = source->readByte();
-
-		if (cmd1 == 0xFC)
-			break;
-		else if (cmd1 == 0xFF)
-			newLine = true;
-		else if (cmd1 == 0xFD) {
-			while (!newLine) {
-				count = source->readByte();
-				if (count == 0xFF) {
-					newLine = true;
-				} else {
-					pixel = source->readByte();
-					while (count--)
-						*outp++ = (pixel == 0xFD) ? 0 : pixel;
-				}
-			}
-		} else {
-			while (!newLine) {
-				cmd2 = source->readByte();
-				if (cmd2 == 0xFF) {
-					newLine = true;
-				} else if (cmd2 == 0xFE) {
-					count = source->readByte();
-					pixel = source->readByte();
-					while (count--)
-						*outp++ = (pixel == 0xFD) ? 0 : pixel;
-				} else {
-					*outp++ = (cmd2 == 0xFD) ? 0 : cmd2;
-				}
-			}
-		}
-	}
-}
-
-} // End of namespace MADS
diff --git a/engines/mads/msprite.h b/engines/mads/msprite.h
deleted file mode 100644
index f2194da..0000000
--- a/engines/mads/msprite.h
+++ /dev/null
@@ -1,114 +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 MADS_MSPRITE_H
-#define MADS_MSPRITE_H
-
-#include "common/scummsys.h"
-#include "mads/msurface.h"
-
-namespace MADS {
-
-class MADSEngine;
-
-struct BGR8 {
-	uint8 b, g, r;
-};
-
-typedef struct {
-	int32	x;			// x position relative	to GrBuff(0, 0)
-	int32	y;			// y position relative	to GrBuff(0, 0)
-	int32	scale_x;	// x scale factor (can be negative for reverse draw)
-	int32	scale_y;	// y scale factor (can't be negative)
-	uint8*	depth_map;	// depth code array for destination (doesn't care if srcDepth is 0)
-	BGR8*	Pal;		// palette for shadow draw (doesn't care if SHADOW bit is not set in Src.encoding)
-	uint8*	ICT;		// Inverse Color Table (doesn't care if SHADOW bit is not set in Src.encoding)
-	uint8	depth;		// depth code for source (0 if no depth processing)
-} DrawRequestX;
-
-typedef struct
-{
-	uint32 Pack;
-	uint32 Stream;
-	long   hot_x;
-	long   hot_y;
-	uint32 Width;
-	uint32 Height;
-	uint32 Comp;
-	uint32 Reserved[8];
-	uint8* data;
-} RendCell;
-
-#define SS_HEADER_NUM_FIELDS 14
-struct SpriteSeriesHeader {
-	uint32 header;
-	uint32 size;
-	uint32 packing;
-	uint32 frameRate;
-	uint32 pixSpeed;
-	uint32 maxWidth;
-	uint32 maxHeight;
-	uint32 reserved3;
-	uint32 reserved4;
-	uint32 reserved5;
-	uint32 reserved6;
-	uint32 reserved7;
-	uint32 reserved8;
-	uint32 count;
-};
-
-#define SF_HEADER_NUM_FIELDS 15
-struct SpriteFrameHeader {
-	uint32 pack;
-	uint32 stream;
-	uint32 x;
-	uint32 y;
-	uint32 width;
-	uint32 height;
-	uint32 comp;
-	uint32 reserved1;
-	uint32 reserved2;
-	uint32 reserved3;
-	uint32 reserved4;
-	uint32 reserved5;
-	uint32 reserved6;
-	uint32 reserved7;
-	uint32 reserved8;
-};
-
-class MSprite: public MSurface {
-private:
-	void loadSprite(Common::SeekableReadStream *source);
-public:
-	MSprite();
-	MSprite(Common::SeekableReadStream *source, const Common::Point &offset, 
-		int widthVal, int heightVal, bool decodeRle = true, uint8 encodingVal = 0);
-	virtual ~MSprite();
-
-	Common::Point _pos;
-	Common::Point _offset;
-	uint8 _encoding;
-};
-
-} // End of namespace MADS
-
-#endif /* MADS_MSPRITE_H */
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index ca75a50..bb9b308 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -24,9 +24,9 @@
 #include "mads/compression.h"
 #include "mads/graphics.h"
 #include "mads/mads.h"
-#include "mads/msprite.h"
 #include "mads/msurface.h"
 #include "mads/resources.h"
+#include "mads/sprites.h"
 
 namespace MADS {
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index db252a9..994f582 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -424,7 +424,14 @@ void Scene::doFrame() {
 }
 
 void Scene::drawElements(bool transitionFlag, bool surfaceFlag) {
+	// Draw any background objects
+	_spriteSlots.drawBackground();
 
+	// Merge any identified dirty areas
+	_dirtyAreas.merge(1, _dirtyAreas.size());
+
+	// Copy dirty areas to the main display surface
+	_dirtyAreas.copy(&_vm->_screen, &_backgroundSurface, _posAdjust);
 }
 
 void Scene::leftClick() {
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 483ecae..c466f97 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -32,6 +32,7 @@
 #include "mads/scene_data.h"
 #include "mads/animation.h"
 #include "mads/sequence.h"
+#include "mads/sprites.h"
 
 namespace MADS {
 
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 46ef2c3..371fa43 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -138,76 +138,7 @@ void ScreenObjects::proc1() {
 
 /*------------------------------------------------------------------------*/
 
-SpriteSlot::SpriteSlot() {
-	_spriteType = ST_NONE;
-	_seqIndex = 0;
-	_spritesIndex = 0;
-	_frameNumber = 0;
-	_depth = 0;
-	_scale = 0;
-}
-
-SpriteSlot::SpriteSlot(SpriteType type, int seqIndex) {
-	_spriteType = type;
-	_seqIndex = seqIndex;
-	_spritesIndex = 0;
-	_frameNumber = 0;
-	_depth = 0;
-	_scale = 0;
-}
-
-/*------------------------------------------------------------------------*/
-
-void SpriteSlots::clear(bool flag) {
-	_vm->_game->_scene._textDisplay.clear();
-
-	if (flag)
-		_vm->_game->_scene._sprites.clear();
-
-	Common::Array<SpriteSlot>::clear();
-	push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1));
-}
-
-/**
- * Releases any sprites used by the player
- */
-void SpriteSlots::releasePlayerSprites() {
-	Player &player = _vm->_game->_player;
-
-	if (player._spritesLoaded && player._numSprites > 0) {
-		int spriteEnd = player._spritesStart + player._numSprites - 1;
-		do {
-			deleteEntry(spriteEnd);
-		} while (--spriteEnd >= player._spritesStart);
-	}
-}
-
-void SpriteSlots::deleteEntry(int index) {
-	remove_at(index);
-}
-
-void SpriteSlots::fullRefresh(bool clearAll) {
-	if (clearAll)
-		Common::Array<SpriteSlot>::clear();
-
-	push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1));
-}
-
-/*------------------------------------------------------------------------*/
-
-int SpriteSets::add(SpriteAsset *asset, int idx) {
-	if (!idx)
-		idx = size();
-
-	if (idx >= (int)(size() + 1))
-		resize(idx + 1);
-	delete (*this)[idx];
-	(*this)[idx] = asset;
-
-	return idx;
-}
-
-/*------------------------------------------------------------------------*/
+MADSEngine *DirtyArea::_vm = nullptr;
 
 void DirtyArea::setArea(int width, int height, int maxWidth, int maxHeight) {
 	if (_bounds.left % 2) {
@@ -246,73 +177,75 @@ void DirtyArea::setArea(int width, int height, int maxWidth, int maxHeight) {
 	_active = true;
 }
 
-/*------------------------------------------------------------------------*/
-
-DirtyAreas::DirtyAreas(MADSEngine *vm) : _vm(vm) {
-	for (int i = 0; i < DIRTY_AREAS_SIZE; ++i) {
-		DirtyArea rec;
-		rec._active = false;
-		_entries.push_back(rec);
-	}
-}
 
-void DirtyAreas::setSpriteSlot(int dirtyIdx, const SpriteSlot &spriteSlot) {
+void DirtyArea::setSpriteSlot(const SpriteSlot *spriteSlot) {
 	int width, height;
-	DirtyArea &dirtyArea = _entries[dirtyIdx];
 	Scene &scene = _vm->_game->_scene;
 
-	if (spriteSlot._spriteType == ST_FULL_SCREEN_REFRESH) {
+	if (spriteSlot->_spriteType == ST_FULL_SCREEN_REFRESH) {
 		// Special entry to refresh the entire screen
-		dirtyArea._bounds.left = 0;
-		dirtyArea._bounds.top = 0;
+		_bounds.left = 0;
+		_bounds.top = 0;
 		width = MADS_SCREEN_WIDTH;
 		height = MADS_SCENE_HEIGHT;
 	} else {
 		// Standard sprite slots
-		dirtyArea._bounds.left = spriteSlot._position.x - scene._posAdjust.x;
-		dirtyArea._bounds.top = spriteSlot._position.y - scene._posAdjust.y;
+		_bounds.left = spriteSlot->_position.x - scene._posAdjust.x;
+		_bounds.top = spriteSlot->_position.y - scene._posAdjust.y;
 
-		SpriteAsset &spriteSet = scene._spriteSlots.getSprite(spriteSlot._spritesIndex);
-		MSprite *frame = spriteSet.getFrame(((spriteSlot._frameNumber & 0x7fff) - 1) & 0x7f);
+		SpriteAsset &spriteSet = scene._spriteSlots.getSprite(spriteSlot->_spritesIndex);
+		MSprite *frame = spriteSet.getFrame(((spriteSlot->_frameNumber & 0x7fff) - 1) & 0x7f);
 
-		if (spriteSlot._scale == -1) {
-			width = frame->getWidth();
-			height = frame->getHeight();
-		} else {
-			width = frame->getWidth() * spriteSlot._scale / 100;
-			height = frame->getHeight() * spriteSlot._scale / 100;
+		if (spriteSlot->_scale == -1) {
+			width = frame->w;
+			height = frame->h;
+		}
+		else {
+			width = frame->w * spriteSlot->_scale / 100;
+			height = frame->h * spriteSlot->_scale / 100;
 
-			dirtyArea._bounds.left -= width / 2;
-			dirtyArea._bounds.top += -(height - 1);
+			_bounds.left -= width / 2;
+			_bounds.top += -(height - 1);
 		}
 	}
 
-	dirtyArea.setArea(width, height, MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT);
+	setArea(width, height, MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT);
 }
 
-void DirtyAreas::setTextDisplay(int dirtyIdx, const TextDisplay &textDisplay) {
-	DirtyArea &dirtyArea = _entries[dirtyIdx];
-	dirtyArea._bounds.left = textDisplay._bounds.left;
-	dirtyArea._bounds.top = textDisplay._bounds.top;
+void DirtyArea::setTextDisplay(const TextDisplay *textDisplay) {
+	_bounds.left = textDisplay->_bounds.left;
+	_bounds.top = textDisplay->_bounds.top;
 
-	dirtyArea.setArea(textDisplay._bounds.width(), textDisplay._bounds.height(), 
+	setArea(textDisplay->_bounds.width(), textDisplay->_bounds.height(),
 		MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT);
 }
 
+/*------------------------------------------------------------------------*/
+
+DirtyAreas::DirtyAreas(MADSEngine *vm) : _vm(vm) {
+	DirtyArea::_vm = vm;
+
+	for (int i = 0; i < DIRTY_AREAS_SIZE; ++i) {
+		DirtyArea rec;
+		rec._active = false;
+		push_back(rec);
+	}
+}
+
 void DirtyAreas::merge(int startIndex, int count) {
 	error("TODO: DirtyAreas::merge");
 	if (startIndex >= count)
 		return;
 
 	for (int outerCtr = startIndex - 1, idx = 0; idx < count; ++outerCtr, ++idx) {
-		if (!_entries[outerCtr]._active)
+		if (!(*this)[outerCtr]._active)
 			continue;
 
 		for (int innerCtr = outerCtr + 1; innerCtr < count; ++innerCtr) {
-			if (!_entries[innerCtr]._active || !intersects(outerCtr, innerCtr))
+			if (!(*this)[innerCtr]._active || !intersects(outerCtr, innerCtr))
 				continue;
 
-			if (_entries[outerCtr]._textActive && _entries[innerCtr]._textActive)
+			if ((*this)[outerCtr]._textActive && (*this)[innerCtr]._textActive)
 				mergeAreas(outerCtr, innerCtr);
 		}
 	}
@@ -322,12 +255,12 @@ void DirtyAreas::merge(int startIndex, int count) {
 * Returns true if two dirty areas intersect
 */
 bool DirtyAreas::intersects(int idx1, int idx2) {
-	return _entries[idx1]._bounds2.intersects(_entries[idx2]._bounds2);
+	return (*this)[idx1]._bounds2.intersects((*this)[idx2]._bounds2);
 }
 
 void DirtyAreas::mergeAreas(int idx1, int idx2) {
-	DirtyArea &da1 = _entries[idx1];
-	DirtyArea &da2 = _entries[idx2];
+	DirtyArea &da1 = (*this)[idx1];
+	DirtyArea &da2 = (*this)[idx2];
 
 	da1._bounds.extend(da2._bounds);
 
@@ -341,20 +274,22 @@ void DirtyAreas::mergeAreas(int idx1, int idx2) {
 }
 
 void DirtyAreas::copy(MSurface *dest, MSurface *src, const Common::Point &posAdjust) {
-	for (uint i = 0; i < _entries.size(); ++i) {
-		const Common::Rect &srcBounds = _entries[i]._bounds;
+	for (uint i = 0; i < size(); ++i) {
+		const Common::Rect &srcBounds = (*this)[i]._bounds;
 
 		Common::Rect bounds(srcBounds.left + posAdjust.x, srcBounds.top + posAdjust.y,
 			srcBounds.right + posAdjust.x, srcBounds.bottom + posAdjust.y);
 
-		if (_entries[i]._active && _entries[i]._bounds.isValidRect())
-			src->copyTo(dest, bounds, Common::Point(_entries[i]._bounds.left, _entries[i]._bounds.top));
+		if ((*this)[i]._active && (*this)[i]._bounds.isValidRect()) {
+			src->copyTo(dest, bounds, Common::Point((*this)[i]._bounds.left,
+				(*this)[i]._bounds.top));
+		}
 	}
 }
 
-void DirtyAreas::clear() {
-	for (uint i = 0; i < _entries.size(); ++i)
-		_entries[i]._active = false;
+void DirtyAreas::reset() {
+	for (uint i = 0; i < size(); ++i)
+		(*this)[i]._active = false;
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 522cd17..15371e4 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -38,6 +38,7 @@ namespace MADS {
 
 class MADSEngine;
 class Scene;
+class SpriteSlot;
 
 #define MADS_INTERFACE_HEIGHT 44
 #define MADS_SCENE_HEIGHT 156
@@ -58,11 +59,6 @@ enum Layer {
 	LAYER_GUI = 19
 };
 
-enum SpriteType {
-	ST_NONE = 0, ST_FOREGROUND = 1, ST_BACKGROUND = -4,
-	ST_FULL_SCREEN_REFRESH = -2, ST_EXPIRED = -1
-};
-
 class VerbInit {
 public:
 	int _id;
@@ -117,72 +113,6 @@ public:
 	void check(bool scanFlag);
 };
 
-class SpriteSlotSubset {
-public:
-	int _spritesIndex;
-	int _frameNumber;
-	Common::Point _position;
-	int _depth;
-	int _scale;
-};
-
-class SpriteSlot: public SpriteSlotSubset {
-public:
-	SpriteType _spriteType;
-	int _seqIndex;
-public:
-	SpriteSlot();
-	SpriteSlot(SpriteType type, int seqIndex);
-};
-
-class SpriteSlots: public Common::Array<SpriteSlot> {
-private:
-	MADSEngine *_vm;
-public:
-	SpriteSlots(MADSEngine *vm): _vm(vm) {}
-
-	/**
-	 * Clears any pending slot data and schedules a full screen refresh.
-	 * @param flag		Also reset sprite list
-	 */
-	void clear(bool flag);
-
-	/**
-	 * Delete any sprites used by the player
-	 */
-	void releasePlayerSprites();
-
-	/**
-	 * Delete a sprite entry
-	 * @param index		Specifies the index in the array
-	 */
-	void deleteEntry(int index);
-
-	/**
-	 * Adds a full screen refresh to the sprite slots
-	 */
-	void fullRefresh(bool clearAll = false);
-
-	SpriteAsset &getSprite(int idx) {
-		error("TODO");
-	}
-	void deleteTimer(int idx) { 
-		warning("TODO: SpriteSlots::deleteTimer"); 
-	}
-	int getIndex() {
-		warning("TODO: SpriteSlots::indexOf");
-		return -1;
-	}
-};
-
-class SpriteSets: public Common::Array<SpriteAsset *> {
-public:
-	/**
-	 * Add a sprite asset to the list
-	 */
-	int add(SpriteAsset *asset, int idx = 0);
-};
-
 class DynamicHotspot {
 public:
 	bool _active;
@@ -235,6 +165,9 @@ public:
 };
 
 class DirtyArea {
+private:
+	static MADSEngine *_vm;
+	friend class DirtyAreas;
 public:
 	Common::Rect _bounds;
 	Common::Rect _bounds2;
@@ -242,25 +175,23 @@ public:
 	bool _active;
 
 	DirtyArea() { _active = false; }
+
 	void setArea(int width, int height, int maxWidth, int maxHeight);
+
+	void setSpriteSlot(const SpriteSlot *spriteSlot);
+
+	/**
+	* Set up a dirty area for a text display
+	*/
+	void setTextDisplay(const TextDisplay *textDisplay);
 };
 
-class DirtyAreas {
+class DirtyAreas: public Common::Array<DirtyArea> {
 private:
 	MADSEngine *_vm;
-	Common::Array<DirtyArea> _entries;
 public:
 	DirtyAreas(MADSEngine *vm);
-
-	DirtyArea &operator[](uint idx) {
-		assert(idx < _entries.size());
-		return _entries[idx];
-	}
-
-	void setSpriteSlot(int dirtyIdx, const SpriteSlot &spriteSlot);
-
-	void setTextDisplay(int dirtyIdx, const TextDisplay &textDisplay);
-
+	
 	/**
 	* Merge together any designated dirty areas that overlap
 	* @param startIndex	1-based starting dirty area starting index
@@ -271,7 +202,7 @@ public:
 	bool intersects(int idx1, int idx2);
 	void mergeAreas(int idx1, int idx2);
 	void copy(MSurface *dest, MSurface *src, const Common::Point &posAdjust);
-	void clear();
+	void reset();
 };
 
 class SceneLogic {
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
new file mode 100644
index 0000000..3cba698
--- /dev/null
+++ b/engines/mads/sprites.cpp
@@ -0,0 +1,239 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "engines/util.h"
+#include "graphics/palette.h"
+#include "mads/mads.h"
+#include "mads/graphics.h"
+#include "mads/msurface.h"
+#include "mads/sprites.h"
+
+namespace MADS {
+
+enum {
+	kEndOfLine   = 0,
+	kEndOfSprite = 1,
+	kMarker = 2
+};
+
+MSprite::MSprite(): MSurface() {
+	_encoding = 0;
+}
+
+MSprite::MSprite(Common::SeekableReadStream *source, const Common::Point &offset, 
+		int widthVal, int heightVal, bool decodeRle, uint8 encodingVal)
+		: MSurface(widthVal, heightVal), 
+		_encoding(encodingVal), _offset(offset) {
+
+	// Load the sprite data
+	loadSprite(source);
+}
+
+MSprite::~MSprite() {
+}
+
+
+// TODO: The sprite outlines (pixel value 0xFD) are not shown
+void MSprite::loadSprite(Common::SeekableReadStream *source) {
+	byte *outp, *lineStart;
+	bool newLine = false;
+
+	outp = getData();
+	lineStart = getData();
+
+	while (1) {
+		byte cmd1, cmd2, count, pixel;
+
+		if (newLine) {
+			outp = lineStart + getWidth();
+			lineStart = outp;
+			newLine = false;
+		}
+
+		cmd1 = source->readByte();
+
+		if (cmd1 == 0xFC)
+			break;
+		else if (cmd1 == 0xFF)
+			newLine = true;
+		else if (cmd1 == 0xFD) {
+			while (!newLine) {
+				count = source->readByte();
+				if (count == 0xFF) {
+					newLine = true;
+				} else {
+					pixel = source->readByte();
+					while (count--)
+						*outp++ = (pixel == 0xFD) ? 0 : pixel;
+				}
+			}
+		} else {
+			while (!newLine) {
+				cmd2 = source->readByte();
+				if (cmd2 == 0xFF) {
+					newLine = true;
+				} else if (cmd2 == 0xFE) {
+					count = source->readByte();
+					pixel = source->readByte();
+					while (count--)
+						*outp++ = (pixel == 0xFD) ? 0 : pixel;
+				} else {
+					*outp++ = (cmd2 == 0xFD) ? 0 : cmd2;
+				}
+			}
+		}
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+MADSEngine *SpriteSlot::_vm = nullptr;
+
+SpriteSlot::SpriteSlot() {
+	_spriteType = ST_NONE;
+	_seqIndex = 0;
+	_spritesIndex = 0;
+	_frameNumber = 0;
+	_depth = 0;
+	_scale = 0;
+}
+
+SpriteSlot::SpriteSlot(SpriteType type, int seqIndex) {
+	_spriteType = type;
+	_seqIndex = seqIndex;
+	_spritesIndex = 0;
+	_frameNumber = 0;
+	_depth = 0;
+	_scale = 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+SpriteSlots::SpriteSlots(MADSEngine *vm) : _vm(vm) {
+	SpriteSlot::_vm = vm;
+}
+
+void SpriteSlots::clear(bool flag) {
+	_vm->_game->_scene._textDisplay.clear();
+
+	if (flag)
+		_vm->_game->_scene._sprites.clear();
+
+	Common::Array<SpriteSlot>::clear();
+	push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1));
+}
+
+/**
+* Releases any sprites used by the player
+*/
+void SpriteSlots::releasePlayerSprites() {
+	Player &player = _vm->_game->_player;
+
+	if (player._spritesLoaded && player._numSprites > 0) {
+		int spriteEnd = player._spritesStart + player._numSprites - 1;
+		do {
+			deleteEntry(spriteEnd);
+		} while (--spriteEnd >= player._spritesStart);
+	}
+}
+
+void SpriteSlots::deleteEntry(int index) {
+	remove_at(index);
+}
+
+void SpriteSlots::fullRefresh(bool clearAll) {
+	if (clearAll)
+		Common::Array<SpriteSlot>::clear();
+
+	push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1));
+}
+
+void SpriteSlots::drawBackground() {
+	Scene &scene = _vm->_game->_scene;
+
+	// Initial draw loop for any active sprites in the background
+	for (uint i = 0; i < scene._spriteSlots.size(); ++i) {
+		if (scene._spriteSlots[i]._spriteType >= ST_NONE) {
+			scene._dirtyAreas[i]._active = false;
+		}
+		else {
+			scene._dirtyAreas[i]._active = true;
+			scene._dirtyAreas[i].setSpriteSlot(&scene._spriteSlots[i]);
+
+			SpriteAsset *asset = scene._sprites[scene._spriteSlots[i]._spritesIndex];
+			MSprite *frame = asset->getFrame(scene._spriteSlots[i]._frameNumber);
+
+			if (scene._spriteSlots[i]._spriteType == ST_BACKGROUND) {
+				Common::Point pt = scene._spriteSlots[i]._position;
+				if (scene._spriteSlots[i]._scale != -1) {
+					// Adjust the drawing position
+					pt.x -= frame->w / 2;
+					pt.y -= frame->h / 2;
+				}
+
+				if (scene._spriteSlots[i]._depth <= 1) {
+					asset->draw(&scene._backgroundSurface, scene._spriteSlots[i]._frameNumber, pt);
+				}
+				else if (scene._depthStyle == 0) {
+					asset->depthDraw(&scene._backgroundSurface, &scene._depthSurface, scene._spriteSlots[i]._frameNumber,
+						pt, scene._spriteSlots[i]._depth);
+				} else {
+					error("Unsupported depth style");
+				}
+			}
+		}
+	}
+
+	// Mark any remaning dirty areas as inactive
+	for (uint i = scene._spriteSlots.size(); i < 50; ++i)
+		scene._dirtyAreas[i]._active = false;
+
+	// Flag any active text display
+	for (uint i = 50; i < scene._textDisplay.size(); ++i) {
+		TextDisplay &textDisplay = scene._textDisplay[i - 50];
+		if (scene._textDisplay[i]._expire >= 0 || !textDisplay._active) {
+			scene._dirtyAreas[i]._active = false;
+		} else {
+			scene._dirtyAreas[i]._active = true;
+			scene._dirtyAreas[i].setTextDisplay(&textDisplay);
+		}
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+int SpriteSets::add(SpriteAsset *asset, int idx) {
+	if (!idx)
+		idx = size();
+
+	if (idx >= (int)(size() + 1))
+		resize(idx + 1);
+	delete (*this)[idx];
+	(*this)[idx] = asset;
+
+	return idx;
+}
+
+/*------------------------------------------------------------------------*/
+
+} // End of namespace MADS
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
new file mode 100644
index 0000000..6b13110
--- /dev/null
+++ b/engines/mads/sprites.h
@@ -0,0 +1,197 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_SPRITES_H
+#define MADS_SPRITES_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+#include "mads/assets.h"
+#include "mads/msurface.h"
+
+namespace MADS {
+
+enum SpriteType {
+	ST_NONE = 0, ST_FOREGROUND = 1, ST_BACKGROUND = -4,
+	ST_FULL_SCREEN_REFRESH = -2, ST_EXPIRED = -1
+};
+
+class MADSEngine;
+
+struct BGR8 {
+	uint8 b, g, r;
+};
+
+typedef struct {
+	int32	x;			// x position relative	to GrBuff(0, 0)
+	int32	y;			// y position relative	to GrBuff(0, 0)
+	int32	scale_x;	// x scale factor (can be negative for reverse draw)
+	int32	scale_y;	// y scale factor (can't be negative)
+	uint8*	depth_map;	// depth code array for destination (doesn't care if srcDepth is 0)
+	BGR8*	Pal;		// palette for shadow draw (doesn't care if SHADOW bit is not set in Src.encoding)
+	uint8*	ICT;		// Inverse Color Table (doesn't care if SHADOW bit is not set in Src.encoding)
+	uint8	depth;		// depth code for source (0 if no depth processing)
+} DrawRequestX;
+
+typedef struct
+{
+	uint32 Pack;
+	uint32 Stream;
+	long   hot_x;
+	long   hot_y;
+	uint32 Width;
+	uint32 Height;
+	uint32 Comp;
+	uint32 Reserved[8];
+	uint8* data;
+} RendCell;
+
+#define SS_HEADER_NUM_FIELDS 14
+struct SpriteSeriesHeader {
+	uint32 header;
+	uint32 size;
+	uint32 packing;
+	uint32 frameRate;
+	uint32 pixSpeed;
+	uint32 maxWidth;
+	uint32 maxHeight;
+	uint32 reserved3;
+	uint32 reserved4;
+	uint32 reserved5;
+	uint32 reserved6;
+	uint32 reserved7;
+	uint32 reserved8;
+	uint32 count;
+};
+
+#define SF_HEADER_NUM_FIELDS 15
+struct SpriteFrameHeader {
+	uint32 pack;
+	uint32 stream;
+	uint32 x;
+	uint32 y;
+	uint32 width;
+	uint32 height;
+	uint32 comp;
+	uint32 reserved1;
+	uint32 reserved2;
+	uint32 reserved3;
+	uint32 reserved4;
+	uint32 reserved5;
+	uint32 reserved6;
+	uint32 reserved7;
+	uint32 reserved8;
+};
+
+class MSprite: public MSurface {
+private:
+	void loadSprite(Common::SeekableReadStream *source);
+public:
+	MSprite();
+	MSprite(Common::SeekableReadStream *source, const Common::Point &offset, 
+		int widthVal, int heightVal, bool decodeRle = true, uint8 encodingVal = 0);
+	virtual ~MSprite();
+
+	Common::Point _pos;
+	Common::Point _offset;
+	uint8 _encoding;
+};
+
+class SpriteSlotSubset {
+public:
+	int _spritesIndex;
+	int _frameNumber;
+	Common::Point _position;
+	int _depth;
+	int _scale;
+};
+
+class SpriteSlot : public SpriteSlotSubset {
+private:
+	static MADSEngine *_vm;
+	friend class SpriteSlots;
+public:
+	SpriteType _spriteType;
+	int _seqIndex;
+public:
+	SpriteSlot();
+	SpriteSlot(SpriteType type, int seqIndex);
+
+	void setup(int dirtyAreaIndex);
+};
+
+class SpriteSlots : public Common::Array<SpriteSlot> {
+private:
+	MADSEngine *_vm;
+public:
+	SpriteSlots(MADSEngine *vm);
+
+	/**
+	* Clears any pending slot data and schedules a full screen refresh.
+	* @param flag		Also reset sprite list
+	*/
+	void clear(bool flag);
+
+	/**
+	* Delete any sprites used by the player
+	*/
+	void releasePlayerSprites();
+
+	/**
+	* Delete a sprite entry
+	* @param index		Specifies the index in the array
+	*/
+	void deleteEntry(int index);
+
+	/**
+	* Adds a full screen refresh to the sprite slots
+	*/
+	void fullRefresh(bool clearAll = false);
+
+	SpriteAsset &getSprite(int idx) {
+		error("TODO");
+	}
+	void deleteTimer(int idx) {
+		warning("TODO: SpriteSlots::deleteTimer");
+	}
+	int getIndex() {
+		warning("TODO: SpriteSlots::indexOf");
+		return -1;
+	}
+
+	/**
+	 * Draw any sprites into the background of the scene
+	 */
+	void drawBackground();
+};
+
+class SpriteSets : public Common::Array<SpriteAsset *> {
+public:
+	/**
+	* Add a sprite asset to the list
+	*/
+	int add(SpriteAsset *asset, int idx = 0);
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_SPRITES_H */


Commit: 23ebeec600f8210601dd45fc42c21a596fa6d127
    https://github.com/scummvm/scummvm/commit/23ebeec600f8210601dd45fc42c21a596fa6d127
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-05T07:27:39-05:00

Commit Message:
MADS: Further implementation of drawElements

Changed paths:
  A engines/mads/interface.cpp
  A engines/mads/interface.h
    engines/mads/animation.h
    engines/mads/graphics.cpp
    engines/mads/graphics.h
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/module.mk
    engines/mads/msurface.cpp
    engines/mads/msurface.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h
    engines/mads/sprites.cpp
    engines/mads/sprites.h



diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 297abf4..9498483 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -29,6 +29,7 @@
 #include "mads/msurface.h"
 #include "mads/scene_data.h"
 #include "mads/font.h"
+#include "mads/interface.h"
 
 namespace MADS {
 
diff --git a/engines/mads/graphics.cpp b/engines/mads/graphics.cpp
index 267785b..f4d788f 100644
--- a/engines/mads/graphics.cpp
+++ b/engines/mads/graphics.cpp
@@ -26,5 +26,23 @@
 
 namespace MADS {
 
+void ScreenSurface::init() {
+	setSize(g_system->getWidth(), g_system->getHeight());
+}
+
+void ScreenSurface::updateScreen() {
+	g_system->copyRectToScreen((const byte *)pixels, pitch, 0, 0, w, h);
+	g_system->updateScreen();
+}
+
+void ScreenSurface::transition(bool transitionFlag, bool surfaceFlag) {
+
+}
+
+void ScreenSurface::setPointer(MSurface *s) {
+	_pixels = s->getData();
+	_pitch = s->w;
+}
+
 
 } // End of namespace MADS
diff --git a/engines/mads/graphics.h b/engines/mads/graphics.h
index cadbbc8..b64bced 100644
--- a/engines/mads/graphics.h
+++ b/engines/mads/graphics.h
@@ -24,12 +24,40 @@
 #define MADS_GRAPHICS_H
 
 #include "common/scummsys.h"
+#include "common/array.h"
+#include "mads/msurface.h"
 
 namespace MADS {
 
 #define MADS_SCREEN_WIDTH 320
 #define MADS_SCREEN_HEIGHT 200
 
+class ScreenSurface : public MSurface {
+public:
+	Common::Point _offset;
+	byte *_pixels;
+	int _pitch;
+public:
+	/**
+	 * Constructor
+	 */
+	ScreenSurface() {}
+
+	/**
+	 * Initialise the surface
+	 */
+	void init();
+
+	void setPointer(MSurface *s);
+
+	/**
+	 * Updates the screen with the contents of the surface
+	 */
+	void updateScreen();
+
+	void transition(bool transitionFlag, bool surfaceFlag);
+};
+
 } // End of namespace MADS
 
 #endif /* MADS_GRAPHICS_H */
diff --git a/engines/mads/interface.cpp b/engines/mads/interface.cpp
new file mode 100644
index 0000000..fa50cbd
--- /dev/null
+++ b/engines/mads/interface.cpp
@@ -0,0 +1,87 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/compression.h"
+#include "mads/interface.h"
+
+namespace MADS {
+
+void SceneNode::load(Common::SeekableReadStream *f) {
+	_walkPos.x = f->readSint16LE();
+	_walkPos.y = f->readSint16LE();
+	for (int i = 0; i < MAX_ROUTE_NODES; ++i)
+		_indexes[i] = f->readUint16LE();
+}
+
+/*------------------------------------------------------------------------*/
+
+InterfaceSurface::InterfaceSurface(MADSEngine *vm) : _vm(vm) {
+	_category = CAT_NONE;
+	_screenObjectsCount = 0;
+}
+
+
+void InterfaceSurface::load(const Common::String &resName) {
+	File f(resName);
+	MadsPack madsPack(&f);
+
+	// Load in the palette
+	Common::SeekableReadStream *palStream = madsPack.getItemStream(0);
+
+	RGB4 *gamePalP = &_vm->_palette->_gamePalette[0];
+	byte *palP = &_vm->_palette->_mainPalette[0];
+
+	for (int i = 0; i < 16; ++i, gamePalP++, palP += 3) {
+		palP[0] = palStream->readByte();
+		palP[1] = palStream->readByte();
+		palP[2] = palStream->readByte();
+		gamePalP->r |= 1;
+		palStream->skip(3);
+	}
+	delete palStream;
+
+	// set the size for the interface
+	setSize(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
+	Common::SeekableReadStream *pixelsStream = madsPack.getItemStream(1);
+	pixelsStream->read(getData(), MADS_SCREEN_WIDTH * MADS_INTERFACE_HEIGHT);
+	delete pixelsStream;
+}
+
+void InterfaceSurface::elementHighlighted() {
+	warning("TODO: InterfaceSurface::elementHighlighted");
+}
+
+void InterfaceSurface::writeText() {
+	warning("TODO: InterfaceSurface::writeText");
+}
+
+
+void InterfaceSurface::setBounds(const Common::Rect &r) {
+	_bounds = r;
+}
+
+/*------------------------------------------------------------------------*/
+
+
+} // End of namespace MADS
diff --git a/engines/mads/interface.h b/engines/mads/interface.h
new file mode 100644
index 0000000..3295fa4
--- /dev/null
+++ b/engines/mads/interface.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_INTERFACE_H
+#define MADS_INTERFACE_H
+
+#include "common/scummsys.h"
+#include "common/rect.h"
+#include "common/str.h"
+
+namespace MADS {
+
+class InterfaceSurface : public MSurface {
+private:
+	MADSEngine *_vm;
+public:
+	ScrCategory _category;
+	int _screenObjectsCount;
+	Common::Rect _bounds;
+	Common::Rect *_rectP;
+public:
+	/**
+	* Constructor
+	*/
+	InterfaceSurface(MADSEngine *vm);
+
+	/**
+	* Loads an interface from a specified resource
+	*/
+	void load(const Common::String &resName);
+
+	void elementHighlighted();
+
+	void writeText();
+
+	void setBounds(const Common::Rect &r);
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_INTERFACE_H */
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index fd2aeba..fcf0395 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -82,7 +82,7 @@ void MADSEngine::initialise() {
 	_events = new EventsManager(this);
 	_palette = new Palette(this);
 	_font = new Font(this);
-	_screen.setSize(g_system->getWidth(), g_system->getHeight());
+	_screen.init();
 	_sound = new SoundManager(this, _mixer);
 	_userInterface = UserInterface::init(this);
 	_game = Game::init(this);
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index 0d5e16a..abe6e79 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -35,6 +35,7 @@
 #include "mads/events.h"
 #include "mads/font.h"
 #include "mads/game.h"
+#include "mads/graphics.h"
 #include "mads/msurface.h"
 #include "mads/resources.h"
 #include "mads/sound.h"
@@ -97,7 +98,7 @@ public:
 	Game *_game;
 	Palette *_palette;
 	Resources *_resources;
-	MSurface _screen;
+	ScreenSurface _screen;
 	SoundManager *_sound;
 	UserInterface *_userInterface;
 	bool _easyMouse;
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 2bff5b7..6a44621 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -18,6 +18,7 @@ MODULE_OBJS := \
 	game.o \
 	game_data.o \
 	graphics.o \
+	interface.o \
 	mads.o \
 	messages.o \
 	msurface.o \
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index bb9b308..5f7b37b 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -199,11 +199,6 @@ void MSurface::empty() {
 	Common::fill(getBasePtr(0, 0), getBasePtr(0, h), _vm->_palette->BLACK);
 }
 
-void MSurface::updateScreen() { 
-	g_system->copyRectToScreen((const byte *)pixels, pitch, 0, 0, w, h);
-	g_system->updateScreen(); 
-}
-
 void MSurface::copyFrom(MSurface *src, const Common::Rect &srcBounds, 
 		const Common::Point &destPos, int transparentColor) {
 	// Validation of the rectangle and position	
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index 7f4cec3..7043cd4 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -132,11 +132,6 @@ public:
 	void empty();
 
 	/**
-	 * Updates the screen with the contents of the surface
-	 */
-	void updateScreen();
-
-	/**
 	 * Copys a sub-section of another surface into the current one.
 	 * @param src			Source surface
 	 * @param srcBounds		Area of source surface to copy
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 994f582..1d489dd 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -164,7 +164,6 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	_scaleRange = _sceneInfo->_maxScale - _sceneInfo->_minScale;
 
 	_spriteSlots.clear(false);
-	_screenY = 0;
 	_interfaceY = MADS_SCENE_HEIGHT;
 	_spritesCount = _sprites.size();
 
@@ -432,6 +431,28 @@ void Scene::drawElements(bool transitionFlag, bool surfaceFlag) {
 
 	// Copy dirty areas to the main display surface
 	_dirtyAreas.copy(&_vm->_screen, &_backgroundSurface, _posAdjust);
+
+	// Set dirty areas
+	_spriteSlots.setDirtyAreas();
+	_textDisplay.setDirtyAreas();
+
+	//
+	_vm->_screen.setPointer(&_vm->_screen);
+	_interface.setBounds(Common::Rect(_vm->_screen._offset.x, _vm->_screen._offset.y,
+		_vm->_screen._offset.x + _vm->_screen.w, _vm->_screen._offset.y + _vm->_screen.h));
+
+	if (transitionFlag) {
+		// Fading in the screen
+		_vm->_screen.transition(transitionFlag, surfaceFlag);
+		_vm->_sound->startQueuedCommands();
+	} else {
+		// Copy dirty areas to the screen
+		_dirtyAreas.copy(&_vm->_screen, &_backgroundSurface, _vm->_screen._offset);
+	}
+
+	warning("TODO: sub_115A2");
+	_spriteSlots.cleanUp();
+	_textDisplay.cleanUp();
 }
 
 void Scene::leftClick() {
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index c466f97..d9bc15a 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -112,7 +112,6 @@ public:
 	int _depthStyle;
 	int _bandsRange;
 	int _scaleRange;
-	int _screenY;
 	int _interfaceY;
 	int _spritesCount;
 	int _v1A;
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 371fa43..00632f6 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -471,30 +471,6 @@ void ARTHeader::load(Common::SeekableReadStream *f) {
 
 /*------------------------------------------------------------------------*/
 
-void SceneNode::load(Common::SeekableReadStream *f) {
-	_walkPos.x = f->readSint16LE();
-	_walkPos.y = f->readSint16LE();
-	for (int i = 0; i < MAX_ROUTE_NODES; ++i)
-		_indexes[i] = f->readUint16LE();
-}
-
-/*------------------------------------------------------------------------*/
-
-InterfaceSurface::InterfaceSurface(MADSEngine *vm): _vm(vm) {
-	_category = CAT_NONE;
-	_screenObjectsCount = 0;
-}
-
-void InterfaceSurface::elementHighlighted() {
-	warning("TODO: InterfaceSurface::elementHighlighted");
-}
-
-void InterfaceSurface::writeText() {
-	warning("TODO: InterfaceSurface::writeText");
-}
-
-/*------------------------------------------------------------------------*/
-
 void SceneInfo::SpriteInfo::load(Common::SeekableReadStream *f) {
 	f->skip(3);
 	_spriteSetIndex = f->readByte();
@@ -507,34 +483,6 @@ void SceneInfo::SpriteInfo::load(Common::SeekableReadStream *f) {
 
 /*------------------------------------------------------------------------*/
 
-void InterfaceSurface::load(const Common::String &resName) {
-	File f(resName);
-	MadsPack madsPack(&f);
-
-	// Load in the palette
-	Common::SeekableReadStream *palStream = madsPack.getItemStream(0);
-
-	RGB4 *gamePalP = &_vm->_palette->_gamePalette[0];
-	byte *palP = &_vm->_palette->_mainPalette[0];
-
-	for (int i = 0; i < 16; ++i, gamePalP++, palP += 3) {
-		palP[0] = palStream->readByte();
-		palP[1] = palStream->readByte();
-		palP[2] = palStream->readByte();
-		gamePalP->r |= 1;
-		palStream->skip(3);
-	}
-	delete palStream;
-
-	// set the size for the interface
-	setSize(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
-	Common::SeekableReadStream *pixelsStream = madsPack.getItemStream(1);
-	pixelsStream->read(getData(), MADS_SCREEN_WIDTH * MADS_INTERFACE_HEIGHT);
-	delete pixelsStream;
-}
-
-/*------------------------------------------------------------------------*/
-
 SceneInfo *SceneInfo::init(MADSEngine *vm) {
 	if (vm->getGameID() == GType_RexNebular) {
 		return new SceneInfoNebular(vm);
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 15371e4..ce785e7 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -277,27 +277,6 @@ public:
 };
 typedef Common::Array<SceneNode> SceneNodeList;
 
-class InterfaceSurface : public MSurface {
-private:
-	MADSEngine *_vm;
-public:
-	ScrCategory _category;
-	int _screenObjectsCount;
-public:
-	/**
-	 * Constructor
-	 */
-	InterfaceSurface(MADSEngine *vm);
-
-	/**
-	 * Loads an interface from a specified resource
-	 */
-	void load(const Common::String &resName);
-
-	void elementHighlighted();
-
-	void writeText();
-};
 
 /**
  * Handles general data for a given scene
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 3cba698..e7349f6 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -161,6 +161,19 @@ void SpriteSlots::deleteEntry(int index) {
 	remove_at(index);
 }
 
+void SpriteSlots::setDirtyAreas() {
+	Scene &scene = _vm->_game->_scene;
+
+	for (uint i = 0; i < size(); ++i) {
+		if ((*this)[i]._spriteType >= ST_NONE) {
+			scene._dirtyAreas[i].setSpriteSlot(&(*this)[i]);
+
+			scene._dirtyAreas[i]._textActive = ((*this)[i]._spriteType <= ST_NONE) ? 0 : 1;
+			(*this)[i]._spriteType = ST_NONE;
+		}
+	}
+}
+
 void SpriteSlots::fullRefresh(bool clearAll) {
 	if (clearAll)
 		Common::Array<SpriteSlot>::clear();
@@ -220,6 +233,13 @@ void SpriteSlots::drawBackground() {
 	}
 }
 
+void SpriteSlots::cleanUp() {
+	for (int i = (int)size() - 1; i >= 0; --i) {
+		if ((*this)[i]._spriteType >= ST_NONE)
+			remove_at(i);
+	}
+}
+
 /*------------------------------------------------------------------------*/
 
 int SpriteSets::add(SpriteAsset *asset, int idx) {
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index 6b13110..b1208d0 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -163,6 +163,11 @@ public:
 	void deleteEntry(int index);
 
 	/**
+	 * Setup dirty areas for the sprite slots
+	 */
+	void setDirtyAreas();
+
+	/**
 	* Adds a full screen refresh to the sprite slots
 	*/
 	void fullRefresh(bool clearAll = false);
@@ -182,6 +187,8 @@ public:
 	 * Draw any sprites into the background of the scene
 	 */
 	void drawBackground();
+
+	void cleanUp();
 };
 
 class SpriteSets : public Common::Array<SpriteAsset *> {


Commit: d98f890029936dfa8139cf8dce4756ec92bc2568
    https://github.com/scummvm/scummvm/commit/d98f890029936dfa8139cf8dce4756ec92bc2568
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-05T09:04:53-05:00

Commit Message:
MADS: Completed implementing drawElements and support methods

Changed paths:
    engines/mads/messages.cpp
    engines/mads/messages.h
    engines/mads/msurface.cpp
    engines/mads/msurface.h
    engines/mads/scene.cpp
    engines/mads/sprites.cpp
    engines/mads/sprites.h



diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index 3b6663e..11db00f 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -305,7 +305,7 @@ TextDisplayList::TextDisplayList(MADSEngine *vm) : _vm(vm) {
 	}
 }
 
-void TextDisplayList::clear() {
+void TextDisplayList::reset() {
 	for (int i = 0; i < TEXT_DISPLAY_SIZE; ++i)
 		(*this)[i]._active = false;
 }
@@ -361,18 +361,16 @@ void TextDisplayList::setDirtyAreas2() {
 	}
 }
 
-void TextDisplayList::draw(MSurface *view) {
-	error("TODO");
-	/*
-	for (uint idx = 0; idx < _entries.size(); ++idx) {
-		if (_entries[idx]._active && (_entries[idx]._expire >= 0)) {
-			_entries[idx]._font->setColors(_entries[idx]._color1, _entries[idx]._color2, 0);
-			_entries[idx]._font->writeString(view, _entries[idx]._msg,
-				Common::Point(_entries[idx]._bounds.left, _entries[idx]._bounds.top), 
-				_entries[idx]._bounds.width(), _entries[idx]._spacing);
+void TextDisplayList::draw(MSurface *s) {
+	for (uint idx = 0; idx < size(); ++idx) {
+		TextDisplay &td = (*this)[idx];
+		if (td._active && (td._expire >= 0)) {
+			td._font->setColors(0xFF, td._color1, td._color2, 0);
+			td._font->writeString(s, td._msg,
+				Common::Point(td._bounds.left, td._bounds.top), 
+				td._bounds.width(), td._spacing);
 		}
 	}
-	*/
 }
 
 void TextDisplayList::cleanUp() {
diff --git a/engines/mads/messages.h b/engines/mads/messages.h
index 1357b98..19a0115 100644
--- a/engines/mads/messages.h
+++ b/engines/mads/messages.h
@@ -108,11 +108,6 @@ public:
 class TextDisplayList: public Common::Array<TextDisplay> {
 private:
 	MADSEngine *_vm;
-
-	/**
-	* Determine dirty areas for active text areas
-	*/
-	void setDirtyAreas2();
 public:
 	TextDisplayList(MADSEngine *vm);
 
@@ -122,8 +117,17 @@ public:
 	void expire(int idx);
 
 	int add(int xp, int yp, uint fontColor, int charSpacing, const Common::String &, Font *font);
-	void clear();
-	void draw(MSurface *view);
+	
+	/**
+	 * Reset all of the text display entries in the list to inactive
+	 */
+	void reset();
+
+	/**
+	 * Draw any text in the list to the specified surface
+	 * @param surface	Surface
+	 */
+	void draw(MSurface *s);
 	
 	/**
 	 * Determine dirty areas for active text areas
@@ -131,6 +135,11 @@ public:
 	void setDirtyAreas();
 
 	/**
+	* Secondary setup dirty areas for the text areas
+	*/
+	void setDirtyAreas2();
+
+	/**
 	* Deactivates any text display entries that are finished
 	*/
 	void cleanUp();
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 5f7b37b..aed00f5 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -244,6 +244,168 @@ void MSurface::copyFrom(MSurface *src, const Common::Rect &srcBounds,
 	}
 }
 
+void MSurface::copyFrom(MSurface *src, const Common::Point &destPos, int depth,
+	MSurface *depthsSurface, int scale, int transparentColor) {
+
+	int destX = destPos.x, destY = destPos.y;
+	if (scale == 100) {
+		// Copy the specified area
+		Common::Rect copyRect(0, 0, src->getWidth(), src->getHeight());
+
+		if (destX < 0) {
+			copyRect.left += -destX;
+			destX = 0;
+		}
+		else if (destX + copyRect.width() > w) {
+			copyRect.right -= destX + copyRect.width() - w;
+		}
+		if (destY < 0) {
+			copyRect.top += -destY;
+			destY = 0;
+		}
+		else if (destY + copyRect.height() > h) {
+			copyRect.bottom -= destY + copyRect.height() - h;
+		}
+
+		if (!copyRect.isValidRect())
+			return;
+
+		byte *data = src->getData();
+		byte *srcPtr = data + (src->getWidth() * copyRect.top + copyRect.left);
+		byte *depthsData = depthsSurface->getData();
+		byte *depthsPtr = depthsData + (depthsSurface->pitch * destY) + destX;
+		byte *destPtr = (byte *)pixels + (destY * pitch) + destX;
+
+		// 100% scaling variation
+		for (int rowCtr = 0; rowCtr < copyRect.height(); ++rowCtr) {
+			// Copy each byte one at a time checking against the depth
+			for (int xCtr = 0; xCtr < copyRect.width(); ++xCtr) {
+				if ((depth <= (depthsPtr[xCtr] & 0x7f)) && (srcPtr[xCtr] != transparentColor))
+					destPtr[xCtr] = srcPtr[xCtr];
+			}
+
+			srcPtr += src->getWidth();
+			depthsPtr += depthsSurface->getWidth();
+			destPtr += getWidth();
+		}
+
+		return;
+	}
+
+	// Start of draw logic for scaled sprites
+	const byte *srcPixelsP = src->getData();
+
+	int destRight = this->getWidth() - 1;
+	int destBottom = this->getHeight() - 1;
+	bool normalFrame = true;	// TODO: false for negative frame numbers
+	int frameWidth = src->getWidth();
+	int frameHeight = src->getHeight();
+
+	int highestDim = MAX(frameWidth, frameHeight);
+	bool lineDist[MADS_SCREEN_WIDTH];
+	int distIndex = 0;
+	int distXCount = 0, distYCount = 0;
+
+	int distCtr = 0;
+	do {
+		distCtr += scale;
+		if (distCtr < 100) {
+			lineDist[distIndex] = false;
+		}
+		else {
+			lineDist[distIndex] = true;
+			distCtr -= 100;
+
+			if (distIndex < frameWidth)
+				++distXCount;
+
+			if (distIndex < frameHeight)
+				++distYCount;
+		}
+	} while (++distIndex < highestDim);
+
+	destX -= distXCount / 2;
+	destY -= distYCount - 1;
+
+	// Check x bounding area
+	int spriteLeft = 0;
+	int spriteWidth = distXCount;
+	int widthAmount = destX + distXCount - 1;
+
+	if (destX < 0) {
+		spriteWidth += destX;
+		spriteLeft -= destX;
+	}
+	widthAmount -= destRight;
+	if (widthAmount > 0)
+		spriteWidth -= widthAmount;
+
+	int spriteRight = spriteLeft + spriteWidth;
+	if (spriteWidth <= 0)
+		return;
+	if (!normalFrame) {
+		destX += distXCount - 1;
+		spriteLeft = -(distXCount - spriteRight);
+		spriteRight = (-spriteLeft + spriteWidth);
+	}
+
+	// Check y bounding area
+	int spriteTop = 0;
+	int spriteHeight = distYCount;
+	int heightAmount = destY + distYCount - 1;
+
+	if (destY < 0) {
+		spriteHeight += destY;
+		spriteTop -= destY;
+	}
+	heightAmount -= destBottom;
+	if (heightAmount > 0)
+		spriteHeight -= heightAmount;
+	int spriteBottom = spriteTop + spriteHeight;
+
+	if (spriteHeight <= 0)
+		return;
+
+	byte *destPixelsP = this->getBasePtr(destX + spriteLeft, destY + spriteTop);
+	const byte *depthPixelsP = depthsSurface->getBasePtr(destX + spriteLeft, destY + spriteTop);
+
+	spriteLeft = (spriteLeft * (normalFrame ? 1 : -1));
+
+	// Loop through the lines of the sprite
+	for (int yp = 0, sprY = -1; yp < frameHeight; ++yp, srcPixelsP += src->pitch) {
+		if (!lineDist[yp])
+			// Not a display line, so skip it
+			continue;
+		// Check whether the sprite line is in the display range
+		++sprY;
+		if ((sprY >= spriteBottom) || (sprY < spriteTop))
+			continue;
+
+		// Found a line to display. Loop through the pixels
+		const byte *srcP = srcPixelsP;
+		const byte *depthP = depthPixelsP;
+		byte *destP = destPixelsP;
+		for (int xp = 0, sprX = 0; xp < frameWidth; ++xp, ++srcP) {
+			if (xp < spriteLeft)
+				// Not yet reached start of display area
+				continue;
+			if (!lineDist[sprX++])
+				// Not a display pixel
+				continue;
+
+			if ((*srcP != transparentColor) && (depth <= (*depthP & 0x7f)))
+				*destP = *srcP;
+
+			++destP;
+			++depthP;
+		}
+
+		// Move to the next destination line
+		destPixelsP += this->pitch;
+		depthPixelsP += depthsSurface->pitch;
+	}
+}
+
 void MSurface::translate(Common::Array<RGB6> &palette) {
 	for (int y = 0; y < this->h; ++y) {
 		byte *pDest = getBasePtr(0, y);
@@ -254,4 +416,18 @@ void MSurface::translate(Common::Array<RGB6> &palette) {
 	}
 }
 
+MSurface *MSurface::flipHorizontal() const {
+	MSurface *dest = new MSurface(this->w, this->h);
+
+	for (int y = 0; y < this->h; ++y) {
+		const byte *srcP = getBasePtr(this->w - 1, y);
+		byte *destP = dest->getData();
+
+		for (int x = 0; x < this->w; ++x)
+			*destP++ = *srcP--;
+	}
+
+	return dest;
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index 7043cd4..c797033 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -127,6 +127,11 @@ public:
 	byte *getBasePtr(int x, int y) { return (byte *)Graphics::Surface::getBasePtr(x, y); }
 
 	/**
+	* Returns a pointer to a given position within the surface
+	*/
+	const byte *getBasePtr(int x, int y) const { return (const byte *)Graphics::Surface::getBasePtr(x, y); }
+
+	/**
 	 * Clears the surface
 	 */
 	void empty();
@@ -142,6 +147,17 @@ public:
 		int transparentColor = -1);
 
 	/**
+	* Copys a sub-section of another surface into the current one.
+	* @param src			Source surface
+	* @param destPos		Destination position to draw in current surface
+	* @param depth			Depth of sprite
+	* @param depthSurface	Depth surface to use with sprite depth
+	* @param transparentColor	Transparency palette index
+	*/
+	void copyFrom(MSurface *src, const Common::Point &destPos, int depth, MSurface *depthSurface,
+		int scale, int transparentColor = -1);
+
+	/**
 	 * Copies the surface to a given destination surface
 	 */
 	void copyTo(MSurface *dest, int transparentColor = -1) { 
@@ -167,6 +183,11 @@ public:
 	 * Translates the pixels of an image used the passed palette with RGB mapping
 	 */
 	void translate(Common::Array<RGB6> &palette);
+
+	/**
+	 * Create a new surface which is a flipped horizontal copy of the current one
+	 */
+	MSurface *flipHorizontal() const;
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 1d489dd..7359562 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -423,18 +423,30 @@ void Scene::doFrame() {
 }
 
 void Scene::drawElements(bool transitionFlag, bool surfaceFlag) {
-	// Draw any background objects
+	// Draw any sprites
+	_dirtyAreas.clear();
 	_spriteSlots.drawBackground();
 
+	// Process dirty areas
+	_textDisplay.setDirtyAreas();
+
 	// Merge any identified dirty areas
-	_dirtyAreas.merge(1, _dirtyAreas.size());
+	_dirtyAreas.merge(1, DIRTY_AREAS_SIZE);
 
 	// Copy dirty areas to the main display surface
 	_dirtyAreas.copy(&_vm->_screen, &_backgroundSurface, _posAdjust);
 
-	// Set dirty areas
+	// Handle dirty areas for foreground objects
 	_spriteSlots.setDirtyAreas();
-	_textDisplay.setDirtyAreas();
+	_textDisplay.setDirtyAreas2();
+	_dirtyAreas.merge(1, DIRTY_AREAS_SIZE);
+
+
+	// Draw foreground sprites
+	_spriteSlots.drawForeground(&_vm->_screen);
+
+	// Draw text elements onto the view
+	_textDisplay.draw(&_vm->_screen);
 
 	//
 	_vm->_screen.setPointer(&_vm->_screen);
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index e7349f6..aa15f66 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -36,6 +36,24 @@ enum {
 	kMarker = 2
 };
 
+#define TRANSPARENT_COLOR_INDEX 0xFF
+
+class DepthEntry {
+public:
+	int depth;
+	int index;
+
+	DepthEntry(int depthAmt, int indexVal) { depth = depthAmt; index = indexVal; }
+};
+
+bool sortHelper(const DepthEntry &entry1, const DepthEntry &entry2) {
+	return entry1.depth < entry2.depth;
+}
+
+typedef Common::List<DepthEntry> DepthList;
+
+/*------------------------------------------------------------------------*/
+
 MSprite::MSprite(): MSurface() {
 	_encoding = 0;
 }
@@ -105,6 +123,10 @@ void MSprite::loadSprite(Common::SeekableReadStream *source) {
 	}
 }
 
+byte MSprite::getTransparencyIndex() const {
+	return TRANSPARENT_COLOR_INDEX;
+}
+
 /*------------------------------------------------------------------------*/
 
 MADSEngine *SpriteSlot::_vm = nullptr;
@@ -233,6 +255,71 @@ void SpriteSlots::drawBackground() {
 	}
 }
 
+void SpriteSlots::drawForeground(MSurface *s) {
+	DepthList depthList;
+	Scene &scene = _vm->_game->_scene;
+
+	// Get a list of sprite object depths for active objects
+	for (uint i = 0; i < size(); ++i) {
+		if ((*this)[i]._spriteType >= ST_NONE) {
+			DepthEntry rec(16 - (*this)[i]._depth, i);
+			depthList.push_back(rec);
+		}
+	}
+
+	// Sort the list in order of the depth
+	Common::sort(depthList.begin(), depthList.end(), sortHelper);
+
+	// Loop through each of the objects
+	DepthList::iterator i;
+	for (i = depthList.begin(); i != depthList.end(); ++i) {
+		DepthEntry &de = *i;
+		SpriteSlot &slot = (*this)[de.index];
+		assert(slot._spritesIndex < (int)scene._sprites.size());
+		SpriteAsset &spriteSet = *scene._sprites[slot._spritesIndex];
+
+		// Get the sprite frame
+		int frameNumber = slot._frameNumber & 0x7fff;
+		bool flipped = (slot._frameNumber & 0x8000) != 0;
+		MSprite *sprite = spriteSet.getFrame(frameNumber - 1);
+
+		MSurface *spr = sprite;
+		if (flipped) {
+			// Create a flipped copy of the sprite temporarily
+			spr = sprite->flipHorizontal();
+		}
+
+		if ((slot._scale < 100) && (slot._scale != -1)) {
+			// Minimalised drawing
+			s->copyFrom(spr, slot._position, slot._depth, &scene._depthSurface, 
+				slot._scale, sprite->getTransparencyIndex());
+		} else {
+			int xp, yp;
+
+			if (slot._scale == -1) {
+				xp = slot._position.x - scene._posAdjust.x;
+				yp = slot._position.y - scene._posAdjust.y;
+			} else {
+				xp = slot._position.x - (spr->w / 2) - scene._posAdjust.x;
+				yp = slot._position.y - spr->h - scene._posAdjust.y + 1;
+			}
+
+			if (slot._depth > 1) {
+				// Draw the frame with depth processing
+				s->copyFrom(spr, Common::Point(xp, yp), slot._depth, &scene._depthSurface, 
+					100, sprite->getTransparencyIndex());
+			} else {
+				// No depth, so simply draw the image
+				spr->copyTo(s, Common::Point(xp, yp), sprite->getTransparencyIndex());
+			}
+		}
+
+		// Free sprite if it was a flipped one
+		if (flipped)
+			delete spr;
+	}
+}
+
 void SpriteSlots::cleanUp() {
 	for (int i = (int)size() - 1; i >= 0; --i) {
 		if ((*this)[i]._spriteType >= ST_NONE)
@@ -254,6 +341,4 @@ int SpriteSets::add(SpriteAsset *asset, int idx) {
 	return idx;
 }
 
-/*------------------------------------------------------------------------*/
-
 } // End of namespace MADS
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index b1208d0..f9ae46a 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -114,6 +114,8 @@ public:
 	Common::Point _pos;
 	Common::Point _offset;
 	uint8 _encoding;
+
+	byte getTransparencyIndex() const;
 };
 
 class SpriteSlotSubset {
@@ -188,6 +190,11 @@ public:
 	 */
 	void drawBackground();
 
+	/**
+	* Draw any sprites into the foreground of the scene
+	*/
+	void drawForeground(MSurface *s);
+
 	void cleanUp();
 };
 


Commit: a0e955d8d327afa83ad96fe1ce765eeba0ce561f
    https://github.com/scummvm/scummvm/commit/a0e955d8d327afa83ad96fe1ce765eeba0ce561f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-05T20:45:02-05:00

Commit Message:
MADS: More Animation class implementation

Changed paths:
    engines/mads/animation.cpp
    engines/mads/animation.h
    engines/mads/msurface.cpp
    engines/mads/msurface.h
    engines/mads/palette.cpp
    engines/mads/palette.h
    engines/mads/sprites.cpp
    engines/mads/sprites.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index c97d707..d0c7d30 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -27,7 +27,7 @@
 
 namespace MADS {
 	
-AAHeader::AAHeader(Common::SeekableReadStream *f) {
+void AAHeader::load(Common::SeekableReadStream *f) {
 	_spriteSetsCount = f->readUint16LE();
 	_miscEntriesCount = f->readUint16LE();
 	_frameEntriesCount = f->readUint16LE();
@@ -40,7 +40,7 @@ AAHeader::AAHeader(Common::SeekableReadStream *f) {
 	_roomNumber = f->readUint16LE();
 	f->skip(2);
 	_manualFlag = f->readUint16LE() != 0;
-	_spriteListIndex = f->readUint16LE();
+	_spritesIndex = f->readUint16LE();
 	_scrollPosition.x = f->readSint16LE();
 	_scrollPosition.y = f->readSint16LE();
 	_scrollTicks = f->readUint32LE();
@@ -184,33 +184,33 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 	MadsPack madsPack(&f);
 
 	Common::SeekableReadStream *stream = madsPack.getItemStream(0);
-	AAHeader aaHeader(stream);
+	_header.load(stream);
 	delete stream;
 
-	if (aaHeader._animMode == 4)
+	if (_header._animMode == 4)
 		flags |= 0x4000;
 
 	if (flags & 0x100) {
-		loadInterface(interfaceSurface, depthSurface, aaHeader, flags, palAnimData, sceneInfo);
+		loadInterface(interfaceSurface, depthSurface, _header, flags, palAnimData, sceneInfo);
 	}
 	if (flags & 0x200) {
 		// No data
-		aaHeader._messagesCount = 0;
-		aaHeader._frameEntriesCount = 0;
-		aaHeader._miscEntriesCount = 0;
+		_header._messagesCount = 0;
+		_header._frameEntriesCount = 0;
+		_header._miscEntriesCount = 0;
 	}
 
 	// Initialize the reference list
 	_spriteListIndexes.clear();
-	for (int i = 0; i < aaHeader._spriteSetsCount; ++i)
+	for (int i = 0; i < _header._spriteSetsCount; ++i)
 		_spriteListIndexes.push_back(-1);
 
 	_messages.clear();
-	if (aaHeader._messagesCount > 0) {
+	if (_header._messagesCount > 0) {
 		// Chunk 2: Following is a list of any messages for the animation
 		Common::SeekableReadStream *msgStream = madsPack.getItemStream(1);
 
-		for (int i = 0; i < aaHeader._messagesCount; ++i) {
+		for (int i = 0; i < _header._messagesCount; ++i) {
 			AnimMessage rec;
 			rec.load(msgStream);
 			_messages.push_back(rec);
@@ -220,11 +220,11 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 	}
 
 	_frameEntries.clear();
-	if (aaHeader._frameEntriesCount > 0) {
+	if (_header._frameEntriesCount > 0) {
 		// Chunk 3: animation frame info
 		Common::SeekableReadStream *frameStream = madsPack.getItemStream(2);
 
-		for (int i = 0; i < aaHeader._frameEntriesCount; i++) {
+		for (int i = 0; i < _header._frameEntriesCount; i++) {
 			AnimFrameEntry rec;
 			rec.load(frameStream);
 			_frameEntries.push_back(rec);
@@ -234,11 +234,11 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 	}
 	
 	_miscEntries.clear();
-	if (aaHeader._miscEntriesCount > 0) {
+	if (_header._miscEntriesCount > 0) {
 		// Chunk 4: Misc Data
 		Common::SeekableReadStream *miscStream = madsPack.getItemStream(3);
 
-		for (int i = 0; i < aaHeader._miscEntriesCount; ++i) {
+		for (int i = 0; i < _header._miscEntriesCount; ++i) {
 			AnimMiscEntry rec;
 			rec.load(miscStream);
 			_miscEntries.push_back(rec);
@@ -249,8 +249,8 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 	
 	// If the animation specifies a font, then load it for access
 	delete _font;
-	if (aaHeader._flags & ANIM_CUSTOM_FONT) {
-		Common::String fontName = "*" + aaHeader._fontResource;
+	if (_header._flags & ANIM_CUSTOM_FONT) {
+		Common::String fontName = "*" + _header._fontResource;
 		_font = _vm->_font->getFont(fontName.c_str());
 	} else {
 		_font = nullptr;
@@ -260,28 +260,28 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 	for (uint i = 0; i < _spriteSets.size(); ++i)
 		delete _spriteSets[i];
 	_spriteSets.clear();
-	_spriteSets.resize(aaHeader._spriteSetsCount);
+	_spriteSets.resize(_header._spriteSetsCount);
 
-	for (int i = 0; i < aaHeader._spriteSetsCount; ++i) {
-		if (aaHeader._manualFlag && (i == aaHeader._spriteListIndex)) {
+	for (int i = 0; i < _header._spriteSetsCount; ++i) {
+		if (_header._manualFlag && (i == _header._spritesIndex)) {
 			// Skip over field, since it's manually loaded
 			_spriteSets[i] = nullptr;
 		} else {
-			_spriteSets[i] = new SpriteAsset(_vm, aaHeader._spriteSetNames[i], flags);
+			_spriteSets[i] = new SpriteAsset(_vm, _header._spriteSetNames[i], flags);
 		}
 	}
 
-	if (aaHeader._manualFlag) {
-		Common::String resName = "*" + aaHeader._spriteSetNames[aaHeader._spriteListIndex];
+	if (_header._manualFlag) {
+		Common::String resName = "*" + _header._spriteSetNames[_header._spritesIndex];
 		SpriteAsset *sprites = new SpriteAsset(_vm, resName, flags);
-		_spriteSets[aaHeader._spriteListIndex] = sprites;
+		_spriteSets[_header._spritesIndex] = sprites;
 
-		_spriteListIndexes[aaHeader._spriteListIndex] = _scene->_sprites.add(sprites);
+		_spriteListIndexes[_header._spritesIndex] = _scene->_sprites.add(sprites);
 	}
 
 	// TODO: List var_420/var_422 population that seems to overwrite other structures?
 
-	if (aaHeader._animMode == 4) {
+	if (_header._animMode == 4) {
 		// Remaps the sprite list indexes for frames to the loaded sprite list indexes
 		for (uint i = 0; i < _frameEntries.size(); ++i) {
 			int spriteListIndex = _frameEntries[i]._spriteSlot._spritesIndex;
@@ -298,6 +298,33 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 	f.close();
 }
 
+void Animation::loadFrame(int frameNumber) {
+	Scene &scene = _vm->_game->_scene;
+	if (_skipLoad)
+		return;
+
+	Common::Point pt;
+	int listIndex = _spriteListIndexes[_header._spritesIndex];
+	SpriteAsset &spriteSet = scene._spriteSlots.getSprite(listIndex);
+
+	if (_unkIndex < 0) {
+		MSurface *frame = spriteSet.getFrame(0);
+		pt.x = frame->getBounds().left;
+		pt.y = frame->getBounds().top;
+	} else {
+		pt.x = _unkList[_unkIndex].x;
+		pt.y = _unkList[_unkIndex].y;
+		_unkIndex = 1 - _unkIndex;
+	}
+
+	if (drawFrame(spriteSet, pt, frameNumber))
+		error("proc1 failure");
+}
+
+bool Animation::drawFrame(SpriteAsset &spriteSet, const Common::Point &pt, int frameNumber) {
+	return 0;
+}
+
 void Animation::loadInterface(InterfaceSurface &interfaceSurface, MSurface &depthSurface,
 		AAHeader &header, int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo) {
 	_scene->_depthStyle = 0;
@@ -323,8 +350,182 @@ void Animation::loadInterface(InterfaceSurface &interfaceSurface, MSurface &dept
 	}
 }
 
+bool Animation::hasScroll() const { 
+	return (_header._scrollPosition.x != 0) || (_header._scrollPosition.x != 0);
+}
+
 void Animation::update() {
-	warning("TODO: Animation::update");
+	Scene &scene = _vm->_game->_scene;
+
+	if (_header._manualFlag) {
+		int spriteListIndex = _spriteListIndexes[_header._spritesIndex];
+		int newIndex = -1;
+
+		for (uint idx = _oldFrameEntry; idx < _frameEntries.size(); ++idx) {
+			if (_frameEntries[idx]._frameNumber > _currentFrame)
+				break;
+			if (_frameEntries[idx]._spriteSlot._spritesIndex == spriteListIndex)
+				newIndex = _frameEntries[idx]._spriteSlot._frameNumber;
+		}
+
+		if (newIndex >= 0)
+			loadFrame(newIndex);
+	}
+
+	// If it's not time for the next frame, then exit
+	if (_vm->_events->_currentTimer < _nextFrameTimer)
+		return;
+
+	for (uint idx = 0; idx < scene._spriteSlots.size(); ++idx) {
+		if (scene._spriteSlots[idx]._seqIndex >= 0x80)
+			scene._spriteSlots[idx]._spriteType = ST_EXPIRED;
+	}
+
+	// Validate the current frame
+	if (_currentFrame >= (int)_miscEntries.size()) {
+		// Is the animation allowed to be repeated?
+		if (_resetFlag) {
+			_currentFrame = 0;
+			_oldFrameEntry = 0;
+		} else {
+			_freeFlag = true;
+			return;
+		}
+	}
+
+	// Handle executing any sound command for this frame
+	AnimMiscEntry &misc = _miscEntries[_currentFrame];
+	if (misc._soundId)
+		_vm->_sound->command(misc._soundId);
+
+	// Handle any screen scrolling
+	if (hasScroll()) {
+		scene._backgroundSurface.scrollX(_header._scrollPosition.x);
+		scene._backgroundSurface.scrollY(_header._scrollPosition.y);
+		scene._spriteSlots.fullRefresh();
+	}
+	
+	// Handle any offset adjustment for sprites as of this frame
+	bool paChanged = false;
+	if (scene._posAdjust.x != misc._posAdjust.x) {
+		scene._posAdjust.x = misc._posAdjust.x;
+		paChanged = true;
+	}
+	if (scene._posAdjust.y != misc._posAdjust.y) {
+		scene._posAdjust.y = misc._posAdjust.y;
+		paChanged = true;
+	}
+
+	int newIndex = -1;
+	if (paChanged) {
+		newIndex = scene._spriteSlots.getIndex();
+		scene._spriteSlots[newIndex]._seqIndex = -1;
+		scene._spriteSlots[newIndex]._spriteType = ST_FULL_SCREEN_REFRESH;
+	}
+
+	// Main frame animation loop - frames get animated by being placed, as necessary, into the
+	// main sprite slot array
+	while ((uint)_oldFrameEntry < _frameEntries.size()) {
+		if (_frameEntries[_oldFrameEntry]._frameNumber > _currentFrame)
+			break;
+		else if (_frameEntries[_oldFrameEntry]._frameNumber == _currentFrame) {
+			// Found the correct frame
+			int spriteSlotIndex = 0;
+			int index = 0;
+
+			for (;;) {
+				if ((spriteSlotIndex == 0) && (index < (int)scene._spriteSlots.size())) {
+					int seqIndex = _frameEntries[_oldFrameEntry]._seqIndex - scene._spriteSlots[index]._seqIndex;
+					if (seqIndex == 0x80) {
+						if (scene._spriteSlots[index] == _frameEntries[_oldFrameEntry]._spriteSlot) {
+							scene._spriteSlots[index]._spriteType = ST_NONE;
+							spriteSlotIndex = -1;
+						}
+					}
+					++index;
+					continue;
+				}
+
+				if (spriteSlotIndex == 0) {
+					int slotIndex = scene._spriteSlots.getIndex();
+					SpriteSlot &slot = scene._spriteSlots[slotIndex];
+					slot.copy(_frameEntries[_oldFrameEntry]._spriteSlot);
+					slot._seqIndex = _frameEntries[_oldFrameEntry]._seqIndex + 0x80;
+
+					SpriteAsset &spriteSet = scene._spriteSlots.getSprite(
+						scene._spriteSlots[slotIndex]._spritesIndex);
+					slot._spriteType = spriteSet.isBackground() ? ST_BACKGROUND : ST_FOREGROUND;
+				}
+				break;
+			}
+		}
+
+		++_oldFrameEntry;
+	}
+
+	// Handle the display of any messages
+	for (uint idx = 0; idx < _messages.size(); ++idx) {
+		if (_messages[idx]._kernelMsgIndex >= 0) {
+			// Handle currently active message
+			if ((_currentFrame < _messages[idx]._startFrame) || (_currentFrame > _messages[idx]._endFrame)) {
+				scene._kernelMessages.remove(_messages[idx]._kernelMsgIndex);
+				_messages[idx]._kernelMsgIndex = -1;
+				--_messageCtr;
+			}
+		} else if ((_currentFrame >= _messages[idx]._startFrame) && (_currentFrame <= _messages[idx]._endFrame)) {
+			// Start displaying the message
+			AnimMessage &me = _messages[idx];
+
+			// The color index to use is dependant on how many messages are currently on-screen
+			uint8 colIndex;
+			switch (_messageCtr) {
+			case 1:
+				colIndex = 252;
+				break;
+			case 2:
+				colIndex = 16;
+				break;
+			default:
+				colIndex = 250;
+				break;
+			}
+
+			_vm->_palette->setEntry(colIndex, me._rgb1[0], me._rgb1[1], me._rgb1[2]);
+			_vm->_palette->setEntry(colIndex + 1, me._rgb2[0], me._rgb2[1], me._rgb2[2]);
+
+			// Add a kernel message to display the given text
+			me._kernelMsgIndex = scene._kernelMessages.add(me._pos, colIndex * 0x101 + 0x100, 
+				0, 0, INDEFINITE_TIMEOUT, me._msg);
+			assert(me._kernelMsgIndex >= 0);
+			++_messageCtr;
+		}
+	}
+
+	// Move to the next frame
+	_currentFrame++;
+	if (_currentFrame >= (int)_miscEntries.size()) {
+		// Animation is complete
+		if (_abortTimers != 0) {
+			_vm->_game->_abortTimers = _abortTimers;
+			_vm->_game->_abortTimersMode = _abortMode;
+
+			if (_abortMode != ABORTMODE_1) {
+				// Copy the noun list
+				scene._action._action = _actionNouns;
+			}
+		}
+	}
+
+	int frameNum = MIN(_currentFrame, (int)_miscEntries.size() - 1);
+	_nextFrameTimer = _vm->_events->_currentTimer + _miscEntries[frameNum]._numTicks;
+}
+
+void Animation::setCurrentFrame(int frameNumber) {
+	_currentFrame = frameNumber;
+	_oldFrameEntry = 0;
+	_freeFlag = false;
+
+	_nextScrollTimer = _nextFrameTimer = _vm->_events->_currentTimer;
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 9498483..8df7b37 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -90,7 +90,7 @@ public:
 	int _animMode;
 	int _roomNumber;
 	bool _manualFlag;
-	int _spriteListIndex;
+	int _spritesIndex;
 	Common::Point _scrollPosition;
 	uint32 _scrollTicks;
 	Common::String _interfaceFile;
@@ -104,28 +104,57 @@ public:
 	/**
 	 * Loads the data for a animation file header
 	 */
-	AAHeader(Common::SeekableReadStream *f);
+	void load(Common::SeekableReadStream *f);
 };
 
 class Animation {
 private:
 	MADSEngine *_vm;
 	Scene *_scene;
+	AAHeader _header;
 
-	void loadInterface(InterfaceSurface &interfaceSurface, MSurface &depthSurface,
-		AAHeader &header, int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo);
-protected:
-	Animation(MADSEngine *vm, Scene *scene);
-public:
-	static Animation *init(MADSEngine *vm, Scene *scene);
-public:
 	Common::Array<int> _spriteListIndexes;
 	Common::Array<AnimMessage> _messages;
 	Common::Array<AnimFrameEntry> _frameEntries;
 	Common::Array<AnimMiscEntry> _miscEntries;
 	Common::Array<SpriteAsset *> _spriteSets;
 	Font *_font;
+
+	int _currentFrame, _oldFrameEntry;
 	bool _resetFlag;
+	bool _freeFlag;
+	bool _skipLoad;
+	int _unkIndex;
+	Common::Point _unkList[2];
+	uint32 _nextFrameTimer;
+	uint32 _nextScrollTimer;
+	int _messageCtr;
+	int _abortTimers;
+	AbortTimerMode _abortMode;
+	ActionDetails _actionNouns;
+
+	/**
+	 * Load data for a given frame
+	 * @param frameNumber	Frame number
+	 */
+	void loadFrame(int frameNumber);
+
+	bool drawFrame(SpriteAsset &spriteSet, const Common::Point &pt, int frameNumber);
+
+	/**
+	 * Load the user interface display for an animation
+	 */
+	void loadInterface(InterfaceSurface &interfaceSurface, MSurface &depthSurface,
+		AAHeader &header, int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo);
+
+	/**
+	 * Returns true if there is a scroll required
+	 */
+	bool hasScroll() const;
+protected:
+	Animation(MADSEngine *vm, Scene *scene);
+public:
+	static Animation *init(MADSEngine *vm, Scene *scene);
 public:
 	/*
 	 * Destructor
@@ -147,6 +176,13 @@ public:
 	 * Update the animation
 	 */
 	void update();
+
+	virtual void setCurrentFrame(int frameNumber);
+	virtual int getCurrentFrame() const { return _currentFrame; }
+
+	bool freeFlag() const { return _freeFlag; }
+	bool getAnimMode() const { return _header._animMode; }
+	int roomNumber() const { return _header._roomNumber; }
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index aed00f5..754fea8 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -406,6 +406,73 @@ void MSurface::copyFrom(MSurface *src, const Common::Point &destPos, int depth,
 	}
 }
 
+void MSurface::scrollX(int xAmount) {
+	if (xAmount == 0)
+		return;
+
+	byte buffer[80];
+	int direction = (xAmount > 0) ? -1 : 1;
+	int xSize = ABS(xAmount);
+	assert(xSize <= 80);
+
+	byte *srcP = getBasePtr(0, 0);
+
+	for (int y = 0; y < this->h; ++y, srcP += pitch) {
+		if (direction < 0) {
+			// Copy area to be overwritten
+			Common::copy(srcP, srcP + xSize, &buffer[0]);
+			// Shift the remainder of the line over the given area
+			Common::copy(srcP + xSize, srcP + this->w, srcP);
+			// Move buffered area to the end of the line
+			Common::copy(&buffer[0], &buffer[xSize], srcP + this->w - xSize);
+		}
+		else {
+			// Copy area to be overwritten
+			Common::copy_backward(srcP + this->w - xSize, srcP + this->w, &buffer[80]);
+			// Shift the remainder of the line over the given area
+			Common::copy_backward(srcP, srcP + this->w - xSize, srcP + this->w);
+			// Move buffered area to the start of the line
+			Common::copy_backward(&buffer[80 - xSize], &buffer[80], srcP + xSize);
+		}
+	}
+}
+
+void MSurface::scrollY(int yAmount) {
+	if (yAmount == 0)
+		return;
+
+	int direction = (yAmount > 0) ? 1 : -1;
+	int ySize = ABS(yAmount);
+	assert(ySize < (this->h / 2));
+	assert(this->w == pitch);
+
+	int blockSize = ySize * this->w;
+	byte *tempData = new byte[blockSize];
+	byte *pixelsP = getBasePtr(0, 0);
+
+	if (direction > 0) {
+		// Buffer the lines to be overwritten
+		byte *srcP = (byte *)getBasePtr(0, this->h - ySize);
+		Common::copy(srcP, srcP + (pitch * ySize), tempData);
+		// Vertically shift all the lines
+		Common::copy_backward(pixelsP, pixelsP + (pitch * (this->h - ySize)),
+			pixelsP + (pitch * this->h));
+		// Transfer the buffered lines top the top of the screen
+		Common::copy(tempData, tempData + blockSize, pixelsP);
+	}
+	else {
+		// Buffer the lines to be overwritten
+		Common::copy(pixelsP, pixelsP + (pitch * ySize), tempData);
+		// Vertically shift all the lines
+		Common::copy(pixelsP + (pitch * ySize), pixelsP + (pitch * this->h), pixelsP);
+		// Transfer the buffered lines to the bottom of the screen
+		Common::copy(tempData, tempData + blockSize, pixelsP + (pitch * (this->h - ySize)));
+	}
+
+	delete[] tempData;
+}
+
+
 void MSurface::translate(Common::Array<RGB6> &palette) {
 	for (int y = 0; y < this->h; ++y) {
 		byte *pDest = getBasePtr(0, y);
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index c797033..bd8142f 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -180,6 +180,18 @@ public:
 	}
 
 	/**
+	 * Scroll the screen horizontally by a given amount
+	 * @param xAmount	Horizontal amount
+	 */
+	void scrollX(int xAmount);
+
+	/**
+	 * Scroll the screen vertically by a given amount
+	 * @param yAmount	Vertical amount
+	 */
+	void scrollY(int yAmount);
+
+	/**
 	 * Translates the pixels of an image used the passed palette with RGB mapping
 	 */
 	void translate(Common::Array<RGB6> &palette);
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index aca1298..4568f7d 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -180,6 +180,15 @@ void Palette::setPalette(const byte *colors, uint start, uint num) {
 	reset();
 }
 
+void Palette::setEntry(byte palIndex, byte r, byte g, byte b) {
+	_mainPalette[palIndex * 3] = r;
+	_mainPalette[palIndex * 3 + 1] = g;
+	_mainPalette[palIndex * 3 + 2] = b;
+
+	setPalette((const byte *)&_mainPalette[palIndex * 3], palIndex, 1);
+}
+
+
 void Palette::grabPalette(byte *colors, uint start, uint num) {
 	g_system->getPaletteManager()->grabPalette(colors, start, num);
 	reset();
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 18b058c..a00e178 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -165,6 +165,11 @@ public:
 	void setPalette(const byte *colors, uint start, uint num);
 
 	/**
+	 * Set a palette entry
+	 */
+	void setEntry(byte palIndex, byte r, byte g, byte b);
+
+	/**
 	 * Returns a subset of the currently loaded palette
 	 */
 	void grabPalette(byte *colors, uint start, uint num);
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index aa15f66..23360b0 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -149,6 +149,20 @@ SpriteSlot::SpriteSlot(SpriteType type, int seqIndex) {
 	_scale = 0;
 }
 
+bool SpriteSlot::operator==(const SpriteSlotSubset &other) const {
+	return (_spritesIndex == other._spritesIndex) && (_frameNumber == other._frameNumber) &&
+		(_position == other._position) && (_depth == other._depth) && 
+		(_scale == other._scale);
+}
+
+void SpriteSlot::copy(const SpriteSlotSubset &other) {
+	_spritesIndex = other._spritesIndex;
+	_frameNumber = other._frameNumber;
+	_position = other._position;
+	_depth = other._depth;
+	_scale = other._scale;
+}
+
 /*------------------------------------------------------------------------*/
 
 SpriteSlots::SpriteSlots(MADSEngine *vm) : _vm(vm) {
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index f9ae46a..49f13ad 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -139,6 +139,8 @@ public:
 	SpriteSlot(SpriteType type, int seqIndex);
 
 	void setup(int dirtyAreaIndex);
+	bool operator==(const SpriteSlotSubset &other) const;
+	void copy(const SpriteSlotSubset &other);
 };
 
 class SpriteSlots : public Common::Array<SpriteSlot> {


Commit: 73a7140be775693533db183f353fc9c82c14fa53
    https://github.com/scummvm/scummvm/commit/73a7140be775693533db183f353fc9c82c14fa53
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-05T21:36:02-05:00

Commit Message:
MADS: Starting implementation of scene group 8

Changed paths:
    engines/mads/game.h
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/nebular/nebular_scenes8.h
    engines/mads/player.h
    engines/mads/resources.cpp
    engines/mads/resources.h
    engines/mads/scene.cpp
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/game.h b/engines/mads/game.h
index 5330cd3..aa3c385 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -65,7 +65,6 @@ protected:
 	int _v5;
 	int _v6;
 	bool _updateSceneFlag;
-	Common::String _aaName;
 	bool _playerSpritesFlag;
 	int _objectHiliteVocabIdx;
 
@@ -117,6 +116,7 @@ public:
 	AbortTimerMode _abortTimersMode;
 	AbortTimerMode _abortTimersMode2;
 	uint32 _priorFrameTimer;
+	Common::String _aaName;
 public:
 	virtual ~Game();
 
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index efd831a..e1dec2c 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -31,17 +31,19 @@ namespace MADS {
 
 namespace Nebular {
 
-SceneLogic *SceneFactory::createScene(Scene *scene) {
-	scene->addActiveVocab(NOUN_DROP);
-	scene->addActiveVocab(NOUN_DOLLOP);
-	scene->addActiveVocab(NOUN_DASH);
-	scene->addActiveVocab(NOUN_SPLASH);
-	scene->addActiveVocab(NOUN_ALCOHOL);
+SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
+	Scene &scene = vm->_game->_scene;
+
+	scene.addActiveVocab(NOUN_DROP);
+	scene.addActiveVocab(NOUN_DOLLOP);
+	scene.addActiveVocab(NOUN_DASH);
+	scene.addActiveVocab(NOUN_SPLASH);
+	scene.addActiveVocab(NOUN_ALCOHOL);
 
 	// TODO: Implement all the game scenes
-	assert(scene->_nextSceneId == 804);
+	assert(scene._nextSceneId == 804);
 
-	return new Scene804(scene);
+	return new Scene804(vm);
 }
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 28d24f0..1997202 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -31,6 +31,10 @@ namespace MADS {
 
 namespace Nebular {
 
+enum {
+	SEX_MALE = 0, SEX_FEMALE = 2
+};
+
 enum Noun {
 	NOUN_BLOWGUN		= 0x29,
 	NOUN_BURGER			= 0x35,
@@ -81,7 +85,7 @@ enum Noun {
 
 class SceneFactory {
 public:
-	static SceneLogic *createScene(Scene *scene);
+	static SceneLogic *createScene(MADSEngine *vm);
 };
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 8feabc8..ee06dd0 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -21,12 +21,36 @@
  */
 
 #include "common/scummsys.h"
+#include "mads/mads.h"
+#include "mads/scene.h"
+#include "mads/nebular/nebular_scenes.h"
 #include "mads/nebular/nebular_scenes8.h"
 
 namespace MADS {
 
 namespace Nebular {
 
+void Scene8xx::setup1() {
+	_vm->_sound->command(5);
+	if ((_vm->_game->_globalFlags[178] && !_vm->_game->_globalFlags[179]) ||
+			_scene->_nextSceneId == 804 || _scene->_nextSceneId == 805 ||
+			_scene->_nextSceneId == 808 || _scene->_nextSceneId == 810) {
+		_vm->_game->_player._spritesPrefix = "";
+	} else {
+		_vm->_game->_player._spritesPrefix = _vm->_game->_globalFlags[0] 
+			== SEX_FEMALE ? "ROX" : "RXM";
+	}
+
+	_vm->_palette->setEntry(16, 0x0A, 0x3F, 0x3F);
+	_vm->_palette->setEntry(17, 0x0A, 0x2D, 0x2D);
+}
+
+void Scene8xx::setup2() {
+	_vm->_game->_aaName = Resources::formatAAName(5);
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene804::setup() {
 }
 
diff --git a/engines/mads/nebular/nebular_scenes8.h b/engines/mads/nebular/nebular_scenes8.h
index 11bb8b0..3f5d274 100644
--- a/engines/mads/nebular/nebular_scenes8.h
+++ b/engines/mads/nebular/nebular_scenes8.h
@@ -31,9 +31,24 @@ namespace MADS {
 
 namespace Nebular {
 
-class Scene804: public SceneLogic {
+class Scene8xx : public SceneLogic {
+protected:
+	/**
+	 * Initial setup code shared by several scenes
+	 */
+	void setup1();
+
+	/**
+	* Initial setup code shared by several scenes
+	*/
+	void setup2();
 public:
-	Scene804(Scene *scene): SceneLogic(scene) {}
+	Scene8xx(MADSEngine *vm) : SceneLogic(vm) {}
+};
+
+class Scene804: public Scene8xx {
+public:
+	Scene804(MADSEngine *vm) : Scene8xx(vm) {}
 
 	virtual void setup();
 
diff --git a/engines/mads/player.h b/engines/mads/player.h
index cff1313..896b8d5 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -65,6 +65,7 @@ public:
 	uint32 _priorTimer;
 	int _unk3;
 	bool _forceRefresh;
+	Common::String _spritesPrefix;
 public:
 	Player(MADSEngine *vm);
 
diff --git a/engines/mads/resources.cpp b/engines/mads/resources.cpp
index 8cfc1a2..5e490c2 100644
--- a/engines/mads/resources.cpp
+++ b/engines/mads/resources.cpp
@@ -303,6 +303,47 @@ Common::String Resources::formatName(RESPREFIX resType, int id, const Common::St
 	return result;
 }
 
+Common::String Resources::formatName(int prefix, char asciiCh, int id, EXTTYPE extType,
+		const Common::String &suffix) {
+	Common::String result;
+	if (prefix <= 0) {
+		result = "*";
+	}
+	else {
+		result = Common::String::format("%s%.3d",
+			(prefix < 100) ? "*SC" : "*RM", prefix);
+	}
+
+	result += Common::String::format("%c%d", asciiCh, id);
+	if (!suffix.empty())
+		result += suffix;
+
+	switch (extType) {
+	case EXT_SS:
+		result += ".SS";
+		break;
+	case EXT_AA:
+		result += ".AA";
+		break;
+	case EXT_DAT:
+		result += ".DAT";
+		break;
+	case EXT_HH:
+		result += ".HH";
+		break;
+	case EXT_ART:
+		result += ".ART";
+		break;
+	case EXT_INT:
+		result += ".INT";
+		break;
+	default:
+		break;
+	}
+
+	return result;
+}
+
 Common::String Resources::formatResource(const Common::String &resName, 
 		const Common::String &hagFilename) {
 //	int v1 = 0, v2 = 0;
@@ -316,6 +357,10 @@ Common::String Resources::formatResource(const Common::String &resName,
 	}
 }
 
+Common::String Resources::formatAAName(int idx) {
+	return formatName(0, 'I', idx, EXT_AA, "");
+}
+
 /*------------------------------------------------------------------------*/
 
 void File::openFile(const Common::String &filename) {
diff --git a/engines/mads/resources.h b/engines/mads/resources.h
index 8fed0ab..01f6490 100644
--- a/engines/mads/resources.h
+++ b/engines/mads/resources.h
@@ -47,7 +47,10 @@ public:
 	static void init(MADSEngine *vm);
 
 	static Common::String formatName(RESPREFIX resType, int id, const Common::String &ext);
+	static Common::String formatName(int prefix, char asciiCh, int id,
+		EXTTYPE extType, const Common::String &suffix);
 	static Common::String formatResource(const Common::String &resName, const Common::String &hagFilename);
+	static Common::String formatAAName(int idx);
 };
 
 /**
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 7359562..b285229 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -107,7 +107,7 @@ void Scene::loadSceneLogic() {
 
 	switch (_vm->getGameID()) {
 	case GType_RexNebular:
-		_sceneLogic = Nebular::SceneFactory::createScene(this);
+		_sceneLogic = Nebular::SceneFactory::createScene(_vm);
 		break;
 	default:
 		error("Unknown game");
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 00632f6..58fa36e 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -715,4 +715,10 @@ void SceneInfoNebular::loadCodes(MSurface &depthSurface) {
 	f.close();
 }
 
+/*------------------------------------------------------------------------*/
+
+SceneLogic::SceneLogic(MADSEngine *vm) : _vm(vm) {
+	_scene = &_vm->_game->_scene;
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index ce785e7..c4b6610 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -207,12 +207,13 @@ public:
 
 class SceneLogic {
 protected:
+	MADSEngine *_vm;
 	Scene *_scene;
 public:
 	/**
 	 * Constructor
 	 */
-	SceneLogic(Scene *scene): _scene(scene) {}
+	SceneLogic(MADSEngine *vm);
 
 	/**
 	 * Destructor


Commit: c35271f20c82d35e613246779ada14fc79ee6c0a
    https://github.com/scummvm/scummvm/commit/c35271f20c82d35e613246779ada14fc79ee6c0a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-05T21:50:12-05:00

Commit Message:
MADS: Moved hotspot code to a separate file

Changed paths:
  A engines/mads/hotspots.cpp
  A engines/mads/hotspots.h
    engines/mads/module.mk
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
new file mode 100644
index 0000000..340ad7d
--- /dev/null
+++ b/engines/mads/hotspots.cpp
@@ -0,0 +1,128 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 "mads/mads.h"
+#include "mads/hotspots.h"
+
+namespace MADS {
+
+DynamicHotspot::DynamicHotspot() {
+	_seqIndex = 0;
+	_facing = 0;
+	_descId = 0;
+	_field14 = 0;
+	_articleNumber = 0;
+	_cursor = CURSOR_NONE;
+}
+
+/*------------------------------------------------------------------------*/
+
+DynamicHotspots::DynamicHotspots(MADSEngine *vm) : _vm(vm) {
+	for (int i = 0; i < DYNAMIC_HOTSPOTS_SIZE; ++i) {
+		DynamicHotspot rec;
+		rec._active = false;
+		_entries.push_back(rec);
+	}
+
+	_changed = true;
+	_count = 0;
+}
+
+int DynamicHotspots::add(int descId, int field14, int seqIndex, const Common::Rect &bounds) {
+	// Find a free slot
+	uint idx = 0;
+	while ((idx < _entries.size()) && _entries[idx]._active)
+		++idx;
+	if (idx == _entries.size())
+		error("DynamicHotspots overflow");
+
+	_entries[idx]._active = true;
+	_entries[idx]._descId = descId;
+	_entries[idx]._seqIndex = seqIndex;
+	_entries[idx]._bounds = bounds;
+	_entries[idx]._feetPos.x = -3;
+	_entries[idx]._feetPos.y = 0;
+	_entries[idx]._facing = 5;
+	_entries[idx]._field14 = field14;
+	_entries[idx]._articleNumber = 6;
+	_entries[idx]._cursor = CURSOR_NONE;
+
+	++_count;
+	_changed = true;
+
+	if (seqIndex >= 0)
+		_vm->_game->_scene._sequences[seqIndex]._dynamicHotspotIndex = idx;
+
+	return idx;
+}
+
+int DynamicHotspots::setPosition(int index, int xp, int yp, int facing) {
+	if (index >= 0) {
+		_entries[index]._feetPos.x = xp;
+		_entries[index]._feetPos.y = yp;
+		_entries[index]._facing = facing;
+	}
+
+	return index;
+}
+
+int DynamicHotspots::setCursor(int index, CursorType cursor) {
+	if (index >= 0)
+		_entries[index]._cursor = cursor;
+
+	return index;
+}
+
+void DynamicHotspots::remove(int index) {
+	Scene &scene = _vm->_game->_scene;
+
+	if (_entries[index]._active) {
+		if (_entries[index]._seqIndex >= 0)
+			scene._sequences[_entries[index]._seqIndex]._dynamicHotspotIndex = -1;
+		_entries[index]._active = false;
+
+		--_count;
+		_changed = true;
+	}
+}
+
+void DynamicHotspots::clear() {
+	for (uint i = 0; i < _entries.size(); ++i)
+		_entries[i]._active = false;
+
+	_changed = false;
+	_count = 0;
+}
+
+void DynamicHotspots::reset() {
+	for (uint i = 0; i < _entries.size(); ++i)
+		remove(i);
+
+	_count = 0;
+	_changed = false;
+}
+
+void DynamicHotspots::refresh() {
+	error("DynamicHotspots::refresh");
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/hotspots.h b/engines/mads/hotspots.h
new file mode 100644
index 0000000..acbc72d
--- /dev/null
+++ b/engines/mads/hotspots.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_HOTSPOTS_H
+#define MADS_HOTSPOTS_H
+
+#include "common/scummsys.h"
+#include "mads/events.h"
+
+namespace MADS {
+
+class MADSEngine;
+
+
+class DynamicHotspot {
+public:
+	bool _active;
+	int _seqIndex;
+	Common::Rect _bounds;
+	Common::Point _feetPos;
+	int _facing;
+	int _descId;
+	int _field14;
+	int _articleNumber;
+	CursorType _cursor;
+
+	DynamicHotspot();
+};
+
+#define DYNAMIC_HOTSPOTS_SIZE 8
+
+class DynamicHotspots {
+private:
+	MADSEngine *_vm;
+	Common::Array<DynamicHotspot> _entries;
+	int _count;
+public:
+	bool _changed;
+public:
+	DynamicHotspots(MADSEngine *vm);
+
+	DynamicHotspot &operator[](uint idx) { return _entries[idx]; }
+	int add(int descId, int field14, int seqIndex, const Common::Rect &bounds);
+	int setPosition(int index, int xp, int yp, int facing);
+	int setCursor(int index, CursorType cursor);
+	void remove(int index);
+	void clear();
+	void reset();
+	void refresh();
+};
+
+class Hotspot {
+public:
+	Common::Rect _bounds;
+	Common::Point _feetPos;
+	int _facing;
+	int _articleNumber;
+	CursorType _cursor;
+	int _vocabId;
+	int _verbId;
+
+	Hotspot();
+	Hotspot(Common::SeekableReadStream &f);
+};
+
+
+} // End of namespace MADS
+
+#endif	/* MADS_HOTSPOTS_H */
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 6a44621..7197a60 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -18,6 +18,7 @@ MODULE_OBJS := \
 	game.o \
 	game_data.o \
 	graphics.o \
+	hotspots.o \
 	interface.o \
 	mads.o \
 	messages.o \
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index d9bc15a..f31927d 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -27,6 +27,7 @@
 #include "common/array.h"
 #include "common/rect.h"
 #include "mads/assets.h"
+#include "mads/hotspots.h"
 #include "mads/messages.h"
 #include "mads/msurface.h"
 #include "mads/scene_data.h"
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 58fa36e..813e906 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -294,108 +294,6 @@ void DirtyAreas::reset() {
 
 /*------------------------------------------------------------------------*/
 
-DynamicHotspot::DynamicHotspot() {
-	_seqIndex = 0;
-	_facing = 0;
-	_descId = 0;
-	_field14 = 0;
-	_articleNumber = 0;
-	_cursor = CURSOR_NONE;
-}
-
-/*------------------------------------------------------------------------*/
-
-DynamicHotspots::DynamicHotspots(MADSEngine *vm): _vm(vm) {
-	for (int i = 0; i < DYNAMIC_HOTSPOTS_SIZE; ++i) {
-		DynamicHotspot rec;
-		rec._active = false;
-		_entries.push_back(rec);
-	}
-
-	_changed = true;
-	_count = 0;
-}
-
-int DynamicHotspots::add(int descId, int field14, int seqIndex, const Common::Rect &bounds) {
-	// Find a free slot
-	uint idx = 0;
-	while ((idx < _entries.size()) && _entries[idx]._active)
-		++idx;
-	if (idx == _entries.size())
-		error("DynamicHotspots overflow");
-
-	_entries[idx]._active = true;
-	_entries[idx]._descId = descId;
-	_entries[idx]._seqIndex = seqIndex;
-	_entries[idx]._bounds = bounds;
-	_entries[idx]._feetPos.x = -3;
-	_entries[idx]._feetPos.y = 0;
-	_entries[idx]._facing = 5;
-	_entries[idx]._field14 = field14;
-	_entries[idx]._articleNumber = 6;
-	_entries[idx]._cursor = CURSOR_NONE;
-
-	++_count;
-	_changed = true;
-
-	if (seqIndex >= 0)
-		_vm->_game->_scene._sequences[seqIndex]._dynamicHotspotIndex = idx;
-
-	return idx;
-}
-
-int DynamicHotspots::setPosition(int index, int xp, int yp, int facing) {
-	if (index >= 0) {
-		_entries[index]._feetPos.x = xp;
-		_entries[index]._feetPos.y = yp;
-		_entries[index]._facing = facing;
-	}
-
-	return index;
-}
-
-int DynamicHotspots::setCursor(int index, CursorType cursor) {
-	if (index >= 0)
-		_entries[index]._cursor = cursor;
-
-	return index;
-}
-
-void DynamicHotspots::remove(int index) {
-	Scene &scene = _vm->_game->_scene;
-
-	if (_entries[index]._active) {
-		if (_entries[index]._seqIndex >= 0)
-			scene._sequences[_entries[index]._seqIndex]._dynamicHotspotIndex = -1;
-		_entries[index]._active = false;
-
-		--_count;
-		_changed = true;
-	}
-}
-
-void DynamicHotspots::clear() {
-	for (uint i = 0; i < _entries.size(); ++i)
-		_entries[i]._active = false;
-
-	_changed = false;
-	_count = 0;
-}
-
-void DynamicHotspots::reset() {
-	for (uint i = 0; i < _entries.size(); ++i)
-		remove(i);
-
-	_count = 0;
-	_changed = false;
-}
-
-void DynamicHotspots::refresh() {
-	error("DynamicHotspots::refresh");
-}
-
-/*------------------------------------------------------------------------*/
-
 KernelMessage::KernelMessage() {
 	_flags = 0;
 	_sequenceIndex = 0;
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index c4b6610..4d8cfc7 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -113,57 +113,6 @@ public:
 	void check(bool scanFlag);
 };
 
-class DynamicHotspot {
-public:
-	bool _active;
-	int _seqIndex;
-	Common::Rect _bounds;
-	Common::Point _feetPos;
-	int _facing;
-	int _descId;
-	int _field14;
-	int _articleNumber;
-	CursorType _cursor;
-
-	DynamicHotspot();
-};
-
-#define DYNAMIC_HOTSPOTS_SIZE 8
-
-class DynamicHotspots {
-private:
-	MADSEngine *_vm;
-	Common::Array<DynamicHotspot> _entries;
-	int _count;
-public:
-	bool _changed;
-public:
-	DynamicHotspots(MADSEngine *vm);
-
-	DynamicHotspot &operator[](uint idx) { return _entries[idx]; }
-	int add(int descId, int field14, int seqIndex, const Common::Rect &bounds);
-	int setPosition(int index, int xp, int yp, int facing);
-	int setCursor(int index, CursorType cursor);
-	void remove(int index);
-	void clear();
-	void reset();
-	void refresh();
-};
-
-class Hotspot {
-public:
-	Common::Rect _bounds;
-	Common::Point _feetPos;
-	int _facing;
-	int _articleNumber;
-	CursorType _cursor;
-	int _vocabId;
-	int _verbId;
-
-	Hotspot();
-	Hotspot(Common::SeekableReadStream &f);
-};
-
 class DirtyArea {
 private:
 	static MADSEngine *_vm;


Commit: 2d9bb392aeef7beab60986a57889eb38001407ef
    https://github.com/scummvm/scummvm/commit/2d9bb392aeef7beab60986a57889eb38001407ef
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-05T21:57:38-05:00

Commit Message:
MADS: Implemented missing hotspot method

Changed paths:
    engines/mads/hotspots.cpp



diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
index 340ad7d..a3660df 100644
--- a/engines/mads/hotspots.cpp
+++ b/engines/mads/hotspots.cpp
@@ -122,7 +122,21 @@ void DynamicHotspots::reset() {
 }
 
 void DynamicHotspots::refresh() {
-	error("DynamicHotspots::refresh");
+	for (uint i = 0; i < _entries.size(); ++i) {
+		DynamicHotspot &dh = (*this)[i];
+
+		if ((*this)[i]._active) {
+			switch (_vm->_game->_scene._screenObjects._v832EC) {
+			case 0:
+			case 2:
+				_vm->_game->_scene._screenObjects.add(dh._bounds, CAT_12, dh._descId);
+				_vm->_game->_scene._screenObjects._v8333C = true;
+				break;
+			default:
+				break;
+			}
+		}
+	}
 }
 
 } // End of namespace MADS


Commit: c9186f51b9502a4cfb1881f2db4f92eeb6227144
    https://github.com/scummvm/scummvm/commit/c9186f51b9502a4cfb1881f2db4f92eeb6227144
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-06T20:30:05-05:00

Commit Message:
MADS: Added in Rex Nebular globals class

Changed paths:
  A engines/mads/nebular/globals_nebular.cpp
  A engines/mads/nebular/globals_nebular.h
  A engines/mads/nebular/nebular_scenes1.cpp
  A engines/mads/nebular/nebular_scenes1.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/messages.cpp
    engines/mads/module.mk
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/game_nebular.h
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/nebular/nebular_scenes8.h
    engines/mads/scene.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 025cf8d..b64c59c 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -66,14 +66,14 @@ Game::~Game() {
 }
 
 void Game::run() {
+	initialiseGlobals();
+
 	_statusFlag = true;
 	int protectionResult = checkCopyProtection();
 	switch (protectionResult) {
 	case 1:
 		// Copy protection failed
 		_scene._nextSceneId = 804;
-		initialiseGlobals();
-		_globalFlags[5] = 0xFFFF;
 		_saveSlot = -1;
 		break;
 	case 2:
@@ -253,11 +253,7 @@ void Game::sectionLoop() {
 		// TODO: sub_1DD46(3)
 
 		// Check whether to show a dialog
-		if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globalFlags[5]) {
-			_scene._spriteSlots.releasePlayerSprites();
-			_vm->_dialogs->showDialog();
-			_vm->_dialogs->_pendingDialog = DIALOG_NONE;
-		}
+		checkShowDialog();
 	}
 }
 
diff --git a/engines/mads/game.h b/engines/mads/game.h
index aa3c385..0cd46b6 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -97,6 +97,12 @@ protected:
 	 * Set up the section handler specific to each section
 	 */
 	virtual void setSectionHandler() = 0;
+
+	/**
+	 * Checks for whether to show a dialog
+	 */
+	virtual void checkShowDialog() = 0;
+
 	//@}
 
 public:
@@ -106,7 +112,6 @@ public:
 	int _sectionNumber;
 	int _priorSectionNumber;
 	int _currentSectionNumber;
-	Common::Array<uint16> _globalFlags;
 	InventoryObjects _objects;
 	Scene _scene;
 	int _v2;
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index fcf0395..c6d2e2e 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -42,6 +42,7 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :
 	_invObjectStill = false;
 	_textWindowStill = false;
 	_screenFade = SCREEN_FADE_FAST;
+	_musicFlag = false;
 
 	_debugger = nullptr;
 	_dialogs = nullptr;
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index abe6e79..2fbac32 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -105,6 +105,7 @@ public:
 	bool _invObjectStill;
 	bool _textWindowStill;
 	ScreenFade _screenFade;
+	bool _musicFlag;
 public:
 	MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc);
 	virtual ~MADSEngine();
diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index 11db00f..33a6a8e 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -37,7 +37,6 @@ KernelMessages::KernelMessages(MADSEngine *vm): _vm(vm) {
 		_entries.push_back(rec);
 	}
 
-	scene._textSpacing = -1;
 	_talkFont = _vm->_font->getFont(FONT_CONVERSATION);
 	word_8469E = 0;
 }
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 7197a60..2f4982f 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -3,6 +3,7 @@ MODULE := engines/mads
 MODULE_OBJS := \
 	nebular/dialogs_nebular.o \
 	nebular/game_nebular.o \
+	nebular/globals_nebular.o \
 	nebular/sound_nebular.o \
 	nebular/nebular_scenes.o \
 	nebular/nebular_scenes8.o \
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index c55abf5..c18561b 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -28,6 +28,7 @@
 #include "mads/msurface.h"
 #include "mads/nebular/game_nebular.h"
 #include "mads/nebular/dialogs_nebular.h"
+#include "mads/nebular/globals_nebular.h"
 
 namespace MADS {
 
@@ -38,6 +39,9 @@ GameNebular::GameNebular(MADSEngine *vm): Game(vm) {
 }
 
 int GameNebular::checkCopyProtection() {
+	// DEBUG: Flag copy protection failure
+	_globals[5] = 0xFFFF;
+	
 	if (!ConfMan.getBool("copy_protection"))
 		return true;
 
@@ -52,32 +56,27 @@ int GameNebular::checkCopyProtection() {
 }
 
 void GameNebular::initialiseGlobals() {
-	// Allocate globals space
-	_globalFlags.resize(210);
-	for (int i = 0; i < 210; ++i)
-		_globalFlags[i] = 0;
-
 	// Set specific values needed by the game
-	_globalFlags[4] = 8;
-	_globalFlags[33] = 1;
-	_globalFlags[10] = 0xFFFF;
-	_globalFlags[13] = 0xFFFF;
-	_globalFlags[15] = 0xFFFF;
-	_globalFlags[19] = 0xFFFF;
-	_globalFlags[20] = 0xFFFF;
-	_globalFlags[21] = 0xFFFF;
-	_globalFlags[95] = 0xFFFF;
+	_globals[4] = 8;
+	_globals[33] = 1;
+	_globals[10] = 0xFFFF;
+	_globals[13] = 0xFFFF;
+	_globals[15] = 0xFFFF;
+	_globals[19] = 0xFFFF;
+	_globals[20] = 0xFFFF;
+	_globals[21] = 0xFFFF;
+	_globals[95] = 0xFFFF;
 
 	_objects.setData(3, 17, nullptr);
 
 	// Put the values 0 through 3 in a random order in global slots 83 to 86
 	for (int i = 0; i < 4;) {
 		int randomVal = _vm->getRandomNumber(3);
-		_globalFlags[83 + i] = randomVal;
+		_globals[83 + i] = randomVal;
 
 		bool flag = false;
 		for (int idx2 = 0; idx2 < i; ++idx2) {
-			if (_globalFlags[83 + idx2] == randomVal)
+			if (_globals[83 + idx2] == randomVal)
 				flag = true;
 		}
 
@@ -88,11 +87,11 @@ void GameNebular::initialiseGlobals() {
 	// Put the values 0 through 3 in a random order in global slots 87 to 90
 	for (int i = 0; i < 4;) {
 		int randomVal = _vm->getRandomNumber(3);
-		_globalFlags[87 + i] = randomVal;
+		_globals[87 + i] = randomVal;
 
 		bool flag = false;
 		for (int idx2 = 0; idx2 < i; ++idx2) {
-			if (_globalFlags[87 + idx2] == randomVal)
+			if (_globals[87 + idx2] == randomVal)
 				flag = true;
 		}
 
@@ -100,20 +99,20 @@ void GameNebular::initialiseGlobals() {
 			++i;
 	}
 
-	_globalFlags[120] = 501;
-	_globalFlags[121] = 0xFFFF;
-	_globalFlags[55] = 0xFFFF;
-	_globalFlags[119] = 1;
-	_globalFlags[134] = 4;
+	_globals[120] = 501;
+	_globals[121] = 0xFFFF;
+	_globals[55] = 0xFFFF;
+	_globals[119] = 1;
+	_globals[134] = 4;
 
 	// Fill out the globals 200 to 209 with unique random values less than 10000
 	for (int i = 0; i < 10; ++i) {
 		int randomVal = _vm->getRandomNumber(9999);
-		_globalFlags[200 + i] = randomVal;
+		_globals[200 + i] = randomVal;
 
 		bool flag = false;
 		for (int idx2 = 0; idx2 < i; ++idx2) {
-			if (_globalFlags[200 + idx2] == randomVal)
+			if (_globals[200 + idx2] == randomVal)
 				flag = true;
 		}
 
@@ -124,20 +123,20 @@ void GameNebular::initialiseGlobals() {
 	// Difficulty level control
 	switch (_difficultyLevel) {
 	case DIFFICULTY_HARD:
-		_globalFlags[35] = 0;
+		_globals[35] = 0;
 		_objects.setRoom(9, 1);
 		_objects.setRoom(50, 1);
-		_globalFlags[137] = 5;
-		_globalFlags[136] = 0;
+		_globals[137] = 5;
+		_globals[136] = 0;
 		break;
 	case DIFFICULTY_MEDIUM:
-		_globalFlags[35] = 0;
+		_globals[35] = 0;
 		_objects.setRoom(8, 1);
-		_globalFlags[137] = 0xFFFF;
-		_globalFlags[136] = 6;
+		_globals[137] = 0xFFFF;
+		_globals[136] = 6;
 		break;
 	case DIFFICULTY_EASY:
-		_globalFlags[35] = 2;
+		_globals[35] = 2;
 		_objects.setRoom(8, 1);
 		_objects.setRoom(27, 1);
 		break;
@@ -185,6 +184,14 @@ void GameNebular::setSectionHandler() {
 	}
 }
 
+void GameNebular::checkShowDialog() {
+	if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globals[5]) {
+		_scene._spriteSlots.releasePlayerSprites();
+		_vm->_dialogs->showDialog();
+		_vm->_dialogs->_pendingDialog = DIALOG_NONE;
+	}
+}
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index 6395ba0..0250f66 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "mads/game.h"
+#include "mads/nebular/globals_nebular.h"
 
 namespace MADS {
 
@@ -40,6 +41,11 @@ protected:
 	virtual void initialiseGlobals();
 
 	virtual void setSectionHandler();
+
+	virtual void checkShowDialog();
+
+public:
+	Globals _globals;
 };
 
 
diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp
new file mode 100644
index 0000000..20789cd
--- /dev/null
+++ b/engines/mads/nebular/globals_nebular.cpp
@@ -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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/scummsys.h"
+#include "common/config-manager.h"
+#include "mads/nebular/globals_nebular.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+Globals::Globals() {
+	// Initialise global flags
+	_flags.resize(210);
+	for (int i = 0; i < 210; ++i)
+		_flags[i] = 0;
+
+	// Initialise game flags
+	_chairHotspotIndex = 0;
+	_v1 = 0;
+	_v2 = 0;
+	_v3 = 0;
+	_v4 = 0;
+	_v5 = 0;
+	_v6 = 0;
+	_v7 = 0;
+	_v8 = 0;
+}
+
+} // End of namespace Nebular
+
+} // End of namespace MADS
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
new file mode 100644
index 0000000..0d8da78
--- /dev/null
+++ b/engines/mads/nebular/globals_nebular.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_GLOBALS_NEBULAR_H
+#define MADS_GLOBALS_NEBULAR_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+#include "mads/game.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+class Globals {
+private:
+	Common::Array<uint16> _flags;
+public:
+	int _chairHotspotIndex;
+	int _v1;
+	int _v2;
+	int _v3;
+	int _v4;
+	int _v5;
+	int _v6;
+	int _v7;
+	int _v8;
+public:
+	/**
+	 * Constructor
+	 */
+	Globals();
+
+	/**
+	 * Square brackets operator for accessing flags
+	 */
+	uint16 &operator[](int idx) { return _flags[idx]; }
+};
+
+} // End of namespace Nebular
+
+} // End of namespace MADS
+
+#endif /* MADS_GLOBALS_NEBULAR_H */
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index e1dec2c..f82e102 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -46,6 +46,9 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	return new Scene804(vm);
 }
 
+NebularScene::NebularScene(MADSEngine *vm) : SceneLogic(vm) {
+}
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 1997202..9d617bb 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -26,6 +26,7 @@
 #include "common/scummsys.h"
 #include "mads/game.h"
 #include "mads/scene.h"
+#include "mads/nebular/globals_nebular.h"
 
 namespace MADS {
 
@@ -88,6 +89,19 @@ public:
 	static SceneLogic *createScene(MADSEngine *vm);
 };
 
+/**
+ * Specialized base class for Rex Nebular game scenes
+ */
+class NebularScene : public SceneLogic {
+protected:
+	Globals &_globals;
+public:
+	/**
+	 * Constructor
+	 */
+	NebularScene(MADSEngine *vm);
+};
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
new file mode 100644
index 0000000..1de4eca
--- /dev/null
+++ b/engines/mads/nebular/nebular_scenes1.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/scene.h"
+#include "mads/nebular/nebular_scenes.h"
+#include "mads/nebular/nebular_scenes1.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+void Scene101::setup() {
+}
+
+void Scene101::enter() {
+}
+
+void Scene101::step() {
+}
+
+void Scene101::preActions() {
+}
+
+void Scene101::actions() {
+}
+
+void Scene101::postActions() {
+}
+
+} // End of namespace Nebular
+
+} // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
new file mode 100644
index 0000000..da6a2f0
--- /dev/null
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_NEBULAR_SCENES1_H
+#define MADS_NEBULAR_SCENES1_H
+
+#include "common/scummsys.h"
+#include "mads/game.h"
+#include "mads/scene.h"
+#include "mads/nebular/nebular_scenes.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+class Scene101: public NebularScene {
+public:
+	Scene101(MADSEngine *vm) : NebularScene(vm) {}
+
+	virtual void setup();
+
+	virtual void enter();
+
+	virtual void step();
+
+	virtual void preActions();
+
+	virtual void actions();
+
+	virtual void postActions();
+};
+
+} // End of namespace Nebular
+
+} // End of namespace MADS
+
+#endif /* MADS_NEBULAR_SCENES1_H */
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index ee06dd0..d08e645 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -32,13 +32,12 @@ namespace Nebular {
 
 void Scene8xx::setup1() {
 	_vm->_sound->command(5);
-	if ((_vm->_game->_globalFlags[178] && !_vm->_game->_globalFlags[179]) ||
+	if ((_globals[178] && !_globals[179]) ||
 			_scene->_nextSceneId == 804 || _scene->_nextSceneId == 805 ||
 			_scene->_nextSceneId == 808 || _scene->_nextSceneId == 810) {
 		_vm->_game->_player._spritesPrefix = "";
 	} else {
-		_vm->_game->_player._spritesPrefix = _vm->_game->_globalFlags[0] 
-			== SEX_FEMALE ? "ROX" : "RXM";
+		_vm->_game->_player._spritesPrefix = _globals[0] == SEX_FEMALE ? "ROX" : "RXM";
 	}
 
 	_vm->_palette->setEntry(16, 0x0A, 0x3F, 0x3F);
@@ -49,6 +48,30 @@ void Scene8xx::setup2() {
 	_vm->_game->_aaName = Resources::formatAAName(5);
 }
 
+void Scene8xx::enter1() {
+	if (_vm->_musicFlag) {
+		switch (_scene->_nextSceneId) {
+		case 801:
+		case 802:
+		case 803:
+		case 804:
+		case 806:
+		case 807:
+		case 808:
+			_vm->_sound->command(20);
+			break;
+		case 805:
+			_vm->_sound->command(23);
+			break;
+		case 810:
+			_vm->_sound->command(10);
+			break;
+		default:
+			break;
+		}
+	}
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene804::setup() {
diff --git a/engines/mads/nebular/nebular_scenes8.h b/engines/mads/nebular/nebular_scenes8.h
index 3f5d274..a3bc97a 100644
--- a/engines/mads/nebular/nebular_scenes8.h
+++ b/engines/mads/nebular/nebular_scenes8.h
@@ -26,12 +26,13 @@
 #include "common/scummsys.h"
 #include "mads/game.h"
 #include "mads/scene.h"
+#include "mads/nebular/nebular_scenes.h"
 
 namespace MADS {
 
 namespace Nebular {
 
-class Scene8xx : public SceneLogic {
+class Scene8xx : public NebularScene {
 protected:
 	/**
 	 * Initial setup code shared by several scenes
@@ -42,8 +43,13 @@ protected:
 	* Initial setup code shared by several scenes
 	*/
 	void setup2();
+
+	/**
+	 * Common scene enter code used by multiple scenes
+	 */
+	void enter1();
 public:
-	Scene8xx(MADSEngine *vm) : SceneLogic(vm) {}
+	Scene8xx(MADSEngine *vm) : NebularScene(vm) {}
 };
 
 class Scene804: public Scene8xx {
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index b285229..f974be4 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -28,9 +28,10 @@
 
 namespace MADS {
 
-Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm),
-		_dirtyAreas(_vm), _dynamicHotspots(vm), _interface(vm), _kernelMessages(vm), 
-		_screenObjects(vm), _sequences(vm), _textDisplay(vm) {
+Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _dirtyAreas(_vm), 
+		_dynamicHotspots(vm), _interface(vm), _kernelMessages(vm), 
+		_screenObjects(vm), _sequences(vm), _spriteSlots(vm), 
+		_textDisplay(vm) {
 	_priorSceneId = 0;
 	_nextSceneId = 0;
 	_currentSceneId = 0;
@@ -47,6 +48,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _spriteSlots(vm), _action(_vm),
 	_freeAnimationFlag = false;
 	_animation = nullptr;
 	_activeAnimation = nullptr;
+	_textSpacing = -1;
 
 	_verbList.push_back(VerbInit(VERB_LOOK, 2, 0));
 	_verbList.push_back(VerbInit(VERB_TAKE, 2, 0));
@@ -424,7 +426,6 @@ void Scene::doFrame() {
 
 void Scene::drawElements(bool transitionFlag, bool surfaceFlag) {
 	// Draw any sprites
-	_dirtyAreas.clear();
 	_spriteSlots.drawBackground();
 
 	// Process dirty areas


Commit: a77ed90618664e50705b3e59dd2111faec2f5f39
    https://github.com/scummvm/scummvm/commit/a77ed90618664e50705b3e59dd2111faec2f5f39
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-06T22:31:41-05:00

Commit Message:
MADS: Implementing support methods needed for scene 804 initialisation

Changed paths:
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/messages.cpp
    engines/mads/msurface.cpp
    engines/mads/msurface.h
    engines/mads/nebular/globals_nebular.cpp
    engines/mads/nebular/globals_nebular.h
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/resources.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h
    engines/mads/sequence.cpp
    engines/mads/sequence.h
    engines/mads/sprites.cpp
    engines/mads/sprites.h



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index b64c59c..962e82c 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -140,7 +140,6 @@ void Game::sectionLoop() {
 		_v6 = 0;
 		_vm->_events->resetCursor();
 
-		_quotes = nullptr;
 		_scene.clearVocab();
 		_scene._dynamicHotspots.clear();
 		_scene.loadSceneLogic();
@@ -223,8 +222,7 @@ void Game::sectionLoop() {
 		if ((_v5 || _v6) && !_updateSceneFlag) {
 			_scene._currentSceneId = _scene._priorSceneId;
 			_updateSceneFlag = true;
-		}
-		else {
+		} else {
 			_updateSceneFlag = false;
 			_scene.loop();
 		}
@@ -232,8 +230,6 @@ void Game::sectionLoop() {
 		_vm->_events->resetCursor();
 		_v1 = 3;
 
-		delete _quotes;
-		_quotes = nullptr;
 		delete _scene._animation;
 		_scene._animation = nullptr;
 
@@ -274,22 +270,27 @@ void Game::loadResourceSequence(const Common::String prefix, int v) {
 	warning("TODO: loadResourceSequence");
 }
 
-Common::String Game::getQuote(int quoteId) {
-	if (_quotes && *_quotes) {
-		// Loop through the list of quotes
-		char *p = (char *)_quotes;
-		while (*p) {
-			// Get a pointer to the quote Id after the string
-			char *idP = p + strlen(p) + 1;
-			if (READ_LE_UINT16(idP) == quoteId)
-				// Found the correct string, so return it
-				return Common::String(p);
-
-			p = idP + 2;
+void Game::loadQuotes() {
+	File f("*QUOTES.DAT");
+	int curPos = 0;
+
+	char buffer[128];
+	strcpy(buffer, "");
+
+	while (true) {
+		uint8 b = f.readByte();
+		if (f.eos()) break;
+
+		buffer[curPos++] = b;
+		if (buffer[curPos - 1] == '\0') {
+			// end of string, add it to the strings list
+			_quotes.push_back(buffer);
+			curPos = 0;
+			strcpy(buffer, "");
 		}
 	}
 
-	return Common::String();
+	f.close();
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 0cd46b6..aa18109 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -24,6 +24,7 @@
 #define MADS_GAME_H
 
 #include "common/scummsys.h"
+#include "common/str-array.h"
 #include "mads/scene.h"
 #include "mads/game_data.h"
 #include "mads/player.h"
@@ -51,6 +52,11 @@ private:
 	 * Inner game loop for executing gameplay within a game section
 	 */
 	void sectionLoop();
+
+	/**
+	 * Load quotes data
+	 */
+	void loadQuotes();
 protected:
 	MADSEngine *_vm;
 	MSurface *_surface;
@@ -59,7 +65,7 @@ protected:
 	int _statusFlag;
 	SectionHandler *_sectionHandler;
 	VisitedScenes _visitedScenes;
-	byte *_quotes;
+	Common::StringArray _quotes;
 	int _v1;
 	int _v3;
 	int _v5;
@@ -130,10 +136,14 @@ public:
 	 */
 	void run();
 
-	/**
-	 * Get a quote
-	 */
-	Common::String getQuote(int quoteId);
+	uint32 getQuotesSize() { return _quotes.size(); }
+	const Common::String &getQuote(uint32 index) { return _quotes[index - 1]; }
+
+	// DEPRECATED: ScummVM re-implementation keeps all the quotes loaded, so the methods below are stubs
+	void clearQuotes() {}
+	void loadQuoteRange(int startNum, int endNum) {}
+	void loadQuoteSet(...) {}
+	void loadQuote(int quoteNum) {}
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index 33a6a8e..aaf6c41 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -30,8 +30,6 @@
 namespace MADS {
 
 KernelMessages::KernelMessages(MADSEngine *vm): _vm(vm) {
-	Scene &scene = _vm->_game->_scene;
-
 	for (int i = 0; i < KERNEL_MESSAGES_SIZE; ++i) {
 		KernelMessage rec;
 		_entries.push_back(rec);
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 754fea8..74043bf 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -497,4 +497,17 @@ MSurface *MSurface::flipHorizontal() const {
 	return dest;
 }
 
+/*------------------------------------------------------------------------*/
+
+int DepthSurface::getDepth(const Common::Point &pt) {
+
+	if (_vm->_game->_scene._sceneInfo->_depthStyle == 2) {
+		int bits = (3 - (pt.x % 4)) * 2;
+		byte v = *getBasePtr(pt.x >> 2, pt.y);
+		return v >> bits;
+	} else {
+		return *getBasePtr(pt.x, pt.y) & 0xF;
+	}
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index bd8142f..9699417 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -202,6 +202,21 @@ public:
 	MSurface *flipHorizontal() const;
 };
 
+class DepthSurface : public MSurface {
+private:
+	MADSEngine *_vm;
+public:
+	/**
+	 * Constructor
+	 */
+	DepthSurface(MADSEngine *vm) : _vm(vm) {}
+
+	/**
+	 * Returns the depth at a given position
+	 */
+	int getDepth(const Common::Point &pt);
+};
+
 } // End of namespace MADS
 
 #endif /* MADS_MSURFACE_H */
diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp
index 20789cd..37ebf5f 100644
--- a/engines/mads/nebular/globals_nebular.cpp
+++ b/engines/mads/nebular/globals_nebular.cpp
@@ -29,10 +29,9 @@ namespace MADS {
 namespace Nebular {
 
 Globals::Globals() {
-	// Initialise global flags
+	// Initialise lists
 	_flags.resize(210);
-	for (int i = 0; i < 210; ++i)
-		_flags[i] = 0;
+	_spriteIndexes.resize(30);
 
 	// Initialise game flags
 	_chairHotspotIndex = 0;
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index 0d8da78..daa384f 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -35,6 +35,8 @@ class Globals {
 private:
 	Common::Array<uint16> _flags;
 public:
+	Common::Array<int> _spriteIndexes;
+
 	int _chairHotspotIndex;
 	int _v1;
 	int _v2;
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index f82e102..d14120a 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -23,7 +23,10 @@
 #include "common/scummsys.h"
 #include "common/config-manager.h"
 #include "mads/mads.h"
+#include "mads/compression.h"
+#include "mads/resources.h"
 #include "mads/scene.h"
+#include "mads/nebular/game_nebular.h"
 #include "mads/nebular/nebular_scenes.h"
 #include "mads/nebular/nebular_scenes8.h"
 
@@ -46,7 +49,43 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	return new Scene804(vm);
 }
 
-NebularScene::NebularScene(MADSEngine *vm) : SceneLogic(vm) {
+/*------------------------------------------------------------------------*/
+
+NebularScene::NebularScene(MADSEngine *vm) : SceneLogic(vm),
+		_globals(static_cast<GameNebular *>(vm->_game)->_globals) {
+}
+
+Common::String NebularScene::formAnimName(char sepChar, int suffixNum) {
+	return Resources::formatName(_scene->_currentSceneId, sepChar, suffixNum,
+		EXT_NONE, "");
+}
+
+/*------------------------------------------------------------------------*/
+
+void SceneInfoNebular::loadCodes(MSurface &depthSurface) {
+	File f(Resources::formatName(RESPREFIX_RM, _sceneId, ".DAT"));
+	MadsPack codesPack(&f);
+	Common::SeekableReadStream *stream = codesPack.getItemStream(0);
+
+	byte *destP = depthSurface.getData();
+	byte *endP = depthSurface.getBasePtr(0, depthSurface.h);
+
+	byte runLength = stream->readByte();
+	while (destP < endP && runLength > 0) {
+		byte runValue = stream->readByte();
+
+		// Write out the run length
+		Common::fill(destP, destP + runLength, runValue);
+		destP += runLength;
+
+		// Get the next run length
+		runLength = stream->readByte();
+	}
+
+	if (destP < endP)
+		Common::fill(destP, endP, 0);
+	delete stream;
+	f.close();
 }
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 9d617bb..92b5626 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -95,6 +95,11 @@ public:
 class NebularScene : public SceneLogic {
 protected:
 	Globals &_globals;
+
+	/**
+	 * Forms an animation resoucre name
+	 */
+	Common::String formAnimName(char sepChar, int suffixNum);
 public:
 	/**
 	 * Constructor
@@ -102,6 +107,17 @@ public:
 	NebularScene(MADSEngine *vm);
 };
 
+class SceneInfoNebular : public SceneInfo {
+	friend class SceneInfo;
+protected:
+	virtual void loadCodes(MSurface &depthSurface);
+
+	/**
+	* Constructor
+	*/
+	SceneInfoNebular(MADSEngine *vm) : SceneInfo(vm) {}
+};
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index d08e645..773b0e6 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -75,6 +75,38 @@ void Scene8xx::enter1() {
 /*------------------------------------------------------------------------*/
 
 void Scene804::setup() {
+	_globals._chairHotspotIndex = 0;
+	_globals._v1 = _globals._v2 = 0;
+	_globals._v3 = _globals._v4 = 0;
+	_globals._v5 = -1;
+	_globals._v6 = _globals._v7 = 0;
+	_globals._v8 = 0;
+	if (_globals[5]) {
+		// Copy protection failed
+		_globals[165] = 0xFFFF;
+		_globals[164] = 0;
+	}
+
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 1));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('x', 2));
+	_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('x', 3));
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('x', 4));
+	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('f', 1));
+
+	_vm->_game->loadQuoteSet(791, 0);
+
+	if (_globals[165]) {
+		if (_globals[164]) {
+			_globals._spriteIndexes[19] = _scene->_sequences.startCycle(
+				_globals._spriteIndexes[4], 0, 1);
+			// TODO
+		} else {
+
+		}
+	} else {
+		// TODO
+	}
 }
 
 void Scene804::enter() {
diff --git a/engines/mads/resources.h b/engines/mads/resources.h
index 01f6490..3d5d582 100644
--- a/engines/mads/resources.h
+++ b/engines/mads/resources.h
@@ -36,7 +36,8 @@ enum RESPREFIX {
 };
 
 enum EXTTYPE {
-	EXT_SS = 1, EXT_AA = 2, EXT_DAT = 3, EXT_HH = 4, EXT_ART = 5, EXT_INT = 6
+	EXT_NONE = -1, EXT_SS = 1, EXT_AA = 2, EXT_DAT = 3, EXT_HH = 4, 
+	EXT_ART = 5, EXT_INT = 6
 };
 
 class Resources {
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index f974be4..bbf46f1 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -28,10 +28,10 @@
 
 namespace MADS {
 
-Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _dirtyAreas(_vm), 
-		_dynamicHotspots(vm), _interface(vm), _kernelMessages(vm), 
-		_screenObjects(vm), _sequences(vm), _spriteSlots(vm), 
-		_textDisplay(vm) {
+Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
+		_dirtyAreas(_vm),  _dynamicHotspots(vm), _interface(vm), 
+		_kernelMessages(vm), _screenObjects(vm), _sequences(vm), 
+		_sprites(vm), _spriteSlots(vm), _textDisplay(vm) {
 	_priorSceneId = 0;
 	_nextSceneId = 0;
 	_currentSceneId = 0;
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index f31927d..3fe3a4e 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -98,7 +98,7 @@ public:
 	int _v1;
 	SceneInfo *_sceneInfo;
 	MSurface _backgroundSurface;
-	MSurface _depthSurface;
+	DepthSurface _depthSurface;
 	InterfaceSurface _interface;
 	bool _animFlag;
 	int _animVal1;
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 813e906..c15a387 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -383,9 +383,8 @@ void SceneInfo::SpriteInfo::load(Common::SeekableReadStream *f) {
 
 SceneInfo *SceneInfo::init(MADSEngine *vm) {
 	if (vm->getGameID() == GType_RexNebular) {
-		return new SceneInfoNebular(vm);
-	}
-	else {
+		return new Nebular::SceneInfoNebular(vm);
+	} else {
 		return new SceneInfo(vm);
 	}
 }
@@ -587,34 +586,6 @@ void SceneInfo::loadCodes(MSurface &depthSurface) {
 
 /*------------------------------------------------------------------------*/
 
-void SceneInfoNebular::loadCodes(MSurface &depthSurface) {
-	File f(Resources::formatName(RESPREFIX_RM, _sceneId, ".DAT"));
-	MadsPack codesPack(&f);
-	Common::SeekableReadStream *stream = codesPack.getItemStream(0);
-
-	byte *destP = depthSurface.getData();
-	byte *endP = depthSurface.getBasePtr(0, depthSurface.h);
-
-	byte runLength = stream->readByte();
-	while (destP < endP && runLength > 0) {
-		byte runValue = stream->readByte();
-
-		// Write out the run length
-		Common::fill(destP, destP + runLength, runValue);
-		destP += runLength;
-
-		// Get the next run length
-		runLength = stream->readByte();
-	}
-
-	if (destP < endP)
-		Common::fill(destP, endP, 0);
-	delete stream;
-	f.close();
-}
-
-/*------------------------------------------------------------------------*/
-
 SceneLogic::SceneLogic(MADSEngine *vm) : _vm(vm) {
 	_scene = &_vm->_game->_scene;
 }
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 4d8cfc7..d2fd624 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -288,17 +288,6 @@ public:
 		MSurface &depthSurface, MSurface &bgSurface);
 };
 
-class SceneInfoNebular : public SceneInfo {
-	friend class SceneInfo;
-protected:
-	virtual void loadCodes(MSurface &depthSurface);
-
-	/**
-	* Constructor
-	*/
-	SceneInfoNebular(MADSEngine *vm) : SceneInfo(vm) {}
-};
-
 } // End of namespace MADS
 
 #endif /* MADS_SCENE_DATA_H */
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 8f25007..33febe3 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -367,4 +367,23 @@ void SequenceList::scan() {
 void SequenceList::setDepth(int seqIndex, int depth) {
 	_entries[seqIndex]._depth = depth;
 }
+
+int SequenceList::addSpriteCycle(int srcSpriteIdx, bool flipped, int numTicks, int triggerCountdown, int timeoutTicks, int extraTicks) {
+	Scene &scene = _vm->_game->_scene;
+	MSprite *spriteFrame = scene._spriteSlots.getSprite(srcSpriteIdx).getFrame(0);
+	int depth = scene._depthSurface.getDepth(Common::Point(spriteFrame->_pos.x + 
+		(spriteFrame->w / 2), spriteFrame->_pos.y + (spriteFrame->h / 2)));
+
+	return add(srcSpriteIdx, flipped, 1, triggerCountdown, timeoutTicks, extraTicks, numTicks, 0, 0,
+		true, 100, depth - 1, 1, ANIMTYPE_CYCLED, 0, 0);
+}
+
+int SequenceList::startCycle(int srcSpriteIndex, bool flipped, int cycleIndex) {
+	int result = addSpriteCycle(srcSpriteIndex, flipped, INDEFINITE_TIMEOUT, 0, 0, 0);
+	if (result >= 0)
+		setAnimRange(result, cycleIndex, cycleIndex);
+
+	return result;
+}
+
 } // End of namespace 
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index f73d48b..80f695c 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -102,6 +102,8 @@ public:
 	void setAnimRange(int seqIndex, int startVal, int endVal);
 	void scan();
 	void setDepth(int seqIndex, int depth);
+	int addSpriteCycle(int srcSpriteIdx, bool flipped, int numTicks, int triggerCountdown, int timeoutTicks, int extraTicks);
+	int startCycle(int srcSpriteIdx, bool flipped, int cycleIndex);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 23360b0..321acf0 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -355,4 +355,8 @@ int SpriteSets::add(SpriteAsset *asset, int idx) {
 	return idx;
 }
 
+int SpriteSets::addSprites(const Common::String &resName, int flags) {
+	return add(new SpriteAsset(_vm, resName, flags));
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index 49f13ad..2061a41 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -201,11 +201,25 @@ public:
 };
 
 class SpriteSets : public Common::Array<SpriteAsset *> {
+private:
+	MADSEngine *_vm;
 public:
 	/**
+	 * Constructor
+	 */
+	SpriteSets(MADSEngine *vm) : _vm(vm) {}
+
+	/**
 	* Add a sprite asset to the list
 	*/
 	int add(SpriteAsset *asset, int idx = 0);
+
+	/**
+	 * Adds a sprite asset to the list by name
+	 */
+	int addSprites(const Common::String &resName, int flags = 0);
+
+	int startCycle(int srcSpriteIndex, bool flipped, int cycleIndex);
 };
 
 } // End of namespace MADS


Commit: 1874ec2111fd944d3e554acde8a0f06c651c95fb
    https://github.com/scummvm/scummvm/commit/1874ec2111fd944d3e554acde8a0f06c651c95fb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-07T08:04:10-05:00

Commit Message:
MADS: More initialisation code for scene 804, and missing engine methods

Changed paths:
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/sequence.cpp
    engines/mads/sequence.h
    engines/mads/sprites.h



diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 773b0e6..b3997e1 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -100,13 +100,33 @@ void Scene804::setup() {
 		if (_globals[164]) {
 			_globals._spriteIndexes[19] = _scene->_sequences.startCycle(
 				_globals._spriteIndexes[4], 0, 1);
-			// TODO
+			_scene->_sequences.addTimer(60, 100);
 		} else {
-
+			_globals._spriteIndexes[20] = _scene->_sequences.startCycle(
+				_globals._spriteIndexes[5], false, 1);
+			_globals._spriteIndexes[21] = _scene->_sequences.startReverseCycle(
+				_globals._spriteIndexes[6], false, 4, 0, 0, 0);
+			_scene->_sequences.addTimer(160, 70);
+			_vm->_game->_player._stepEnabled = false;
 		}
 	} else {
-		// TODO
+		if (_globals[167] == 0) {
+			_globals._spriteIndexes[22] = _scene->_sequences.startCycle(
+				_globals._spriteIndexes[7], false, 1);
+		}
+
+		if (_globals[164] == 0) {
+			_globals._spriteIndexes[22] = _scene->_sequences.startCycle(
+				_globals._spriteIndexes[18], false, 1);
+		}
+
+		_globals._spriteIndexes[0] = _scene->_sequences.startCycle(
+			_globals._spriteIndexes[0], false, 1);
+		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[15], Common::Point(133, 139));
+		_scene->_sequences.setDepth(_globals._spriteIndexes[15], 8);
 	}
+
+	// TODO: More setup
 }
 
 void Scene804::enter() {
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 33febe3..23fa052 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -28,28 +28,27 @@
 
 namespace MADS {
 
-SequenceEntry::SequenceEntry() {
-	_spritesIndex = 0;
-	_flipped = 0;
-	_frameIndex = 0;
-	_frameStart = 0;
-	_numSprites = 0;
-	_animType = ANIMTYPE_NONE;
-	_frameInc = 0;
-	_depth = 0;
-	_scale = 0;
-	_dynamicHotspotIndex = -1;
-	_triggerCountdown = 0;
-	_doneFlag = 0;
-	_entries._count = 0;
-	_abortMode = ABORTMODE_0;
-	_actionNouns[0] = _actionNouns[1] = _actionNouns[2] = 0;
-	_numTicks = 0;
-	_extraTicks = 0;
-	_timeout = 0;
-}
+	SequenceEntry::SequenceEntry() {
+		_spritesIndex = 0;
+		_flipped = 0;
+		_frameIndex = 0;
+		_frameStart = 0;
+		_numSprites = 0;
+		_animType = ANIMTYPE_NONE;
+		_frameInc = 0;
+		_depth = 0;
+		_scale = 0;
+		_dynamicHotspotIndex = -1;
+		_triggerCountdown = 0;
+		_doneFlag = 0;
+		_entries._count = 0;
+		_abortMode = ABORTMODE_0;
+		_numTicks = 0;
+		_extraTicks = 0;
+		_timeout = 0;
+	}
 
-/*------------------------------------------------------------------------*/
+	/*------------------------------------------------------------------------*/
 
 #define TIMER_LIST_SIZE 30
 
@@ -126,8 +125,31 @@ int SequenceList::add(int spriteListIndex, bool flipped, int frameIndex, int tri
 	_entries[seqIndex]._entries._count = 0;
 	_entries[seqIndex]._abortMode = _vm->_game->_abortTimersMode2;
 
-	for (int i = 0; i < 3; ++i)
-		_entries[seqIndex]._actionNouns[i] = _actionNouns[i];
+	_entries[seqIndex]._actionNouns = _vm->_game->_scene._action._activeAction;
+
+	return seqIndex;
+}
+
+int SequenceList::addTimer(int time, int abortVal) {
+	int seqIndex;
+	for (seqIndex = 0; seqIndex < _entries.size(); ++seqIndex) {
+		if (!_entries[seqIndex]._active)
+			break;
+	}
+	assert(seqIndex < (int)_entries.size());
+
+	SequenceEntry &se = _entries[seqIndex];
+	se._active = true;
+	se._spritesIndex = -1;
+	se._numTicks = time;
+	se._extraTicks = 0;
+	se._timeout = _vm->_events->_currentTimer + time;
+	se._triggerCountdown = true;
+	se._doneFlag = false;
+	se._entries._count = 0;
+	se._abortMode = _vm->_game->_abortTimersMode2;
+	se._actionNouns = _vm->_game->_scene._action._activeAction;
+	addSubEntry(seqIndex, SM_0, 0, abortVal);
 
 	return seqIndex;
 }
@@ -368,6 +390,11 @@ void SequenceList::setDepth(int seqIndex, int depth) {
 	_entries[seqIndex]._depth = depth;
 }
 
+void SequenceList::setMsgPosition(int seqIndex, const Common::Point &pt) {
+	_entries[seqIndex]._msgPos = pt;
+	_entries[seqIndex]._nonFixed = false;
+}
+
 int SequenceList::addSpriteCycle(int srcSpriteIdx, bool flipped, int numTicks, int triggerCountdown, int timeoutTicks, int extraTicks) {
 	Scene &scene = _vm->_game->_scene;
 	MSprite *spriteFrame = scene._spriteSlots.getSprite(srcSpriteIdx).getFrame(0);
@@ -386,4 +413,15 @@ int SequenceList::startCycle(int srcSpriteIndex, bool flipped, int cycleIndex) {
 	return result;
 }
 
+int SequenceList::startReverseCycle(int srcSpriteIndex, bool flipped, int numTicks, 
+		int triggerCountdown, int timeoutTicks, int extraTicks) {
+	SpriteAsset *sprites = _vm->_game->_scene._sprites[srcSpriteIndex];
+	MSprite *frame = sprites->getFrame(0);
+	int depth = _vm->_game->_scene._depthSurface.getDepth(Common::Point(
+		frame->_pos.x + frame->w / 2, frame->_pos.y + frame->h / 2));
+
+	return add(srcSpriteIndex, flipped, 1, triggerCountdown, timeoutTicks, extraTicks,
+		numTicks, 0, 0, true, 100, depth - 1, 1, ANIMTYPE_REVERSIBLE, 0, 0);
+}
+
 } // End of namespace 
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index 80f695c..85e4f66 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -70,7 +70,7 @@ struct SequenceEntry {
 	SequenceSubEntries _entries;
 	AbortTimerMode _abortMode;
 
-	uint16 _actionNouns[3];
+	ActionDetails _actionNouns;
 	int _numTicks;
 	int _extraTicks;
 	uint32 _timeout;
@@ -84,7 +84,6 @@ class SequenceList {
 private:
 	MADSEngine *_vm;
 	Common::Array<SequenceEntry> _entries;
-	int _actionNouns[3];
 public:
 	SequenceList(MADSEngine *vm);
 
@@ -94,6 +93,7 @@ public:
 	int add(int spriteListIndex, bool flipped, int frameIndex, int triggerCountdown, int delayTicks,
 		int extraTicks, int numTicks, int msgX, int msgY, bool nonFixed, char scale, uint8 depth,
 		int frameInc, SpriteAnimType animType, int numSprites, int frameStart);
+	int addTimer(int time, int abortVal);
 	void remove(int seqIndex);
 	void setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot);
 	bool loadSprites(int seqIndex);
@@ -102,8 +102,11 @@ public:
 	void setAnimRange(int seqIndex, int startVal, int endVal);
 	void scan();
 	void setDepth(int seqIndex, int depth);
+	void setMsgPosition(int seqIndex, const Common::Point &pt);
 	int addSpriteCycle(int srcSpriteIdx, bool flipped, int numTicks, int triggerCountdown, int timeoutTicks, int extraTicks);
 	int startCycle(int srcSpriteIdx, bool flipped, int cycleIndex);
+	int startReverseCycle(int srcSpriteIndex, bool flipped, int numTicks, int triggerCountdown, 
+		int timeoutTicks, int extraTicks);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index 2061a41..598b9e4 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -218,8 +218,6 @@ public:
 	 * Adds a sprite asset to the list by name
 	 */
 	int addSprites(const Common::String &resName, int flags = 0);
-
-	int startCycle(int srcSpriteIndex, bool flipped, int cycleIndex);
 };
 
 } // End of namespace MADS


Commit: 3399516c5e4c2931adf76a25944cb3e46f9934ee
    https://github.com/scummvm/scummvm/commit/3399516c5e4c2931adf76a25944cb3e46f9934ee
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-07T23:07:36-05:00

Commit Message:
MADS: Implemented remainder of scene 804 setup code and support methods

Changed paths:
    engines/mads/animation.cpp
    engines/mads/animation.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/interface.cpp
    engines/mads/interface.h
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/sequence.cpp
    engines/mads/sprites.cpp
    engines/mads/sprites.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index d0c7d30..588e4ea 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -140,6 +140,8 @@ Animation *Animation::init(MADSEngine *vm, Scene *scene) {
 Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) {
 	_font = nullptr;
 	_resetFlag = false;
+	_messageCtr = 0;
+	_skipLoad = false;
 }
 
 Animation::~Animation() {
@@ -298,6 +300,32 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 	f.close();
 }
 
+void Animation::startAnimation(int abortTimers) {
+	_messageCtr = 0;
+	_skipLoad = true;
+
+	if (_header._manualFlag) {
+		_unkIndex = -1;
+		//SpriteAsset *asset = _scene->_sprites[_spriteListIndexes[_header._spritesIndex]];
+
+		// TODO: Weird stuff with _unkList. Seems like it's treated as pointers
+		// here, but in processText, it's used as POINTs?
+
+		loadFrame(1);
+	}
+
+	_currentFrame = 0;
+	_oldFrameEntry = 0;
+	_nextFrameTimer = _vm->_events->_currentTimer;
+	_abortTimers = abortTimers;
+	_abortTimersMode = _vm->_game->_abortTimersMode2;
+	_vm->_game->_scene._action._activeAction = _actionDetails;
+
+	for (int idx = 0; idx < _header._messagesCount; ++idx) {
+		_messages[idx]._kernelMsgIndex = -1;
+	}
+}
+
 void Animation::loadFrame(int frameNumber) {
 	Scene &scene = _vm->_game->_scene;
 	if (_skipLoad)
@@ -507,11 +535,11 @@ void Animation::update() {
 		// Animation is complete
 		if (_abortTimers != 0) {
 			_vm->_game->_abortTimers = _abortTimers;
-			_vm->_game->_abortTimersMode = _abortMode;
+			_vm->_game->_abortTimersMode = _abortTimersMode;
 
-			if (_abortMode != ABORTMODE_1) {
+			if (_abortTimersMode != ABORTMODE_1) {
 				// Copy the noun list
-				scene._action._action = _actionNouns;
+				scene._action._action = _actionDetails;
 			}
 		}
 	}
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 8df7b37..ca04e86 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -130,8 +130,8 @@ private:
 	uint32 _nextScrollTimer;
 	int _messageCtr;
 	int _abortTimers;
-	AbortTimerMode _abortMode;
-	ActionDetails _actionNouns;
+	AbortTimerMode _abortTimersMode;
+	ActionDetails _actionDetails;
 
 	/**
 	 * Load data for a given frame
@@ -173,6 +173,11 @@ public:
 		int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo);
 
 	/**
+	 * Setups up a loaded animation for playback
+	 */
+	void startAnimation(int abortTimers);
+
+	/**
 	 * Update the animation
 	 */
 	void update();
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 962e82c..08a5f97a 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -58,6 +58,7 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 	_updateSceneFlag = false;
 	_abortTimersMode = ABORTMODE_0;
 	_abortTimersMode2 = ABORTMODE_0;
+	_ticksExpiry = 0;
 }
 
 Game::~Game() {
@@ -176,7 +177,7 @@ void Game::sectionLoop() {
 		}
 
 		_vm->_events->initVars();
-		_scene._v1A = -1;
+		_scene._v1A = true;
 		_scene._v1C = -1;
 		_objectHiliteVocabIdx = -1;
 
@@ -230,8 +231,8 @@ void Game::sectionLoop() {
 		_vm->_events->resetCursor();
 		_v1 = 3;
 
-		delete _scene._animation;
-		_scene._animation = nullptr;
+		delete _scene._animationData;
+		_scene._animationData = nullptr;
 
 		_scene._reloadSceneFlag = false;
 
diff --git a/engines/mads/game.h b/engines/mads/game.h
index aa18109..143259d 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -66,13 +66,11 @@ protected:
 	SectionHandler *_sectionHandler;
 	VisitedScenes _visitedScenes;
 	Common::StringArray _quotes;
-	int _v1;
 	int _v3;
 	int _v5;
 	int _v6;
 	bool _updateSceneFlag;
 	bool _playerSpritesFlag;
-	int _objectHiliteVocabIdx;
 
 	/**
 	 * Constructor
@@ -120,6 +118,7 @@ public:
 	int _currentSectionNumber;
 	InventoryObjects _objects;
 	Scene _scene;
+	int _v1;
 	int _v2;
 	int _v4;
 	int _abortTimers;
@@ -128,6 +127,8 @@ public:
 	AbortTimerMode _abortTimersMode2;
 	uint32 _priorFrameTimer;
 	Common::String _aaName;
+	uint32 _ticksExpiry;
+	int _objectHiliteVocabIdx;
 public:
 	virtual ~Game();
 
diff --git a/engines/mads/interface.cpp b/engines/mads/interface.cpp
index fa50cbd..e310561 100644
--- a/engines/mads/interface.cpp
+++ b/engines/mads/interface.cpp
@@ -68,6 +68,47 @@ void InterfaceSurface::load(const Common::String &resName) {
 	delete pixelsStream;
 }
 
+void InterfaceSurface::setup(int id) {
+	Scene &scene = _vm->_game->_scene;
+
+	if (scene._screenObjects._v832EC != id) {
+		Common::String resName = _vm->_game->_aaName;
+
+		// Strip off any extension
+		const char *p = strchr(resName.c_str(), '.');
+		if (p) {
+			resName = Common::String(resName.c_str(), p - 1);
+		}
+
+		// Add on suffix if necessary
+		if (id)
+			resName += "A";
+
+		resName += ".INT";
+		free();
+		load(resName);
+	}
+	scene._screenObjects._v832EC = id;
+
+	scene._imageInterEntries.clear();
+	scene._imageInterEntries.add(-2, 0xff);
+	_vm->_game->_ticksExpiry = _vm->_events->getFrameCounter();
+	scene._v1A = true;
+	_vm->_game->_objectHiliteVocabIdx = -1;
+	scene._v1C = -1;
+
+	// Make a copy of the surface
+	copyTo(&_surface);
+
+	if (_vm->_game->_v1 == 5)
+		scene._imageInterEntries.call(0);
+
+	scene._action.clear();
+	writeText();
+	loadElements();
+	scene._dynamicHotspots.refresh();
+}
+
 void InterfaceSurface::elementHighlighted() {
 	warning("TODO: InterfaceSurface::elementHighlighted");
 }
@@ -81,6 +122,10 @@ void InterfaceSurface::setBounds(const Common::Rect &r) {
 	_bounds = r;
 }
 
+void InterfaceSurface::loadElements() {
+	warning("TODO: InterfaceSurface::loadElements");
+}
+
 /*------------------------------------------------------------------------*/
 
 
diff --git a/engines/mads/interface.h b/engines/mads/interface.h
index 3295fa4..0d7860b 100644
--- a/engines/mads/interface.h
+++ b/engines/mads/interface.h
@@ -26,17 +26,21 @@
 #include "common/scummsys.h"
 #include "common/rect.h"
 #include "common/str.h"
+#include "mads/msurface.h"
 
 namespace MADS {
 
 class InterfaceSurface : public MSurface {
 private:
 	MADSEngine *_vm;
+
+	void loadElements();
 public:
 	ScrCategory _category;
 	int _screenObjectsCount;
 	Common::Rect _bounds;
 	Common::Rect *_rectP;
+	MSurface _surface;
 public:
 	/**
 	* Constructor
@@ -48,6 +52,11 @@ public:
 	*/
 	void load(const Common::String &resName);
 
+	/**
+	 * Set up the interface
+	 */
+	void setup(int id);
+
 	void elementHighlighted();
 
 	void writeText();
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index b3997e1..caad1e7 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -126,7 +126,14 @@ void Scene804::setup() {
 		_scene->_sequences.setDepth(_globals._spriteIndexes[15], 8);
 	}
 
-	// TODO: More setup
+	_scene->loadAnimation(Resources::formatName(804, 'r', 1, EXT_AA, ""));
+
+	Scene8xx::enter1();
+
+	if (_globals[165] && !_globals[164]) {
+		_scene->_interface.setup(2);
+		_vm->_sound->command(19);
+	}
 }
 
 void Scene804::enter() {
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index bbf46f1..c7a6ede 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -46,7 +46,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 	_reloadSceneFlag = false;
 	_destFacing = 0;
 	_freeAnimationFlag = false;
-	_animation = nullptr;
+	_animationData = nullptr;
 	_activeAnimation = nullptr;
 	_textSpacing = -1;
 
@@ -156,9 +156,9 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	if (!_vm->_textWindowStill)
 		flags |= 0x200;
 
-	_animation = Animation::init(_vm, this);
+	_animationData = Animation::init(_vm, this);
 	MSurface surface;
-	_animation->load(surface, _interface, prefix, flags, nullptr, nullptr);
+	_animationData->load(surface, _interface, prefix, flags, nullptr, nullptr);
 	
 	_vm->_palette->_paletteUsage.load(0);
 
@@ -495,6 +495,17 @@ void Scene::checkKeyboard() {
 	warning("TODO: Scene::checkKeyboard");
 }
 
+void Scene::loadAnimation(const Common::String &resName, int abortTimers) {
+	assert(_activeAnimation == nullptr);
+	MSurface sceneSurface;
+	InterfaceSurface interfaceSurface(_vm);
+
+	_activeAnimation = Animation::init(_vm, this);
+	_activeAnimation->load(sceneSurface, interfaceSurface, resName, 
+		_vm->_game->_v2 ? 1 : 0, nullptr, nullptr);
+	_activeAnimation->startAnimation(abortTimers);
+}
+
 void Scene::free() {
 	warning("TODO: Scene::free");
 }
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 3fe3a4e..e2aa109 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -94,6 +94,7 @@ public:
 	int _textSpacing;
 	Common::Array<Hotspot> _hotspots;
 	ScreenObjects _screenObjects;
+	ImageInterEntries _imageInterEntries;
 	DirtyAreas _dirtyAreas;
 	int _v1;
 	SceneInfo *_sceneInfo;
@@ -107,7 +108,7 @@ public:
 	Common::Array<RGB4> _animPalData;
 	SceneNodeList _nodes;
 	Common::StringArray _vocabStrings;
-	Animation *_animation;
+	Animation *_animationData;
 	Animation *_activeAnimation;
 	bool _freeAnimationFlag;
 	int _depthStyle;
@@ -115,7 +116,7 @@ public:
 	int _scaleRange;
 	int _interfaceY;
 	int _spritesCount;
-	int _v1A;
+	bool _v1A;
 	int _v1C;
 	MADSAction _action;
 	bool _roomChanged;
@@ -195,6 +196,11 @@ public:
 	void leftClick();
 
 	/**
+	 * Load an animation
+	 */
+	void loadAnimation(const Common::String &resName, int abortTimers = 0);
+
+	/**
 	 * Clear the data for the scene
 	 */
 	void free();
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 23fa052..93cc9ea 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -131,7 +131,7 @@ int SequenceList::add(int spriteListIndex, bool flipped, int frameIndex, int tri
 }
 
 int SequenceList::addTimer(int time, int abortVal) {
-	int seqIndex;
+	uint seqIndex;
 	for (seqIndex = 0; seqIndex < _entries.size(); ++seqIndex) {
 		if (!_entries[seqIndex]._active)
 			break;
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 321acf0..9a56ed3 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -359,4 +359,30 @@ int SpriteSets::addSprites(const Common::String &resName, int flags) {
 	return add(new SpriteAsset(_vm, resName, flags));
 }
 
+/*------------------------------------------------------------------------*/
+
+ImageInterEntry::ImageInterEntry() {
+	_field0 = 0;
+	_field2 = 0;
+	_field3 = 0;
+	_field4 = 0;
+	_field6 = 0;
+	_field8 = 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+int ImageInterEntries::add(int field0, int field2) {
+	ImageInterEntry ie;
+	ie._field0 = field0;
+	ie._field2 = field2;
+
+	push_back(ie);
+	return size() - 1;
+}
+
+void ImageInterEntries::call(int v1) {
+	debug("TODO: ImageInterEntries::call");
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index 598b9e4..b7e63a0 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -220,6 +220,25 @@ public:
 	int addSprites(const Common::String &resName, int flags = 0);
 };
 
+class ImageInterEntry {
+public:
+	int _field0;
+	int _field2;
+	int _field3;
+	int _field4;
+	int _field6;
+	int _field8;
+
+	ImageInterEntry();
+};
+
+class ImageInterEntries: public Common::Array<ImageInterEntry> {
+public:
+	int add(int field0, int field2);
+
+	void call(int v1);
+};
+
 } // End of namespace MADS
 
 #endif /* MADS_SPRITES_H */


Commit: 8bfa5f1da2d84fafdda88aac0cdd5e17ebfbc100
    https://github.com/scummvm/scummvm/commit/8bfa5f1da2d84fafdda88aac0cdd5e17ebfbc100
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-08T08:25:46-05:00

Commit Message:
MADS: Make resource file access case insensitive

Changed paths:
    engines/mads/resources.cpp



diff --git a/engines/mads/resources.cpp b/engines/mads/resources.cpp
index 5e490c2..f85d5ce 100644
--- a/engines/mads/resources.cpp
+++ b/engines/mads/resources.cpp
@@ -199,7 +199,7 @@ bool HagArchive::getHeaderEntry(const Common::String &resourceName,
 			Common::List<HagEntry>::iterator ei;
 			for (ei = hagIndex._entries.begin(); ei != hagIndex._entries.end(); ++ei) {
 				hagEntry = *ei;
-				if (hagEntry._resourceName == resName)
+				if (hagEntry._resourceName.compareToIgnoreCase(resName) == 0)
 					return true;
 			}
 		}


Commit: 7310080967d506de91b99611e468c209456b3f81
    https://github.com/scummvm/scummvm/commit/7310080967d506de91b99611e468c209456b3f81
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-08T08:26:09-05:00

Commit Message:
MADS: Fix memory leak with conversation font loading

Changed paths:
    engines/mads/messages.cpp
    engines/mads/messages.h



diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index aaf6c41..69d9843 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -39,6 +39,10 @@ KernelMessages::KernelMessages(MADSEngine *vm): _vm(vm) {
 	word_8469E = 0;
 }
 
+KernelMessages::~KernelMessages() {
+	delete _talkFont;
+}
+
 void KernelMessages::clear() {
 	Scene &scene = _vm->_game->_scene;
 
@@ -46,7 +50,6 @@ void KernelMessages::clear() {
 		_entries[i]._flags = 0;
 
 	scene._textSpacing = -1;
-	_talkFont = _vm->_font->getFont(FONT_CONVERSATION);
 }
 
 int KernelMessages::add(const Common::Point &pt, uint fontColor, uint8 flags, 
diff --git a/engines/mads/messages.h b/engines/mads/messages.h
index 19a0115..340f33e 100644
--- a/engines/mads/messages.h
+++ b/engines/mads/messages.h
@@ -75,6 +75,7 @@ public:
 	int word_8469E;
 public:
 	KernelMessages(MADSEngine *vm);
+	~KernelMessages();
 
 	void clear();
 	int add(const Common::Point &pt, uint fontColor, uint8 flags, uint8 abortTimers, 


Commit: 80bba746406743ab7a7ae6c163c79c652f6d7624
    https://github.com/scummvm/scummvm/commit/80bba746406743ab7a7ae6c163c79c652f6d7624
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-08T08:33:13-05:00

Commit Message:
MADS: Fix sprites loading for scene 804

Changed paths:
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/sprites.cpp



diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index caad1e7..56c3679 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -75,6 +75,11 @@ void Scene8xx::enter1() {
 /*------------------------------------------------------------------------*/
 
 void Scene804::setup() {
+	Scene8xx::setup1();
+	Scene8xx::setup2();
+}
+
+void Scene804::enter() {
 	_globals._chairHotspotIndex = 0;
 	_globals._v1 = _globals._v2 = 0;
 	_globals._v3 = _globals._v4 = 0;
@@ -101,7 +106,8 @@ void Scene804::setup() {
 			_globals._spriteIndexes[19] = _scene->_sequences.startCycle(
 				_globals._spriteIndexes[4], 0, 1);
 			_scene->_sequences.addTimer(60, 100);
-		} else {
+		}
+		else {
 			_globals._spriteIndexes[20] = _scene->_sequences.startCycle(
 				_globals._spriteIndexes[5], false, 1);
 			_globals._spriteIndexes[21] = _scene->_sequences.startReverseCycle(
@@ -109,7 +115,8 @@ void Scene804::setup() {
 			_scene->_sequences.addTimer(160, 70);
 			_vm->_game->_player._stepEnabled = false;
 		}
-	} else {
+	}
+	else {
 		if (_globals[167] == 0) {
 			_globals._spriteIndexes[22] = _scene->_sequences.startCycle(
 				_globals._spriteIndexes[7], false, 1);
@@ -136,9 +143,6 @@ void Scene804::setup() {
 	}
 }
 
-void Scene804::enter() {
-}
-
 void Scene804::step() {
 }
 
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 9a56ed3..87a23d1 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -347,7 +347,7 @@ int SpriteSets::add(SpriteAsset *asset, int idx) {
 	if (!idx)
 		idx = size();
 
-	if (idx >= (int)(size() + 1))
+	if (idx >= (int)size())
 		resize(idx + 1);
 	delete (*this)[idx];
 	(*this)[idx] = asset;


Commit: 8d3857c0536e47a6a03497346424c111b5bebd7b
    https://github.com/scummvm/scummvm/commit/8d3857c0536e47a6a03497346424c111b5bebd7b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-08T08:44:01-05:00

Commit Message:
MADS: Cleanup code for accessing sprite assets

Changed paths:
    engines/mads/animation.cpp
    engines/mads/messages.cpp
    engines/mads/scene_data.cpp
    engines/mads/sequence.cpp
    engines/mads/sprites.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 588e4ea..3508631 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -332,8 +332,8 @@ void Animation::loadFrame(int frameNumber) {
 		return;
 
 	Common::Point pt;
-	int listIndex = _spriteListIndexes[_header._spritesIndex];
-	SpriteAsset &spriteSet = scene._spriteSlots.getSprite(listIndex);
+	int spriteListIndex = _spriteListIndexes[_header._spritesIndex];
+	SpriteAsset &spriteSet = *scene._sprites[spriteListIndex];
 
 	if (_unkIndex < 0) {
 		MSurface *frame = spriteSet.getFrame(0);
@@ -480,8 +480,8 @@ void Animation::update() {
 					slot.copy(_frameEntries[_oldFrameEntry]._spriteSlot);
 					slot._seqIndex = _frameEntries[_oldFrameEntry]._seqIndex + 0x80;
 
-					SpriteAsset &spriteSet = scene._spriteSlots.getSprite(
-						scene._spriteSlots[slotIndex]._spritesIndex);
+					SpriteAsset &spriteSet = *scene._sprites[
+						scene._spriteSlots[slotIndex]._spritesIndex];
 					slot._spriteType = spriteSet.isBackground() ? ST_BACKGROUND : ST_FOREGROUND;
 				}
 				break;
diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index 69d9843..0e66626 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -194,7 +194,7 @@ void KernelMessages::processText(int msgIndex) {
 	if (msg._flags & KMSG_SEQ_ENTRY) {
 		SequenceEntry &seqEntry = scene._sequences[msg._sequenceIndex];
 		if (!seqEntry._nonFixed) {
-			SpriteAsset &spriteSet = scene._spriteSlots.getSprite(seqEntry._spritesIndex);
+			SpriteAsset &spriteSet = *scene._sprites[seqEntry._spritesIndex];
 			MSprite *frame = spriteSet.getFrame(seqEntry._frameIndex - 1);
 			x1 = frame->getBounds().left;
 			y1 = frame->getBounds().top;
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index c15a387..ed53bca 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -193,7 +193,7 @@ void DirtyArea::setSpriteSlot(const SpriteSlot *spriteSlot) {
 		_bounds.left = spriteSlot->_position.x - scene._posAdjust.x;
 		_bounds.top = spriteSlot->_position.y - scene._posAdjust.y;
 
-		SpriteAsset &spriteSet = scene._spriteSlots.getSprite(spriteSlot->_spritesIndex);
+		SpriteAsset &spriteSet = *scene._sprites[spriteSlot->_spritesIndex];
 		MSprite *frame = spriteSet.getFrame(((spriteSlot->_frameNumber & 0x7fff) - 1) & 0x7f);
 
 		if (spriteSlot->_scale == -1) {
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 93cc9ea..1e92810 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -95,7 +95,7 @@ int SequenceList::add(int spriteListIndex, bool flipped, int frameIndex, int tri
 	if (frameStart <= 0)
 		frameStart = 1;
 	if (numSprites == 0)
-		numSprites = scene._spriteSlots.getSprite(spriteListIndex).getCount();
+		numSprites = scene._sprites[spriteListIndex]->getCount();
 	if (frameStart == numSprites)
 		frameInc = 0;
 
@@ -169,7 +169,7 @@ void SequenceList::remove(int seqIndex) {
 void SequenceList::setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot) {
 	Scene &scene = _vm->_game->_scene;
 	SequenceEntry &timerEntry = _entries[seqIndex];
-	SpriteAsset &spriteSet = scene._spriteSlots.getSprite(timerEntry._spritesIndex);
+	SpriteAsset &spriteSet = *scene._sprites[timerEntry._spritesIndex];
 
 	spriteSlot._spriteType = spriteSet.isBackground() ? ST_BACKGROUND : ST_FOREGROUND;
 	spriteSlot._seqIndex = seqIndex;
@@ -209,7 +209,7 @@ bool SequenceList::loadSprites(int seqIndex) {
 		int x2 = 0, y2 = 0;
 
 		if ((seqEntry._field13 != 0) || (seqEntry._dynamicHotspotIndex >= 0)) {
-			SpriteAsset &spriteSet = scene._spriteSlots.getSprite(seqEntry._spritesIndex);
+			SpriteAsset &spriteSet = *scene._sprites[seqEntry._spritesIndex];
 			MSprite *frame = spriteSet.getFrame(seqEntry._frameIndex - 1);
 			int width = frame->getWidth() * seqEntry._scale / 200;
 			int height = frame->getHeight() * seqEntry._scale / 100;
@@ -340,7 +340,7 @@ void SequenceList::delay(uint32 priorFrameTime, uint32 currentTime) {
 void SequenceList::setAnimRange(int seqIndex, int startVal, int endVal) {
 	Scene &scene = _vm->_game->_scene;	
 	SequenceEntry &seqEntry = _entries[seqIndex];
-	SpriteAsset &spriteSet = scene._spriteSlots.getSprite(seqEntry._spritesIndex);
+	SpriteAsset &spriteSet = *scene._sprites[seqEntry._spritesIndex];
 	int numSprites = spriteSet.getCount();
 	int tempStart = startVal, tempEnd = endVal;
 
@@ -397,7 +397,7 @@ void SequenceList::setMsgPosition(int seqIndex, const Common::Point &pt) {
 
 int SequenceList::addSpriteCycle(int srcSpriteIdx, bool flipped, int numTicks, int triggerCountdown, int timeoutTicks, int extraTicks) {
 	Scene &scene = _vm->_game->_scene;
-	MSprite *spriteFrame = scene._spriteSlots.getSprite(srcSpriteIdx).getFrame(0);
+	MSprite *spriteFrame = scene._sprites[srcSpriteIdx]->getFrame(0);
 	int depth = scene._depthSurface.getDepth(Common::Point(spriteFrame->_pos.x + 
 		(spriteFrame->w / 2), spriteFrame->_pos.y + (spriteFrame->h / 2)));
 
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index b7e63a0..b92a6c2 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -176,9 +176,6 @@ public:
 	*/
 	void fullRefresh(bool clearAll = false);
 
-	SpriteAsset &getSprite(int idx) {
-		error("TODO");
-	}
 	void deleteTimer(int idx) {
 		warning("TODO: SpriteSlots::deleteTimer");
 	}


Commit: 0f214e4c9d72d088ccf088496710b20576ec73f5
    https://github.com/scummvm/scummvm/commit/0f214e4c9d72d088ccf088496710b20576ec73f5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-08T08:59:10-05:00

Commit Message:
MADS: Fix for loading animation data

Changed paths:
    engines/mads/animation.cpp
    engines/mads/compression.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 3508631..90f1331 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -207,10 +207,11 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 	for (int i = 0; i < _header._spriteSetsCount; ++i)
 		_spriteListIndexes.push_back(-1);
 
+	int streamIndex = 1;
 	_messages.clear();
 	if (_header._messagesCount > 0) {
 		// Chunk 2: Following is a list of any messages for the animation
-		Common::SeekableReadStream *msgStream = madsPack.getItemStream(1);
+		Common::SeekableReadStream *msgStream = madsPack.getItemStream(streamIndex++);
 
 		for (int i = 0; i < _header._messagesCount; ++i) {
 			AnimMessage rec;
@@ -224,7 +225,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 	_frameEntries.clear();
 	if (_header._frameEntriesCount > 0) {
 		// Chunk 3: animation frame info
-		Common::SeekableReadStream *frameStream = madsPack.getItemStream(2);
+		Common::SeekableReadStream *frameStream = madsPack.getItemStream(streamIndex++);
 
 		for (int i = 0; i < _header._frameEntriesCount; i++) {
 			AnimFrameEntry rec;
@@ -238,7 +239,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 	_miscEntries.clear();
 	if (_header._miscEntriesCount > 0) {
 		// Chunk 4: Misc Data
-		Common::SeekableReadStream *miscStream = madsPack.getItemStream(3);
+		Common::SeekableReadStream *miscStream = madsPack.getItemStream(streamIndex++);
 
 		for (int i = 0; i < _header._miscEntriesCount; ++i) {
 			AnimMiscEntry rec;
diff --git a/engines/mads/compression.h b/engines/mads/compression.h
index bf690dc..aa1f0d9 100644
--- a/engines/mads/compression.h
+++ b/engines/mads/compression.h
@@ -54,9 +54,15 @@ public:
 	~MadsPack();
 
 	int getCount() const { return _count; }
-	MadsPackEntry &getItem(int index) const { return _items[index]; }
-	MadsPackEntry &operator[](int index) const { return _items[index]; }
+	MadsPackEntry &getItem(int index) const { 
+		assert(index < _count);
+		return _items[index]; }
+	MadsPackEntry &operator[](int index) const { 
+		assert(index < _count);
+		return _items[index]; 
+	}
 	Common::MemoryReadStream *getItemStream(int index) {
+		assert(index < _count);
 		return new Common::MemoryReadStream(_items[index].data, _items[index].size,
 			DisposeAfterUse::NO);
 	}


Commit: 9c88ed16828ef6dde467fc03bb9af8d04b0bb3e2
    https://github.com/scummvm/scummvm/commit/9c88ed16828ef6dde467fc03bb9af8d04b0bb3e2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-08T10:28:59-05:00

Commit Message:
MADS: Fix loading user interface background

Changed paths:
    engines/mads/interface.cpp



diff --git a/engines/mads/interface.cpp b/engines/mads/interface.cpp
index e310561..79ae1d7 100644
--- a/engines/mads/interface.cpp
+++ b/engines/mads/interface.cpp
@@ -77,7 +77,7 @@ void InterfaceSurface::setup(int id) {
 		// Strip off any extension
 		const char *p = strchr(resName.c_str(), '.');
 		if (p) {
-			resName = Common::String(resName.c_str(), p - 1);
+			resName = Common::String(resName.c_str(), p);
 		}
 
 		// Add on suffix if necessary


Commit: 984099ae2ca9dd53b47e44e7815c560c68acbd61
    https://github.com/scummvm/scummvm/commit/984099ae2ca9dd53b47e44e7815c560c68acbd61
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-08T10:53:10-05:00

Commit Message:
MADS: Implemented stubbed SpriteSlots methods

Changed paths:
    engines/mads/animation.cpp
    engines/mads/sequence.cpp
    engines/mads/sprites.cpp
    engines/mads/sprites.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 90f1331..e4549d1 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -447,7 +447,7 @@ void Animation::update() {
 
 	int newIndex = -1;
 	if (paChanged) {
-		newIndex = scene._spriteSlots.getIndex();
+		newIndex = scene._spriteSlots.add();
 		scene._spriteSlots[newIndex]._seqIndex = -1;
 		scene._spriteSlots[newIndex]._spriteType = ST_FULL_SCREEN_REFRESH;
 	}
@@ -476,7 +476,7 @@ void Animation::update() {
 				}
 
 				if (spriteSlotIndex == 0) {
-					int slotIndex = scene._spriteSlots.getIndex();
+					int slotIndex = scene._spriteSlots.add();
 					SpriteSlot &slot = scene._spriteSlots[slotIndex];
 					slot.copy(_frameEntries[_oldFrameEntry]._spriteSlot);
 					slot._seqIndex = _frameEntries[_oldFrameEntry]._seqIndex + 0x80;
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 1e92810..ec9c1a8 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -202,7 +202,7 @@ bool SequenceList::loadSprites(int seqIndex) {
 		// Doesn't have an associated sprite anymore, so mark as done
 		seqEntry._doneFlag = true;
 	}
-	else if ((slotIndex = scene._spriteSlots.getIndex()) >= 0) {
+	else if ((slotIndex = scene._spriteSlots.add()) >= 0) {
 		SpriteSlot &spriteSlot = scene._spriteSlots[slotIndex];
 		setSpriteSlot(seqIndex, spriteSlot);
 
@@ -377,7 +377,7 @@ void SequenceList::scan() {
 
 	for (uint i = 0; i < _entries.size(); ++i) {
 		if (!_entries[i]._active && (_entries[i]._spritesIndex != -1)) {
-			int idx = scene._spriteSlots.getIndex();
+			int idx = scene._spriteSlots.add();
 			setSpriteSlot(i, scene._spriteSlots[idx]);
 		}
 	}
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 87a23d1..82e45de 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -70,7 +70,6 @@ MSprite::MSprite(Common::SeekableReadStream *source, const Common::Point &offset
 MSprite::~MSprite() {
 }
 
-
 // TODO: The sprite outlines (pixel value 0xFD) are not shown
 void MSprite::loadSprite(Common::SeekableReadStream *source) {
 	byte *outp, *lineStart;
@@ -217,6 +216,21 @@ void SpriteSlots::fullRefresh(bool clearAll) {
 	push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1));
 }
 
+void SpriteSlots::deleteTimer(int seqIndex) {
+	for (uint idx = 0; idx < size(); ++idx) {
+		if ((*this)[idx]._seqIndex == seqIndex) {
+			remove_at(idx);
+			return;
+		}
+	}
+}
+
+int SpriteSlots::add() {
+	SpriteSlot ss;
+	push_back(ss);
+	return size() - 1;
+}
+
 void SpriteSlots::drawBackground() {
 	Scene &scene = _vm->_game->_scene;
 
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index b92a6c2..2a85115 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -176,13 +176,15 @@ public:
 	*/
 	void fullRefresh(bool clearAll = false);
 
-	void deleteTimer(int idx) {
-		warning("TODO: SpriteSlots::deleteTimer");
-	}
-	int getIndex() {
-		warning("TODO: SpriteSlots::indexOf");
-		return -1;
-	}
+	/**
+	 * Delete a timer entry with the given Id
+	 */
+	void deleteTimer(int seqIndex);
+
+	/**
+	 * Add a new slot entry and return it's index 
+	 */
+	int add();
 
 	/**
 	 * Draw any sprites into the background of the scene


Commit: c2587af8f29b2b79beae7fda5a9b983614840b17
    https://github.com/scummvm/scummvm/commit/c2587af8f29b2b79beae7fda5a9b983614840b17
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-08T14:05:17-05:00

Commit Message:
MADS: Clarified Events::_currentTimer as Scene::_frameStartTime

Changed paths:
    engines/mads/animation.cpp
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/game.cpp
    engines/mads/player.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/sequence.cpp



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index e4549d1..fad5b27 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -317,7 +317,7 @@ void Animation::startAnimation(int abortTimers) {
 
 	_currentFrame = 0;
 	_oldFrameEntry = 0;
-	_nextFrameTimer = _vm->_events->_currentTimer;
+	_nextFrameTimer = _vm->_game->_scene._frameStartTime;
 	_abortTimers = abortTimers;
 	_abortTimersMode = _vm->_game->_abortTimersMode2;
 	_vm->_game->_scene._action._activeAction = _actionDetails;
@@ -402,7 +402,7 @@ void Animation::update() {
 	}
 
 	// If it's not time for the next frame, then exit
-	if (_vm->_events->_currentTimer < _nextFrameTimer)
+	if (_vm->_game->_scene._frameStartTime < _nextFrameTimer)
 		return;
 
 	for (uint idx = 0; idx < scene._spriteSlots.size(); ++idx) {
@@ -546,7 +546,7 @@ void Animation::update() {
 	}
 
 	int frameNum = MIN(_currentFrame, (int)_miscEntries.size() - 1);
-	_nextFrameTimer = _vm->_events->_currentTimer + _miscEntries[frameNum]._numTicks;
+	_nextFrameTimer = _vm->_game->_scene._frameStartTime + _miscEntries[frameNum]._numTicks;
 }
 
 void Animation::setCurrentFrame(int frameNumber) {
@@ -554,7 +554,7 @@ void Animation::setCurrentFrame(int frameNumber) {
 	_oldFrameEntry = 0;
 	_freeFlag = false;
 
-	_nextScrollTimer = _nextFrameTimer = _vm->_events->_currentTimer;
+	_nextScrollTimer = _nextFrameTimer = _vm->_game->_scene._frameStartTime;
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 7fa31d7..59cdfbf 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -41,7 +41,6 @@ EventsManager::EventsManager(MADSEngine *vm) {
 	_keyPressed = false;
 	_mouseClicked = false;
 	_mouseReleased = false;
-	_currentTimer = 0;
 	_mouseButtons = 0;
 	_vD2 = 0;
 	_vD4 = 0;
diff --git a/engines/mads/events.h b/engines/mads/events.h
index f30e588..6f716d8 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -60,7 +60,6 @@ public:
 	bool _mouseReleased;
 	byte _mouseButtons;
 	bool _keyPressed;
-	uint32 _currentTimer;
 	int _vCC;
 	int _vD2;
 	int _vD4;
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 08a5f97a..0367aa6 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -84,6 +84,9 @@ void Game::run() {
 		break;
 	}
 
+	// Get the initial starting time for the first scene
+	_scene._frameStartTime = _vm->_events->getFrameCounter();
+
 	if (_saveSlot == -1 && protectionResult != -1 && protectionResult != -2) {
 		initSection(_sectionNumber);
 		_statusFlag = true;
@@ -199,7 +202,7 @@ void Game::sectionLoop() {
 		}
 		_abortTimers = 0;
 		_abortTimersMode2 = ABORTMODE_1;
-		_priorFrameTimer = _vm->_events->_currentTimer;
+		_priorFrameTimer = _scene._frameStartTime;
 
 		// Call the scene logic for entering the given scene
 		_scene._sceneLogic->enter();
@@ -212,7 +215,7 @@ void Game::sectionLoop() {
 		_player.updateFrame();
 		_player._visible3 = _player._visible;
 		_player._special = _scene.getDepthHighBits(_player._playerPos);
-		_player._priorTimer = _vm->_events->_currentTimer + _player._ticksAmount;
+		_player._priorTimer = _scene._frameStartTime + _player._ticksAmount;
 		_player.idle();
 
 		warning("TODO: _selectedObject IF block");
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index d19a0cb..ef2ce9f 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -94,9 +94,11 @@ void Player::setDest(const Common::Point &pt, int facing) {
 }
 
 void Player::nextFrame() {
+	Scene &scene = _vm->_game->_scene;
+
 	_priorTimer += _ticksAmount;
-	if (_vm->_events->_currentTimer >= _priorTimer) {
-		_priorTimer = _vm->_events->_currentTimer;
+	if (scene._frameStartTime >= _priorTimer) {
+		_priorTimer = scene._frameStartTime;
 		if (_moving) {
 			move();
 		} else {
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index c7a6ede..17c579b 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -49,6 +49,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 	_animationData = nullptr;
 	_activeAnimation = nullptr;
 	_textSpacing = -1;
+	_frameStartTime = 0;
 
 	_verbList.push_back(VerbInit(VERB_LOOK, 2, 0));
 	_verbList.push_back(VerbInit(VERB_TAKE, 2, 0));
@@ -314,7 +315,7 @@ void Scene::doFrame() {
 
 	checkStartWalk();
 	if (!_vm->_game->_abortTimers2)
-		_vm->_events->_currentTimer = _vm->_events->getFrameCounter();
+		_frameStartTime = _vm->_events->getFrameCounter();
 
 	if ((_action._inProgress && !player._moving && !_action._startWalkFlag &&
 			player._newDirection == player._direction) ||
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index e2aa109..969fb0b 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -124,6 +124,7 @@ public:
 	Common::Point _destPos;
 	int _destFacing;
 	Common::Point _posAdjust;
+	uint32 _frameStartTime;
 
 	/**
 	 * Constructor
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index ec9c1a8..e8c5a37 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -116,7 +116,7 @@ int SequenceList::add(int spriteListIndex, bool flipped, int frameIndex, int tri
 	_entries[seqIndex]._numTicks = numTicks;
 	_entries[seqIndex]._extraTicks = extraTicks;
 
-	_entries[seqIndex]._timeout = _vm->_events->_currentTimer + delayTicks;
+	_entries[seqIndex]._timeout = scene._frameStartTime + delayTicks;
 
 	_entries[seqIndex]._triggerCountdown = triggerCountdown;
 	_entries[seqIndex]._doneFlag = false;
@@ -131,6 +131,7 @@ int SequenceList::add(int spriteListIndex, bool flipped, int frameIndex, int tri
 }
 
 int SequenceList::addTimer(int time, int abortVal) {
+	Scene &scene = _vm->_game->_scene;
 	uint seqIndex;
 	for (seqIndex = 0; seqIndex < _entries.size(); ++seqIndex) {
 		if (!_entries[seqIndex]._active)
@@ -143,7 +144,7 @@ int SequenceList::addTimer(int time, int abortVal) {
 	se._spritesIndex = -1;
 	se._numTicks = time;
 	se._extraTicks = 0;
-	se._timeout = _vm->_events->_currentTimer + time;
+	se._timeout = scene._frameStartTime + time;
 	se._triggerCountdown = true;
 	se._doneFlag = false;
 	se._entries._count = 0;
@@ -309,12 +310,13 @@ bool SequenceList::loadSprites(int seqIndex) {
 * Handles counting down entries in the timer list for action
 */
 void SequenceList::tick() {
+	Scene &scene = _vm->_game->_scene;
 	for (uint idx = 0; idx < _entries.size(); ++idx) {
 		if ((_vm->_game->_abortTimers2 == 0) && (_vm->_game->_abortTimers != 0))
 			break;
 
 		SequenceEntry &seqEntry = _entries[idx];
-		uint32 currentTimer = _vm->_events->_currentTimer;
+		uint32 currentTimer = scene._frameStartTime;
 
 		if (!seqEntry._active || (currentTimer < seqEntry._timeout))
 			continue;


Commit: 5536b8a933f792f45d08ab5126e826a9a20fa476
    https://github.com/scummvm/scummvm/commit/5536b8a933f792f45d08ab5126e826a9a20fa476
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-08T15:42:07-05:00

Commit Message:
MADS: Fixes for sprite list initialisation

Changed paths:
    engines/mads/animation.cpp
    engines/mads/game.cpp
    engines/mads/scene.cpp
    engines/mads/sequence.cpp
    engines/mads/sprites.cpp
    engines/mads/sprites.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index fad5b27..2117ae2 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -271,6 +271,7 @@ void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
 			_spriteSets[i] = nullptr;
 		} else {
 			_spriteSets[i] = new SpriteAsset(_vm, _header._spriteSetNames[i], flags);
+			_spriteListIndexes[i] = _vm->_game->_scene._sprites.add(_spriteSets[i]);
 		}
 	}
 
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 0367aa6..d206823 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -121,7 +121,7 @@ void Game::gameLoop() {
 		initSection(_sectionNumber);
 		_sectionHandler->postLoadSection();
 
-		_scene._spriteSlots.clear(true);
+		_scene._spriteSlots.reset();
 
 		if (_sectionNumber == _currentSectionNumber) {
 			sectionLoop();
@@ -164,7 +164,7 @@ void Game::sectionLoop() {
 			if (_player._spritesLoaded)
 				_scene._spriteSlots.releasePlayerSprites();
 			_vm->_palette->resetGamePalette(18, 10);
-			_scene._spriteSlots.clear(true);
+			_scene._spriteSlots.reset();
 		} else {
 			_vm->_palette->initGamePalette();
 		}
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 17c579b..8521c2e 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -126,7 +126,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	if (palFlag)
 		_vm->_palette->resetGamePalette(18, 10);
 
-	_spriteSlots.clear(false);
+	_spriteSlots.reset(false);
 	_sequences.clear();
 	_kernelMessages.clear();
 
@@ -166,7 +166,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	_bandsRange = _sceneInfo->_yBandsEnd - _sceneInfo->_yBandsStart;
 	_scaleRange = _sceneInfo->_maxScale - _sceneInfo->_minScale;
 
-	_spriteSlots.clear(false);
+	_spriteSlots.reset(false);
 	_interfaceY = MADS_SCENE_HEIGHT;
 	_spritesCount = _sprites.size();
 
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index e8c5a37..f703ce3 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -50,10 +50,12 @@ namespace MADS {
 
 	/*------------------------------------------------------------------------*/
 
-#define TIMER_LIST_SIZE 30
+#define SEQUENCE_LIST_SIZE 30
 
 SequenceList::SequenceList(MADSEngine *vm) : _vm(vm) {
-	for (int i = 0; i < TIMER_LIST_SIZE; ++i) {
+	// IMPORTANT: Preallocate timer slots. Note that sprite slots refer to entries 
+	// in this list by index, so we can't just add or delete entries later
+	for (int i = 0; i < SEQUENCE_LIST_SIZE; ++i) {
 		SequenceEntry rec;
 		rec._active = false;
 		rec._dynamicHotspotIndex = -1;
@@ -239,7 +241,7 @@ bool SequenceList::loadSprites(int seqIndex) {
 			if (seqEntry._frameIndex > seqEntry._numSprites) {
 				result = true;
 				if (seqEntry._animType == ANIMTYPE_CYCLED) {
-					// Reset back to the starting frame (cyclic)
+					//  back to the starting frame (cyclic)
 					seqEntry._frameIndex = seqEntry._frameStart;
 				}
 				else {
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 82e45de..b18efa2 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -168,7 +168,7 @@ SpriteSlots::SpriteSlots(MADSEngine *vm) : _vm(vm) {
 	SpriteSlot::_vm = vm;
 }
 
-void SpriteSlots::clear(bool flag) {
+void SpriteSlots::reset(bool flag) {
 	_vm->_game->_scene._textDisplay.clear();
 
 	if (flag)
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index 2a85115..0e4e86a 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -153,7 +153,7 @@ public:
 	* Clears any pending slot data and schedules a full screen refresh.
 	* @param flag		Also reset sprite list
 	*/
-	void clear(bool flag);
+	void reset(bool flag = true);
 
 	/**
 	* Delete any sprites used by the player


Commit: 8cd85f3a000ab755da7b13c8589d3c67c081122a
    https://github.com/scummvm/scummvm/commit/8cd85f3a000ab755da7b13c8589d3c67c081122a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-08T16:06:37-05:00

Commit Message:
MADS: Fixes for drawing scene elements

Changed paths:
    engines/mads/messages.cpp
    engines/mads/scene.cpp
    engines/mads/scene_data.cpp



diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index 0e66626..8bdbe72 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -340,7 +340,7 @@ int TextDisplayList::add(int xp, int yp, uint fontColor, int charSpacing,
 void TextDisplayList::setDirtyAreas() {
 	Scene &scene = _vm->_game->_scene;
 
-	for (uint idx = 0, dirtyIdx = DIRTY_AREAS_TEXT_DISPLAY_IDX; dirtyIdx < DIRTY_AREAS_SIZE; ++idx, ++dirtyIdx) {
+	for (uint idx = 0, dirtyIdx = DIRTY_AREAS_TEXT_DISPLAY_IDX; dirtyIdx < size(); ++idx, ++dirtyIdx) {
 		if (((*this)[idx]._expire >= 0) || !(*this)[idx]._active)
 			scene._dirtyAreas[dirtyIdx]._active = false;
 		else {
@@ -353,7 +353,7 @@ void TextDisplayList::setDirtyAreas() {
 void TextDisplayList::setDirtyAreas2() {
 	Scene &scene = _vm->_game->_scene;
 
-	for (uint idx = 0, dirtyIdx = DIRTY_AREAS_TEXT_DISPLAY_IDX; dirtyIdx < DIRTY_AREAS_SIZE; ++idx, ++dirtyIdx) {
+	for (uint idx = 0, dirtyIdx = DIRTY_AREAS_TEXT_DISPLAY_IDX; idx < size(); ++idx, ++dirtyIdx) {
 		if ((*this)[idx]._active && ((*this)[idx]._expire >= 0)) {
 			scene._dirtyAreas[dirtyIdx].setTextDisplay(&(*this)[idx]);
 			scene._dirtyAreas[dirtyIdx]._textActive = ((*this)[idx]._expire <= 0) ? 0 : 1;
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 8521c2e..11a5935 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -422,7 +422,7 @@ void Scene::doFrame() {
 	}
 
 	// TODO: Verify correctness of frame wait
-
+	_vm->_events->waitForNextFrame();
 }
 
 void Scene::drawElements(bool transitionFlag, bool surfaceFlag) {
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index ed53bca..36efcb3 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -233,7 +233,6 @@ DirtyAreas::DirtyAreas(MADSEngine *vm) : _vm(vm) {
 }
 
 void DirtyAreas::merge(int startIndex, int count) {
-	error("TODO: DirtyAreas::merge");
 	if (startIndex >= count)
 		return;
 


Commit: c89193f24f252cf1a7f744f2712218b6808370fc
    https://github.com/scummvm/scummvm/commit/c89193f24f252cf1a7f744f2712218b6808370fc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-08T18:12:06-05:00

Commit Message:
MADS: Removed old RGBList code from old M4 engine

Changed paths:
    engines/mads/font.cpp
    engines/mads/msurface.cpp
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/font.cpp b/engines/mads/font.cpp
index 0ff0190..b8f8187 100644
--- a/engines/mads/font.cpp
+++ b/engines/mads/font.cpp
@@ -30,11 +30,12 @@ namespace MADS {
 
 Font::Font(MADSEngine *vm) : _vm(vm) {
 	_sysFont = true;
-	
+	/*
 	_fontColors[0] = _vm->_palette->BLACK;
 	_fontColors[1] = _vm->_palette->WHITE;
 	_fontColors[2] = _vm->_palette->BLACK;
 	_fontColors[3] = _vm->_palette->DARK_GRAY;
+	*/
 }
 
 Font::~Font() {
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 74043bf..3a38360 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -196,7 +196,7 @@ void MSurface::drawSprite(const Common::Point &pt, SpriteInfo &info, const Commo
 }
 
 void MSurface::empty() {
-	Common::fill(getBasePtr(0, 0), getBasePtr(0, h), _vm->_palette->BLACK);
+	Common::fill(getBasePtr(0, 0), getBasePtr(0, h), 0);
 }
 
 void MSurface::copyFrom(MSurface *src, const Common::Rect &srcBounds, 
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 4568f7d..a0e58ca 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -37,28 +37,6 @@ void RGB6::load(Common::SeekableReadStream *f) {
 	flags = f->readByte();
 }
 
-RGBList::RGBList(int numEntries, byte *srcData, bool freeData) {
-	_size = numEntries;
-	assert(numEntries <= PALETTE_COUNT);
-
-	if (srcData == NULL) {
-		_data = new byte[numEntries * 3];
-		_freeData = true;
-	} else {
-		_data = srcData;
-		_freeData = freeData;
-	}
-
-	_palIndexes = new byte[numEntries];
-	Common::fill(&_palIndexes[0], &_palIndexes[numEntries], 0);
-}
-
-RGBList::~RGBList() {
-	if (_freeData)
-		delete[] _data;
-	delete[] _palIndexes;
-}
-
 /*------------------------------------------------------------------------*/
 
 PaletteUsage::PaletteUsage() {
@@ -220,97 +198,6 @@ uint8 Palette::palIndexFromRgb(byte r, byte g, byte b, byte *paletteData) {
 }
 
 void Palette::reset() {
-	byte palData[PALETTE_SIZE];
-	g_system->getPaletteManager()->grabPalette(palData, 0, PALETTE_COUNT);
-
-	BLACK = palIndexFromRgb(0, 0, 0, palData);
-	BLUE = palIndexFromRgb(0, 0, 255, palData);
-	GREEN = palIndexFromRgb(0, 255, 0, palData);
-	CYAN = palIndexFromRgb(0, 255, 255, palData);
-	RED = palIndexFromRgb(255, 0, 0, palData);
-	VIOLET = palIndexFromRgb(255, 0, 255, palData);
-	BROWN = palIndexFromRgb(168, 84, 84, palData);
-	LIGHT_GRAY = palIndexFromRgb(168, 168, 168, palData);
-	DARK_GRAY = palIndexFromRgb(84, 84, 84, palData);
-	LIGHT_BLUE = palIndexFromRgb(0, 0, 127, palData);
-	LIGHT_GREEN = palIndexFromRgb(0, 127, 0, palData);
-	LIGHT_CYAN = palIndexFromRgb(0, 127, 127, palData);
-	LIGHT_RED = palIndexFromRgb(84, 0, 0, palData);
-	PINK = palIndexFromRgb(84, 0, 0, palData);
-	YELLOW = palIndexFromRgb(0, 84, 84, palData);
-	WHITE = palIndexFromRgb(255, 255, 255, palData);
-}
-
-void Palette::resetColorCounts() {
-	Common::fill(&_usageCount[0], &_usageCount[PALETTE_COUNT], 0);
-}
-
-void Palette::blockRange(int startIndex, int size) {
-	// Use a reference count of -1 to signal a palette index shouldn't be used
-	Common::fill(&_usageCount[startIndex], &_usageCount[startIndex + size], -1);
-}
-
-void Palette::addRange(RGBList *list) {
-	byte *data = list->data();
-	byte *palIndexes = list->palIndexes();
-	byte palData[PALETTE_COUNT];
-	g_system->getPaletteManager()->grabPalette(palData, 0, PALETTE_COUNT);
-	bool paletteChanged = false;
-	
-	for (int colIndex = 0; colIndex < list->size(); ++colIndex) {
-		// Scan through for an existing copy of the RGB value
-		int palIndex = -1; 
-		while (++palIndex < PALETTE_COUNT) {
-			if (_usageCount[palIndex] <= 0)
-				// Palette index is to be skipped
-				continue;
-
-			if ((palData[palIndex * 3] == data[colIndex * 3]) && 
-				(palData[palIndex * 3 + 1] == data[colIndex * 3 + 1]) &&
-				(palData[palIndex * 3 + 2] == data[colIndex * 3 + 2])) 
-				// Match found
-				break;
-		}
-
-		if (palIndex == PALETTE_COUNT) {
-			// No match found, so find a free slot to use
-			palIndex = -1;
-			while (++palIndex < PALETTE_COUNT) {
-				if (_usageCount[palIndex] == 0)
-					break;
-			}
-
-			if (palIndex == PALETTE_COUNT) 
-				error("addRange - Ran out of palette space to allocate");
-
-			palData[palIndex * 3] = data[colIndex * 3];
-			palData[palIndex * 3 + 1] = data[colIndex * 3 + 1];
-			palData[palIndex * 3 + 2] = data[colIndex * 3 + 2];
-			paletteChanged = true;
-		}
-
-		palIndexes[colIndex] = palIndex;
-		++_usageCount[palIndex];
-	}
-
-	if (paletteChanged) {
-		g_system->getPaletteManager()->setPalette(&palData[0], 0, 256);
-		reset();
-	}
-}
-
-void Palette::deleteRange(RGBList *list) {
-	// Release the reference count on each of the palette entries
-	for (int colIndex = 0; colIndex < list->size(); ++colIndex) {
-		int palIndex = list->palIndexes()[colIndex];
-		assert(_usageCount[palIndex] > 0);
-		--_usageCount[palIndex];
-	}
-}
-
-void Palette::deleteAllRanges() {
-	for (int colIndex = 0; colIndex < 255; ++colIndex)
-		_usageCount[colIndex] = 0;
 }
 
 void Palette::setGradient(byte *palette, int start, int count, int rgbValue1, int rgbValue2) {
@@ -373,8 +260,6 @@ int Palette::loadPalette(Common::SeekableReadStream *palStream, int indexStart)
 }
 
 void Palette::setSystemPalette() {
-	resetColorCounts();
-
 	byte palData[4 * 3];
 	palData[0 * 3] = palData[0 * 3 + 1] = palData[0 * 3 + 2] = 0;
 	palData[1 * 3] = palData[1 * 3 + 1] = palData[1 * 3 + 2] = 0x54;
@@ -382,7 +267,6 @@ void Palette::setSystemPalette() {
 	palData[3 * 3] = palData[3 * 3 + 1] = palData[3 * 3 + 2] = 0xff;
 	
 	setPalette(palData, 0, 4);
-	blockRange(0, 4);
 }
 
 void Palette::resetGamePalette(int lowRange, int highRange) {
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index a00e178..d85e25b 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -50,42 +50,6 @@ struct RGB6 {
 	void load(Common::SeekableReadStream *f);
 };
 
-/**
- * Used to store a list of RGB values
- */
-class RGBList {
-private:
-	int _size;
-	byte *_data;
-	byte *_palIndexes;
-	bool _freeData;
-public:
-	/** 
-	 * Constructor
-	 */
-	RGBList(int numEntries = 256, byte *srcData = NULL, bool freeData = true);
-
-	/**
-	 * Destructor
-	 */
-	~RGBList();
-
-	/**
-	 * Returns the raw data containing the RGB values as 3 bytes per entry
-	 */
-	byte *data() { return _data; }
-
-	/**
-	 * Returns the list of palette indexes each RGB tuple maps to in the current palette
-	 */
-	byte *palIndexes() { return _palIndexes; }
-
-	/**
-	 * Returns the size of the palette
-	 */
-	int size() const { return _size; }
-};
-
 class PaletteUsage {
 private:
 	Common::Array<int> _data;
@@ -180,33 +144,6 @@ public:
 	 */
 	uint8 palIndexFromRgb(byte r, byte g, byte b, byte *paletteData = nullptr);
 
-	// Methods used for reference counting color usage
-	/**
-	 * Resets the usage counts for the palette
-	 */
-	void resetColorCounts();
-
-	/**
-	 * Blocks out a range of the palette from being used
-	 */
-	void blockRange(int startIndex, int size);
-
-	/**
-	 * Adds the data of an RGBList into the current palette and increment usage counts.
-	 */
-	void addRange(RGBList *list);
-
-	/**
-	 * Delets a range from the current palette, dercementing the accompanying usage counts.
-	 */
-	void deleteRange(RGBList *list);
-
-	/**
-	 * Deletes all loaded RGB lists are their usage references.
-	 */
-	void deleteAllRanges();
-
-	// Virtual method table
 	/**
 	 * Decode a palette and return it, without affecting the Palette itself
 	 */
@@ -248,24 +185,6 @@ public:
 	void close() {
 		warning("TODO: Palette::close");
 	}
-
-	// Color indexes
-	uint8 BLACK;
-	uint8 BLUE;
-	uint8 GREEN;
-	uint8 CYAN;
-	uint8 RED;
-	uint8 VIOLET;
-	uint8 BROWN;
-	uint8 LIGHT_GRAY;
-	uint8 DARK_GRAY;
-	uint8 LIGHT_BLUE;
-	uint8 LIGHT_GREEN;
-	uint8 LIGHT_CYAN;
-	uint8 LIGHT_RED;
-	uint8 PINK;
-	uint8 YELLOW;
-	uint8 WHITE;
 };
 
 } // End of namespace MADS


Commit: 680b5a4487a6c1b08f79c4a657b63715e69240de
    https://github.com/scummvm/scummvm/commit/680b5a4487a6c1b08f79c4a657b63715e69240de
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-10T00:00:39-04:00

Commit Message:
MADS: In progress implementation of PaletteUsage::process

Changed paths:
    engines/mads/assets.cpp
    engines/mads/assets.h
    engines/mads/game.cpp
    engines/mads/graphics.cpp
    engines/mads/graphics.h
    engines/mads/interface.cpp
    engines/mads/mads.cpp
    engines/mads/msurface.cpp
    engines/mads/msurface.h
    engines/mads/palette.cpp
    engines/mads/palette.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/sprites.cpp
    engines/mads/sprites.h



diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index ebedeb8..554cd9a 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -54,6 +54,7 @@ void SpriteAsset::load(Common::SeekableReadStream *stream, int flags) {
 	_pixelSpeed = 0;
 	_maxWidth = 0;
 	_maxHeight = 0;
+	_field6 = -1;
 
 	Common::SeekableReadStream *spriteStream = sprite.getItemStream(0);
 	_mode = spriteStream->readByte();
diff --git a/engines/mads/assets.h b/engines/mads/assets.h
index 30676a1..c0d1feb 100644
--- a/engines/mads/assets.h
+++ b/engines/mads/assets.h
@@ -77,6 +77,7 @@ private:
 	void load(Common::SeekableReadStream *stream, int flags);
 public:
 	SpriteSetCharInfo *_charInfo;
+	int _field6;
 public:
 	/**
 	 * Constructor
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index d206823..e0d3ca1 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -191,15 +191,16 @@ void Game::sectionLoop() {
 
 		switch (_vm->_screenFade) {
 		case SCREEN_FADE_SMOOTH:
-			_abortTimers2 = 2;
+			_abortTimers2 = kTransitionFadeOutIn;
 			break;
 		case SCREEN_FADE_FAST:
-			_abortTimers2 = 20;
+			_abortTimers2 = kCenterVertTransition;
 			break;
 		default:
-			_abortTimers2 = 21;
+			_abortTimers2 = kTransitionNone;
 			break;
 		}
+
 		_abortTimers = 0;
 		_abortTimersMode2 = ABORTMODE_1;
 		_priorFrameTimer = _scene._frameStartTime;
diff --git a/engines/mads/graphics.cpp b/engines/mads/graphics.cpp
index f4d788f..769b4dd 100644
--- a/engines/mads/graphics.cpp
+++ b/engines/mads/graphics.cpp
@@ -22,7 +22,9 @@
 
 #include "common/scummsys.h"
 #include "mads/mads.h"
+#include "mads/game.h"
 #include "mads/graphics.h"
+#include "mads/palette.h"
 
 namespace MADS {
 
@@ -35,8 +37,41 @@ void ScreenSurface::updateScreen() {
 	g_system->updateScreen();
 }
 
-void ScreenSurface::transition(bool transitionFlag, bool surfaceFlag) {
+void ScreenSurface::transition(ScreenTransition transitionType, bool surfaceFlag) {
+	switch (transitionType) {
+	case kTransitionFadeOutIn:
+		fadeOut();
+		fadeIn();
+		break;
 
+	case kTransitionFadeIn:
+		fadeIn();
+		break;
+
+	case kTransitionBoxInBottomLeft:
+	case kTransitionBoxInBottomRight:
+	case kTransitionBoxInTopLeft:
+	case kTransitionBoxInTopRight:
+		error("TODO: transition");
+		break;
+
+	case kTransitionPanLeftToRight:
+	case kTransitionPanRightToLeft:
+		error("TODO: transition");
+
+	case kTransitionCircleIn1:
+	case kTransitionCircleIn2:
+	case kTransitionCircleIn3:
+	case kTransitionCircleIn4:
+		error("TODO circle transition");
+
+	case kCenterVertTransition:
+		error("TODO: center vert transition");
+
+	default:
+		// Quick transitions
+		break;
+	}
 }
 
 void ScreenSurface::setPointer(MSurface *s) {
@@ -44,5 +79,13 @@ void ScreenSurface::setPointer(MSurface *s) {
 	_pitch = s->w;
 }
 
+void ScreenSurface::fadeOut() {
+	warning("TODO: Proper fade out");
+}
+
+void ScreenSurface::fadeIn() {
+	warning("TODO: Proper fade in");
+	_vm->_palette->setFullPalette(_vm->_palette->_mainPalette);
+}
 
 } // End of namespace MADS
diff --git a/engines/mads/graphics.h b/engines/mads/graphics.h
index b64bced..d4933ae 100644
--- a/engines/mads/graphics.h
+++ b/engines/mads/graphics.h
@@ -32,7 +32,30 @@ namespace MADS {
 #define MADS_SCREEN_WIDTH 320
 #define MADS_SCREEN_HEIGHT 200
 
+enum ScreenTransition {
+	kTransitionNone = 0,
+	kTransitionFadeIn, kTransitionFadeOutIn,
+	kTransitionBoxInBottomLeft, kTransitionBoxInBottomRight,
+	kTransitionBoxInTopLeft, kTransitionBoxInTopRight,
+	kTransitionPanLeftToRight, kTransitionPanRightToLeft,
+	kTransitionCircleIn1, kTransitionCircleIn2,
+	kTransitionCircleIn3, kTransitionCircleIn4,
+	kVertTransition1, kVertTransition2, kVertTransition3,
+	kVertTransition4, kVertTransition5, kVertTransition6,
+	kVertTransition7, kCenterVertTransition
+};
+
 class ScreenSurface : public MSurface {
+private:
+	/**
+	 * Handles screen fade out
+	 */
+	void fadeOut();
+
+	/**
+	 * Handles screen fade in
+	 */
+	void fadeIn();
 public:
 	Common::Point _offset;
 	byte *_pixels;
@@ -55,7 +78,7 @@ public:
 	 */
 	void updateScreen();
 
-	void transition(bool transitionFlag, bool surfaceFlag);
+	void transition(ScreenTransition transitionType, bool surfaceFlag);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/interface.cpp b/engines/mads/interface.cpp
index 79ae1d7..cd2f162 100644
--- a/engines/mads/interface.cpp
+++ b/engines/mads/interface.cpp
@@ -101,7 +101,7 @@ void InterfaceSurface::setup(int id) {
 	copyTo(&_surface);
 
 	if (_vm->_game->_v1 == 5)
-		scene._imageInterEntries.call(0);
+		scene._imageInterEntries.call(0, 0);
 
 	scene._action.clear();
 	writeText();
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index c6d2e2e..0327a9f 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -41,7 +41,7 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :
 	_easyMouse = true;
 	_invObjectStill = false;
 	_textWindowStill = false;
-	_screenFade = SCREEN_FADE_FAST;
+	_screenFade = SCREEN_FADE_SMOOTH;
 	_musicFlag = false;
 
 	_debugger = nullptr;
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 3a38360..f21836e 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -478,7 +478,7 @@ void MSurface::translate(Common::Array<RGB6> &palette) {
 		byte *pDest = getBasePtr(0, y);
 
 		for (int x = 0; x < this->w; ++x, ++pDest) {
-			*pDest = palette[*pDest].palIndex;
+			*pDest = palette[*pDest]._palIndex;
 		}
 	}
 }
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index 9699417..d5b8741 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -50,7 +50,7 @@ struct SpriteInfo {
  * MADS graphics surface
  */
 class MSurface : public Graphics::Surface {
-private:
+protected:
 	static MADSEngine *_vm;
 public:
 	/**
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index a0e58ca..da59707 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -32,14 +32,15 @@ void RGB6::load(Common::SeekableReadStream *f) {
 	r = f->readByte();
 	g = f->readByte();
 	b = f->readByte();
-	palIndex = f->readByte();
-	u2 = f->readByte();
-	flags = f->readByte();
+	_palIndex = f->readByte();
+	_u2 = f->readByte();
+	_flags = f->readByte();
 }
 
 /*------------------------------------------------------------------------*/
 
-PaletteUsage::PaletteUsage() {
+PaletteUsage::PaletteUsage(MADSEngine *vm) {
+	_vm = vm;
 }
 
 void PaletteUsage::load(int count, ...) {
@@ -58,7 +59,7 @@ void PaletteUsage::getKeyEntries(Common::Array<RGB6> &palette) {
 	_data.clear();
 
 	 for (uint i = 0; i < palette.size(); ++i) {
-		 byte *uPtr = &palette[i].flags;
+		 byte *uPtr = &palette[i]._flags;
 		 if ((*uPtr & 0x10) && _data.size() < 3) {
 			 _data.push_back(i);
 		 }
@@ -76,6 +77,124 @@ void PaletteUsage::prioritize(Common::Array<RGB6> &palette) {
 	prioritizeFromList(lst);
 }
 
+int PaletteUsage::process(Common::Array<RGB6> &palette, int v) {
+	byte *palette1 = nullptr, *palette2 = nullptr;
+	int palLow;
+	int palHigh = (v & 0x800) ? 0x100 : 0xC;
+	int palIdx;
+	assert(v >= 0);
+
+	if (v & 0x4000) {
+		palLow = 0;
+		palIdx = palHigh;
+	} else {
+		palLow = _vm->_palette->_lowRange;
+		if ((PALETTE_COUNT - _vm->_palette->_highRange) > palHigh) {
+			palIdx = palHigh;
+		} else {
+			palIdx = PALETTE_COUNT - _vm->_palette->_highRange;
+		}
+	}
+
+	int rgbIndex = _vm->_palette->_rgbList.scan();
+	uint32 rgbMask = 1 << rgbIndex;
+	int varA = v & 0x8000;
+	bool hasUsage = !_vm->_palette->_paletteUsage.empty();
+	bool flag1 = false;
+
+	if (hasUsage) {
+		if (varA || !_vm->_palette->_paletteUsage[0])
+			hasUsage = false;
+
+		if (varA && _vm->_palette->_paletteUsage[0])
+			flag1 = true;
+	}
+
+	if (hasUsage) {
+		getKeyEntries(palette);
+		prioritize(palette);
+	}
+
+	int freeIndex;
+	int palCount = getGamePalFreeIndex(&freeIndex);
+	byte *pal1 = new byte[PALETTE_COUNT];
+	byte *pal2 = new byte[PALETTE_COUNT];
+
+	for (uint palIndex = 0; palIndex < palette.size(); ++palIndex) {
+		pal2[palIndex] = palIndex;
+		pal1[palIndex] = 0;
+
+		if (!(palette[palIndex]._flags & 0x80)) {
+			pal1[palIndex] = 0x40;
+		}
+		if (!(palette[palIndex]._flags & 0x60)) {
+			pal1[palIndex] |= 0x20;
+		}
+	}
+
+	_vm->_palette->processLists(palette.size(), pal1, pal2);
+	
+	int var3A = (v & 0x4000) ? 0xffff : 0xfffe;
+
+	for (uint palIndex = 0; palIndex < palette.size(); ++palIndex) {
+		bool var48 = false;
+		int var4 = 0xffff;
+		int v1 = pal1[palIndex];
+
+		if (palette[v1]._flags & 8) {
+			var48 = true;
+			var4 = 0xFD;
+		}
+
+		if (hasUsage && palette[v1]._flags & 0x10) {
+			for (uint usageIndex = 0; usageIndex < _data.size() && !var48; ++usageIndex) {
+				if (_data[usageIndex] == palIndex) {
+					var48 = true;
+					int dataIndex = MIN(usageIndex, _data.size() - 1);
+					var4 = _data[dataIndex];
+				}
+			}
+		}
+
+		if (flag1 && palette[palIndex]._flags & 0x10) {
+			for (uint usageIndex = 0; usageIndex < _data.size() && !var48; ++usageIndex) {
+				if (_data[usageIndex] == palIndex) {
+					var48 = true;
+					var4 = 0xF0 + usageIndex;
+
+					// Copy data into the high end of the main palette
+					RGB6 &pSrc = palette[palIndex];
+					byte *pDest = &_vm->_palette->_mainPalette[var4 * 3];
+					pDest[0] = pSrc.r;
+					pDest[1] = pSrc.g;
+					pDest[2] = pSrc.b;
+				}
+			}
+		}
+
+		if (!var48 && !varA) {
+			int var2 = !(palette[palIndex]._flags & 0x20) && (
+				((v & 0x2000) && !(palette[palIndex]._flags & 0x40)) ||
+				((v & 0x1000) && (palCount > 0))
+				) ? 1 : 0x7fff;
+			int var36 = (palette[palIndex]._flags & 0x80) ? 0 : 2;
+			
+			for (int idx = palLow; idx < palIdx; ++idx) {
+				// TODO
+			}
+		}
+		//TODO
+	}
+
+	_vm->_palette->_rgbList[rgbIndex] = 0xffff;
+
+	delete[] pal1;
+	delete[] pal2;
+
+	return rgbIndex;
+}
+
+
 int PaletteUsage::rgbMerge(RGB6 &palEntry) {
 	return palEntry.r * 38 + palEntry.g * 76 + palEntry.b * 14;
 }
@@ -137,19 +256,56 @@ void PaletteUsage::transform(Common::Array<RGB6> &palette) {
 	if (!empty()) {
 		for (uint i = 0; i < _data.size(); ++i) {
 			int palIndex = _data[i];
-			_data[i] = palette[palIndex].palIndex;
+			_data[i] = palette[palIndex]._palIndex;
+		}
+	}
+}
+
+int PaletteUsage::getGamePalFreeIndex(int *palIndex) {
+	*palIndex = -1;
+	int count = 0;
+
+	for (int i = 0; i < PALETTE_COUNT; ++i) {
+		RGB4 &r = _vm->_palette->_gamePalette[i];
+		if (!(r.r | r.g | r.b | r.u)) {
+			++count;
+			if (*palIndex < 0)
+				*palIndex = i;
 		}
 	}
+
+	return count;
+}
+
+/*------------------------------------------------------------------------*/
+
+void RGBList::clear() {
+	Common::fill(&_data[0], &_data[32], 0);
+}
+
+void RGBList::reset() {
+	Common::fill(&_data[2], &_data[32], 0);
+}
+
+int RGBList::scan() {
+	for (int i = 0; i < 32; ++i) {
+		if (!_data[i])
+			return i;
+	}
+
+	error("List was full");
 }
 
 /*------------------------------------------------------------------------*/
 
 #define VGA_COLOR_TRANS(x) (x == 0x3f ? 255 : x << 2)
 
-Palette::Palette(MADSEngine *vm) : _vm(vm) {
+Palette::Palette(MADSEngine *vm) : _vm(vm), _paletteUsage(vm) {
 	reset();
-	_fading_in_progress = false;
-	Common::fill(&_usageCount[0], &_usageCount[PALETTE_COUNT], 0);
+
+	_v1 = 0;
+	_lowRange = 0;
+	_highRange = 0;
 	Common::fill(&_mainPalette[0], &_mainPalette[PALETTE_SIZE], 0);
 }
 
@@ -228,6 +384,49 @@ void Palette::setGradient(byte *palette, int start, int count, int rgbValue1, in
 	}
 }
 
+void Palette::processLists(int count, byte *pal1, byte *pal2) {
+	bool continueFlag;
+	int endIndex = count - 1;
+
+	do {
+		continueFlag = false;
+
+		for (int palIndex = 0; palIndex < endIndex && !continueFlag; ++palIndex) {
+			byte *palP = &pal1[palIndex];
+			byte *pal2P = &pal2[palIndex];
+
+			if (palP[1] < palP[0]) {
+				int v1 = palP[0];
+				int v2 = pal2P[0];
+
+				int size = count - palIndex - 1;
+				if (size > 0) {
+					Common::copy(palP + 1, palP + size + 1, palP);
+					Common::copy(pal2P + 1, pal2P + size + 1, pal2P);
+				}
+
+				int idx;
+				for (idx = 0; idx < endIndex && !continueFlag; ++idx) {
+					if (pal1[idx] > v1)
+						continueFlag = true;
+				}
+				continueFlag = true;
+
+				int size2 = count - idx - 1;
+				if (size2 > 0) {
+					Common::copy(palP + idx, palP + idx + size2 + 1, palP);
+					Common::copy(pal2P + idx, pal2P + idx + size2 + 1, pal2P);
+				}
+
+				pal1[idx] = v1;
+				pal2[idx] = v2;
+			}
+		}
+
+	} while (continueFlag);
+}
+
+
 byte *Palette::decodePalette(Common::SeekableReadStream *palStream, int *numColors) {
 	*numColors = palStream->readUint16LE();
 	assert(*numColors <= 252);
@@ -288,10 +487,43 @@ void Palette::resetGamePalette(int lowRange, int highRange) {
 
 		Common::fill(&_gamePalette[255 - highRange], &_gamePalette[254], _gamePalette[255]);
 	}
+
+	_rgbList.clear();
+	_v1 = 0;
+	_lowRange = lowRange;
+	_highRange = highRange;
 }
 
 void Palette::initGamePalette() {
-	// TODO
+	RGB4 rgb;
+	rgb.r = 1;
+
+	if (_vm->_game->_player._spritesLoaded && _vm->_game->_player._numSprites) {
+
+		for (int idx = 0; idx < _vm->_game->_player._numSprites; ++idx) {
+			SpriteAsset *asset = _vm->_game->_scene._sprites[
+				_vm->_game->_player._spritesStart + idx];
+			
+			uint32 mask = 1;
+			if (asset->_field6)
+				mask <<= asset->_field6;
+			
+			rgb.r = mask & 0xff;
+			rgb.g = (mask >> 8) & 0xff;
+			rgb.b = (mask >> 16) & 0xff;
+			rgb.u = (mask >> 24) & 0xff;
+		}
+	}
+
+	for (int idx = 0; idx < PALETTE_COUNT; ++idx) {
+		_gamePalette[idx].r &= rgb.r;
+		_gamePalette[idx].g &= rgb.g;
+		_gamePalette[idx].b &= rgb.b;
+		_gamePalette[idx].u &= rgb.u;
+	}
+
+	_v1 = 0;
+	_rgbList.reset();
 }
 
 void Palette::initRange(byte *palette) {
@@ -337,4 +569,9 @@ void Palette::setLowRange() {
 	_vm->_palette->setPalette(_mainPalette, 0, 4);
 }
 
+void Palette::fadeOut(byte palette[PALETTE_SIZE], int v1, int v2, int v3, int v4, int v5, int v6) {
+
+}
+
+
 } // End of namespace MADS
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index d85e25b..83e406a 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -37,28 +37,36 @@ struct RGB4 {
 	byte g;
 	byte b;
 	byte u;
+
+	RGB4() { r = g = b = u = 0; }
 };
 
 struct RGB6 {
 	byte r;
 	byte g;
 	byte b;
-	byte palIndex;
-	byte u2;
-	byte flags;
+	byte _palIndex;
+	byte _u2;
+	byte _flags;
 
 	void load(Common::SeekableReadStream *f);
 };
 
 class PaletteUsage {
 private:
-	Common::Array<int> _data;
+	MADSEngine *_vm;
+	Common::Array<uint16> _data;
 
 	int rgbMerge(RGB6 &palEntry);
 
 	void prioritizeFromList(int lst[3]);
+
+	int getGamePalFreeIndex(int *palIndex);
 public:
-	PaletteUsage();
+	/**
+	 * Constructor
+	 */
+	PaletteUsage(MADSEngine *vm);
 
 	void load(int count, ...);
 
@@ -67,6 +75,8 @@ public:
 	 */
 	bool empty() const { return _data.size() == 0;  }
 
+	uint16 &operator[](int index) { return _data[index]; }
+
 	/**
 	 * Gets key entries from the passed palette
 	 * @param palette	6-bit per entry read in palette
@@ -79,14 +89,28 @@ public:
 	 */
 	void prioritize(Common::Array<RGB6> &palette);
 
-	bool process(Common::Array<RGB6> &palette, int v) {
-		warning("TODO: PaletteUsage::process");
-		return 0;
-	}
+	int process(Common::Array<RGB6> &palette, int v);
 
 	void transform(Common::Array<RGB6> &palette);
 };
 
+class RGBList {
+private:
+	uint16 _data[32];
+public:
+	RGBList() { clear(); }
+
+	void clear();
+
+	void reset();
+
+	/**
+	 * Scans for a free slot
+	 */
+	int scan();
+
+	uint16 &operator[](int idx) { return _data[idx]; }
+};
 
 #define PALETTE_COUNT 256
 #define PALETTE_SIZE (256 * 3)
@@ -99,12 +123,6 @@ private:
 	void initRange(byte *palette);
 protected:
 	MADSEngine *_vm;
-	bool _colorsChanged;
-
-	bool _fading_in_progress;
-	byte _originalPalette[PALETTE_COUNT * 4];
-	byte _fadedPalette[PALETTE_COUNT * 4];
-	int _usageCount[PALETTE_COUNT];
 
 	void reset();
 public:
@@ -112,6 +130,10 @@ public:
 	byte _savedPalette[PALETTE_SIZE];
 	RGB4 _gamePalette[PALETTE_COUNT];
 	PaletteUsage _paletteUsage;
+	RGBList _rgbList;
+	int _v1;
+	int _lowRange;
+	int _highRange;
 public:
 	/**
 	 * Constructor
@@ -139,6 +161,20 @@ public:
 	void grabPalette(byte *colors, uint start, uint num);
 	
 	/**
+	 * Gets the entire palette at once
+	 */
+	void getFullPalette(byte palette[PALETTE_SIZE]) {
+		grabPalette(&palette[0], 0, PALETTE_COUNT);
+	}
+
+	/**
+	 * Sets the entire palette at once
+	 */
+	void setFullPalette(byte palette[PALETTE_SIZE]) {
+		setPalette(&palette[0], 0, PALETTE_COUNT);
+	}
+
+	/**
 	 * Returns the palette index in the palette that most closely matches the
 	 * specified RGB pair
 	 */
@@ -164,6 +200,8 @@ public:
 	 */
 	static void setGradient(byte *palette, int start, int count, int rgbValue1, int rgbValue2);
 
+	static void processLists(int count, byte *pal1, byte *pal2);
+
 	/**
 	 * Resets the game palette
 	 */
@@ -185,6 +223,8 @@ public:
 	void close() {
 		warning("TODO: Palette::close");
 	}
+
+	void fadeOut(byte palette[PALETTE_SIZE], int v1, int v2, int v3, int v4, int v5, int v6);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 11a5935..1557797 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -384,16 +384,15 @@ void Scene::doFrame() {
 				_kernelMessages.update();
 			}
 
-			_vm->_game->_abortTimers2 = !_vm->_game->_abortTimers2;
-
-			warning("TODO: image_inter_list_call");
+			_imageInterEntries.call(_vm->_game->_abortTimers2 == kTransitionFadeIn ? 0xff : 0,
+				_vm->_game->_abortTimers2);
 
 			// Write any text needed by the interface
 			if (_vm->_game->_abortTimers2)
 				_interface.writeText();
 
 			// Draw any elements
-			drawElements(_vm->_game->_abortTimers2, _vm->_game->_abortTimers2);
+			drawElements((ScreenTransition)_vm->_game->_abortTimers2, _vm->_game->_abortTimers2);
 
 			// Handle message updates
 			if (_vm->_game->_abortTimers2) {
@@ -425,7 +424,7 @@ void Scene::doFrame() {
 	_vm->_events->waitForNextFrame();
 }
 
-void Scene::drawElements(bool transitionFlag, bool surfaceFlag) {
+void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
 	// Draw any sprites
 	_spriteSlots.drawBackground();
 
@@ -455,9 +454,9 @@ void Scene::drawElements(bool transitionFlag, bool surfaceFlag) {
 	_interface.setBounds(Common::Rect(_vm->_screen._offset.x, _vm->_screen._offset.y,
 		_vm->_screen._offset.x + _vm->_screen.w, _vm->_screen._offset.y + _vm->_screen.h));
 
-	if (transitionFlag) {
+	if (transitionType) {
 		// Fading in the screen
-		_vm->_screen.transition(transitionFlag, surfaceFlag);
+		_vm->_screen.transition(transitionType, surfaceFlag);
 		_vm->_sound->startQueuedCommands();
 	} else {
 		// Copy dirty areas to the screen
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 969fb0b..79c5910 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -27,6 +27,7 @@
 #include "common/array.h"
 #include "common/rect.h"
 #include "mads/assets.h"
+#include "mads/graphics.h"
 #include "mads/hotspots.h"
 #include "mads/messages.h"
 #include "mads/msurface.h"
@@ -189,7 +190,7 @@ public:
 	/**
 	 * Draw all the elements onto the scene
 	 */
-	void drawElements(bool transitionFlag, bool surfaceFlag);
+	void drawElements(ScreenTransition transitionType, bool surfaceFlag);
 
 	/**
 	 * Execute a click within the scene
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index b18efa2..398c1c9 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -395,7 +395,7 @@ int ImageInterEntries::add(int field0, int field2) {
 	return size() - 1;
 }
 
-void ImageInterEntries::call(int v1) {
+void ImageInterEntries::call(int v1, int v2) {
 	debug("TODO: ImageInterEntries::call");
 }
 
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index 0e4e86a..848aa1a 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -235,7 +235,7 @@ class ImageInterEntries: public Common::Array<ImageInterEntry> {
 public:
 	int add(int field0, int field2);
 
-	void call(int v1);
+	void call(int v1, int v2);
 };
 
 } // End of namespace MADS


Commit: 9e69e64d3fc54a3d9e2065eb2af75950353c7f64
    https://github.com/scummvm/scummvm/commit/9e69e64d3fc54a3d9e2065eb2af75950353c7f64
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-10T00:52:33-04:00

Commit Message:
MADS: Completed PaletteUsage::process

Changed paths:
    engines/mads/interface.cpp
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/interface.cpp b/engines/mads/interface.cpp
index cd2f162..68e2341 100644
--- a/engines/mads/interface.cpp
+++ b/engines/mads/interface.cpp
@@ -49,14 +49,14 @@ void InterfaceSurface::load(const Common::String &resName) {
 	// Load in the palette
 	Common::SeekableReadStream *palStream = madsPack.getItemStream(0);
 
-	RGB4 *gamePalP = &_vm->_palette->_gamePalette[0];
+	uint32 *gamePalP = &_vm->_palette->_gamePalette[0];
 	byte *palP = &_vm->_palette->_mainPalette[0];
 
 	for (int i = 0; i < 16; ++i, gamePalP++, palP += 3) {
 		palP[0] = palStream->readByte();
 		palP[1] = palStream->readByte();
 		palP[2] = palStream->readByte();
-		gamePalP->r |= 1;
+		*gamePalP |= 1;
 		palStream->skip(3);
 	}
 	delete palStream;
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index da59707..1303ea2 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -78,7 +78,7 @@ void PaletteUsage::prioritize(Common::Array<RGB6> &palette) {
 }
 
 int PaletteUsage::process(Common::Array<RGB6> &palette, int v) {
-	byte *palette1 = nullptr, *palette2 = nullptr;
+	byte *pal1 = nullptr, *pal2 = nullptr;
 	int palLow;
 	int palHigh = (v & 0x800) ? 0x100 : 0xC;
 	int palIdx;
@@ -117,8 +117,8 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, int v) {
 
 	int freeIndex;
 	int palCount = getGamePalFreeIndex(&freeIndex);
-	byte *pal1 = new byte[PALETTE_COUNT];
-	byte *pal2 = new byte[PALETTE_COUNT];
+	pal1 = new byte[PALETTE_COUNT];
+	pal2 = new byte[PALETTE_COUNT];
 
 	for (uint palIndex = 0; palIndex < palette.size(); ++palIndex) {
 		pal2[palIndex] = palIndex;
@@ -180,10 +180,52 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, int v) {
 			int var36 = (palette[palIndex]._flags & 0x80) ? 0 : 2;
 			
 			for (int idx = palLow; idx < palIdx; ++idx) {
-				// TODO
+				uint32 v = _vm->_palette->_gamePalette[idx];
+				if ((v & var3A) && !(v & var36)) {
+					int var10;
+
+					if (var2 > 1) {
+						var10 = rgbFactor(&_vm->_palette->_mainPalette[idx * 3], palette[palIndex]);
+					}
+					else if (_vm->_palette->_mainPalette[idx * 3] != palette[palIndex].r ||
+							_vm->_palette->_mainPalette[idx * 3 + 1] != palette[palIndex].g ||
+							_vm->_palette->_mainPalette[idx * 3 + 2] != palette[palIndex].b) {
+						var10 = 1;
+					} else {
+						var10 = 0;
+					}
+
+					if (var2 > var10) {
+						var48 = true;
+						var2 = idx;
+						var2 = var10;
+					}
+				}
 			}
 		}
-		//TODO
+
+		if (!var48 && (!(v & 0x1000) || (!(palette[palIndex]._flags & 0x60) && !(v & 0x2000)))) {
+			for (int idx = freeIndex; idx < palIdx && !var48; ++idx) {
+				if (!_vm->_palette->_gamePalette[idx]) {
+					--palCount;
+					++freeIndex;
+					var48 = true;
+					var4 = idx;
+
+					RGB6 &pSrc = palette[palIndex];
+					byte *pDest = &_vm->_palette->_mainPalette[idx * 3];
+					pDest[0] = pSrc.r;
+					pDest[1] = pSrc.g;
+					pDest[2] = pSrc.b;
+				}
+			}
+		}
+		
+		assert(var48);
+		int var52 = (varA && palette[palIndex]._u2) ? 2 : 0;
+
+		_vm->_palette->_gamePalette[var4] |= var52 | rgbMask;
+		palette[palIndex]._palIndex = var4;
 	}
 
 	_vm->_palette->_rgbList[rgbIndex] = 0xffff;
@@ -266,8 +308,7 @@ int PaletteUsage::getGamePalFreeIndex(int *palIndex) {
 	int count = 0;
 
 	for (int i = 0; i < PALETTE_COUNT; ++i) {
-		RGB4 &r = _vm->_palette->_gamePalette[i];
-		if (!(r.r | r.g | r.b | r.u)) {
+		if (!_vm->_palette->_gamePalette[i]) {
 			++count;
 			if (*palIndex < 0)
 				*palIndex = i;
@@ -277,6 +318,15 @@ int PaletteUsage::getGamePalFreeIndex(int *palIndex) {
 	return count;
 }
 
+int PaletteUsage::rgbFactor(byte *palEntry, RGB6 &pal6) {
+	int total = 0;
+	total += (palEntry[0] - pal6.r) * (palEntry[0] - pal6.r);
+	total += (palEntry[1] - pal6.g) * (palEntry[1] - pal6.g);
+	total += (palEntry[2] - pal6.b) * (palEntry[2] - pal6.b);
+
+	return total;
+}
+
 /*------------------------------------------------------------------------*/
 
 void RGBList::clear() {
@@ -474,16 +524,14 @@ void Palette::resetGamePalette(int lowRange, int highRange) {
 
 	// Init low range to common RGB values
 	if (lowRange) {
-		_gamePalette[0].r = 1;
-		_gamePalette[0].b = 0;
+		_gamePalette[0] = 1;
 
 		Common::fill(&_gamePalette[1], &_gamePalette[lowRange - 1], _gamePalette[0]);
 	}
 
 	// Init high range to common RGB values
 	if (highRange) {
-		_gamePalette[255].r = 1;
-		_gamePalette[255].b = 0;
+		_gamePalette[255] = 1;
 
 		Common::fill(&_gamePalette[255 - highRange], &_gamePalette[254], _gamePalette[255]);
 	}
@@ -496,7 +544,7 @@ void Palette::resetGamePalette(int lowRange, int highRange) {
 
 void Palette::initGamePalette() {
 	RGB4 rgb;
-	rgb.r = 1;
+	uint32 palMask = 1;
 
 	if (_vm->_game->_player._spritesLoaded && _vm->_game->_player._numSprites) {
 
@@ -508,19 +556,12 @@ void Palette::initGamePalette() {
 			if (asset->_field6)
 				mask <<= asset->_field6;
 			
-			rgb.r = mask & 0xff;
-			rgb.g = (mask >> 8) & 0xff;
-			rgb.b = (mask >> 16) & 0xff;
-			rgb.u = (mask >> 24) & 0xff;
+			palMask = mask;
 		}
 	}
 
-	for (int idx = 0; idx < PALETTE_COUNT; ++idx) {
-		_gamePalette[idx].r &= rgb.r;
-		_gamePalette[idx].g &= rgb.g;
-		_gamePalette[idx].b &= rgb.b;
-		_gamePalette[idx].u &= rgb.u;
-	}
+	for (int idx = 0; idx < PALETTE_COUNT; ++idx)
+		_gamePalette[idx] = palMask;
 
 	_v1 = 0;
 	_rgbList.reset();
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 83e406a..a7c3285 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -62,6 +62,8 @@ private:
 	void prioritizeFromList(int lst[3]);
 
 	int getGamePalFreeIndex(int *palIndex);
+
+	int rgbFactor(byte *palEntry, RGB6 &pal6);
 public:
 	/**
 	 * Constructor
@@ -128,7 +130,7 @@ protected:
 public:
 	byte _mainPalette[PALETTE_SIZE];
 	byte _savedPalette[PALETTE_SIZE];
-	RGB4 _gamePalette[PALETTE_COUNT];
+	uint32 _gamePalette[PALETTE_COUNT];
 	PaletteUsage _paletteUsage;
 	RGBList _rgbList;
 	int _v1;


Commit: d295a1654547d4f3636ea6d64939a0a91c5b2c25
    https://github.com/scummvm/scummvm/commit/d295a1654547d4f3636ea6d64939a0a91c5b2c25
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-10T01:00:11-04:00

Commit Message:
MADS: Properly hook up use of PaletteUsage::process

Changed paths:
    engines/mads/assets.cpp
    engines/mads/assets.h
    engines/mads/palette.cpp
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index 554cd9a..1a2d542 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -54,7 +54,7 @@ void SpriteAsset::load(Common::SeekableReadStream *stream, int flags) {
 	_pixelSpeed = 0;
 	_maxWidth = 0;
 	_maxHeight = 0;
-	_field6 = -1;
+	_usageIndex = -1;
 
 	Common::SeekableReadStream *spriteStream = sprite.getItemStream(0);
 	_mode = spriteStream->readByte();
diff --git a/engines/mads/assets.h b/engines/mads/assets.h
index c0d1feb..31d4688 100644
--- a/engines/mads/assets.h
+++ b/engines/mads/assets.h
@@ -77,7 +77,7 @@ private:
 	void load(Common::SeekableReadStream *stream, int flags);
 public:
 	SpriteSetCharInfo *_charInfo;
-	int _field6;
+	int _usageIndex;
 public:
 	/**
 	 * Constructor
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 1303ea2..d9eb3ff 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -553,8 +553,8 @@ void Palette::initGamePalette() {
 				_vm->_game->_player._spritesStart + idx];
 			
 			uint32 mask = 1;
-			if (asset->_field6)
-				mask <<= asset->_field6;
+			if (asset->_usageIndex)
+				mask <<= asset->_usageIndex;
 			
 			palMask = mask;
 		}
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 36efcb3..eb4b221 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -500,8 +500,8 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
 			_vm->_palette->_paletteUsage.prioritize(artHeader._palette);
 		}
 
-		_field4C = _vm->_palette->_paletteUsage.process(artHeader._palette, 0xF800);
-		if (_field4C > 0) {
+		_usageIndex = _vm->_palette->_paletteUsage.process(artHeader._palette, 0xF800);
+		if (_usageIndex > 0) {
 			_vm->_palette->_paletteUsage.transform(artHeader._palette);
 
 			for (uint i = 0; i < _palAnimData.size(); ++i) {
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index d2fd624..67393fc 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -267,7 +267,7 @@ public:
 	int _depthList[DEPTH_BANDS_SIZE];
 	int _field4A;
 
-	int _field4C;
+	int _usageIndex;
 	Common::Array<RGB4> _palAnimData;
 	SceneNodeList _nodes;
 public:


Commit: 5543d5884cbc32012bfcf9e111817cd01770cd7e
    https://github.com/scummvm/scummvm/commit/5543d5884cbc32012bfcf9e111817cd01770cd7e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-10T22:08:55-04:00

Commit Message:
MADS: Refactoring calls to PaletteUsage::process, and initial bugfixes

Changed paths:
    engines/mads/assets.cpp
    engines/mads/mads.cpp
    engines/mads/palette.cpp
    engines/mads/palette.h
    engines/mads/scene_data.cpp



diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index 1a2d542..1c958ad 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -74,13 +74,8 @@ void SpriteAsset::load(Common::SeekableReadStream *stream, int flags) {
 
 	// Get the palette data
 	spriteStream = sprite.getItemStream(2);
-	int numColors = 0;
-	byte *palData = _vm->_palette->decodePalette(spriteStream, &numColors);
-	Common::copy(palData, &palData[numColors], &_palette[0]);
-	if (numColors < 256)
-		Common::fill((byte *)&_palette[numColors], (byte *)&_palette[256], 0);
-	_colorCount = numColors;
-	delete[] palData;
+	_vm->_palette->decodePalette(spriteStream, flags);
+
 	delete spriteStream;
 
 	spriteStream = sprite.getItemStream(1);
@@ -133,7 +128,7 @@ void SpriteAsset::load(Common::SeekableReadStream *stream, int flags) {
 
 			fab.decompress(srcData, srcSize, destData, frameSizes[curFrame]);
 
-			// Load the frame
+			// Load the frames
 			Common::MemoryReadStream *rs = new Common::MemoryReadStream(destData, frameSizes[curFrame]);
 			_frames[curFrame]._frame = new MSprite(rs, 
 				Common::Point(_frames[curFrame]._bounds.left, _frames[curFrame]._bounds.top),
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 0327a9f..6dfdf7b 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -88,7 +88,6 @@ void MADSEngine::initialise() {
 	_userInterface = UserInterface::init(this);
 	_game = Game::init(this);
 
-	_events->loadCursors("*CURSOR.SS");
 	_screen.empty();
 }
 
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index d9eb3ff..1525be9 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -77,14 +77,13 @@ void PaletteUsage::prioritize(Common::Array<RGB6> &palette) {
 	prioritizeFromList(lst);
 }
 
-int PaletteUsage::process(Common::Array<RGB6> &palette, int v) {
+int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 	byte *pal1 = nullptr, *pal2 = nullptr;
 	int palLow;
-	int palHigh = (v & 0x800) ? 0x100 : 0xC;
+	int palHigh = (flags & 0x800) ? 0x100 : 0xFC;
 	int palIdx;
-	assert(v >= 0);
 
-	if (v & 0x4000) {
+	if (flags & 0x4000) {
 		palLow = 0;
 		palIdx = palHigh;
 	} else {
@@ -98,7 +97,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, int v) {
 
 	int rgbIndex = _vm->_palette->_rgbList.scan();
 	uint32 rgbMask = 1 << rgbIndex;
-	int varA = v & 0x8000;
+	int varA = flags & 0x8000;
 	bool hasUsage = !_vm->_palette->_paletteUsage.empty();
 	bool flag1 = false;
 
@@ -127,14 +126,14 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, int v) {
 		if (!(palette[palIndex]._flags & 0x80)) {
 			pal1[palIndex] = 0x40;
 		}
-		if (!(palette[palIndex]._flags & 0x60)) {
+		if (palette[palIndex]._flags & 0x60) {
 			pal1[palIndex] |= 0x20;
 		}
 	}
 
 	_vm->_palette->processLists(palette.size(), pal1, pal2);
 	
-	int var3A = (v & 0x4000) ? 0xffff : 0xfffe;
+	int var3A = (flags & 0x4000) ? 0xffff : 0xfffe;
 
 	for (uint palIndex = 0; palIndex < palette.size(); ++palIndex) {
 		bool var48 = false;
@@ -174,8 +173,8 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, int v) {
 
 		if (!var48 && !varA) {
 			int var2 = !(palette[palIndex]._flags & 0x20) && (
-				((v & 0x2000) && !(palette[palIndex]._flags & 0x40)) ||
-				((v & 0x1000) && (palCount > 0))
+				((flags & 0x2000) && !(palette[palIndex]._flags & 0x40)) ||
+				((flags & 0x1000) && (palCount > 0))
 				) ? 1 : 0x7fff;
 			int var36 = (palette[palIndex]._flags & 0x80) ? 0 : 2;
 			
@@ -204,7 +203,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, int v) {
 			}
 		}
 
-		if (!var48 && (!(v & 0x1000) || (!(palette[palIndex]._flags & 0x60) && !(v & 0x2000)))) {
+		if (!var48 && (!(flags & 0x1000) || (!(palette[palIndex]._flags & 0x60) && !(flags & 0x2000)))) {
 			for (int idx = freeIndex; idx < palIdx && !var48; ++idx) {
 				if (!_vm->_palette->_gamePalette[idx]) {
 					--palCount;
@@ -477,35 +476,18 @@ void Palette::processLists(int count, byte *pal1, byte *pal2) {
 }
 
 
-byte *Palette::decodePalette(Common::SeekableReadStream *palStream, int *numColors) {
-	*numColors = palStream->readUint16LE();
-	assert(*numColors <= 252);
+void Palette::decodePalette(Common::SeekableReadStream *palStream, uint flags) {
+	int numColors = palStream->readUint16LE();
+	assert(numColors <= 252);
 
-	byte *palData = new byte[*numColors * 3];
-	Common::fill(&palData[0], &palData[*numColors * 3], 0);
-
-	for (int i = 0; i < *numColors; ++i) {
-		byte r = palStream->readByte();
-		byte g = palStream->readByte();
-		byte b = palStream->readByte();
-		palData[i * 3] = VGA_COLOR_TRANS(r);
-		palData[i * 3 + 1] = VGA_COLOR_TRANS(g);
-		palData[i * 3 + 2] = VGA_COLOR_TRANS(b);
-
-		// The next 3 bytes are unused
-		palStream->skip(3);
-	}
-
-	return palData;
-}
-
-int Palette::loadPalette(Common::SeekableReadStream *palStream, int indexStart) {
-	int colorCount;
-	byte *palData = decodePalette(palStream, &colorCount);
-	_vm->_palette->setPalette(palData, indexStart, colorCount);
-
-	delete palData;
-	return colorCount;
+	// Load in the palette
+	Common::Array<RGB6> palette;
+	palette.resize(numColors);
+	for (int i = 0; i < numColors; ++i)
+		palette[i].load(palStream);
+	
+	// Process the palette data
+	_paletteUsage.process(palette, flags);
 }
 
 void Palette::setSystemPalette() {
@@ -524,9 +506,7 @@ void Palette::resetGamePalette(int lowRange, int highRange) {
 
 	// Init low range to common RGB values
 	if (lowRange) {
-		_gamePalette[0] = 1;
-
-		Common::fill(&_gamePalette[1], &_gamePalette[lowRange - 1], _gamePalette[0]);
+		Common::fill(&_gamePalette[0], &_gamePalette[lowRange], 1);
 	}
 
 	// Init high range to common RGB values
@@ -537,6 +517,8 @@ void Palette::resetGamePalette(int lowRange, int highRange) {
 	}
 
 	_rgbList.clear();
+	_rgbList[0] = _rgbList[1] = 0xffff;
+
 	_v1 = 0;
 	_lowRange = lowRange;
 	_highRange = highRange;
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index a7c3285..ad9d1f3 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -91,7 +91,7 @@ public:
 	 */
 	void prioritize(Common::Array<RGB6> &palette);
 
-	int process(Common::Array<RGB6> &palette, int v);
+	int process(Common::Array<RGB6> &palette, uint flags);
 
 	void transform(Common::Array<RGB6> &palette);
 };
@@ -183,14 +183,9 @@ public:
 	uint8 palIndexFromRgb(byte r, byte g, byte b, byte *paletteData = nullptr);
 
 	/**
-	 * Decode a palette and return it, without affecting the Palette itself
+	 * Decodes a palette and loads it into the main palette
 	 */
-	byte *decodePalette(Common::SeekableReadStream *palStream, int *numColors);
-
-	/**
-	 * Loads a palette from a stream
-	 */
-	int loadPalette(Common::SeekableReadStream *palStream, int indexStart = 0);
+	void decodePalette(Common::SeekableReadStream *palStream, uint flags);
 
 	/**
 	 * Sets a small set of system/core colors needed by the game
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index eb4b221..d4fefff 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -500,7 +500,8 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
 			_vm->_palette->_paletteUsage.prioritize(artHeader._palette);
 		}
 
-		_usageIndex = _vm->_palette->_paletteUsage.process(artHeader._palette, 0xF800);
+		_usageIndex = _vm->_palette->_paletteUsage.process(artHeader._palette, 
+			(flags & 0xF800) | 0x8000);
 		if (_usageIndex > 0) {
 			_vm->_palette->_paletteUsage.transform(artHeader._palette);
 


Commit: 5d4b6b79db701fac2e9511de8cc977a5def4160c
    https://github.com/scummvm/scummvm/commit/5d4b6b79db701fac2e9511de8cc977a5def4160c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-11T21:01:07-04:00

Commit Message:
MADS: Fix for palette initialisation in Palette::initRange

Changed paths:
    engines/mads/palette.cpp



diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 1525be9..9b93fb3 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -553,8 +553,10 @@ void Palette::initRange(byte *palette) {
 	int var6 = 0;
 	int vdx = 0;
 	int vbx = 0;
+	byte *destP = palette;
+
 	do {
-		int vdi = (vdx == 1) ? 0 : 0x2A;
+		int vdi = (vdx == 1) ? 0x3F : 0x2A;
 		int var8 = 0;
 		int varE = vbx;
 		int var10 = vdx;
@@ -565,11 +567,10 @@ void Palette::initRange(byte *palette) {
 				int var4 = vdx;
 				do {
 					int var2 = var6 + vcx;
-					byte *destP = &palette[var2 * 3];
 					
-					destP[0] = (var8) ? vdi & 0xFF : vbx & 0XFF;
-					destP[1] = (var4) ? vdi & 0xFF : vbx & 0XFF;
-					destP[2] = (vcx) ? vdi & 0xFF : vbx & 0XFF;					
+					*destP++ = (var8) ? vdi & 0xFF : vbx & 0XFF;
+					*destP++ = (var4) ? vdi & 0xFF : vbx & 0XFF;
+					*destP++ = (vcx) ? vdi & 0xFF : vbx & 0XFF;
 				} while (++vcx < 2);
 
 				var6 += 2;


Commit: 5a1c64e7329bd85c0089c7ee55217266be36c921
    https://github.com/scummvm/scummvm/commit/5a1c64e7329bd85c0089c7ee55217266be36c921
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-11T21:32:42-04:00

Commit Message:
MADS: Further fixes for PaletteUsage::process

Changed paths:
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 9b93fb3..2e4995e 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -138,7 +138,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 	for (uint palIndex = 0; palIndex < palette.size(); ++palIndex) {
 		bool var48 = false;
 		int var4 = 0xffff;
-		int v1 = pal1[palIndex];
+		int v1 = pal2[palIndex];
 
 		if (palette[v1]._flags & 8) {
 			var48 = true;
@@ -196,7 +196,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 
 					if (var2 > var10) {
 						var48 = true;
-						var2 = idx;
+						var4 = idx;
 						var2 = var10;
 					}
 				}
@@ -502,7 +502,7 @@ void Palette::setSystemPalette() {
 
 void Palette::resetGamePalette(int lowRange, int highRange) {
 	Common::fill((byte *)&_gamePalette[0], (byte *)&_gamePalette[PALETTE_COUNT], 0);
-	initRange(_mainPalette);
+	initVGAPalette(_mainPalette);
 
 	// Init low range to common RGB values
 	if (lowRange) {
@@ -549,7 +549,7 @@ void Palette::initGamePalette() {
 	_rgbList.reset();
 }
 
-void Palette::initRange(byte *palette) {
+void Palette::initVGAPalette(byte *palette) {
 	int var6 = 0;
 	int vdx = 0;
 	int vbx = 0;
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index ad9d1f3..b540aa5 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -120,9 +120,9 @@ public:
 class Palette {
 private:
 	/**
-	 * Initialises a stanadrd range of colours for the given palette
+	 * Initialises a stanadrd VGA palette
 	 */
-	void initRange(byte *palette);
+	void initVGAPalette(byte *palette);
 protected:
 	MADSEngine *_vm;
 


Commit: 5047c118f1b3bb60136bc4088e9db53f38dbb087
    https://github.com/scummvm/scummvm/commit/5047c118f1b3bb60136bc4088e9db53f38dbb087
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-11T21:35:18-04:00

Commit Message:
MADS: Fix for executing queued sound commands

Changed paths:
    engines/mads/sound.cpp



diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index ea02390..eaac70c 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -85,7 +85,7 @@ void SoundManager::startQueuedCommands() {
 	_newSoundsPaused = false;
 
 	while (!_queuedCommands.empty()) {
-		int commandId = _queuedCommands.front();
+		int commandId = _queuedCommands.pop();
 		command(commandId);
 	}
 }


Commit: 41e86d553e087e1b4276748064fb5893859196b2
    https://github.com/scummvm/scummvm/commit/41e86d553e087e1b4276748064fb5893859196b2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-11T21:40:49-04:00

Commit Message:
MADS: Renamed game palette to palette flags

Changed paths:
    engines/mads/game.cpp
    engines/mads/interface.cpp
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index e0d3ca1..f290ab0 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -166,7 +166,7 @@ void Game::sectionLoop() {
 			_vm->_palette->resetGamePalette(18, 10);
 			_scene._spriteSlots.reset();
 		} else {
-			_vm->_palette->initGamePalette();
+			_vm->_palette->initPalette();
 		}
 
 		_vm->_palette->_paletteUsage.load(3, 0xF0, 0xF1, 0xF2);
diff --git a/engines/mads/interface.cpp b/engines/mads/interface.cpp
index 68e2341..0c983dc 100644
--- a/engines/mads/interface.cpp
+++ b/engines/mads/interface.cpp
@@ -49,7 +49,7 @@ void InterfaceSurface::load(const Common::String &resName) {
 	// Load in the palette
 	Common::SeekableReadStream *palStream = madsPack.getItemStream(0);
 
-	uint32 *gamePalP = &_vm->_palette->_gamePalette[0];
+	uint32 *gamePalP = &_vm->_palette->_palFlags[0];
 	byte *palP = &_vm->_palette->_mainPalette[0];
 
 	for (int i = 0; i < 16; ++i, gamePalP++, palP += 3) {
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 2e4995e..e63d9c0 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -179,7 +179,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 			int var36 = (palette[palIndex]._flags & 0x80) ? 0 : 2;
 			
 			for (int idx = palLow; idx < palIdx; ++idx) {
-				uint32 v = _vm->_palette->_gamePalette[idx];
+				uint32 v = _vm->_palette->_palFlags[idx];
 				if ((v & var3A) && !(v & var36)) {
 					int var10;
 
@@ -205,7 +205,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 
 		if (!var48 && (!(flags & 0x1000) || (!(palette[palIndex]._flags & 0x60) && !(flags & 0x2000)))) {
 			for (int idx = freeIndex; idx < palIdx && !var48; ++idx) {
-				if (!_vm->_palette->_gamePalette[idx]) {
+				if (!_vm->_palette->_palFlags[idx]) {
 					--palCount;
 					++freeIndex;
 					var48 = true;
@@ -223,7 +223,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 		assert(var48);
 		int var52 = (varA && palette[palIndex]._u2) ? 2 : 0;
 
-		_vm->_palette->_gamePalette[var4] |= var52 | rgbMask;
+		_vm->_palette->_palFlags[var4] |= var52 | rgbMask;
 		palette[palIndex]._palIndex = var4;
 	}
 
@@ -307,7 +307,7 @@ int PaletteUsage::getGamePalFreeIndex(int *palIndex) {
 	int count = 0;
 
 	for (int i = 0; i < PALETTE_COUNT; ++i) {
-		if (!_vm->_palette->_gamePalette[i]) {
+		if (!_vm->_palette->_palFlags[i]) {
 			++count;
 			if (*palIndex < 0)
 				*palIndex = i;
@@ -501,19 +501,19 @@ void Palette::setSystemPalette() {
 }
 
 void Palette::resetGamePalette(int lowRange, int highRange) {
-	Common::fill((byte *)&_gamePalette[0], (byte *)&_gamePalette[PALETTE_COUNT], 0);
+	Common::fill((byte *)&_palFlags[0], (byte *)&_palFlags[PALETTE_COUNT], 0);
 	initVGAPalette(_mainPalette);
 
 	// Init low range to common RGB values
 	if (lowRange) {
-		Common::fill(&_gamePalette[0], &_gamePalette[lowRange], 1);
+		Common::fill(&_palFlags[0], &_palFlags[lowRange], 1);
 	}
 
 	// Init high range to common RGB values
 	if (highRange) {
-		_gamePalette[255] = 1;
+		_palFlags[255] = 1;
 
-		Common::fill(&_gamePalette[255 - highRange], &_gamePalette[254], _gamePalette[255]);
+		Common::fill(&_palFlags[255 - highRange], &_palFlags[254], _palFlags[255]);
 	}
 
 	_rgbList.clear();
@@ -524,7 +524,7 @@ void Palette::resetGamePalette(int lowRange, int highRange) {
 	_highRange = highRange;
 }
 
-void Palette::initGamePalette() {
+void Palette::initPalette() {
 	RGB4 rgb;
 	uint32 palMask = 1;
 
@@ -543,7 +543,7 @@ void Palette::initGamePalette() {
 	}
 
 	for (int idx = 0; idx < PALETTE_COUNT; ++idx)
-		_gamePalette[idx] = palMask;
+		_palFlags[idx] = palMask;
 
 	_v1 = 0;
 	_rgbList.reset();
@@ -566,8 +566,6 @@ void Palette::initVGAPalette(byte *palette) {
 				int vcx = 0;
 				int var4 = vdx;
 				do {
-					int var2 = var6 + vcx;
-					
 					*destP++ = (var8) ? vdi & 0xFF : vbx & 0XFF;
 					*destP++ = (var4) ? vdi & 0xFF : vbx & 0XFF;
 					*destP++ = (vcx) ? vdi & 0xFF : vbx & 0XFF;
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index b540aa5..2744d47 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -130,7 +130,7 @@ protected:
 public:
 	byte _mainPalette[PALETTE_SIZE];
 	byte _savedPalette[PALETTE_SIZE];
-	uint32 _gamePalette[PALETTE_COUNT];
+	uint32 _palFlags[PALETTE_COUNT];
 	PaletteUsage _paletteUsage;
 	RGBList _rgbList;
 	int _v1;
@@ -205,9 +205,9 @@ public:
 	void resetGamePalette(int v1, int v2);
 
 	/**
-	 * Initialises game palette
+	 * Initialises the main palette
 	 */
-	void initGamePalette();
+	void initPalette();
 
 	/**
 	 * Set the first four palette entries with preset values


Commit: be1a53062a21b6af27b504c64c1ddf8b33f0880a
    https://github.com/scummvm/scummvm/commit/be1a53062a21b6af27b504c64c1ddf8b33f0880a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-11T21:48:16-04:00

Commit Message:
MADS: Convert 6 bit palettes to 8 bit values

Changed paths:
    engines/mads/palette.cpp



diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index e63d9c0..aeb97d2 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -28,10 +28,12 @@
 
 namespace MADS {
 
+#define VGA_COLOR_TRANS(x) (((((int)(x)) + 1) << 2) - 1)
+
 void RGB6::load(Common::SeekableReadStream *f) {
-	r = f->readByte();
-	g = f->readByte();
-	b = f->readByte();
+	r = VGA_COLOR_TRANS(f->readByte());
+	g = VGA_COLOR_TRANS(f->readByte());
+	b = VGA_COLOR_TRANS(f->readByte());
 	_palIndex = f->readByte();
 	_u2 = f->readByte();
 	_flags = f->readByte();
@@ -347,8 +349,6 @@ int RGBList::scan() {
 
 /*------------------------------------------------------------------------*/
 
-#define VGA_COLOR_TRANS(x) (x == 0x3f ? 255 : x << 2)
-
 Palette::Palette(MADSEngine *vm) : _vm(vm), _paletteUsage(vm) {
 	reset();
 
@@ -566,9 +566,9 @@ void Palette::initVGAPalette(byte *palette) {
 				int vcx = 0;
 				int var4 = vdx;
 				do {
-					*destP++ = (var8) ? vdi & 0xFF : vbx & 0XFF;
-					*destP++ = (var4) ? vdi & 0xFF : vbx & 0XFF;
-					*destP++ = (vcx) ? vdi & 0xFF : vbx & 0XFF;
+					*destP++ = VGA_COLOR_TRANS((var8) ? vdi & 0xFF : vbx & 0XFF);
+					*destP++ = VGA_COLOR_TRANS((var4) ? vdi & 0xFF : vbx & 0XFF);
+					*destP++ = VGA_COLOR_TRANS((vcx) ? vdi & 0xFF : vbx & 0XFF);
 				} while (++vcx < 2);
 
 				var6 += 2;


Commit: 2d99f761f0bb0a8db4468846f0643fbdc4da450a
    https://github.com/scummvm/scummvm/commit/2d99f761f0bb0a8db4468846f0643fbdc4da450a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-11T23:26:31-04:00

Commit Message:
MADS: Implemented scene 804 step

Changed paths:
    engines/mads/dialogs.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/game_nebular.h
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes8.cpp



diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index 0f9a098..bec7f84 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -68,6 +68,10 @@ public:
 	 * Destructor
 	 */
 	virtual ~Dialog();
+
+	static void show(int msgId) {
+		warning("TODO: Dialog::show");
+	}
 };
 
 enum {
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index f290ab0..6a7f6fb 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -59,6 +59,7 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 	_abortTimersMode = ABORTMODE_0;
 	_abortTimersMode2 = ABORTMODE_0;
 	_ticksExpiry = 0;
+	_exitFlag = 0;
 }
 
 Game::~Game() {
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 143259d..01f2360 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -129,6 +129,7 @@ public:
 	Common::String _aaName;
 	uint32 _ticksExpiry;
 	int _objectHiliteVocabIdx;
+	int _exitFlag;
 public:
 	virtual ~Game();
 
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index c18561b..c2a23b6 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -36,6 +36,7 @@ namespace Nebular {
 
 GameNebular::GameNebular(MADSEngine *vm): Game(vm) {
 	_surface = new MSurface(MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT);
+	_storyMode = STORYMODE_NAUGHTY;
 }
 
 int GameNebular::checkCopyProtection() {
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index 0250f66..3d1d915 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -31,6 +31,24 @@ namespace MADS {
 
 namespace Nebular {
 
+enum StoryMode { STORYMODE_NAUGHTY = 1, STORYMODE_NICE = 2 };
+
+enum InventoryObject {
+	OBJ_BURGER = 1, OBJ_DEAD_FISH = 2, OBJ_STUFFED_FISH = 3, OBJ_REBREATHER = 4,
+	OBJ_TIMER_MODULE = 5, OBJ_BIG_LEAVES = 6, OBJ_POISON_DARTS = 7, OBJ_PLANT_STALK = 8,
+	OBJ_BLOWGUN = 9, OBJ_TWINKIFRUIT = 10, OBJ_BONE = 11, OBJ_CHICKEN = 12,
+	OBJ_SCALPEL = 13, OBJ_AUDIO_TAPE = 14, OBJ_CREDIT_CHIP = 15, OBJ_SECURITY_CARD = 16,
+	OBJ_CHARGE_CASES = 17, OBJ_ESTROTOXIN = 18, OBJ_BOMB = 19, OBJ_TIMEBOMB = 20,
+	OBJ_REPAIR_LIST = 21, OBJ_ALIEN_LIQUOR = 22, OBJ_TARGET_MODULE = 23, OBJ_SHIELD_MODULATOR = 24,
+	OBJ_TAPE_PLAYER = 25, OBJ_PHONE_CELLS = 26, OBJ_PENLIGHT = 27, OBJ_DURAFAIL_CELLS = 28,
+	OBJ_FAKE_ID = 29, OBJ_ID_CARD = 30, OBJ_POLYCEMENT = 31, OBJ_FISHING_LINE = 33,
+	OBJ_PADLOCK_KEY = 34, OBJ_DOOR_KEY = 35, OBJ_REARVIEW_MIRROR = 36, OBJ_COMPACT_CASE = 37,
+	OBJ_DETONATORS = 39, OBJ_BOTTLE = 40, OBJ_CHICKEN_BOMB = 41, OBJ_VASE = 42,
+	OBJ_REMOTE = 43, OBJ_COMPUTER_GAME = 44, OBJ_PHONE_HANDSET = 45, OBJ_BONES = 46,
+	OBJ_GUARDS_ARM = 47, OBJ_LOG = 48, OBJ_BOMBS = 49, OBJ_NOTE = 50,
+	OBJ_COMBINATION = 51, OBJ_FORMALDEHYDE = 52, OBJ_PETROX = 53, OBJ_LECITHIN = 54
+};
+
 class GameNebular: public Game {
 	friend class Game;
 protected:
@@ -46,6 +64,7 @@ protected:
 
 public:
 	Globals _globals;
+	StoryMode _storyMode;
 };
 
 
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index d14120a..baee40c 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -52,7 +52,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 /*------------------------------------------------------------------------*/
 
 NebularScene::NebularScene(MADSEngine *vm) : SceneLogic(vm),
-		_globals(static_cast<GameNebular *>(vm->_game)->_globals) {
+		_globals(static_cast<GameNebular *>(vm->_game)->_globals),
+		_game(*static_cast<GameNebular *>(vm->_game)) {
 }
 
 Common::String NebularScene::formAnimName(char sepChar, int suffixNum) {
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 92b5626..da36c71 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -26,8 +26,10 @@
 #include "common/scummsys.h"
 #include "mads/game.h"
 #include "mads/scene.h"
+#include "mads/nebular/game_nebular.h"
 #include "mads/nebular/globals_nebular.h"
 
+
 namespace MADS {
 
 namespace Nebular {
@@ -95,6 +97,7 @@ public:
 class NebularScene : public SceneLogic {
 protected:
 	Globals &_globals;
+	GameNebular &_game;
 
 	/**
 	 * Forms an animation resoucre name
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 56c3679..c912d32 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -35,9 +35,9 @@ void Scene8xx::setup1() {
 	if ((_globals[178] && !_globals[179]) ||
 			_scene->_nextSceneId == 804 || _scene->_nextSceneId == 805 ||
 			_scene->_nextSceneId == 808 || _scene->_nextSceneId == 810) {
-		_vm->_game->_player._spritesPrefix = "";
+		_game._player._spritesPrefix = "";
 	} else {
-		_vm->_game->_player._spritesPrefix = _globals[0] == SEX_FEMALE ? "ROX" : "RXM";
+		_game._player._spritesPrefix = _globals[0] == SEX_FEMALE ? "ROX" : "RXM";
 	}
 
 	_vm->_palette->setEntry(16, 0x0A, 0x3F, 0x3F);
@@ -45,7 +45,7 @@ void Scene8xx::setup1() {
 }
 
 void Scene8xx::setup2() {
-	_vm->_game->_aaName = Resources::formatAAName(5);
+	_game._aaName = Resources::formatAAName(5);
 }
 
 void Scene8xx::enter1() {
@@ -99,7 +99,7 @@ void Scene804::enter() {
 	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('x', 4));
 	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('f', 1));
 
-	_vm->_game->loadQuoteSet(791, 0);
+	_game.loadQuoteSet(791, 0);
 
 	if (_globals[165]) {
 		if (_globals[164]) {
@@ -113,7 +113,7 @@ void Scene804::enter() {
 			_globals._spriteIndexes[21] = _scene->_sequences.startReverseCycle(
 				_globals._spriteIndexes[6], false, 4, 0, 0, 0);
 			_scene->_sequences.addTimer(160, 70);
-			_vm->_game->_player._stepEnabled = false;
+			_game._player._stepEnabled = false;
 		}
 	}
 	else {
@@ -144,6 +144,155 @@ void Scene804::enter() {
 }
 
 void Scene804::step() {
+	if (_globals._chairHotspotIndex) {
+		if (_scene->_activeAnimation->getCurrentFrame() == 36 && !_globals._v3) {
+			_scene->_sequences.remove(_globals._spriteIndexes[15]);
+			_globals._v3 = -1;
+		}
+		if (_scene->_activeAnimation->getCurrentFrame() == 39) {
+			_globals._v2 = 0;
+			if (_globals._v1 == 3)
+				_scene->_sequences.addTimer(130, 120);
+		}
+
+		if (!_globals._v2) {
+			++_globals._v1;
+			_globals._v2 = -1;
+
+			if (_globals._v1 >= 4) {
+				_globals._chairHotspotIndex = 0;
+				_globals._v1 = 0;
+				_game._player._stepEnabled = true;
+			} else {
+				_globals._v5 = 34;
+			}
+		}
+	} else {
+		if (_globals._v3 && _globals._v2 && _scene->_activeAnimation->getCurrentFrame() == 39) {
+			_globals._spriteIndexes[15] = _scene->_sequences.startCycle(
+				_globals._spriteIndexes[0], false, 1);
+			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[15],
+				Common::Point(133, 139));
+			_scene->_sequences.setDepth(_globals._spriteIndexes[15], 8);
+			_globals._v3 = 0;
+		}
+
+		if (_globals._v2 && _scene->_activeAnimation->getCurrentFrame() == 42) {
+			_globals._v5 = 0;
+			_globals._v2 = 0;
+		}
+
+		if (_game._abortTimers == 70)
+			_globals._v5 = 42;
+		if (_scene->_activeAnimation->getCurrentFrame() == 65)
+			_scene->_sequences.remove(_globals._spriteIndexes[21]);
+
+		switch (_game._storyMode)  {
+		case STORYMODE_NAUGHTY:
+			if (_scene->_activeAnimation->getCurrentFrame() == 81) {
+				_globals._v5 = 80;
+			} else {
+				_globals[165] = 0;
+				_globals[167] = -1;
+				assert(!_globals[5]);
+				_game._exitFlag = 4;
+				_vm->quitGame();
+			}
+			break;
+
+		case STORYMODE_NICE:
+			if (_scene->_activeAnimation->getCurrentFrame() == 68) {
+				_globals._v5 = 66;
+			} else {
+				_globals[165] = 0;
+				_globals[167] = -1;
+				assert(!_globals[5]);
+				_game._exitFlag = 4;
+				_vm->quitGame();
+			}
+			break;
+		}
+
+		if (_scene->_activeAnimation->getCurrentFrame() == 34) {
+			_globals._v5 = 36;
+			_scene->_sequences.remove(_globals._spriteIndexes[15]);
+		}
+		if (_scene->_activeAnimation->getCurrentFrame() == 37) {
+			_globals._v5 = 36;
+			if (!_globals._v4)
+				_scene->_sequences.addTimer(60, 80);
+		}
+
+		if (_game._abortTimers == 80)
+			_scene->_nextSceneId = 803;
+
+		if (_scene->_activeAnimation->getCurrentFrame() == 7 && !_globals[164]) {
+			_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+			_scene->_sequences.addTimer(20, 110);
+			_globals[164] = -1;
+		}
+
+		if (_scene->_activeAnimation->getCurrentFrame() == 10) {
+			_globals._v5 = 0;
+			_game._player._stepEnabled = true;
+			_game._objects.setRoom(OBJ_POLYCEMENT, 1);
+		}
+
+		switch (_scene->_activeAnimation->getCurrentFrame()) {
+		case 1:
+			_globals[29] = _vm->getRandomNumber(29) + 1;
+			switch (_globals[29]) {
+			case 1:
+				_globals._v5 = 25;
+				break;
+			case 2:
+				_globals._v5 = 27;
+				break;
+			case 3:
+				_globals._v5 = 9;
+				break;
+			default:
+				_globals._v5 = 0;
+				break;
+			}
+			break;
+
+		case 26:
+		case 28:
+		case 31:
+			_globals._v5 = 0;
+			break;
+
+		default:
+			break;
+		}
+	}
+
+	if (_game._abortTimers == 120)
+		Dialog::show(0x13a26);
+	if (_game._abortTimers == 110)
+		Dialog::show(0x13a2a);
+
+	if (_globals._v6) {
+		_globals._v5 = 32;
+		_globals._v6 = 0;
+	}
+	if (_globals._v5 >= 0 && (_scene->_activeAnimation->getCurrentFrame() != _globals._v5)) {
+		_scene->_activeAnimation->setCurrentFrame(_globals._v5);
+		_globals._v5 = -1;
+	}
+
+	if (_game._abortTimers == 90)
+		_scene->_nextSceneId = 803;
+
+	if (_scene->_activeAnimation->getCurrentFrame() == 7 &&!_globals._v8) {
+		_vm->_sound->command(21);
+		_globals._v8 = -1;
+	}
+	if (_scene->_activeAnimation->getCurrentFrame() == 80 && !_globals._v7) {
+		_vm->_sound->command(22);
+		_globals._v7 = -1;
+	}
 }
 
 void Scene804::preActions() {


Commit: 709fcc6fac4e1449064c4ddd5de3c443d0290c93
    https://github.com/scummvm/scummvm/commit/709fcc6fac4e1449064c4ddd5de3c443d0290c93
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-11T23:42:20-04:00

Commit Message:
MADS: Fix inter-frame wait loop

Changed paths:
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/globals_nebular.h
    engines/mads/nebular/nebular_scenes8.cpp



diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 59cdfbf..182d6cb 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -36,7 +36,6 @@ EventsManager::EventsManager(MADSEngine *vm) {
 	_vm = vm;
 	_cursorSprites = nullptr;
 	_frameCounter = 0;
-	_frameNumber = 0;
 	_priorFrameTime = 0;
 	_keyPressed = false;
 	_mouseClicked = false;
@@ -166,8 +165,8 @@ void EventsManager::delay(int cycles) {
 }
 
 void EventsManager::waitForNextFrame() {
-	uint32 frameNum = getFrameCounter();
-	while (!_vm->shouldQuit() && !_vm->_game->_abortTimers && frameNum == _frameNumber)
+	uint32 frameCtr = getFrameCounter();
+	while (!_vm->shouldQuit() && frameCtr == _frameCounter)
 		delay(1);
 }
 
diff --git a/engines/mads/events.h b/engines/mads/events.h
index 6f716d8..1722422 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -38,7 +38,6 @@ class EventsManager {
 private:
 	MADSEngine *_vm;
 	uint32 _frameCounter;
-	uint32 _frameNumber;
 	uint32 _priorFrameTime;
 	Common::Point _mousePos;
 	Common::Point _currentPos;
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index c2a23b6..65abb40 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -41,7 +41,7 @@ GameNebular::GameNebular(MADSEngine *vm): Game(vm) {
 
 int GameNebular::checkCopyProtection() {
 	// DEBUG: Flag copy protection failure
-	_globals[5] = 0xFFFF;
+	_globals[5] = -1;
 	
 	if (!ConfMan.getBool("copy_protection"))
 		return true;
@@ -60,13 +60,13 @@ void GameNebular::initialiseGlobals() {
 	// Set specific values needed by the game
 	_globals[4] = 8;
 	_globals[33] = 1;
-	_globals[10] = 0xFFFF;
-	_globals[13] = 0xFFFF;
-	_globals[15] = 0xFFFF;
-	_globals[19] = 0xFFFF;
-	_globals[20] = 0xFFFF;
-	_globals[21] = 0xFFFF;
-	_globals[95] = 0xFFFF;
+	_globals[10] = -1;
+	_globals[13] = -1;
+	_globals[15] = -1;
+	_globals[19] = -1;
+	_globals[20] = -1;
+	_globals[21] = -1;
+	_globals[95] = -1;
 
 	_objects.setData(3, 17, nullptr);
 
@@ -101,8 +101,8 @@ void GameNebular::initialiseGlobals() {
 	}
 
 	_globals[120] = 501;
-	_globals[121] = 0xFFFF;
-	_globals[55] = 0xFFFF;
+	_globals[121] = -1;
+	_globals[55] = -1;
 	_globals[119] = 1;
 	_globals[134] = 4;
 
@@ -133,7 +133,7 @@ void GameNebular::initialiseGlobals() {
 	case DIFFICULTY_MEDIUM:
 		_globals[35] = 0;
 		_objects.setRoom(8, 1);
-		_globals[137] = 0xFFFF;
+		_globals[137] = -1;
 		_globals[136] = 6;
 		break;
 	case DIFFICULTY_EASY:
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index daa384f..3134044 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -33,7 +33,7 @@ namespace Nebular {
 
 class Globals {
 private:
-	Common::Array<uint16> _flags;
+	Common::Array<int16> _flags;
 public:
 	Common::Array<int> _spriteIndexes;
 
@@ -55,7 +55,7 @@ public:
 	/**
 	 * Square brackets operator for accessing flags
 	 */
-	uint16 &operator[](int idx) { return _flags[idx]; }
+	int16 &operator[](int idx) { return _flags[idx]; }
 };
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index c912d32..ac3f029 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -88,7 +88,7 @@ void Scene804::enter() {
 	_globals._v8 = 0;
 	if (_globals[5]) {
 		// Copy protection failed
-		_globals[165] = 0xFFFF;
+		_globals[165] = -1;
 		_globals[164] = 0;
 	}
 


Commit: 98f7ba964369b128f65755c918f4c5e6d1d16dbe
    https://github.com/scummvm/scummvm/commit/98f7ba964369b128f65755c918f4c5e6d1d16dbe
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-12T08:44:57-04:00

Commit Message:
MADS: Fix definition/loading of animation frame change data

Changed paths:
    engines/mads/animation.cpp
    engines/mads/animation.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 2117ae2..ec043a3 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -127,8 +127,7 @@ void AnimMiscEntry::load(Common::SeekableReadStream *f) {
 	_numTicks = f->readUint16LE();
 	_posAdjust.x = f->readSint16LE();
 	_posAdjust.y = f->readSint16LE();
-	_scrollPos.x = f->readSint16LE();
-	_scrollPos.y = f->readSint16LE();
+	_field8 = f->readUint16LE();
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index ca04e86..492fb9d 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -72,7 +72,7 @@ public:
 	int _msgIndex;
 	int _numTicks;
 	Common::Point _posAdjust;
-	Common::Point _scrollPos;
+	int _field8;
 
 	/**
 	* Loads data for the record


Commit: d9bb593b5f39f31f078d9b479d569c56c6eda563
    https://github.com/scummvm/scummvm/commit/d9bb593b5f39f31f078d9b479d569c56c6eda563
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-12T20:54:50-04:00

Commit Message:
MADS: Implemented PaletteUsage::updateUsage

Changed paths:
    engines/mads/palette.cpp
    engines/mads/palette.h
    engines/mads/scene_data.cpp



diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index aeb97d2..7e0d5bb 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -304,6 +304,30 @@ void PaletteUsage::transform(Common::Array<RGB6> &palette) {
 	}
 }
 
+void PaletteUsage::updateUsage(Common::Array<int> &usageList, int sceneUsageIndex) {
+	uint32 mask1 = 0xFFFFFFFF;
+	uint32 mask2 = 0;
+
+	for (uint idx = 0; idx < usageList.size(); ++idx) {
+		uint32 bitMask = 1 << usageList[idx];
+		mask1 ^= bitMask;
+		mask2 |= bitMask;
+		_vm->_palette->_rgbList[usageList[idx]] = 0;
+	}
+
+	uint32 mask3 = 1 << sceneUsageIndex;
+
+	for (uint idx = 0; idx < PALETTE_COUNT; ++idx) {
+		uint32 mask = mask2 & _vm->_palette->_palFlags[idx];
+		if (mask) {
+			_vm->_palette->_palFlags[idx] = (_vm->_palette->_palFlags[idx] &
+				mask1) | mask3;
+		}
+	}
+
+	_vm->_palette->_rgbList[sceneUsageIndex] = -1;
+}
+
 int PaletteUsage::getGamePalFreeIndex(int *palIndex) {
 	*palIndex = -1;
 	int count = 0;
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 2744d47..5f21bd9 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -94,6 +94,8 @@ public:
 	int process(Common::Array<RGB6> &palette, uint flags);
 
 	void transform(Common::Array<RGB6> &palette);
+
+	void updateUsage(Common::Array<int> &usageList, int sceneUsageIndex);
 };
 
 class RGBList {
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index d4fefff..18a3b6c 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -522,7 +522,7 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
 	artFile.close();
 
 	Common::Array<SpriteAsset *> spriteSets;
-	Common::Array<int> indexList;
+	Common::Array<int> usageList;
 
 	if (flags & 1) {
 		for (uint i = 0; i < setNames.size(); ++i) {
@@ -533,11 +533,11 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
 
 			SpriteAsset *sprites = new SpriteAsset(_vm, setResName, flags);
 			spriteSets.push_back(sprites);
-			indexList.push_back(-1); // TODO:: sprites->_field6
+			usageList.push_back(sprites->_usageIndex); 
 		}
 	}
 
-	warning("TODO: sub_201E4(indexList, namesCount, &pal data2");
+	_vm->_palette->_paletteUsage.updateUsage(usageList, _usageIndex);
 
 	for (uint i = 0; i < spriteInfo.size(); ++i) {
 		SpriteInfo &si = spriteInfo[i];


Commit: 408f5e79df5e8a33367fdf2a9c17b424953edace
    https://github.com/scummvm/scummvm/commit/408f5e79df5e8a33367fdf2a9c17b424953edace
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-12T22:45:33-04:00

Commit Message:
MADS: General cleanup and minor fixes

Changed paths:
    engines/mads/animation.cpp
    engines/mads/assets.h
    engines/mads/messages.cpp
    engines/mads/msurface.cpp
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/resources.cpp
    engines/mads/scene.cpp
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h
    engines/mads/sequence.cpp
    engines/mads/sprites.cpp
    engines/mads/sprites.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index ec043a3..b5ebb2c 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -347,7 +347,7 @@ void Animation::loadFrame(int frameNumber) {
 	}
 
 	if (drawFrame(spriteSet, pt, frameNumber))
-		error("proc1 failure");
+		error("drawFrame failure");
 }
 
 bool Animation::drawFrame(SpriteAsset &spriteSet, const Common::Point &pt, int frameNumber) {
@@ -373,8 +373,7 @@ void Animation::loadInterface(InterfaceSurface &interfaceSurface, MSurface &dept
 
 		if (palAnimData)
 			palAnimData->clear();
-	}
-	else {
+	} else {
 		// Original has useless code here
 	}
 }
diff --git a/engines/mads/assets.h b/engines/mads/assets.h
index 31d4688..b485660 100644
--- a/engines/mads/assets.h
+++ b/engines/mads/assets.h
@@ -78,6 +78,7 @@ private:
 public:
 	SpriteSetCharInfo *_charInfo;
 	int _usageIndex;
+	Common::Point _pos;
 public:
 	/**
 	 * Constructor
diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index 8bdbe72..dcac541 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -340,10 +340,10 @@ int TextDisplayList::add(int xp, int yp, uint fontColor, int charSpacing,
 void TextDisplayList::setDirtyAreas() {
 	Scene &scene = _vm->_game->_scene;
 
-	for (uint idx = 0, dirtyIdx = DIRTY_AREAS_TEXT_DISPLAY_IDX; dirtyIdx < size(); ++idx, ++dirtyIdx) {
-		if (((*this)[idx]._expire >= 0) || !(*this)[idx]._active)
+	for (uint idx = 0, dirtyIdx = SPRITE_SLOTS_MAX_SIZE; dirtyIdx < size(); ++idx, ++dirtyIdx) {
+		if (((*this)[idx]._expire >= 0) || !(*this)[idx]._active) {
 			scene._dirtyAreas[dirtyIdx]._active = false;
-		else {
+		} else {
 			scene._dirtyAreas[dirtyIdx]._textActive = true;
 			scene._dirtyAreas[dirtyIdx].setTextDisplay(&(*this)[idx]);
 		}
@@ -353,7 +353,7 @@ void TextDisplayList::setDirtyAreas() {
 void TextDisplayList::setDirtyAreas2() {
 	Scene &scene = _vm->_game->_scene;
 
-	for (uint idx = 0, dirtyIdx = DIRTY_AREAS_TEXT_DISPLAY_IDX; idx < size(); ++idx, ++dirtyIdx) {
+	for (uint idx = 0, dirtyIdx = SPRITE_SLOTS_MAX_SIZE; idx < size(); ++idx, ++dirtyIdx) {
 		if ((*this)[idx]._active && ((*this)[idx]._expire >= 0)) {
 			scene._dirtyAreas[dirtyIdx].setTextDisplay(&(*this)[idx]);
 			scene._dirtyAreas[dirtyIdx]._textActive = ((*this)[idx]._expire <= 0) ? 0 : 1;
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index f21836e..2adb3e5 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -230,10 +230,10 @@ void MSurface::copyFrom(MSurface *src, const Common::Rect &srcBounds,
 	byte *destPtr = (byte *)pixels + (destY * getWidth()) + destX;
 
 	for (int rowCtr = 0; rowCtr < copyRect.height(); ++rowCtr) {
-		if (transparentColor == -1)
+		if (transparentColor == -1) {
 			// No transparency, so copy line over
 			Common::copy(srcPtr, srcPtr + copyRect.width(), destPtr);
-		else {
+		} else {
 			// Copy each byte one at a time checking for the transparency color
 			for (int xCtr = 0; xCtr < copyRect.width(); ++xCtr)
 				if (srcPtr[xCtr] != transparentColor) destPtr[xCtr] = srcPtr[xCtr];
@@ -311,8 +311,7 @@ void MSurface::copyFrom(MSurface *src, const Common::Point &destPos, int depth,
 		distCtr += scale;
 		if (distCtr < 100) {
 			lineDist[distIndex] = false;
-		}
-		else {
+		} else {
 			lineDist[distIndex] = true;
 			distCtr -= 100;
 
@@ -425,8 +424,7 @@ void MSurface::scrollX(int xAmount) {
 			Common::copy(srcP + xSize, srcP + this->w, srcP);
 			// Move buffered area to the end of the line
 			Common::copy(&buffer[0], &buffer[xSize], srcP + this->w - xSize);
-		}
-		else {
+		} else {
 			// Copy area to be overwritten
 			Common::copy_backward(srcP + this->w - xSize, srcP + this->w, &buffer[80]);
 			// Shift the remainder of the line over the given area
@@ -459,8 +457,7 @@ void MSurface::scrollY(int yAmount) {
 			pixelsP + (pitch * this->h));
 		// Transfer the buffered lines top the top of the screen
 		Common::copy(tempData, tempData + blockSize, pixelsP);
-	}
-	else {
+	} else {
 		// Buffer the lines to be overwritten
 		Common::copy(pixelsP, pixelsP + (pitch * ySize), tempData);
 		// Vertically shift all the lines
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index ac3f029..2d12366 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -106,8 +106,7 @@ void Scene804::enter() {
 			_globals._spriteIndexes[19] = _scene->_sequences.startCycle(
 				_globals._spriteIndexes[4], 0, 1);
 			_scene->_sequences.addTimer(60, 100);
-		}
-		else {
+		} else {
 			_globals._spriteIndexes[20] = _scene->_sequences.startCycle(
 				_globals._spriteIndexes[5], false, 1);
 			_globals._spriteIndexes[21] = _scene->_sequences.startReverseCycle(
@@ -115,8 +114,7 @@ void Scene804::enter() {
 			_scene->_sequences.addTimer(160, 70);
 			_game._player._stepEnabled = false;
 		}
-	}
-	else {
+	} else {
 		if (_globals[167] == 0) {
 			_globals._spriteIndexes[22] = _scene->_sequences.startCycle(
 				_globals._spriteIndexes[7], false, 1);
diff --git a/engines/mads/resources.cpp b/engines/mads/resources.cpp
index f85d5ce..140a347 100644
--- a/engines/mads/resources.cpp
+++ b/engines/mads/resources.cpp
@@ -308,8 +308,7 @@ Common::String Resources::formatName(int prefix, char asciiCh, int id, EXTTYPE e
 	Common::String result;
 	if (prefix <= 0) {
 		result = "*";
-	}
-	else {
+	} else {
 		result = Common::String::format("%s%.3d",
 			(prefix < 100) ? "*SC" : "*RM", prefix);
 	}
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 1557797..ebc35f0 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -170,7 +170,9 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	_interfaceY = MADS_SCENE_HEIGHT;
 	_spritesCount = _sprites.size();
 
-	warning("TODO: sub_1EA80 / showMouse");
+	_interface.setup(_screenObjects._v832EC);
+
+	warning("TODO: showMouse");
 
 	warning("TODO: inventory_anim_allocate");
 }
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 18a3b6c..d2071e3 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -199,8 +199,7 @@ void DirtyArea::setSpriteSlot(const SpriteSlot *spriteSlot) {
 		if (spriteSlot->_scale == -1) {
 			width = frame->w;
 			height = frame->h;
-		}
-		else {
+		} else {
 			width = frame->w * spriteSlot->_scale / 100;
 			height = frame->h * spriteSlot->_scale / 100;
 
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 67393fc..b8b2056 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -46,8 +46,9 @@ class SpriteSlot;
 #define DEPTH_BANDS_SIZE 15
 #define MAX_ROUTE_NODES 22
 
-#define DIRTY_AREAS_SIZE 90
-#define DIRTY_AREAS_TEXT_DISPLAY_IDX 50
+#define SPRITE_SLOTS_MAX_SIZE 50
+#define TEXT_DISPLAY_MAX_SIZE 40
+#define DIRTY_AREAS_SIZE (SPRITE_SLOTS_MAX_SIZE + TEXT_DISPLAY_MAX_SIZE)
 
 enum ScrCategory {
 	CAT_NONE = 0, CAT_ACTION = 1, CAT_INV_LIST = 2, CAT_INV_VOCAB = 3,
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index f703ce3..dfb3d6f 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -184,7 +184,7 @@ void SequenceList::setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot) {
 	if (!timerEntry._nonFixed) {
 		spriteSlot._position = timerEntry._msgPos;
 	} else {
-		spriteSlot._position = spriteSet.getFrame(timerEntry._frameIndex - 1)->_pos;
+		spriteSlot._position = spriteSet._pos;
 	}
 }
 
@@ -243,15 +243,13 @@ bool SequenceList::loadSprites(int seqIndex) {
 				if (seqEntry._animType == ANIMTYPE_CYCLED) {
 					//  back to the starting frame (cyclic)
 					seqEntry._frameIndex = seqEntry._frameStart;
-				}
-				else {
+				} else {
 					// Switch into reverse mode
 					seqEntry._frameIndex = seqEntry._numSprites - 1;
 					seqEntry._frameInc = -1;
 				}
 			}
-		}
-		else {
+		} else {
 			// Currently in reverse mode and moved past starting frame
 			result = true;
 
@@ -260,8 +258,7 @@ bool SequenceList::loadSprites(int seqIndex) {
 				// Switch back to forward direction again
 				seqEntry._frameIndex = seqEntry._frameStart + 1;
 				seqEntry._frameInc = 1;
-			}
-			else {
+			} else {
 				// Otherwise reset back to last sprite for further reverse animating
 				seqEntry._frameIndex = seqEntry._numSprites;
 			}
@@ -271,8 +268,7 @@ bool SequenceList::loadSprites(int seqIndex) {
 			if (--seqEntry._triggerCountdown == 0)
 				seqEntry._doneFlag = true;
 		}
-	}
-	else {
+	} else {
 		// Out of sprite display slots, so mark entry as done
 		seqEntry._doneFlag = true;
 	}
@@ -402,8 +398,9 @@ void SequenceList::setMsgPosition(int seqIndex, const Common::Point &pt) {
 int SequenceList::addSpriteCycle(int srcSpriteIdx, bool flipped, int numTicks, int triggerCountdown, int timeoutTicks, int extraTicks) {
 	Scene &scene = _vm->_game->_scene;
 	MSprite *spriteFrame = scene._sprites[srcSpriteIdx]->getFrame(0);
-	int depth = scene._depthSurface.getDepth(Common::Point(spriteFrame->_pos.x + 
-		(spriteFrame->w / 2), spriteFrame->_pos.y + (spriteFrame->h / 2)));
+	int depth = scene._depthSurface.getDepth(Common::Point(
+		spriteFrame->_offset.x + (spriteFrame->w / 2), 
+		spriteFrame->_offset.y + (spriteFrame->h / 2)));
 
 	return add(srcSpriteIdx, flipped, 1, triggerCountdown, timeoutTicks, extraTicks, numTicks, 0, 0,
 		true, 100, depth - 1, 1, ANIMTYPE_CYCLED, 0, 0);
@@ -422,7 +419,7 @@ int SequenceList::startReverseCycle(int srcSpriteIndex, bool flipped, int numTic
 	SpriteAsset *sprites = _vm->_game->_scene._sprites[srcSpriteIndex];
 	MSprite *frame = sprites->getFrame(0);
 	int depth = _vm->_game->_scene._depthSurface.getDepth(Common::Point(
-		frame->_pos.x + frame->w / 2, frame->_pos.y + frame->h / 2));
+		frame->_offset.x + frame->w / 2, frame->_offset.y + frame->h / 2));
 
 	return add(srcSpriteIndex, flipped, 1, triggerCountdown, timeoutTicks, extraTicks,
 		numTicks, 0, 0, true, 100, depth - 1, 1, ANIMTYPE_REVERSIBLE, 0, 0);
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 398c1c9..228071a 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -235,31 +235,33 @@ void SpriteSlots::drawBackground() {
 	Scene &scene = _vm->_game->_scene;
 
 	// Initial draw loop for any active sprites in the background
-	for (uint i = 0; i < scene._spriteSlots.size(); ++i) {
-		if (scene._spriteSlots[i]._spriteType >= ST_NONE) {
-			scene._dirtyAreas[i]._active = false;
-		}
-		else {
-			scene._dirtyAreas[i]._active = true;
-			scene._dirtyAreas[i].setSpriteSlot(&scene._spriteSlots[i]);
+	for (uint i = 0; i < size(); ++i) {
+		SpriteSlot &spriteSlot = (*this)[i];
+		DirtyArea &dirtyArea = scene._dirtyAreas[i];
+
+		if (spriteSlot._spriteType >= ST_NONE) {
+			dirtyArea._active = false;
+		} else {
+			dirtyArea._active = true;
+			dirtyArea.setSpriteSlot(&spriteSlot);
 
-			SpriteAsset *asset = scene._sprites[scene._spriteSlots[i]._spritesIndex];
-			MSprite *frame = asset->getFrame(scene._spriteSlots[i]._frameNumber);
+			SpriteAsset *asset = scene._sprites[spriteSlot._spritesIndex];
+			MSprite *frame = asset->getFrame(spriteSlot._frameNumber);
 
-			if (scene._spriteSlots[i]._spriteType == ST_BACKGROUND) {
-				Common::Point pt = scene._spriteSlots[i]._position;
-				if (scene._spriteSlots[i]._scale != -1) {
+			if (spriteSlot._spriteType == ST_BACKGROUND) {
+				Common::Point pt = spriteSlot._position;
+				if (spriteSlot._scale != -1) {
 					// Adjust the drawing position
 					pt.x -= frame->w / 2;
 					pt.y -= frame->h / 2;
 				}
 
-				if (scene._spriteSlots[i]._depth <= 1) {
-					asset->draw(&scene._backgroundSurface, scene._spriteSlots[i]._frameNumber, pt);
+				if (spriteSlot._depth <= 1) {
+					asset->draw(&scene._backgroundSurface, spriteSlot._frameNumber, pt);
 				}
 				else if (scene._depthStyle == 0) {
-					asset->depthDraw(&scene._backgroundSurface, &scene._depthSurface, scene._spriteSlots[i]._frameNumber,
-						pt, scene._spriteSlots[i]._depth);
+					asset->depthDraw(&scene._backgroundSurface, &scene._depthSurface, spriteSlot._frameNumber,
+						pt, spriteSlot._depth);
 				} else {
 					error("Unsupported depth style");
 				}
@@ -267,18 +269,20 @@ void SpriteSlots::drawBackground() {
 		}
 	}
 
-	// Mark any remaning dirty areas as inactive
-	for (uint i = scene._spriteSlots.size(); i < 50; ++i)
+	// Mark any remaning sprite slot dirty areas as inactive
+	for (uint i = size(); i < SPRITE_SLOTS_MAX_SIZE; ++i)
 		scene._dirtyAreas[i]._active = false;
 
 	// Flag any active text display
-	for (uint i = 50; i < scene._textDisplay.size(); ++i) {
-		TextDisplay &textDisplay = scene._textDisplay[i - 50];
-		if (scene._textDisplay[i]._expire >= 0 || !textDisplay._active) {
-			scene._dirtyAreas[i]._active = false;
+	for (uint i = 0; i < scene._textDisplay.size(); ++i) {
+		TextDisplay &textDisplay = scene._textDisplay[i];
+		DirtyArea &dirtyArea = scene._dirtyAreas[i + SPRITE_SLOTS_MAX_SIZE];
+
+		if (textDisplay._expire >= 0 || !textDisplay._active) {
+			dirtyArea._active = false;
 		} else {
-			scene._dirtyAreas[i]._active = true;
-			scene._dirtyAreas[i].setTextDisplay(&textDisplay);
+			dirtyArea._active = true;
+			dirtyArea.setTextDisplay(&textDisplay);
 		}
 	}
 }
@@ -289,8 +293,9 @@ void SpriteSlots::drawForeground(MSurface *s) {
 
 	// Get a list of sprite object depths for active objects
 	for (uint i = 0; i < size(); ++i) {
-		if ((*this)[i]._spriteType >= ST_NONE) {
-			DepthEntry rec(16 - (*this)[i]._depth, i);
+		SpriteSlot &spriteSlot = (*this)[i];
+		if (spriteSlot._spriteType >= ST_NONE) {
+			DepthEntry rec(16 - spriteSlot._depth, i);
 			depthList.push_back(rec);
 		}
 	}
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index 848aa1a..603518a 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -52,8 +52,7 @@ typedef struct {
 	uint8	depth;		// depth code for source (0 if no depth processing)
 } DrawRequestX;
 
-typedef struct
-{
+typedef struct {
 	uint32 Pack;
 	uint32 Stream;
 	long   hot_x;
@@ -111,7 +110,6 @@ public:
 		int widthVal, int heightVal, bool decodeRle = true, uint8 encodingVal = 0);
 	virtual ~MSprite();
 
-	Common::Point _pos;
 	Common::Point _offset;
 	uint8 _encoding;
 


Commit: 0df4d0aed1678f81cb75bb56cb2a1fc19603312c
    https://github.com/scummvm/scummvm/commit/0df4d0aed1678f81cb75bb56cb2a1fc19603312c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-12T23:45:57-04:00

Commit Message:
MADS: Fixed loading of scene depth surface for Rex Nebular

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes.h
    engines/mads/palette.cpp
    engines/mads/palette.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index baee40c..3587822 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -68,6 +68,13 @@ void SceneInfoNebular::loadCodes(MSurface &depthSurface) {
 	MadsPack codesPack(&f);
 	Common::SeekableReadStream *stream = codesPack.getItemStream(0);
 
+	loadCodes(depthSurface, stream);
+
+	delete stream;
+	f.close();
+}
+
+void SceneInfoNebular::loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream) {
 	byte *destP = depthSurface.getData();
 	byte *endP = depthSurface.getBasePtr(0, depthSurface.h);
 
@@ -85,8 +92,6 @@ void SceneInfoNebular::loadCodes(MSurface &depthSurface) {
 
 	if (destP < endP)
 		Common::fill(destP, endP, 0);
-	delete stream;
-	f.close();
 }
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index da36c71..5ac708d 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -115,6 +115,8 @@ class SceneInfoNebular : public SceneInfo {
 protected:
 	virtual void loadCodes(MSurface &depthSurface);
 
+	virtual void loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream);
+
 	/**
 	* Constructor
 	*/
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 7e0d5bb..b42fa14 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -229,7 +229,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 		palette[palIndex]._palIndex = var4;
 	}
 
-	_vm->_palette->_rgbList[rgbIndex] = 0xffff;
+	_vm->_palette->_rgbList[rgbIndex] = -1;
 
 	delete[] pal1;
 	delete[] pal2;
@@ -541,7 +541,7 @@ void Palette::resetGamePalette(int lowRange, int highRange) {
 	}
 
 	_rgbList.clear();
-	_rgbList[0] = _rgbList[1] = 0xffff;
+	_rgbList[0] = _rgbList[1] = -1;
 
 	_v1 = 0;
 	_lowRange = lowRange;
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 5f21bd9..906f62c 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -100,7 +100,7 @@ public:
 
 class RGBList {
 private:
-	uint16 _data[32];
+	int16 _data[32];
 public:
 	RGBList() { clear(); }
 
@@ -113,7 +113,7 @@ public:
 	 */
 	int scan();
 
-	uint16 &operator[](int idx) { return _data[idx]; }
+	int16 &operator[](int idx) { return _data[idx]; }
 };
 
 #define PALETTE_COUNT 256
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index d2071e3..0cb273a 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -383,7 +383,7 @@ SceneInfo *SceneInfo::init(MADSEngine *vm) {
 	if (vm->getGameID() == GType_RexNebular) {
 		return new Nebular::SceneInfoNebular(vm);
 	} else {
-		return new SceneInfo(vm);
+		error("Unknown game");
 	}
 }
 
@@ -453,9 +453,7 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
 		if (i < spriteInfoCount)
 			spriteInfo.push_back(info);
 	}
-
 	delete infoStream;
-	infoFile.close();
 
 	int width = _width;
 	int height = _height;
@@ -471,7 +469,11 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
 	}
 
 	// Load the depth surface with the scene codes
-	loadCodes(depthSurface);
+	Common::SeekableReadStream *depthStream = infoPack.getItemStream(1);
+	loadCodes(depthSurface, depthStream);
+	delete depthStream;
+
+	infoFile.close();
 
 	// Get the ART resource
 	if (sceneFlag) {
@@ -554,35 +556,6 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
 	}
 }
 
-void SceneInfo::loadCodes(MSurface &depthSurface) {
-	File f(Resources::formatName(RESPREFIX_RM, _sceneId, ".DAT"));
-	MadsPack codesPack(&f);
-	Common::SeekableReadStream *stream = codesPack.getItemStream(0);
-
-	uint16 width = _width;
-	uint16 height = _height;
-	byte *walkMap = new byte[stream->size()];
-
-	depthSurface.setSize(width, height);
-	stream->read(walkMap, f.size());
-	delete stream;
-	f.close();
-
-	byte *ptr = (byte *)depthSurface.getPixels();
-
-	for (int y = 0; y < height; y++) {
-		for (int x = 0; x < width; x++) {
-			int ofs = x + (y * width);
-			if ((walkMap[ofs / 8] << (ofs % 8)) & 0x80)
-				*ptr++ = 1;		// walkable
-			else
-				*ptr++ = 0;
-		}
-	}
-
-	delete[] walkMap;
-}
-
 /*------------------------------------------------------------------------*/
 
 SceneLogic::SceneLogic(MADSEngine *vm) : _vm(vm) {
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index b8b2056..d5c7281 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -253,7 +253,12 @@ protected:
 	/**
 	 * Loads the given surface with depth information of a given scene
 	 */
-	virtual void loadCodes(MSurface &depthSurface);
+	virtual void loadCodes(MSurface &depthSurface) = 0;
+
+	/**
+	* Loads the given surface with depth information of a given scene
+	*/
+	virtual void loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream) = 0;
 public:
 	int _sceneId;
 	int _artFileNum;


Commit: e80373c823215c8d1ac59a6a1a81dc9233b1eb07
    https://github.com/scummvm/scummvm/commit/e80373c823215c8d1ac59a6a1a81dc9233b1eb07
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-13T00:26:19-04:00

Commit Message:
MADS: Add guard against reading depth value outside bounds of depth surface

Changed paths:
    engines/mads/msurface.cpp



diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 2adb3e5..e8d391f 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -497,12 +497,14 @@ MSurface *MSurface::flipHorizontal() const {
 /*------------------------------------------------------------------------*/
 
 int DepthSurface::getDepth(const Common::Point &pt) {
-
 	if (_vm->_game->_scene._sceneInfo->_depthStyle == 2) {
 		int bits = (3 - (pt.x % 4)) * 2;
 		byte v = *getBasePtr(pt.x >> 2, pt.y);
 		return v >> bits;
 	} else {
+		if (pt.x < 0 || pt.y < 0 || pt.x >= this->w || pt.y >= this->h)
+			return 8;
+
 		return *getBasePtr(pt.x, pt.y) & 0xF;
 	}
 }


Commit: b2d90ddaab19702495a2dcc84be0de7443739f0b
    https://github.com/scummvm/scummvm/commit/b2d90ddaab19702495a2dcc84be0de7443739f0b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-13T13:05:12-04:00

Commit Message:
MADS: Fix positioning of foreground sprites

Changed paths:
    engines/mads/assets.h
    engines/mads/sequence.cpp



diff --git a/engines/mads/assets.h b/engines/mads/assets.h
index b485660..31d4688 100644
--- a/engines/mads/assets.h
+++ b/engines/mads/assets.h
@@ -78,7 +78,6 @@ private:
 public:
 	SpriteSetCharInfo *_charInfo;
 	int _usageIndex;
-	Common::Point _pos;
 public:
 	/**
 	 * Constructor
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index dfb3d6f..c03ff38 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -184,7 +184,8 @@ void SequenceList::setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot) {
 	if (!timerEntry._nonFixed) {
 		spriteSlot._position = timerEntry._msgPos;
 	} else {
-		spriteSlot._position = spriteSet._pos;
+		MSprite *sprite = spriteSet.getFrame(spriteSlot._frameNumber);
+		spriteSlot._position = sprite->_offset;
 	}
 }
 


Commit: 84fb90e7a52daffd862159d54cda4817aa930a6f
    https://github.com/scummvm/scummvm/commit/84fb90e7a52daffd862159d54cda4817aa930a6f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-13T20:56:03-04:00

Commit Message:
MADS: Fix GCC warnings and memory leaks

Changed paths:
    engines/mads/animation.cpp
    engines/mads/animation.h
    engines/mads/scene.cpp
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h
    engines/mads/sequence.cpp
    engines/mads/sprites.cpp
    engines/mads/sprites.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index b5ebb2c..09a9e1f 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -145,8 +145,6 @@ Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) {
 
 Animation::~Animation() {
 	delete _font;
-	for (uint i = 0; i < _spriteSets.size(); ++i)
-		delete _spriteSets[i];
 }
 
 void Animation::free() {
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 492fb9d..c5308b7 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -182,8 +182,8 @@ public:
 	 */
 	void update();
 
-	virtual void setCurrentFrame(int frameNumber);
-	virtual int getCurrentFrame() const { return _currentFrame; }
+	void setCurrentFrame(int frameNumber);
+	int getCurrentFrame() const { return _currentFrame; }
 
 	bool freeFlag() const { return _freeFlag; }
 	bool getAnimMode() const { return _header._animMode; }
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index ebc35f0..ef5fd78 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -41,7 +41,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 	_animFlag = false;
 	_animVal1 = 0;
 	_depthStyle = 0;
-	_v1A = _v1C = 0;
+	_v1A = 0;
+	_v1C = 0;
 	_roomChanged = false;
 	_reloadSceneFlag = false;
 	_destFacing = 0;
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 0cb273a..8f981ef 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -140,6 +140,11 @@ void ScreenObjects::proc1() {
 
 MADSEngine *DirtyArea::_vm = nullptr;
 
+DirtyArea::DirtyArea() {
+	_active = false;
+	_textActive = false;
+}
+
 void DirtyArea::setArea(int width, int height, int maxWidth, int maxHeight) {
 	if (_bounds.left % 2) {
 		--_bounds.left;
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index d5c7281..d0c61ae 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -124,7 +124,7 @@ public:
 	bool _textActive;
 	bool _active;
 
-	DirtyArea() { _active = false; }
+	DirtyArea();
 
 	void setArea(int width, int height, int maxWidth, int maxHeight);
 
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index c03ff38..c7cbf19 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -41,11 +41,15 @@ namespace MADS {
 		_dynamicHotspotIndex = -1;
 		_triggerCountdown = 0;
 		_doneFlag = 0;
-		_entries._count = 0;
 		_abortMode = ABORTMODE_0;
 		_numTicks = 0;
 		_extraTicks = 0;
 		_timeout = 0;
+
+		_entries._count = 0;
+		Common::fill(&_entries._mode[0], &_entries._mode[TIMER_ENTRY_SUBSET_MAX], SM_0);
+		Common::fill(&_entries._frameIndex[0], &_entries._frameIndex[TIMER_ENTRY_SUBSET_MAX], 0);
+		Common::fill(&_entries._abortVal[0], &_entries._abortVal[TIMER_ENTRY_SUBSET_MAX], 0);
 	}
 
 	/*------------------------------------------------------------------------*/
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 228071a..a7a46ce 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -362,6 +362,10 @@ void SpriteSlots::cleanUp() {
 
 /*------------------------------------------------------------------------*/
 
+SpriteSets::~SpriteSets() {
+	clear();
+}
+
 int SpriteSets::add(SpriteAsset *asset, int idx) {
 	if (!idx)
 		idx = size();
@@ -378,6 +382,13 @@ int SpriteSets::addSprites(const Common::String &resName, int flags) {
 	return add(new SpriteAsset(_vm, resName, flags));
 }
 
+void SpriteSets::clear() {
+	for (uint i = 0; i < size(); ++i)
+		delete (*this)[i];
+
+	Common::Array<SpriteAsset *>::clear();
+}
+
 /*------------------------------------------------------------------------*/
 
 ImageInterEntry::ImageInterEntry() {
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index 603518a..bf19be1 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -207,6 +207,16 @@ public:
 	SpriteSets(MADSEngine *vm) : _vm(vm) {}
 
 	/**
+	 * Destructor
+	 */
+	~SpriteSets();
+
+	/**
+	 * Clears the current list, freeing any laoded assets
+	 */
+	void clear();
+
+	/**
 	* Add a sprite asset to the list
 	*/
 	int add(SpriteAsset *asset, int idx = 0);


Commit: 3f0cd4771c94a83c72f09f74ba351a3905357d1c
    https://github.com/scummvm/scummvm/commit/3f0cd4771c94a83c72f09f74ba351a3905357d1c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-13T22:25:16-04:00

Commit Message:
MADS: Fixed handling of dirty rects to copy areas to the physical screen

Changed paths:
  A engines/mads/screen.cpp
  A engines/mads/screen.h
  R engines/mads/graphics.cpp
  R engines/mads/graphics.h
    engines/mads/dialogs.cpp
    engines/mads/game.cpp
    engines/mads/game_data.cpp
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/messages.cpp
    engines/mads/module.mk
    engines/mads/msurface.cpp
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/game_nebular.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h
    engines/mads/sprites.cpp
    engines/mads/user_interface.cpp



diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index d159d48..571cca5 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -23,7 +23,7 @@
 #include "common/scummsys.h"
 #include "common/config-manager.h"
 #include "mads/mads.h"
-#include "mads/graphics.h"
+#include "mads/screen.h"
 #include "mads/msurface.h"
 #include "mads/nebular/dialogs_nebular.h"
 
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 6a7f6fb..bcebc04 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -25,7 +25,7 @@
 #include "mads/game.h"
 #include "mads/game_data.h"
 #include "mads/events.h"
-#include "mads/graphics.h"
+#include "mads/screen.h"
 #include "mads/msurface.h"
 #include "mads/resources.h"
 #include "mads/nebular/game_nebular.h"
diff --git a/engines/mads/game_data.cpp b/engines/mads/game_data.cpp
index ba24ed9..cbc8f93 100644
--- a/engines/mads/game_data.cpp
+++ b/engines/mads/game_data.cpp
@@ -24,7 +24,7 @@
 #include "mads/mads.h"
 #include "mads/game.h"
 #include "mads/nebular/game_nebular.h"
-#include "mads/graphics.h"
+#include "mads/screen.h"
 #include "mads/msurface.h"
 #include "mads/resources.h"
 
diff --git a/engines/mads/graphics.cpp b/engines/mads/graphics.cpp
deleted file mode 100644
index 769b4dd..0000000
--- a/engines/mads/graphics.cpp
+++ /dev/null
@@ -1,91 +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/scummsys.h"
-#include "mads/mads.h"
-#include "mads/game.h"
-#include "mads/graphics.h"
-#include "mads/palette.h"
-
-namespace MADS {
-
-void ScreenSurface::init() {
-	setSize(g_system->getWidth(), g_system->getHeight());
-}
-
-void ScreenSurface::updateScreen() {
-	g_system->copyRectToScreen((const byte *)pixels, pitch, 0, 0, w, h);
-	g_system->updateScreen();
-}
-
-void ScreenSurface::transition(ScreenTransition transitionType, bool surfaceFlag) {
-	switch (transitionType) {
-	case kTransitionFadeOutIn:
-		fadeOut();
-		fadeIn();
-		break;
-
-	case kTransitionFadeIn:
-		fadeIn();
-		break;
-
-	case kTransitionBoxInBottomLeft:
-	case kTransitionBoxInBottomRight:
-	case kTransitionBoxInTopLeft:
-	case kTransitionBoxInTopRight:
-		error("TODO: transition");
-		break;
-
-	case kTransitionPanLeftToRight:
-	case kTransitionPanRightToLeft:
-		error("TODO: transition");
-
-	case kTransitionCircleIn1:
-	case kTransitionCircleIn2:
-	case kTransitionCircleIn3:
-	case kTransitionCircleIn4:
-		error("TODO circle transition");
-
-	case kCenterVertTransition:
-		error("TODO: center vert transition");
-
-	default:
-		// Quick transitions
-		break;
-	}
-}
-
-void ScreenSurface::setPointer(MSurface *s) {
-	_pixels = s->getData();
-	_pitch = s->w;
-}
-
-void ScreenSurface::fadeOut() {
-	warning("TODO: Proper fade out");
-}
-
-void ScreenSurface::fadeIn() {
-	warning("TODO: Proper fade in");
-	_vm->_palette->setFullPalette(_vm->_palette->_mainPalette);
-}
-
-} // End of namespace MADS
diff --git a/engines/mads/graphics.h b/engines/mads/graphics.h
deleted file mode 100644
index d4933ae..0000000
--- a/engines/mads/graphics.h
+++ /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.
- *
- */
-
-#ifndef MADS_GRAPHICS_H
-#define MADS_GRAPHICS_H
-
-#include "common/scummsys.h"
-#include "common/array.h"
-#include "mads/msurface.h"
-
-namespace MADS {
-
-#define MADS_SCREEN_WIDTH 320
-#define MADS_SCREEN_HEIGHT 200
-
-enum ScreenTransition {
-	kTransitionNone = 0,
-	kTransitionFadeIn, kTransitionFadeOutIn,
-	kTransitionBoxInBottomLeft, kTransitionBoxInBottomRight,
-	kTransitionBoxInTopLeft, kTransitionBoxInTopRight,
-	kTransitionPanLeftToRight, kTransitionPanRightToLeft,
-	kTransitionCircleIn1, kTransitionCircleIn2,
-	kTransitionCircleIn3, kTransitionCircleIn4,
-	kVertTransition1, kVertTransition2, kVertTransition3,
-	kVertTransition4, kVertTransition5, kVertTransition6,
-	kVertTransition7, kCenterVertTransition
-};
-
-class ScreenSurface : public MSurface {
-private:
-	/**
-	 * Handles screen fade out
-	 */
-	void fadeOut();
-
-	/**
-	 * Handles screen fade in
-	 */
-	void fadeIn();
-public:
-	Common::Point _offset;
-	byte *_pixels;
-	int _pitch;
-public:
-	/**
-	 * Constructor
-	 */
-	ScreenSurface() {}
-
-	/**
-	 * Initialise the surface
-	 */
-	void init();
-
-	void setPointer(MSurface *s);
-
-	/**
-	 * Updates the screen with the contents of the surface
-	 */
-	void updateScreen();
-
-	void transition(ScreenTransition transitionType, bool surfaceFlag);
-};
-
-} // End of namespace MADS
-
-#endif /* MADS_GRAPHICS_H */
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 6dfdf7b..9cab1ad 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -26,7 +26,7 @@
 #include "common/events.h"
 #include "engines/util.h"
 #include "mads/mads.h"
-#include "mads/graphics.h"
+#include "mads/screen.h"
 #include "mads/msurface.h"
 #include "mads/resources.h"
 #include "mads/sound.h"
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index 2fbac32..749c69a 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -35,7 +35,7 @@
 #include "mads/events.h"
 #include "mads/font.h"
 #include "mads/game.h"
-#include "mads/graphics.h"
+#include "mads/screen.h"
 #include "mads/msurface.h"
 #include "mads/resources.h"
 #include "mads/sound.h"
diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index dcac541..21463aa 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -23,7 +23,7 @@
 #include "common/scummsys.h"
 #include "mads/mads.h"
 #include "mads/font.h"
-#include "mads/graphics.h"
+#include "mads/screen.h"
 #include "mads/messages.h"
 #include "mads/scene_data.h"
 
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 2f4982f..a65519f 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -18,7 +18,6 @@ MODULE_OBJS := \
 	font.o \
 	game.o \
 	game_data.o \
-	graphics.o \
 	hotspots.o \
 	interface.o \
 	mads.o \
@@ -29,6 +28,7 @@ MODULE_OBJS := \
 	resources.o \
 	scene.o \
 	scene_data.o \
+	screen.o \
 	sequence.o \
 	sound.o \
 	sprites.o \
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index e8d391f..c8c6623 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -22,7 +22,7 @@
 
 #include "engines/util.h"
 #include "mads/compression.h"
-#include "mads/graphics.h"
+#include "mads/screen.h"
 #include "mads/mads.h"
 #include "mads/msurface.h"
 #include "mads/resources.h"
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 6d2321e..dc74f39 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -23,7 +23,7 @@
 #include "common/scummsys.h"
 #include "common/config-manager.h"
 #include "mads/mads.h"
-#include "mads/graphics.h"
+#include "mads/screen.h"
 #include "mads/msurface.h"
 #include "mads/nebular/dialogs_nebular.h"
 
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 65abb40..8948689 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -24,7 +24,7 @@
 #include "common/config-manager.h"
 #include "mads/mads.h"
 #include "mads/game.h"
-#include "mads/graphics.h"
+#include "mads/screen.h"
 #include "mads/msurface.h"
 #include "mads/nebular/game_nebular.h"
 #include "mads/nebular/dialogs_nebular.h"
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index ef5fd78..8bf0b6a 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -438,7 +438,7 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
 	_dirtyAreas.merge(1, DIRTY_AREAS_SIZE);
 
 	// Copy dirty areas to the main display surface
-	_dirtyAreas.copy(&_vm->_screen, &_backgroundSurface, _posAdjust);
+	_dirtyAreas.copy(&_backgroundSurface, &_vm->_screen, _posAdjust);
 
 	// Handle dirty areas for foreground objects
 	_spriteSlots.setDirtyAreas();
@@ -463,7 +463,7 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
 		_vm->_sound->startQueuedCommands();
 	} else {
 		// Copy dirty areas to the screen
-		_dirtyAreas.copy(&_vm->_screen, &_backgroundSurface, _vm->_screen._offset);
+		_dirtyAreas.copyToScreen(_vm->_screen._offset);
 	}
 
 	warning("TODO: sub_115A2");
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 79c5910..0b20fb0 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -27,7 +27,7 @@
 #include "common/array.h"
 #include "common/rect.h"
 #include "mads/assets.h"
-#include "mads/graphics.h"
+#include "mads/screen.h"
 #include "mads/hotspots.h"
 #include "mads/messages.h"
 #include "mads/msurface.h"
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 8f981ef..fe76893 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -24,7 +24,7 @@
 #include "mads/scene_data.h"
 #include "mads/mads.h"
 #include "mads/compression.h"
-#include "mads/graphics.h"
+#include "mads/screen.h"
 #include "mads/resources.h"
 #include "mads/nebular/nebular_scenes.h"
 
@@ -276,7 +276,20 @@ void DirtyAreas::mergeAreas(int idx1, int idx2) {
 	da1._textActive = true;
 }
 
-void DirtyAreas::copy(MSurface *dest, MSurface *src, const Common::Point &posAdjust) {
+void DirtyAreas::copy(MSurface *srcSurface, MSurface *destSurface, const Common::Point &posAdjust) {
+	for (uint i = 0; i < size(); ++i) {
+		const Common::Rect &srcBounds = (*this)[i]._bounds;
+
+		Common::Rect bounds(srcBounds.left + posAdjust.x, srcBounds.top + posAdjust.y,
+			srcBounds.right + posAdjust.x, srcBounds.bottom + posAdjust.y);
+
+		if ((*this)[i]._active && bounds.isValidRect()) {
+			srcSurface->copyTo(destSurface, bounds, Common::Point(bounds.left, bounds.top));
+		}
+	}
+}
+
+void DirtyAreas::copyToScreen(const Common::Point &posAdjust) {
 	for (uint i = 0; i < size(); ++i) {
 		const Common::Rect &srcBounds = (*this)[i]._bounds;
 
@@ -284,8 +297,7 @@ void DirtyAreas::copy(MSurface *dest, MSurface *src, const Common::Point &posAdj
 			srcBounds.right + posAdjust.x, srcBounds.bottom + posAdjust.y);
 
 		if ((*this)[i]._active && (*this)[i]._bounds.isValidRect()) {
-			src->copyTo(dest, bounds, Common::Point((*this)[i]._bounds.left,
-				(*this)[i]._bounds.top));
+			_vm->_screen.copyRectToScreen(bounds);
 		}
 	}
 }
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index d0c61ae..7a41bab 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -151,7 +151,21 @@ public:
 
 	bool intersects(int idx1, int idx2);
 	void mergeAreas(int idx1, int idx2);
-	void copy(MSurface *dest, MSurface *src, const Common::Point &posAdjust);
+
+	/**
+	 * Copy the data specified by the dirty rect list between surfaces
+	 * @param srcSurface	Source surface
+	 * @param destSurface	Dest surface
+	 * @param posAdjust		Position adjustment
+	 */
+	void copy(MSurface *srcSurface, MSurface *destSurface, const Common::Point &posAdjust);
+
+	/**
+	 * Use the lsit of dirty areas to copy areas of the screen surface to
+	 * the physical screen
+	 * @param posAdjust		Position adjustment	 */
+	void copyToScreen(const Common::Point &posAdjust);
+
 	void reset();
 };
 
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
new file mode 100644
index 0000000..20ff4f6
--- /dev/null
+++ b/engines/mads/screen.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/game.h"
+#include "mads/screen.h"
+#include "mads/palette.h"
+
+namespace MADS {
+
+ScreenSurface::ScreenSurface() {
+	_dataP = nullptr;
+}
+
+void ScreenSurface::init() {
+	setSize(g_system->getWidth(), g_system->getHeight());
+}
+
+void ScreenSurface::copyRectToScreen(const Common::Point &destPos,
+		const Common::Rect &bounds) {
+	byte *buf = getBasePtr(destPos.x, destPos.y);
+	g_system->copyRectToScreen(buf, this->pitch, bounds.left, bounds.top,
+		bounds.width(), bounds.height());
+}
+
+void ScreenSurface::copyRectToScreen(const Common::Rect &bounds) {
+	copyRectToScreen(Common::Point(bounds.left, bounds.top), bounds);
+}
+
+
+void ScreenSurface::updateScreen() {
+	g_system->updateScreen();
+}
+
+void ScreenSurface::transition(ScreenTransition transitionType, bool surfaceFlag) {
+	switch (transitionType) {
+	case kTransitionFadeOutIn:
+		fadeOut();
+		fadeIn();
+		break;
+
+	case kTransitionFadeIn:
+		fadeIn();
+		break;
+
+	case kTransitionBoxInBottomLeft:
+	case kTransitionBoxInBottomRight:
+	case kTransitionBoxInTopLeft:
+	case kTransitionBoxInTopRight:
+		error("TODO: transition");
+		break;
+
+	case kTransitionPanLeftToRight:
+	case kTransitionPanRightToLeft:
+		error("TODO: transition");
+
+	case kTransitionCircleIn1:
+	case kTransitionCircleIn2:
+	case kTransitionCircleIn3:
+	case kTransitionCircleIn4:
+		error("TODO circle transition");
+
+	case kCenterVertTransition:
+		error("TODO: center vert transition");
+
+	default:
+		// Quick transitions
+		break;
+	}
+}
+
+void ScreenSurface::setPointer(MSurface *s) {
+	_dataP = s->getData();
+}
+
+void ScreenSurface::fadeOut() {
+	warning("TODO: Proper fade out");
+}
+
+void ScreenSurface::fadeIn() {
+	warning("TODO: Proper fade in");
+	_vm->_palette->setFullPalette(_vm->_palette->_mainPalette);
+	_vm->_screen.copyRectToScreen(Common::Rect(0, 0, 320, 200));
+}
+
+} // End of namespace MADS
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
new file mode 100644
index 0000000..e101020
--- /dev/null
+++ b/engines/mads/screen.h
@@ -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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_SCREEN_H
+#define MADS_SCREEN_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+#include "mads/msurface.h"
+
+namespace MADS {
+
+#define MADS_SCREEN_WIDTH 320
+#define MADS_SCREEN_HEIGHT 200
+
+enum ScreenTransition {
+	kTransitionNone = 0,
+	kTransitionFadeIn, kTransitionFadeOutIn,
+	kTransitionBoxInBottomLeft, kTransitionBoxInBottomRight,
+	kTransitionBoxInTopLeft, kTransitionBoxInTopRight,
+	kTransitionPanLeftToRight, kTransitionPanRightToLeft,
+	kTransitionCircleIn1, kTransitionCircleIn2,
+	kTransitionCircleIn3, kTransitionCircleIn4,
+	kVertTransition1, kVertTransition2, kVertTransition3,
+	kVertTransition4, kVertTransition5, kVertTransition6,
+	kVertTransition7, kCenterVertTransition
+};
+
+class ScreenSurface : public MSurface {
+private:
+	/**
+	 * Handles screen fade out
+	 */
+	void fadeOut();
+
+	/**
+	 * Handles screen fade in
+	 */
+	void fadeIn();
+public:
+	Common::Point _offset;
+	byte *_dataP;
+public:
+	/**
+	 * Constructor
+	 */
+	ScreenSurface();
+
+	/**
+	 * Initialise the surface
+	 */
+	void init();
+
+	void setPointer(MSurface *s);
+
+	/**
+	 * Copys an area of the screen surface to a given destination position on
+	 * the ScummVM physical screen buffer
+	 * @param destPos	Destination position
+	 * @param bounds	Area of screen surface to copy
+	 */
+	void copyRectToScreen(const Common::Point &destPos, const Common::Rect &bounds);
+
+	/**
+	 * Copys an area of the screen surface to the ScmmVM physical screen buffer
+	 * @param bounds	Area of screen surface to copy
+	 */
+	void copyRectToScreen(const Common::Rect &bounds);
+
+	/**
+	 * Updates the screen with the contents of the surface
+	 */
+	void updateScreen();
+
+	void transition(ScreenTransition transitionType, bool surfaceFlag);
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_SCREEN_H */
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index a7a46ce..6f227fa 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -24,7 +24,7 @@
 #include "engines/util.h"
 #include "graphics/palette.h"
 #include "mads/mads.h"
-#include "mads/graphics.h"
+#include "mads/screen.h"
 #include "mads/msurface.h"
 #include "mads/sprites.h"
 
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 3bbf6a0..ec5ca8a 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -22,7 +22,7 @@
 
 #include "common/scummsys.h"
 #include "mads/mads.h"
-#include "mads/graphics.h"
+#include "mads/screen.h"
 #include "mads/user_interface.h"
 #include "mads/msurface.h"
 


Commit: 12b79e817833fe17da717b88999da96e9bb1ec76
    https://github.com/scummvm/scummvm/commit/12b79e817833fe17da717b88999da96e9bb1ec76
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-14T21:56:01-04:00

Commit Message:
MADS: Fix for sprite slot cleanup post-frame draw

Changed paths:
    engines/mads/sprites.cpp



diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 6f227fa..ff953ac 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -240,6 +240,7 @@ void SpriteSlots::drawBackground() {
 		DirtyArea &dirtyArea = scene._dirtyAreas[i];
 
 		if (spriteSlot._spriteType >= ST_NONE) {
+			// Foreground sprite, so we can ignore it
 			dirtyArea._active = false;
 		} else {
 			dirtyArea._active = true;
@@ -249,6 +250,7 @@ void SpriteSlots::drawBackground() {
 			MSprite *frame = asset->getFrame(spriteSlot._frameNumber);
 
 			if (spriteSlot._spriteType == ST_BACKGROUND) {
+				// Background object, so need to draw it
 				Common::Point pt = spriteSlot._position;
 				if (spriteSlot._scale != -1) {
 					// Adjust the drawing position
@@ -258,8 +260,7 @@ void SpriteSlots::drawBackground() {
 
 				if (spriteSlot._depth <= 1) {
 					asset->draw(&scene._backgroundSurface, spriteSlot._frameNumber, pt);
-				}
-				else if (scene._depthStyle == 0) {
+				} else if (scene._depthStyle == 0) {
 					asset->depthDraw(&scene._backgroundSurface, &scene._depthSurface, spriteSlot._frameNumber,
 						pt, spriteSlot._depth);
 				} else {
@@ -355,7 +356,7 @@ void SpriteSlots::drawForeground(MSurface *s) {
 
 void SpriteSlots::cleanUp() {
 	for (int i = (int)size() - 1; i >= 0; --i) {
-		if ((*this)[i]._spriteType >= ST_NONE)
+		if ((*this)[i]._spriteType < ST_NONE)
 			remove_at(i);
 	}
 }


Commit: 37bb5150d0d2c901b9bb88ec009a348f1de3d5b0
    https://github.com/scummvm/scummvm/commit/37bb5150d0d2c901b9bb88ec009a348f1de3d5b0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-14T22:21:52-04:00

Commit Message:
MADS: Fixes for handling sprite transparency

Changed paths:
    engines/mads/sprites.cpp



diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index ff953ac..2d318c5 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -70,15 +70,15 @@ MSprite::MSprite(Common::SeekableReadStream *source, const Common::Point &offset
 MSprite::~MSprite() {
 }
 
-// TODO: The sprite outlines (pixel value 0xFD) are not shown
 void MSprite::loadSprite(Common::SeekableReadStream *source) {
 	byte *outp, *lineStart;
 	bool newLine = false;
 
 	outp = getData();
 	lineStart = getData();
+	Common::fill(outp, outp + this->w * this->h, getTransparencyIndex());
 
-	while (1) {
+	for (;;) {
 		byte cmd1, cmd2, count, pixel;
 
 		if (newLine) {
@@ -101,7 +101,7 @@ void MSprite::loadSprite(Common::SeekableReadStream *source) {
 				} else {
 					pixel = source->readByte();
 					while (count--)
-						*outp++ = (pixel == 0xFD) ? 0 : pixel;
+						*outp++ = (pixel == 0xFD) ? getTransparencyIndex() : pixel;
 				}
 			}
 		} else {
@@ -113,9 +113,9 @@ void MSprite::loadSprite(Common::SeekableReadStream *source) {
 					count = source->readByte();
 					pixel = source->readByte();
 					while (count--)
-						*outp++ = (pixel == 0xFD) ? 0 : pixel;
+						*outp++ = (pixel == 0xFD) ? getTransparencyIndex() : pixel;
 				} else {
-					*outp++ = (cmd2 == 0xFD) ? 0 : cmd2;
+					*outp++ = (cmd2 == 0xFD) ? getTransparencyIndex() : cmd2;
 				}
 			}
 		}


Commit: c9661ca88cbe3554a455c320fe7bcdcb203823a5
    https://github.com/scummvm/scummvm/commit/c9661ca88cbe3554a455c320fe7bcdcb203823a5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-15T08:41:17-04:00

Commit Message:
MADS: Fix off by 1 frame references in srite drawing

Changed paths:
    engines/mads/interface.cpp
    engines/mads/palette.cpp
    engines/mads/palette.h
    engines/mads/sequence.cpp
    engines/mads/sprites.cpp



diff --git a/engines/mads/interface.cpp b/engines/mads/interface.cpp
index 0c983dc..8ea8913 100644
--- a/engines/mads/interface.cpp
+++ b/engines/mads/interface.cpp
@@ -53,9 +53,9 @@ void InterfaceSurface::load(const Common::String &resName) {
 	byte *palP = &_vm->_palette->_mainPalette[0];
 
 	for (int i = 0; i < 16; ++i, gamePalP++, palP += 3) {
-		palP[0] = palStream->readByte();
-		palP[1] = palStream->readByte();
-		palP[2] = palStream->readByte();
+		palP[0] = VGA_COLOR_TRANS(palStream->readByte());
+		palP[1] = VGA_COLOR_TRANS(palStream->readByte());
+		palP[2] = VGA_COLOR_TRANS(palStream->readByte());
 		*gamePalP |= 1;
 		palStream->skip(3);
 	}
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index b42fa14..9f6e3c7 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -28,8 +28,6 @@
 
 namespace MADS {
 
-#define VGA_COLOR_TRANS(x) (((((int)(x)) + 1) << 2) - 1)
-
 void RGB6::load(Common::SeekableReadStream *f) {
 	r = VGA_COLOR_TRANS(f->readByte());
 	g = VGA_COLOR_TRANS(f->readByte());
@@ -573,38 +571,47 @@ void Palette::initPalette() {
 	_rgbList.reset();
 }
 
+const uint32 DEFAULT_VGA_PALETTE[PALETTE_COUNT] = {
+	0x000000, 0x0000a8, 0x00a800, 0x00a8a8, 0xa80000, 0xa800a8, 0xa85400, 0xa8a8a8,
+	0x545454, 0x5454fc, 0x54fc54, 0x54fcfc, 0xfc5454, 0xfc54fc, 0xfcfc54, 0xfcfcfc,
+	0x000000, 0x141414, 0x202020, 0x2c2c2c, 0x383838, 0x444444, 0x505050, 0x606060,
+	0x707070, 0x808080, 0x909090, 0xa0a0a0, 0xb4b4b4, 0xc8c8c8, 0xe0e0e0, 0xfcfcfc,
+	0x0000fc, 0x4000fc, 0x7c00fc, 0xbc00fc, 0xfc00fc, 0xfc00bc, 0xfc007c, 0xfc0040,
+	0xfc0000, 0xfc4000, 0xfc7c00, 0xfcbc00, 0xfcfc00, 0xbcfc00, 0x7cfc00, 0x40fc00,
+	0x00fc00, 0x00fc40, 0x00fc7c, 0x00fcbc, 0x00fcfc, 0x00bcfc, 0x007cfc, 0x0040fc,
+	0x7c7cfc, 0x9c7cfc, 0xbc7cfc, 0xdc7cfc, 0xfc7cfc, 0xfc7cdc, 0xfc7cbc, 0xfc7c9c,
+	0xfc7c7c, 0xfc9c7c, 0xfcbc7c, 0xfcdc7c, 0xfcfc7c, 0xdcfc7c, 0xbcfc7c, 0x9cfc7c,
+	0x7cfc7c, 0x7cfc9c, 0x7cfcbc, 0x7cfcdc, 0x7cfcfc, 0x7cdcfc, 0x7cbcfc, 0x7c9cfc,
+	0xb4b4fc, 0xc4b4fc, 0xd8b4fc, 0xe8b4fc, 0xfcb4fc, 0xfcb4e8, 0xfcb4d8, 0xfcb4c4,
+	0xfcb4b4, 0xfcc4b4, 0xfcd8b4, 0xfce8b4, 0xfcfcb4, 0xe8fcb4, 0xd8fcb4, 0xc4fcb4,
+	0xb4fcb4, 0xb4fcc4, 0xb4fcd8, 0xb4fce8, 0xb4fcfc, 0xb4e8fc, 0xb4d8fc, 0xb4c4fc,
+	0x000070, 0x1c0070, 0x380070, 0x540070, 0x700070, 0x700054, 0x700038, 0x70001c,
+	0x700000, 0x701c00, 0x703800, 0x705400, 0x707000, 0x547000, 0x387000, 0x1c7000,
+	0x007000, 0x00701c, 0x007038, 0x007054, 0x007070, 0x005470, 0x003870, 0x001c70,
+	0x383870, 0x443870, 0x543870, 0x603870, 0x703870, 0x703860, 0x703854, 0x703844,
+	0x703838, 0x704438, 0x705438, 0x706038, 0x707038, 0x607038, 0x547038, 0x447038,
+	0x387038, 0x387044, 0x387054, 0x387060, 0x387070, 0x386070, 0x385470, 0x384470,
+	0x505070, 0x585070, 0x605070, 0x685070, 0x705070, 0x705068, 0x705060, 0x705058,
+	0x705050, 0x705850, 0x706050, 0x706850, 0x707050, 0x687050, 0x607050, 0x587050,
+	0x507050, 0x507058, 0x507060, 0x507068, 0x507070, 0x506870, 0x506070, 0x505870,
+	0x000040, 0x100040, 0x200040, 0x300040, 0x400040, 0x400030, 0x400020, 0x400010,
+	0x400000, 0x401000, 0x402000, 0x403000, 0x404000, 0x304000, 0x204000, 0x104000,
+	0x004000, 0x004010, 0x004020, 0x004030, 0x004040, 0x003040, 0x002040, 0x001040,
+	0x202040, 0x282040, 0x302040, 0x382040, 0x402040, 0x402038, 0x402030, 0x402028,
+	0x402020, 0x402820, 0x403020, 0x403820, 0x404020, 0x384020, 0x304020, 0x284020,
+	0x204020, 0x204028, 0x204030, 0x204038, 0x204040, 0x203840, 0x203040, 0x202840,
+	0x2c2c40, 0x302c40, 0x342c40, 0x3c2c40, 0x402c40, 0x402c3c, 0x402c34, 0x402c30,
+	0x402c2c, 0x40302c, 0x40342c, 0x403c2c, 0x40402c, 0x3c402c, 0x34402c, 0x30402c,
+	0x2c402c, 0x2c4030, 0x2c4034, 0x2c403c, 0x2c4040, 0x2c3c40, 0x2c3440, 0x2c3040,
+	0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000
+};
+
 void Palette::initVGAPalette(byte *palette) {
-	int var6 = 0;
-	int vdx = 0;
-	int vbx = 0;
 	byte *destP = palette;
-
-	do {
-		int vdi = (vdx == 1) ? 0x3F : 0x2A;
-		int var8 = 0;
-		int varE = vbx;
-		int var10 = vdx;
-		do {
-			vdx = 0;
-			do {
-				int vcx = 0;
-				int var4 = vdx;
-				do {
-					*destP++ = VGA_COLOR_TRANS((var8) ? vdi & 0xFF : vbx & 0XFF);
-					*destP++ = VGA_COLOR_TRANS((var4) ? vdi & 0xFF : vbx & 0XFF);
-					*destP++ = VGA_COLOR_TRANS((vcx) ? vdi & 0xFF : vbx & 0XFF);
-				} while (++vcx < 2);
-
-				var6 += 2;
-				vdx = var4;
-			} while (++vdx < 2);
-		} while (++var8 < 2);
-	
-		vdx = var10 + 1;
-		vbx = varE + 21;
-	} while (vbx < 42);
-
-	palette[19] = 21;
+	for (int palIndex = 0; palIndex < PALETTE_COUNT; ++palIndex) {
+		for (int byteCtr = 2; byteCtr >= 0; --byteCtr)
+			*destP++ = ((DEFAULT_VGA_PALETTE[palIndex] >> (8 * byteCtr)) & 0xff) >> 2;
+	}
 }
 
 void Palette::setLowRange() {
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 906f62c..1a54075 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -32,6 +32,9 @@ class MADSEngine;
 
 #define PALETTE_USAGE_COUNT 4
 
+//#define VGA_COLOR_TRANS(x) (((((int)(x)) + 1) << 2) - 1)
+#define VGA_COLOR_TRANS(x) (x)
+
 struct RGB4 {
 	byte r;
 	byte g;
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index c7cbf19..1b4f8a9 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -188,7 +188,8 @@ void SequenceList::setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot) {
 	if (!timerEntry._nonFixed) {
 		spriteSlot._position = timerEntry._msgPos;
 	} else {
-		MSprite *sprite = spriteSet.getFrame(spriteSlot._frameNumber);
+		assert(spriteSlot._frameNumber > 0);
+		MSprite *sprite = spriteSet.getFrame(spriteSlot._frameNumber - 1);
 		spriteSlot._position = sprite->_offset;
 	}
 }
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 2d318c5..78743e6 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -246,11 +246,12 @@ void SpriteSlots::drawBackground() {
 			dirtyArea._active = true;
 			dirtyArea.setSpriteSlot(&spriteSlot);
 
-			SpriteAsset *asset = scene._sprites[spriteSlot._spritesIndex];
-			MSprite *frame = asset->getFrame(spriteSlot._frameNumber);
-
 			if (spriteSlot._spriteType == ST_BACKGROUND) {
 				// Background object, so need to draw it
+				assert(spriteSlot._frameNumber > 0);
+				SpriteAsset *asset = scene._sprites[spriteSlot._spritesIndex];
+				MSprite *frame = asset->getFrame(spriteSlot._frameNumber - 1);
+
 				Common::Point pt = spriteSlot._position;
 				if (spriteSlot._scale != -1) {
 					// Adjust the drawing position
@@ -315,6 +316,8 @@ void SpriteSlots::drawForeground(MSurface *s) {
 		// Get the sprite frame
 		int frameNumber = slot._frameNumber & 0x7fff;
 		bool flipped = (slot._frameNumber & 0x8000) != 0;
+
+		assert(frameNumber > 0);
 		MSprite *sprite = spriteSet.getFrame(frameNumber - 1);
 
 		MSurface *spr = sprite;


Commit: d2bbdd255a43915267bac8dce6998c8f843979da
    https://github.com/scummvm/scummvm/commit/d2bbdd255a43915267bac8dce6998c8f843979da
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-15T11:12:31-04:00

Commit Message:
MADS: Implement palette shifting for loaded sprites

Changed paths:
    engines/mads/assets.cpp
    engines/mads/palette.cpp
    engines/mads/palette.h
    engines/mads/sprites.cpp
    engines/mads/sprites.h



diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index 1c958ad..136a3ff 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -73,10 +73,20 @@ void SpriteAsset::load(Common::SeekableReadStream *stream, int flags) {
 	delete spriteStream;
 
 	// Get the palette data
-	spriteStream = sprite.getItemStream(2);
-	_vm->_palette->decodePalette(spriteStream, flags);
+	Common::SeekableReadStream *palStream = sprite.getItemStream(2);
+	Common::Array<RGB6> palette;
 
-	delete spriteStream;
+	int numColors = palStream->readUint16LE();
+	assert(numColors <= 252);
+
+	// Load in the palette
+	palette.resize(numColors);
+	for (int i = 0; i < numColors; ++i)
+		palette[i].load(palStream);
+
+	// Process the palette data
+	_vm->_palette->_paletteUsage.process(palette, flags);
+	delete palStream;
 
 	spriteStream = sprite.getItemStream(1);
 	Common::SeekableReadStream *spriteDataStream = sprite.getItemStream(3);
@@ -103,9 +113,7 @@ void SpriteAsset::load(Common::SeekableReadStream *stream, int flags) {
 		if (_mode == 0) {
 			// Create a frame and decompress the raw pixel data
 			uint32 currPos = (uint32)spriteDataStream->pos();
-			frame._frame = new MSprite(spriteDataStream, 
-				Common::Point(frame._bounds.left, frame._bounds.top),
-				frame._bounds.width(), frame._bounds.height(), false);
+			frame._frame = new MSprite(spriteDataStream, palette, frame._bounds);
 			assert((uint32)spriteDataStream->pos() == (currPos + frameSize));
 		}
 
@@ -130,9 +138,7 @@ void SpriteAsset::load(Common::SeekableReadStream *stream, int flags) {
 
 			// Load the frames
 			Common::MemoryReadStream *rs = new Common::MemoryReadStream(destData, frameSizes[curFrame]);
-			_frames[curFrame]._frame = new MSprite(rs, 
-				Common::Point(_frames[curFrame]._bounds.left, _frames[curFrame]._bounds.top),
-				_frames[curFrame]._bounds.width(), _frames[curFrame]._bounds.height(), false);
+			_frames[curFrame]._frame = new MSprite(rs, palette, _frames[curFrame]._bounds);
 			delete rs;
 
 			delete[] srcData;
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 9f6e3c7..8f803d1 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -497,21 +497,6 @@ void Palette::processLists(int count, byte *pal1, byte *pal2) {
 	} while (continueFlag);
 }
 
-
-void Palette::decodePalette(Common::SeekableReadStream *palStream, uint flags) {
-	int numColors = palStream->readUint16LE();
-	assert(numColors <= 252);
-
-	// Load in the palette
-	Common::Array<RGB6> palette;
-	palette.resize(numColors);
-	for (int i = 0; i < numColors; ++i)
-		palette[i].load(palStream);
-	
-	// Process the palette data
-	_paletteUsage.process(palette, flags);
-}
-
 void Palette::setSystemPalette() {
 	byte palData[4 * 3];
 	palData[0 * 3] = palData[0 * 3 + 1] = palData[0 * 3 + 2] = 0;
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 1a54075..5a563a5 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -32,8 +32,7 @@ class MADSEngine;
 
 #define PALETTE_USAGE_COUNT 4
 
-//#define VGA_COLOR_TRANS(x) (((((int)(x)) + 1) << 2) - 1)
-#define VGA_COLOR_TRANS(x) (x)
+#define VGA_COLOR_TRANS(x) (((((int)(x)) + 1) << 2) - 1)
 
 struct RGB4 {
 	byte r;
@@ -188,11 +187,6 @@ public:
 	uint8 palIndexFromRgb(byte r, byte g, byte b, byte *paletteData = nullptr);
 
 	/**
-	 * Decodes a palette and loads it into the main palette
-	 */
-	void decodePalette(Common::SeekableReadStream *palStream, uint flags);
-
-	/**
 	 * Sets a small set of system/core colors needed by the game
 	 */
 	void setSystemPalette();
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 78743e6..1b65442 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -58,25 +58,27 @@ MSprite::MSprite(): MSurface() {
 	_encoding = 0;
 }
 
-MSprite::MSprite(Common::SeekableReadStream *source, const Common::Point &offset, 
-		int widthVal, int heightVal, bool decodeRle, uint8 encodingVal)
-		: MSurface(widthVal, heightVal), 
-		_encoding(encodingVal), _offset(offset) {
-
+MSprite::MSprite(Common::SeekableReadStream *source, const Common::Array<RGB6> &palette,
+		const Common::Rect &bounds): 
+		MSurface(bounds.width(), bounds.height()), 
+		_encoding(0), _offset(Common::Point(bounds.left, bounds.top)) {
 	// Load the sprite data
-	loadSprite(source);
+	loadSprite(source, palette);
 }
 
 MSprite::~MSprite() {
 }
 
-void MSprite::loadSprite(Common::SeekableReadStream *source) {
+void MSprite::loadSprite(Common::SeekableReadStream *source,
+		const Common::Array<RGB6> &palette) {
 	byte *outp, *lineStart;
 	bool newLine = false;
 
 	outp = getData();
 	lineStart = getData();
-	Common::fill(outp, outp + this->w * this->h, getTransparencyIndex());
+	int spriteSize = this->w * this->h;
+	byte transIndex = getTransparencyIndex();
+	Common::fill(outp, outp + spriteSize, transIndex);
 
 	for (;;) {
 		byte cmd1, cmd2, count, pixel;
@@ -120,6 +122,13 @@ void MSprite::loadSprite(Common::SeekableReadStream *source) {
 			}
 		}
 	}
+
+	// Do a final iteration over the sprite to convert it's pixels to
+	// the final positions in the main palette
+	for (outp = getData(); spriteSize > 0; --spriteSize, ++outp) {
+		if (*outp != transIndex)
+			*outp = palette[*outp]._palIndex;
+	}
 }
 
 byte MSprite::getTransparencyIndex() const {
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index bf19be1..e0e91dc 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -103,11 +103,11 @@ struct SpriteFrameHeader {
 
 class MSprite: public MSurface {
 private:
-	void loadSprite(Common::SeekableReadStream *source);
+	void loadSprite(Common::SeekableReadStream *source, const Common::Array<RGB6> &palette);
 public:
 	MSprite();
-	MSprite(Common::SeekableReadStream *source, const Common::Point &offset, 
-		int widthVal, int heightVal, bool decodeRle = true, uint8 encodingVal = 0);
+	MSprite(Common::SeekableReadStream *source, const Common::Array<RGB6> &palette,
+		const Common::Rect &bounds);
 	virtual ~MSprite();
 
 	Common::Point _offset;


Commit: 49ca357e9ef19aa2650ca42b1f42c8aacf937ec6
    https://github.com/scummvm/scummvm/commit/49ca357e9ef19aa2650ca42b1f42c8aacf937ec6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-15T11:22:19-04:00

Commit Message:
MADS: Remove redundant _encoding field from MSprite

Changed paths:
    engines/mads/sprites.cpp
    engines/mads/sprites.h



diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 1b65442..8979fdb 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -55,13 +55,12 @@ typedef Common::List<DepthEntry> DepthList;
 /*------------------------------------------------------------------------*/
 
 MSprite::MSprite(): MSurface() {
-	_encoding = 0;
 }
 
 MSprite::MSprite(Common::SeekableReadStream *source, const Common::Array<RGB6> &palette,
 		const Common::Rect &bounds): 
 		MSurface(bounds.width(), bounds.height()), 
-		_encoding(0), _offset(Common::Point(bounds.left, bounds.top)) {
+		_offset(Common::Point(bounds.left, bounds.top)) {
 	// Load the sprite data
 	loadSprite(source, palette);
 }
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index e0e91dc..2d5b208 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -111,7 +111,6 @@ public:
 	virtual ~MSprite();
 
 	Common::Point _offset;
-	uint8 _encoding;
 
 	byte getTransparencyIndex() const;
 };


Commit: e00a1b88ca7500516d78f4bad515b5a558af82a6
    https://github.com/scummvm/scummvm/commit/e00a1b88ca7500516d78f4bad515b5a558af82a6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-15T14:08:43-04:00

Commit Message:
MADS: Perform palette translation on background

Changed paths:
    engines/mads/scene_data.cpp



diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index fe76893..de053a6 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -535,6 +535,11 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
 	stream = artResource.getItemStream(1);
 	stream->read(bgSurface.getPixels(), bgSurface.w * bgSurface.h);
 
+	if (!(flags & 1)) {
+		// Translate the background to use the correct palette indexes
+		bgSurface.translate(artHeader._palette);
+	}
+
 	// Close the ART file
 	delete stream;
 	artFile.close();


Commit: 10124f6806150aad409f6db9a6c7a60afcb44872
    https://github.com/scummvm/scummvm/commit/10124f6806150aad409f6db9a6c7a60afcb44872
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-15T17:38:44-04:00

Commit Message:
MADS: Implemented scene 103 setup and needed support methods

Changed paths:
  A engines/mads/inventory.cpp
  A engines/mads/inventory.h
    engines/mads/game.h
    engines/mads/game_data.cpp
    engines/mads/game_data.h
    engines/mads/hotspots.cpp
    engines/mads/hotspots.h
    engines/mads/messages.cpp
    engines/mads/messages.h
    engines/mads/module.mk
    engines/mads/nebular/globals_nebular.cpp
    engines/mads/nebular/globals_nebular.h
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/palette.cpp
    engines/mads/scene.h
    engines/mads/sequence.cpp
    engines/mads/sequence.h



diff --git a/engines/mads/game.h b/engines/mads/game.h
index 01f2360..8e1559e 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -27,6 +27,7 @@
 #include "common/str-array.h"
 #include "mads/scene.h"
 #include "mads/game_data.h"
+#include "mads/inventory.h"
 #include "mads/player.h"
 
 namespace MADS {
@@ -64,9 +65,7 @@ protected:
 	int _saveSlot;
 	int _statusFlag;
 	SectionHandler *_sectionHandler;
-	VisitedScenes _visitedScenes;
 	Common::StringArray _quotes;
-	int _v3;
 	int _v5;
 	int _v6;
 	bool _updateSceneFlag;
@@ -117,9 +116,11 @@ public:
 	int _priorSectionNumber;
 	int _currentSectionNumber;
 	InventoryObjects _objects;
+	VisitedScenes _visitedScenes;
 	Scene _scene;
 	int _v1;
 	int _v2;
+	int _v3;
 	int _v4;
 	int _abortTimers;
 	int _abortTimers2;
diff --git a/engines/mads/game_data.cpp b/engines/mads/game_data.cpp
index cbc8f93..0f41692 100644
--- a/engines/mads/game_data.cpp
+++ b/engines/mads/game_data.cpp
@@ -31,7 +31,9 @@
 namespace MADS {
 
 void VisitedScenes::add(int sceneId) {
-	if (!exists(sceneId))
+	_sceneRevisited = exists(sceneId);
+
+	if (!_sceneRevisited)
 		push_back(sceneId);
 }
 
@@ -44,62 +46,4 @@ bool VisitedScenes::exists(int sceneId) {
 	return false;
 }
 
-void InventoryObject::load(Common::SeekableReadStream &f) {
-	_descId = f.readUint16LE();
-	_roomNumber = f.readUint16LE();
-	_article = f.readByte();
-	_vocabCount = f.readByte();
-	
-	for (int i = 0; i < 3; ++i) {
-		_vocabList[i]._actionFlags1 = f.readByte();
-		_vocabList[i]._actionFlags2 = f.readByte();
-		_vocabList[i]._vocabId = f.readUint16LE();
-	}
-
-	f.skip(4);	// field12
-	f.read(&_mutilateString[0], 10);
-	f.skip(16);
-}
-
-/*------------------------------------------------------------------------*/
-
-void InventoryObjects::load() {
-	File f("*OBJECTS.DAT");
-
-	// Get the total numer of inventory objects
-	int count = f.readUint16LE();
-	reserve(count);
-
-	// Read in each object
-	for (int i = 0; i < count; ++i) {
-		InventoryObject obj;
-		obj.load(f);
-		push_back(obj);
-
-		// If it's for the player's inventory, add the index to the inventory list
-		if (obj._roomNumber == PLAYER_INVENTORY) {
-			_inventoryList.push_back(i);
-			assert(_inventoryList.size() <= 32);
-		}
-	}
-}
-
-void InventoryObjects::setData(int objIndex, int id, const byte *p) {
-	// TODO: This whole method seems weird. Check it out more thoroughly once
-	// more of the engine is implemented
-	for (int i = 0; i < (int)size(); ++i) {
-		InventoryObject &obj = (*this)[i];
-		if (obj._vocabList[0]._actionFlags1 <= i)
-			break;
-
-		if (obj._mutilateString[6 + i] == id) {
-			(*this)[objIndex]._objFolder = p;
-		}
-	}
-}
-
-void InventoryObjects::setRoom(int objectId, int roomNumber) {
-	warning("TODO: setObjectRoom");
-}
-
 } // End of namespace MADS
diff --git a/engines/mads/game_data.h b/engines/mads/game_data.h
index 56ab366..7674bee 100644
--- a/engines/mads/game_data.h
+++ b/engines/mads/game_data.h
@@ -34,6 +34,11 @@ class Game;
 class VisitedScenes: public Common::Array<int> {
 public:
 	/**
+	 * Stores true when a previously visited scene is revisited
+	 */
+	bool _sceneRevisited;
+
+	/**
 	 * Returns true if a given Scene Id exists in the listed of previously visited scenes.
 	 */
 	bool exists(int sceneId);
@@ -44,53 +49,6 @@ public:
 	void add(int sceneId);
 };
 
-class InventoryObject {
-public:
-	int _descId;
-	int _roomNumber;
-	int _article;
-	int _vocabCount;
-	struct {
-		int _actionFlags1;
-		int _actionFlags2;
-		int _vocabId;
-	} _vocabList[3];
-	char _mutilateString[10];	// ???
-	const byte *_objFolder;		// ???
-
-	/**
-	 * Loads the data for a given object
-	 */
-	void load(Common::SeekableReadStream &f);
-};
-
-class InventoryObjects: public Common::Array<InventoryObject> {
-private:
-	MADSEngine *_vm;
-public:
-	Common::Array<int> _inventoryList;
-
-	/** 
-	 * Constructor
-	 */
-	InventoryObjects(MADSEngine *vm): _vm(vm) {}
-
-	/**
-	 * Loads the game's object list
-	 */
-	void load();
-
-	/**
-	 * Set the associated data? pointer with an inventory object
-	 */
-	void setData(int objIndex, int id, const byte *p);
-
-	/**
-	 * Sets the room number
-	 */
-	void setRoom(int objectId, int roomNumber);
-};
-
 class SectionHandler {
 protected:
 	MADSEngine *_vm;
diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
index a3660df..d754c47 100644
--- a/engines/mads/hotspots.cpp
+++ b/engines/mads/hotspots.cpp
@@ -139,4 +139,10 @@ void DynamicHotspots::refresh() {
 	}
 }
 
+/*------------------------------------------------------------------------*/
+
+void Hotspots::activate(int hotspotId, bool active) {
+	warning("TODO: Hotspots::activate");
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/hotspots.h b/engines/mads/hotspots.h
index acbc72d..0dcde1d 100644
--- a/engines/mads/hotspots.h
+++ b/engines/mads/hotspots.h
@@ -82,6 +82,10 @@ public:
 	Hotspot(Common::SeekableReadStream &f);
 };
 
+class Hotspots : public Common::Array<Hotspot> {
+public:
+	void activate(int hotspotId, bool active);
+};
 
 } // End of namespace MADS
 
diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
new file mode 100644
index 0000000..89eaaad
--- /dev/null
+++ b/engines/mads/inventory.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/inventory.h"
+
+namespace MADS {
+
+void InventoryObject::load(Common::SeekableReadStream &f) {
+	_descId = f.readUint16LE();
+	_roomNumber = f.readUint16LE();
+	_article = f.readByte();
+	_vocabCount = f.readByte();
+	
+	for (int i = 0; i < 3; ++i) {
+		_vocabList[i]._actionFlags1 = f.readByte();
+		_vocabList[i]._actionFlags2 = f.readByte();
+		_vocabList[i]._vocabId = f.readUint16LE();
+	}
+
+	f.skip(4);	// field12
+	f.read(&_mutilateString[0], 10);
+	f.skip(16);
+}
+
+/*------------------------------------------------------------------------*/
+
+void InventoryObjects::load() {
+	File f("*OBJECTS.DAT");
+
+	// Get the total numer of inventory objects
+	int count = f.readUint16LE();
+	reserve(count);
+
+	// Read in each object
+	for (int i = 0; i < count; ++i) {
+		InventoryObject obj;
+		obj.load(f);
+		push_back(obj);
+
+		// If it's for the player's inventory, add the index to the inventory list
+		if (obj._roomNumber == PLAYER_INVENTORY) {
+			_inventoryList.push_back(i);
+			assert(_inventoryList.size() <= 32);
+		}
+	}
+}
+
+void InventoryObjects::setData(int objIndex, int id, const byte *p) {
+	// TODO: This whole method seems weird. Check it out more thoroughly once
+	// more of the engine is implemented
+	for (int i = 0; i < (int)size(); ++i) {
+		InventoryObject &obj = (*this)[i];
+		if (obj._vocabList[0]._actionFlags1 <= i)
+			break;
+
+		if (obj._mutilateString[6 + i] == id) {
+			(*this)[objIndex]._objFolder = p;
+		}
+	}
+}
+
+void InventoryObjects::setRoom(int objectId, int roomNumber) {
+	warning("TODO: setObjectRoom");
+}
+
+bool InventoryObjects::isInRoom(int objectId) const {
+	return (*this)[objectId]._roomNumber == _vm->_game->_scene._currentSceneId;
+}
+
+
+} // End of namespace MADS
diff --git a/engines/mads/inventory.h b/engines/mads/inventory.h
new file mode 100644
index 0000000..57ae43b
--- /dev/null
+++ b/engines/mads/inventory.h
@@ -0,0 +1,87 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_INVENTORY_H
+#define MADS_INVENTORY_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+
+namespace MADS {
+
+class MADSEngine;
+
+class InventoryObject {
+public:
+	int _descId;
+	int _roomNumber;
+	int _article;
+	int _vocabCount;
+	struct {
+		int _actionFlags1;
+		int _actionFlags2;
+		int _vocabId;
+	} _vocabList[3];
+	char _mutilateString[10];	// ???
+	const byte *_objFolder;		// ???
+
+	/**
+	 * Loads the data for a given object
+	 */
+	void load(Common::SeekableReadStream &f);
+};
+
+class InventoryObjects: public Common::Array<InventoryObject> {
+private:
+	MADSEngine *_vm;
+public:
+	Common::Array<int> _inventoryList;
+
+	/** 
+	 * Constructor
+	 */
+	InventoryObjects(MADSEngine *vm): _vm(vm) {}
+
+	/**
+	 * Loads the game's object list
+	 */
+	void load();
+
+	/**
+	 * Set the associated data? pointer with an inventory object
+	 */
+	void setData(int objIndex, int id, const byte *p);
+
+	/**
+	 * Sets the room number
+	 */
+	void setRoom(int objectId, int roomNumber);
+
+	/**
+	 * Returns true if a given object is in the player's current scene
+	 */
+	bool isInRoom(int objectId) const;
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_INVENTORY_H */
diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index 21463aa..a9ce093 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -283,6 +283,29 @@ void KernelMessages::delay(uint32 priorFrameTime, uint32 currentTime) {
 	}
 }
 
+void KernelMessages::setQuoted(int msgIndex, int numTicks, bool quoted) {
+	if (msgIndex >= 0) {
+		KernelMessage &msg = _entries[msgIndex];
+
+		msg._flags |= KMSG_SCROLL;
+		if (quoted)
+			msg._flags |= KMSG_QUOTED;
+
+		msg._msgOffset = 0;
+		msg._numTicks = numTicks;
+		msg._frameTimer2 = _vm->_game->_scene._frameStartTime;
+		msg._asciiChar = msg._msg[0];
+		msg._asciiChar2 = msg._msg[1];
+
+		if (msg._flags & KMSG_PLAYER_TIMEOUT) {
+			msg._frameTimer2 = _vm->_game->_player._priorTimer +
+				_vm->_game->_player._ticksAmount;
+		}
+
+		msg._frameTimer = msg._frameTimer2;
+	}
+}
+
 /*------------------------------------------------------------------------*/
 
 TextDisplay::TextDisplay() {
diff --git a/engines/mads/messages.h b/engines/mads/messages.h
index 340f33e..205cbf8 100644
--- a/engines/mads/messages.h
+++ b/engines/mads/messages.h
@@ -88,6 +88,7 @@ public:
 	void update();
 	void processText(int msgIndex);
 	void delay(uint32 priorFrameTime, uint32 currentTime);
+	void setQuoted(int msgIndex, int numTicks, bool quoted);
 };
 
 class TextDisplay {
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index a65519f..76d80bc 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -6,6 +6,7 @@ MODULE_OBJS := \
 	nebular/globals_nebular.o \
 	nebular/sound_nebular.o \
 	nebular/nebular_scenes.o \
+	nebular/nebular_scenes1.o \
 	nebular/nebular_scenes8.o \
 	action.o \
 	animation.o \
@@ -20,6 +21,7 @@ MODULE_OBJS := \
 	game_data.o \
 	hotspots.o \
 	interface.o \
+	inventory.o \
 	mads.o \
 	messages.o \
 	msurface.o \
diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp
index 37ebf5f..3c16cd1 100644
--- a/engines/mads/nebular/globals_nebular.cpp
+++ b/engines/mads/nebular/globals_nebular.cpp
@@ -34,8 +34,8 @@ Globals::Globals() {
 	_spriteIndexes.resize(30);
 
 	// Initialise game flags
-	_chairHotspotIndex = 0;
-	_v1 = 0;
+	_v0 = 0;
+	_frameTime = 0;
 	_v2 = 0;
 	_v3 = 0;
 	_v4 = 0;
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index 3134044..b2a1f0d 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -37,8 +37,8 @@ private:
 public:
 	Common::Array<int> _spriteIndexes;
 
-	int _chairHotspotIndex;
-	int _v1;
+	int _v0;
+	uint32 _frameTime;
 	int _v2;
 	int _v3;
 	int _v4;
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 3587822..6644d95 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -61,6 +61,40 @@ Common::String NebularScene::formAnimName(char sepChar, int suffixNum) {
 		EXT_NONE, "");
 }
 
+void NebularScene::setPlayerSpritesPrefix() {
+	_vm->_sound->command(5);
+	Common::String oldName = _game._player._spritesPrefix;
+	if (_scene->_nextSceneId <= 103 || _scene->_nextSceneId == 111) {
+		if (_globals[0] == SEX_FEMALE) {
+			_game._player._spritesPrefix = "ROX";
+		} else {
+			_game._player._spritesPrefix = "RXM";
+			_globals[0] = SEX_MALE;
+		}
+	} else if (_scene->_nextSceneId <= 110) {
+		_game._player._spritesPrefix = "RXSW";
+		_globals[0] = SEX_UNKNOWN;
+	} else if (_scene->_nextSceneId == 112) {
+		_game._player._spritesPrefix = "";
+	}
+
+	if (oldName == _game._player._spritesPrefix)
+		_game._player._spritesChanged = true;
+	if (_scene->_nextSceneId == 105 || (_scene->_nextSceneId == 109 && _globals[15])) {
+		_game._player._spritesChanged = true;
+		_game._v3 = 0;
+	}
+
+	_game._player._unk3 = 0;
+	_vm->_palette->setEntry(16, 10, 63, 63);
+	_vm->_palette->setEntry(17, 10, 45, 45);
+}
+
+void NebularScene::setAAName() {
+	int idx = (_scene->_nextSceneId > 103 && _scene->_nextSceneId < 112) ? 1 : 0;
+	_game._aaName = Resources::formatAAName(idx);
+}
+
 /*------------------------------------------------------------------------*/
 
 void SceneInfoNebular::loadCodes(MSurface &depthSurface) {
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 5ac708d..4da8b49 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -35,7 +35,7 @@ namespace MADS {
 namespace Nebular {
 
 enum {
-	SEX_MALE = 0, SEX_FEMALE = 2
+	SEX_MALE = 0, SEX_UNKNOWN = 1, SEX_FEMALE = 2
 };
 
 enum Noun {
@@ -103,6 +103,21 @@ protected:
 	 * Forms an animation resoucre name
 	 */
 	Common::String formAnimName(char sepChar, int suffixNum);
+
+	/**
+	 *Sets the AA file to use for the scene
+	 */
+	void setAAName();
+
+	/**
+	 * Updates the prefix used for getting player sprites for the scene
+	 */
+	void setPlayerSpritesPrefix();
+
+	/**
+	 * Plays appropriate sound for entering varous rooms
+	 */
+	void lowRoomsEntrySound();
 public:
 	/**
 	 * Constructor
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 1de4eca..d684f02 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -30,6 +30,41 @@ namespace MADS {
 
 namespace Nebular {
 
+void Scene1xx::sceneEntrySound() {
+	if (_vm->_musicFlag) {
+		switch (_scene->_nextSceneId) {
+		case 101:
+			_vm->_sound->command(11);
+			break;
+		case 102:
+			_vm->_sound->command(12);
+			break;
+		case 103:
+			_vm->_sound->command(3);
+			_vm->_sound->command(25);
+			break;
+		case 109:
+			_vm->_sound->command(13);
+			break;
+		case 110:
+			_vm->_sound->command(10);
+			break;
+		case 111:
+			_vm->_sound->command(3);
+			break;
+		case 112:
+			_vm->_sound->command(15);
+			break;
+		default:
+			if (_scene->_priorSceneId < 104 || _scene->_priorSceneId > 108)
+				_vm->_sound->command(10);
+			break;
+		}
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene101::setup() {
 }
 
@@ -48,6 +83,113 @@ void Scene101::actions() {
 void Scene101::postActions() {
 }
 
+/*------------------------------------------------------------------------*/
+
+void Scene103::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene103::enter() {
+	_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 2));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 3));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 4));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('x', 5));
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('b', -1));
+	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('h', -1));
+	_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('m', -1));
+	_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('t', -1));
+	_globals._spriteIndexes[10] = _scene->_sprites.addSprites(formAnimName('r', -1));
+	_globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('c', -1));
+
+	_globals._spriteIndexes[12] = _scene->_sprites.addSprites("*RXMBD_2");
+	_globals._spriteIndexes[13] = _scene->_sprites.addSprites("*RXMRD_3");
+	_globals._spriteIndexes[15] = _scene->_sequences.addSpriteCycle(
+		_globals._spriteIndexes[0], false, 7, 0, 1, 0);
+	_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(
+		_globals._spriteIndexes[1], false, 6, 0, 2, 0);
+	_scene->_sequences.setDepth(_globals._spriteIndexes[16], 0);
+	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(
+		_globals._spriteIndexes[2], false, 6, 0, 0, 25);	
+	_globals._spriteIndexes[18] = _scene->_sequences.addSubEntry(
+		_globals._spriteIndexes[17], SM_FRAME_INDEX, 2, 72);
+	_globals._spriteIndexes[19] = _scene->_sequences.addSubEntry(
+		_globals._spriteIndexes[17], SM_FRAME_INDEX, 2, 72);
+	int idx = _scene->_sequences.addSubEntry(_globals._spriteIndexes[17],
+		SM_FRAME_INDEX, 2, 73);
+
+	_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(
+		_globals._spriteIndexes[8], false, 8);
+	_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(
+		_globals._spriteIndexes[7], false, 6);
+	_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(
+		_globals._spriteIndexes[4], false, 6);
+	_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(
+		_globals._spriteIndexes[5], false, 6);
+
+	if (_game._objects.isInRoom(OBJ_TIMER_MODULE)) {
+		_vm->_game->_scene._hotspots.activate(371, false);
+	} else {
+		_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(
+			_globals._spriteIndexes[11], false, 6);
+	}
+
+	if (_game._objects.isInRoom(OBJ_REBREATHER)) {
+		_vm->_game->_scene._hotspots.activate(289, false);
+	} else {
+		_globals._spriteIndexes[25] = _scene->_sequences.addSpriteCycle(
+			_globals._spriteIndexes[10], false, 6);
+	}
+	
+	if (_globals[11]) {
+		_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(
+			_globals._spriteIndexes[9], false, 6);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[24], -2, -2);
+		_scene->_hotspots.activate(362, false);
+	}
+
+	if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(237, 74);
+	if (_scene->_priorSceneId == 102) {
+		_game._player._stepEnabled = false;
+
+		_globals._spriteIndexes[21] = _scene->_sequences.addReverseSpriteCycle(
+			_globals._spriteIndexes[6], false, 6, 1, 0, 0);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 70);
+	}
+
+	sceneEntrySound();
+	_vm->_game->loadQuoteSet(70, 51, 71, 7, 73, 0);
+
+	if (!_game._visitedScenes._sceneRevisited) {
+		int msgIndex = _scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 
+			34, 0, 120, _game.getQuote(70));
+		_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+	}
+
+	if (_scene->_priorSceneId == 102)
+		_vm->_sound->command(20);
+
+	_vm->_palette->setEntry(252, 63, 63, 10);
+	_vm->_palette->setEntry(253, 45, 45, 10);
+	_globals._v0 = 0;
+	_globals._frameTime = _scene->_frameStartTime;
+}
+
+void Scene103::step() {
+}
+
+void Scene103::preActions() {
+}
+
+void Scene103::actions() {
+}
+
+void Scene103::postActions() {
+}
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index da6a2f0..6077e1e 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -32,9 +32,36 @@ namespace MADS {
 
 namespace Nebular {
 
-class Scene101: public NebularScene {
+class Scene1xx : protected NebularScene {
+protected:
+	/**
+	 * Plays an appropriate sound when entering a scene
+	 */
+	void sceneEntrySound();
 public:
-	Scene101(MADSEngine *vm) : NebularScene(vm) {}
+	Scene1xx(MADSEngine *vm) : NebularScene(vm) {}
+};
+
+class Scene101: public Scene1xx {
+public:
+	Scene101(MADSEngine *vm) : Scene1xx(vm) {}
+
+	virtual void setup();
+
+	virtual void enter();
+
+	virtual void step();
+
+	virtual void preActions();
+
+	virtual void actions();
+
+	virtual void postActions();
+};
+
+class Scene103 : public Scene1xx {
+public:
+	Scene103(MADSEngine *vm) : Scene1xx(vm) {}
 
 	virtual void setup();
 
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 2d12366..7bc1af9 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -80,11 +80,13 @@ void Scene804::setup() {
 }
 
 void Scene804::enter() {
-	_globals._chairHotspotIndex = 0;
-	_globals._v1 = _globals._v2 = 0;
-	_globals._v3 = _globals._v4 = 0;
+	_globals._frameTime = 0;
+	_globals._v2 = 0;
+	_globals._v3 = 0;
+	_globals._v4 = 0;
 	_globals._v5 = -1;
-	_globals._v6 = _globals._v7 = 0;
+	_globals._v6 = 0;
+	_globals._v7 = 0;
 	_globals._v8 = 0;
 	if (_globals[5]) {
 		// Copy protection failed
@@ -92,43 +94,43 @@ void Scene804::enter() {
 		_globals[164] = 0;
 	}
 
-	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 0));
-	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 1));
-	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('x', 2));
-	_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('x', 3));
-	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('x', 4));
-	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('f', 1));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('x', 1));
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('x', 2));
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 3));
+	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('x', 4));
+	_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('f', 1));
 
 	_game.loadQuoteSet(791, 0);
 
 	if (_globals[165]) {
 		if (_globals[164]) {
-			_globals._spriteIndexes[19] = _scene->_sequences.startCycle(
-				_globals._spriteIndexes[4], 0, 1);
+			_globals._spriteIndexes[20] = _scene->_sequences.startCycle(
+				_globals._spriteIndexes[5], 0, 1);
 			_scene->_sequences.addTimer(60, 100);
 		} else {
-			_globals._spriteIndexes[20] = _scene->_sequences.startCycle(
-				_globals._spriteIndexes[5], false, 1);
-			_globals._spriteIndexes[21] = _scene->_sequences.startReverseCycle(
-				_globals._spriteIndexes[6], false, 4, 0, 0, 0);
+			_globals._spriteIndexes[21] = _scene->_sequences.startCycle(
+				_globals._spriteIndexes[6], false, 1);
+			_globals._spriteIndexes[22] = _scene->_sequences.startReverseCycle(
+				_globals._spriteIndexes[7], false, 4, 0, 0, 0);
 			_scene->_sequences.addTimer(160, 70);
 			_game._player._stepEnabled = false;
 		}
 	} else {
 		if (_globals[167] == 0) {
-			_globals._spriteIndexes[22] = _scene->_sequences.startCycle(
-				_globals._spriteIndexes[7], false, 1);
+			_globals._spriteIndexes[23] = _scene->_sequences.startCycle(
+				_globals._spriteIndexes[8], false, 1);
 		}
 
 		if (_globals[164] == 0) {
-			_globals._spriteIndexes[22] = _scene->_sequences.startCycle(
-				_globals._spriteIndexes[18], false, 1);
+			_globals._spriteIndexes[23] = _scene->_sequences.startCycle(
+				_globals._spriteIndexes[19], false, 1);
 		}
 
-		_globals._spriteIndexes[0] = _scene->_sequences.startCycle(
-			_globals._spriteIndexes[0], false, 1);
-		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[15], Common::Point(133, 139));
-		_scene->_sequences.setDepth(_globals._spriteIndexes[15], 8);
+		_globals._spriteIndexes[1] = _scene->_sequences.startCycle(
+			_globals._spriteIndexes[1], false, 1);
+		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[16], Common::Point(133, 139));
+		_scene->_sequences.setDepth(_globals._spriteIndexes[16], 8);
 	}
 
 	_scene->loadAnimation(Resources::formatName(804, 'r', 1, EXT_AA, ""));
@@ -142,24 +144,23 @@ void Scene804::enter() {
 }
 
 void Scene804::step() {
-	if (_globals._chairHotspotIndex) {
+	if (_globals._frameTime) {
 		if (_scene->_activeAnimation->getCurrentFrame() == 36 && !_globals._v3) {
-			_scene->_sequences.remove(_globals._spriteIndexes[15]);
+			_scene->_sequences.remove(_globals._spriteIndexes[16]);
 			_globals._v3 = -1;
 		}
 		if (_scene->_activeAnimation->getCurrentFrame() == 39) {
 			_globals._v2 = 0;
-			if (_globals._v1 == 3)
+			if ((_globals._frameTime / 256) == 3)
 				_scene->_sequences.addTimer(130, 120);
 		}
 
 		if (!_globals._v2) {
-			++_globals._v1;
+			_globals._frameTime += 0x100;
 			_globals._v2 = -1;
 
-			if (_globals._v1 >= 4) {
-				_globals._chairHotspotIndex = 0;
-				_globals._v1 = 0;
+			if ((_globals._frameTime / 256) >= 4) {
+				_globals._frameTime = 0;
 				_game._player._stepEnabled = true;
 			} else {
 				_globals._v5 = 34;
@@ -167,11 +168,11 @@ void Scene804::step() {
 		}
 	} else {
 		if (_globals._v3 && _globals._v2 && _scene->_activeAnimation->getCurrentFrame() == 39) {
-			_globals._spriteIndexes[15] = _scene->_sequences.startCycle(
-				_globals._spriteIndexes[0], false, 1);
-			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[15],
+			_globals._spriteIndexes[16] = _scene->_sequences.startCycle(
+				_globals._spriteIndexes[1], false, 1);
+			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[16],
 				Common::Point(133, 139));
-			_scene->_sequences.setDepth(_globals._spriteIndexes[15], 8);
+			_scene->_sequences.setDepth(_globals._spriteIndexes[16], 8);
 			_globals._v3 = 0;
 		}
 
@@ -183,7 +184,7 @@ void Scene804::step() {
 		if (_game._abortTimers == 70)
 			_globals._v5 = 42;
 		if (_scene->_activeAnimation->getCurrentFrame() == 65)
-			_scene->_sequences.remove(_globals._spriteIndexes[21]);
+			_scene->_sequences.remove(_globals._spriteIndexes[22]);
 
 		switch (_game._storyMode)  {
 		case STORYMODE_NAUGHTY:
@@ -213,7 +214,7 @@ void Scene804::step() {
 
 		if (_scene->_activeAnimation->getCurrentFrame() == 34) {
 			_globals._v5 = 36;
-			_scene->_sequences.remove(_globals._spriteIndexes[15]);
+			_scene->_sequences.remove(_globals._spriteIndexes[16]);
 		}
 		if (_scene->_activeAnimation->getCurrentFrame() == 37) {
 			_globals._v5 = 36;
@@ -225,7 +226,7 @@ void Scene804::step() {
 			_scene->_nextSceneId = 803;
 
 		if (_scene->_activeAnimation->getCurrentFrame() == 7 && !_globals[164]) {
-			_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+			_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 			_scene->_sequences.addTimer(20, 110);
 			_globals[164] = -1;
 		}
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 8f803d1..d7301bb 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -386,9 +386,9 @@ void Palette::setPalette(const byte *colors, uint start, uint num) {
 }
 
 void Palette::setEntry(byte palIndex, byte r, byte g, byte b) {
-	_mainPalette[palIndex * 3] = r;
-	_mainPalette[palIndex * 3 + 1] = g;
-	_mainPalette[palIndex * 3 + 2] = b;
+	_mainPalette[palIndex * 3] = VGA_COLOR_TRANS(r);
+	_mainPalette[palIndex * 3 + 1] = VGA_COLOR_TRANS(g);
+	_mainPalette[palIndex * 3 + 2] = VGA_COLOR_TRANS(b);
 
 	setPalette((const byte *)&_mainPalette[palIndex * 3], palIndex, 1);
 }
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 0b20fb0..f96cb59 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -93,7 +93,7 @@ public:
 	KernelMessages _kernelMessages;
 	Common::String _talkFont;
 	int _textSpacing;
-	Common::Array<Hotspot> _hotspots;
+	Hotspots _hotspots;
 	ScreenObjects _screenObjects;
 	ImageInterEntries _imageInterEntries;
 	DirtyAreas _dirtyAreas;
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 1b4f8a9..6418a03 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -412,6 +412,21 @@ int SequenceList::addSpriteCycle(int srcSpriteIdx, bool flipped, int numTicks, i
 		true, 100, depth - 1, 1, ANIMTYPE_CYCLED, 0, 0);
 }
 
+int SequenceList::addReverseSpriteCycle(int srcSpriteIdx, bool flipped, int numTicks,
+		int triggerCountdown, int timeoutTicks, int extraTicks) {
+	Scene &scene = _vm->_game->_scene;
+
+	SpriteAsset *asset = scene._sprites[srcSpriteIdx];
+	MSprite *spriteFrame = asset->getFrame(0);
+	int depth = scene._depthSurface.getDepth(Common::Point(
+		spriteFrame->_offset.x + (spriteFrame->w / 2),
+		spriteFrame->_offset.y + (spriteFrame->h / 2)));
+
+	return add(srcSpriteIdx, flipped, asset->getCount(), triggerCountdown, timeoutTicks, extraTicks, 
+		numTicks, 0, 0, true, 100, depth - 1, -1, ANIMTYPE_CYCLED, 0, 0);
+}
+
+
 int SequenceList::startCycle(int srcSpriteIndex, bool flipped, int cycleIndex) {
 	int result = addSpriteCycle(srcSpriteIndex, flipped, INDEFINITE_TIMEOUT, 0, 0, 0);
 	if (result >= 0)
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index 85e4f66..a62ad7e 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -93,6 +93,7 @@ public:
 	int add(int spriteListIndex, bool flipped, int frameIndex, int triggerCountdown, int delayTicks,
 		int extraTicks, int numTicks, int msgX, int msgY, bool nonFixed, char scale, uint8 depth,
 		int frameInc, SpriteAnimType animType, int numSprites, int frameStart);
+	
 	int addTimer(int time, int abortVal);
 	void remove(int seqIndex);
 	void setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot);
@@ -103,7 +104,11 @@ public:
 	void scan();
 	void setDepth(int seqIndex, int depth);
 	void setMsgPosition(int seqIndex, const Common::Point &pt);
-	int addSpriteCycle(int srcSpriteIdx, bool flipped, int numTicks, int triggerCountdown, int timeoutTicks, int extraTicks);
+	int addSpriteCycle(int srcSpriteIdx, bool flipped, int numTicks, 
+		int triggerCountdown = 0, int timeoutTicks = 0, int extraTicks = 0);
+	int addReverseSpriteCycle(int srcSpriteIdx, bool flipped, int numTicks,
+		int triggerCountdown = 0, int timeoutTicks = 0, int extraTicks = 0);
+
 	int startCycle(int srcSpriteIdx, bool flipped, int cycleIndex);
 	int startReverseCycle(int srcSpriteIndex, bool flipped, int numTicks, int triggerCountdown, 
 		int timeoutTicks, int extraTicks);


Commit: b652e2eafd3de5436b45619659b5299d945074be
    https://github.com/scummvm/scummvm/commit/b652e2eafd3de5436b45619659b5299d945074be
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-15T18:43:39-04:00

Commit Message:
MADS: Merged the InterfaceSurface and UserInterface classes

Changed paths:
  R engines/mads/interface.cpp
  R engines/mads/interface.h
    engines/mads/animation.cpp
    engines/mads/animation.h
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/module.mk
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 09a9e1f..783611e 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -172,9 +172,9 @@ void Animation::free() {
 	delete this;
 }
 
-void Animation::load(MSurface &depthSurface, InterfaceSurface &interfaceSurface,
-	const Common::String &resName, int flags, Common::Array<RGB4> *palAnimData,
-	SceneInfo *sceneInfo) {
+void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
+		const Common::String &resName, int flags, Common::Array<RGB4> *palAnimData,
+		SceneInfo *sceneInfo) {
 	Common::String resourceName = resName;
 	if (!resourceName.contains("."))
 		resourceName += ".AA";
@@ -352,7 +352,7 @@ bool Animation::drawFrame(SpriteAsset &spriteSet, const Common::Point &pt, int f
 	return 0;
 }
 
-void Animation::loadInterface(InterfaceSurface &interfaceSurface, MSurface &depthSurface,
+void Animation::loadInterface(UserInterface &interfaceSurface, MSurface &depthSurface,
 		AAHeader &header, int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo) {
 	_scene->_depthStyle = 0;
 	if (header._animMode <= 2) {
@@ -363,8 +363,7 @@ void Animation::loadInterface(InterfaceSurface &interfaceSurface, MSurface &dept
 			for (uint i = 0; i < sceneInfo->_palAnimData.size(); ++i)
 				palAnimData->push_back(sceneInfo->_palAnimData[i]);
 		}
-	}
-	else if (header._animMode == 4) {
+	} else if (header._animMode == 4) {
 		// Load a scene interface
 		Common::String resourceName = "*" + header._interfaceFile;
 		interfaceSurface.load(resourceName);
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index c5308b7..dd902b8 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -29,7 +29,7 @@
 #include "mads/msurface.h"
 #include "mads/scene_data.h"
 #include "mads/font.h"
-#include "mads/interface.h"
+#include "mads/user_interface.h"
 
 namespace MADS {
 
@@ -144,7 +144,7 @@ private:
 	/**
 	 * Load the user interface display for an animation
 	 */
-	void loadInterface(InterfaceSurface &interfaceSurface, MSurface &depthSurface,
+	void loadInterface(UserInterface &interfaceSurface, MSurface &depthSurface,
 		AAHeader &header, int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo);
 
 	/**
@@ -169,7 +169,7 @@ public:
 	/**
 	 * Loads animation data
 	 */
-	void load(MSurface &depthSurface, InterfaceSurface &interfaceSurface, const Common::String &resName,
+	void load(UserInterface &interfaceSurface, MSurface &depthSurface, const Common::String &resName,
 		int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo);
 
 	/**
diff --git a/engines/mads/interface.cpp b/engines/mads/interface.cpp
deleted file mode 100644
index 8ea8913..0000000
--- a/engines/mads/interface.cpp
+++ /dev/null
@@ -1,132 +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/scummsys.h"
-#include "mads/mads.h"
-#include "mads/compression.h"
-#include "mads/interface.h"
-
-namespace MADS {
-
-void SceneNode::load(Common::SeekableReadStream *f) {
-	_walkPos.x = f->readSint16LE();
-	_walkPos.y = f->readSint16LE();
-	for (int i = 0; i < MAX_ROUTE_NODES; ++i)
-		_indexes[i] = f->readUint16LE();
-}
-
-/*------------------------------------------------------------------------*/
-
-InterfaceSurface::InterfaceSurface(MADSEngine *vm) : _vm(vm) {
-	_category = CAT_NONE;
-	_screenObjectsCount = 0;
-}
-
-
-void InterfaceSurface::load(const Common::String &resName) {
-	File f(resName);
-	MadsPack madsPack(&f);
-
-	// Load in the palette
-	Common::SeekableReadStream *palStream = madsPack.getItemStream(0);
-
-	uint32 *gamePalP = &_vm->_palette->_palFlags[0];
-	byte *palP = &_vm->_palette->_mainPalette[0];
-
-	for (int i = 0; i < 16; ++i, gamePalP++, palP += 3) {
-		palP[0] = VGA_COLOR_TRANS(palStream->readByte());
-		palP[1] = VGA_COLOR_TRANS(palStream->readByte());
-		palP[2] = VGA_COLOR_TRANS(palStream->readByte());
-		*gamePalP |= 1;
-		palStream->skip(3);
-	}
-	delete palStream;
-
-	// set the size for the interface
-	setSize(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
-	Common::SeekableReadStream *pixelsStream = madsPack.getItemStream(1);
-	pixelsStream->read(getData(), MADS_SCREEN_WIDTH * MADS_INTERFACE_HEIGHT);
-	delete pixelsStream;
-}
-
-void InterfaceSurface::setup(int id) {
-	Scene &scene = _vm->_game->_scene;
-
-	if (scene._screenObjects._v832EC != id) {
-		Common::String resName = _vm->_game->_aaName;
-
-		// Strip off any extension
-		const char *p = strchr(resName.c_str(), '.');
-		if (p) {
-			resName = Common::String(resName.c_str(), p);
-		}
-
-		// Add on suffix if necessary
-		if (id)
-			resName += "A";
-
-		resName += ".INT";
-		free();
-		load(resName);
-	}
-	scene._screenObjects._v832EC = id;
-
-	scene._imageInterEntries.clear();
-	scene._imageInterEntries.add(-2, 0xff);
-	_vm->_game->_ticksExpiry = _vm->_events->getFrameCounter();
-	scene._v1A = true;
-	_vm->_game->_objectHiliteVocabIdx = -1;
-	scene._v1C = -1;
-
-	// Make a copy of the surface
-	copyTo(&_surface);
-
-	if (_vm->_game->_v1 == 5)
-		scene._imageInterEntries.call(0, 0);
-
-	scene._action.clear();
-	writeText();
-	loadElements();
-	scene._dynamicHotspots.refresh();
-}
-
-void InterfaceSurface::elementHighlighted() {
-	warning("TODO: InterfaceSurface::elementHighlighted");
-}
-
-void InterfaceSurface::writeText() {
-	warning("TODO: InterfaceSurface::writeText");
-}
-
-
-void InterfaceSurface::setBounds(const Common::Rect &r) {
-	_bounds = r;
-}
-
-void InterfaceSurface::loadElements() {
-	warning("TODO: InterfaceSurface::loadElements");
-}
-
-/*------------------------------------------------------------------------*/
-
-
-} // End of namespace MADS
diff --git a/engines/mads/interface.h b/engines/mads/interface.h
deleted file mode 100644
index 0d7860b..0000000
--- a/engines/mads/interface.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 MADS_INTERFACE_H
-#define MADS_INTERFACE_H
-
-#include "common/scummsys.h"
-#include "common/rect.h"
-#include "common/str.h"
-#include "mads/msurface.h"
-
-namespace MADS {
-
-class InterfaceSurface : public MSurface {
-private:
-	MADSEngine *_vm;
-
-	void loadElements();
-public:
-	ScrCategory _category;
-	int _screenObjectsCount;
-	Common::Rect _bounds;
-	Common::Rect *_rectP;
-	MSurface _surface;
-public:
-	/**
-	* Constructor
-	*/
-	InterfaceSurface(MADSEngine *vm);
-
-	/**
-	* Loads an interface from a specified resource
-	*/
-	void load(const Common::String &resName);
-
-	/**
-	 * Set up the interface
-	 */
-	void setup(int id);
-
-	void elementHighlighted();
-
-	void writeText();
-
-	void setBounds(const Common::Rect &r);
-};
-
-} // End of namespace MADS
-
-#endif /* MADS_INTERFACE_H */
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 9cab1ad..ded9487 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -52,7 +52,6 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :
 	_palette = nullptr;
 	_resources = nullptr;
 	_sound = nullptr;
-	_userInterface = nullptr;
 }
 
 MADSEngine::~MADSEngine() {
@@ -64,7 +63,6 @@ MADSEngine::~MADSEngine() {
 	delete _palette;
 	delete _resources;
 	delete _sound;
-	delete _userInterface;
 }
 
 void MADSEngine::initialise() {
@@ -85,7 +83,6 @@ void MADSEngine::initialise() {
 	_font = new Font(this);
 	_screen.init();
 	_sound = new SoundManager(this, _mixer);
-	_userInterface = UserInterface::init(this);
 	_game = Game::init(this);
 
 	_screen.empty();
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index 749c69a..10f4bad 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -100,7 +100,6 @@ public:
 	Resources *_resources;
 	ScreenSurface _screen;
 	SoundManager *_sound;
-	UserInterface *_userInterface;
 	bool _easyMouse;
 	bool _invObjectStill;
 	bool _textWindowStill;
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 76d80bc..74376dc 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -20,7 +20,6 @@ MODULE_OBJS := \
 	game.o \
 	game_data.o \
 	hotspots.o \
-	interface.o \
 	inventory.o \
 	mads.o \
 	messages.o \
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index d684f02..cdc7547 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -117,7 +117,7 @@ void Scene103::enter() {
 		_globals._spriteIndexes[17], SM_FRAME_INDEX, 2, 72);
 	_globals._spriteIndexes[19] = _scene->_sequences.addSubEntry(
 		_globals._spriteIndexes[17], SM_FRAME_INDEX, 2, 72);
-	int idx = _scene->_sequences.addSubEntry(_globals._spriteIndexes[17],
+	_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], 
 		SM_FRAME_INDEX, 2, 73);
 
 	_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 7bc1af9..2aa65d9 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -138,7 +138,7 @@ void Scene804::enter() {
 	Scene8xx::enter1();
 
 	if (_globals[165] && !_globals[164]) {
-		_scene->_interface.setup(2);
+		_scene->_userInterface.setup(2);
 		_vm->_sound->command(19);
 	}
 }
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 8bf0b6a..d1e83f6 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -29,9 +29,9 @@
 namespace MADS {
 
 Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
-		_dirtyAreas(_vm),  _dynamicHotspots(vm), _interface(vm), 
-		_kernelMessages(vm), _screenObjects(vm), _sequences(vm), 
-		_sprites(vm), _spriteSlots(vm), _textDisplay(vm) {
+		_dirtyAreas(_vm),  _dynamicHotspots(vm), _kernelMessages(vm), 
+		_screenObjects(vm), _sequences(vm), _sprites(vm), _spriteSlots(vm), 
+		_textDisplay(vm), _userInterface(vm) {
 	_priorSceneId = 0;
 	_nextSceneId = 0;
 	_currentSceneId = 0;
@@ -159,8 +159,8 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 		flags |= 0x200;
 
 	_animationData = Animation::init(_vm, this);
-	MSurface surface;
-	_animationData->load(surface, _interface, prefix, flags, nullptr, nullptr);
+	UserInterface surface(_vm);
+	_animationData->load(surface, _userInterface, prefix, flags, nullptr, nullptr);
 	
 	_vm->_palette->_paletteUsage.load(0);
 
@@ -171,7 +171,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	_interfaceY = MADS_SCENE_HEIGHT;
 	_spritesCount = _sprites.size();
 
-	_interface.setup(_screenObjects._v832EC);
+	_userInterface.setup(_screenObjects._v832EC);
 
 	warning("TODO: showMouse");
 
@@ -341,7 +341,7 @@ void Scene::doFrame() {
 			CursorType cursorId = CURSOR_ARROW;
 			if (_action._v83338 == 1 && !_screenObjects._v7FECA &&
 					_screenObjects._category == CAT_HOTSPOT) {
-				int idx = _screenObjects._selectedObject - _interface._screenObjectsCount;
+				int idx = _screenObjects._selectedObject - _userInterface._screenObjectsCount;
 				if (idx >= (int)_hotspots.size()) {
 					idx -= _hotspots.size();
 					_vm->_events->_newCursorId = _dynamicHotspots[idx]._cursor;
@@ -392,7 +392,7 @@ void Scene::doFrame() {
 
 			// Write any text needed by the interface
 			if (_vm->_game->_abortTimers2)
-				_interface.writeText();
+				_userInterface.writeText();
 
 			// Draw any elements
 			drawElements((ScreenTransition)_vm->_game->_abortTimers2, _vm->_game->_abortTimers2);
@@ -454,7 +454,7 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
 
 	//
 	_vm->_screen.setPointer(&_vm->_screen);
-	_interface.setBounds(Common::Rect(_vm->_screen._offset.x, _vm->_screen._offset.y,
+	_userInterface.setBounds(Common::Rect(_vm->_screen._offset.x, _vm->_screen._offset.y,
 		_vm->_screen._offset.x + _vm->_screen.w, _vm->_screen._offset.y + _vm->_screen.h));
 
 	if (transitionType) {
@@ -500,11 +500,11 @@ void Scene::checkKeyboard() {
 
 void Scene::loadAnimation(const Common::String &resName, int abortTimers) {
 	assert(_activeAnimation == nullptr);
-	MSurface sceneSurface;
-	InterfaceSurface interfaceSurface(_vm);
+	MSurface depthSurface;
+	UserInterface interfaceSurface(_vm);
 
 	_activeAnimation = Animation::init(_vm, this);
-	_activeAnimation->load(sceneSurface, interfaceSurface, resName, 
+	_activeAnimation->load(interfaceSurface, depthSurface, resName, 
 		_vm->_game->_v2 ? 1 : 0, nullptr, nullptr);
 	_activeAnimation->startAnimation(abortTimers);
 }
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index f96cb59..292eb4a 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -35,6 +35,7 @@
 #include "mads/animation.h"
 #include "mads/sequence.h"
 #include "mads/sprites.h"
+#include "mads/user_interface.h"
 
 namespace MADS {
 
@@ -101,7 +102,7 @@ public:
 	SceneInfo *_sceneInfo;
 	MSurface _backgroundSurface;
 	DepthSurface _depthSurface;
-	InterfaceSurface _interface;
+	UserInterface _userInterface;
 	bool _animFlag;
 	int _animVal1;
 	int _animCount;
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index de053a6..94bbb7b 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -77,34 +77,34 @@ void ScreenObjects::check(bool scanFlag) {
 		}
 
 		// Handling for easy mouse
-		ScrCategory category = scene._interface._category;
+		ScrCategory category = scene._userInterface._category;
 		if (_vm->_easyMouse && !_vm->_events->_vD4 && category != _category
-				&& scene._interface._category != CAT_NONE) {
+				&& scene._userInterface._category != CAT_NONE) {
 			_released = true;
 			if (category >= CAT_ACTION && category <= CAT_6) {
-				scene._interface.elementHighlighted();
+				scene._userInterface.elementHighlighted();
 			} 
 		}
 
 		_released = _vm->_events->_mouseReleased;
 		if (_vm->_events->_vD2 || (_vm->_easyMouse && !_vm->_events->_vD4))
-			scene._interface._category = _category;
+			scene._userInterface._category = _category;
 
 		if (!_vm->_events->_mouseButtons || _vm->_easyMouse) {
 			if (category >= CAT_ACTION && category <= CAT_6) {
-				scene._interface.elementHighlighted();
+				scene._userInterface.elementHighlighted();
 			}
 		}
 
 		if (_vm->_events->_mouseButtons || (_vm->_easyMouse && scene._action._v83338 > 1
-				&& scene._interface._category == CAT_INV_LIST) ||
-				(_vm->_easyMouse && scene._interface._category == CAT_HOTSPOT)) {
+				&& scene._userInterface._category == CAT_INV_LIST) ||
+				(_vm->_easyMouse && scene._userInterface._category == CAT_HOTSPOT)) {
 			scene._action.checkActionAtMousePos();
 		}
 			
 		if (_vm->_events->_mouseReleased) {
 			scene.leftClick();
-			scene._interface._category = CAT_NONE;
+			scene._userInterface._category = CAT_NONE;
 		}
 
 		if (_vm->_events->_mouseButtons || _vm->_easyMouse || _yp)
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index ec5ca8a..6afbf4c 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -22,22 +22,107 @@
 
 #include "common/scummsys.h"
 #include "mads/mads.h"
-#include "mads/screen.h"
+#include "mads/compression.h"
 #include "mads/user_interface.h"
-#include "mads/msurface.h"
 
 namespace MADS {
 
-UserInterface *UserInterface::init(MADSEngine *vm) {
-	return new UserInterface(vm);
+void SceneNode::load(Common::SeekableReadStream *f) {
+	_walkPos.x = f->readSint16LE();
+	_walkPos.y = f->readSint16LE();
+	for (int i = 0; i < MAX_ROUTE_NODES; ++i)
+		_indexes[i] = f->readUint16LE();
 }
 
-UserInterface::UserInterface(MADSEngine *vm): _vm(vm), _surface(
-	new MSurface(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT)) {
+/*------------------------------------------------------------------------*/
+
+UserInterface::UserInterface(MADSEngine *vm) : _vm(vm) {
+	_category = CAT_NONE;
+	_screenObjectsCount = 0;
+}
+
+void UserInterface::load(const Common::String &resName) {
+	File f(resName);
+	MadsPack madsPack(&f);
+
+	// Load in the palette
+	Common::SeekableReadStream *palStream = madsPack.getItemStream(0);
+
+	uint32 *gamePalP = &_vm->_palette->_palFlags[0];
+	byte *palP = &_vm->_palette->_mainPalette[0];
+
+	for (int i = 0; i < 16; ++i, gamePalP++, palP += 3) {
+		palP[0] = VGA_COLOR_TRANS(palStream->readByte());
+		palP[1] = VGA_COLOR_TRANS(palStream->readByte());
+		palP[2] = VGA_COLOR_TRANS(palStream->readByte());
+		*gamePalP |= 1;
+		palStream->skip(3);
+	}
+	delete palStream;
+
+	// set the size for the interface
+	setSize(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
+	Common::SeekableReadStream *pixelsStream = madsPack.getItemStream(1);
+	pixelsStream->read(getData(), MADS_SCREEN_WIDTH * MADS_INTERFACE_HEIGHT);
+	delete pixelsStream;
+}
+
+void UserInterface::setup(int id) {
+	Scene &scene = _vm->_game->_scene;
+
+	if (scene._screenObjects._v832EC != id) {
+		Common::String resName = _vm->_game->_aaName;
+
+		// Strip off any extension
+		const char *p = strchr(resName.c_str(), '.');
+		if (p) {
+			resName = Common::String(resName.c_str(), p);
+		}
+
+		// Add on suffix if necessary
+		if (id)
+			resName += "A";
+
+		resName += ".INT";
+		free();
+		load(resName);
+	}
+	scene._screenObjects._v832EC = id;
+
+	scene._imageInterEntries.clear();
+	scene._imageInterEntries.add(-2, 0xff);
+	_vm->_game->_ticksExpiry = _vm->_events->getFrameCounter();
+	scene._v1A = true;
+	_vm->_game->_objectHiliteVocabIdx = -1;
+	scene._v1C = -1;
+
+	// Make a copy of the surface
+	copyTo(&_surface);
+
+	if (_vm->_game->_v1 == 5)
+		scene._imageInterEntries.call(0, 0);
+
+	scene._action.clear();
+	writeText();
+	loadElements();
+	scene._dynamicHotspots.refresh();
+}
+
+void UserInterface::elementHighlighted() {
+	warning("TODO: UserInterface::elementHighlighted");
+}
+
+void UserInterface::writeText() {
+	warning("TODO: UserInterface::writeText");
+}
+
+
+void UserInterface::setBounds(const Common::Rect &r) {
+	_bounds = r;
 }
 
-UserInterface::~UserInterface() {
-	delete _surface;
+void UserInterface::loadElements() {
+	warning("TODO: UserInterface::loadElements");
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 838638b..8bd02ff 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -24,21 +24,44 @@
 #define MADS_USER_INTERFACE_H
 
 #include "common/scummsys.h"
+#include "common/rect.h"
+#include "common/str.h"
+#include "mads/msurface.h"
 
 namespace MADS {
 
-class MADSEngine;
-
-class UserInterface {
+class UserInterface : public MSurface {
 private:
 	MADSEngine *_vm;
-	MSurface *_surface;
 
-	UserInterface(MADSEngine *vm);
+	void loadElements();
 public:
-	static UserInterface *init(MADSEngine *vm);
+	ScrCategory _category;
+	int _screenObjectsCount;
+	Common::Rect _bounds;
+	Common::Rect *_rectP;
+	MSurface _surface;
 public:
-	~UserInterface();
+	/**
+	* Constructor
+	*/
+	UserInterface(MADSEngine *vm);
+
+	/**
+	* Loads an interface from a specified resource
+	*/
+	void load(const Common::String &resName);
+
+	/**
+	* Set up the interface
+	*/
+	void setup(int id);
+
+	void elementHighlighted();
+
+	void writeText();
+
+	void setBounds(const Common::Rect &r);
 };
 
 } // End of namespace MADS


Commit: ca6cf0eaf2692ac5c787b86e193e8e6980d2b7ee
    https://github.com/scummvm/scummvm/commit/ca6cf0eaf2692ac5c787b86e193e8e6980d2b7ee
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-15T18:52:44-04:00

Commit Message:
MADS: Fix display of user interface during animation

Changed paths:
    engines/mads/mads.h
    engines/mads/msurface.cpp
    engines/mads/msurface.h
    engines/mads/user_interface.cpp



diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index 10f4bad..f19abb3 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -39,7 +39,6 @@
 #include "mads/msurface.h"
 #include "mads/resources.h"
 #include "mads/sound.h"
-#include "mads/user_interface.h"
 
 /**
  * This is the namespace of the MADS engine.
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index c8c6623..62807e5 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -34,20 +34,32 @@ MADSEngine *MSurface::_vm = nullptr;
 
 MSurface::MSurface() {
 	pixels = nullptr;
+	_freeFlag = false;
 }
 
 MSurface::MSurface(int width, int height) { 
 	pixels = nullptr;
+	_freeFlag = false;
 	setSize(width, height); 
 }
 
 MSurface::~MSurface() {
-	Graphics::Surface::free();
+	if (_freeFlag)
+		Graphics::Surface::free();
 }
 
 void MSurface::setSize(int width, int height) {
-	Graphics::Surface::free();
+	if (_freeFlag)
+		Graphics::Surface::free();
 	Graphics::Surface::create(width, height, Graphics::PixelFormat::createFormatCLUT8());
+	_freeFlag = true;
+}
+
+void MSurface::setPixels(byte *pData, int horizSize, int vertSize) {
+	_freeFlag = false;
+	pixels = pData;
+	w = horizSize;
+	h = vertSize;
 }
 
 int MSurface::scaleValue(int value, int scale, int err) {
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index d5b8741..37ab305 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -50,6 +50,8 @@ struct SpriteInfo {
  * MADS graphics surface
  */
 class MSurface : public Graphics::Surface {
+private:
+	bool _freeFlag;
 protected:
 	static MADSEngine *_vm;
 public:
@@ -84,6 +86,12 @@ public:
 	void setSize(int width, int height);
 
 	/**
+	 * Sets the pixels the surface is associated with
+	 * @remarks		The surface will not free the data block
+	 */
+	void setPixels(byte *pData, int horizSize, int vertSize);
+
+	/**
 	 * Draws an arbitrary line on the screen using a specified color
 	 * @param startPos		Starting position
 	 * @param endPos		Ending position
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 6afbf4c..63a0ec0 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -39,6 +39,9 @@ void SceneNode::load(Common::SeekableReadStream *f) {
 UserInterface::UserInterface(MADSEngine *vm) : _vm(vm) {
 	_category = CAT_NONE;
 	_screenObjectsCount = 0;
+
+	byte *pData = _vm->_screen.getBasePtr(0, MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT);
+	setPixels(pData, MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
 }
 
 void UserInterface::load(const Common::String &resName) {
@@ -61,7 +64,6 @@ void UserInterface::load(const Common::String &resName) {
 	delete palStream;
 
 	// set the size for the interface
-	setSize(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
 	Common::SeekableReadStream *pixelsStream = madsPack.getItemStream(1);
 	pixelsStream->read(getData(), MADS_SCREEN_WIDTH * MADS_INTERFACE_HEIGHT);
 	delete pixelsStream;
@@ -84,7 +86,6 @@ void UserInterface::setup(int id) {
 			resName += "A";
 
 		resName += ".INT";
-		free();
 		load(resName);
 	}
 	scene._screenObjects._v832EC = id;


Commit: c4ed42e6d5974e635b4241aa110d8ffe2a8c99c7
    https://github.com/scummvm/scummvm/commit/c4ed42e6d5974e635b4241aa110d8ffe2a8c99c7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-15T20:19:01-04:00

Commit Message:
MADS: Implementing UserInterface loading

Changed paths:
    engines/mads/scene_data.h
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 7a41bab..1cd2627 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -33,6 +33,7 @@
 #include "mads/events.h"
 #include "mads/game_data.h"
 #include "mads/messages.h"
+#include "mads/user_interface.h"
 
 namespace MADS {
 
@@ -50,12 +51,6 @@ class SpriteSlot;
 #define TEXT_DISPLAY_MAX_SIZE 40
 #define DIRTY_AREAS_SIZE (SPRITE_SLOTS_MAX_SIZE + TEXT_DISPLAY_MAX_SIZE)
 
-enum ScrCategory {
-	CAT_NONE = 0, CAT_ACTION = 1, CAT_INV_LIST = 2, CAT_INV_VOCAB = 3,
-	CAT_HOTSPOT = 4, CAT_INV_ANIM = 5, CAT_6 = 6, CAT_INV_SCROLLER = 7,
-	CAT_12 = 12
-};
-
 enum Layer {
 	LAYER_GUI = 19
 };
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 63a0ec0..e6840ac 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -39,6 +39,8 @@ void SceneNode::load(Common::SeekableReadStream *f) {
 UserInterface::UserInterface(MADSEngine *vm) : _vm(vm) {
 	_category = CAT_NONE;
 	_screenObjectsCount = 0;
+	_inventoryTopIndex = 0;
+	_objectY = 0;
 
 	byte *pData = _vm->_screen.getBasePtr(0, MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT);
 	setPixels(pData, MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
@@ -123,7 +125,105 @@ void UserInterface::setBounds(const Common::Rect &r) {
 }
 
 void UserInterface::loadElements() {
-	warning("TODO: UserInterface::loadElements");
+	Scene &scene = _vm->_game->_scene;
+	Common::Rect bounds;
+	scene._screenObjects.clear();
+
+	if (!scene._screenObjects._v832EC) {
+		for (int idx = 1; idx <= 3; ++idx) {
+			getBounds(CAT_INV_SCROLLER, idx, bounds);
+			// TODO
+		}
+	}
+}
+
+bool UserInterface::getBounds(ScrCategory category, int v, Common::Rect &bounds) {
+	Common::Rect result;
+	int heightMultiplier, widthMultiplier;
+	int leftStart, yOffset, widthAmt;
+
+	switch (category) {
+	case CAT_ACTION:
+		heightMultiplier = v / 5;
+		widthMultiplier = v / 5;
+		leftStart = 2;
+		yOffset = 3;
+		widthAmt = 32;
+		break;
+
+	case CAT_INV_LIST:
+		if (v < _inventoryTopIndex || v > (_inventoryTopIndex + 5))
+			return false;
+
+		heightMultiplier = v - _inventoryTopIndex;
+		widthMultiplier = 0;
+		leftStart = 90;
+		yOffset = 3;
+		widthAmt = 69;
+		break;
+
+	case CAT_6:
+		heightMultiplier = v;
+		widthMultiplier = 0;
+		leftStart = 2;
+		yOffset = 3;
+		widthAmt = 310;
+		break;
+
+	case CAT_INV_SCROLLER:
+		heightMultiplier = 0;
+		widthMultiplier = 73;
+		yOffset = 0;
+		widthAmt = 9;
+		leftStart = (v != 73) ? 73 : 75;
+		break;
+
+	default:
+		heightMultiplier = v;
+		widthMultiplier = 0;
+		leftStart = 240;
+		yOffset = 3;
+		widthAmt = 80;
+		break;
+	}
+
+	result.left = (widthMultiplier > 0) ? widthMultiplier * widthAmt + leftStart : leftStart;
+	result.setWidth(widthAmt);
+	result.top = heightMultiplier * 3 + yOffset;
+	result.setHeight(8);
+
+	if (category == CAT_INV_SCROLLER) {
+		switch (v) {
+		case 1:
+			// Arrow up
+			result.top = 4;
+			result.setHeight(7);
+			break;
+		case 2:
+			// Arrow down
+			result.top = 35;
+			result.setHeight(7);
+			break;
+		case 3:
+			// Scroller
+			result.top = 12;
+			result.setHeight(22);
+			break;
+		case 4:
+			// Thumb
+			result.top = _objectY + 14;
+			result.setHeight(1);
+			break;
+		default:
+			break;
+		}
+	}
+
+	return true;
+}
+
+void UserInterface::extendRect(Common::Rect &bounds) {
+	
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 8bd02ff..b8e86bf 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -30,17 +30,38 @@
 
 namespace MADS {
 
+enum ScrCategory {
+	CAT_NONE = 0, CAT_ACTION = 1, CAT_INV_LIST = 2, CAT_INV_VOCAB = 3,
+	CAT_HOTSPOT = 4, CAT_INV_ANIM = 5, CAT_6 = 6, CAT_INV_SCROLLER = 7,
+	CAT_12 = 12
+};
+
 class UserInterface : public MSurface {
 private:
 	MADSEngine *_vm;
 
+	/**
+	 * Loads the elements of the user interface
+	 */
 	void loadElements();
+
+	/**
+	 * Returns the area within the user interface a given element falls
+	 */
+	bool getBounds(ScrCategory category, int invIndex, Common::Rect &bounds);
+
+	/**
+	 * Reposition a bounding rectangle to physical co-ordinates
+	 */
+	void extendRect(Common::Rect &bounds);
 public:
 	ScrCategory _category;
 	int _screenObjectsCount;
 	Common::Rect _bounds;
 	Common::Rect *_rectP;
 	MSurface _surface;
+	int _inventoryTopIndex;
+	int _objectY;
 public:
 	/**
 	* Constructor


Commit: 630679a5c8d72242866638b470cd361c0d5c6b0a
    https://github.com/scummvm/scummvm/commit/630679a5c8d72242866638b470cd361c0d5c6b0a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-15T21:33:15-04:00

Commit Message:
MADS: Completed UserInterface::loadElements

Changed paths:
    engines/mads/game.cpp
    engines/mads/hotspots.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index bcebc04..ad3ea5e 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -265,6 +265,10 @@ void Game::initSection(int sectionNumber) {
 
 	_vm->_palette->resetGamePalette(18, 10);
 	_vm->_palette->setLowRange();
+
+	if (_scene._layer == LAYER_GUI)
+		_vm->_palette->setPalette(_vm->_palette->_mainPalette, 0, 4);
+
 	_vm->_events->loadCursors("*CURSOR.SS");
 	
 	assert(_vm->_events->_cursorSprites);
diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
index d754c47..b33b4b2 100644
--- a/engines/mads/hotspots.cpp
+++ b/engines/mads/hotspots.cpp
@@ -129,7 +129,8 @@ void DynamicHotspots::refresh() {
 			switch (_vm->_game->_scene._screenObjects._v832EC) {
 			case 0:
 			case 2:
-				_vm->_game->_scene._screenObjects.add(dh._bounds, CAT_12, dh._descId);
+				_vm->_game->_scene._screenObjects.add(dh._bounds, _vm->_game->_scene._layer,
+					CAT_12, dh._descId);
 				_vm->_game->_scene._screenObjects._v8333C = true;
 				break;
 			default:
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index d1e83f6..9ece16f 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -51,6 +51,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 	_activeAnimation = nullptr;
 	_textSpacing = -1;
 	_frameStartTime = 0;
+	_layer = LAYER_GUI;
 
 	_verbList.push_back(VerbInit(VERB_LOOK, 2, 0));
 	_verbList.push_back(VerbInit(VERB_TAKE, 2, 0));
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 292eb4a..d88f5ec 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -127,6 +127,7 @@ public:
 	int _destFacing;
 	Common::Point _posAdjust;
 	uint32 _frameStartTime;
+	Layer _layer;
 
 	/**
 	 * Constructor
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 94bbb7b..aa3670e 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -51,14 +51,14 @@ ScreenObjects::ScreenObjects(MADSEngine *vm): _vm(vm) {
 	_released = false;
 }
 
-void ScreenObjects::add(const Common::Rect &bounds, ScrCategory category, int descId) {
+void ScreenObjects::add(const Common::Rect &bounds, Layer layer, ScrCategory category, int descId) {
 	assert(size() < 100);
 
 	ScreenObject so;
 	so._bounds = bounds;
 	so._category = category;
 	so._descId = descId;
-	so._layer = 0x1413;
+	so._layer = layer;
 
 	push_back(so);
 }
@@ -119,7 +119,7 @@ void ScreenObjects::check(bool scanFlag) {
 	scene._action.refresh();
 
 	// Loop through image inter list
-	warning("TODO: iimageInterList loop");
+	warning("TODO: imageInterList loop");
 }
 
 int ScreenObjects::scanBackwards(const Common::Point &pt, int layer) {
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 1cd2627..ffea369 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -102,7 +102,7 @@ public:
 	/**
 	 * Add a new item to the list
 	 */
-	void add(const Common::Rect &bounds, ScrCategory category, int descId);
+	void add(const Common::Rect &bounds, Layer layer, ScrCategory category, int descId);
 
 	/**
 	 */
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index e6840ac..cbd4573 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -130,9 +130,56 @@ void UserInterface::loadElements() {
 	scene._screenObjects.clear();
 
 	if (!scene._screenObjects._v832EC) {
+		// Set up screen objects for the inventory scroller
 		for (int idx = 1; idx <= 3; ++idx) {
 			getBounds(CAT_INV_SCROLLER, idx, bounds);
-			// TODO
+			moveRect(bounds);
+
+			scene._screenObjects.add(bounds, LAYER_GUI, CAT_INV_SCROLLER, idx);
+		}
+
+		// Set up actions
+		for (int idx = 0; idx < 10; ++idx) {
+			getBounds(CAT_ACTION, idx, bounds);
+			moveRect(bounds);
+
+			scene._screenObjects.add(bounds, LAYER_GUI, CAT_ACTION, idx);
+		}
+
+		// Set up inventory list
+		for (int idx = 0; idx < 5; ++idx) {
+			getBounds(CAT_INV_LIST, idx, bounds);
+			moveRect(bounds);
+
+			scene._screenObjects.add(bounds, LAYER_GUI, CAT_INV_LIST, idx);
+		}
+
+		// Set up the inventory vocab list
+		for (int idx = 0; idx < 5; ++idx) {
+			getBounds(CAT_INV_VOCAB, idx, bounds);
+			moveRect(bounds);
+
+			scene._screenObjects.add(bounds, LAYER_GUI, CAT_INV_VOCAB, idx);
+		}
+
+		// Set up the inventory item picture
+		scene._screenObjects.add(Common::Rect(160, 159, 231, 194), LAYER_GUI,
+			CAT_INV_ANIM, 0);
+	}
+
+	if (!scene._screenObjects._v832EC || scene._screenObjects._v832EC == 2) {
+		for (int hotspotIdx = scene._hotspots.size() - 1; hotspotIdx >= 0; --hotspotIdx) {
+			Hotspot &hs = scene._hotspots[hotspotIdx];
+			scene._screenObjects.add(hs._bounds, LAYER_GUI, CAT_HOTSPOT, hotspotIdx);
+		}
+	}
+
+	if (scene._screenObjects._v832EC == 1) {
+		for (int idx = 0; idx < 5; ++idx) {
+			getBounds(CAT_6, idx, bounds);
+			moveRect(bounds);
+
+			scene._screenObjects.add(bounds, LAYER_GUI, CAT_6, idx);
 		}
 	}
 }
@@ -222,8 +269,8 @@ bool UserInterface::getBounds(ScrCategory category, int v, Common::Rect &bounds)
 	return true;
 }
 
-void UserInterface::extendRect(Common::Rect &bounds) {
-	
+void UserInterface::moveRect(Common::Rect &bounds) {
+	bounds.translate(0, MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT);
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index b8e86bf..d50a820 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -53,7 +53,7 @@ private:
 	/**
 	 * Reposition a bounding rectangle to physical co-ordinates
 	 */
-	void extendRect(Common::Rect &bounds);
+	void moveRect(Common::Rect &bounds);
 public:
 	ScrCategory _category;
 	int _screenObjectsCount;


Commit: 2fb9edc4ee80c99b5a56a66cf52c614939748bd9
    https://github.com/scummvm/scummvm/commit/2fb9edc4ee80c99b5a56a66cf52c614939748bd9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-15T21:51:40-04:00

Commit Message:
MADS: Added some more ImageInterEntries methods

Changed paths:
    engines/mads/sprites.cpp
    engines/mads/sprites.h



diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 8979fdb..be066ba 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -414,15 +414,34 @@ ImageInterEntry::ImageInterEntry() {
 
 /*------------------------------------------------------------------------*/
 
-int ImageInterEntries::add(int field0, int field2) {
+void ImageInterEntries::add(int v1, int v2) {
 	ImageInterEntry ie;
-	ie._field0 = field0;
-	ie._field2 = field2;
+	ie._field0 = -2;
+	ie._field2 = -1;
+
+	push_back(ie);
+}
+
+void ImageInterEntries::add(int v1, int v2, int v3, int v4) {
+	assert(size() < 50);
+
+	ImageInterEntry ie;
+	ie._field0 = -3;
+	ie._field2 = 201;
+	ie._field6 = v1;
+	ie._field8 = v2;
+	ie._field4 = v3;
+	ie._field3 = v4;
 
 	push_back(ie);
-	return size() - 1;
 }
 
+ImageInterEntry &ImageInterEntries::add() {
+	resize(size() + 1);
+	return (*this)[size() - 1];
+}
+
+
 void ImageInterEntries::call(int v1, int v2) {
 	debug("TODO: ImageInterEntries::call");
 }
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index 2d5b208..82f0a9b 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -240,7 +240,9 @@ public:
 
 class ImageInterEntries: public Common::Array<ImageInterEntry> {
 public:
-	int add(int field0, int field2);
+	void add(int v1, int v2);
+	void add(int v1, int v2, int v3, int v4);
+	ImageInterEntry &add();
 
 	void call(int v1, int v2);
 };


Commit: dfcef632eacc27b4e035e3796550dced425e836d
    https://github.com/scummvm/scummvm/commit/dfcef632eacc27b4e035e3796550dced425e836d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-16T00:00:18-04:00

Commit Message:
MADS: Hooked up the in-progress scene 103

Changed paths:
    engines/mads/game.cpp
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes1.h
    engines/mads/palette.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index ad3ea5e..a4f3b24 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -82,6 +82,7 @@ void Game::run() {
 		_statusFlag = 0;
 		break;
 	default:
+		_scene._nextSceneId = 103;
 		break;
 	}
 
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 8948689..1476620 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -40,20 +40,21 @@ GameNebular::GameNebular(MADSEngine *vm): Game(vm) {
 }
 
 int GameNebular::checkCopyProtection() {
+	/*
 	// DEBUG: Flag copy protection failure
 	_globals[5] = -1;
 	
 	if (!ConfMan.getBool("copy_protection"))
 		return true;
 
-	/* DEBUG: Disabled for now
+	* DEBUG: Disabled for now
 	CopyProtectionDialog *dlg = new CopyProtectionDialog(_vm, false);
 	dlg->show();
 	delete dlg;
 	*/
 
 	// DEBUG: Return that copy protection failed
-	return 1;
+	return 0;
 }
 
 void GameNebular::initialiseGlobals() {
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 6644d95..21592b0 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -28,6 +28,7 @@
 #include "mads/scene.h"
 #include "mads/nebular/game_nebular.h"
 #include "mads/nebular/nebular_scenes.h"
+#include "mads/nebular/nebular_scenes1.h"
 #include "mads/nebular/nebular_scenes8.h"
 
 namespace MADS {
@@ -43,10 +44,18 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	scene.addActiveVocab(NOUN_SPLASH);
 	scene.addActiveVocab(NOUN_ALCOHOL);
 
-	// TODO: Implement all the game scenes
-	assert(scene._nextSceneId == 804);
+	switch (scene._nextSceneId) {
+	// Scene group #1
+	case 103:
+		return new Scene103(vm);
 
-	return new Scene804(vm);
+	// Scene group #8
+	case 804:
+		return new Scene804(vm);
+
+	default:
+		error("Invalid scene %d called", scene._nextSceneId);
+	}
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index 6077e1e..0af34df 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -32,7 +32,7 @@ namespace MADS {
 
 namespace Nebular {
 
-class Scene1xx : protected NebularScene {
+class Scene1xx : public NebularScene {
 protected:
 	/**
 	 * Plays an appropriate sound when entering a scene
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index d7301bb..ba63dd3 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -237,7 +237,8 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 
 
 int PaletteUsage::rgbMerge(RGB6 &palEntry) {
-	return palEntry.r * 38 + palEntry.g * 76 + palEntry.b * 14;
+	return ((palEntry.r + 1) / 4 - 1) * 38 + ((palEntry.g + 1) / 4 - 1) * 76 + 
+		((palEntry.b + 1) / 4 - 1) * 14;
 }
 
 void PaletteUsage::prioritizeFromList(int lst[3]) {


Commit: 5e3684b37a5dad7aaf76275f2a84f054e31d6d06
    https://github.com/scummvm/scummvm/commit/5e3684b37a5dad7aaf76275f2a84f054e31d6d06
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-16T00:43:08-04:00

Commit Message:
MADS: Simplified code for PaletteUsage::prioritize

Changed paths:
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index ba63dd3..94a3117 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -49,7 +49,7 @@ void PaletteUsage::load(int count, ...) {
 
 	_data.clear();
 	for (int i = 0; i < count; ++i)
-		_data.push_back(va_arg(va, int));
+		_data.push_back(UsageEntry(va_arg(va, int)));
 
 	va_end(va);
 }
@@ -61,20 +61,22 @@ void PaletteUsage::getKeyEntries(Common::Array<RGB6> &palette) {
 	 for (uint i = 0; i < palette.size(); ++i) {
 		 byte *uPtr = &palette[i]._flags;
 		 if ((*uPtr & 0x10) && _data.size() < 3) {
-			 _data.push_back(i);
+			 _data.push_back(UsageEntry(i));
 		 }
 	 }
 }
 
-void PaletteUsage::prioritize(Common::Array<RGB6> &palette) {
-	int lst[3];
+static bool sortHelper(const PaletteUsage::UsageEntry &ue1, const PaletteUsage::UsageEntry &ue2) {
+	return ue1._sortValue < ue2._sortValue;
+}
 
+void PaletteUsage::prioritize(Common::Array<RGB6> &palette) {
 	for (uint i = 0; i < _data.size(); ++i) {
-		RGB6 &palEntry = palette[_data[i]];
-		lst[i] = rgbMerge(palEntry);
+		RGB6 &palEntry = palette[_data[i]._palIndex];
+		_data[i]._sortValue = rgbMerge(palEntry);
 	}
 	
-	prioritizeFromList(lst);
+	Common::sort(_data.begin(), _data.end(), sortHelper);
 }
 
 int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
@@ -147,17 +149,17 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 
 		if (hasUsage && palette[v1]._flags & 0x10) {
 			for (uint usageIndex = 0; usageIndex < _data.size() && !var48; ++usageIndex) {
-				if (_data[usageIndex] == palIndex) {
+				if (_data[usageIndex]._palIndex == palIndex) {
 					var48 = true;
 					int dataIndex = MIN(usageIndex, _data.size() - 1);
-					var4 = _data[dataIndex];
+					var4 = _data[dataIndex]._palIndex;
 				}
 			}
 		}
 
 		if (flag1 && palette[palIndex]._flags & 0x10) {
 			for (uint usageIndex = 0; usageIndex < _data.size() && !var48; ++usageIndex) {
-				if (_data[usageIndex] == palIndex) {
+				if (_data[usageIndex]._palIndex == palIndex) {
 					var48 = true;
 					var4 = 0xF0 + usageIndex;
 
@@ -241,63 +243,10 @@ int PaletteUsage::rgbMerge(RGB6 &palEntry) {
 		((palEntry.b + 1) / 4 - 1) * 14;
 }
 
-void PaletteUsage::prioritizeFromList(int lst[3]) {
-	int idx1 = _data.size() - 1;
-	bool continueFlag;
-	int count2;
-
-	do {
-		continueFlag = false;
-		count2 = 0;
-
-		if (idx1 > 0) {
-			int numEntries = _data.size() - 1;
-			int usageIndex = 0, lstIndex = 0;
-
-			do {
-				if (lst[lstIndex] < lst[lstIndex + 1]) {
-					int lstVal = lst[lstIndex];
-					int usageVal = _data[usageIndex];
-
-					if (numEntries > 0) {
-						Common::copy(&lst[lstIndex + 1], &lst[lstIndex + numEntries], &lst[lstIndex]);
-						_data.remove_at(usageIndex);
-						_data.push_back(0);
-					}
-					
-					int newIdx = 0;
-					if (idx1 > 0 && !continueFlag) {
-						for (newIdx = 0; newIdx <= idx1; ++newIdx) {
-							if (lst[newIdx] > lstVal)
-								break;
-						}
-					}
-
-					continueFlag = true;
-					int idxDiff = _data.size() - newIdx - 1;
-					if (idxDiff > 0) {
-						Common::copy_backward(&lst[0], &lst[2], &lst[1]);
-						_data.remove_at(2);
-						_data.insert_at(0, 0);
-					}
-
-					lst[newIdx] = lstVal;
-					_data[newIdx] = usageVal;
-				}
-
-				++usageIndex;
-				--numEntries;
-				++lstIndex;
-				++count2;
-			} while (count2 > idx1 && !continueFlag);
-		}
-	} while (continueFlag);
-}
-
 void PaletteUsage::transform(Common::Array<RGB6> &palette) {
 	if (!empty()) {
 		for (uint i = 0; i < _data.size(); ++i) {
-			int palIndex = _data[i];
+			int palIndex = _data[i]._palIndex;
 			_data[i] = palette[palIndex]._palIndex;
 		}
 	}
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 5a563a5..a28810e 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -55,14 +55,19 @@ struct RGB6 {
 };
 
 class PaletteUsage {
+public:
+	struct UsageEntry {
+		uint16 _palIndex;
+		int _sortValue;
+
+		UsageEntry(int palIndex) { _palIndex = palIndex; }
+	};
 private:
 	MADSEngine *_vm;
-	Common::Array<uint16> _data;
+	Common::Array<UsageEntry> _data;
 
 	int rgbMerge(RGB6 &palEntry);
 
-	void prioritizeFromList(int lst[3]);
-
 	int getGamePalFreeIndex(int *palIndex);
 
 	int rgbFactor(byte *palEntry, RGB6 &pal6);
@@ -79,7 +84,7 @@ public:
 	 */
 	bool empty() const { return _data.size() == 0;  }
 
-	uint16 &operator[](int index) { return _data[index]; }
+	uint16 &operator[](int index) { return _data[index]._palIndex; }
 
 	/**
 	 * Gets key entries from the passed palette


Commit: 120374b7d0eb1af089111f3dfa710122d2ab7424
    https://github.com/scummvm/scummvm/commit/120374b7d0eb1af089111f3dfa710122d2ab7424
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-16T01:08:16-04:00

Commit Message:
MADS: Simplified PaletteUsage::process list sorting

Changed paths:
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 94a3117..bd467aa 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -79,8 +79,11 @@ void PaletteUsage::prioritize(Common::Array<RGB6> &palette) {
 	Common::sort(_data.begin(), _data.end(), sortHelper);
 }
 
+static bool rangeSorter(const PaletteUsage::UsageRange &ur1, const PaletteUsage::UsageRange &ur2) {
+	return ur1._v2 < ur2._v2;
+}
+
 int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
-	byte *pal1 = nullptr, *pal2 = nullptr;
 	int palLow;
 	int palHigh = (flags & 0x800) ? 0x100 : 0xFC;
 	int palIdx;
@@ -118,29 +121,30 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 
 	int freeIndex;
 	int palCount = getGamePalFreeIndex(&freeIndex);
-	pal1 = new byte[PALETTE_COUNT];
-	pal2 = new byte[PALETTE_COUNT];
+	Common::Array<UsageRange> palRange;
 
 	for (uint palIndex = 0; palIndex < palette.size(); ++palIndex) {
-		pal2[palIndex] = palIndex;
-		pal1[palIndex] = 0;
+		byte pal2 = palIndex;
+		byte pal1 = 0;
 
 		if (!(palette[palIndex]._flags & 0x80)) {
-			pal1[palIndex] = 0x40;
+			pal1 = 0x40;
 		}
 		if (palette[palIndex]._flags & 0x60) {
-			pal1[palIndex] |= 0x20;
+			pal1 |= 0x20;
 		}
+
+		palRange.push_back(UsageRange(pal1, pal2));
 	}
 
-	_vm->_palette->processLists(palette.size(), pal1, pal2);
+	Common::sort(palRange.begin(), palRange.end(), rangeSorter);
 	
 	int var3A = (flags & 0x4000) ? 0xffff : 0xfffe;
 
 	for (uint palIndex = 0; palIndex < palette.size(); ++palIndex) {
 		bool var48 = false;
 		int var4 = 0xffff;
-		int v1 = pal2[palIndex];
+		int v1 = palRange[palIndex]._v2;
 
 		if (palette[v1]._flags & 8) {
 			var48 = true;
@@ -231,9 +235,6 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 
 	_vm->_palette->_rgbList[rgbIndex] = -1;
 
-	delete[] pal1;
-	delete[] pal2;
-
 	return rgbIndex;
 }
 
@@ -405,48 +406,6 @@ void Palette::setGradient(byte *palette, int start, int count, int rgbValue1, in
 	}
 }
 
-void Palette::processLists(int count, byte *pal1, byte *pal2) {
-	bool continueFlag;
-	int endIndex = count - 1;
-
-	do {
-		continueFlag = false;
-
-		for (int palIndex = 0; palIndex < endIndex && !continueFlag; ++palIndex) {
-			byte *palP = &pal1[palIndex];
-			byte *pal2P = &pal2[palIndex];
-
-			if (palP[1] < palP[0]) {
-				int v1 = palP[0];
-				int v2 = pal2P[0];
-
-				int size = count - palIndex - 1;
-				if (size > 0) {
-					Common::copy(palP + 1, palP + size + 1, palP);
-					Common::copy(pal2P + 1, pal2P + size + 1, pal2P);
-				}
-
-				int idx;
-				for (idx = 0; idx < endIndex && !continueFlag; ++idx) {
-					if (pal1[idx] > v1)
-						continueFlag = true;
-				}
-				continueFlag = true;
-
-				int size2 = count - idx - 1;
-				if (size2 > 0) {
-					Common::copy(palP + idx, palP + idx + size2 + 1, palP);
-					Common::copy(pal2P + idx, pal2P + idx + size2 + 1, pal2P);
-				}
-
-				pal1[idx] = v1;
-				pal2[idx] = v2;
-			}
-		}
-
-	} while (continueFlag);
-}
-
 void Palette::setSystemPalette() {
 	byte palData[4 * 3];
 	palData[0 * 3] = palData[0 * 3 + 1] = palData[0 * 3 + 2] = 0;
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index a28810e..e9549fd 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -62,6 +62,11 @@ public:
 
 		UsageEntry(int palIndex) { _palIndex = palIndex; }
 	};
+	struct UsageRange {
+		byte _v1, _v2;
+
+		UsageRange(byte v1, byte v2) { _v1 = v1; _v2 = v2; }
+	};
 private:
 	MADSEngine *_vm;
 	Common::Array<UsageEntry> _data;
@@ -201,8 +206,6 @@ public:
 	 */
 	static void setGradient(byte *palette, int start, int count, int rgbValue1, int rgbValue2);
 
-	static void processLists(int count, byte *pal1, byte *pal2);
-
 	/**
 	 * Resets the game palette
 	 */


Commit: 17870490873bd9ba040b58cb5fbfc1c8480d5461
    https://github.com/scummvm/scummvm/commit/17870490873bd9ba040b58cb5fbfc1c8480d5461
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-16T01:29:02-04:00

Commit Message:
MADS: Add loading of game inventory list and quotes

Changed paths:
    engines/mads/game.cpp
    engines/mads/resources.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index a4f3b24..5c034bf 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -60,6 +60,12 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 	_abortTimersMode2 = ABORTMODE_0;
 	_ticksExpiry = 0;
 	_exitFlag = 0;
+
+	// Load the inventory object list
+	_objects.load();
+
+	// Load the quotes
+	loadQuotes();
 }
 
 Game::~Game() {
@@ -285,20 +291,18 @@ void Game::loadQuotes() {
 	File f("*QUOTES.DAT");
 	int curPos = 0;
 
-	char buffer[128];
-	strcpy(buffer, "");
-
+	Common::String msg;
 	while (true) {
 		uint8 b = f.readByte();
-		if (f.eos()) break;
 
-		buffer[curPos++] = b;
-		if (buffer[curPos - 1] == '\0') {
+		msg += b;
+		if (f.eos() || b == '\0') {
 			// end of string, add it to the strings list
-			_quotes.push_back(buffer);
-			curPos = 0;
-			strcpy(buffer, "");
+			_quotes.push_back(msg);
+			msg = "";
 		}
+
+		if (f.eos()) break;
 	}
 
 	f.close();
diff --git a/engines/mads/resources.cpp b/engines/mads/resources.cpp
index 140a347..2742b5b 100644
--- a/engines/mads/resources.cpp
+++ b/engines/mads/resources.cpp
@@ -313,7 +313,9 @@ Common::String Resources::formatName(int prefix, char asciiCh, int id, EXTTYPE e
 			(prefix < 100) ? "*SC" : "*RM", prefix);
 	}
 
-	result += Common::String::format("%c%d", asciiCh, id);
+	result += Common::String::format("%c", asciiCh);
+	if (id >= 0)
+		result += Common::String::format("%d", id);
 	if (!suffix.empty())
 		result += suffix;
 


Commit: 136b64db83a36f0c6ac00d52b11afba497d7c212
    https://github.com/scummvm/scummvm/commit/136b64db83a36f0c6ac00d52b11afba497d7c212
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-16T17:26:51+01:00

Commit Message:
MADS: Move setAAName() to Scene1xx

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 21592b0..085eee1 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -99,11 +99,6 @@ void NebularScene::setPlayerSpritesPrefix() {
 	_vm->_palette->setEntry(17, 10, 45, 45);
 }
 
-void NebularScene::setAAName() {
-	int idx = (_scene->_nextSceneId > 103 && _scene->_nextSceneId < 112) ? 1 : 0;
-	_game._aaName = Resources::formatAAName(idx);
-}
-
 /*------------------------------------------------------------------------*/
 
 void SceneInfoNebular::loadCodes(MSurface &depthSurface) {
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 4da8b49..c1dbcb8 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -105,11 +105,6 @@ protected:
 	Common::String formAnimName(char sepChar, int suffixNum);
 
 	/**
-	 *Sets the AA file to use for the scene
-	 */
-	void setAAName();
-
-	/**
 	 * Updates the prefix used for getting player sprites for the scene
 	 */
 	void setPlayerSpritesPrefix();
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index cdc7547..3d36b19 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -30,6 +30,12 @@ namespace MADS {
 
 namespace Nebular {
 
+void Scene1xx::setAAName() {
+	int idx = (_scene->_nextSceneId > 103 && _scene->_nextSceneId < 112) ? 1 : 0;
+	_game._aaName = Resources::formatAAName(idx);
+}
+
+
 void Scene1xx::sceneEntrySound() {
 	if (_vm->_musicFlag) {
 		switch (_scene->_nextSceneId) {
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index 0af34df..93de7c8 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -38,6 +38,12 @@ protected:
 	 * Plays an appropriate sound when entering a scene
 	 */
 	void sceneEntrySound();
+
+	/**
+	 *Sets the AA file to use for the scene
+	 */
+	void setAAName();
+
 public:
 	Scene1xx(MADSEngine *vm) : NebularScene(vm) {}
 };
@@ -47,15 +53,10 @@ public:
 	Scene101(MADSEngine *vm) : Scene1xx(vm) {}
 
 	virtual void setup();
-
 	virtual void enter();
-
 	virtual void step();
-
 	virtual void preActions();
-
 	virtual void actions();
-
 	virtual void postActions();
 };
 
@@ -64,15 +65,10 @@ public:
 	Scene103(MADSEngine *vm) : Scene1xx(vm) {}
 
 	virtual void setup();
-
 	virtual void enter();
-
 	virtual void step();
-
 	virtual void preActions();
-
 	virtual void actions();
-
 	virtual void postActions();
 };
 


Commit: 9ffaf672ff0f2d05c55db3a69af1f1cf873f4f1b
    https://github.com/scummvm/scummvm/commit/9ffaf672ff0f2d05c55db3a69af1f1cf873f4f1b
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-16T18:10:22+01:00

Commit Message:
MADS: Move setPlayerSpritesPrefix() to Scene1xx

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 085eee1..6b922a4 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -70,35 +70,6 @@ Common::String NebularScene::formAnimName(char sepChar, int suffixNum) {
 		EXT_NONE, "");
 }
 
-void NebularScene::setPlayerSpritesPrefix() {
-	_vm->_sound->command(5);
-	Common::String oldName = _game._player._spritesPrefix;
-	if (_scene->_nextSceneId <= 103 || _scene->_nextSceneId == 111) {
-		if (_globals[0] == SEX_FEMALE) {
-			_game._player._spritesPrefix = "ROX";
-		} else {
-			_game._player._spritesPrefix = "RXM";
-			_globals[0] = SEX_MALE;
-		}
-	} else if (_scene->_nextSceneId <= 110) {
-		_game._player._spritesPrefix = "RXSW";
-		_globals[0] = SEX_UNKNOWN;
-	} else if (_scene->_nextSceneId == 112) {
-		_game._player._spritesPrefix = "";
-	}
-
-	if (oldName == _game._player._spritesPrefix)
-		_game._player._spritesChanged = true;
-	if (_scene->_nextSceneId == 105 || (_scene->_nextSceneId == 109 && _globals[15])) {
-		_game._player._spritesChanged = true;
-		_game._v3 = 0;
-	}
-
-	_game._player._unk3 = 0;
-	_vm->_palette->setEntry(16, 10, 63, 63);
-	_vm->_palette->setEntry(17, 10, 45, 45);
-}
-
 /*------------------------------------------------------------------------*/
 
 void SceneInfoNebular::loadCodes(MSurface &depthSurface) {
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index c1dbcb8..5b7dd6a 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -105,11 +105,6 @@ protected:
 	Common::String formAnimName(char sepChar, int suffixNum);
 
 	/**
-	 * Updates the prefix used for getting player sprites for the scene
-	 */
-	void setPlayerSpritesPrefix();
-
-	/**
 	 * Plays appropriate sound for entering varous rooms
 	 */
 	void lowRoomsEntrySound();
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 3d36b19..65787af 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -35,7 +35,6 @@ void Scene1xx::setAAName() {
 	_game._aaName = Resources::formatAAName(idx);
 }
 
-
 void Scene1xx::sceneEntrySound() {
 	if (_vm->_musicFlag) {
 		switch (_scene->_nextSceneId) {
@@ -69,6 +68,35 @@ void Scene1xx::sceneEntrySound() {
 	}
 }
 
+void Scene1xx::setPlayerSpritesPrefix() {
+	_vm->_sound->command(5);
+	Common::String oldName = _game._player._spritesPrefix;
+	if (_scene->_nextSceneId <= 103 || _scene->_nextSceneId == 111) {
+		if (_globals[0] == SEX_FEMALE) {
+			_game._player._spritesPrefix = "ROX";
+		} else {
+			_game._player._spritesPrefix = "RXM";
+			_globals[0] = SEX_MALE;
+		}
+	} else if (_scene->_nextSceneId <= 110) {
+		_game._player._spritesPrefix = "RXSW";
+		_globals[0] = SEX_UNKNOWN;
+	} else if (_scene->_nextSceneId == 112) {
+		_game._player._spritesPrefix = "";
+	}
+
+	if (oldName == _game._player._spritesPrefix)
+		_game._player._spritesChanged = true;
+	if (_scene->_nextSceneId == 105 || (_scene->_nextSceneId == 109 && _globals[15])) {
+		_game._player._spritesChanged = true;
+		_game._v3 = 0;
+	}
+
+	_game._player._unk3 = 0;
+	_vm->_palette->setEntry(16, 10, 63, 63);
+	_vm->_palette->setEntry(17, 10, 45, 45);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene101::setup() {
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index 93de7c8..56c70b1 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -44,6 +44,10 @@ protected:
 	 */
 	void setAAName();
 
+	/**
+	 * Updates the prefix used for getting player sprites for the scene
+	 */
+	void setPlayerSpritesPrefix();
 public:
 	Scene1xx(MADSEngine *vm) : NebularScene(vm) {}
 };


Commit: ecbe2c87fde0b3f5d8264d4e56426cb5f73521a5
    https://github.com/scummvm/scummvm/commit/ecbe2c87fde0b3f5d8264d4e56426cb5f73521a5
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-16T18:16:21+01:00

Commit Message:
MADS: Implement Scene2xx functions

Changed paths:
  A engines/mads/nebular/nebular_scenes2.cpp
  A engines/mads/nebular/nebular_scenes2.h
    engines/mads/module.mk
    engines/mads/player.cpp
    engines/mads/player.h



diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 74376dc..c2e269e 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -7,6 +7,7 @@ MODULE_OBJS := \
 	nebular/sound_nebular.o \
 	nebular/nebular_scenes.o \
 	nebular/nebular_scenes1.o \
+	nebular/nebular_scenes2.o \
 	nebular/nebular_scenes8.o \
 	action.o \
 	animation.o \
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
new file mode 100644
index 0000000..062ea93
--- /dev/null
+++ b/engines/mads/nebular/nebular_scenes2.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/scene.h"
+#include "mads/nebular/nebular_scenes.h"
+#include "mads/nebular/nebular_scenes2.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+void Scene2xx::setAAName() {
+	int idx = (_scene->_nextSceneId == 216) ? 4 : 2;
+	_game._aaName = Resources::formatAAName(idx);
+}
+
+void Scene2xx::setPlayerSpritesPrefix() {
+	_vm->_sound->command(5);
+	Common::String oldName = _game._player._spritesPrefix;
+
+	switch(_scene->_nextSceneId) {
+	case 213:
+	case 216:
+		_game._player._spritesPrefix = "";
+		break;
+	default:
+		if (_globals[0] == SEX_MALE) {
+			_game._player._spritesPrefix = "ROX";
+		} else {
+			_game._player._spritesPrefix = "RXM";
+		}
+		break;
+	}
+
+	if (_scene->_nextSceneId > 212)
+		_game._player._unk4 = 0;
+	else
+		_game._player._unk4 = -1;
+
+	if (oldName == _game._player._spritesPrefix)
+		_game._player._spritesChanged = true;
+	
+	if ((_scene->_nextSceneId == 203 || _scene->_nextSceneId == 204) && _globals[34])
+		_game._v3 = 0;
+
+	_vm->_palette->setEntry(16, 10, 63, 63);
+	_vm->_palette->setEntry(17, 10, 45, 45);
+}
+
+void Scene201::setup() {
+}
+
+void Scene201::enter() {
+}
+
+void Scene201::step() {
+}
+
+void Scene201::preActions() {
+}
+
+void Scene201::actions() {
+}
+
+void Scene201::postActions() {
+}
+
+} // End of namespace Nebular
+} // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
new file mode 100644
index 0000000..32da9ea
--- /dev/null
+++ b/engines/mads/nebular/nebular_scenes2.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_NEBULAR_SCENES2_H
+#define MADS_NEBULAR_SCENES2_H
+
+#include "common/scummsys.h"
+#include "mads/game.h"
+#include "mads/scene.h"
+#include "mads/nebular/nebular_scenes.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+class Scene2xx : public NebularScene {
+protected:
+	/**
+	 * Plays an appropriate sound when entering a scene
+	 */
+	void setAAName();
+
+	/**
+	 * Updates the prefix used for getting player sprites for the scene
+	 */
+	void setPlayerSpritesPrefix();
+public:
+	Scene2xx(MADSEngine *vm) : NebularScene(vm) {}
+};
+
+class Scene201: public Scene2xx {
+public:
+	Scene201(MADSEngine *vm) : Scene2xx(vm) {}
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions();
+};
+
+} // End of namespace Nebular
+} // End of namespace MADS
+
+#endif /* MADS_NEBULAR_SCENES2_H */
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index ef2ce9f..73b8ce0 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -39,7 +39,7 @@ Player::Player(MADSEngine *vm): _vm(vm) {
 	_special = 0;
 	_ticksAmount = 0;
 	_priorTimer = 0;
-	_unk3 = 0;
+	_unk3 = _unk4 = 0;
 	_forceRefresh = false;
 }
 
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 896b8d5..92e2889 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -63,7 +63,7 @@ public:
 	int _special;
 	int _ticksAmount;
 	uint32 _priorTimer;
-	int _unk3;
+	int _unk3, _unk4;
 	bool _forceRefresh;
 	Common::String _spritesPrefix;
 public:


Commit: 834cf846f14ac613b96a662b9701380e7a132d9b
    https://github.com/scummvm/scummvm/commit/834cf846f14ac613b96a662b9701380e7a132d9b
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-16T18:32:46+01:00

Commit Message:
MADS: Implement Scene201::setup, remove some function definition, add some Noun enum values

Changed paths:
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 5b7dd6a..6021e67 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -39,6 +39,7 @@ enum {
 };
 
 enum Noun {
+	NOUN_D              = 0xD,
 	NOUN_BLOWGUN		= 0x29,
 	NOUN_BURGER			= 0x35,
 	NOUN_CHAIR			= 0x47,
@@ -76,6 +77,7 @@ enum Noun {
 	NOUN_SIT_IN			= 0x13F,
 	NOUN_SMELL			= 0x147,
 	NOUN_STUFFED_FISH	= 0x157,
+	NOUN_15F            = 0x15F,
 	NOUN_VIEW_SCREEN	= 0x180,
 	NOUN_CAPTIVE_CREATURE	= 0x1C3,
 	NOUN_NATIVE_WOMAN	= 0x1DC,
@@ -83,7 +85,8 @@ enum Noun {
 	NOUN_DOLLOP			= 0x3AC,
 	NOUN_DROP			= 0x3AD,
 	NOUN_DASH			= 0x3AE,
-	NOUN_SPLASH			= 0x3AF
+	NOUN_SPLASH			= 0x3AF,
+	NOUN_487            = 0x487
 };
 
 class SceneFactory {
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 062ea93..ec8af4c 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -69,6 +69,13 @@ void Scene2xx::setPlayerSpritesPrefix() {
 }
 
 void Scene201::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+
+	Scene &scene = _vm->_game->_scene;
+	scene.addActiveVocab(NOUN_15F);
+	scene.addActiveVocab(NOUN_487);
+	scene.addActiveVocab(NOUN_D);
 }
 
 void Scene201::enter() {
@@ -77,14 +84,8 @@ void Scene201::enter() {
 void Scene201::step() {
 }
 
-void Scene201::preActions() {
-}
-
 void Scene201::actions() {
 }
 
-void Scene201::postActions() {
-}
-
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 32da9ea..c4de731 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -53,9 +53,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions();
 	virtual void actions();
-	virtual void postActions();
 };
 
 } // End of namespace Nebular


Commit: f3415b762eede6481cbfcb48faecfec505150eab
    https://github.com/scummvm/scummvm/commit/f3415b762eede6481cbfcb48faecfec505150eab
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-16T14:53:10-04:00

Commit Message:
MADS: Implemented lots of Player methods

Changed paths:
    engines/mads/game.cpp
    engines/mads/msurface.cpp
    engines/mads/msurface.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/player.cpp
    engines/mads/player.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h
    engines/mads/user_interface.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 5c034bf..af23998 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -179,11 +179,18 @@ void Game::sectionLoop() {
 
 		_vm->_palette->_paletteUsage.load(3, 0xF0, 0xF1, 0xF2);
 		
+		if (!_player._spritesLoaded && _v3) {
+			if (_player.loadSprites(""))
+				_vm->quitGame();
+			_playerSpritesFlag = true;
+		}
+
 		_scene.loadScene(_scene._nextSceneId, _aaName, 0);
 		_vm->_sound->pauseNewCommands();
 
 		if (!_player._spritesLoaded) {
-			_player.loadSprites("");
+			if (_player.loadSprites(""))
+				_vm->quitGame();
 			_playerSpritesFlag = false;
 		}
 
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 62807e5..65858f5 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -521,4 +521,18 @@ int DepthSurface::getDepth(const Common::Point &pt) {
 	}
 }
 
+int DepthSurface::getDepthHighBit(const Common::Point &pt) {
+	if (_vm->_game->_scene._sceneInfo->_depthStyle == 2) {
+		int bits = (3 - (pt.x % 4)) * 2;
+		byte v = *getBasePtr(pt.x >> 2, pt.y);
+		return (v >> bits) & 2;
+	} else {
+		if (pt.x < 0 || pt.y < 0 || pt.x >= this->w || pt.y >= this->h)
+			return 0;
+
+		return *getBasePtr(pt.x, pt.y) & 0x80;
+	}
+}
+
+
 } // End of namespace MADS
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index 37ab305..7cf2bbe 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -223,6 +223,10 @@ public:
 	 * Returns the depth at a given position
 	 */
 	int getDepth(const Common::Point &pt);
+
+	/**
+	 */
+	int getDepthHighBit(const Common::Point &pt);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 1476620..91c10a5 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -35,7 +35,7 @@ namespace MADS {
 namespace Nebular {
 
 GameNebular::GameNebular(MADSEngine *vm): Game(vm) {
-	_surface = new MSurface(MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT);
+	_surface = new MSurface(MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT);
 	_storyMode = STORYMODE_NAUGHTY;
 }
 
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 73b8ce0..fe1065c 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -26,21 +26,47 @@
 
 namespace MADS {
 
+#define PLAYER_SEQ_INDEX -2
+
+const int Player::_directionListIndexes[32] = {
+	0, 7, 4, 3, 6, 0, 2, 5, 0, 1, 9, 4, 1, 2, 7, 9, 3, 8, 9, 6, 7, 2, 3, 6, 1, 7, 9, 4, 7, 8, 0, 0
+};
+
 Player::Player(MADSEngine *vm): _vm(vm) {
 	_action = nullptr;
 	_direction = 8;
 	_newDirection = 8;
 	_destFacing = 0;
 	_spritesLoaded = false;
-	_spritesStart = _numSprites = 0;
+	_spritesStart = 0;
+	_spritesIdx = 0;
+	_numSprites = 0;
 	_stepEnabled = false;
 	_visible = false;
+	_priorVisible = false;
 	_visible3 = false;
 	_special = 0;
 	_ticksAmount = 0;
 	_priorTimer = 0;
 	_unk3 = _unk4 = 0;
 	_forceRefresh = false;
+	_highSprites = false;
+	_currentDepth = 0;
+	_currentScale = 0;
+	_frameOffset = 0;
+	_frameNum = 0;
+	_yScale = 0;
+	_frameCount = 0;
+	_unk1 = 0;
+	_unk2 = 0;
+	_unk3 = 0;
+	_frameListIndex = 0;
+	_actionIndex = 0;
+	_hypotenuse = 0;
+	
+	Common::fill(&_actionList[0], &_actionList[12], 0);
+	Common::fill(&_actionList2[0], &_actionList2[12], 0);
+	Common::fill(&_spriteSetsPresent[0], &_spriteSetsPresent[PLAYER_SPRITES_FILE_COUNT], false);
 }
 
 void Player::reset() {
@@ -49,7 +75,7 @@ void Player::reset() {
 	_destFacing = 5;
 	_newDirection = _direction;
 	_moving = false;
-	_v844C0 = _v844BE = 0;
+	_newSceneId = _v844BE = 0;
 	_next = 0;
 	_routeCount = 0;
 
@@ -58,8 +84,49 @@ void Player::reset() {
 	_action->_walkFlag = false;
 }
 
-void Player::loadSprites(const Common::String &prefix) {
-	warning("TODO: Player::loadSprites");
+bool Player::loadSprites(const Common::String &prefix) {
+	Common::String suffixList = "89632741";
+
+	Common::String newPrefix;
+	if (prefix.empty()) {
+		newPrefix = _spritesPrefix;
+	} else {
+		_spritesPrefix = prefix;
+		newPrefix = prefix;
+	}
+
+	_numSprites = 0;
+	if (!_spritesPrefix.empty()) {
+		for (int fileIndex = 0; fileIndex < PLAYER_SPRITES_FILE_COUNT; ++fileIndex) {
+			Common::String setName = Common::String::format("*%s_%c.SS",
+				newPrefix.c_str(), suffixList[fileIndex]);
+			if (fileIndex >= 5)
+				_highSprites = true;
+
+			_spriteSetsPresent[fileIndex] = true;
+			int setIndex = _vm->_game->_scene._sprites.addSprites(setName, 4);
+			if (setIndex >= 0) {
+				++_numSprites;
+			}  else if (fileIndex >= 5) {
+				_highSprites = 0;
+				return true;
+			} else {
+				_spriteSetsPresent[fileIndex] = false;
+			}
+
+			if (fileIndex == 0)
+				_spritesStart = setIndex;
+		}
+
+		_spritesLoaded = true;
+		_spritesChanged = false;
+		_highSprites = false;
+		return false;
+	} else {
+		Common::fill(&_spriteSetsPresent[0], &_spriteSetsPresent[PLAYER_SPRITES_FILE_COUNT], false);
+		_highSprites = false;
+		return true;
+	}
 }
 
 void Player::turnToDestFacing() {
@@ -67,30 +134,227 @@ void Player::turnToDestFacing() {
 		_newDirection = _destFacing;
 }
 
+void Player::dirChanged() {
+	int dirIndex = 0, dirIndex2 = 0;
+	int newDir = 0, newDir2 = 0;
+
+	if (_direction != _newDirection) {
+		// Find the index for the given direction in the player direction list
+		int tempDir = _direction;
+		do {
+			++dirIndex;
+			newDir += tempDir;
+			tempDir = _directionListIndexes[tempDir + 10];
+		} while (tempDir != _newDirection);
+	}
+
+
+	if (_direction != _newDirection) {
+		// Find the index for the given direction in the player direction list
+		int tempDir = _direction;
+		do {
+			++dirIndex2;
+			newDir2 += tempDir;
+			tempDir = _directionListIndexes[tempDir + 20];
+		} while (tempDir != _newDirection);
+	}
+
+	int diff = dirIndex - dirIndex2;
+	if (diff == 0)
+		diff = newDir - newDir2;
+
+	_direction = (diff >= 0) ? _directionListIndexes[_direction + 20] : _directionListIndexes[_direction + 10];
+	setupFrame();
+	if ((_direction == _newDirection) && !_moving)
+		updateFrame();
+
+	_priorTimer += 1;
+}
+
 void Player::moveComplete() {
 	reset();
 	_action->_inProgress = false;
 }
 
 void Player::setupFrame() {
+	Scene &scene = _vm->_game->_scene;
+
 	resetActionList();
-	warning("TODO: Player::setupFrame");
+	_frameOffset = 0;
+	_spritesIdx = _directionListIndexes[_direction];
+	if (!_spriteSetsPresent[_spritesIdx]) {
+		// Direction isn't present, so use alternate direction, with entries flipped
+		_spritesIdx -= 4;
+		_frameOffset = 0x8000;
+	}
+
+	SpriteAsset &spriteSet = *scene._sprites[_spritesStart + _spritesIdx];
+	assert(spriteSet._charInfo);
+	_unk1 = MAX(spriteSet._charInfo->_unk1, 100);
+	setTicksAmount();
+
+	_frameCount = spriteSet._charInfo->_totalFrames;
+	if (_frameCount == 0)
+		_frameCount = spriteSet.getCount();
+
+	_yScale = spriteSet._charInfo->_yScale;
+
+	if ((_frameNum <= 0) || (_frameNum > _frameCount))
+		_frameNum = 1;
+	_forceRefresh = true;
 }
 
 void Player::updateFrame() {
-	warning("TODO: Player::updateFrame");
+	Scene &scene = _vm->_game->_scene;
+	SpriteAsset &spriteSet = *scene._sprites[_spritesStart + _spritesIdx];
+	assert(spriteSet._charInfo);
+
+	if (!spriteSet._charInfo->_numEntries) {
+		_frameNum = 1;
+	} else {
+		_frameListIndex = _actionList[_actionIndex];
+
+		if (!_visible) {
+			_unk2 = 0;
+		}
+		else {
+			_unk2 = _actionList2[_actionIndex];
+
+			if (_actionIndex > 0)
+				--_actionIndex;
+		}
+
+		// Set the player frame number
+		int frameIndex = ABS(_frameListIndex);
+		_frameNum = (_frameListIndex <= 0) ? spriteSet._charInfo->_frameList[frameIndex] :
+			spriteSet._charInfo->_frameList2[frameIndex];
+
+		// Set next waiting period in ticks
+		if (frameIndex == 0) {
+			setTicksAmount();
+		} else {
+			_ticksAmount = spriteSet._charInfo->_ticksList[frameIndex];
+		}
+	}
 }
 
 void Player::update() {
-	warning("TODO: Player::update");
+	Scene &scene = _vm->_game->_scene;
+
+	if (_forceRefresh || (_visible != _priorVisible)) {
+		int slotIndex = getSpriteSlot();
+		if (slotIndex >= 0)
+			scene._spriteSlots[slotIndex]._spriteType = ST_EXPIRED;
+
+		int newDepth = 1;
+		int yp = MAX(_playerPos.y, (int16)(MADS_SCENE_HEIGHT - 1));
+		
+		for (int idx = 1; idx < 15; ++idx) {
+			if (scene._sceneInfo->_depthList[newDepth] >= yp)
+				newDepth = idx + 1;
+		}
+		_currentDepth = newDepth;
+
+		// Get the scale
+		int newScale = getScale(_playerPos.y);
+		_currentScale = MIN(newScale, 100);
+
+		if (_visible) {
+			// Player sprite needs to be rendered
+			SpriteSlot slot;
+			slot._spriteType = ST_FOREGROUND;
+			slot._seqIndex = PLAYER_SEQ_INDEX;
+			slot._spritesIndex = _spritesStart + _spritesIdx;
+			slot._frameNumber = _frameOffset + _frameNum;
+			slot._position.x = _playerPos.x;
+			slot._position.y = _playerPos.y + (_yScale * newScale) / 100;
+			slot._depth = newDepth;
+			slot._scale = newScale;
+
+			if (slotIndex >= 0) {
+				// Check if the existing player slot has the same details, and can be re-used
+				SpriteSlot &s2 = scene._spriteSlots[slotIndex];
+				bool equal = (s2._seqIndex == slot._seqIndex) 
+					&& (s2._spritesIndex == slot._spritesIndex)
+					&& (s2._frameNumber == slot._frameNumber) 
+					&& (s2._position == slot._position)
+					&& (s2._depth == slot._depth) 
+					&& (s2._scale == slot._scale);
+
+				if (equal)
+					// Undo the prior expiry of the player sprite
+					s2._spriteType = ST_NONE;
+				else
+					slotIndex = -1;
+			}
+
+			if (slotIndex < 0) {
+				// New slot needed, so allocate one and copy the slot data
+				slotIndex = scene._spriteSlots.add();
+				scene._spriteSlots[slotIndex] = slot;
+			}
+
+			// If changing a scene, check to change the scene when the player 
+			// has moved off-screen
+			if (_newSceneId) {
+				SpriteAsset *asset = scene._sprites[slot._spritesIndex];
+				MSprite *frame = asset->getFrame(_frameNum - 1);
+				int xScale = frame->w * newScale / 200;
+				int yScale = frame->h * newScale / 100;
+				int playerX = slot._position.x;
+				int playerY = slot._position.y;
+
+				if ((playerX + xScale) < 0 || (playerX + xScale) >= MADS_SCREEN_WIDTH ||
+						playerY < 0 || (playerY + yScale) >= MADS_SCENE_HEIGHT) {
+					scene._nextSceneId = _newSceneId;
+					_newSceneId = 0;
+					_vm->_game->_v4 = 0;
+				}
+			}
+
+		}
+	}
+
+	_visible3 = _visible;
+	_priorVisible = _visible;
+	_forceRefresh = false;
 }
 
 void Player::resetActionList() {
-	warning("TODO: Player::resetActionList");
+	_actionList[0] = 0;
+	_actionList2[0] = 0;
+	_actionIndex = 0;
+	_unk2 = 0;
+	_unk3 = 0;
 }
 
 void Player::setDest(const Common::Point &pt, int facing) {
-	warning("TODO: Player::setDest");
+	Scene &scene = _vm->_game->_scene;
+
+	resetActionList();
+	setTicksAmount();
+	_moving = true;
+	_destFacing = facing;
+
+	scene._sceneInfo->setRouteNode(scene._sceneInfo->_nodes.size() - 2,
+		_playerPos, scene._depthSurface);
+	scene._sceneInfo->setRouteNode(scene._sceneInfo->_nodes.size() - 1,
+		pt, scene._depthSurface);
+
+	bool v = scene._depthSurface.getDepthHighBit(pt);
+	setupRoute(v);
+	_next = 0;
+
+	if (_routeCount > 0) {
+		Common::Point srcPos = _playerPos;
+		for (int routeCtr = _routeCount - 1; (routeCtr >= 0) && (_next == 0); --routeCtr) {
+			int idx = _routeIndexes[routeCtr];
+			const Common::Point &pt =scene._sceneInfo->_nodes[idx]._walkPos;
+
+			_next = scanPath(scene._depthSurface, srcPos, pt);
+			srcPos = pt;
+		}
+	}
 }
 
 void Player::nextFrame() {
@@ -111,15 +375,364 @@ void Player::nextFrame() {
 }
 
 void Player::move() {
-	warning("TODO: Player::move");
+	Scene &scene = _vm->_game->_scene;
+	bool routeFlag = false;
+
+	if (_moving) {
+		int idx = _routeCount;
+		while (!_newSceneId && (_destPos.x == _playerPos.x) && (_destPos.y == _playerPos.y)) {
+			if (idx != 0) {
+				--idx;
+				SceneNode &node = scene._sceneInfo->_nodes[_routeIndexes[idx]];
+				_destPos = node._walkPos;
+				routeFlag = true;
+			}
+			else if (_v844BE == idx) {
+				// End of walking path
+				_routeCount = 0;
+				_moving = false;
+				turnToDestFacing();
+				routeFlag = true;
+				idx = _routeCount;
+			}
+			else {
+				_newSceneId = _v844BE;
+				_v844BC = true;
+				_v844BE = 0;
+				_stepEnabled = true;
+				routeFlag = false;
+			}
+
+			if (!_moving)
+				break;
+		}
+		_routeCount = idx;
+	}
+
+	if (routeFlag && _moving)
+		startMovement();
+
+	if (_newDirection != _direction)
+		dirChanged();
+	else if (!_moving)
+		updateFrame();
+
+	int var1 = _unk1;
+	if (_unk4 && (_hypotenuse > 0)) {
+		int v1 = -(_currentScale - 100) * (_posDiff.x - 1) / _hypotenuse + _currentScale;
+		var1 = MAX(1, 10000 / (v1 * _currentScale * var1));
+	}
+
+	if (!_moving || (_direction != _newDirection))
+		return;
+
+	Common::Point newPos = _playerPos;
+
+	if (_v8452E < var1) {
+		do {
+			if (_v8452C < _posDiff.x)
+				_v8452C += _posDiff.y;
+			if (_v8452C >= _posDiff.x) {
+				if ((_posChange.y > 0) || (_newSceneId != 0))
+					newPos.y += _yDirection;
+				--_posChange.y;
+				_v8452C -= _posDiff.x;
+			}
+
+			if (_v8452C < _posDiff.x) {
+				if ((_posChange.x > 0) || (_newSceneId != 0))
+					newPos.x += _xDirection;
+				--_posChange.x;
+			}
+
+			if ((_v844BC == 0) && (_newSceneId == 0) && (_v844BE == 0)) {
+				routeFlag = scene._depthSurface.getDepthHighBit(newPos);
+
+				if (_special == 0)
+					_special = scene.getDepthHighBits(newPos);
+			}
+
+			_v8452E += _v84530;
+
+		} while ((_v8452E < var1) && !routeFlag && ((_posChange.x > 0) || (_posChange.y > 0) || (_newSceneId != 0)));
+	}
+
+	_v8452E -= var1;
+
+	if (routeFlag)
+		moveComplete();
+	else {
+		if (!_newSceneId) {
+			// If the move is complete, make sure the position is exactly on the given destination
+			if (_posChange.x == 0)
+				newPos.x = _destPos.x;
+			if (_posChange.y == 0)
+				newPos.y = _destPos.y;
+		}
+
+		_playerPos = newPos;
+	}
 }
 
 void Player::idle() {
-	warning("TODO: Player::idle");
+	Scene &scene = _vm->_game->_scene;
+
+	if (_direction != _newDirection) {
+		// The direction has changed, so reset for new direction
+		dirChanged();
+		return;
+	}
+
+	SpriteAsset &spriteSet = *scene._sprites[_spritesStart + _spritesIdx];
+	assert(spriteSet._charInfo);
+	if (spriteSet._charInfo->_numEntries == 0)
+		// No entries, so exit immediately
+		return;
+
+	int frameIndex = ABS(_frameListIndex);
+	int direction = (_frameListIndex < 0) ? -1 : 1;
+
+	if (frameIndex >= spriteSet._charInfo->_numEntries)
+		// Reset back to the start of the list
+		_frameListIndex = 0;
+	else {
+		_frameNum += direction;
+		_forceRefresh = true;
+
+		if (spriteSet._charInfo->_frameList2[frameIndex] < _frameNum) {
+			_unk3 = _unk2;
+			updateFrame();
+		}
+		if (spriteSet._charInfo->_frameList[frameIndex] < _frameNum) {
+			_unk3 = _unk2;
+			updateFrame();
+		}
+	}
 }
 
 void Player::postUpdate() {
-	warning("TODO: Player::postUpdate");
+	if (_moving) {
+		if (++_frameNum > _frameCount)
+			_frameNum = 1;
+		_forceRefresh = true;
+	} else {
+		if (!_forceRefresh)
+			idle();
+	}
+}
+
+int Player::getSpriteSlot() {
+	SpriteSlots &spriteSlots = _vm->_game->_scene._spriteSlots;
+
+	for (uint idx = 0; idx < spriteSlots.size(); ++idx) {
+		if (spriteSlots[idx]._seqIndex == PLAYER_SEQ_INDEX && 
+				spriteSlots[idx]._spriteType >= ST_NONE)
+			return idx;
+	}
+
+	return - 1;
+}
+
+int Player::getScale(int yp) {
+	Scene &scene = _vm->_game->_scene;
+
+	int scale = (scene._bandsRange == 0) ? scene._sceneInfo->_maxScale :
+		(yp - scene._sceneInfo->_yBandsStart) * scene._scaleRange / scene._bandsRange +
+		scene._sceneInfo->_minScale;
+
+	return MIN(scale, 100);
+}
+
+void Player::setTicksAmount() {
+	Scene &scene = _vm->_game->_scene;
+
+	SpriteAsset &spriteSet = *scene._sprites[_spritesStart + _spritesIdx];
+	assert(spriteSet._charInfo);
+
+	_ticksAmount = spriteSet._charInfo->_ticksAmount;
+	if (_ticksAmount == 0)
+		_ticksAmount = 6;
+}
+
+void Player::setupRoute(bool bitFlag) {
+	Scene &scene = _vm->_game->_scene;
+
+	// Reset the flag set of nodes in use
+	SceneNodeList &nodes = scene._sceneInfo->_nodes;
+	for (uint i = 0; i < nodes.size(); ++i)
+		nodes[i]._active = false;
+
+	// Start constructing route node list
+	_routeLength = 0x3FFF;
+	_routeCount = 0;
+
+	setupRouteNode(_tempRoute, nodes.size() - 1, bitFlag ? 0xC000 : 0x8000, 0);
+}
+
+void Player::setupRouteNode(int *routeIndexP, int nodeIndex, int flags, int routeLength) {
+	Scene &scene = _vm->_game->_scene;
+	SceneNodeList &nodes = scene._sceneInfo->_nodes;
+	SceneNode &currentNode = nodes[nodeIndex];
+	currentNode._active = true;
+
+	*routeIndexP++ = nodeIndex;
+
+	int subIndex = nodes.size() - 2;
+	int indexVal = nodes[nodeIndex]._indexes[subIndex];
+	if (indexVal & flags) {
+		routeLength += indexVal & 0x3FFF;
+		if (routeLength < _routeLength) {
+			// Found a new shorter route to destination, so set up the route with the found one
+			Common::copy(_tempRoute, routeIndexP, _routeIndexes);
+			_routeCount = routeIndexP - _tempRoute;
+			_routeLength = indexVal & 0x3FFF;
+		}
+	} else {
+		for (int idx = nodes.size() - 2; idx > 0; --idx) {
+			int nodePos = idx - 1;
+			if (!nodes[nodePos]._active && ((currentNode._indexes[nodePos] & flags) != 0))
+				setupRouteNode(routeIndexP, nodePos, 0x8000, indexVal & 0x3fff);
+		}
+	}
+
+	currentNode._active = false;
+}
+
+int Player::scanPath(MSurface &depthSurface, const Common::Point &srcPos, const Common::Point &destPos) {
+	Scene &scene = _vm->_game->_scene;
+	
+	// For compressed depth surfaces, always return 0
+	if (scene._sceneInfo->_depthStyle != 2)
+		return 0;
+
+	int yDiff = destPos.y - srcPos.y;
+	int yAmount = MADS_SCREEN_WIDTH;
+
+	if (yDiff < 0) {
+		yDiff = -yDiff;
+		yAmount = -yAmount;
+	}
+
+	int xDiff = destPos.x - srcPos.y;
+	int xDirection = 1;
+	int xAmount = 0;
+	if (xDiff < 0) {
+		xDiff = -xDiff;
+		xDirection = -xDirection;
+		xAmount = MIN(yDiff, xDiff);
+	}
+
+	++xDiff;
+	++yDiff;
+
+	const byte *srcP = depthSurface.getBasePtr(srcPos.x, srcPos.y);
+	int index = xAmount;
+
+	// Outer horizontal movement loop
+	for (int yIndex = 0; yIndex < yDiff; ++yIndex) {
+		index += yDiff;
+		int v = (*srcP & 0x7F) >> 4;
+		if (v)
+			return v;
+
+		// Inner loop for handling vertical movement
+		while (index >= xDiff) {
+			index -= xDiff;
+
+			v = (*srcP & 0x7F) >> 4;
+			if (v)
+				return v;
+
+			srcP += yAmount;
+		}
+
+		srcP += xDirection;
+	}
+
+	return 0;
+}
+
+void Player::startMovement() {
+	int xDiff = _destPos.x - _playerPos.x;
+	int yDiff = _destPos.y - _playerPos.y;
+	int srcScale = getScale(_playerPos.y);
+	int destScale = getScale(_destPos.y);
+
+	// Sets the X direction
+	if (xDiff > 0)
+		_xDirection = 1;
+	else if (xDiff < 0)
+		_xDirection = -1;
+	else
+		_xDirection = 0;
+
+	// Sets the Y direction
+	if (yDiff > 0)
+		_yDirection = 1;
+	else if (yDiff < 0)
+		_yDirection = -1;
+	else
+		_yDirection = 0;
+
+	xDiff = ABS(xDiff);
+	yDiff = ABS(yDiff);
+	int scaleDiff = ABS(srcScale - destScale);
+
+	int xAmt100 = xDiff * 100;
+	int yAmt100 = yDiff * 100;
+	int xAmt33 = xDiff * 33;
+
+	int scaleAmount = (_unk4 ? scaleDiff * 3 : 0) + 100 * yDiff / 100;
+	int scaleAmount100 = scaleAmount * 100;
+
+	// Figure out direction that will need to be moved in
+	int majorDir;
+	if (xDiff == 0)
+		majorDir = 1;
+	else if (yDiff == 0)
+		majorDir = 3;
+	else {
+		if ((scaleAmount < xDiff) && ((xAmt33 / scaleAmount) >= 141))
+			majorDir = 3;
+		else if (yDiff <= xDiff)
+			majorDir = 2;
+		else if ((scaleAmount100 / xDiff) >= 141)
+			majorDir = 1;
+		else
+			majorDir = 2;
+	}
+
+	switch (majorDir) {
+	case 1:
+		_newDirection = (_yDirection <= 0) ? 8 : 2;
+		break;
+	case 2: {
+				_newDirection = ((_yDirection <= 0) ? 9 : 3) - ((_xDirection <= 0) ? 2 : 0);
+				break;
+	}
+	case 3:
+		_newDirection = (_xDirection <= 0) ? 4 : 6;
+		break;
+	default:
+		break;
+	}
+
+	_hypotenuse = sqrt((double)(xAmt100 * xAmt100 + yAmt100 * yAmt100));
+	_posDiff.x = xDiff + 1;
+	_posDiff.y = yDiff + 1;
+	_posChange.x = xDiff;
+	_posChange.y = yDiff;
+
+	int majorChange = MAX(xDiff, yDiff);
+	_v84530 = (majorChange == 0) ? 0 : _hypotenuse / majorChange;
+
+	if (_playerPos.x > _destPos.x)
+		_v8452C = MAX(_posChange.x, _posChange.y);
+	else
+		_v8452C = 0;
+
+	_hypotenuse /= 100;
+	_v8452E = -_v84530;
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 92e2889..9a615e5 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -31,10 +31,32 @@ namespace MADS {
 class MADSEngine;
 class Action;
 
+#define PLAYER_SPRITES_FILE_COUNT 8
+
 class Player {
 private:
+	static const int _directionListIndexes[32];
+private:
 	MADSEngine *_vm;
 	MADSAction *_action;
+	bool _highSprites;
+	bool _spriteSetsPresent[PLAYER_SPRITES_FILE_COUNT];
+	int _currentDepth;
+	int _currentScale;
+	int _frameOffset;
+	int _frameNum;
+	int _yScale;
+	int _frameCount;
+	int _frameListIndex;
+	int _actionIndex;
+	bool _v844BC;
+	int _v8452E;
+	int _v8452C;
+	int _v84530;
+	int _routeLength;
+	int _actionList[12];
+	int _actionList2[12];
+	int _hypotenuse;
 
 	void reset();
 
@@ -43,33 +65,78 @@ private:
 	void move();
 
 	void postUpdate();
+
+	/**
+	 * Get the sprite slot index for the player
+	 */
+	int getSpriteSlot();
+
+	/**
+	 * Get the scale for the player at the given Y position
+	 */
+	int getScale(int yp);
+
+	void setTicksAmount();
+
+	void setupRoute();
+
+	void setupRoute(bool bitFlag);
+
+	void setupRouteNode(int *routeIndexP, int nodeIndex, int flags, int routeLength);
+
+	/**
+	* Scans along an edge connecting two points within the depths/walk surface, and returns the information of the first
+	* pixel high nibble encountered with a non-zero value
+	*/
+	int scanPath(MSurface &depthSurface, const Common::Point &srcPos, const Common::Point &destPos);
+
+	/**
+	* Starts a player moving to a given destination
+	*/
+	void startMovement();
+
+	void dirChanged();
 public:
 	int _direction;
 	int _newDirection;
+	int _xDirection, _yDirection;
 	int _destFacing;
 	bool _spritesLoaded;
 	int _spritesStart;
+	int _spritesIdx;
 	int _numSprites;
 	bool _stepEnabled;
 	bool _spritesChanged;
 	bool _visible;
+	bool _priorVisible;
 	bool _visible3;
 	Common::Point _playerPos;
 	Common::Point _destPos;
+	Common::Point _posChange;
+	Common::Point _posDiff;
 	bool _moving;
-	int _v844C0, _v844BE;
+	int _newSceneId, _v844BE;
 	int _next;
-	int _routeCount;
 	int _special;
 	int _ticksAmount;
 	uint32 _priorTimer;
-	int _unk3, _unk4;
+	int _unk1;
+	int _unk2;
+	int _unk3;
+	bool _unk4;
 	bool _forceRefresh;
 	Common::String _spritesPrefix;
+	int _routeCount;
+	int _routeOffset;
+	int _tempRoute[MAX_ROUTE_NODES];
+	int _routeIndexes[MAX_ROUTE_NODES];
 public:
 	Player(MADSEngine *vm);
 
-	void loadSprites(const Common::String &prefix);
+	/**
+	 * Load sprites for the player
+	 */
+	bool loadSprites(const Common::String &prefix);
 
 	void turnToDestFacing();
 
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index aa3670e..04dfc4b 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -394,6 +394,87 @@ void SceneInfo::SpriteInfo::load(Common::SeekableReadStream *f) {
 	_scale = f->readByte();
 }
 
+void SceneInfo::setRouteNode(int nodeIndex, const Common::Point &pt, MSurface &depthSurface) {
+	int flags, hypotenuse;
+
+	_nodes[nodeIndex]._walkPos = pt;
+
+	// Recalculate inter-node lengths
+	for (uint idx = 0; idx < _nodes.size(); ++idx) {
+		int entry;
+		if (idx == (uint)nodeIndex) {
+			entry = 0x3FFF;
+		}
+		else {
+			// Process the node
+			flags = getRouteFlags(pt, _nodes[idx]._walkPos, depthSurface);
+
+			int xDiff = ABS(_nodes[idx]._walkPos.x - pt.x);
+			int yDiff = ABS(_nodes[idx]._walkPos.y - pt.y);
+			hypotenuse = sqrt((double)(xDiff * xDiff + yDiff * yDiff));
+
+			if (hypotenuse >= 0x3FFF)
+				// Shouldn't ever be this large
+				hypotenuse = 0x3FFF;
+
+			entry = hypotenuse | flags;
+			_nodes[idx]._indexes[nodeIndex] = entry;
+			_nodes[nodeIndex]._indexes[idx] = entry;
+		}
+	}
+}
+
+int SceneInfo::getRouteFlags(const Common::Point &src, const Common::Point &dest, 
+		MSurface &depthSurface) {
+	int result = 0x8000;
+	bool flag = false;
+
+	int xDiff = ABS(dest.x - src.x);
+	int yDiff = ABS(dest.y - src.y);
+	int xDirection = dest.x >= src.x ? 1 : -1;
+	int yDirection = dest.y >= src.y ? depthSurface.w : -depthSurface.w;
+	int majorDiff = 0;
+	if (dest.x < src.x)
+		majorDiff = MAX(xDiff, yDiff);
+	++xDiff;
+	++yDiff;
+
+	byte *srcP = depthSurface.getBasePtr(src.x, src.y);
+
+	int totalCtr = majorDiff;
+	for (int xCtr = 0; xCtr < xDiff; ++xCtr, srcP += xDirection) {
+		totalCtr += yDiff;
+
+		if ((*srcP & 0x80) == 0)
+			flag = false;
+		else if (!flag) {
+			flag = true;
+			result -= 0x4000;
+			if (result == 0)
+				break;
+		}
+
+		while (totalCtr >= xDiff) {
+			totalCtr -= xDiff;
+
+			if ((*srcP & 0x80) == 0)
+				flag = false;
+			else if (!flag) {
+				flag = true;
+				result -= 0x4000;
+				if (result == 0)
+					break;
+			}
+
+			srcP += yDirection;
+		}
+		if (result == 0)
+			break;
+	}
+
+	return result;
+}
+
 /*------------------------------------------------------------------------*/
 
 SceneInfo *SceneInfo::init(MADSEngine *vm) {
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index ffea369..00edefb 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -251,6 +251,9 @@ class SceneInfo {
 
 		void load(Common::SeekableReadStream *f);
 	};
+
+
+	int getRouteFlags(const Common::Point &src, const Common::Point &dest, MSurface &depthSurface);
 protected:
 	MADSEngine *_vm;
 
@@ -301,6 +304,11 @@ public:
 	 */
 	void load(int sceneId, int flags, const Common::String &resName, int v3, 
 		MSurface &depthSurface, MSurface &bgSurface);
+
+	/**
+	 * Set up a route node
+	 */
+	void setRouteNode(int nodeIndex, const Common::Point &pt, MSurface &depthSurface);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index cbd4573..3b3fc93 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -42,7 +42,7 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm) {
 	_inventoryTopIndex = 0;
 	_objectY = 0;
 
-	byte *pData = _vm->_screen.getBasePtr(0, MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT);
+	byte *pData = _vm->_screen.getBasePtr(0, MADS_SCENE_HEIGHT);
 	setPixels(pData, MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
 }
 
@@ -270,7 +270,7 @@ bool UserInterface::getBounds(ScrCategory category, int v, Common::Rect &bounds)
 }
 
 void UserInterface::moveRect(Common::Rect &bounds) {
-	bounds.translate(0, MADS_SCREEN_HEIGHT - MADS_INTERFACE_HEIGHT);
+	bounds.translate(0, MADS_SCENE_HEIGHT);
 }
 
 } // End of namespace MADS


Commit: 74da0c2ef7a5a77ddfcda26b28ebdeab68a9f8f5
    https://github.com/scummvm/scummvm/commit/74da0c2ef7a5a77ddfcda26b28ebdeab68a9f8f5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-16T15:50:17-04:00

Commit Message:
MADS: Fix for loading player sprites during scene startup

Changed paths:
    engines/mads/player.cpp



diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index fe1065c..c3ce270 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -104,10 +104,12 @@ bool Player::loadSprites(const Common::String &prefix) {
 				_highSprites = true;
 
 			_spriteSetsPresent[fileIndex] = true;
-			int setIndex = _vm->_game->_scene._sprites.addSprites(setName, 4);
-			if (setIndex >= 0) {
+
+			int setIndex = -1;
+			if (Common::File::exists(setName)) {
+				setIndex = _vm->_game->_scene._sprites.addSprites(setName, 4);
 				++_numSprites;
-			}  else if (fileIndex >= 5) {
+			}  else if (fileIndex < 5) {
 				_highSprites = 0;
 				return true;
 			} else {


Commit: d599c7c404729217cf4cf85ee02b2d8b3f3b9ec9
    https://github.com/scummvm/scummvm/commit/d599c7c404729217cf4cf85ee02b2d8b3f3b9ec9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-16T16:50:53-04:00

Commit Message:
MADS: Fix to display player

Changed paths:
    engines/mads/game.cpp
    engines/mads/nebular/game_nebular.cpp
    engines/mads/player.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index af23998..03c0544 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -89,6 +89,7 @@ void Game::run() {
 		break;
 	default:
 		_scene._nextSceneId = 103;
+		_scene._priorSceneId = 102;
 		break;
 	}
 
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 91c10a5..e5c344b 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -54,7 +54,7 @@ int GameNebular::checkCopyProtection() {
 	*/
 
 	// DEBUG: Return that copy protection failed
-	return 0;
+	return -2;
 }
 
 void GameNebular::initialiseGlobals() {
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index c3ce270..3fc7ca5 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -362,8 +362,8 @@ void Player::setDest(const Common::Point &pt, int facing) {
 void Player::nextFrame() {
 	Scene &scene = _vm->_game->_scene;
 
-	_priorTimer += _ticksAmount;
-	if (scene._frameStartTime >= _priorTimer) {
+	uint32 newTime = _priorTimer + _ticksAmount;
+	if (scene._frameStartTime >= newTime) {
 		_priorTimer = scene._frameStartTime;
 		if (_moving) {
 			move();


Commit: 4dd057edd93bdb121cd046bfc1b2d770c5c0dbc4
    https://github.com/scummvm/scummvm/commit/4dd057edd93bdb121cd046bfc1b2d770c5c0dbc4
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-16T22:46:28+01:00

Commit Message:
MADS: First real try - Implement Scene201::enter()

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index ec8af4c..3eff596 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -79,6 +79,77 @@ void Scene201::setup() {
 }
 
 void Scene201::enter() {
+	if ((_globals._frameTime) && (_vm->getRandomNumber(5000) == 9)) {
+		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 5, 1, 6, 0);
+		int idx = _scene->_dynamicHotspots.add(351, 13, _globals._spriteIndexes[20], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, 270, 80, 6);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[20], 8);
+		_vm->_sound->command(14);
+		_globals._frameTime = 0;
+	}
+	
+	if (_game._abortTimers == 70) {
+		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 9, 1, 0, 0);
+		_game._player._visible = false;
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[21], 12, 16);
+		_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 9, 1, 0, 0);
+		_vm->_sound->command(42);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 1);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[22], 1);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_FRAME_INDEX, 3, 81);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 71);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 73);
+	}
+
+	if (_game._abortTimers == 81) {
+		_scene->_kernelMessages.reset();
+	}
+
+	if (_game._abortTimers == 71) {
+		_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 9, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[22], -2, -2);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[22], 1);
+	}
+
+	if (_game._abortTimers == 73) {
+		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 9, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[21], 17, -2);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 74);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 1);
+	}
+
+	if (_game._abortTimers == 74) {
+		_vm->_sound->command(40);
+
+		_scene->_kernelMessages.add(Common::Point(125, 56), 0xFDFC, 32, 82, 180, _game.getQuote(91));
+		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 9, 0, 0, 0);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 1);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[21], -2, -2);
+		_scene->_sequences.addTimer(180, 75);
+	}
+
+	if (_game._abortTimers == 75) {
+		_globals[37] = 0;
+		_scene->_nextSceneId = 202;
+	}
+
+	if (_game._abortTimers == 76) {
+		_game._player._stepEnabled = true;
+		_game._player._visible = true;
+		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+	}
+
+	if (_game._abortTimers == 77) {
+		_globals[39] = 1;
+		_scene->_nextSceneId = _globals[40];
+		_scene->_reloadSceneFlag = true;
+	}
+
+	if (_game._abortTimers == 78) {
+		_vm->_sound->command(40);
+		Dialog::show(0x4E92);
+		_scene->_reloadSceneFlag = true;
+	}
 }
 
 void Scene201::step() {


Commit: 39a36064ac91ad7864c04dfe4d88c97824f070ae
    https://github.com/scummvm/scummvm/commit/39a36064ac91ad7864c04dfe4d88c97824f070ae
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-16T17:50:47-04:00

Commit Message:
MADS: In progress text draw methods for user interface

Changed paths:
    engines/mads/scene.cpp
    engines/mads/scene_data.cpp
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 9ece16f..0258f15 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -393,7 +393,7 @@ void Scene::doFrame() {
 
 			// Write any text needed by the interface
 			if (_vm->_game->_abortTimers2)
-				_userInterface.writeText();
+				_userInterface.drawTextElements();
 
 			// Draw any elements
 			drawElements((ScreenTransition)_vm->_game->_abortTimers2, _vm->_game->_abortTimers2);
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 04dfc4b..bbc6e1c 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -45,7 +45,6 @@ ScreenObjects::ScreenObjects(MADSEngine *vm): _vm(vm) {
 	_v7FECA = 0;
 	_v7FED6 = 0;
 	_v8332A = 0;
-	_selectedObject = 0;
 	_category = CAT_NONE;
 	_objectIndex = 0;
 	_released = false;
@@ -70,10 +69,10 @@ void ScreenObjects::check(bool scanFlag) {
 		_v7FECA = false;
 
 	if ((_vm->_events->_vD6 || _v8332A || _yp || _v8333C) && scanFlag) {
-		_selectedObject = scanBackwards(_vm->_events->currentPos(), LAYER_GUI);
-		if (_selectedObject > 0) {
-			_category = (ScrCategory)((*this)[_selectedObject - 1]._category & 7);
-			_objectIndex = (*this)[_selectedObject - 1]._descId;
+		scene._userInterface._selectedObject = scanBackwards(_vm->_events->currentPos(), LAYER_GUI);
+		if (scene._userInterface._selectedObject > 0) {
+			_category = (ScrCategory)((*this)[scene._userInterface._selectedObject - 1]._category & 7);
+			_objectIndex = (*this)[scene._userInterface._selectedObject - 1]._descId;
 		}
 
 		// Handling for easy mouse
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 3b3fc93..9cff221 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -41,6 +41,7 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm) {
 	_screenObjectsCount = 0;
 	_inventoryTopIndex = 0;
 	_objectY = 0;
+	_selectedObject = -1;
 
 	byte *pData = _vm->_screen.getBasePtr(0, MADS_SCENE_HEIGHT);
 	setPixels(pData, MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
@@ -106,7 +107,7 @@ void UserInterface::setup(int id) {
 		scene._imageInterEntries.call(0, 0);
 
 	scene._action.clear();
-	writeText();
+	drawTextElements();
 	loadElements();
 	scene._dynamicHotspots.refresh();
 }
@@ -115,10 +116,38 @@ void UserInterface::elementHighlighted() {
 	warning("TODO: UserInterface::elementHighlighted");
 }
 
-void UserInterface::writeText() {
-	warning("TODO: UserInterface::writeText");
+void UserInterface::drawTextElements() {
+	Scene &scene = _vm->_game->_scene;
+	if (scene._screenObjects._v832EC) {
+		drawTalkList();
+	} else {
+		// Draw the actions
+		drawActions();
+		drawInventoryList();
+		drawItemVocabList();
+	}
+}
+
+void UserInterface::drawActions() {
+	for (int idx = 0; idx < 10; ++idx) {
+		drawVocab(CAT_ACTION, idx);
+	}
+}
+
+void UserInterface::drawInventoryList() {
+	int endIndex = MIN((int)_vm->_game->_objects._inventoryList.size(), _inventoryTopIndex + 5);
+	for (int idx = _inventoryTopIndex; idx < endIndex; ++idx) {
+		drawVocab(CAT_INV_LIST, idx);
+	}
 }
 
+void UserInterface::drawItemVocabList() {
+
+}
+
+void UserInterface::drawVocab(ScrCategory category, int id) {
+
+}
 
 void UserInterface::setBounds(const Common::Rect &r) {
 	_bounds = r;
@@ -273,4 +302,9 @@ void UserInterface::moveRect(Common::Rect &bounds) {
 	bounds.translate(0, MADS_SCENE_HEIGHT);
 }
 
+void UserInterface::drawTalkList() {
+	warning("TODO: drawTalkList");
+}
+
+
 } // End of namespace MADS
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index d50a820..e3a1b20 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -54,6 +54,31 @@ private:
 	 * Reposition a bounding rectangle to physical co-ordinates
 	 */
 	void moveRect(Common::Rect &bounds);
+
+	/**
+	 * Draw options during a conversation.
+	 */
+	void drawTalkList();
+
+	/**
+	 * Draw the action list
+	 */
+	void drawActions();
+
+	/**
+	 * Draw the inventory list
+	 */
+	void drawInventoryList();
+
+	/**
+	 * Draw the inventory item vocab list
+	 */
+	void drawItemVocabList();
+
+	/**
+	 * Draw a vocab text entry
+	 */
+	void drawVocab(ScrCategory category, int id);
 public:
 	ScrCategory _category;
 	int _screenObjectsCount;
@@ -62,6 +87,7 @@ public:
 	MSurface _surface;
 	int _inventoryTopIndex;
 	int _objectY;
+	int _selectedObject;
 public:
 	/**
 	* Constructor
@@ -80,7 +106,7 @@ public:
 
 	void elementHighlighted();
 
-	void writeText();
+	void drawTextElements();
 
 	void setBounds(const Common::Rect &r);
 };


Commit: e24a4b7b16f5ded50974220d546b2ff0483f99f7
    https://github.com/scummvm/scummvm/commit/e24a4b7b16f5ded50974220d546b2ff0483f99f7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-16T17:55:47-04:00

Commit Message:
MADS: Fix for Scene2xx::setPlayerSpritesPrefix

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 3eff596..53e876b 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -58,7 +58,7 @@ void Scene2xx::setPlayerSpritesPrefix() {
 	else
 		_game._player._unk4 = -1;
 
-	if (oldName == _game._player._spritesPrefix)
+	if (oldName != _game._player._spritesPrefix)
 		_game._player._spritesChanged = true;
 	
 	if ((_scene->_nextSceneId == 203 || _scene->_nextSceneId == 204) && _globals[34])
@@ -68,6 +68,8 @@ void Scene2xx::setPlayerSpritesPrefix() {
 	_vm->_palette->setEntry(17, 10, 45, 45);
 }
 
+/*------------------------------------------------------------------------*/
+
 void Scene201::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();


Commit: acba8f9254a724ce9c57f5ddd81e6b9264c07274
    https://github.com/scummvm/scummvm/commit/acba8f9254a724ce9c57f5ddd81e6b9264c07274
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-16T23:40:21-04:00

Commit Message:
MADS: Implementing user interface text display methods

Changed paths:
    engines/mads/dialogs.cpp
    engines/mads/font.cpp
    engines/mads/font.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/inventory.h
    engines/mads/mads.cpp
    engines/mads/messages.cpp
    engines/mads/msurface.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index 571cca5..4c1a789 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -270,7 +270,7 @@ void TextDialog::draw() {
 				++yp;
 
 			_vm->_font->writeString(&_vm->_screen, _lines[lineNum], 
-				Common::Point(xp, yp), 0, 1);
+				Common::Point(xp, yp), 1);
 
 			if (_lineXp[lineNum] & 0x80) {
 				// Draw an underline under the text
diff --git a/engines/mads/font.cpp b/engines/mads/font.cpp
index b8f8187..205e653 100644
--- a/engines/mads/font.cpp
+++ b/engines/mads/font.cpp
@@ -28,14 +28,26 @@
 
 namespace MADS {
 
-Font::Font(MADSEngine *vm) : _vm(vm) {
+MADSEngine *Font::_vm = nullptr;
+
+uint8 Font::_fontColors[4];
+
+void Font::init(MADSEngine *vm) {
+	_vm = vm;
+	_fontColors[0] = 0xFF;
+	_fontColors[1] = 0xF;
+	_fontColors[2] = 7;
+	_fontColors[3] = 8;
+}
+
+Font *Font::getFont(const Common::String &fontName) {
+	Font *font = new Font();
+	font->setFont(fontName);
+	return font;
+}
+
+Font::Font() {
 	_sysFont = true;
-	/*
-	_fontColors[0] = _vm->_palette->BLACK;
-	_fontColors[1] = _vm->_palette->WHITE;
-	_fontColors[2] = _vm->_palette->BLACK;
-	_fontColors[3] = _vm->_palette->DARK_GRAY;
-	*/
 }
 
 Font::~Font() {
@@ -96,18 +108,28 @@ void Font::setColors(uint8 v1, uint8 v2, uint8 v3, uint8 v4) {
 	_fontColors[2] = v3;
 }
 
-int Font::write(MSurface *surface, const Common::String &msg, const Common::Point &pt, int width, int spaceWidth, uint8 colors[]) {
-
-	/*TODO
-	if (custom_ascii_converter) {			 // if there is a function to convert the extended ASCII characters
-		custom_ascii_converter(out_string);	 // call it with the string
+void Font::setColorMode(int mode) {
+	switch (mode) {
+	case 0:
+		setColors(0xFF, 4, 4, 0);
+		break;
+	case 1:
+		setColors(0xFF, 5, 5, 0);
+		break;
+	case 2:
+		setColors(0xFF, 6, 6, 0);
+		break;
+	default:
+		break;
 	}
-	*/
+}
 
+int Font::writeString(MSurface *surface, const Common::String &msg, const Common::Point &pt,
+		int spaceWidth, int width) {
 	if (width > 0)
-		width = MIN(surface->getWidth(), pt.x + width);
+		width = MIN((int)surface->w, pt.x + width);
 	else
-		width = surface->getWidth();
+		width = surface->w - pt.x;
 
 	int x = pt.x + 1;
 	int y = pt.y + 1;
@@ -154,16 +176,16 @@ int Font::write(MSurface *surface, const Common::String &msg, const Common::Poin
 			for (int i = 0; i < height; i++) {
 				for (int j = 0; j < bpp; j++) {
 					if (*charData & 0xc0)
-						*destPtr = colors[(*charData & 0xc0) >> 6];
+						*destPtr = _fontColors[(*charData & 0xc0) >> 6];
 					destPtr++;
 					if (*charData & 0x30)
-						*destPtr = colors[(*charData & 0x30) >> 4];
+						*destPtr = _fontColors[(*charData & 0x30) >> 4];
 					destPtr++;
 					if (*charData & 0x0C)
-						*destPtr = colors[(*charData & 0x0C) >> 2];
+						*destPtr = _fontColors[(*charData & 0x0C) >> 2];
 					destPtr++;
 					if (*charData & 0x03)
-						*destPtr = colors[*charData & 0x03];
+						*destPtr = _fontColors[*charData & 0x03];
 					destPtr++;
 					charData++;
 				}
@@ -205,10 +227,4 @@ int Font::getBpp(int charWidth) {
 		return 1;
 }
 
-Font *Font::getFont(const Common::String &fontName) {
-	Font *font = new Font(_vm);
-	font->setFont(fontName);
-	return font;
-}
-
 } // End of namespace MADS
diff --git a/engines/mads/font.h b/engines/mads/font.h
index c642831..9b3e5bc 100644
--- a/engines/mads/font.h
+++ b/engines/mads/font.h
@@ -41,38 +41,42 @@ namespace MADS {
 class MADSEngine;
 
 class Font {
-protected:
-	MADSEngine *_vm;
+private:
+	static uint8 _fontColors[4];
+	static MADSEngine *_vm;
+public:
+	/**
+	 * Initialise the font system
+	 */
+	static void init(MADSEngine *vm);
 
+	/**
+	* Returns a new Font instance using the specified font name
+	*/
+	static Font *getFont(const Common::String &fontName);
+protected:
 	uint8 _maxWidth, _maxHeight;
 	uint8 *_charWidths;
 	uint16 *_charOffs;
 	uint8 *_charData;
 	bool _sysFont;
 	Common::String _filename;
-	uint8 _fontColors[4];
 
 	int getBpp(int charWidth);
 public:
-	Font(MADSEngine *vm);
+	Font();
 	virtual ~Font();
 
 	void setFont(const Common::String &filename);
 	void setColor(uint8 color);
 	void setColors(uint8 v1, uint8 v2, uint8 v3, uint8 v4);
+	void setColorMode(int mode);
 
 	int maxWidth() const { return _maxWidth; }
 	int getWidth(const Common::String &msg, int spaceWidth = -1);
 	int getHeight() const { return _maxHeight; }
-	int write(MSurface *surface, const Common::String &msg, const Common::Point &pt, int width, int spaceWidth, uint8 colors[]);
-	int writeString(MSurface *surface, const Common::String &msg, const Common::Point &pt, int width = 0, int spaceWidth = -1) {
-		return write(surface, msg, pt, width, spaceWidth, _fontColors);
-	}
-
-	/**
-	 * Returns a new Font instance using the specified font name
-	 */
-	Font *getFont(const Common::String &fontName);
+	int writeString(MSurface *surface, const Common::String &msg, const Common::Point &pt,
+		int spaceWidth = 0, int width = 0);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 03c0544..3778e83 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -165,7 +165,7 @@ void Game::sectionLoop() {
 
 		_scene._screenObjects._v8333C = true;
 		_scene._screenObjects._v832EC = 0;
-		_scene._screenObjects._yp = 0;
+		_scene._userInterface._scrollerY = 0;
 		_v3 = -1;
 
 		_scene._sceneLogic->setup();
@@ -196,9 +196,9 @@ void Game::sectionLoop() {
 		}
 
 		_vm->_events->initVars();
-		_scene._v1A = true;
-		_scene._v1C = -1;
-		_objectHiliteVocabIdx = -1;
+		_scene._userInterface._v1A = -1;
+		_scene._userInterface._v1C = -1;
+		_scene._userInterface._v1E = -1;
 
 		_scene._action.clear();
 		_player.turnToDestFacing();
@@ -297,7 +297,6 @@ void Game::loadResourceSequence(const Common::String prefix, int v) {
 
 void Game::loadQuotes() {
 	File f("*QUOTES.DAT");
-	int curPos = 0;
 
 	Common::String msg;
 	while (true) {
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 8e1559e..6ef1ca9 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -129,7 +129,6 @@ public:
 	uint32 _priorFrameTimer;
 	Common::String _aaName;
 	uint32 _ticksExpiry;
-	int _objectHiliteVocabIdx;
 	int _exitFlag;
 public:
 	virtual ~Game();
diff --git a/engines/mads/inventory.h b/engines/mads/inventory.h
index 57ae43b..1eef0f7 100644
--- a/engines/mads/inventory.h
+++ b/engines/mads/inventory.h
@@ -67,6 +67,13 @@ public:
 	void load();
 
 	/**
+	 * Returns the inventory item from the player's inventory
+	 */
+	InventoryObject &getItem(int itemIndex) {
+		return (*this)[_inventoryList[itemIndex]];
+	}
+
+	/**
 	 * Set the associated data? pointer with an inventory object
 	 */
 	void setData(int objIndex, int id, const byte *p);
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index ded9487..80a797b 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -80,7 +80,8 @@ void MADSEngine::initialise() {
 	_dialogs = Dialogs::init(this);
 	_events = new EventsManager(this);
 	_palette = new Palette(this);
-	_font = new Font(this);
+	Font::init(this);
+	_font = new Font();
 	_screen.init();
 	_sound = new SoundManager(this, _mixer);
 	_game = Game::init(this);
diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index a9ce093..c355dac 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -391,7 +391,7 @@ void TextDisplayList::draw(MSurface *s) {
 			td._font->setColors(0xFF, td._color1, td._color2, 0);
 			td._font->writeString(s, td._msg,
 				Common::Point(td._bounds.left, td._bounds.top), 
-				td._bounds.width(), td._spacing);
+				td._spacing, td._bounds.width());
 		}
 	}
 }
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 65858f5..3ce5bda 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -58,8 +58,9 @@ void MSurface::setSize(int width, int height) {
 void MSurface::setPixels(byte *pData, int horizSize, int vertSize) {
 	_freeFlag = false;
 	pixels = pData;
-	w = horizSize;
+	w = pitch = horizSize;
 	h = vertSize;
+	format.bytesPerPixel = 1;
 }
 
 int MSurface::scaleValue(int value, int scale, int err) {
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 0258f15..88533a9 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -35,14 +35,11 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 	_priorSceneId = 0;
 	_nextSceneId = 0;
 	_currentSceneId = 0;
-	_vocabBuffer = nullptr;
 	_sceneLogic = nullptr;
 	_sceneInfo = nullptr;
 	_animFlag = false;
 	_animVal1 = 0;
 	_depthStyle = 0;
-	_v1A = 0;
-	_v1C = 0;
 	_roomChanged = false;
 	_reloadSceneFlag = false;
 	_destFacing = 0;
@@ -66,21 +63,14 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 }
 
 Scene::~Scene() {
-	delete[] _vocabBuffer;
 	delete _sceneLogic;
 	delete _sceneInfo;
 }
 
 void Scene::clearVocab() {
-	freeVocab();
 	_activeVocabs.clear();
 }
 
-void Scene::freeVocab() {
-	delete[] _vocabBuffer;
-	_vocabBuffer = nullptr;
-}
-
 void Scene::addActiveVocab(int vocabId) {
 	if (activeVocabIndexOf(vocabId) == -1) {
 		assert(_activeVocabs.size() < 200);
@@ -222,21 +212,22 @@ void Scene::loadVocab() {
 }
 
 void Scene::loadVocabStrings() {
-	freeVocab();
+	_vocabStrings.clear();
 	File f("*VOCAB.DAT");
+	Common::String msg;
 
-	char *textStrings = new char[f.size()];
-	f.read(textStrings, f.size());
-
-	for (uint strIndex = 0; strIndex < _activeVocabs.size(); ++strIndex) {
-		const char *s = textStrings;
-		for (int vocabIndex = 0; vocabIndex < _activeVocabs[strIndex]; ++vocabIndex)
-			s += strlen(s) + 1;
+	for (;;) {
+		char c = (char)f.readByte();
+		if (f.eos()) break;
 
-		_vocabStrings.push_back(s);
+		if (c == '\0') {
+			_vocabStrings.push_back(msg);
+			msg = "";
+		} else {
+			msg += c;
+		}
 	}
 
-	delete[] textStrings;
 	f.close();
 }
 
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index d88f5ec..dce799a 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -42,11 +42,6 @@ namespace MADS {
 class Scene {
 private:
 	/**
-	 * Free the voculary list buffer
-	 */
-	void freeVocab();
-
-	/**
 	 * Return the index of a given Vocab in the active vocab list
 	 */
 	int activeVocabIndexOf(int vocabId);
@@ -88,7 +83,6 @@ public:
 	SpriteSets _sprites;
 	int _spritesIndex;
 	DynamicHotspots _dynamicHotspots;
-	byte *_vocabBuffer;
 	Common::Array<int> _activeVocabs;
 	SequenceList _sequences;
 	KernelMessages _kernelMessages;
@@ -118,8 +112,6 @@ public:
 	int _scaleRange;
 	int _interfaceY;
 	int _spritesCount;
-	bool _v1A;
-	int _v1C;
 	MADSAction _action;
 	bool _roomChanged;
 	bool _reloadSceneFlag;
@@ -205,6 +197,11 @@ public:
 	void loadAnimation(const Common::String &resName, int abortTimers = 0);
 
 	/**
+	 * Returns a vocab entry
+	 */
+	Common::String getVocab(int vocabId) { return _vocabStrings[vocabId]; }
+
+	/**
 	 * Clear the data for the scene
 	 */
 	void free();
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index bbc6e1c..c37f0b1 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -41,7 +41,6 @@ ScreenObject::ScreenObject() {
 ScreenObjects::ScreenObjects(MADSEngine *vm): _vm(vm) {
 	_v8333C = false;
 	_v832EC = 0;
-	_yp = 0;
 	_v7FECA = 0;
 	_v7FED6 = 0;
 	_v8332A = 0;
@@ -68,11 +67,11 @@ void ScreenObjects::check(bool scanFlag) {
 	if (!_vm->_events->_mouseButtons || _v832EC)
 		_v7FECA = false;
 
-	if ((_vm->_events->_vD6 || _v8332A || _yp || _v8333C) && scanFlag) {
-		scene._userInterface._selectedObject = scanBackwards(_vm->_events->currentPos(), LAYER_GUI);
-		if (scene._userInterface._selectedObject > 0) {
-			_category = (ScrCategory)((*this)[scene._userInterface._selectedObject - 1]._category & 7);
-			_objectIndex = (*this)[scene._userInterface._selectedObject - 1]._descId;
+	if ((_vm->_events->_vD6 || _v8332A || _vm->_game->_scene._userInterface._scrollerY || _v8333C) && scanFlag) {
+		scene._userInterface._selectedInvIndex = scanBackwards(_vm->_events->currentPos(), LAYER_GUI);
+		if (scene._userInterface._selectedInvIndex > 0) {
+			_category = (ScrCategory)((*this)[scene._userInterface._selectedInvIndex - 1]._category & 7);
+			_objectIndex = (*this)[scene._userInterface._selectedInvIndex - 1]._descId;
 		}
 
 		// Handling for easy mouse
@@ -80,7 +79,7 @@ void ScreenObjects::check(bool scanFlag) {
 		if (_vm->_easyMouse && !_vm->_events->_vD4 && category != _category
 				&& scene._userInterface._category != CAT_NONE) {
 			_released = true;
-			if (category >= CAT_ACTION && category <= CAT_6) {
+			if (category >= CAT_ACTION && category <= CAT_TALK_ENTRY) {
 				scene._userInterface.elementHighlighted();
 			} 
 		}
@@ -90,7 +89,7 @@ void ScreenObjects::check(bool scanFlag) {
 			scene._userInterface._category = _category;
 
 		if (!_vm->_events->_mouseButtons || _vm->_easyMouse) {
-			if (category >= CAT_ACTION && category <= CAT_6) {
+			if (category >= CAT_ACTION && category <= CAT_TALK_ENTRY) {
 				scene._userInterface.elementHighlighted();
 			}
 		}
@@ -106,7 +105,7 @@ void ScreenObjects::check(bool scanFlag) {
 			scene._userInterface._category = CAT_NONE;
 		}
 
-		if (_vm->_events->_mouseButtons || _vm->_easyMouse || _yp)
+		if (_vm->_events->_mouseButtons || _vm->_easyMouse || scene._userInterface._scrollerY)
 			proc1();
 
 		if (_vm->_events->_mouseButtons || _vm->_easyMouse)
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 00edefb..f2893c5 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -87,7 +87,6 @@ public:
 	int _v7FECA;
 	int _v7FED6;
 	int _v8332A;
-	int _yp;
 	int _v8333C;
 	int _selectedObject;
 	ScrCategory _category;
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 9cff221..985e288 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -41,7 +41,13 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm) {
 	_screenObjectsCount = 0;
 	_inventoryTopIndex = 0;
 	_objectY = 0;
-	_selectedObject = -1;
+	_selectedInvIndex = -1;
+	_selectedActionIndex = -1;
+	_selectedItemVocabIdx = -1;
+	_scrollerY = 0;
+	_v1A = -1;
+	_v1C = -1;
+	_v1E = -1;
 
 	byte *pData = _vm->_screen.getBasePtr(0, MADS_SCENE_HEIGHT);
 	setPixels(pData, MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
@@ -96,9 +102,9 @@ void UserInterface::setup(int id) {
 	scene._imageInterEntries.clear();
 	scene._imageInterEntries.add(-2, 0xff);
 	_vm->_game->_ticksExpiry = _vm->_events->getFrameCounter();
-	scene._v1A = true;
-	_vm->_game->_objectHiliteVocabIdx = -1;
-	scene._v1C = -1;
+	_v1A = -1;
+	_v1E = -1;
+	_v1C = -1;
 
 	// Make a copy of the surface
 	copyTo(&_surface);
@@ -123,30 +129,118 @@ void UserInterface::drawTextElements() {
 	} else {
 		// Draw the actions
 		drawActions();
-		drawInventoryList();
-		drawItemVocabList();
+//		drawInventoryList();
+//		drawItemVocabList();
 	}
 }
 
 void UserInterface::drawActions() {
 	for (int idx = 0; idx < 10; ++idx) {
-		drawVocab(CAT_ACTION, idx);
+		writeVocab(CAT_ACTION, idx);
 	}
 }
 
 void UserInterface::drawInventoryList() {
 	int endIndex = MIN((int)_vm->_game->_objects._inventoryList.size(), _inventoryTopIndex + 5);
 	for (int idx = _inventoryTopIndex; idx < endIndex; ++idx) {
-		drawVocab(CAT_INV_LIST, idx);
+		writeVocab(CAT_INV_LIST, idx);
 	}
 }
 
 void UserInterface::drawItemVocabList() {
+	if (_selectedInvIndex >= 0) {
+		InventoryObject &io = _vm->_game->_objects[
+			_vm->_game->_objects._inventoryList[_selectedInvIndex]];
+		for (int idx = 0; idx < io._vocabCount; ++idx) {
+			writeVocab(CAT_INV_VOCAB, idx);
+		}
+	}
+}
 
+void UserInterface::drawScrolller() {
+	if (_scrollerY > 0)
+		writeVocab(CAT_INV_SCROLLER, _scrollerY);
+	writeVocab(CAT_INV_SCROLLER, 4);
 }
 
-void UserInterface::drawVocab(ScrCategory category, int id) {
+void UserInterface::writeVocab(ScrCategory category, int id) {
+	Common::Rect bounds;
+	if (!getBounds(category, id, bounds))
+		return;
+
+	Scene &scene = _vm->_game->_scene;
+	Font *font = nullptr;
+
+	int vocabId;
+	Common::String vocabStr;
+	switch (category) {
+	case CAT_ACTION:
+		font = _vm->_font->getFont(FONT_INTERFACE);
+		vocabId = scene._verbList[id]._id;
+		if (_v1A) {
+			_vm->_font->setColorMode(1);
+		} else {
+			_vm->_font->setColorMode(id == _selectedActionIndex ? 2 : 0);
+		}
+		vocabStr = scene.getVocab(vocabId);
+		vocabStr.toUppercase();
+		font->writeString(this, vocabStr, Common::Point(bounds.left, bounds.top));
+		break;
+
+	case CAT_INV_LIST:
+		font = _vm->_font->getFont(FONT_INTERFACE);
+		vocabId = _vm->_game->_objects.getItem(id)._descId;
+		if (_v1C == id) {
+			_vm->_font->setColorMode(1);
+		} else {
+			_vm->_font->setColorMode(id == _selectedInvIndex ? 2 : 0);
+			vocabStr = scene.getVocab(vocabId);
+			vocabStr.toUppercase();
+			font->writeString(this, vocabStr, Common::Point(bounds.left, bounds.top));
+			break;
+		}
+		break;
+
+	case CAT_TALK_ENTRY:
+		error("TODO: CAT_TALK_ENTRY");
+
+	case CAT_INV_SCROLLER:
+		font = _vm->_font->getFont(FONT_MISC);
 
+		switch (id) {
+		case 1:
+			vocabStr = "a";
+			break;
+		case 2:
+			vocabStr = "b";
+			break;
+		case 3:
+			vocabStr = "d";
+			break;
+		case 4:
+			vocabStr = "c";
+			break;
+		default:
+			break;
+		}
+
+		font->setColorMode((id == 4) || (_scrollerY == 3) ? 1 : 0);
+		font->writeString(this, vocabStr, Common::Point(bounds.left, bounds.top));
+		break;
+	default:
+		font = _vm->_font->getFont(FONT_INTERFACE);
+		vocabId = _vm->_game->_objects.getItem(_selectedInvIndex)._vocabList[id]._vocabId;
+		if (_v1E == id) {
+			_vm->_font->setColorMode(1);
+		} else {
+			_vm->_font->setColorMode(id == _selectedInvIndex ? 2 : 0);
+			vocabStr = scene.getVocab(vocabId);
+			vocabStr.toUppercase();
+			font->writeString(this, vocabStr, Common::Point(bounds.left, bounds.top));
+			break;
+		}
+		break;
+	}
 }
 
 void UserInterface::setBounds(const Common::Rect &r) {
@@ -204,23 +298,23 @@ void UserInterface::loadElements() {
 	}
 
 	if (scene._screenObjects._v832EC == 1) {
+		// setup areas for talk entries
 		for (int idx = 0; idx < 5; ++idx) {
-			getBounds(CAT_6, idx, bounds);
+			getBounds(CAT_TALK_ENTRY, idx, bounds);
 			moveRect(bounds);
 
-			scene._screenObjects.add(bounds, LAYER_GUI, CAT_6, idx);
+			scene._screenObjects.add(bounds, LAYER_GUI, CAT_TALK_ENTRY, idx);
 		}
 	}
 }
 
 bool UserInterface::getBounds(ScrCategory category, int v, Common::Rect &bounds) {
-	Common::Rect result;
 	int heightMultiplier, widthMultiplier;
 	int leftStart, yOffset, widthAmt;
 
 	switch (category) {
 	case CAT_ACTION:
-		heightMultiplier = v / 5;
+		heightMultiplier = v % 5;
 		widthMultiplier = v / 5;
 		leftStart = 2;
 		yOffset = 3;
@@ -238,7 +332,7 @@ bool UserInterface::getBounds(ScrCategory category, int v, Common::Rect &bounds)
 		widthAmt = 69;
 		break;
 
-	case CAT_6:
+	case CAT_TALK_ENTRY:
 		heightMultiplier = v;
 		widthMultiplier = 0;
 		leftStart = 2;
@@ -263,32 +357,32 @@ bool UserInterface::getBounds(ScrCategory category, int v, Common::Rect &bounds)
 		break;
 	}
 
-	result.left = (widthMultiplier > 0) ? widthMultiplier * widthAmt + leftStart : leftStart;
-	result.setWidth(widthAmt);
-	result.top = heightMultiplier * 3 + yOffset;
-	result.setHeight(8);
+	bounds.left = (widthMultiplier > 0) ? widthMultiplier * widthAmt + leftStart : leftStart;
+	bounds.setWidth(widthAmt);
+	bounds.top = heightMultiplier * 8 + yOffset;
+	bounds.setHeight(8);
 
 	if (category == CAT_INV_SCROLLER) {
 		switch (v) {
 		case 1:
 			// Arrow up
-			result.top = 4;
-			result.setHeight(7);
+			bounds.top = 4;
+			bounds.setHeight(7);
 			break;
 		case 2:
 			// Arrow down
-			result.top = 35;
-			result.setHeight(7);
+			bounds.top = 35;
+			bounds.setHeight(7);
 			break;
 		case 3:
 			// Scroller
-			result.top = 12;
-			result.setHeight(22);
+			bounds.top = 12;
+			bounds.setHeight(22);
 			break;
 		case 4:
 			// Thumb
-			result.top = _objectY + 14;
-			result.setHeight(1);
+			bounds.top = _objectY + 14;
+			bounds.setHeight(1);
 			break;
 		default:
 			break;
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index e3a1b20..cab2653 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -32,7 +32,7 @@ namespace MADS {
 
 enum ScrCategory {
 	CAT_NONE = 0, CAT_ACTION = 1, CAT_INV_LIST = 2, CAT_INV_VOCAB = 3,
-	CAT_HOTSPOT = 4, CAT_INV_ANIM = 5, CAT_6 = 6, CAT_INV_SCROLLER = 7,
+	CAT_HOTSPOT = 4, CAT_INV_ANIM = 5, CAT_TALK_ENTRY = 6, CAT_INV_SCROLLER = 7,
 	CAT_12 = 12
 };
 
@@ -76,9 +76,14 @@ private:
 	void drawItemVocabList();
 
 	/**
-	 * Draw a vocab text entry
+	 * Draw the inventory scroller
 	 */
-	void drawVocab(ScrCategory category, int id);
+	void drawScrolller();
+
+	/**
+	 * Draw a UI textual element
+	 */
+	void writeVocab(ScrCategory category, int id);
 public:
 	ScrCategory _category;
 	int _screenObjectsCount;
@@ -87,7 +92,13 @@ public:
 	MSurface _surface;
 	int _inventoryTopIndex;
 	int _objectY;
-	int _selectedObject;
+	int _selectedInvIndex;
+	int _selectedActionIndex;
+	int _selectedItemVocabIdx;
+	int _scrollerY;
+	int _v1A;
+	int _v1C;
+	int _v1E;
 public:
 	/**
 	* Constructor


Commit: b831323c85bb1ca26368cee6690d4664c37e9c0b
    https://github.com/scummvm/scummvm/commit/b831323c85bb1ca26368cee6690d4664c37e9c0b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-17T00:00:22-04:00

Commit Message:
MADS: Added caching for font instances

Changed paths:
    engines/mads/dialogs.cpp
    engines/mads/font.cpp
    engines/mads/font.h
    engines/mads/mads.cpp
    engines/mads/messages.cpp



diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index 4c1a789..333bbe9 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -106,7 +106,6 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName,
 	_fontName = fontName;
 	_position = pos;
 	
-	_vm->_font->setFont(FONT_INTERFACE);
 	_vm->_font->setColors(TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK);
 
 	_innerWidth = (_vm->_font->maxWidth() + 1) * maxChars;
diff --git a/engines/mads/font.cpp b/engines/mads/font.cpp
index 205e653..ed7542d 100644
--- a/engines/mads/font.cpp
+++ b/engines/mads/font.cpp
@@ -28,7 +28,9 @@
 
 namespace MADS {
 
-MADSEngine *Font::_vm = nullptr;
+MADSEngine *Font::_vm;
+
+Common::HashMap<Common::String, Font *> *Font::_fonts;
 
 uint8 Font::_fontColors[4];
 
@@ -38,24 +40,40 @@ void Font::init(MADSEngine *vm) {
 	_fontColors[1] = 0xF;
 	_fontColors[2] = 7;
 	_fontColors[3] = 8;
+
+	_fonts = new Common::HashMap<Common::String, Font *>();
+}
+
+void Font::deinit() {
+	Common::HashMap<Common::String, Font *>::iterator i;
+	for (i = _fonts->begin(); i != _fonts->end(); ++i)
+		delete (*i)._value;
+
+	delete _fonts;
 }
 
 Font *Font::getFont(const Common::String &fontName) {
-	Font *font = new Font();
-	font->setFont(fontName);
-	return font;
+	if (_fonts->contains(fontName)) {
+		return _fonts->getVal(fontName);
+	} else {
+		Font *font = new Font(fontName);
+		_fonts->setVal(fontName, font);
+		return font;
+	}
 }
 
 Font::Font() {
-	_sysFont = true;
+	setFont(FONT_INTERFACE);
+}
+
+Font::Font(const Common::String &filename) {
+	setFont(filename);
 }
 
 Font::~Font() {
-	if (!_sysFont) {
-		delete[] _charWidths;
-		delete[] _charOffs;
-		delete[] _charData;
-	}
+	delete[] _charWidths;
+	delete[] _charOffs;
+	delete[] _charData;
 }
 
 void Font::setFont(const Common::String &filename) {
@@ -63,7 +81,6 @@ void Font::setFont(const Common::String &filename) {
 		// Already using specified font, so don't bother reloading
 		return;
 
-	_sysFont = false;
 	_filename = filename;
 
 	MadsPack fontData(filename, _vm);
@@ -95,13 +112,6 @@ void Font::setFont(const Common::String &filename) {
 	delete fontFile;
 }
 
-void Font::setColor(uint8 color) {
-	if (_sysFont)
-		_fontColors[1] = color;
-	else 
-		_fontColors[3] = color;		
-}
-
 void Font::setColors(uint8 v1, uint8 v2, uint8 v3, uint8 v4) {
 	_fontColors[0] = v1;
 	_fontColors[1] = v2;
diff --git a/engines/mads/font.h b/engines/mads/font.h
index 9b3e5bc..5079f12 100644
--- a/engines/mads/font.h
+++ b/engines/mads/font.h
@@ -24,8 +24,9 @@
 #define MADS_FONT_H
 
 #include "common/scummsys.h"
-#include "common/util.h"
+#include "common/hashmap.h"
 #include "common/endian.h"
+#include "common/util.h"
 #include "mads/msurface.h"
 
 namespace MADS {
@@ -44,6 +45,7 @@ class Font {
 private:
 	static uint8 _fontColors[4];
 	static MADSEngine *_vm;
+	static Common::HashMap<Common::String, Font *> *_fonts;
 public:
 	/**
 	 * Initialise the font system
@@ -51,24 +53,29 @@ public:
 	static void init(MADSEngine *vm);
 
 	/**
+	 * Free up the resources used by the font
+	 */
+	static void deinit();
+
+	/**
 	* Returns a new Font instance using the specified font name
 	*/
 	static Font *getFont(const Common::String &fontName);
-protected:
+private:
 	uint8 _maxWidth, _maxHeight;
 	uint8 *_charWidths;
 	uint16 *_charOffs;
 	uint8 *_charData;
-	bool _sysFont;
 	Common::String _filename;
 
 	int getBpp(int charWidth);
+
+	void setFont(const Common::String &filename);
 public:
 	Font();
+	Font(const Common::String &filename);
 	virtual ~Font();
 
-	void setFont(const Common::String &filename);
-	void setColor(uint8 color);
 	void setColors(uint8 v1, uint8 v2, uint8 v3, uint8 v4);
 	void setColorMode(int mode);
 
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 80a797b..1785ce3 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -59,6 +59,7 @@ MADSEngine::~MADSEngine() {
 	delete _dialogs;
 	delete _events;
 	delete _font;
+	Font::deinit();
 	delete _game;
 	delete _palette;
 	delete _resources;
diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index c355dac..592dd4b 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -40,7 +40,6 @@ KernelMessages::KernelMessages(MADSEngine *vm): _vm(vm) {
 }
 
 KernelMessages::~KernelMessages() {
-	delete _talkFont;
 }
 
 void KernelMessages::clear() {


Commit: e6b73f4938e2bdb3601f6d567336fe8167ea7e1f
    https://github.com/scummvm/scummvm/commit/e6b73f4938e2bdb3601f6d567336fe8167ea7e1f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-17T00:20:50-04:00

Commit Message:
MADS: Actions text in the UI now displaying correctly

Changed paths:
    engines/mads/scene.h
    engines/mads/user_interface.cpp



diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index dce799a..3a94754 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -199,7 +199,7 @@ public:
 	/**
 	 * Returns a vocab entry
 	 */
-	Common::String getVocab(int vocabId) { return _vocabStrings[vocabId]; }
+	Common::String getVocab(int vocabId) { return _vocabStrings[vocabId - 1]; }
 
 	/**
 	 * Clear the data for the scene
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 985e288..5ab0b0f 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -129,8 +129,8 @@ void UserInterface::drawTextElements() {
 	} else {
 		// Draw the actions
 		drawActions();
-//		drawInventoryList();
-//		drawItemVocabList();
+		drawInventoryList();
+		drawItemVocabList();
 	}
 }
 
@@ -183,7 +183,7 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
 			_vm->_font->setColorMode(id == _selectedActionIndex ? 2 : 0);
 		}
 		vocabStr = scene.getVocab(vocabId);
-		vocabStr.toUppercase();
+		vocabStr.setChar(toupper(vocabStr[0]), 0);
 		font->writeString(this, vocabStr, Common::Point(bounds.left, bounds.top));
 		break;
 
@@ -195,7 +195,7 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
 		} else {
 			_vm->_font->setColorMode(id == _selectedInvIndex ? 2 : 0);
 			vocabStr = scene.getVocab(vocabId);
-			vocabStr.toUppercase();
+			vocabStr.setChar(toupper(vocabStr[0]), 0);
 			font->writeString(this, vocabStr, Common::Point(bounds.left, bounds.top));
 			break;
 		}
@@ -235,7 +235,7 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
 		} else {
 			_vm->_font->setColorMode(id == _selectedInvIndex ? 2 : 0);
 			vocabStr = scene.getVocab(vocabId);
-			vocabStr.toUppercase();
+			vocabStr.setChar(toupper(vocabStr[0]), 0);
 			font->writeString(this, vocabStr, Common::Point(bounds.left, bounds.top));
 			break;
 		}


Commit: d57d4b876e90d1d043bd171c9de46d93c9e014f4
    https://github.com/scummvm/scummvm/commit/d57d4b876e90d1d043bd171c9de46d93c9e014f4
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-17T08:47:20+01:00

Commit Message:
MADS: Implement some more logic used in scene 201

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h
    engines/mads/player.cpp
    engines/mads/player.h



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 53e876b..d3284cc 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -54,9 +54,9 @@ void Scene2xx::setPlayerSpritesPrefix() {
 	}
 
 	if (_scene->_nextSceneId > 212)
-		_game._player._unk4 = 0;
+		_game._player._unk4 = false;
 	else
-		_game._player._unk4 = -1;
+		_game._player._unk4 = true;
 
 	if (oldName != _game._player._spritesPrefix)
 		_game._player._spritesChanged = true;
@@ -70,6 +70,56 @@ void Scene2xx::setPlayerSpritesPrefix() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene2xx::sceneEntrySound() {
+	if (_vm->_musicFlag) {
+		switch (_scene->_nextSceneId) {
+		case 201:
+			if ((_globals[39] == 2) || (_globals[39] == 4) || (_globals[33] != 1))
+				_vm->_sound->command(17);
+			else
+				_vm->_sound->command(9);
+			break;
+		case 202:
+		case 203:
+		case 204:
+		case 205:
+		case 208:
+		case 209:
+		case 212:
+			_vm->_sound->command(9);
+			break;
+		case 206:
+		case 211:
+		case 215:
+			_vm->_sound->command(10);
+			break;
+		case 207:
+		case 214:
+			_vm->_sound->command(11);
+			break;
+		case 210:
+			if (_globals[44] == 0)
+				_vm->_sound->command(15);
+			else
+				_vm->_sound->command(10);
+			break;
+		case 213:
+			if (_globals[38] == 0)
+				_vm->_sound->command(1);
+			else
+				_vm->_sound->command(9);
+				break;
+		case 216:
+			_vm->_sound->command(16);
+			break;
+		default:
+			_vm->_sound->command(10);
+			break;
+		}
+	} else
+		_vm->_sound->command(2);
+}
+
 void Scene201::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -81,6 +131,86 @@ void Scene201::setup() {
 }
 
 void Scene201::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0), 0);
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 1), 0);
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('m', -1), 0);
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('b', -1), 0);
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*SC002Z1");
+	_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 1, 0);
+	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 15, 0, 0, 50);
+	_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 4, 0, 0, 0);
+	_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 0, 0);
+	_scene->_sequences.setDepth(_globals._spriteIndexes[19], 8);
+	_scene->_sequences.setMsgPosition(_globals._spriteIndexes[19], Common::Point(185, 46));
+
+	int idx = _scene->_dynamicHotspots.add(1159, 209, _globals._spriteIndexes[19], Common::Rect(0, 0, 0, 0));
+	_scene->_dynamicHotspots.setPosition(idx, 186, 81, 8);
+
+	_globals._v0 = 0;
+
+	if ((_scene->_priorSceneId == 202) || (_scene->_priorSceneId == -1)) {
+		_game._player._playerPos = Common::Point(165, 152);
+	} else {
+		_game._player._playerPos = Common::Point(223, 149);
+		_game._player._direction = 2;
+	}
+
+	if (_globals[39] != 0) {
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+		int sepChar = (_globals[0] == SEX_UNKNOWN) ? 't' : 'u';
+		// Guess values. What is the default value used by the compiler?
+		int suffixNum = -1;
+		int abortTimers = -1; 
+		switch(_globals[39]) {
+		case 1:
+			suffixNum = 3;
+			abortTimers = 76;
+			_globals[41] = -1;
+			break;
+		case 2:
+			suffixNum = 1;
+			abortTimers = 77;
+			break;
+		case 3:
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			suffixNum = -1;
+			break;
+		case 4:
+			suffixNum = 2;
+			abortTimers = 78;
+			break;
+		}
+		_globals[39] = 0;
+		if (suffixNum >= 0)
+			_scene->loadAnimation(formAnimName(sepChar, suffixNum), abortTimers);
+	}
+	
+	if ((_scene->_priorSceneId == 202) && (_globals[33] == 1) && !_scene->_roomChanged) {
+		_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('a', 0), 0);
+		_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('a', 1), 0);
+		_game.loadQuoteSet(90, 91, 0);
+		_game._player._stepEnabled = false;
+		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 7, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[21], -1, 12);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_FRAME_INDEX, 12, 70);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 1);
+		_globals._frameTime = 0;
+		_game._player.sub7E53C(Common::Point(157, 143), 8);
+		_vm->_palette->setEntry(252, 45, 63, 45);
+		_vm->_palette->setEntry(253, 20, 45, 20);
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 2, 0, 120, _game.getQuote(90));
+	} else
+		_globals._frameTime = 0xFFFF;
+
+	if (_globals[41] != 0)
+		_scene->_hotspots.activate(438, false);
+
+	sceneEntrySound();
+}
+
+void Scene201::step() {
 	if ((_globals._frameTime) && (_vm->getRandomNumber(5000) == 9)) {
 		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 5, 1, 6, 0);
 		int idx = _scene->_dynamicHotspots.add(351, 13, _globals._spriteIndexes[20], Common::Rect(0, 0, 0, 0));
@@ -89,7 +219,7 @@ void Scene201::enter() {
 		_vm->_sound->command(14);
 		_globals._frameTime = 0;
 	}
-	
+
 	if (_game._abortTimers == 70) {
 		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 9, 1, 0, 0);
 		_game._player._visible = false;
@@ -154,9 +284,6 @@ void Scene201::enter() {
 	}
 }
 
-void Scene201::step() {
-}
-
 void Scene201::actions() {
 }
 
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index c4de731..4d6e6a2 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -43,6 +43,8 @@ protected:
 	 * Updates the prefix used for getting player sprites for the scene
 	 */
 	void setPlayerSpritesPrefix();
+
+	void sceneEntrySound();
 public:
 	Scene2xx(MADSEngine *vm) : NebularScene(vm) {}
 };
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 3fc7ca5..44dfc88 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -737,4 +737,13 @@ void Player::startMovement() {
 	_v8452E = -_v84530;
 }
 
+void Player::sub7E53C(Common::Point pos, int direction) {
+	Scene &scene = _vm->_game->_scene;
+
+	reset();
+	scene._action._startWalkFlag = true;
+	scene._action._walkFlag = true;
+	scene._destPos = pos;
+	scene._destFacing = direction;
+}
 } // End of namespace MADS
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 9a615e5..ed44de2 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -153,6 +153,8 @@ public:
 	void setDest(const Common::Point &pt, int facing);
 
 	void nextFrame();
+
+	void sub7E53C(Common::Point pos, int direction);
 };
 
 } // End of namespace MADS


Commit: 0c8a3a47e28075bd559be43bde910587af35d8ab
    https://github.com/scummvm/scummvm/commit/0c8a3a47e28075bd559be43bde910587af35d8ab
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-17T21:53:22-04:00

Commit Message:
MADS: Transformed ImageInterEntries to be User Interface UISlots

Changed paths:
    engines/mads/animation.cpp
    engines/mads/game.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/player.cpp
    engines/mads/player.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h
    engines/mads/screen.cpp
    engines/mads/screen.h
    engines/mads/sequence.cpp
    engines/mads/sprites.cpp
    engines/mads/sprites.h
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 783611e..b0b69b9 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -403,7 +403,7 @@ void Animation::update() {
 
 	for (uint idx = 0; idx < scene._spriteSlots.size(); ++idx) {
 		if (scene._spriteSlots[idx]._seqIndex >= 0x80)
-			scene._spriteSlots[idx]._spriteType = ST_EXPIRED;
+			scene._spriteSlots[idx]._SlotType = ST_EXPIRED;
 	}
 
 	// Validate the current frame
@@ -445,7 +445,7 @@ void Animation::update() {
 	if (paChanged) {
 		newIndex = scene._spriteSlots.add();
 		scene._spriteSlots[newIndex]._seqIndex = -1;
-		scene._spriteSlots[newIndex]._spriteType = ST_FULL_SCREEN_REFRESH;
+		scene._spriteSlots[newIndex]._SlotType = ST_FULL_SCREEN_REFRESH;
 	}
 
 	// Main frame animation loop - frames get animated by being placed, as necessary, into the
@@ -463,7 +463,7 @@ void Animation::update() {
 					int seqIndex = _frameEntries[_oldFrameEntry]._seqIndex - scene._spriteSlots[index]._seqIndex;
 					if (seqIndex == 0x80) {
 						if (scene._spriteSlots[index] == _frameEntries[_oldFrameEntry]._spriteSlot) {
-							scene._spriteSlots[index]._spriteType = ST_NONE;
+							scene._spriteSlots[index]._SlotType = ST_NONE;
 							spriteSlotIndex = -1;
 						}
 					}
@@ -479,7 +479,7 @@ void Animation::update() {
 
 					SpriteAsset &spriteSet = *scene._sprites[
 						scene._spriteSlots[slotIndex]._spritesIndex];
-					slot._spriteType = spriteSet.isBackground() ? ST_BACKGROUND : ST_FOREGROUND;
+					slot._SlotType = spriteSet.isBackground() ? ST_BACKGROUND : ST_FOREGROUND;
 				}
 				break;
 			}
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 3778e83..e65330a 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -235,7 +235,12 @@ void Game::sectionLoop() {
 		_player._priorTimer = _scene._frameStartTime + _player._ticksAmount;
 		_player.idle();
 
-		warning("TODO: _selectedObject IF block");
+		if (_scene._userInterface._selectedInvIndex >= 0) {
+			_scene._userInterface.loadInventoryAnim(
+				_objects._inventoryList[_scene._userInterface._selectedInvIndex]);
+		} else {
+			_scene._userInterface.noInventoryAnim();
+		}
 
 		_v1 = 5;
 		_scene._roomChanged = false;
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index d3284cc..63c03dc 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -197,7 +197,7 @@ void Scene201::enter() {
 		_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_FRAME_INDEX, 12, 70);
 		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 1);
 		_globals._frameTime = 0;
-		_game._player.sub7E53C(Common::Point(157, 143), 8);
+		_game._player.startWalking(Common::Point(157, 143), 8);
 		_vm->_palette->setEntry(252, 45, 63, 45);
 		_vm->_palette->setEntry(253, 20, 45, 20);
 		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 2, 0, 120, _game.getQuote(90));
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 44dfc88..8034360 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -246,7 +246,7 @@ void Player::update() {
 	if (_forceRefresh || (_visible != _priorVisible)) {
 		int slotIndex = getSpriteSlot();
 		if (slotIndex >= 0)
-			scene._spriteSlots[slotIndex]._spriteType = ST_EXPIRED;
+			scene._spriteSlots[slotIndex]._SlotType = ST_EXPIRED;
 
 		int newDepth = 1;
 		int yp = MAX(_playerPos.y, (int16)(MADS_SCENE_HEIGHT - 1));
@@ -264,7 +264,7 @@ void Player::update() {
 		if (_visible) {
 			// Player sprite needs to be rendered
 			SpriteSlot slot;
-			slot._spriteType = ST_FOREGROUND;
+			slot._SlotType = ST_FOREGROUND;
 			slot._seqIndex = PLAYER_SEQ_INDEX;
 			slot._spritesIndex = _spritesStart + _spritesIdx;
 			slot._frameNumber = _frameOffset + _frameNum;
@@ -285,7 +285,7 @@ void Player::update() {
 
 				if (equal)
 					// Undo the prior expiry of the player sprite
-					s2._spriteType = ST_NONE;
+					s2._SlotType = ST_NONE;
 				else
 					slotIndex = -1;
 			}
@@ -359,6 +359,16 @@ void Player::setDest(const Common::Point &pt, int facing) {
 	}
 }
 
+void Player::startWalking(const Common::Point &pos, int direction) {
+	Scene &scene = _vm->_game->_scene;
+
+	reset();
+	scene._action._startWalkFlag = true;
+	scene._action._walkFlag = true;
+	scene._destPos = pos;
+	scene._destFacing = direction;
+}
+
 void Player::nextFrame() {
 	Scene &scene = _vm->_game->_scene;
 
@@ -528,7 +538,7 @@ int Player::getSpriteSlot() {
 
 	for (uint idx = 0; idx < spriteSlots.size(); ++idx) {
 		if (spriteSlots[idx]._seqIndex == PLAYER_SEQ_INDEX && 
-				spriteSlots[idx]._spriteType >= ST_NONE)
+				spriteSlots[idx]._SlotType >= ST_NONE)
 			return idx;
 	}
 
@@ -737,13 +747,4 @@ void Player::startMovement() {
 	_v8452E = -_v84530;
 }
 
-void Player::sub7E53C(Common::Point pos, int direction) {
-	Scene &scene = _vm->_game->_scene;
-
-	reset();
-	scene._action._startWalkFlag = true;
-	scene._action._walkFlag = true;
-	scene._destPos = pos;
-	scene._destFacing = direction;
-}
 } // End of namespace MADS
diff --git a/engines/mads/player.h b/engines/mads/player.h
index ed44de2..e330c65 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -152,9 +152,9 @@ public:
 
 	void setDest(const Common::Point &pt, int facing);
 
-	void nextFrame();
+	void startWalking(const Common::Point &pos, int direction);
 
-	void sub7E53C(Common::Point pos, int direction);
+	void nextFrame();
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 88533a9..ed5fca5 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -379,7 +379,7 @@ void Scene::doFrame() {
 				_kernelMessages.update();
 			}
 
-			_imageInterEntries.call(_vm->_game->_abortTimers2 == kTransitionFadeIn ? 0xff : 0,
+			_userInterface._uiSlots.call(_vm->_game->_abortTimers2 == kTransitionFadeIn ? 0xff : 0,
 				_vm->_game->_abortTimers2);
 
 			// Write any text needed by the interface
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 3a94754..f5163bb 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -90,7 +90,6 @@ public:
 	int _textSpacing;
 	Hotspots _hotspots;
 	ScreenObjects _screenObjects;
-	ImageInterEntries _imageInterEntries;
 	DirtyAreas _dirtyAreas;
 	int _v1;
 	SceneInfo *_sceneInfo;
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index c37f0b1..8980bd4 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -136,173 +136,11 @@ void ScreenObjects::proc1() {
 
 /*------------------------------------------------------------------------*/
 
-MADSEngine *DirtyArea::_vm = nullptr;
-
-DirtyArea::DirtyArea() {
-	_active = false;
-	_textActive = false;
-}
-
-void DirtyArea::setArea(int width, int height, int maxWidth, int maxHeight) {
-	if (_bounds.left % 2) {
-		--_bounds.left;
-		++width;
-	}
-
-	if (_bounds.left < 0)
-		_bounds.left = 0;
-	else if (_bounds.left > maxWidth)
-		_bounds.left = maxWidth;
-	int right = _bounds.left + width;
-	if (right < 0)
-		right = 0;
-	if (right > maxWidth)
-		right = maxWidth;
-
-	_bounds.right = right;
-	_bounds2.left = _bounds.width() / 2;
-	_bounds2.right = _bounds.left + (_bounds.width() + 1) / 2 - 1;
-
-	if (_bounds.top < 0)
-		_bounds.top = 0;
-	else if (_bounds.top > maxHeight)
-		_bounds.top = maxHeight;
-	int bottom = _bounds.top + height;
-	if (bottom < 0)
-		bottom = 0;
-	if (bottom > maxHeight)
-		bottom = maxHeight;
-
-	_bounds.bottom = bottom;
-	_bounds2.top = _bounds.height() / 2;
-	_bounds2.bottom = _bounds.top + (_bounds.height() + 1) / 2 - 1;
-
-	_active = true;
-}
-
-
-void DirtyArea::setSpriteSlot(const SpriteSlot *spriteSlot) {
-	int width, height;
-	Scene &scene = _vm->_game->_scene;
-
-	if (spriteSlot->_spriteType == ST_FULL_SCREEN_REFRESH) {
-		// Special entry to refresh the entire screen
-		_bounds.left = 0;
-		_bounds.top = 0;
-		width = MADS_SCREEN_WIDTH;
-		height = MADS_SCENE_HEIGHT;
-	} else {
-		// Standard sprite slots
-		_bounds.left = spriteSlot->_position.x - scene._posAdjust.x;
-		_bounds.top = spriteSlot->_position.y - scene._posAdjust.y;
-
-		SpriteAsset &spriteSet = *scene._sprites[spriteSlot->_spritesIndex];
-		MSprite *frame = spriteSet.getFrame(((spriteSlot->_frameNumber & 0x7fff) - 1) & 0x7f);
-
-		if (spriteSlot->_scale == -1) {
-			width = frame->w;
-			height = frame->h;
-		} else {
-			width = frame->w * spriteSlot->_scale / 100;
-			height = frame->h * spriteSlot->_scale / 100;
-
-			_bounds.left -= width / 2;
-			_bounds.top += -(height - 1);
-		}
-	}
-
-	setArea(width, height, MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT);
-}
-
-void DirtyArea::setTextDisplay(const TextDisplay *textDisplay) {
-	_bounds.left = textDisplay->_bounds.left;
-	_bounds.top = textDisplay->_bounds.top;
-
-	setArea(textDisplay->_bounds.width(), textDisplay->_bounds.height(),
-		MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT);
-}
-
-/*------------------------------------------------------------------------*/
-
-DirtyAreas::DirtyAreas(MADSEngine *vm) : _vm(vm) {
-	DirtyArea::_vm = vm;
-
-	for (int i = 0; i < DIRTY_AREAS_SIZE; ++i) {
-		DirtyArea rec;
-		rec._active = false;
-		push_back(rec);
-	}
-}
-
-void DirtyAreas::merge(int startIndex, int count) {
-	if (startIndex >= count)
-		return;
-
-	for (int outerCtr = startIndex - 1, idx = 0; idx < count; ++outerCtr, ++idx) {
-		if (!(*this)[outerCtr]._active)
-			continue;
-
-		for (int innerCtr = outerCtr + 1; innerCtr < count; ++innerCtr) {
-			if (!(*this)[innerCtr]._active || !intersects(outerCtr, innerCtr))
-				continue;
-
-			if ((*this)[outerCtr]._textActive && (*this)[innerCtr]._textActive)
-				mergeAreas(outerCtr, innerCtr);
-		}
-	}
-}
-
-/**
-* Returns true if two dirty areas intersect
-*/
-bool DirtyAreas::intersects(int idx1, int idx2) {
-	return (*this)[idx1]._bounds2.intersects((*this)[idx2]._bounds2);
-}
-
-void DirtyAreas::mergeAreas(int idx1, int idx2) {
-	DirtyArea &da1 = (*this)[idx1];
-	DirtyArea &da2 = (*this)[idx2];
-
-	da1._bounds.extend(da2._bounds);
-
-	da1._bounds2.left = da1._bounds.width() / 2;
-	da1._bounds2.right = da1._bounds.left + (da1._bounds.width() + 1) / 2 - 1;
-	da1._bounds2.top = da1._bounds.height() / 2;
-	da1._bounds2.bottom = da1._bounds.top + (da1._bounds.height() + 1) / 2 - 1;
-
-	da2._active = false;
-	da1._textActive = true;
-}
-
-void DirtyAreas::copy(MSurface *srcSurface, MSurface *destSurface, const Common::Point &posAdjust) {
-	for (uint i = 0; i < size(); ++i) {
-		const Common::Rect &srcBounds = (*this)[i]._bounds;
-
-		Common::Rect bounds(srcBounds.left + posAdjust.x, srcBounds.top + posAdjust.y,
-			srcBounds.right + posAdjust.x, srcBounds.bottom + posAdjust.y);
-
-		if ((*this)[i]._active && bounds.isValidRect()) {
-			srcSurface->copyTo(destSurface, bounds, Common::Point(bounds.left, bounds.top));
-		}
-	}
-}
-
-void DirtyAreas::copyToScreen(const Common::Point &posAdjust) {
-	for (uint i = 0; i < size(); ++i) {
-		const Common::Rect &srcBounds = (*this)[i]._bounds;
-
-		Common::Rect bounds(srcBounds.left + posAdjust.x, srcBounds.top + posAdjust.y,
-			srcBounds.right + posAdjust.x, srcBounds.bottom + posAdjust.y);
-
-		if ((*this)[i]._active && (*this)[i]._bounds.isValidRect()) {
-			_vm->_screen.copyRectToScreen(bounds);
-		}
-	}
-}
-
-void DirtyAreas::reset() {
-	for (uint i = 0; i < size(); ++i)
-		(*this)[i]._active = false;
+void SceneNode::load(Common::SeekableReadStream *f) {
+	_walkPos.x = f->readSint16LE();
+	_walkPos.y = f->readSint16LE();
+	for (int i = 0; i < MAX_ROUTE_NODES; ++i)
+		_indexes[i] = f->readUint16LE();
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index f2893c5..1543669 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -108,61 +108,6 @@ public:
 	void check(bool scanFlag);
 };
 
-class DirtyArea {
-private:
-	static MADSEngine *_vm;
-	friend class DirtyAreas;
-public:
-	Common::Rect _bounds;
-	Common::Rect _bounds2;
-	bool _textActive;
-	bool _active;
-
-	DirtyArea();
-
-	void setArea(int width, int height, int maxWidth, int maxHeight);
-
-	void setSpriteSlot(const SpriteSlot *spriteSlot);
-
-	/**
-	* Set up a dirty area for a text display
-	*/
-	void setTextDisplay(const TextDisplay *textDisplay);
-};
-
-class DirtyAreas: public Common::Array<DirtyArea> {
-private:
-	MADSEngine *_vm;
-public:
-	DirtyAreas(MADSEngine *vm);
-	
-	/**
-	* Merge together any designated dirty areas that overlap
-	* @param startIndex	1-based starting dirty area starting index
-	* @param count			Number of entries to process
-	*/
-	void merge(int startIndex, int count);
-
-	bool intersects(int idx1, int idx2);
-	void mergeAreas(int idx1, int idx2);
-
-	/**
-	 * Copy the data specified by the dirty rect list between surfaces
-	 * @param srcSurface	Source surface
-	 * @param destSurface	Dest surface
-	 * @param posAdjust		Position adjustment
-	 */
-	void copy(MSurface *srcSurface, MSurface *destSurface, const Common::Point &posAdjust);
-
-	/**
-	 * Use the lsit of dirty areas to copy areas of the screen surface to
-	 * the physical screen
-	 * @param posAdjust		Position adjustment	 */
-	void copyToScreen(const Common::Point &posAdjust);
-
-	void reset();
-};
-
 class SceneLogic {
 protected:
 	MADSEngine *_vm;
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 20ff4f6..e760aa4 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -28,6 +28,179 @@
 
 namespace MADS {
 
+MADSEngine *DirtyArea::_vm = nullptr;
+
+DirtyArea::DirtyArea() {
+	_active = false;
+	_textActive = false;
+}
+
+void DirtyArea::setArea(int width, int height, int maxWidth, int maxHeight) {
+	if (_bounds.left % 2) {
+		--_bounds.left;
+		++width;
+	}
+
+	if (_bounds.left < 0)
+		_bounds.left = 0;
+	else if (_bounds.left > maxWidth)
+		_bounds.left = maxWidth;
+	int right = _bounds.left + width;
+	if (right < 0)
+		right = 0;
+	if (right > maxWidth)
+		right = maxWidth;
+
+	_bounds.right = right;
+	_bounds2.left = _bounds.width() / 2;
+	_bounds2.right = _bounds.left + (_bounds.width() + 1) / 2 - 1;
+
+	if (_bounds.top < 0)
+		_bounds.top = 0;
+	else if (_bounds.top > maxHeight)
+		_bounds.top = maxHeight;
+	int bottom = _bounds.top + height;
+	if (bottom < 0)
+		bottom = 0;
+	if (bottom > maxHeight)
+		bottom = maxHeight;
+
+	_bounds.bottom = bottom;
+	_bounds2.top = _bounds.height() / 2;
+	_bounds2.bottom = _bounds.top + (_bounds.height() + 1) / 2 - 1;
+
+	_active = true;
+}
+
+
+void DirtyArea::setSpriteSlot(const SpriteSlot *spriteSlot) {
+	int width, height;
+	Scene &scene = _vm->_game->_scene;
+
+	if (spriteSlot->_SlotType == ST_FULL_SCREEN_REFRESH) {
+		// Special entry to refresh the entire screen
+		_bounds.left = 0;
+		_bounds.top = 0;
+		width = MADS_SCREEN_WIDTH;
+		height = MADS_SCENE_HEIGHT;
+	}
+	else {
+		// Standard sprite slots
+		_bounds.left = spriteSlot->_position.x - scene._posAdjust.x;
+		_bounds.top = spriteSlot->_position.y - scene._posAdjust.y;
+
+		SpriteAsset &spriteSet = *scene._sprites[spriteSlot->_spritesIndex];
+		MSprite *frame = spriteSet.getFrame(((spriteSlot->_frameNumber & 0x7fff) - 1) & 0x7f);
+
+		if (spriteSlot->_scale == -1) {
+			width = frame->w;
+			height = frame->h;
+		}
+		else {
+			width = frame->w * spriteSlot->_scale / 100;
+			height = frame->h * spriteSlot->_scale / 100;
+
+			_bounds.left -= width / 2;
+			_bounds.top += -(height - 1);
+		}
+	}
+
+	setArea(width, height, MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT);
+}
+
+void DirtyArea::setTextDisplay(const TextDisplay *textDisplay) {
+	_bounds.left = textDisplay->_bounds.left;
+	_bounds.top = textDisplay->_bounds.top;
+
+	setArea(textDisplay->_bounds.width(), textDisplay->_bounds.height(),
+		MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT);
+}
+
+/*------------------------------------------------------------------------*/
+
+DirtyAreas::DirtyAreas(MADSEngine *vm) : _vm(vm) {
+	DirtyArea::_vm = vm;
+
+	for (int i = 0; i < DIRTY_AREAS_SIZE; ++i) {
+		DirtyArea rec;
+		rec._active = false;
+		push_back(rec);
+	}
+}
+
+void DirtyAreas::merge(int startIndex, int count) {
+	if (startIndex >= count)
+		return;
+
+	for (int outerCtr = startIndex - 1, idx = 0; idx < count; ++outerCtr, ++idx) {
+		if (!(*this)[outerCtr]._active)
+			continue;
+
+		for (int innerCtr = outerCtr + 1; innerCtr < count; ++innerCtr) {
+			if (!(*this)[innerCtr]._active || !intersects(outerCtr, innerCtr))
+				continue;
+
+			if ((*this)[outerCtr]._textActive && (*this)[innerCtr]._textActive)
+				mergeAreas(outerCtr, innerCtr);
+		}
+	}
+}
+
+/**
+* Returns true if two dirty areas intersect
+*/
+bool DirtyAreas::intersects(int idx1, int idx2) {
+	return (*this)[idx1]._bounds2.intersects((*this)[idx2]._bounds2);
+}
+
+void DirtyAreas::mergeAreas(int idx1, int idx2) {
+	DirtyArea &da1 = (*this)[idx1];
+	DirtyArea &da2 = (*this)[idx2];
+
+	da1._bounds.extend(da2._bounds);
+
+	da1._bounds2.left = da1._bounds.width() / 2;
+	da1._bounds2.right = da1._bounds.left + (da1._bounds.width() + 1) / 2 - 1;
+	da1._bounds2.top = da1._bounds.height() / 2;
+	da1._bounds2.bottom = da1._bounds.top + (da1._bounds.height() + 1) / 2 - 1;
+
+	da2._active = false;
+	da1._textActive = true;
+}
+
+void DirtyAreas::copy(MSurface *srcSurface, MSurface *destSurface, const Common::Point &posAdjust) {
+	for (uint i = 0; i < size(); ++i) {
+		const Common::Rect &srcBounds = (*this)[i]._bounds;
+
+		Common::Rect bounds(srcBounds.left + posAdjust.x, srcBounds.top + posAdjust.y,
+			srcBounds.right + posAdjust.x, srcBounds.bottom + posAdjust.y);
+
+		if ((*this)[i]._active && bounds.isValidRect()) {
+			srcSurface->copyTo(destSurface, bounds, Common::Point(bounds.left, bounds.top));
+		}
+	}
+}
+
+void DirtyAreas::copyToScreen(const Common::Point &posAdjust) {
+	for (uint i = 0; i < size(); ++i) {
+		const Common::Rect &srcBounds = (*this)[i]._bounds;
+
+		Common::Rect bounds(srcBounds.left + posAdjust.x, srcBounds.top + posAdjust.y,
+			srcBounds.right + posAdjust.x, srcBounds.bottom + posAdjust.y);
+
+		if ((*this)[i]._active && (*this)[i]._bounds.isValidRect()) {
+			_vm->_screen.copyRectToScreen(bounds);
+		}
+	}
+}
+
+void DirtyAreas::reset() {
+	for (uint i = 0; i < size(); ++i)
+		(*this)[i]._active = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 ScreenSurface::ScreenSurface() {
 	_dataP = nullptr;
 }
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index e101020..2860462 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -45,6 +45,64 @@ enum ScreenTransition {
 	kVertTransition7, kCenterVertTransition
 };
 
+class SpriteSlot;
+class TextDisplay;
+
+class DirtyArea {
+private:
+	static MADSEngine *_vm;
+	friend class DirtyAreas;
+public:
+	Common::Rect _bounds;
+	Common::Rect _bounds2;
+	bool _textActive;
+	bool _active;
+
+	DirtyArea();
+
+	void setArea(int width, int height, int maxWidth, int maxHeight);
+
+	void setSpriteSlot(const SpriteSlot *spriteSlot);
+
+	/**
+	* Set up a dirty area for a text display
+	*/
+	void setTextDisplay(const TextDisplay *textDisplay);
+};
+
+class DirtyAreas : public Common::Array<DirtyArea> {
+private:
+	MADSEngine *_vm;
+public:
+	DirtyAreas(MADSEngine *vm);
+
+	/**
+	* Merge together any designated dirty areas that overlap
+	* @param startIndex	1-based starting dirty area starting index
+	* @param count			Number of entries to process
+	*/
+	void merge(int startIndex, int count);
+
+	bool intersects(int idx1, int idx2);
+	void mergeAreas(int idx1, int idx2);
+
+	/**
+	* Copy the data specified by the dirty rect list between surfaces
+	* @param srcSurface	Source surface
+	* @param destSurface	Dest surface
+	* @param posAdjust		Position adjustment
+	*/
+	void copy(MSurface *srcSurface, MSurface *destSurface, const Common::Point &posAdjust);
+
+	/**
+	* Use the lsit of dirty areas to copy areas of the screen surface to
+	* the physical screen
+	* @param posAdjust		Position adjustment	 */
+	void copyToScreen(const Common::Point &posAdjust);
+
+	void reset();
+};
+
 class ScreenSurface : public MSurface {
 private:
 	/**
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 6418a03..684e499 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -178,7 +178,7 @@ void SequenceList::setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot) {
 	SequenceEntry &timerEntry = _entries[seqIndex];
 	SpriteAsset &spriteSet = *scene._sprites[timerEntry._spritesIndex];
 
-	spriteSlot._spriteType = spriteSet.isBackground() ? ST_BACKGROUND : ST_FOREGROUND;
+	spriteSlot._SlotType = spriteSet.isBackground() ? ST_BACKGROUND : ST_FOREGROUND;
 	spriteSlot._seqIndex = seqIndex;
 	spriteSlot._spritesIndex = timerEntry._spritesIndex;
 	spriteSlot._frameNumber = (timerEntry._flipped ? 0x8000 : 0) | timerEntry._frameIndex;
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index be066ba..18f6a64 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -139,7 +139,7 @@ byte MSprite::getTransparencyIndex() const {
 MADSEngine *SpriteSlot::_vm = nullptr;
 
 SpriteSlot::SpriteSlot() {
-	_spriteType = ST_NONE;
+	_SlotType = ST_NONE;
 	_seqIndex = 0;
 	_spritesIndex = 0;
 	_frameNumber = 0;
@@ -147,8 +147,8 @@ SpriteSlot::SpriteSlot() {
 	_scale = 0;
 }
 
-SpriteSlot::SpriteSlot(SpriteType type, int seqIndex) {
-	_spriteType = type;
+SpriteSlot::SpriteSlot(SlotType type, int seqIndex) {
+	_SlotType = type;
 	_seqIndex = seqIndex;
 	_spritesIndex = 0;
 	_frameNumber = 0;
@@ -208,11 +208,11 @@ void SpriteSlots::setDirtyAreas() {
 	Scene &scene = _vm->_game->_scene;
 
 	for (uint i = 0; i < size(); ++i) {
-		if ((*this)[i]._spriteType >= ST_NONE) {
+		if ((*this)[i]._SlotType >= ST_NONE) {
 			scene._dirtyAreas[i].setSpriteSlot(&(*this)[i]);
 
-			scene._dirtyAreas[i]._textActive = ((*this)[i]._spriteType <= ST_NONE) ? 0 : 1;
-			(*this)[i]._spriteType = ST_NONE;
+			scene._dirtyAreas[i]._textActive = ((*this)[i]._SlotType <= ST_NONE) ? 0 : 1;
+			(*this)[i]._SlotType = ST_NONE;
 		}
 	}
 }
@@ -247,14 +247,14 @@ void SpriteSlots::drawBackground() {
 		SpriteSlot &spriteSlot = (*this)[i];
 		DirtyArea &dirtyArea = scene._dirtyAreas[i];
 
-		if (spriteSlot._spriteType >= ST_NONE) {
+		if (spriteSlot._SlotType >= ST_NONE) {
 			// Foreground sprite, so we can ignore it
 			dirtyArea._active = false;
 		} else {
 			dirtyArea._active = true;
 			dirtyArea.setSpriteSlot(&spriteSlot);
 
-			if (spriteSlot._spriteType == ST_BACKGROUND) {
+			if (spriteSlot._SlotType == ST_BACKGROUND) {
 				// Background object, so need to draw it
 				assert(spriteSlot._frameNumber > 0);
 				SpriteAsset *asset = scene._sprites[spriteSlot._spritesIndex];
@@ -304,7 +304,7 @@ void SpriteSlots::drawForeground(MSurface *s) {
 	// Get a list of sprite object depths for active objects
 	for (uint i = 0; i < size(); ++i) {
 		SpriteSlot &spriteSlot = (*this)[i];
-		if (spriteSlot._spriteType >= ST_NONE) {
+		if (spriteSlot._SlotType >= ST_NONE) {
 			DepthEntry rec(16 - spriteSlot._depth, i);
 			depthList.push_back(rec);
 		}
@@ -367,7 +367,7 @@ void SpriteSlots::drawForeground(MSurface *s) {
 
 void SpriteSlots::cleanUp() {
 	for (int i = (int)size() - 1; i >= 0; --i) {
-		if ((*this)[i]._spriteType < ST_NONE)
+		if ((*this)[i]._SlotType < ST_NONE)
 			remove_at(i);
 	}
 }
@@ -391,6 +391,7 @@ int SpriteSets::add(SpriteAsset *asset, int idx) {
 }
 
 int SpriteSets::addSprites(const Common::String &resName, int flags) {
+	++_assetCount;
 	return add(new SpriteAsset(_vm, resName, flags));
 }
 
@@ -398,52 +399,17 @@ void SpriteSets::clear() {
 	for (uint i = 0; i < size(); ++i)
 		delete (*this)[i];
 
+	_assetCount = 0;
 	Common::Array<SpriteAsset *>::clear();
 }
 
-/*------------------------------------------------------------------------*/
-
-ImageInterEntry::ImageInterEntry() {
-	_field0 = 0;
-	_field2 = 0;
-	_field3 = 0;
-	_field4 = 0;
-	_field6 = 0;
-	_field8 = 0;
-}
-
-/*------------------------------------------------------------------------*/
-
-void ImageInterEntries::add(int v1, int v2) {
-	ImageInterEntry ie;
-	ie._field0 = -2;
-	ie._field2 = -1;
-
-	push_back(ie);
-}
+void SpriteSets::remove(int idx) {
+	if (idx >= 0) {
+		delete (*this)[idx];
+		(*this)[idx] = nullptr;
 
-void ImageInterEntries::add(int v1, int v2, int v3, int v4) {
-	assert(size() < 50);
-
-	ImageInterEntry ie;
-	ie._field0 = -3;
-	ie._field2 = 201;
-	ie._field6 = v1;
-	ie._field8 = v2;
-	ie._field4 = v3;
-	ie._field3 = v4;
-
-	push_back(ie);
-}
-
-ImageInterEntry &ImageInterEntries::add() {
-	resize(size() + 1);
-	return (*this)[size() - 1];
-}
-
-
-void ImageInterEntries::call(int v1, int v2) {
-	debug("TODO: ImageInterEntries::call");
+		--_assetCount;
+	}
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index 82f0a9b..cf45be6 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -30,7 +30,7 @@
 
 namespace MADS {
 
-enum SpriteType {
+enum SlotType {
 	ST_NONE = 0, ST_FOREGROUND = 1, ST_BACKGROUND = -4,
 	ST_FULL_SCREEN_REFRESH = -2, ST_EXPIRED = -1
 };
@@ -129,11 +129,11 @@ private:
 	static MADSEngine *_vm;
 	friend class SpriteSlots;
 public:
-	SpriteType _spriteType;
+	SlotType _SlotType;
 	int _seqIndex;
 public:
 	SpriteSlot();
-	SpriteSlot(SpriteType type, int seqIndex);
+	SpriteSlot(SlotType type, int seqIndex);
 
 	void setup(int dirtyAreaIndex);
 	bool operator==(const SpriteSlotSubset &other) const;
@@ -200,10 +200,12 @@ class SpriteSets : public Common::Array<SpriteAsset *> {
 private:
 	MADSEngine *_vm;
 public:
+	int _assetCount;
+
 	/**
 	 * Constructor
 	 */
-	SpriteSets(MADSEngine *vm) : _vm(vm) {}
+	SpriteSets(MADSEngine *vm) : _vm(vm), _assetCount(0) {}
 
 	/**
 	 * Destructor
@@ -224,27 +226,11 @@ public:
 	 * Adds a sprite asset to the list by name
 	 */
 	int addSprites(const Common::String &resName, int flags = 0);
-};
-
-class ImageInterEntry {
-public:
-	int _field0;
-	int _field2;
-	int _field3;
-	int _field4;
-	int _field6;
-	int _field8;
-
-	ImageInterEntry();
-};
 
-class ImageInterEntries: public Common::Array<ImageInterEntry> {
-public:
-	void add(int v1, int v2);
-	void add(int v1, int v2, int v3, int v4);
-	ImageInterEntry &add();
-
-	void call(int v1, int v2);
+	/**
+	 * Remove an asset from the list
+	 */
+	void remove(int idx);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 5ab0b0f..fd9f4c0 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -27,16 +27,47 @@
 
 namespace MADS {
 
-void SceneNode::load(Common::SeekableReadStream *f) {
-	_walkPos.x = f->readSint16LE();
-	_walkPos.y = f->readSint16LE();
-	for (int i = 0; i < MAX_ROUTE_NODES; ++i)
-		_indexes[i] = f->readUint16LE();
+UISlot::UISlot() {
+	_slotType = ST_NONE;
+	_field2 = 0;
+	_field3 = 0;
+	_field4 = 0;
+	_field6 = 0;
+	_field8 = 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+void UISlots::fullRefresh() {
+	UISlot slot;
+	slot._slotType = ST_FULL_SCREEN_REFRESH;
+	slot._field2 = -1;
+
+	push_back(slot);
+}
+
+void UISlots::add(int v1, int v2, int v3, int v4) {
+	assert(size() < 50);
+
+	UISlot ie;
+	ie._slotType = -3;
+	ie._field2 = 201;
+	ie._field6 = v1;
+	ie._field8 = v2;
+	ie._field4 = v3;
+	ie._field3 = v4;
+
+	push_back(ie);
+}
+
+void UISlots::call(int v1, int v2) {
+	debug("TODO: UISlots::call");
 }
 
 /*------------------------------------------------------------------------*/
 
 UserInterface::UserInterface(MADSEngine *vm) : _vm(vm) {
+	_invSpritesIndex = -1;
 	_category = CAT_NONE;
 	_screenObjectsCount = 0;
 	_inventoryTopIndex = 0;
@@ -99,8 +130,8 @@ void UserInterface::setup(int id) {
 	}
 	scene._screenObjects._v832EC = id;
 
-	scene._imageInterEntries.clear();
-	scene._imageInterEntries.add(-2, 0xff);
+	scene._userInterface._uiSlots.clear();
+	scene._userInterface._uiSlots.fullRefresh();
 	_vm->_game->_ticksExpiry = _vm->_events->getFrameCounter();
 	_v1A = -1;
 	_v1E = -1;
@@ -110,7 +141,7 @@ void UserInterface::setup(int id) {
 	copyTo(&_surface);
 
 	if (_vm->_game->_v1 == 5)
-		scene._imageInterEntries.call(0, 0);
+		scene._userInterface._uiSlots.call(0, 0);
 
 	scene._action.clear();
 	drawTextElements();
@@ -400,5 +431,27 @@ void UserInterface::drawTalkList() {
 	warning("TODO: drawTalkList");
 }
 
+void UserInterface::loadInventoryAnim(int objectId) {
+
+}
+
+void UserInterface::noInventoryAnim() {
+	Scene &scene = _vm->_game->_scene;
+
+	if (_invSpritesIndex >= 0) {
+		scene._sprites.remove(_invSpritesIndex);
+		_vm->_game->_ticksExpiry = _vm->_events->getFrameCounter();
+		_invSpritesIndex = -1;
+	}
+
+	if (!scene._screenObjects._v832EC)
+		refresh();
+}
+
+void UserInterface::refresh() {
+	Scene &scene = _vm->_game->_scene;
+	scene._userInterface._uiSlots.clear();
+//	scene._userInterface._uiSlots.new()
+}
 
 } // End of namespace MADS
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index cab2653..65c7e1c 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -36,9 +36,31 @@ enum ScrCategory {
 	CAT_12 = 12
 };
 
+class UISlot {
+public:
+	int _slotType;
+	int _field2;
+	int _field3;
+	int _field4;
+	int _field6;
+	int _field8;
+
+	UISlot();
+};
+
+class UISlots : public Common::Array<UISlot> {
+public:
+	void add(int v1, int v2, int v3, int v4);
+	void fullRefresh();
+
+	void call(int v1, int v2);
+};
+
+
 class UserInterface : public MSurface {
 private:
 	MADSEngine *_vm;
+	int _invSpritesIndex;
 
 	/**
 	 * Loads the elements of the user interface
@@ -84,6 +106,8 @@ private:
 	 * Draw a UI textual element
 	 */
 	void writeVocab(ScrCategory category, int id);
+
+	void refresh();
 public:
 	ScrCategory _category;
 	int _screenObjectsCount;
@@ -99,6 +123,7 @@ public:
 	int _v1A;
 	int _v1C;
 	int _v1E;
+	UISlots _uiSlots;
 public:
 	/**
 	* Constructor
@@ -120,6 +145,10 @@ public:
 	void drawTextElements();
 
 	void setBounds(const Common::Rect &r);
+
+	void loadInventoryAnim(int objectId);
+
+	void noInventoryAnim();
 };
 
 } // End of namespace MADS


Commit: d494db888e24c04261a46aa89d946ff3c7db3851
    https://github.com/scummvm/scummvm/commit/d494db888e24c04261a46aa89d946ff3c7db3851
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-17T23:14:54-04:00

Commit Message:
MADS: Beginnings of code for UI inventory item animation

Changed paths:
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/sprites.cpp
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 1785ce3..781fd7d 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -39,7 +39,7 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :
 	
 	// Initialise fields
 	_easyMouse = true;
-	_invObjectStill = false;
+	_invObjectsAnimated = true;
 	_textWindowStill = false;
 	_screenFade = SCREEN_FADE_SMOOTH;
 	_musicFlag = false;
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index f19abb3..3152e84 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -100,7 +100,7 @@ public:
 	ScreenSurface _screen;
 	SoundManager *_sound;
 	bool _easyMouse;
-	bool _invObjectStill;
+	bool _invObjectsAnimated;
 	bool _textWindowStill;
 	ScreenFade _screenFade;
 	bool _musicFlag;
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 18f6a64..e519c69 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -379,7 +379,9 @@ SpriteSets::~SpriteSets() {
 }
 
 int SpriteSets::add(SpriteAsset *asset, int idx) {
-	if (!idx)
+	if (idx)
+		idx = idx + 49;
+	else
 		idx = size();
 
 	if (idx >= (int)size())
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index fd9f4c0..2b5e6c4 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -30,8 +30,8 @@ namespace MADS {
 UISlot::UISlot() {
 	_slotType = ST_NONE;
 	_field2 = 0;
-	_field3 = 0;
-	_field4 = 0;
+	_spritesIndex = 0;
+	_frameNumber = 0;
 	_field6 = 0;
 	_field8 = 0;
 }
@@ -46,7 +46,7 @@ void UISlots::fullRefresh() {
 	push_back(slot);
 }
 
-void UISlots::add(int v1, int v2, int v3, int v4) {
+void UISlots::add(int v1, int v2, int frameNumber, int spritesIndex) {
 	assert(size() < 50);
 
 	UISlot ie;
@@ -54,8 +54,8 @@ void UISlots::add(int v1, int v2, int v3, int v4) {
 	ie._field2 = 201;
 	ie._field6 = v1;
 	ie._field8 = v2;
-	ie._field4 = v3;
-	ie._field3 = v4;
+	ie._frameNumber = frameNumber;
+	ie._spritesIndex = spritesIndex;
 
 	push_back(ie);
 }
@@ -68,6 +68,7 @@ void UISlots::call(int v1, int v2) {
 
 UserInterface::UserInterface(MADSEngine *vm) : _vm(vm) {
 	_invSpritesIndex = -1;
+	_invFrameNumber = 1;
 	_category = CAT_NONE;
 	_screenObjectsCount = 0;
 	_inventoryTopIndex = 0;
@@ -432,7 +433,23 @@ void UserInterface::drawTalkList() {
 }
 
 void UserInterface::loadInventoryAnim(int objectId) {
+	Scene &scene = _vm->_game->_scene;
+	noInventoryAnim();
+	bool flag = true;
+
+	if (_vm->_invObjectsAnimated) {
+		Common::String resName = Common::String::format("*OB%.3dI", objectId);
+		SpriteAsset *asset = new SpriteAsset(_vm, resName, 8);
+		_invSpritesIndex = scene._sprites.add(asset, 1);
+		if (_invSpritesIndex >= 0) {
+			_invFrameNumber = 1;
+			flag = false;
+		}
+	}
 
+	if (flag) {
+		// TODO: Use of inv_object_data?
+	}
 }
 
 void UserInterface::noInventoryAnim() {
@@ -449,9 +466,41 @@ void UserInterface::noInventoryAnim() {
 }
 
 void UserInterface::refresh() {
+	_uiSlots.clear();
+	_uiSlots.fullRefresh();
+	_uiSlots.call(0, 0);
+
+	drawTextElements();
+}
+
+void UserInterface::inventoryAnim() {
 	Scene &scene = _vm->_game->_scene;
-	scene._userInterface._uiSlots.clear();
-//	scene._userInterface._uiSlots.new()
+	if (scene._screenObjects._v832EC == 1 || scene._screenObjects._v832EC == 2
+			|| _invSpritesIndex < 0)
+		return;
+
+	// Move to the next frame number in the sequence, resetting if at the end
+	SpriteAsset *asset = scene._sprites[_invSpritesIndex];
+	if (++_invFrameNumber > asset->getCount())
+		_invFrameNumber = 1;
+
+	// Loop through the slots list for ?? entry
+	for (uint i = 0; i < _uiSlots.size(); ++i) {
+		if (_uiSlots[i]._field2 == 200)
+			_uiSlots[i]._slotType = -5;
+	}
+
+	// Add a new slot entry for the inventory animation
+	UISlot slot;
+	slot._slotType = ST_FOREGROUND;
+	slot._field2 = 200;
+	slot._frameNumber = _invFrameNumber;
+	slot._spritesIndex = _invSpritesIndex;
+	slot._field6 = 160;
+	slot._field8 = 3;
+
+	_uiSlots.push_back(slot);
 }
 
+
 } // End of namespace MADS
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 65c7e1c..8b87b4e 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -40,8 +40,8 @@ class UISlot {
 public:
 	int _slotType;
 	int _field2;
-	int _field3;
-	int _field4;
+	int _spritesIndex;
+	int _frameNumber;
 	int _field6;
 	int _field8;
 
@@ -50,7 +50,7 @@ public:
 
 class UISlots : public Common::Array<UISlot> {
 public:
-	void add(int v1, int v2, int v3, int v4);
+	void add(int v1, int v2, int frameNumber, int spritesIndex);
 	void fullRefresh();
 
 	void call(int v1, int v2);
@@ -61,6 +61,7 @@ class UserInterface : public MSurface {
 private:
 	MADSEngine *_vm;
 	int _invSpritesIndex;
+	int _invFrameNumber;
 
 	/**
 	 * Loads the elements of the user interface
@@ -108,6 +109,11 @@ private:
 	void writeVocab(ScrCategory category, int id);
 
 	void refresh();
+
+	/**
+	 * Handles queuing a new frame of an inventory animation for drawing
+	 */
+	void inventoryAnim();
 public:
 	ScrCategory _category;
 	int _screenObjectsCount;


Commit: a82a0f2618049c337ed36e55a3c3c89911c54e55
    https://github.com/scummvm/scummvm/commit/a82a0f2618049c337ed36e55a3c3c89911c54e55
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-18T07:26:39+01:00

Commit Message:
MADS: Complete scene 201

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/player.h



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 63c03dc..d8b1308 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -285,6 +285,51 @@ void Scene201::step() {
 }
 
 void Scene201::actions() {
+	MADSAction *action = _game._player._action;
+	if (action->_lookFlag == false) {
+		if (action->isAction(0x18C, 0x83, 0))
+			_scene->_nextSceneId = 202;
+		else if ((action->isAction(0x50, 0x156, 0)) || (action->isAction(0x188, 0x16C, 0)) || (action->isAction(0x188, 0x1B6, 0))) {
+			if (_game._abortTimers != 0) { 
+				if (_game._abortTimers != 1)
+					_scene->_nextSceneId = 213;
+			} else {
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				int sepChar = (_globals[0] == SEX_UNKNOWN) ? 't' : 'u';
+				_scene->loadAnimation(formAnimName(sepChar, 0), 1);
+			}
+		} else if (action->isAction(0x3, 0x1A6, 0)) {
+			Dialog::show(0x4E85);
+		} else if (action->isAction(0x3, 0x129, 0)) {
+			Dialog::show(0x4E86);
+		} else if (action->isAction(0x3, 0x16F, 0)) {
+			Dialog::show(0x4E87);
+		} else if (action->isAction(0x3, 0x142, 0)) {
+			Dialog::show(0x4E88);
+		} else if (action->isAction(0x3, 0x18F, 0)) {
+			Dialog::show(0x4E89);
+		} else if (action->isAction(0x3, 0x1B9, 0)) {
+			Dialog::show(0x4E8A);
+		} else if (action->isAction(0x3, 0x192, 0)) {
+			Dialog::show(0x4E8B);
+		} else if (action->isAction(0x3, 0x1BA, 0)) {
+			Dialog::show(0x4E8C);
+		} else if (action->isAction(0x3, 0x83, 0)) {
+			Dialog::show(0x4E8E);
+		} else if (action->isAction(0x3, 0x1B6, 0)) {
+			if (_globals[37])
+				Dialog::show(0x4E90);
+			else
+				Dialog::show(0x4E8D);
+		} else if (action->isAction(0x3, 0x16C, 0)) {
+			Dialog::show(0x4E91);
+		} else
+			return;
+	} else {
+		Dialog::show(0x4E8F);
+	}
+	action->_inProgress = false;
 }
 
 } // End of namespace Nebular
diff --git a/engines/mads/player.h b/engines/mads/player.h
index e330c65..b997e26 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -38,7 +38,6 @@ private:
 	static const int _directionListIndexes[32];
 private:
 	MADSEngine *_vm;
-	MADSAction *_action;
 	bool _highSprites;
 	bool _spriteSetsPresent[PLAYER_SPRITES_FILE_COUNT];
 	int _currentDepth;
@@ -97,6 +96,8 @@ private:
 
 	void dirChanged();
 public:
+	MADSAction *_action;
+
 	int _direction;
 	int _newDirection;
 	int _xDirection, _yDirection;


Commit: 26c90afdef0d5ecf11935f2b02add292df562de5
    https://github.com/scummvm/scummvm/commit/26c90afdef0d5ecf11935f2b02add292df562de5
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-18T07:35:02+01:00

Commit Message:
MADS: Add scene 201 in createScene()

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 6b922a4..b9d244d 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -29,6 +29,7 @@
 #include "mads/nebular/game_nebular.h"
 #include "mads/nebular/nebular_scenes.h"
 #include "mads/nebular/nebular_scenes1.h"
+#include "mads/nebular/nebular_scenes2.h"
 #include "mads/nebular/nebular_scenes8.h"
 
 namespace MADS {
@@ -49,6 +50,10 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 103:
 		return new Scene103(vm);
 
+	// Scene group #2
+	case 201:
+		return new Scene201(vm);
+
 	// Scene group #8
 	case 804:
 		return new Scene804(vm);
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 4d6e6a2..097041b 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -55,7 +55,9 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
+	virtual void preActions() {};
 	virtual void actions();
+	virtual void postActions() {};
 };
 
 } // End of namespace Nebular


Commit: 306ea295eef03b23882fc4bfa5343b72cb8c4067
    https://github.com/scummvm/scummvm/commit/306ea295eef03b23882fc4bfa5343b72cb8c4067
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-18T18:49:36+01:00

Commit Message:
MADS: Add isInInventory()

Changed paths:
    engines/mads/inventory.cpp
    engines/mads/inventory.h



diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index 89eaaad..f1a2537 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -88,5 +88,8 @@ bool InventoryObjects::isInRoom(int objectId) const {
 	return (*this)[objectId]._roomNumber == _vm->_game->_scene._currentSceneId;
 }
 
+bool InventoryObjects::isInInventory(int objectId) const {
+	return (*this)[objectId]._roomNumber == PLAYER_INVENTORY;
+}
 
 } // End of namespace MADS
diff --git a/engines/mads/inventory.h b/engines/mads/inventory.h
index 1eef0f7..1ff38ab 100644
--- a/engines/mads/inventory.h
+++ b/engines/mads/inventory.h
@@ -87,6 +87,11 @@ public:
 	 * Returns true if a given object is in the player's current scene
 	 */
 	bool isInRoom(int objectId) const;
+
+	/**
+	 * Returns true if a given object is in the player's inventory
+	 */
+	bool isInInventory(int objectId) const;
 };
 
 } // End of namespace MADS


Commit: 4875c83f1023585ff7c807f5633aac84eb5e3c2b
    https://github.com/scummvm/scummvm/commit/4875c83f1023585ff7c807f5633aac84eb5e3c2b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-18T19:56:29-04:00

Commit Message:
MADS: Implemented DirtyArea::setUISlot

Changed paths:
    engines/mads/scene.cpp
    engines/mads/screen.cpp
    engines/mads/screen.h
    engines/mads/sprites.h
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index ed5fca5..60b3385 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -379,7 +379,7 @@ void Scene::doFrame() {
 				_kernelMessages.update();
 			}
 
-			_userInterface._uiSlots.call(_vm->_game->_abortTimers2 == kTransitionFadeIn ? 0xff : 0,
+			_userInterface._uiSlots.draw(_vm->_game->_abortTimers2 == kTransitionFadeIn ? 0xff : 0,
 				_vm->_game->_abortTimers2);
 
 			// Write any text needed by the interface
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index e760aa4..8b05d7a 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -25,6 +25,7 @@
 #include "mads/game.h"
 #include "mads/screen.h"
 #include "mads/palette.h"
+#include "mads/user_interface.h"
 
 namespace MADS {
 
@@ -116,6 +117,47 @@ void DirtyArea::setTextDisplay(const TextDisplay *textDisplay) {
 		MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT);
 }
 
+void DirtyArea::setUISlot(const UISlot *slot) {
+	int type = slot->_slotType;
+	if (type <= -20)
+		type += 20;
+	if (type >= 64)
+		type &= 0xBF;
+
+	MSurface &intSurface = _vm->_game->_scene._userInterface;
+	switch (type) {
+	case ST_FULL_SCREEN_REFRESH:
+		_bounds.left = 0;
+		_bounds.top = 0;
+		setArea(intSurface.w, intSurface.h, intSurface.w, intSurface.h);
+		break;
+	case ST_MINUS3:
+		_bounds.left = slot->_position.x;
+		_bounds.top = slot->_position.y;
+		// TODO: spritesIndex & frameNumber used as w & h??!
+		error("TODO: Figure out ST_MINUS3. Maybe need a union?");
+		break;
+
+	default: {
+		SpriteAsset *asset = _vm->_game->_scene._sprites[slot->_spritesIndex];
+		MSprite *frame = asset->getFrame(slot->_frameNumber - 1);
+		int w = frame->w;
+		int h = frame->h;
+
+		if (slot->_field2 == 200) {
+			_bounds.left = slot->_position.x;
+			_bounds.top = slot->_position.y;
+		} else {
+			_bounds.left = slot->_position.x + w / 2;
+			_bounds.top = slot->_position.y + h / 2;
+		}
+
+		setArea(w, h, intSurface.w, intSurface.h);
+		break;
+	}
+	}
+}
+
 /*------------------------------------------------------------------------*/
 
 DirtyAreas::DirtyAreas(MADSEngine *vm) : _vm(vm) {
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index 2860462..06053e8 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -47,6 +47,7 @@ enum ScreenTransition {
 
 class SpriteSlot;
 class TextDisplay;
+class UISlot;
 
 class DirtyArea {
 private:
@@ -62,12 +63,20 @@ public:
 
 	void setArea(int width, int height, int maxWidth, int maxHeight);
 
+	/**
+	 * Set up a dirty area for a sprite slot
+	 */
 	void setSpriteSlot(const SpriteSlot *spriteSlot);
 
 	/**
 	* Set up a dirty area for a text display
 	*/
 	void setTextDisplay(const TextDisplay *textDisplay);
+
+	/**
+	 * Set up a dirty area for a UI slot
+	 */
+	void setUISlot(const UISlot *slot);
 };
 
 class DirtyAreas : public Common::Array<DirtyArea> {
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index cf45be6..6118924 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -31,7 +31,7 @@
 namespace MADS {
 
 enum SlotType {
-	ST_NONE = 0, ST_FOREGROUND = 1, ST_BACKGROUND = -4,
+	ST_NONE = 0, ST_FOREGROUND = 1, ST_BACKGROUND = -4, ST_MINUS3 = -3,
 	ST_FULL_SCREEN_REFRESH = -2, ST_EXPIRED = -1
 };
 
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 2b5e6c4..f34d68c 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -32,8 +32,6 @@ UISlot::UISlot() {
 	_field2 = 0;
 	_spritesIndex = 0;
 	_frameNumber = 0;
-	_field6 = 0;
-	_field8 = 0;
 }
 
 /*------------------------------------------------------------------------*/
@@ -46,22 +44,21 @@ void UISlots::fullRefresh() {
 	push_back(slot);
 }
 
-void UISlots::add(int v1, int v2, int frameNumber, int spritesIndex) {
+void UISlots::add(const Common::Point &pt, int frameNumber, int spritesIndex) {
 	assert(size() < 50);
 
 	UISlot ie;
 	ie._slotType = -3;
 	ie._field2 = 201;
-	ie._field6 = v1;
-	ie._field8 = v2;
+	ie._position = pt;
 	ie._frameNumber = frameNumber;
 	ie._spritesIndex = spritesIndex;
 
 	push_back(ie);
 }
 
-void UISlots::call(int v1, int v2) {
-	debug("TODO: UISlots::call");
+void UISlots::draw(int v1, int v2) {
+	
 }
 
 /*------------------------------------------------------------------------*/
@@ -142,7 +139,7 @@ void UserInterface::setup(int id) {
 	copyTo(&_surface);
 
 	if (_vm->_game->_v1 == 5)
-		scene._userInterface._uiSlots.call(0, 0);
+		scene._userInterface._uiSlots.draw(0, 0);
 
 	scene._action.clear();
 	drawTextElements();
@@ -468,7 +465,7 @@ void UserInterface::noInventoryAnim() {
 void UserInterface::refresh() {
 	_uiSlots.clear();
 	_uiSlots.fullRefresh();
-	_uiSlots.call(0, 0);
+	_uiSlots.draw(0, 0);
 
 	drawTextElements();
 }
@@ -496,8 +493,7 @@ void UserInterface::inventoryAnim() {
 	slot._field2 = 200;
 	slot._frameNumber = _invFrameNumber;
 	slot._spritesIndex = _invSpritesIndex;
-	slot._field6 = 160;
-	slot._field8 = 3;
+	slot._position = Common::Point(160, 3);
 
 	_uiSlots.push_back(slot);
 }
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 8b87b4e..a474fe1 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -42,18 +42,17 @@ public:
 	int _field2;
 	int _spritesIndex;
 	int _frameNumber;
-	int _field6;
-	int _field8;
+	Common::Point _position;
 
 	UISlot();
 };
 
 class UISlots : public Common::Array<UISlot> {
 public:
-	void add(int v1, int v2, int frameNumber, int spritesIndex);
+	void add(const Common::Point &pt, int frameNumber, int spritesIndex);
 	void fullRefresh();
 
-	void call(int v1, int v2);
+	void draw(int v1, int v2);
 };
 
 


Commit: 5b4b7a5ca972f533c7a6129e84fd5d26e3b2ebb6
    https://github.com/scummvm/scummvm/commit/5b4b7a5ca972f533c7a6129e84fd5d26e3b2ebb6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-18T22:37:33-04:00

Commit Message:
MADS: Finished UISlots::draw method

Changed paths:
    engines/mads/scene.cpp
    engines/mads/sprites.h
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 60b3385..79ac2ce 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -379,8 +379,8 @@ void Scene::doFrame() {
 				_kernelMessages.update();
 			}
 
-			_userInterface._uiSlots.draw(_vm->_game->_abortTimers2 == kTransitionFadeIn ? 0xff : 0,
-				_vm->_game->_abortTimers2);
+			_userInterface._uiSlots.draw(_vm->_game->_abortTimers2 == kTransitionFadeIn,
+				_vm->_game->_abortTimers2 != 0);
 
 			// Write any text needed by the interface
 			if (_vm->_game->_abortTimers2)
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index 6118924..2017961 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -31,8 +31,8 @@
 namespace MADS {
 
 enum SlotType {
-	ST_NONE = 0, ST_FOREGROUND = 1, ST_BACKGROUND = -4, ST_MINUS3 = -3,
-	ST_FULL_SCREEN_REFRESH = -2, ST_EXPIRED = -1
+	ST_NONE = 0, ST_FOREGROUND = 1, ST_MINUS5 = -5, ST_BACKGROUND = -4, 
+	ST_MINUS3 = -3, ST_FULL_SCREEN_REFRESH = -2, ST_EXPIRED = -1
 };
 
 class MADSEngine;
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index f34d68c..d11c122 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -57,13 +57,136 @@ void UISlots::add(const Common::Point &pt, int frameNumber, int spritesIndex) {
 	push_back(ie);
 }
 
-void UISlots::draw(int v1, int v2) {
-	
+void UISlots::draw(bool updateFlag, bool delFlag) {
+	Scene &scene = _vm->_game->_scene;
+	UserInterface &userInterface = scene._userInterface;
+	DirtyArea *dirtyAreaPtr = nullptr;
+
+	// Loop through setting up the dirty areas
+	for (uint idx = 0; idx < size(); ++idx) {
+		DirtyArea &dirtyArea = userInterface._dirtyAreas[idx];
+		UISlot &slot = (*this)[idx];
+
+		if (slot._slotType >= ST_NONE) {
+			dirtyArea._active = false;
+		} else {
+			dirtyArea.setUISlot(&slot);
+			dirtyArea._textActive = true;
+			if (slot._field2 == 200 && slot._slotType == ST_MINUS5) {
+				dirtyArea._active = false;
+				dirtyAreaPtr = &dirtyArea;
+			}
+		}
+	}
+
+	userInterface._dirtyAreas.merge(1, userInterface._uiSlots.size());
+	if (dirtyAreaPtr)
+		dirtyAreaPtr->_active = true;
+
+	// Main draw loop
+	for (uint idx = 0; idx < size(); ++idx) {
+		DirtyArea &dirtyArea = userInterface._dirtyAreas[idx];
+		UISlot &slot = (*this)[idx];
+
+		if (dirtyArea._active && dirtyArea._bounds.width() > 0
+				&& dirtyArea._bounds.height() > 0 && slot._slotType >= -20) {
+
+			// TODO: Figure out the difference between two copy methods used
+			if (slot._slotType >= ST_EXPIRED) {
+				userInterface._surface.copyTo(&userInterface, dirtyArea._bounds,
+					Common::Point(dirtyArea._bounds.left, dirtyArea._bounds.top));
+			} else {
+				userInterface._surface.copyTo(&userInterface, dirtyArea._bounds,
+					Common::Point(dirtyArea._bounds.left, dirtyArea._bounds.top));
+			}
+		}
+	}
+
+	for (uint idx = 0; idx < size(); ++idx) {
+		DirtyArea &dirtyArea = userInterface._dirtyAreas[idx];
+		UISlot &slot = (*this)[idx];
+
+		int slotType = slot._slotType;
+		if (slotType >= ST_NONE) {
+			dirtyArea.setUISlot(&slot);
+			if (!updateFlag)
+				slotType &= ~0x40;
+
+			dirtyArea._textActive = slotType > 0;
+			slot._slotType &= 0x40;
+		}
+	}
+
+	userInterface._dirtyAreas.merge(1, userInterface._uiSlots.size());
+
+	for (uint idx = 0; idx < size(); ++idx) {
+		DirtyArea &dirtyArea = userInterface._dirtyAreas[idx];
+		UISlot &slot = (*this)[idx];
+
+		if (slot._slotType >= ST_NONE && !(slot._slotType & 0x40)) {
+			if (!dirtyArea._active) {
+				error("TODO: Original code here doesn't make sense!");
+			}
+
+			if (dirtyArea._textActive) {
+				SpriteAsset *asset = scene._sprites[slot._spritesIndex];
+				
+				if (slot._field2 == 200) {
+					MSprite *sprite = asset->getFrame(slot._frameNumber & 0x7F);
+					sprite->copyTo(&userInterface, slot._position);
+				} else {
+					MSprite *sprite = asset->getFrame(slot._frameNumber - 1);
+					sprite->copyTo(&userInterface, slot._position);
+				}
+			}
+		}
+	}
+
+	// Mark areas of the screen surface for updating
+	if (updateFlag) {
+		_vm->_screen.setPointer(&userInterface);
+		userInterface.setBounds(Common::Rect(0, scene._interfaceY,
+			MADS_SCREEN_WIDTH - 1, userInterface.h + scene._interfaceY - 1));
+		warning("TODO: sub_111C8 / sub_1146C");
+
+		for (uint idx = 0; idx < size(); ++idx) {
+			DirtyArea &dirtyArea = userInterface._dirtyAreas[idx];
+			UISlot &slot = (*this)[idx];
+
+			if (dirtyArea._active && dirtyArea._textActive &&
+				dirtyArea._bounds.width() > 0 && dirtyArea._bounds.height() > 0) {
+				// Flag area of screen as needing update
+				Common::Rect r = dirtyArea._bounds;
+				r.translate(0, scene._interfaceY);
+				_vm->_screen.copyRectToScreen(r);
+			}
+		}
+
+		warning("TODO: sub 115A2 / sub111D3");
+	}
+
+	// Post-processing to remove slots no longer needed
+	for (int idx = (int)size() - 1; idx >= 0; --idx) {
+		UISlot &slot = (*this)[idx];
+
+		if (slot._slotType < ST_NONE) {
+			if (delFlag || updateFlag)
+				remove_at(idx);
+			else if (slot._slotType >= -20)
+				slot._slotType -= 20;
+		} else {
+			if (updateFlag)
+				slot._slotType &= 0xBF;
+			else
+				slot._slotType |= 0x40;
+		}
+	}
 }
 
 /*------------------------------------------------------------------------*/
 
-UserInterface::UserInterface(MADSEngine *vm) : _vm(vm) {
+UserInterface::UserInterface(MADSEngine *vm) : _vm(vm), _dirtyAreas(vm), 
+		_uiSlots(vm) {
 	_invSpritesIndex = -1;
 	_invFrameNumber = 1;
 	_category = CAT_NONE;
@@ -77,7 +200,9 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm) {
 	_v1A = -1;
 	_v1C = -1;
 	_v1E = -1;
+	_dirtyAreas.resize(50);
 
+	// Map the user interface to the bottom of the game's screen surface
 	byte *pData = _vm->_screen.getBasePtr(0, MADS_SCENE_HEIGHT);
 	setPixels(pData, MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
 }
@@ -101,9 +226,10 @@ void UserInterface::load(const Common::String &resName) {
 	}
 	delete palStream;
 
-	// set the size for the interface
+	// Read in the surface data
 	Common::SeekableReadStream *pixelsStream = madsPack.getItemStream(1);
-	pixelsStream->read(getData(), MADS_SCREEN_WIDTH * MADS_INTERFACE_HEIGHT);
+	_surface.setSize(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
+	pixelsStream->read(_surface.getData(), MADS_SCREEN_WIDTH * MADS_INTERFACE_HEIGHT);
 	delete pixelsStream;
 }
 
@@ -124,7 +250,9 @@ void UserInterface::setup(int id) {
 			resName += "A";
 
 		resName += ".INT";
+
 		load(resName);
+		_surface.copyTo(this);
 	}
 	scene._screenObjects._v832EC = id;
 
@@ -139,7 +267,7 @@ void UserInterface::setup(int id) {
 	copyTo(&_surface);
 
 	if (_vm->_game->_v1 == 5)
-		scene._userInterface._uiSlots.draw(0, 0);
+		scene._userInterface._uiSlots.draw(false, false);
 
 	scene._action.clear();
 	drawTextElements();
@@ -273,7 +401,7 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
 }
 
 void UserInterface::setBounds(const Common::Rect &r) {
-	_bounds = r;
+	_drawBounds = r;
 }
 
 void UserInterface::loadElements() {
@@ -465,7 +593,7 @@ void UserInterface::noInventoryAnim() {
 void UserInterface::refresh() {
 	_uiSlots.clear();
 	_uiSlots.fullRefresh();
-	_uiSlots.draw(0, 0);
+	_uiSlots.draw(false, false);
 
 	drawTextElements();
 }
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index a474fe1..9d2af04 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -27,6 +27,7 @@
 #include "common/rect.h"
 #include "common/str.h"
 #include "mads/msurface.h"
+#include "mads/screen.h"
 
 namespace MADS {
 
@@ -47,18 +48,42 @@ public:
 	UISlot();
 };
 
+/**
+ * Sprite list for the user interface
+ */
 class UISlots : public Common::Array<UISlot> {
+private:
+	MADSEngine *_vm;
 public:
+	/**
+	 * Constructor
+	 */
+	UISlots(MADSEngine *vm) : _vm(vm) {}
+
+	/**
+	 * Add a sprite to the list
+	 */
 	void add(const Common::Point &pt, int frameNumber, int spritesIndex);
+
+	/**
+	 * Adds a special entry for full refresh of the user interface
+	 */
 	void fullRefresh();
 
-	void draw(int v1, int v2);
+	/**
+	 * Draw all the sprites in the list on the user interface.
+	 * @param updateFlag	Flag drawn areas to be updated on physical screen
+	 * @param delFlag		Controls how used slots are deleted after drawing
+	 */
+	void draw(bool updateFlag, bool delFlag);
 };
 
 
 class UserInterface : public MSurface {
+	friend class UISlots;
 private:
 	MADSEngine *_vm;
+	MSurface _surface;
 	int _invSpritesIndex;
 	int _invFrameNumber;
 
@@ -114,11 +139,12 @@ private:
 	 */
 	void inventoryAnim();
 public:
+	UISlots _uiSlots;
+	DirtyAreas _dirtyAreas;
 	ScrCategory _category;
 	int _screenObjectsCount;
-	Common::Rect _bounds;
+	Common::Rect _drawBounds;
 	Common::Rect *_rectP;
-	MSurface _surface;
 	int _inventoryTopIndex;
 	int _objectY;
 	int _selectedInvIndex;
@@ -128,7 +154,6 @@ public:
 	int _v1A;
 	int _v1C;
 	int _v1E;
-	UISlots _uiSlots;
 public:
 	/**
 	* Constructor


Commit: 53eac0d7c045c734e897df1c0246cab185af0463
    https://github.com/scummvm/scummvm/commit/53eac0d7c045c734e897df1c0246cab185af0463
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-18T23:13:13-04:00

Commit Message:
MADS: Fixes for scene background loading

Changed paths:
    engines/mads/scene.cpp
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 79ac2ce..02ef916 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -150,8 +150,8 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 		flags |= 0x200;
 
 	_animationData = Animation::init(_vm, this);
-	UserInterface surface(_vm);
-	_animationData->load(surface, _userInterface, prefix, flags, nullptr, nullptr);
+	MSurface depthSurface;
+	_animationData->load(_userInterface, depthSurface, prefix, flags, nullptr, nullptr);
 	
 	_vm->_palette->_paletteUsage.load(0);
 
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index d11c122..a117ae0 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -83,7 +83,7 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 	if (dirtyAreaPtr)
 		dirtyAreaPtr->_active = true;
 
-	// Main draw loop
+	// Copy parts of the user interface background that are going to have sprites drawn
 	for (uint idx = 0; idx < size(); ++idx) {
 		DirtyArea &dirtyArea = userInterface._dirtyAreas[idx];
 		UISlot &slot = (*this)[idx];
@@ -205,6 +205,8 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm), _dirtyAreas(vm),
 	// Map the user interface to the bottom of the game's screen surface
 	byte *pData = _vm->_screen.getBasePtr(0, MADS_SCENE_HEIGHT);
 	setPixels(pData, MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
+
+	_surface.setSize(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
 }
 
 void UserInterface::load(const Common::String &resName) {
@@ -228,7 +230,6 @@ void UserInterface::load(const Common::String &resName) {
 
 	// Read in the surface data
 	Common::SeekableReadStream *pixelsStream = madsPack.getItemStream(1);
-	_surface.setSize(MADS_SCREEN_WIDTH, MADS_INTERFACE_HEIGHT);
 	pixelsStream->read(_surface.getData(), MADS_SCREEN_WIDTH * MADS_INTERFACE_HEIGHT);
 	delete pixelsStream;
 }
@@ -263,9 +264,6 @@ void UserInterface::setup(int id) {
 	_v1E = -1;
 	_v1C = -1;
 
-	// Make a copy of the surface
-	copyTo(&_surface);
-
 	if (_vm->_game->_v1 == 5)
 		scene._userInterface._uiSlots.draw(false, false);
 
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 9d2af04..b9035c5 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -83,7 +83,6 @@ class UserInterface : public MSurface {
 	friend class UISlots;
 private:
 	MADSEngine *_vm;
-	MSurface _surface;
 	int _invSpritesIndex;
 	int _invFrameNumber;
 
@@ -139,6 +138,7 @@ private:
 	 */
 	void inventoryAnim();
 public:
+	MSurface _surface;
 	UISlots _uiSlots;
 	DirtyAreas _dirtyAreas;
 	ScrCategory _category;


Commit: 7b808b4464fb20ee37325ce5763504eb2c8e80a2
    https://github.com/scummvm/scummvm/commit/7b808b4464fb20ee37325ce5763504eb2c8e80a2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-19T00:15:25-04:00

Commit Message:
MADS: Added inventory add/remove methods

Changed paths:
    engines/mads/inventory.cpp
    engines/mads/inventory.h
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index f1a2537..4f6ba48 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -80,8 +80,16 @@ void InventoryObjects::setData(int objIndex, int id, const byte *p) {
 	}
 }
 
-void InventoryObjects::setRoom(int objectId, int roomNumber) {
-	warning("TODO: setObjectRoom");
+void InventoryObjects::setRoom(int objectId, int sceneNumber) {
+	InventoryObject &obj = (*this)[objectId];
+
+	if (obj._roomNumber == PLAYER_INVENTORY)
+		removeFromInventory(objectId, 1);
+
+	if (sceneNumber == PLAYER_INVENTORY)
+		addToInventory(objectId);
+	else
+		obj._roomNumber = sceneNumber;
 }
 
 bool InventoryObjects::isInRoom(int objectId) const {
@@ -92,4 +100,68 @@ bool InventoryObjects::isInInventory(int objectId) const {
 	return (*this)[objectId]._roomNumber == PLAYER_INVENTORY;
 }
 
+void InventoryObjects::addToInventory(int objectId) {
+	assert(_inventoryList.size() < 32);
+	UserInterface &userInterface = _vm->_game->_scene._userInterface;
+
+	if (!isInInventory(objectId)) {
+		_inventoryList.push_back(objectId);
+		userInterface._selectedInvIndex = _inventoryList.size() - 1;
+		userInterface._inventoryTopIndex = CLIP(userInterface._inventoryTopIndex,
+			0, (int)_inventoryList.size() - 1);
+
+		if ((userInterface._inventoryTopIndex + 5) <= (size() - 1))
+			userInterface._inventoryTopIndex = size() - 5;
+		userInterface._inventoryChanged = true;
+
+		(*this)[objectId]._roomNumber = PLAYER_INVENTORY;
+
+		if (_vm->_game->_v1 == 5 && !_vm->_game->_scene._screenObjects._v832EC) {
+			userInterface.categoryChanged();
+			userInterface.selectObject(userInterface._selectedInvIndex);
+		}
+	}
+}
+
+void InventoryObjects::removeFromInventory(int objectId, int newScene) {
+	Scene &scene = _vm->_game->_scene;
+	UserInterface &userInterface = scene._userInterface;
+
+	// Scan the inventory list for the object
+	int invIndex = -1;
+	for (int idx = 0; idx < (int)_inventoryList.size() && invIndex == -1; ++idx) {
+		if (_inventoryList[idx] == objectId)
+			invIndex = idx;
+	}
+
+	int selectedIndex = userInterface._selectedInvIndex;
+	bool noSelection = selectedIndex < 0;
+
+	if (_vm->_game->_v1 == 5 && !scene._screenObjects._v832EC)
+		userInterface.selectObject(-1);
+
+	// Remove the item from the inventory list
+	_inventoryList.remove_at(invIndex);
+
+	if (invIndex > userInterface._inventoryTopIndex) {
+		userInterface._inventoryTopIndex = MAX(userInterface._inventoryTopIndex, 0);
+	}
+
+	userInterface._inventoryChanged = true;
+	(*this)[objectId]._roomNumber = newScene;
+
+	int newIndex = selectedIndex;
+	if (!noSelection) {
+		if (newIndex >= invIndex)
+			--newIndex;
+		if (newIndex < 0 && size() > 0)
+			newIndex = 0;
+	}
+
+	if (_vm->_game->_v1 == 5 && !scene._screenObjects._v832EC) {
+		userInterface.categoryChanged();
+		userInterface.selectObject(newIndex);
+	}
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/inventory.h b/engines/mads/inventory.h
index 1ff38ab..245d439 100644
--- a/engines/mads/inventory.h
+++ b/engines/mads/inventory.h
@@ -53,6 +53,18 @@ public:
 class InventoryObjects: public Common::Array<InventoryObject> {
 private:
 	MADSEngine *_vm;
+
+	/**
+	* Removes the specified object from the player's inventory
+	*/
+	void addToInventory(int objectId);
+
+	/**
+	 * Removes the specified object to the player's inventory
+	 * @param objectId	Object to remove
+	 * @param newScene	Specifies the new scene to set the item to
+	 */
+	void removeFromInventory(int objectId, int newScene);
 public:
 	Common::Array<int> _inventoryList;
 
@@ -79,9 +91,9 @@ public:
 	void setData(int objIndex, int id, const byte *p);
 
 	/**
-	 * Sets the room number
+	 * Sets an item's scene number
 	 */
-	void setRoom(int objectId, int roomNumber);
+	void setRoom(int objectId, int sceneNumber);
 
 	/**
 	 * Returns true if a given object is in the player's current scene
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index a117ae0..5a15293 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -201,6 +201,7 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm), _dirtyAreas(vm),
 	_v1C = -1;
 	_v1E = -1;
 	_dirtyAreas.resize(50);
+	_inventoryChanged = false;
 
 	// Map the user interface to the bottom of the game's screen surface
 	byte *pData = _vm->_screen.getBasePtr(0, MADS_SCENE_HEIGHT);
@@ -624,5 +625,14 @@ void UserInterface::inventoryAnim() {
 	_uiSlots.push_back(slot);
 }
 
+void UserInterface::categoryChanged() {
+	_v1C = -1;
+	_vm->_events->initVars();
+	_category = CAT_NONE;
+}
+
+void UserInterface::selectObject(int invIndex) {
+	warning("TODO: selectObject");
+}
 
 } // End of namespace MADS
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index b9035c5..07c3f74 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -154,6 +154,7 @@ public:
 	int _v1A;
 	int _v1C;
 	int _v1E;
+	bool _inventoryChanged;
 public:
 	/**
 	* Constructor
@@ -179,6 +180,14 @@ public:
 	void loadInventoryAnim(int objectId);
 
 	void noInventoryAnim();
+
+	void categoryChanged();
+
+	/**
+	 * Select an item from the inventory list
+	 * @param invIndex	Index in the inventory list of the item to select
+	 */
+	void selectObject(int invIndex);
 };
 
 } // End of namespace MADS


Commit: 829a099ad23e187db7cd79353d975d381d6c0338
    https://github.com/scummvm/scummvm/commit/829a099ad23e187db7cd79353d975d381d6c0338
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-19T08:04:32+01:00

Commit Message:
MADS: Implement Scene202::actions

Changed paths:
    engines/mads/nebular/globals_nebular.cpp
    engines/mads/nebular/globals_nebular.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp
index 3c16cd1..31b7940 100644
--- a/engines/mads/nebular/globals_nebular.cpp
+++ b/engines/mads/nebular/globals_nebular.cpp
@@ -43,6 +43,7 @@ Globals::Globals() {
 	_v6 = 0;
 	_v7 = 0;
 	_v8 = 0;
+	_abortVal = 0;
 }
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index b2a1f0d..8d9d009 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -46,6 +46,7 @@ public:
 	int _v6;
 	int _v7;
 	int _v8;
+	int _abortVal;
 public:
 	/**
 	 * Constructor
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index d8b1308..439ac3e 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -68,8 +68,6 @@ void Scene2xx::setPlayerSpritesPrefix() {
 	_vm->_palette->setEntry(17, 10, 45, 45);
 }
 
-/*------------------------------------------------------------------------*/
-
 void Scene2xx::sceneEntrySound() {
 	if (_vm->_musicFlag) {
 		switch (_scene->_nextSceneId) {
@@ -120,6 +118,8 @@ void Scene2xx::sceneEntrySound() {
 		_vm->_sound->command(2);
 }
 
+/*------------------------------------------------------------------------*/
+
 void Scene201::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -332,5 +332,242 @@ void Scene201::actions() {
 	action->_inProgress = false;
 }
 
+/*------------------------------------------------------------------------*/
+
+void Scene202::setup() {
+}
+
+void Scene202::enter() {
+}
+
+void Scene202::step() {
+}
+
+void Scene202::preActions() {
+}
+
+void Scene202::actions() {
+	MADSAction *action = _game._player._action;
+	if (action->_lookFlag == false) {
+		if (action->isAction(0x4E, 0xC7, 0)) {
+			action->_inProgress = false;
+			return;
+		} else if (action->isAction(0x18C, 0x83, 0)) {
+			_scene->_nextSceneId = 203;
+		} else if (action->isAction(0x18C, 0x82, 0)) {
+			if (_globals[33] != 2) {
+				if (_scene->_activeAnimation)
+					_globals[33] = 1;
+				else
+					_globals[33] = 0;
+			}
+			_scene->_nextSceneId = 201;
+		} else if (action->isAction(0x4, 0x2C, 0)) {
+			if (action->_actionMode2 == 4) {
+				if (_game._abortTimers == 0) {
+					if (_game._objects.isInInventory(OBJ_BONES)) {
+						Dialog::show(0x4EFB);
+					} else {
+						_game._player._stepEnabled = false;
+						_game._player._visible = false;
+						_globals._spriteIndexes[22] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[6], false, 3, 2, 0, 0);
+						warning("TODO: sub71312");
+						_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_FRAME_INDEX, 6, 1);
+						_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 2);
+					}
+				} else if (_game._abortTimers == 1) {
+					if ((_game._player._playerPos.x == 132) && (_game._player._playerPos.y == 97)) {
+						_scene->_sequences.remove(_globals._spriteIndexes[16]);
+						_globals[32] |= 1;
+					} else {
+						_scene->_sequences.remove(_globals._spriteIndexes[21]);
+						_globals[32] |= 2;
+					}
+				} else if (_game._abortTimers == 2) {
+					if (_game._objects.isInInventory(OBJ_BONE)) {
+						warning("TODO: _game._objects.removeFromInventory(OBJ_BONE, 1);");
+						warning("TODO: _game._objects.addToInventory(OBJ_BONES);");
+						warning("TODO: Dialog::showPicture(OBJ_BONES, 0x4EFA, 0);");
+					} else {
+						warning("TODO: _game._objects.addToInventory(OBJ_BONE);");
+						warning("TODO: Dialog::showPicture(OBJ_BONE, 0x4EFA, 0);");
+					}
+					warning("TODO: sub1EB6E(_globals[32];");
+					_game._player._stepEnabled = true;
+					_game._player._visible = true;
+				} else {
+					action->_inProgress = false;
+					return;
+				}
+			}
+		} else if ((action->isAction(0x50, 0xC7, 0)) && (_globals[31] == 0)) {
+			if (_game._abortTimers == 0) {
+				_vm->_sound->command(29);
+				warning("TODO: word_8425E = _scene->_frameStartTime;");
+				_game._player._visible = false;
+				_game._player._stepEnabled = false;
+
+				int idx = _scene->_dynamicHotspots.add(199, 79, -1, Common::Rect(241, 68, 12, 54));
+				warning("CHECKME: _globals._frameTime = _scene->_dynamicHotspots.setPosition(idx, 246, 124, 8);");
+				_globals._frameTime = _scene->_dynamicHotspots.setPosition(idx, 246, 124, 8);
+				_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
+				_scene->_sequences.setDepth(_globals._spriteIndexes[23], 1);
+				_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 1);
+			} else if (_game._abortTimers == 1) {
+				_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
+				_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
+				_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
+				warning("TODO: TimerList_getTimeout(_globals._spriteIndexes[23], _globals._spriteIndexes[24]);");
+				_globals._v4 = -1;
+				_game._player._stepEnabled = true;
+				int msgIndex = _scene->_kernelMessages.add(Common::Point(248, 15), 0x1110, 32, 0, 60, _game.getQuote(97));
+				_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+			} else {
+				action->_inProgress = false;
+				return;
+			}
+		} else if (((action->isAction(0x3, 0x27, 0x82)) || (action->isAction(0x3, 0x27, 0x1B6))) && (_globals[0] == SEX_MALE)) {
+			if (_globals._v4 == 0) {
+				if (_game._abortTimers == 0) {
+					_game._player._stepEnabled = false;
+					_game._player._visible= false;
+					_globals._spriteIndexes[25] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
+					_scene->_sequences.setAnimRange(_globals._spriteIndexes[25], 1, 6);
+					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
+					_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
+					warning("TODO: TimerList_getTimeout(-1, _globals._spriteIndexes[25]);");
+					_scene->_sequences.addSubEntry(_globals._spriteIndexes[25], SM_0, 0, 1);
+				} else if (_game._abortTimers == 1) {
+					_globals._spriteIndexes[25] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
+					_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
+					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
+					if (_scene->_activeAnimation) {
+						_globals._v5 = -1;
+						_globals[38] = 1;
+					} else {
+						_scene->_sequences.addTimer(120, 2);
+					}
+				} else if (_game._abortTimers == 2) {
+					if (!_scene->_activeAnimation && (_globals._abortVal == 0)) {
+						Dialog::show(0x4EFE);
+					}
+					_scene->_sequences.remove(_globals._spriteIndexes[25]);
+					_globals._spriteIndexes[25] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
+					_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
+					_scene->_sequences.setAnimRange(_globals._spriteIndexes[25], 1, 6);
+					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
+					_scene->_sequences.addSubEntry(_globals._spriteIndexes[25], SM_0, 0, 3);
+				} else if (_game._abortTimers == 3) {
+					warning("TODO: TimerList_getTimeout(-1, _globals._spriteIndexes[25]);");
+					_game._player._stepEnabled = true;
+					_game._player._visible = true;
+				} else {
+					action->_inProgress = false;
+					return;
+				}
+			} else {
+				if (_game._abortTimers == 0) {
+					warning("TODO: word_84268 = 1;");
+					_game._player._stepEnabled = false;
+					_scene->_sequences.remove(_globals._spriteIndexes[24]);
+					_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0);
+					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
+					_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
+					_scene->_sequences.addSubEntry(_globals._spriteIndexes[24], SM_0, 0, 1);
+				} else if (_game._abortTimers == 1) {
+					_globals._spriteIndexes[25] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, -2);
+					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(247, 82));
+					_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
+					if (_scene->_activeAnimation) {
+						if (_scene->_activeAnimation->getCurrentFrame() > 200) {
+							_scene->_sequences.addTimer(120, 2);
+						} else {
+							_globals._v5 = -1;
+							_globals[38] = 2;
+							if ((_scene->_activeAnimation->getCurrentFrame() >= 44) && (_scene->_activeAnimation->getCurrentFrame() <= 75)) {
+								_scene->_kernelMessages.reset();
+								int msgIndex = _scene->_kernelMessages.add(Common::Point(248, 15), 0x1110, 32, 0, 60, _game.getQuote(100));
+								_scene->_kernelMessages.setQuoted(msgIndex, 4, false);
+							} else {
+								action->_inProgress = false;
+								return;
+							}
+						}
+					} else {
+						_scene->_sequences.addTimer(120, 2);
+					}
+				} else if (_game._abortTimers == 2) {
+					if (!_scene->_activeAnimation)
+						Dialog::show(0x4EFE);
+					_globals._abortVal = 0;
+					_scene->_sequences.remove(_globals._spriteIndexes[25]);
+					_globals._spriteIndexes[24] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
+					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
+					_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
+					_scene->_sequences.addSubEntry(_globals._spriteIndexes[24], SM_0, 0, 3);
+				} else if (_game._abortTimers == 3) {
+					_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
+					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
+					_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
+					_game._player._stepEnabled = true;
+				} else {
+					action->_inProgress = false;
+					return;
+				}
+			}
+		} else if (action->isAction(0x188, 0xAA, 0)) {
+			warning("TODO - sub_370C8");
+		} else if (action->isAction(0x3, 0x129, 0)) {
+			Dialog::show(0x4EEA);
+		} else if (action->isAction(0x3, 0x86, 0)) {
+			Dialog::show(0x4EEB);
+		} else if (action->isAction(0x3, 0x19C, 0)) {
+			Dialog::show(0x4EEC);
+		} else if (action->isAction(0x3, 0x82, 0)) {
+			if ((_globals[33] == 0) || (_globals[33] == 2)) {
+				Dialog::show(0x4EED);
+			} else if (_globals[33] == 1) {
+				Dialog::show(0x4EFC);
+			} else {
+				action->_inProgress = false;
+				return;
+			} 
+		} else if (action->isAction(0x3, 0x18E, 0)) {
+			Dialog::show(0x4EEE);
+		} else if (action->isAction(0x3, 0x164, 0)) {
+			Dialog::show(0x4EEF);
+		} else if (action->isAction(0x3, 0x175, 0)) {
+			Dialog::show(0x4EF0);
+		} else if (action->isAction(0x3, 0x174, 0)) {
+			Dialog::show(0x4EF1);
+		} else if (action->isAction(0x3, 0x142, 0)) {
+			Dialog::show(0x4EF2);
+		} else if (action->isAction(0x3, 0xAA, 0)) {
+			if ((_game._player._playerPos == Common::Point(77, 105)) && (_game._player._direction == 8))
+				Dialog::show(0x4EF4);
+			else
+				Dialog::show(0x4EF3);
+		} else if (action->isAction(0x3, 0x186, 0)) {
+			Dialog::show(0x4EF5);
+		} else if (action->isAction(0x3, 0x1B5, 0)) {
+			Dialog::show(0x4EF6);
+		} else if (action->isAction(0x3, 0x140, 0)) {
+			Dialog::show(0x4EF7);
+		} else if (action->isAction(0x4, 0x140, 0)) {
+			Dialog::show(0x4EF8);
+		} else if (action->isAction(0x3, 0x2D, 0)) {
+			if (action->_actionMode == 4)
+				Dialog::show(0x4EF9);
+			else
+				return;
+		} else {
+			return;			
+		}
+	} else {
+		Dialog::show(0x4EFB);
+	}
+	action->_inProgress = false;
+}
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 097041b..35a6ff1 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -60,6 +60,16 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene202: public Scene2xx {
+public:
+	Scene202(MADSEngine *vm) : Scene2xx(vm) {}
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: b04f7c16935e63f35a46ffe9eec4e712c2b824c8
    https://github.com/scummvm/scummvm/commit/b04f7c16935e63f35a46ffe9eec4e712c2b824c8
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-19T08:12:11+01:00

Commit Message:
MADS: set public 2 inventory functions, fix signed/unsigned comparison

Changed paths:
    engines/mads/inventory.cpp
    engines/mads/inventory.h



diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index 4f6ba48..b697462 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -110,7 +110,7 @@ void InventoryObjects::addToInventory(int objectId) {
 		userInterface._inventoryTopIndex = CLIP(userInterface._inventoryTopIndex,
 			0, (int)_inventoryList.size() - 1);
 
-		if ((userInterface._inventoryTopIndex + 5) <= (size() - 1))
+		if ((userInterface._inventoryTopIndex + 5) <= ((int) size() - 1))
 			userInterface._inventoryTopIndex = size() - 5;
 		userInterface._inventoryChanged = true;
 
diff --git a/engines/mads/inventory.h b/engines/mads/inventory.h
index 245d439..2ca27064 100644
--- a/engines/mads/inventory.h
+++ b/engines/mads/inventory.h
@@ -54,17 +54,6 @@ class InventoryObjects: public Common::Array<InventoryObject> {
 private:
 	MADSEngine *_vm;
 
-	/**
-	* Removes the specified object from the player's inventory
-	*/
-	void addToInventory(int objectId);
-
-	/**
-	 * Removes the specified object to the player's inventory
-	 * @param objectId	Object to remove
-	 * @param newScene	Specifies the new scene to set the item to
-	 */
-	void removeFromInventory(int objectId, int newScene);
 public:
 	Common::Array<int> _inventoryList;
 
@@ -104,6 +93,18 @@ public:
 	 * Returns true if a given object is in the player's inventory
 	 */
 	bool isInInventory(int objectId) const;
+
+	/**
+	* Removes the specified object from the player's inventory
+	*/
+	void addToInventory(int objectId);
+
+	/**
+	 * Removes the specified object to the player's inventory
+	 * @param objectId	Object to remove
+	 * @param newScene	Specifies the new scene to set the item to
+	 */
+	void removeFromInventory(int objectId, int newScene);
 };
 
 } // End of namespace MADS


Commit: cfe2257d00af3d608b907f940729138503366760
    https://github.com/scummvm/scummvm/commit/cfe2257d00af3d608b907f940729138503366760
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-19T08:13:35+01:00

Commit Message:
MADS: Use removeFromInventory and addToInventory in Scene 202

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 439ac3e..9294378 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -385,11 +385,11 @@ void Scene202::actions() {
 					}
 				} else if (_game._abortTimers == 2) {
 					if (_game._objects.isInInventory(OBJ_BONE)) {
-						warning("TODO: _game._objects.removeFromInventory(OBJ_BONE, 1);");
-						warning("TODO: _game._objects.addToInventory(OBJ_BONES);");
+						_game._objects.removeFromInventory(OBJ_BONE, 1);
+						_game._objects.addToInventory(OBJ_BONES);
 						warning("TODO: Dialog::showPicture(OBJ_BONES, 0x4EFA, 0);");
 					} else {
-						warning("TODO: _game._objects.addToInventory(OBJ_BONE);");
+						_game._objects.addToInventory(OBJ_BONE);
 						warning("TODO: Dialog::showPicture(OBJ_BONE, 0x4EFA, 0);");
 					}
 					warning("TODO: sub1EB6E(_globals[32];");


Commit: c43f8347922b808458f5114ae0bdfd2f1752f696
    https://github.com/scummvm/scummvm/commit/c43f8347922b808458f5114ae0bdfd2f1752f696
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-19T08:45:42+01:00

Commit Message:
MADS: More work on scene 202

Changed paths:
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 6021e67..13e3597 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -41,8 +41,10 @@ enum {
 enum Noun {
 	NOUN_D              = 0xD,
 	NOUN_BLOWGUN		= 0x29,
+	NOUN_2C             = 0x2C,
 	NOUN_BURGER			= 0x35,
 	NOUN_CHAIR			= 0x47,
+	NOUN_4E             = 0x4E,
 	NOUN_DEAD_FISH		= 0x65,
 	NOUN_DOOR			= 0x6E,
 	NOUN_EAT			= 0x75,
@@ -58,6 +60,7 @@ enum Noun {
 	NOUN_INSERT			= 0x0B6,
 	NOUN_INSPECT		= 0x0B7,
 	NOUN_JUNGLE			= 0x0B8,
+	NOUN_C7             = 0x0C7,
 	NOUN_LIFE_SUPPORT_SECTION  = 0x0CC,
 	NOUN_LOG			= 0x0D0,
 	NOUN_LOOK_AT		= 0x0D1,
@@ -75,6 +78,8 @@ enum Noun {
 	NOUN_SHIELD_MODULATOR	= 0x137,
 	NOUN_SHOOT			= 0x13A,
 	NOUN_SIT_IN			= 0x13F,
+	NOUN_140            = 0x140,
+	NOUN_1C9            = 0x1C9,
 	NOUN_SMELL			= 0x147,
 	NOUN_STUFFED_FISH	= 0x157,
 	NOUN_15F            = 0x15F,
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 9294378..f03bf00 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -335,6 +335,16 @@ void Scene201::actions() {
 /*------------------------------------------------------------------------*/
 
 void Scene202::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+
+	Scene &scene = _vm->_game->_scene;
+	scene.addActiveVocab(NOUN_C7);
+	scene.addActiveVocab(NOUN_4E);
+	scene.addActiveVocab(NOUN_D);
+	scene.addActiveVocab(NOUN_2C);
+	scene.addActiveVocab(NOUN_140);
+	scene.addActiveVocab(NOUN_1C9);
 }
 
 void Scene202::enter() {
@@ -344,6 +354,41 @@ void Scene202::step() {
 }
 
 void Scene202::preActions() {
+	MADSAction *action = _game._player._action;
+	if (action->_walkFlag)
+		_scene->_kernelMessages.reset();
+
+	if ((_globals._v4 == 0) && (action->isAction(0x4E, 0xC7, 0) || !action->_walkFlag)) {
+		if (_game._abortTimers == 0) {
+			_vm->_sound->command(29);
+			action->_walkFlag = false;
+			_game._player._stepEnabled = false;
+			_scene->_sequences.remove(_globals._spriteIndexes[24]);
+			_globals._spriteIndexes[23] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._spriteIndexes[23], 1);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 1);
+		} else if (_game._abortTimers == 1) {
+			warning("TODO: TimerList_getTimeout(-1, _globals._spriteIndexes[23]);");
+			warning("CHECKME: _scene->_dynamicHotspots.remove(_globals._frameTime);");
+			_scene->_dynamicHotspots.remove(_globals._frameTime);
+			_game._player._visible = true;
+			action->_walkFlag = true;
+			_game._player._stepEnabled = true;
+			_globals._v4 = 0;
+		} else {
+			// nothing
+		}		
+	}
+
+	if (action->isAction(0x3, 0x27, 0) && action->_activeAction._indirectObjectId > 0) {
+		if (!action->_walkFlag || (_globals._v4 != 0))
+			action->_startWalkFlag = false;
+		else
+			action->_startWalkFlag = true;
+
+		if (_globals._v4 == 0)
+			_game._player.startWalking(Common::Point(171, 122), 8);
+	}
 }
 
 void Scene202::actions() {


Commit: 66643b3ad6ab2beb3cb42c1b1952aa7ff7cecc02
    https://github.com/scummvm/scummvm/commit/66643b3ad6ab2beb3cb42c1b1952aa7ff7cecc02
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-19T23:30:45+01:00

Commit Message:
MADS: Some more work on Scene 202

Changed paths:
    engines/mads/nebular/game_nebular.h
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index 3d1d915..685e5c7 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -33,7 +33,7 @@ namespace Nebular {
 
 enum StoryMode { STORYMODE_NAUGHTY = 1, STORYMODE_NICE = 2 };
 
-enum InventoryObject {
+enum InventoryObject { OBJ_NONE = 0,
 	OBJ_BURGER = 1, OBJ_DEAD_FISH = 2, OBJ_STUFFED_FISH = 3, OBJ_REBREATHER = 4,
 	OBJ_TIMER_MODULE = 5, OBJ_BIG_LEAVES = 6, OBJ_POISON_DARTS = 7, OBJ_PLANT_STALK = 8,
 	OBJ_BLOWGUN = 9, OBJ_TWINKIFRUIT = 10, OBJ_BONE = 11, OBJ_CHICKEN = 12,
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index f03bf00..84941e6 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -45,7 +45,7 @@ void Scene2xx::setPlayerSpritesPrefix() {
 		_game._player._spritesPrefix = "";
 		break;
 	default:
-		if (_globals[0] == SEX_MALE) {
+		if (_globals[0] != SEX_MALE) {
 			_game._player._spritesPrefix = "ROX";
 		} else {
 			_game._player._spritesPrefix = "RXM";
@@ -348,6 +348,118 @@ void Scene202::setup() {
 }
 
 void Scene202::enter() {
+	_game._player._visible3 = true;
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('b', 0), 0);
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('b', 1), 0);
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('b', 2), 0);
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 0), 0);
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('l', -1), 0);
+	if (_globals[0] != SEX_MALE) {
+		_globals._spriteIndexes[7] = _scene->_sprites.addSprites("*ROXBD_2");
+	} else {
+		_globals._spriteIndexes[7] = _scene->_sprites.addSprites("*RXMBD_2");
+	}
+	_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('a', 0), 0);
+	_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('a', 1), 0);
+	_globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('a', 2), 0);
+
+	_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 0, 0);
+	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 0);
+	_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(149, 113));
+	_scene->_sequences.setDepth(_globals._spriteIndexes[17], 10);
+	int idx = _scene->_dynamicHotspots.add(320, 13, _globals._spriteIndexes[17], Common::Rect(0, 0, 0, 0));
+	_scene->_dynamicHotspots.setPosition(idx, 153, 97, 2);
+
+	if (_globals[32] & 1) {
+		_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[16], Common::Point(130, 108));
+		_scene->_sequences.setDepth(_globals._spriteIndexes[16], 10);
+		idx = _scene->_dynamicHotspots.add(44, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, 132, 97, 2);
+	}
+
+	if (_globals[32] & 2) {
+		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 0, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[21], Common::Point(166, 110));
+		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 10);
+		idx = _scene->_dynamicHotspots.add(44, 13, _globals._spriteIndexes[21], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, 165, 99, 2);
+	}
+
+	if (_globals[32])
+		warning("TODO: sub1EB6E(_globals[32];");
+
+	if (_scene->_priorSceneId == 201) {
+		_game._player._playerPos = Common::Point(190, 91);
+		_game._player._direction = 2;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(178, 152);
+		_game._player._direction = 8;
+	}
+
+	if (_globals[31]) {
+		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 0, 0, 0);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[20], 6);
+		_scene->_hotspots.activate(199, false);
+		idx = _scene->_dynamicHotspots.add(457, 13, _globals._spriteIndexes[20], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, 246, 124, 8);
+	}
+
+	_game.loadQuoteSet(0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x62, 0x63, 0x64, 0x65, 0x66, 0x61, 0);
+	_globals._v0 = 0;
+
+	if (_scene->_priorSceneId == -1) {
+		if (_globals._v5) {
+			_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
+			_game._player._visible = false;
+		}
+	} else {
+		_globals._v5 = 0;
+		_globals._v4 = 0;
+	}
+
+	_globals._v7 = _scene->_frameStartTime;
+	warning("dword_8425C = _scene->_frameStartTime;");
+
+	if (_scene->_roomChanged)
+		_game._objects.addToInventory(OBJ_NONE);
+	
+	if (_globals[38]) {
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+		if (_globals[38] == 2)
+			_globals._v4 = 1;
+		else
+			_globals._v4 = 0;
+
+		if (_globals[38] < 1)
+			_globals._spriteIndexes[25] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
+		else
+			_globals._spriteIndexes[25] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 8);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
+
+		if (_globals._v4) {
+			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(247, 82));
+			_game._player._playerPos = Common::Point(246, 124);
+			_game._player._direction = 8;
+			_globals[41] = -1;
+		} else {
+			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
+			_game._player._playerPos = Common::Point(171, 122);
+			_game._player._direction = 8;
+		}
+
+		_scene->loadAnimation(formAnimName('M', -1), 71);
+		_scene->_activeAnimation->setCurrentFrame(200);
+	} else {
+		_game._player._visible = false;
+		_scene->_sequences.startCycle(_globals._spriteIndexes[24], true, 1);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
+		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
+		_game._player._playerPos = Common::Point(246, 124);
+		_game._player._direction = 8;
+	}
+	_globals._abortVal = 0;
 }
 
 void Scene202::step() {


Commit: db017b746dded2ea287c04c37fbb88ef82492781
    https://github.com/scummvm/scummvm/commit/db017b746dded2ea287c04c37fbb88ef82492781
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-19T19:44:51-04:00

Commit Message:
MADS: Moved ScreenObjects into the Game class

Changed paths:
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/hotspots.cpp
    engines/mads/inventory.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h
    engines/mads/screen.cpp
    engines/mads/screen.h
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index e65330a..06ea2a5 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -40,7 +40,7 @@ Game *Game::init(MADSEngine *vm) {
 }
 
 Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm), 
-		_scene(vm), _player(vm) {
+		_scene(vm), _screenObjects(vm), _player(vm) {
 	_sectionNumber = _priorSectionNumber = 0;
 	_difficultyLevel = DIFFICULTY_HARD;
 	_saveSlot = -1;
@@ -163,8 +163,8 @@ void Game::sectionLoop() {
 		_vm->_dialogs->_defaultPosition = Common::Point(-1, -1);
 		_visitedScenes.add(_scene._nextSceneId);
 
-		_scene._screenObjects._v8333C = true;
-		_scene._screenObjects._v832EC = 0;
+		_screenObjects._v8333C = true;
+		_screenObjects._v832EC = 0;
 		_scene._userInterface._scrollerY = 0;
 		_v3 = -1;
 
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 6ef1ca9..444e2fa 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -29,6 +29,7 @@
 #include "mads/game_data.h"
 #include "mads/inventory.h"
 #include "mads/player.h"
+#include "mads/screen.h"
 
 namespace MADS {
 
@@ -112,6 +113,7 @@ public:
 	static Game *init(MADSEngine *vm);
 public:
 	Player _player;
+	ScreenObjects _screenObjects;
 	int _sectionNumber;
 	int _priorSectionNumber;
 	int _currentSectionNumber;
diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
index b33b4b2..df56a69 100644
--- a/engines/mads/hotspots.cpp
+++ b/engines/mads/hotspots.cpp
@@ -126,12 +126,12 @@ void DynamicHotspots::refresh() {
 		DynamicHotspot &dh = (*this)[i];
 
 		if ((*this)[i]._active) {
-			switch (_vm->_game->_scene._screenObjects._v832EC) {
+			switch (_vm->_game->_screenObjects._v832EC) {
 			case 0:
 			case 2:
-				_vm->_game->_scene._screenObjects.add(dh._bounds, _vm->_game->_scene._layer,
+				_vm->_game->_screenObjects.add(dh._bounds, _vm->_game->_scene._layer,
 					CAT_12, dh._descId);
-				_vm->_game->_scene._screenObjects._v8333C = true;
+				_vm->_game->_screenObjects._v8333C = true;
 				break;
 			default:
 				break;
diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index b697462..1443761 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -116,7 +116,7 @@ void InventoryObjects::addToInventory(int objectId) {
 
 		(*this)[objectId]._roomNumber = PLAYER_INVENTORY;
 
-		if (_vm->_game->_v1 == 5 && !_vm->_game->_scene._screenObjects._v832EC) {
+		if (_vm->_game->_v1 == 5 && !_vm->_game->_screenObjects._v832EC) {
 			userInterface.categoryChanged();
 			userInterface.selectObject(userInterface._selectedInvIndex);
 		}
@@ -137,7 +137,7 @@ void InventoryObjects::removeFromInventory(int objectId, int newScene) {
 	int selectedIndex = userInterface._selectedInvIndex;
 	bool noSelection = selectedIndex < 0;
 
-	if (_vm->_game->_v1 == 5 && !scene._screenObjects._v832EC)
+	if (_vm->_game->_v1 == 5 && !_vm->_game->_screenObjects._v832EC)
 		userInterface.selectObject(-1);
 
 	// Remove the item from the inventory list
@@ -158,7 +158,7 @@ void InventoryObjects::removeFromInventory(int objectId, int newScene) {
 			newIndex = 0;
 	}
 
-	if (_vm->_game->_v1 == 5 && !scene._screenObjects._v832EC) {
+	if (_vm->_game->_v1 == 5 && !_vm->_game->_screenObjects._v832EC) {
 		userInterface.categoryChanged();
 		userInterface.selectObject(newIndex);
 	}
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 02ef916..741ba82 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -30,7 +30,7 @@ namespace MADS {
 
 Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 		_dirtyAreas(_vm),  _dynamicHotspots(vm), _kernelMessages(vm), 
-		_screenObjects(vm), _sequences(vm), _sprites(vm), _spriteSlots(vm), 
+		_sequences(vm), _sprites(vm), _spriteSlots(vm), 
 		_textDisplay(vm), _userInterface(vm) {
 	_priorSceneId = 0;
 	_nextSceneId = 0;
@@ -162,7 +162,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	_interfaceY = MADS_SCENE_HEIGHT;
 	_spritesCount = _sprites.size();
 
-	_userInterface.setup(_screenObjects._v832EC);
+	_userInterface.setup(_vm->_game->_screenObjects._v832EC);
 
 	warning("TODO: showMouse");
 
@@ -289,7 +289,7 @@ void Scene::doFrame() {
 		if (_dynamicHotspots._changed)
 			_dynamicHotspots.refresh();
 
-		_screenObjects.check(player._stepEnabled && !_action._startWalkFlag &&
+		_vm->_game->_screenObjects.check(player._stepEnabled && !_action._startWalkFlag &&
 				!_vm->_game->_abortTimers2);
 	}
 
@@ -331,9 +331,9 @@ void Scene::doFrame() {
 
 			// Cursor update code
 			CursorType cursorId = CURSOR_ARROW;
-			if (_action._v83338 == 1 && !_screenObjects._v7FECA &&
-					_screenObjects._category == CAT_HOTSPOT) {
-				int idx = _screenObjects._selectedObject - _userInterface._screenObjectsCount;
+			if (_action._v83338 == 1 && !_vm->_game->_screenObjects._v7FECA &&
+					_vm->_game->_screenObjects._category == CAT_HOTSPOT) {
+				int idx = _vm->_game->_screenObjects._selectedObject - _userInterface._screenObjectsCount;
 				if (idx >= (int)_hotspots.size()) {
 					idx -= _hotspots.size();
 					_vm->_events->_newCursorId = _dynamicHotspots[idx]._cursor;
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index f5163bb..9493eda 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -89,7 +89,6 @@ public:
 	Common::String _talkFont;
 	int _textSpacing;
 	Hotspots _hotspots;
-	ScreenObjects _screenObjects;
 	DirtyAreas _dirtyAreas;
 	int _v1;
 	SceneInfo *_sceneInfo;
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 8980bd4..625eec7 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -30,112 +30,6 @@
 
 namespace MADS {
 
-ScreenObject::ScreenObject() {
-	_category = CAT_NONE;
-	_descId = 0;
-	_layer = 0;
-}
-
-/*------------------------------------------------------------------------*/
-
-ScreenObjects::ScreenObjects(MADSEngine *vm): _vm(vm) {
-	_v8333C = false;
-	_v832EC = 0;
-	_v7FECA = 0;
-	_v7FED6 = 0;
-	_v8332A = 0;
-	_category = CAT_NONE;
-	_objectIndex = 0;
-	_released = false;
-}
-
-void ScreenObjects::add(const Common::Rect &bounds, Layer layer, ScrCategory category, int descId) {
-	assert(size() < 100);
-
-	ScreenObject so;
-	so._bounds = bounds;
-	so._category = category;
-	so._descId = descId;
-	so._layer = layer;
-
-	push_back(so);
-}
-
-void ScreenObjects::check(bool scanFlag) {
-	Scene &scene = _vm->_game->_scene;
-
-	if (!_vm->_events->_mouseButtons || _v832EC)
-		_v7FECA = false;
-
-	if ((_vm->_events->_vD6 || _v8332A || _vm->_game->_scene._userInterface._scrollerY || _v8333C) && scanFlag) {
-		scene._userInterface._selectedInvIndex = scanBackwards(_vm->_events->currentPos(), LAYER_GUI);
-		if (scene._userInterface._selectedInvIndex > 0) {
-			_category = (ScrCategory)((*this)[scene._userInterface._selectedInvIndex - 1]._category & 7);
-			_objectIndex = (*this)[scene._userInterface._selectedInvIndex - 1]._descId;
-		}
-
-		// Handling for easy mouse
-		ScrCategory category = scene._userInterface._category;
-		if (_vm->_easyMouse && !_vm->_events->_vD4 && category != _category
-				&& scene._userInterface._category != CAT_NONE) {
-			_released = true;
-			if (category >= CAT_ACTION && category <= CAT_TALK_ENTRY) {
-				scene._userInterface.elementHighlighted();
-			} 
-		}
-
-		_released = _vm->_events->_mouseReleased;
-		if (_vm->_events->_vD2 || (_vm->_easyMouse && !_vm->_events->_vD4))
-			scene._userInterface._category = _category;
-
-		if (!_vm->_events->_mouseButtons || _vm->_easyMouse) {
-			if (category >= CAT_ACTION && category <= CAT_TALK_ENTRY) {
-				scene._userInterface.elementHighlighted();
-			}
-		}
-
-		if (_vm->_events->_mouseButtons || (_vm->_easyMouse && scene._action._v83338 > 1
-				&& scene._userInterface._category == CAT_INV_LIST) ||
-				(_vm->_easyMouse && scene._userInterface._category == CAT_HOTSPOT)) {
-			scene._action.checkActionAtMousePos();
-		}
-			
-		if (_vm->_events->_mouseReleased) {
-			scene.leftClick();
-			scene._userInterface._category = CAT_NONE;
-		}
-
-		if (_vm->_events->_mouseButtons || _vm->_easyMouse || scene._userInterface._scrollerY)
-			proc1();
-
-		if (_vm->_events->_mouseButtons || _vm->_easyMouse)
-			scene._action.set();
-
-		_v8333C = 0;
-	}
-
-	scene._action.refresh();
-
-	// Loop through image inter list
-	warning("TODO: imageInterList loop");
-}
-
-int ScreenObjects::scanBackwards(const Common::Point &pt, int layer) {
-	for (int i = (int)size() - 1; i >= 0; --i) {
-		if ((*this)[i]._bounds.contains(pt) && ((*this)[i]._layer == layer))
-			return i + 1;
-	}
-
-	// Entry not found
-	return 0;
-}
-
-void ScreenObjects::proc1() {
-	warning("TODO: ScreenObjects::proc1");
-}
-
-/*------------------------------------------------------------------------*/
-
 void SceneNode::load(Common::SeekableReadStream *f) {
 	_walkPos.x = f->readSint16LE();
 	_walkPos.y = f->readSint16LE();
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 1543669..d29d4e3 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -51,10 +51,6 @@ class SpriteSlot;
 #define TEXT_DISPLAY_MAX_SIZE 40
 #define DIRTY_AREAS_SIZE (SPRITE_SLOTS_MAX_SIZE + TEXT_DISPLAY_MAX_SIZE)
 
-enum Layer {
-	LAYER_GUI = 19
-};
-
 class VerbInit {
 public:
 	int _id;
@@ -65,49 +61,6 @@ public:
 	VerbInit(int id, int action1, int action2): _id(id), _action1(action1), _action2(action2) {}
 };
 
-class ScreenObject {
-public:
-	Common::Rect _bounds;
-	ScrCategory _category;
-	int _descId;
-	int _layer;
-
-	ScreenObject();
-};
-
-class ScreenObjects: public Common::Array<ScreenObject> {
-private:
-	MADSEngine *_vm;
-
-	int scanBackwards(const Common::Point &pt, int layer);
-
-	void proc1();
-public:
-	int _v832EC;
-	int _v7FECA;
-	int _v7FED6;
-	int _v8332A;
-	int _v8333C;
-	int _selectedObject;
-	ScrCategory _category;
-	int _objectIndex;
-	bool _released;
-
-	/*
-	 * Constructor
-	 */
-	ScreenObjects(MADSEngine *vm);
-
-	/**
-	 * Add a new item to the list
-	 */
-	void add(const Common::Rect &bounds, Layer layer, ScrCategory category, int descId);
-
-	/**
-	 */
-	void check(bool scanFlag);
-};
-
 class SceneLogic {
 protected:
 	MADSEngine *_vm;
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 8b05d7a..608456e 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -243,6 +243,112 @@ void DirtyAreas::reset() {
 
 /*------------------------------------------------------------------------*/
 
+ScreenObject::ScreenObject() {
+	_category = CAT_NONE;
+	_descId = 0;
+	_layer = 0;
+}
+
+/*------------------------------------------------------------------------*/
+
+ScreenObjects::ScreenObjects(MADSEngine *vm) : _vm(vm) {
+	_v8333C = false;
+	_v832EC = 0;
+	_v7FECA = 0;
+	_v7FED6 = 0;
+	_v8332A = 0;
+	_category = CAT_NONE;
+	_objectIndex = 0;
+	_released = false;
+}
+
+void ScreenObjects::add(const Common::Rect &bounds, Layer layer, ScrCategory category, int descId) {
+	assert(size() < 100);
+
+	ScreenObject so;
+	so._bounds = bounds;
+	so._category = category;
+	so._descId = descId;
+	so._layer = layer;
+
+	push_back(so);
+}
+
+void ScreenObjects::check(bool scanFlag) {
+	Scene &scene = _vm->_game->_scene;
+
+	if (!_vm->_events->_mouseButtons || _v832EC)
+		_v7FECA = false;
+
+	if ((_vm->_events->_vD6 || _v8332A || _vm->_game->_scene._userInterface._scrollerY || _v8333C) && scanFlag) {
+		scene._userInterface._selectedInvIndex = scanBackwards(_vm->_events->currentPos(), LAYER_GUI);
+		if (scene._userInterface._selectedInvIndex > 0) {
+			_category = (ScrCategory)((*this)[scene._userInterface._selectedInvIndex - 1]._category & 7);
+			_objectIndex = (*this)[scene._userInterface._selectedInvIndex - 1]._descId;
+		}
+
+		// Handling for easy mouse
+		ScrCategory category = scene._userInterface._category;
+		if (_vm->_easyMouse && !_vm->_events->_vD4 && category != _category
+			&& scene._userInterface._category != CAT_NONE) {
+			_released = true;
+			if (category >= CAT_ACTION && category <= CAT_TALK_ENTRY) {
+				scene._userInterface.elementHighlighted();
+			}
+		}
+
+		_released = _vm->_events->_mouseReleased;
+		if (_vm->_events->_vD2 || (_vm->_easyMouse && !_vm->_events->_vD4))
+			scene._userInterface._category = _category;
+
+		if (!_vm->_events->_mouseButtons || _vm->_easyMouse) {
+			if (category >= CAT_ACTION && category <= CAT_TALK_ENTRY) {
+				scene._userInterface.elementHighlighted();
+			}
+		}
+
+		if (_vm->_events->_mouseButtons || (_vm->_easyMouse && scene._action._v83338 > 1
+			&& scene._userInterface._category == CAT_INV_LIST) ||
+			(_vm->_easyMouse && scene._userInterface._category == CAT_HOTSPOT)) {
+			scene._action.checkActionAtMousePos();
+		}
+
+		if (_vm->_events->_mouseReleased) {
+			scene.leftClick();
+			scene._userInterface._category = CAT_NONE;
+		}
+
+		if (_vm->_events->_mouseButtons || _vm->_easyMouse || scene._userInterface._scrollerY)
+			proc1();
+
+		if (_vm->_events->_mouseButtons || _vm->_easyMouse)
+			scene._action.set();
+
+		_v8333C = 0;
+	}
+
+	scene._action.refresh();
+
+	// Loop through image inter list
+	warning("TODO: imageInterList loop");
+}
+
+int ScreenObjects::scanBackwards(const Common::Point &pt, int layer) {
+	for (int i = (int)size() - 1; i >= 0; --i) {
+		if ((*this)[i]._bounds.contains(pt) && ((*this)[i]._layer == layer))
+			return i + 1;
+	}
+
+	// Entry not found
+	return 0;
+}
+
+void ScreenObjects::proc1() {
+	warning("TODO: ScreenObjects::proc1");
+}
+
+/*------------------------------------------------------------------------*/
+
 ScreenSurface::ScreenSurface() {
 	_dataP = nullptr;
 }
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index 06053e8..9033206 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -32,6 +32,16 @@ namespace MADS {
 #define MADS_SCREEN_WIDTH 320
 #define MADS_SCREEN_HEIGHT 200
 
+enum ScrCategory {
+	CAT_NONE = 0, CAT_ACTION = 1, CAT_INV_LIST = 2, CAT_INV_VOCAB = 3,
+	CAT_HOTSPOT = 4, CAT_INV_ANIM = 5, CAT_TALK_ENTRY = 6, CAT_INV_SCROLLER = 7,
+	CAT_12 = 12
+};
+
+enum Layer {
+	LAYER_GUI = 19
+};
+
 enum ScreenTransition {
 	kTransitionNone = 0,
 	kTransitionFadeIn, kTransitionFadeOutIn,
@@ -112,6 +122,50 @@ public:
 	void reset();
 };
 
+
+class ScreenObject {
+public:
+	Common::Rect _bounds;
+	ScrCategory _category;
+	int _descId;
+	int _layer;
+
+	ScreenObject();
+};
+
+class ScreenObjects : public Common::Array<ScreenObject> {
+private:
+	MADSEngine *_vm;
+
+	int scanBackwards(const Common::Point &pt, int layer);
+
+	void proc1();
+public:
+	int _v832EC;
+	int _v7FECA;
+	int _v7FED6;
+	int _v8332A;
+	int _v8333C;
+	int _selectedObject;
+	ScrCategory _category;
+	int _objectIndex;
+	bool _released;
+
+	/*
+	* Constructor
+	*/
+	ScreenObjects(MADSEngine *vm);
+
+	/**
+	* Add a new item to the list
+	*/
+	void add(const Common::Rect &bounds, Layer layer, ScrCategory category, int descId);
+
+	/**
+	*/
+	void check(bool scanFlag);
+};
+
 class ScreenSurface : public MSurface {
 private:
 	/**
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 5a15293..f46a4c4 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -151,7 +151,6 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 
 		for (uint idx = 0; idx < size(); ++idx) {
 			DirtyArea &dirtyArea = userInterface._dirtyAreas[idx];
-			UISlot &slot = (*this)[idx];
 
 			if (dirtyArea._active && dirtyArea._textActive &&
 				dirtyArea._bounds.width() > 0 && dirtyArea._bounds.height() > 0) {
@@ -238,7 +237,7 @@ void UserInterface::load(const Common::String &resName) {
 void UserInterface::setup(int id) {
 	Scene &scene = _vm->_game->_scene;
 
-	if (scene._screenObjects._v832EC != id) {
+	if (_vm->_game->_screenObjects._v832EC != id) {
 		Common::String resName = _vm->_game->_aaName;
 
 		// Strip off any extension
@@ -256,7 +255,7 @@ void UserInterface::setup(int id) {
 		load(resName);
 		_surface.copyTo(this);
 	}
-	scene._screenObjects._v832EC = id;
+	_vm->_game->_screenObjects._v832EC = id;
 
 	scene._userInterface._uiSlots.clear();
 	scene._userInterface._uiSlots.fullRefresh();
@@ -279,8 +278,7 @@ void UserInterface::elementHighlighted() {
 }
 
 void UserInterface::drawTextElements() {
-	Scene &scene = _vm->_game->_scene;
-	if (scene._screenObjects._v832EC) {
+	if (_vm->_game->_screenObjects._v832EC) {
 		drawTalkList();
 	} else {
 		// Draw the actions
@@ -406,15 +404,15 @@ void UserInterface::setBounds(const Common::Rect &r) {
 void UserInterface::loadElements() {
 	Scene &scene = _vm->_game->_scene;
 	Common::Rect bounds;
-	scene._screenObjects.clear();
+	_vm->_game->_screenObjects.clear();
 
-	if (!scene._screenObjects._v832EC) {
+	if (!_vm->_game->_screenObjects._v832EC) {
 		// Set up screen objects for the inventory scroller
 		for (int idx = 1; idx <= 3; ++idx) {
 			getBounds(CAT_INV_SCROLLER, idx, bounds);
 			moveRect(bounds);
 
-			scene._screenObjects.add(bounds, LAYER_GUI, CAT_INV_SCROLLER, idx);
+			_vm->_game->_screenObjects.add(bounds, LAYER_GUI, CAT_INV_SCROLLER, idx);
 		}
 
 		// Set up actions
@@ -422,7 +420,7 @@ void UserInterface::loadElements() {
 			getBounds(CAT_ACTION, idx, bounds);
 			moveRect(bounds);
 
-			scene._screenObjects.add(bounds, LAYER_GUI, CAT_ACTION, idx);
+			_vm->_game->_screenObjects.add(bounds, LAYER_GUI, CAT_ACTION, idx);
 		}
 
 		// Set up inventory list
@@ -430,7 +428,7 @@ void UserInterface::loadElements() {
 			getBounds(CAT_INV_LIST, idx, bounds);
 			moveRect(bounds);
 
-			scene._screenObjects.add(bounds, LAYER_GUI, CAT_INV_LIST, idx);
+			_vm->_game->_screenObjects.add(bounds, LAYER_GUI, CAT_INV_LIST, idx);
 		}
 
 		// Set up the inventory vocab list
@@ -438,28 +436,28 @@ void UserInterface::loadElements() {
 			getBounds(CAT_INV_VOCAB, idx, bounds);
 			moveRect(bounds);
 
-			scene._screenObjects.add(bounds, LAYER_GUI, CAT_INV_VOCAB, idx);
+			_vm->_game->_screenObjects.add(bounds, LAYER_GUI, CAT_INV_VOCAB, idx);
 		}
 
 		// Set up the inventory item picture
-		scene._screenObjects.add(Common::Rect(160, 159, 231, 194), LAYER_GUI,
+		_vm->_game->_screenObjects.add(Common::Rect(160, 159, 231, 194), LAYER_GUI,
 			CAT_INV_ANIM, 0);
 	}
 
-	if (!scene._screenObjects._v832EC || scene._screenObjects._v832EC == 2) {
+	if (!_vm->_game->_screenObjects._v832EC || _vm->_game->_screenObjects._v832EC == 2) {
 		for (int hotspotIdx = scene._hotspots.size() - 1; hotspotIdx >= 0; --hotspotIdx) {
 			Hotspot &hs = scene._hotspots[hotspotIdx];
-			scene._screenObjects.add(hs._bounds, LAYER_GUI, CAT_HOTSPOT, hotspotIdx);
+			_vm->_game->_screenObjects.add(hs._bounds, LAYER_GUI, CAT_HOTSPOT, hotspotIdx);
 		}
 	}
 
-	if (scene._screenObjects._v832EC == 1) {
+	if (_vm->_game->_screenObjects._v832EC == 1) {
 		// setup areas for talk entries
 		for (int idx = 0; idx < 5; ++idx) {
 			getBounds(CAT_TALK_ENTRY, idx, bounds);
 			moveRect(bounds);
 
-			scene._screenObjects.add(bounds, LAYER_GUI, CAT_TALK_ENTRY, idx);
+			_vm->_game->_screenObjects.add(bounds, LAYER_GUI, CAT_TALK_ENTRY, idx);
 		}
 	}
 }
@@ -585,7 +583,7 @@ void UserInterface::noInventoryAnim() {
 		_invSpritesIndex = -1;
 	}
 
-	if (!scene._screenObjects._v832EC)
+	if (!_vm->_game->_screenObjects._v832EC)
 		refresh();
 }
 
@@ -599,7 +597,7 @@ void UserInterface::refresh() {
 
 void UserInterface::inventoryAnim() {
 	Scene &scene = _vm->_game->_scene;
-	if (scene._screenObjects._v832EC == 1 || scene._screenObjects._v832EC == 2
+	if (_vm->_game->_screenObjects._v832EC == 1 || _vm->_game->_screenObjects._v832EC == 2
 			|| _invSpritesIndex < 0)
 		return;
 
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 07c3f74..b4c581d 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -31,12 +31,6 @@
 
 namespace MADS {
 
-enum ScrCategory {
-	CAT_NONE = 0, CAT_ACTION = 1, CAT_INV_LIST = 2, CAT_INV_VOCAB = 3,
-	CAT_HOTSPOT = 4, CAT_INV_ANIM = 5, CAT_TALK_ENTRY = 6, CAT_INV_SCROLLER = 7,
-	CAT_12 = 12
-};
-
 class UISlot {
 public:
 	int _slotType;


Commit: 4ab73a89abd66890391a977ebf4a23eb361a44a4
    https://github.com/scummvm/scummvm/commit/4ab73a89abd66890391a977ebf4a23eb361a44a4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-19T20:12:32-04:00

Commit Message:
MADS: Preliminary code to show game cursor

Changed paths:
    engines/mads/events.cpp



diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 182d6cb..32d3a09 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -85,7 +85,12 @@ void EventsManager::resetCursor() {
 }
 
 void EventsManager::changeCursor() {
-	warning("TODO: changeCursor");
+	if (_cursorSprites) {
+		MSprite *cursor = _cursorSprites->getFrame(_cursorId - 1);
+		CursorMan.replaceCursor(cursor->getData(), cursor->w, cursor->h, 0, 0,
+			cursor->getTransparencyIndex());
+		showCursor();
+	}
 }
 
 void EventsManager::freeCursors() {


Commit: 8d252f4f0e81cfd43e5b311df4a1ed5fb478953b
    https://github.com/scummvm/scummvm/commit/8d252f4f0e81cfd43e5b311df4a1ed5fb478953b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-19T23:33:18-04:00

Commit Message:
MADS: Implemented methods for checking action at mouse position and clicking

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h
    engines/mads/hotspots.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/screen.cpp
    engines/mads/screen.h
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 134321f..65abc94 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -39,8 +39,8 @@ MADSAction::MADSAction(MADSEngine *vm) : _vm(vm) {
 
 void MADSAction::clear() {
 	_v83338 = 1;
-	_actionMode = ACTMODE_NONE;
-	_actionMode2 = ACTMODE2_0;
+	_actionMode = ACTIONMODE_NONE;
+	_actionMode2 = ACTIONMODE2_0;
 	_v86F42 = 0;
 	_v86F4E = 0;
 	_articleNumber = 0;
@@ -339,7 +339,273 @@ bool MADSAction::isAction(int verbId, int objectNameId, int indirectObjectId) {
 }
 
 void MADSAction::checkActionAtMousePos() {
-	warning("TODO: checkActionAtMousePos");
+	Scene &scene = _vm->_game->_scene;
+	UserInterface &userInterface = scene._userInterface;
+	ScreenObjects &screenObjects = _vm->_game->_screenObjects;
+
+	if ((userInterface._category == CAT_ACTION || userInterface._category == CAT_INV_VOCAB) &&
+			_v83338 != 1 && scene._highlightedHotspot >= 0) {
+		if (_v86F4E == userInterface._category || _v86F4C != scene._highlightedHotspot ||
+			(_v83338 != 2 && _v83338 != 3))
+			clear();
+		else if (_selectedRow != 0 || userInterface._category != CAT_ACTION)
+			scene._lookFlag = false;
+		else
+			scene._lookFlag = true;
+	}
+
+	if (screenObjects._v7FECA && _vm->_events->_mouseButtons) {
+		switch (userInterface._category) {
+		case CAT_ACTION:
+		case CAT_INV_VOCAB:
+			return;
+
+		case CAT_INV_LIST:
+		case CAT_TALK_ENTRY:
+			if (_v83338 != 3) {
+				if (userInterface._selectedActionIndex >= 0) {
+					_actionMode = ACTIONMODE_VERB;
+					_selectedRow = userInterface._selectedActionIndex;
+					_flags1 = scene._verbList[_selectedRow]._action1;
+					_flags2 = scene._verbList[_selectedRow]._action2;
+					_v83338 = 2;
+				} else if (userInterface._selectedItemVocabIdx >= 0) {
+					_actionMode = ACTIONMODE_OBJECT;
+					_selectedRow = userInterface._selectedItemVocabIdx;
+					int objectId = _vm->_game->_objects._inventoryList[_selectedRow];
+					InventoryObject &invObject = _vm->_game->_objects[objectId];
+
+					_flags1 = invObject._vocabList[_selectedRow - 1]._actionFlags1;
+					_flags2 = invObject._vocabList[_selectedRow - 1]._actionFlags2;
+					_actionMode2 = ACTIONMODE2_2;
+					_hotspotId = userInterface._selectedInvIndex;
+					_articleNumber = _flags2;
+
+					if ((_flags1 == 1 && _flags2 == 0) || (_flags1 == 2 && _flags2 != 0))
+						_v83338 = 4;
+					else
+						_v83338 = 3;
+				}
+			}
+			break;
+		}
+	}
+
+	switch (_v83338) {
+	case 1:
+		_articleNumber = 0;
+		switch (userInterface._category) {
+		case CAT_ACTION:
+			_actionMode = ACTIONMODE_VERB;
+			_selectedRow = scene._highlightedHotspot;
+			if (_selectedRow >= 0) {
+				_flags1 = scene._verbList[_selectedRow]._action1;
+				_flags2 = scene._verbList[_selectedRow]._action2;
+			}
+			break;
+
+		case CAT_INV_VOCAB:
+			_actionMode = ACTIONMODE_OBJECT;
+			_selectedRow = scene._highlightedHotspot;
+			if (_selectedRow < 0) {
+				_hotspotId = -1;
+				_actionMode2 = ACTIONMODE2_0;
+			} else {
+				int objectId = _vm->_game->_objects._inventoryList[_selectedRow];
+				InventoryObject &invObject = _vm->_game->_objects[objectId];
+
+				_flags1 = invObject._vocabList[_selectedRow - 2]._actionFlags1;
+				_flags2 = invObject._vocabList[_selectedRow - 2]._actionFlags2;
+				_hotspotId = userInterface._selectedInvIndex;
+				_actionMode2 = ACTIONMODE2_2;
+
+				if (_flags1 == 2)
+					_articleNumber = _flags2;
+			}
+			break;
+
+		case CAT_HOTSPOT:
+			_selectedRow = -1;
+			_actionMode = ACTIONMODE_NONE;
+			_actionMode2 = ACTIONMODE2_4;
+			_hotspotId = scene._highlightedHotspot;
+			break;
+
+		case CAT_TALK_ENTRY:
+			_actionMode = ACTIONMODE_TALK;
+			_selectedRow = scene._highlightedHotspot;
+			break;
+
+		default:
+			break;
+		}
+		break;
+
+	case 2:
+		_articleNumber = 0;
+		switch (userInterface._category) {
+		case CAT_INV_LIST:
+		case CAT_HOTSPOT:
+		case CAT_INV_ANIM:
+			// TODO: We may not need a separate ActionMode2 enum
+			_actionMode2 = (ActionMode2)userInterface._category;
+			_hotspotId = scene._highlightedHotspot;
+			break;
+		default:
+			break;
+		}
+		break;
+
+	case 3:
+		switch (userInterface._category) {
+		case CAT_INV_LIST:
+		case CAT_HOTSPOT:
+		case CAT_INV_ANIM:
+			_v86F42 = userInterface._category;
+			_v86F3A = scene._highlightedHotspot;
+			break;
+		default:
+			break;
+		}
+		break;
+
+	default:
+		break;
+	}
+}
+
+void MADSAction::leftClick() {
+	Scene &scene = _vm->_game->_scene;
+	UserInterface &userInterface = scene._userInterface;
+	ScreenObjects &screenObjects = _vm->_game->_screenObjects;
+	bool abortFlag = false;
+
+	if ((userInterface._category == CAT_ACTION || userInterface._category == CAT_INV_VOCAB) &&
+			_v83338 != 1 && scene._highlightedHotspot >= 0 && 
+			_v86F4E == userInterface._category && _v86F4C == scene._highlightedHotspot &&
+			(_v83338 == 2 || userInterface._category == CAT_INV_VOCAB)) {
+		abortFlag = true;
+		if (_selectedRow == 0 && userInterface._category == CAT_ACTION) {
+			_selectedAction = CAT_ACTION;
+			scene._lookFlag = true;
+		} else {
+			_selectedAction = CAT_NONE;
+			scene._lookFlag = false;
+			clear();
+		}
+	}
+
+	if (abortFlag || (screenObjects._v7FECA && (userInterface._category == CAT_ACTION ||
+			userInterface._category == CAT_INV_VOCAB)))
+		return;
+
+	switch (_v83338) {
+	case 1:
+		switch (userInterface._category) {
+		case CAT_ACTION:
+			if (_selectedRow >= 0) {
+				if (!_flags1) {
+					_selectedAction = -1;
+				}
+				else {
+					_v86F4C = _selectedRow;
+					_v86F4E = _actionMode;
+					_v83338 = 2;
+				}
+			}
+			break;
+
+		case CAT_INV_LIST:
+			if (scene._highlightedHotspot >= 0) {
+				userInterface.selectObject(scene._highlightedHotspot);
+			}
+			break;
+
+		case CAT_INV_VOCAB:
+			if (_selectedRow >= 0) {
+				if (_flags1 != 1 || _flags2 != 0) {
+					if (_flags1 != 2 || _flags2 == 0) {
+						_v83338 = 3;
+						_articleNumber = _flags2;
+					}
+					else {
+						_articleNumber = _flags2;
+						_selectedAction = -1;
+					}
+				}
+				else {
+					_selectedAction = -1;
+				}
+
+				_v86F4C = _selectedRow;
+				_v86F4E = _actionMode;
+			}
+			break;
+
+		case CAT_HOTSPOT:
+			_v86F4C = -1;
+			_v86F4E = 0;
+
+			if (_vm->_events->currentPos().y < MADS_SCENE_HEIGHT)
+				scene._customDest = _vm->_events->currentPos() + scene._posAdjust;
+			break;
+
+		case CAT_TALK_ENTRY:
+			if (_selectedRow >= 0)
+				_selectedAction = -1;
+			break;
+
+		default:
+			break;
+		}
+		break;
+
+	case 2:
+		switch (userInterface._category) {
+		case CAT_INV_LIST:
+		case CAT_HOTSPOT:
+		case CAT_INV_ANIM:
+			if (_hotspotId >= 0) {
+				if (_flags2) {
+					_articleNumber = _flags2;
+					_v83338 = 3;
+				}
+				else {
+					_selectedAction = -1;
+				}
+
+				if (userInterface._category == CAT_HOTSPOT) {
+					scene._customDest = _vm->_events->mousePos() + scene._posAdjust;
+					_v86F4A = true;
+				}
+			}
+			break;
+		default:
+			break;
+		}
+		break;
+
+	case 3:
+		switch (userInterface._category) {
+		case CAT_INV_LIST:
+		case CAT_HOTSPOT:
+		case CAT_INV_ANIM:
+			if (_v86F3A >= 0) {
+				_selectedAction = -1;
+
+				if (userInterface._category == CAT_HOTSPOT) {
+					if (!_v86F4A) {
+						scene._customDest = _vm->_events->mousePos() + scene._posAdjust;
+						_v86F4A = true;
+					}
+				}
+			}
+			break;
+		default:
+			break;
+		}
+		break;
+	}
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/action.h b/engines/mads/action.h
index da738ac..440990f 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -28,8 +28,8 @@
 
 namespace MADS {
 
-enum ActionMode { ACTMODE_NONE = 0, ACTMODE_VERB = 1, ACTMODE_OBJECT = 3, ACTMODE_TALK = 6 };
-enum ActionMode2 { ACTMODE2_0 = 0, ACTMODE2_2 = 2, ACTMODE2_4 = 4, ACTMODE2_5 = 5 };
+enum ActionMode { ACTIONMODE_NONE = 0, ACTIONMODE_VERB = 1, ACTIONMODE_OBJECT = 3, ACTIONMODE_TALK = 6 };
+enum ActionMode2 { ACTIONMODE2_0 = 0, ACTIONMODE2_2 = 2, ACTIONMODE2_4 = 4, ACTIONMODE2_5 = 5 };
 enum AbortTimerMode { ABORTMODE_0 = 0, ABORTMODE_1 = 1, ABORTMODE_2 = 2 };
 
 enum {
@@ -47,6 +47,7 @@ enum {
 	VERB_WALKTO = 13
 };
 
+
 class MADSEngine;
 
 struct ActionDetails {
@@ -110,6 +111,11 @@ public:
 	bool isAction(int verbId, int objectNameId = 0, int indirectObjectId = 0);
 	
 	void checkActionAtMousePos();
+
+	/**
+	* Execute a click within the scene
+	*/
+	void leftClick();
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
index df56a69..91b8127 100644
--- a/engines/mads/hotspots.cpp
+++ b/engines/mads/hotspots.cpp
@@ -122,16 +122,20 @@ void DynamicHotspots::reset() {
 }
 
 void DynamicHotspots::refresh() {
+	// Reset the screen objects back to only contain UI elements
+	ScreenObjects &scrObjects = _vm->_game->_screenObjects;
+	scrObjects.resize(scrObjects._uiCount);
+
+	// Loop through adding hotspots
 	for (uint i = 0; i < _entries.size(); ++i) {
 		DynamicHotspot &dh = (*this)[i];
 
 		if ((*this)[i]._active) {
-			switch (_vm->_game->_screenObjects._v832EC) {
+			switch (scrObjects._v832EC) {
 			case 0:
 			case 2:
-				_vm->_game->_screenObjects.add(dh._bounds, _vm->_game->_scene._layer,
-					CAT_12, dh._descId);
-				_vm->_game->_screenObjects._v8333C = true;
+				scrObjects.add(dh._bounds, _vm->_game->_scene._layer, CAT_12, dh._descId);
+				scrObjects._v8333C = true;
 				break;
 			default:
 				break;
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 741ba82..baf51fe 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -49,6 +49,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 	_textSpacing = -1;
 	_frameStartTime = 0;
 	_layer = LAYER_GUI;
+	_lookFlag = false;
+	_highlightedHotspot = 0;
 
 	_verbList.push_back(VerbInit(VERB_LOOK, 2, 0));
 	_verbList.push_back(VerbInit(VERB_TAKE, 2, 0));
@@ -463,10 +465,6 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
 	_textDisplay.cleanUp();
 }
 
-void Scene::leftClick() {
-	warning("TODO: Scene::leftClick");
-}
-
 void Scene::doPreactions() {
 	warning("TODO: Scene::doPreactions");
 }
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 9493eda..16684c4 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -118,6 +118,9 @@ public:
 	Common::Point _posAdjust;
 	uint32 _frameStartTime;
 	Layer _layer;
+	bool _lookFlag;
+	int _highlightedHotspot;
+	Common::Point _customDest;
 
 	/**
 	 * Constructor
@@ -185,11 +188,6 @@ public:
 	void drawElements(ScreenTransition transitionType, bool surfaceFlag);
 
 	/**
-	 * Execute a click within the scene
-	 */
-	void leftClick();
-
-	/**
 	 * Load an animation
 	 */
 	void loadAnimation(const Common::String &resName, int abortTimers = 0);
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 608456e..1f1fc0a 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -260,6 +260,7 @@ ScreenObjects::ScreenObjects(MADSEngine *vm) : _vm(vm) {
 	_category = CAT_NONE;
 	_objectIndex = 0;
 	_released = false;
+	_uiCount = 0;
 }
 
 void ScreenObjects::add(const Common::Rect &bounds, Layer layer, ScrCategory category, int descId) {
@@ -314,7 +315,7 @@ void ScreenObjects::check(bool scanFlag) {
 		}
 
 		if (_vm->_events->_mouseReleased) {
-			scene.leftClick();
+			scene._action.leftClick();
 			scene._userInterface._category = CAT_NONE;
 		}
 
@@ -329,8 +330,25 @@ void ScreenObjects::check(bool scanFlag) {
 
 	scene._action.refresh();
 
-	// Loop through image inter list
-	warning("TODO: imageInterList loop");
+	UserInterface &userInterface = _vm->_game->_scene._userInterface;
+	uint32 currentTicks = _vm->_events->getFrameCounter();
+	if (currentTicks >= _vm->_game->_ticksExpiry) {
+		// Check the user interface slots to see if there's any slots that need to be expired
+		UISlots &uiSlots = userInterface._uiSlots;
+		for (uint idx = 0; idx <  uiSlots.size(); ++idx) {
+			UISlot &slot = uiSlots[idx];
+
+			if (slot._slotType != ST_FULL_SCREEN_REFRESH && slot._slotType > -20
+					&& slot._field2 != 200)
+				slot._slotType = ST_EXPIRED;
+		}
+
+		// Handle animating the selected inventory animation
+		userInterface.inventoryAnim();
+
+		// Set the next frame expiry
+		_vm->_game->_ticksExpiry = currentTicks + 6;
+	}	
 }
 
 int ScreenObjects::scanBackwards(const Common::Point &pt, int layer) {
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index 9033206..862c872 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -150,6 +150,7 @@ public:
 	ScrCategory _category;
 	int _objectIndex;
 	bool _released;
+	int _uiCount;
 
 	/*
 	* Constructor
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index f46a4c4..f6be725 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -460,6 +460,9 @@ void UserInterface::loadElements() {
 			_vm->_game->_screenObjects.add(bounds, LAYER_GUI, CAT_TALK_ENTRY, idx);
 		}
 	}
+
+	// Store the number of UI elements loaded for easy nuking/refreshing hotspots added later
+	_vm->_game->_screenObjects._uiCount = _vm->_game->_screenObjects.size();
 }
 
 bool UserInterface::getBounds(ScrCategory category, int v, Common::Rect &bounds) {
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index b4c581d..4a26d34 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -126,11 +126,6 @@ private:
 	void writeVocab(ScrCategory category, int id);
 
 	void refresh();
-
-	/**
-	 * Handles queuing a new frame of an inventory animation for drawing
-	 */
-	void inventoryAnim();
 public:
 	MSurface _surface;
 	UISlots _uiSlots;
@@ -171,10 +166,21 @@ public:
 
 	void setBounds(const Common::Rect &r);
 
+	/**
+	 * Loads the animation sprite data for a given inventory object
+	 */
 	void loadInventoryAnim(int objectId);
 
+	/**
+	 * Resets the inventory animation when no inventory item is selected
+	 */
 	void noInventoryAnim();
 
+	/**
+	* Handles queuing a new frame of an inventory animation for drawing
+	*/
+	void inventoryAnim();
+
 	void categoryChanged();
 
 	/**


Commit: 436949eba2c51593ad35bab25af1f5fe17f3fe7a
    https://github.com/scummvm/scummvm/commit/436949eba2c51593ad35bab25af1f5fe17f3fe7a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-20T08:34:56-04:00

Commit Message:
MADS: Implemented more action logic for highlighting hotspots

Changed paths:
    engines/mads/action.cpp
    engines/mads/hotspots.cpp
    engines/mads/hotspots.h
    engines/mads/module.mk
    engines/mads/scene.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 65abc94..40ece8e 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -23,7 +23,9 @@
 #include "common/scummsys.h"
 #include "mads/mads.h"
 #include "mads/action.h"
+#include "mads/inventory.h"
 #include "mads/scene.h"
+#include "mads/staticres.h"
 
 namespace MADS {
 
@@ -58,71 +60,68 @@ void MADSAction::clear() {
 }
 
 void MADSAction::appendVocab(int vocabId, bool capitalise) {
-	/*
-	char *s = _statusText + strlen(_statusText);
-	vocabStr = _madsVm->globals()->getVocab(vocabId);
-	strcpy(s, vocabStr);
+	Common::String vocabStr = _vm->_game->_scene.getVocab(vocabId);
 	if (capitalise)
-		*s = toupper(*s);
+		vocabStr.setChar(toupper(vocabStr[0]), 0);
 
-	strcat(s, " ");
-	*/
+	_statusText += vocabStr;
+	_statusText += " ";
 }
 
 void MADSAction::set() {
-	/*
-	int hotspotCount = _madsVm->scene()->getSceneResources().hotspots->size();
-	bool flag = false; // FIXME: unused
-	strcpy(_statusText, "");
+	Scene &scene = _vm->_game->_scene;
+	UserInterface &userInterface = scene._userInterface;
+	bool flag = false;
+	_statusText = "";
 
-	_currentAction = -1;
-	_action.objectNameId = -1;
-	_action.indirectObjectId = -1;
+	_action._verbId = -1;
+	_action._objectNameId = -1;
+	_action._indirectObjectId = -1;
 
-	if (_actionMode == ACTMODE_TALK) {
+	if (_actionMode == ACTIONMODE_TALK) {
 		// Handle showing the conversation selection. Rex at least doesn't actually seem to use this
 		if (_selectedRow >= 0) {
-			const char *desc = _madsVm->_converse[_selectedRow].desc;
-			if (desc)
-				strcpy(_statusText, desc);
+			Common::String desc = userInterface._talkStrings[userInterface._talkIds[_selectedRow]];
+			if (!desc.empty())
+				_statusText = desc;
 		}
 	} else if (_lookFlag && (_selectedRow == 0)) {
 		// Two 'look' actions in succession, so the action becomes 'Look around'
-		strcpy(_statusText, lookAroundStr);
+		_statusText = kLookAroundStr;
 	} else {
-		if ((_actionMode == ACTMODE_OBJECT) && (_selectedRow >= 0) && (_flags1 == 2) && (_flags2 == 0)) {
+		if ((_actionMode == ACTIONMODE_OBJECT) && (_selectedRow >= 0) && (_flags1 == 2) && (_flags2 == 0)) {
 			// Use/to action
-			int selectedObject = _madsVm->scene()->getInterface()->getSelectedObject();
-			MadsObject *objEntry = _madsVm->globals()->getObject(selectedObject);
+			int invIndex = userInterface._selectedInvIndex;
+			InventoryObject &objEntry = _vm->_game->_objects.getItem(invIndex);
 
-			_action.objectNameId = objEntry->_descId;
-			_currentAction = objEntry->_vocabList[_selectedRow].vocabId;
+			_action._objectNameId = objEntry._descId;
+			_action._verbId = objEntry._vocabList[_selectedRow]._vocabId;
 
 			// Set up the status text stirng
-			strcpy(_statusText, useStr);
-			appendVocab(_action.objectNameId);
-			strcpy(_statusText, toStr);
-			appendVocab(_currentAction);
+			_statusText = kUseStr;
+			appendVocab(_action._objectNameId);
+			_statusText += kToStr;
+			appendVocab(_action._verbId);
 		} else {
 			// Handling for if an action has been selected
 			if (_selectedRow >= 0) {
-				if (_actionMode == ACTMODE_VERB) {
+				if (_actionMode == ACTIONMODE_VERB) {
 					// Standard verb action
-					_currentAction = verbList[_selectedRow].verb;
+					_currentAction = scene._verbList[_selectedRow]._id;
 				} else {
 					// Selected action on an inventory object
-					int selectedObject = _madsVm->scene()->getInterface()->getSelectedObject();
-					MadsObject *objEntry = _madsVm->globals()->getObject(selectedObject);
+					int invIndex = userInterface._selectedInvIndex;
+					InventoryObject &objEntry = _vm->_game->_objects.getItem(invIndex);
 
-					_currentAction = objEntry->_vocabList[_selectedRow].vocabId;
+					_currentAction = objEntry._vocabList[_selectedRow]._vocabId;
 				}
 
-				appendVocab(_currentAction, true);
+				appendVocab(_action._verbId, true);
 
-				if (_currentAction == kVerbLook) {
+				if (_currentAction == VERB_LOOK) {
 					// Add in the word 'add'
-					strcat(_statusText, atStr);
-					strcat(_statusText, " ");
+					_statusText += kAtStr;
+					_statusText += " ";
 				}
 			}
 
@@ -130,20 +129,20 @@ void MADSAction::set() {
 			if ((_hotspotId >= 0) && (_selectedRow >= 0) && (_articleNumber > 0) && (_flags1 == 2)) {
 				flag = true;
 
-				strcat(_statusText, englishMADSArticleList[_articleNumber]);
-				strcat(_statusText, " ");
+				_statusText += kArticleList[_articleNumber];
+				_statusText += " ";
 			}
 
 			if (_hotspotId >= 0) {
 				if (_selectedRow < 0) {
 					int verbId;
 
-					if (_hotspotId < hotspotCount) {
+					if (_hotspotId < (int)scene._hotspots.size()) {
 						// Get the verb Id from the hotspot
-						verbId = (*_madsVm->scene()->getSceneResources().hotspots)[_hotspotId].getVerbID();
+						verbId = scene._hotspots[_hotspotId]._verbId;
 					} else {
 						// Get the verb Id from the scene object
-						verbId = (*_madsVm->scene()->getSceneResources().dynamicHotspots)[_hotspotId - hotspotCount].getVerbID();
+						verbId = scene._dynamicHotspots[_hotspotId - scene._hotspots.size()]._vocabId;
 					}
 
 					if (verbId > 0) {
@@ -152,23 +151,23 @@ void MADSAction::set() {
 						appendVocab(_currentAction, true);
 					} else {
 						// Default to a standard 'walk to'
-						_currentAction = kVerbWalkTo;
-						strcat(_statusText, walkToStr);
+						_currentAction = VERB_WALKTO;
+						_statusText += kWalkToStr;
 					}
 				}
 
-				if ((_actionMode2 == ACTMODE2_2) || (_actionMode2 == ACTMODE2_5)) {
+				if ((_actionMode2 == ACTIONMODE2_2) || (_actionMode2 == ACTIONMODE2_5)) {
 					// Get name from given inventory object
-					int objectId = _madsVm->scene()->getInterface()->getInventoryObject(_hotspotId);
-					_action.objectNameId = _madsVm->globals()->getObject(objectId)->_descId;
-				} else if (_hotspotId < hotspotCount) {
+					InventoryObject &invObject = _vm->_game->_objects.getItem(_hotspotId);
+					_action._objectNameId = invObject._descId;
+				} else if (_hotspotId < (int)scene._hotspots.size()) {
 					// Get name from scene hotspot
-					_action.objectNameId = (*_madsVm->scene()->getSceneResources().hotspots)[_hotspotId].getVocabID();
+					_action._objectNameId = scene._hotspots[_hotspotId]._vocabId;
 				} else {
 					// Get name from temporary scene hotspot
-					_action.objectNameId = (*_madsVm->scene()->getSceneResources().dynamicHotspots)[_hotspotId].getVocabID();
+					_action._objectNameId = scene._dynamicHotspots[_hotspotId - scene._hotspots.size()]._vocabId;
 				}
-				appendVocab(_action.objectNameId);
+				appendVocab(_action._objectNameId);
 			}
 		}
 
@@ -178,76 +177,74 @@ void MADSAction::set() {
 					int articleNum = 0;
 
 					if ((_v86F42 == 2) || (_v86F42 == 5)) {
-						int objectId = _madsVm->scene()->getInterface()->getInventoryObject(_hotspotId);
-						articleNum = _madsVm->globals()->getObject(objectId)->_article;
-					} else if (_v86F3A < hotspotCount) {
-						articleNum = (*_madsVm->scene()->getSceneResources().hotspots)[_hotspotId].getArticle();
+						InventoryObject &invObject = _vm->_game->_objects.getItem(_hotspotId);
+						articleNum = invObject._article;
+					} else if (_v86F3A < (int)scene._hotspots.size()) {
+						articleNum = scene._hotspots[_hotspotId]._articleNumber;
 					} else {
-
+						articleNum = scene._hotspots[_hotspotId - scene._hotspots.size()]._articleNumber;
 					}
-				}
 
-			} else if ((_articleNumber == kVerbLook) || (_vm->getGameType() != GType_RexNebular) ||
-				(strcmp(_madsVm->globals()->getVocab(_action.indirectObjectId), fenceStr) != 0)) {
+					_statusText += kArticleList[articleNum];
+					_statusText += " ";
+				}
+			} else if ((_articleNumber == VERB_LOOK) || (_vm->getGameID() != GType_RexNebular) ||
+				(scene._vocabStrings[_action._indirectObjectId] != kFenceStr)) {
 				// Write out the article
-				strcat(_statusText, englishMADSArticleList[_articleNumber]);
+				_statusText += kArticleList[_articleNumber];
 			} else {
 				// Special case for a 'fence' entry in Rex Nebular
-				strcat(_statusText, overStr);
+				_statusText += kOverStr;
 			}
 
-			strcat(_statusText, " ");
+			_statusText += " ";
 		}
 
 		// Append object description if necessary
 		if (_v86F3A >= 0)
-			appendVocab(_action.indirectObjectId);
+			appendVocab(_action._indirectObjectId);
 
 		// Remove any trailing space character
-		int statusLen = strlen(_statusText);
-		if ((statusLen > 0) && (_statusText[statusLen - 1] == ' '))
-			_statusText[statusLen - 1] = '\0';
+		if (_statusText.hasSuffix(" "))
+			_statusText.deleteLastChar();
 	}
 
 	_textChanged = true;
-	*/
 }
 
 void MADSAction::refresh() {
-	/*
+	Scene &scene = _vm->_game->_scene;
+
 	// Exit immediately if nothing has changed
 	if (!_textChanged)
 		return;
 
 	// Remove any old copy of the status text
 	if (_statusTextIndex >= 0) {
-		_owner._textDisplay.expire(_statusTextIndex);
+		scene._textDisplay.expire(_statusTextIndex);
 		_statusTextIndex = -1;
 	}
 
-	if (_statusText[0] != '\0') {
-		if ((_owner._screenObjects._v832EC == 0) || (_owner._screenObjects._v832EC == 2)) {
-			Font *font = _madsVm->_font->getFont(FONT_MAIN_MADS);
+	if (!_statusText.empty()) {
+		if ((_vm->_game->_screenObjects._v832EC == 0) || (_vm->_game->_screenObjects._v832EC == 2)) {
+			Font *font = _vm->_font->getFont(FONT_MAIN);
 			int textSpacing = -1;
 
 			int strWidth = font->getWidth(_statusText);
-			if (strWidth > 320) {
+			if (strWidth > MADS_SCREEN_WIDTH) {
 				// Too large to fit, so fall back on interface font
-				font = _madsVm->_font->getFont(FONT_INTERFACE_MADS);
+				font = _vm->_font->getFont(FONT_INTERFACE);
 				strWidth = font->getWidth(_statusText, 0);
 				textSpacing = 0;
 			}
 
 			// Add a new text display entry to display the status text at the bottom of the screen area
-			uint colors = (_vm->getGameType() == GType_DragonSphere) ? 0x0300 : 0x0003;
-
-			_statusTextIndex = _owner._textDisplay.add(160 - (strWidth / 2),
-				MADS_SURFACE_HEIGHT + _owner._posAdjust.y - 13, colors, textSpacing, _statusText, font);
+			_statusTextIndex = scene._textDisplay.add(160 - (strWidth / 2),
+				MADS_SCENE_HEIGHT + scene._posAdjust.y - 13, 3, textSpacing, _statusText, font);
 		}
 	}
 
 	_textChanged = false;
-	*/
 }
 
 void MADSAction::startAction() {
diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
index 91b8127..4356e78 100644
--- a/engines/mads/hotspots.cpp
+++ b/engines/mads/hotspots.cpp
@@ -29,7 +29,7 @@ DynamicHotspot::DynamicHotspot() {
 	_seqIndex = 0;
 	_facing = 0;
 	_descId = 0;
-	_field14 = 0;
+	_vocabId = 0;
 	_articleNumber = 0;
 	_cursor = CURSOR_NONE;
 }
@@ -47,7 +47,7 @@ DynamicHotspots::DynamicHotspots(MADSEngine *vm) : _vm(vm) {
 	_count = 0;
 }
 
-int DynamicHotspots::add(int descId, int field14, int seqIndex, const Common::Rect &bounds) {
+int DynamicHotspots::add(int descId, int vocabId, int seqIndex, const Common::Rect &bounds) {
 	// Find a free slot
 	uint idx = 0;
 	while ((idx < _entries.size()) && _entries[idx]._active)
@@ -62,7 +62,7 @@ int DynamicHotspots::add(int descId, int field14, int seqIndex, const Common::Re
 	_entries[idx]._feetPos.x = -3;
 	_entries[idx]._feetPos.y = 0;
 	_entries[idx]._facing = 5;
-	_entries[idx]._field14 = field14;
+	_entries[idx]._vocabId = vocabId;
 	_entries[idx]._articleNumber = 6;
 	_entries[idx]._cursor = CURSOR_NONE;
 
diff --git a/engines/mads/hotspots.h b/engines/mads/hotspots.h
index 0dcde1d..ed18fbf 100644
--- a/engines/mads/hotspots.h
+++ b/engines/mads/hotspots.h
@@ -39,7 +39,7 @@ public:
 	Common::Point _feetPos;
 	int _facing;
 	int _descId;
-	int _field14;
+	int _vocabId;
 	int _articleNumber;
 	CursorType _cursor;
 
@@ -59,7 +59,7 @@ public:
 	DynamicHotspots(MADSEngine *vm);
 
 	DynamicHotspot &operator[](uint idx) { return _entries[idx]; }
-	int add(int descId, int field14, int seqIndex, const Common::Rect &bounds);
+	int add(int descId, int vocabId, int seqIndex, const Common::Rect &bounds);
 	int setPosition(int index, int xp, int yp, int facing);
 	int setCursor(int index, CursorType cursor);
 	void remove(int index);
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index c2e269e..54126b1 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -34,6 +34,7 @@ MODULE_OBJS := \
 	sequence.o \
 	sound.o \
 	sprites.o \
+	staticres.o \
 	user_interface.o
 
 # This module can be built as a plugin
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index baf51fe..154e4c3 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -425,13 +425,13 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
 	// Draw any sprites
 	_spriteSlots.drawBackground();
 
-	// Process dirty areas
+	// Set up dirty areas for any text display
 	_textDisplay.setDirtyAreas();
 
 	// Merge any identified dirty areas
 	_dirtyAreas.merge(1, DIRTY_AREAS_SIZE);
 
-	// Copy dirty areas to the main display surface
+	// Copy background for the dirty areas to the screen
 	_dirtyAreas.copy(&_backgroundSurface, &_vm->_screen, _posAdjust);
 
 	// Handle dirty areas for foreground objects
@@ -439,14 +439,13 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
 	_textDisplay.setDirtyAreas2();
 	_dirtyAreas.merge(1, DIRTY_AREAS_SIZE);
 
-
 	// Draw foreground sprites
 	_spriteSlots.drawForeground(&_vm->_screen);
 
 	// Draw text elements onto the view
 	_textDisplay.draw(&_vm->_screen);
 
-	//
+	// 
 	_vm->_screen.setPointer(&_vm->_screen);
 	_userInterface.setBounds(Common::Rect(_vm->_screen._offset.x, _vm->_screen._offset.y,
 		_vm->_screen._offset.x + _vm->_screen.w, _vm->_screen._offset.y + _vm->_screen.h));
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 4a26d34..80038e8 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -144,6 +144,8 @@ public:
 	int _v1C;
 	int _v1E;
 	bool _inventoryChanged;
+	Common::StringArray _talkStrings;
+	Common::Array<int> _talkIds;
 public:
 	/**
 	* Constructor


Commit: 8df3da1556b05e5aab203125e0c61802e75b971f
    https://github.com/scummvm/scummvm/commit/8df3da1556b05e5aab203125e0c61802e75b971f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-20T08:41:09-04:00

Commit Message:
MADS: Added new file for static resources

Changed paths:
  A engines/mads/staticres.cpp
  A engines/mads/staticres.h



diff --git a/engines/mads/staticres.cpp b/engines/mads/staticres.cpp
new file mode 100644
index 0000000..cf43576
--- /dev/null
+++ b/engines/mads/staticres.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 "mads/staticres.h"
+
+namespace MADS {
+
+const char *const kArticleList[9] = {
+	nullptr, "with", "to", "at", "from", "on", "in", "under", "behind"
+};
+
+const char *const kCheatingEnabledDesc[3] = {
+	"CHEATING ENABLED",
+	"(For your convenience).",
+	nullptr
+};
+
+const char *const kAtStr = "at";
+const char *const kLookAroundStr = "Look around";
+const char *const kToStr = "to ";
+const char *const kUseStr = "Use ";
+const char *const kWalkToStr = "Walk to ";
+const char *const kFenceStr = "fence";
+const char *const kOverStr = "over";
+
+const char *const kGameReleaseInfoStr = "ScummVM rev: 8.43 14-Sept-92";
+const char *const kGameReleaseTitleStr = "GAME RELASE VERSION INFO";
+
+} // End of namespace MADS
diff --git a/engines/mads/staticres.h b/engines/mads/staticres.h
new file mode 100644
index 0000000..5aaa331
--- /dev/null
+++ b/engines/mads/staticres.h
@@ -0,0 +1,45 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_STATICRES_H
+#define MADS_STATICRES_H
+
+namespace MADS {
+
+extern const char *const kArticleList[9];
+
+extern const char *const kCheatingEnabledDesc[3];
+
+extern const char *const kAtStr;
+extern const char *const kLookAroundStr;
+extern const char *const kToStr;
+extern const char *const kUseStr;
+extern const char *const kWalkToStr;
+extern const char *const kFenceStr;
+extern const char *const kOverStr;
+
+extern const char *const kGameReleaseInfoStr;
+extern const char *const kGameReleaseTitleStr;
+
+} // End of namespace MADS
+
+#endif /* MADS_STATICRES_H */


Commit: 79f51c4ebd377ae91ec639ecf935c5fc4b2d2a32
    https://github.com/scummvm/scummvm/commit/79f51c4ebd377ae91ec639ecf935c5fc4b2d2a32
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-20T21:59:43-04:00

Commit Message:
MADS: Minor initial sprite slots loading fixes, missing code from SequenceList::loadSprites

Changed paths:
    engines/mads/events.cpp
    engines/mads/game.cpp
    engines/mads/scene.cpp
    engines/mads/sequence.cpp
    engines/mads/sequence.h



diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 32d3a09..90393d6 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -35,7 +35,7 @@ namespace MADS {
 EventsManager::EventsManager(MADSEngine *vm) {
 	_vm = vm;
 	_cursorSprites = nullptr;
-	_frameCounter = 0;
+	_frameCounter = 10;
 	_priorFrameTime = 0;
 	_keyPressed = false;
 	_mouseClicked = false;
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 06ea2a5..60481c6 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -232,7 +232,7 @@ void Game::sectionLoop() {
 		_player.updateFrame();
 		_player._visible3 = _player._visible;
 		_player._special = _scene.getDepthHighBits(_player._playerPos);
-		_player._priorTimer = _scene._frameStartTime + _player._ticksAmount;
+		_player._priorTimer = _scene._frameStartTime - _player._ticksAmount;
 		_player.idle();
 
 		if (_scene._userInterface._selectedInvIndex >= 0) {
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 154e4c3..e654606 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -288,9 +288,11 @@ void Scene::doFrame() {
 	}
 
 	if (!_vm->_game->_abortTimers && !player._unk3) {
+		// Refresh the dynamic hotspots if they've changed
 		if (_dynamicHotspots._changed)
 			_dynamicHotspots.refresh();
 
+		// Check all on-screen visual objects
 		_vm->_game->_screenObjects.check(player._stepEnabled && !_action._startWalkFlag &&
 				!_vm->_game->_abortTimers2);
 	}
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 684e499..6288f0a 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -28,31 +28,37 @@
 
 namespace MADS {
 
-	SequenceEntry::SequenceEntry() {
-		_spritesIndex = 0;
-		_flipped = 0;
-		_frameIndex = 0;
-		_frameStart = 0;
-		_numSprites = 0;
-		_animType = ANIMTYPE_NONE;
-		_frameInc = 0;
-		_depth = 0;
-		_scale = 0;
-		_dynamicHotspotIndex = -1;
-		_triggerCountdown = 0;
-		_doneFlag = 0;
-		_abortMode = ABORTMODE_0;
-		_numTicks = 0;
-		_extraTicks = 0;
-		_timeout = 0;
-
-		_entries._count = 0;
-		Common::fill(&_entries._mode[0], &_entries._mode[TIMER_ENTRY_SUBSET_MAX], SM_0);
-		Common::fill(&_entries._frameIndex[0], &_entries._frameIndex[TIMER_ENTRY_SUBSET_MAX], 0);
-		Common::fill(&_entries._abortVal[0], &_entries._abortVal[TIMER_ENTRY_SUBSET_MAX], 0);
-	}
+SequenceEntry::SequenceEntry() {
+	_spritesIndex = 0;
+	_flipped = 0;
+	_frameIndex = 0;
+	_frameStart = 0;
+	_numSprites = 0;
+	_animType = ANIMTYPE_NONE;
+	_frameInc = 0;
+	_depth = 0;
+	_scale = 0;
+	_dynamicHotspotIndex = -1;
+	_field18 = 0;
+	_field1A = 0;
+	_field1C = 0;
+	_field1E = 0;
+	_field20 = 0;
+	_field22 = 0;
+	_triggerCountdown = 0;
+	_doneFlag = 0;
+	_abortMode = ABORTMODE_0;
+	_numTicks = 0;
+	_extraTicks = 0;
+	_timeout = 0;
+
+	_entries._count = 0;
+	Common::fill(&_entries._mode[0], &_entries._mode[TIMER_ENTRY_SUBSET_MAX], SM_0);
+	Common::fill(&_entries._frameIndex[0], &_entries._frameIndex[TIMER_ENTRY_SUBSET_MAX], 0);
+	Common::fill(&_entries._abortVal[0], &_entries._abortVal[TIMER_ENTRY_SUBSET_MAX], 0);
+}
 
-	/*------------------------------------------------------------------------*/
+/*------------------------------------------------------------------------*/
 
 #define SEQUENCE_LIST_SIZE 30
 
@@ -126,7 +132,7 @@ int SequenceList::add(int spriteListIndex, bool flipped, int frameIndex, int tri
 
 	_entries[seqIndex]._triggerCountdown = triggerCountdown;
 	_entries[seqIndex]._doneFlag = false;
-	_entries[seqIndex]._field13 = 0;
+	_entries[seqIndex]._flags = 0;
 	_entries[seqIndex]._dynamicHotspotIndex = -1;
 	_entries[seqIndex]._entries._count = 0;
 	_entries[seqIndex]._abortMode = _vm->_game->_abortTimersMode2;
@@ -210,30 +216,49 @@ bool SequenceList::loadSprites(int seqIndex) {
 	if (seqEntry._spritesIndex == -1) {
 		// Doesn't have an associated sprite anymore, so mark as done
 		seqEntry._doneFlag = true;
-	}
-	else if ((slotIndex = scene._spriteSlots.add()) >= 0) {
+	} else if ((slotIndex = scene._spriteSlots.add()) >= 0) {
 		SpriteSlot &spriteSlot = scene._spriteSlots[slotIndex];
 		setSpriteSlot(seqIndex, spriteSlot);
 
-		int x2 = 0, y2 = 0;
-
-		if ((seqEntry._field13 != 0) || (seqEntry._dynamicHotspotIndex >= 0)) {
+		if ((seqEntry._flags != 0) || (seqEntry._dynamicHotspotIndex >= 0)) {
 			SpriteAsset &spriteSet = *scene._sprites[seqEntry._spritesIndex];
 			MSprite *frame = spriteSet.getFrame(seqEntry._frameIndex - 1);
 			int width = frame->getWidth() * seqEntry._scale / 200;
 			int height = frame->getHeight() * seqEntry._scale / 100;
+			Common::Point pt = spriteSlot._position;
+
+			// ToDO: Find out the proper meanings of the following fields
+			if (seqEntry._flags & 1) {
+				seqEntry._field20 += seqEntry._field18;
+				if (seqEntry._field20 >= 100) {
+					int v = seqEntry._field20 / 100;
+					seqEntry._msgPos.x += v * seqEntry._field1C;
+					seqEntry._field20 -= v * 100;
+				}
 
-			warning("frame size %d x %d", width, height);
+				seqEntry._field22 += seqEntry._field1A;
+				if (seqEntry._field22 >= 100) {
+					int v = seqEntry._field22 / 100;
+					seqEntry._msgPos.y += v * seqEntry._field1E;
+					seqEntry._field22 -= v * 100;
+				}
+			}
 
-			// TODO: Missing stuff here, and I'm not certain about the dynamic hotspot stuff below
+			if (seqEntry._flags & 2) {
+				if ((pt.x + width) < 0 || (pt.x + width) >= MADS_SCREEN_WIDTH ||
+						pt.y < 0 || (pt.y + height) >= MADS_SCENE_HEIGHT) {
+					result = true;
+					seqEntry._doneFlag = true;
+				}
+			}
 
 			if (seqEntry._dynamicHotspotIndex >= 0) {
 				DynamicHotspot &dynHotspot = scene._dynamicHotspots[seqEntry._dynamicHotspotIndex];
 
-				dynHotspot._bounds.left = MAX(x2 - width, 0);
-				dynHotspot._bounds.right = MAX(x2 - width, 319) - dynHotspot._bounds.left + 1;
-				dynHotspot._bounds.top = MAX(y2 - height, 0);
-				dynHotspot._bounds.bottom = MIN(y2, 155) - dynHotspot._bounds.top;
+				dynHotspot._bounds.left = MAX(pt.x - width, 0);
+				dynHotspot._bounds.top = MAX(pt.y - height, 0);
+				dynHotspot._bounds.right = dynHotspot._bounds.left + width;
+				dynHotspot._bounds.bottom = dynHotspot._bounds.top + height;
 
 				scene._dynamicHotspots._changed = true;
 			}
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index a62ad7e..2645e62 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -62,9 +62,15 @@ struct SequenceEntry {
 	int _dynamicHotspotIndex;
 
 	bool _nonFixed;
-	int _field13;
+	uint32 _flags;
 
 	Common::Point _msgPos;
+	int _field18;
+	int _field1A;
+	int _field1C;
+	int _field1E;
+	int _field20;
+	int _field22;
 	int _triggerCountdown;
 	bool _doneFlag;
 	SequenceSubEntries _entries;


Commit: 2b141aaba681a3c7b848010cd58768f55f4434a3
    https://github.com/scummvm/scummvm/commit/2b141aaba681a3c7b848010cd58768f55f4434a3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-21T09:27:22-04:00

Commit Message:
MADS: Fixes for screen objects loading and checking

Changed paths:
    engines/mads/dialogs.cpp
    engines/mads/game.h
    engines/mads/game_data.h
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/player.cpp
    engines/mads/player.h
    engines/mads/scene.cpp
    engines/mads/screen.cpp
    engines/mads/screen.h
    engines/mads/sequence.cpp
    engines/mads/sequence.h
    engines/mads/sprites.cpp
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index 333bbe9..d5d7d64 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -338,6 +338,7 @@ Dialogs *Dialogs::init(MADSEngine *vm) {
 }
 
 Dialogs::Dialogs(MADSEngine *vm): _vm(vm) {
+	_pendingDialog = DIALOG_NONE;
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 444e2fa..32491ce 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -65,7 +65,6 @@ protected:
 	Difficulty _difficultyLevel;
 	int _saveSlot;
 	int _statusFlag;
-	SectionHandler *_sectionHandler;
 	Common::StringArray _quotes;
 	int _v5;
 	int _v6;
@@ -118,6 +117,7 @@ public:
 	int _priorSectionNumber;
 	int _currentSectionNumber;
 	InventoryObjects _objects;
+	SectionHandler *_sectionHandler;
 	VisitedScenes _visitedScenes;
 	Scene _scene;
 	int _v1;
diff --git a/engines/mads/game_data.h b/engines/mads/game_data.h
index 7674bee..8b31e52 100644
--- a/engines/mads/game_data.h
+++ b/engines/mads/game_data.h
@@ -59,6 +59,7 @@ public:
 	virtual void preLoadSection() = 0;
 	virtual void sectionPtr2() = 0;
 	virtual void postLoadSection() = 0;
+	virtual void step() {}
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 65787af..d3df1e9 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -147,15 +147,13 @@ void Scene103::enter() {
 	_scene->_sequences.setDepth(_globals._spriteIndexes[16], 0);
 	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(
 		_globals._spriteIndexes[2], false, 6, 0, 0, 25);	
-	_globals._spriteIndexes[18] = _scene->_sequences.addSubEntry(
-		_globals._spriteIndexes[17], SM_FRAME_INDEX, 2, 72);
-	_globals._spriteIndexes[19] = _scene->_sequences.addSubEntry(
-		_globals._spriteIndexes[17], SM_FRAME_INDEX, 2, 72);
-	_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], 
-		SM_FRAME_INDEX, 2, 73);
-
+	_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], 
+		SM_FRAME_INDEX, 2, 72), false, 8);
 	_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(
-		_globals._spriteIndexes[8], false, 8);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18],
+		SM_FRAME_INDEX, 2, 73), false, 8);
+
 	_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(
 		_globals._spriteIndexes[7], false, 6);
 	_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 8034360..1e886ae 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -747,4 +747,8 @@ void Player::startMovement() {
 	_v8452E = -_v84530;
 }
 
+void Player::step() {
+	warning("TODO: Player::step");
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/player.h b/engines/mads/player.h
index b997e26..8bc0ae7 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -156,6 +156,8 @@ public:
 	void startWalking(const Common::Point &pos, int direction);
 
 	void nextFrame();
+
+	void step();
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index e654606..ee5ff1f 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -337,7 +337,9 @@ void Scene::doFrame() {
 			CursorType cursorId = CURSOR_ARROW;
 			if (_action._v83338 == 1 && !_vm->_game->_screenObjects._v7FECA &&
 					_vm->_game->_screenObjects._category == CAT_HOTSPOT) {
-				int idx = _vm->_game->_screenObjects._selectedObject - _userInterface._screenObjectsCount;
+				int idx = _vm->_game->_screenObjects._selectedObject - _vm->_game->_screenObjects._hotspotsIndex;
+				assert(idx >= 0);
+
 				if (idx >= (int)_hotspots.size()) {
 					idx -= _hotspots.size();
 					_vm->_events->_newCursorId = _dynamicHotspots[idx]._cursor;
@@ -482,7 +484,15 @@ void Scene::checkStartWalk() {
 }
 
 void Scene::doSceneStep() {
-	warning("TODO: Scene::doSceneStep");
+	_vm->_game->_abortTimersMode2 = ABORTMODE_1;
+	_sceneLogic->step();
+	_vm->_game->_sectionHandler->step();
+
+	_vm->_game->_player.step();
+	_vm->_game->_player._unk3 = 0;
+
+	if (_vm->_game->_abortTimersMode == ABORTMODE_1)
+		_vm->_game->_abortTimers = 0;
 }
 
 void Scene::checkKeyboard() {
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 1f1fc0a..7fea54a 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -261,6 +261,8 @@ ScreenObjects::ScreenObjects(MADSEngine *vm) : _vm(vm) {
 	_objectIndex = 0;
 	_released = false;
 	_uiCount = 0;
+	_hotspotsIndex = 0;
+	_selectedObject = -1;
 }
 
 void ScreenObjects::add(const Common::Rect &bounds, Layer layer, ScrCategory category, int descId) {
@@ -282,10 +284,10 @@ void ScreenObjects::check(bool scanFlag) {
 		_v7FECA = false;
 
 	if ((_vm->_events->_vD6 || _v8332A || _vm->_game->_scene._userInterface._scrollerY || _v8333C) && scanFlag) {
-		scene._userInterface._selectedInvIndex = scanBackwards(_vm->_events->currentPos(), LAYER_GUI);
-		if (scene._userInterface._selectedInvIndex > 0) {
-			_category = (ScrCategory)((*this)[scene._userInterface._selectedInvIndex - 1]._category & 7);
-			_objectIndex = (*this)[scene._userInterface._selectedInvIndex - 1]._descId;
+		_selectedObject = scanBackwards(_vm->_events->currentPos(), LAYER_GUI);
+		if (_selectedObject > 0) {
+			_category = (ScrCategory)((*this)[_selectedObject - 1]._category & 7);
+			_objectIndex = (*this)[_selectedObject - 1]._descId;
 		}
 
 		// Handling for easy mouse
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index 862c872..c1e51cb 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -151,6 +151,7 @@ public:
 	int _objectIndex;
 	bool _released;
 	int _uiCount;
+	int _hotspotsIndex;
 
 	/*
 	* Constructor
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 6288f0a..e5cc3b5 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -53,9 +53,9 @@ SequenceEntry::SequenceEntry() {
 	_timeout = 0;
 
 	_entries._count = 0;
-	Common::fill(&_entries._mode[0], &_entries._mode[TIMER_ENTRY_SUBSET_MAX], SM_0);
-	Common::fill(&_entries._frameIndex[0], &_entries._frameIndex[TIMER_ENTRY_SUBSET_MAX], 0);
-	Common::fill(&_entries._abortVal[0], &_entries._abortVal[TIMER_ENTRY_SUBSET_MAX], 0);
+	Common::fill(&_entries._mode[0], &_entries._mode[SEQUENCE_ENTRY_SUBSET_MAX], SM_0);
+	Common::fill(&_entries._frameIndex[0], &_entries._frameIndex[SEQUENCE_ENTRY_SUBSET_MAX], 0);
+	Common::fill(&_entries._abortVal[0], &_entries._abortVal[SEQUENCE_ENTRY_SUBSET_MAX], 0);
 }
 
 /*------------------------------------------------------------------------*/
@@ -81,7 +81,7 @@ void SequenceList::clear() {
 }
 
 bool SequenceList::addSubEntry(int index, SequenceSubEntryMode mode, int frameIndex, int abortVal) {
-	if (_entries[index]._entries._count >= TIMER_ENTRY_SUBSET_MAX)
+	if (_entries[index]._entries._count >= SEQUENCE_ENTRY_SUBSET_MAX)
 		return true;
 
 	int subIndex = _entries[index]._entries._count++;
@@ -305,7 +305,7 @@ bool SequenceList::loadSprites(int seqIndex) {
 	}
 
 	if (seqEntry._entries._count > 0) {
-		for (int i = 0; i <= seqEntry._entries._count; ++i) {
+		for (int i = 0; i < seqEntry._entries._count; ++i) {
 			switch (seqEntry._entries._mode[i]) {
 			case SM_0:
 			case SM_1:
@@ -330,6 +330,9 @@ bool SequenceList::loadSprites(int seqIndex) {
 	if (idx >= 0) {
 		_vm->_game->_abortTimers = seqEntry._entries._abortVal[idx];
 		_vm->_game->_abortTimersMode = seqEntry._abortMode;
+
+		if (seqEntry._abortMode == ABORTMODE_1)
+			scene._action._activeAction = seqEntry._actionNouns;
 	}
 
 	return result;
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index 2645e62..f1b963a 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -36,13 +36,13 @@ enum SequenceSubEntryMode { SM_0 = 0, SM_1 = 1, SM_FRAME_INDEX = 2 };
 
 enum SpriteAnimType { ANIMTYPE_NONE = 0, ANIMTYPE_CYCLED = 1, ANIMTYPE_REVERSIBLE = 2 };
 
-#define TIMER_ENTRY_SUBSET_MAX 5
+#define SEQUENCE_ENTRY_SUBSET_MAX 5
 
 struct SequenceSubEntries {
 	int _count;
-	SequenceSubEntryMode _mode[TIMER_ENTRY_SUBSET_MAX];
-	int _frameIndex[TIMER_ENTRY_SUBSET_MAX];
-	int8 _abortVal[TIMER_ENTRY_SUBSET_MAX];
+	SequenceSubEntryMode _mode[SEQUENCE_ENTRY_SUBSET_MAX];
+	int _frameIndex[SEQUENCE_ENTRY_SUBSET_MAX];
+	int8 _abortVal[SEQUENCE_ENTRY_SUBSET_MAX];
 };
 
 struct SequenceEntry {
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index e519c69..ea4dbbb 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -177,7 +177,7 @@ SpriteSlots::SpriteSlots(MADSEngine *vm) : _vm(vm) {
 }
 
 void SpriteSlots::reset(bool flag) {
-	_vm->_game->_scene._textDisplay.clear();
+	_vm->_game->_scene._textDisplay.reset();
 
 	if (flag)
 		_vm->_game->_scene._sprites.clear();
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index f6be725..baec133 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -189,7 +189,6 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm), _dirtyAreas(vm),
 	_invSpritesIndex = -1;
 	_invFrameNumber = 1;
 	_category = CAT_NONE;
-	_screenObjectsCount = 0;
 	_inventoryTopIndex = 0;
 	_objectY = 0;
 	_selectedInvIndex = -1;
@@ -445,6 +444,7 @@ void UserInterface::loadElements() {
 	}
 
 	if (!_vm->_game->_screenObjects._v832EC || _vm->_game->_screenObjects._v832EC == 2) {
+		_vm->_game->_screenObjects._hotspotsIndex = _vm->_game->_screenObjects.size();
 		for (int hotspotIdx = scene._hotspots.size() - 1; hotspotIdx >= 0; --hotspotIdx) {
 			Hotspot &hs = scene._hotspots[hotspotIdx];
 			_vm->_game->_screenObjects.add(hs._bounds, LAYER_GUI, CAT_HOTSPOT, hotspotIdx);
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 80038e8..cd3ac1d 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -131,7 +131,6 @@ public:
 	UISlots _uiSlots;
 	DirtyAreas _dirtyAreas;
 	ScrCategory _category;
-	int _screenObjectsCount;
 	Common::Rect _drawBounds;
 	Common::Rect *_rectP;
 	int _inventoryTopIndex;


Commit: de09300fdd2194cd78054175b5d4e5231482ab1d
    https://github.com/scummvm/scummvm/commit/de09300fdd2194cd78054175b5d4e5231482ab1d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-21T21:58:53-04:00

Commit Message:
MADS: Fix initialisation of scene 103

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index d3df1e9..86cac3b 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -145,15 +145,16 @@ void Scene103::enter() {
 	_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(
 		_globals._spriteIndexes[1], false, 6, 0, 2, 0);
 	_scene->_sequences.setDepth(_globals._spriteIndexes[16], 0);
+
 	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(
 		_globals._spriteIndexes[2], false, 6, 0, 0, 25);	
+	_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], SM_FRAME_INDEX, 2, 72);
 	_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], 
-		SM_FRAME_INDEX, 2, 72), false, 8);
-	_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18],
-		SM_FRAME_INDEX, 2, 73), false, 8);
+		_globals._spriteIndexes[3], _scene, false, 8);
+	_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_FRAME_INDEX, 2, 73);
 
+	_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(
+		_globals._spriteIndexes[8], false, 8);
 	_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(
 		_globals._spriteIndexes[7], false, 6);
 	_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(


Commit: 2090987b81615af4cda189a462bc04cd22d7a180
    https://github.com/scummvm/scummvm/commit/2090987b81615af4cda189a462bc04cd22d7a180
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-21T22:47:31-04:00

Commit Message:
MADS: Fixes for handling horizontally flipped frames

Changed paths:
    engines/mads/assets.cpp
    engines/mads/msurface.cpp
    engines/mads/screen.cpp
    engines/mads/sequence.cpp
    engines/mads/sprites.cpp



diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index 136a3ff..a84d194 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -78,6 +78,7 @@ void SpriteAsset::load(Common::SeekableReadStream *stream, int flags) {
 
 	int numColors = palStream->readUint16LE();
 	assert(numColors <= 252);
+	_colorCount = numColors;
 
 	// Load in the palette
 	palette.resize(numColors);
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 3ce5bda..8f40173 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -498,7 +498,7 @@ MSurface *MSurface::flipHorizontal() const {
 
 	for (int y = 0; y < this->h; ++y) {
 		const byte *srcP = getBasePtr(this->w - 1, y);
-		byte *destP = dest->getData();
+		byte *destP = dest->getBasePtr(0, y);
 
 		for (int x = 0; x < this->w; ++x)
 			*destP++ = *srcP--;
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 7fea54a..975ec77 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -91,13 +91,12 @@ void DirtyArea::setSpriteSlot(const SpriteSlot *spriteSlot) {
 		_bounds.top = spriteSlot->_position.y - scene._posAdjust.y;
 
 		SpriteAsset &spriteSet = *scene._sprites[spriteSlot->_spritesIndex];
-		MSprite *frame = spriteSet.getFrame(((spriteSlot->_frameNumber & 0x7fff) - 1) & 0x7f);
+		MSprite *frame = spriteSet.getFrame(ABS(spriteSlot->_frameNumber) - 1);
 
 		if (spriteSlot->_scale == -1) {
 			width = frame->w;
 			height = frame->h;
-		}
-		else {
+		} else {
 			width = frame->w * spriteSlot->_scale / 100;
 			height = frame->h * spriteSlot->_scale / 100;
 
@@ -380,8 +379,10 @@ void ScreenSurface::init() {
 void ScreenSurface::copyRectToScreen(const Common::Point &destPos,
 		const Common::Rect &bounds) {
 	byte *buf = getBasePtr(destPos.x, destPos.y);
-	g_system->copyRectToScreen(buf, this->pitch, bounds.left, bounds.top,
-		bounds.width(), bounds.height());
+
+	if (bounds.width() != 0 && bounds.height() != 0)
+		g_system->copyRectToScreen(buf, this->pitch, bounds.left, bounds.top,
+			bounds.width(), bounds.height());
 }
 
 void ScreenSurface::copyRectToScreen(const Common::Rect &bounds) {
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index e5cc3b5..a03d0f8 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -187,15 +187,14 @@ void SequenceList::setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot) {
 	spriteSlot._SlotType = spriteSet.isBackground() ? ST_BACKGROUND : ST_FOREGROUND;
 	spriteSlot._seqIndex = seqIndex;
 	spriteSlot._spritesIndex = timerEntry._spritesIndex;
-	spriteSlot._frameNumber = (timerEntry._flipped ? 0x8000 : 0) | timerEntry._frameIndex;
+	spriteSlot._frameNumber = timerEntry._flipped ? -timerEntry._frameIndex : timerEntry._frameIndex;
 	spriteSlot._depth = timerEntry._depth;
 	spriteSlot._scale = timerEntry._scale;
 
 	if (!timerEntry._nonFixed) {
 		spriteSlot._position = timerEntry._msgPos;
 	} else {
-		assert(spriteSlot._frameNumber > 0);
-		MSprite *sprite = spriteSet.getFrame(spriteSlot._frameNumber - 1);
+		MSprite *sprite = spriteSet.getFrame(timerEntry._frameIndex - 1);
 		spriteSlot._position = sprite->_offset;
 	}
 }
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index ea4dbbb..c0467ff 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -322,8 +322,8 @@ void SpriteSlots::drawForeground(MSurface *s) {
 		SpriteAsset &spriteSet = *scene._sprites[slot._spritesIndex];
 
 		// Get the sprite frame
-		int frameNumber = slot._frameNumber & 0x7fff;
-		bool flipped = (slot._frameNumber & 0x8000) != 0;
+		int frameNumber = ABS(slot._frameNumber);
+		bool flipped = slot._frameNumber < 0;
 
 		assert(frameNumber > 0);
 		MSprite *sprite = spriteSet.getFrame(frameNumber - 1);


Commit: 202d4ad4f1980bc7367e22ad1061b7b270991692
    https://github.com/scummvm/scummvm/commit/202d4ad4f1980bc7367e22ad1061b7b270991692
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-21T23:36:56-04:00

Commit Message:
MADS: Implemented more of scene 103 code

Changed paths:
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 781fd7d..d6cd901 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -107,4 +107,8 @@ int MADSEngine::getRandomNumber(int maxNumber) {
 	return _randomSource.getRandomNumber(maxNumber);
 }
 
+int MADSEngine::hypotenuse(int xv, int yv) {
+	return (int)sqrt((double)(xv * xv + yv * yv));
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index 3152e84..e9da307 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -116,6 +116,7 @@ public:
 	uint32 getGameFeatures() const;
 
 	int getRandomNumber(int maxNumber);
+	int hypotenuse(int xv, int yv);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index b9d244d..42a44a2 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -67,7 +67,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 
 NebularScene::NebularScene(MADSEngine *vm) : SceneLogic(vm),
 		_globals(static_cast<GameNebular *>(vm->_game)->_globals),
-		_game(*static_cast<GameNebular *>(vm->_game)) {
+		_game(*static_cast<GameNebular *>(vm->_game)),
+		_action(vm->_game->_scene._action) {
 }
 
 Common::String NebularScene::formAnimName(char sepChar, int suffixNum) {
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 13e3597..6b2b101 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -106,6 +106,7 @@ class NebularScene : public SceneLogic {
 protected:
 	Globals &_globals;
 	GameNebular &_game;
+	MADSAction &_action;
 
 	/**
 	 * Forms an animation resoucre name
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 86cac3b..1ee1990 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -150,7 +150,7 @@ void Scene103::enter() {
 		_globals._spriteIndexes[2], false, 6, 0, 0, 25);	
 	_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], SM_FRAME_INDEX, 2, 72);
 	_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(
-		_globals._spriteIndexes[3], _scene, false, 8);
+		_globals._spriteIndexes[3], false, 6, 0, 1, 37);
 	_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_FRAME_INDEX, 2, 73);
 
 	_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(
@@ -212,6 +212,45 @@ void Scene103::enter() {
 }
 
 void Scene103::step() {
+	Common::Point pt;
+	int dist;
+
+	switch (_vm->_game->_abortTimers) {
+	case 70:
+		_vm->_game->_player._stepEnabled = true;
+		break;
+
+	case 72:
+		pt = _vm->_game->_player._playerPos;
+		dist = _vm->hypotenuse(pt.x - 58, pt.y - 93);
+		_vm->_sound->command(27, (dist * -128 / 378) + 127);
+		break;
+
+	case 73:
+		pt = _vm->_game->_player._playerPos;
+		dist = _vm->hypotenuse(pt.x - 266, pt.y - 81);
+		_vm->_sound->command(27, (dist * -127 / 378) + 127);
+		break;
+
+	default:
+		break;
+	}
+	
+	if (_globals._frameTime <= _scene->_frameStartTime) {
+		pt = _vm->_game->_player._playerPos;
+		int dist = _vm->hypotenuse(pt.x - 79, pt.y - 137);
+		_vm->_sound->command(29, (dist * -127 / 378) + 127);
+
+		pt = _vm->_game->_player._playerPos;
+		dist = _vm->hypotenuse(pt.x - 69, pt.y - 80);
+		_vm->_sound->command(30, (dist * -127 / 378) + 127);
+
+		pt = _vm->_game->_player._playerPos;
+		dist = _vm->hypotenuse(pt.x - 266, pt.y - 138);
+		_vm->_sound->command(32, (dist * -127 / 378) + 127);
+
+		_globals._frameTime = _scene->_frameStartTime + _vm->_game->_player._ticksAmount;
+	}
 }
 
 void Scene103::preActions() {
@@ -221,6 +260,17 @@ void Scene103::actions() {
 }
 
 void Scene103::postActions() {
+	if (_action.isAction(27) && !_action.isAction(13)) {
+		Dialog::show(0x2841);
+		_action._inProgress = false;
+	} else {
+		if (_action.isAction(7, 85, 144)) {
+			Common::String msg = _game.getQuote(73);
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110,
+				34, 0, 120, msg);
+			_action._inProgress = false;
+		}
+	}
 }
 
 } // End of namespace Nebular


Commit: 07b9a54e271f30574a574988fa292e2548dd5a80
    https://github.com/scummvm/scummvm/commit/07b9a54e271f30574a574988fa292e2548dd5a80
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-22T14:36:00+01:00

Commit Message:
MADS: Implement Scene202::Step

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h
    engines/mads/staticres.cpp



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 84941e6..963a027 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -419,7 +419,7 @@ void Scene202::enter() {
 	}
 
 	_globals._v7 = _scene->_frameStartTime;
-	warning("dword_8425C = _scene->_frameStartTime;");
+	warning("TODO: dword_8425C = _scene->_frameStartTime;");
 
 	if (_scene->_roomChanged)
 		_game._objects.addToInventory(OBJ_NONE);
@@ -462,7 +462,284 @@ void Scene202::enter() {
 	_globals._abortVal = 0;
 }
 
+void Scene202::setRandomKernelMessage() {
+	int vocabId = 92 + _vm->getRandomNumber(4);
+	_scene->_kernelMessages.reset();
+	_game._abortTimersMode2 = ABORTMODE_1;
+	_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 70, 120, _game.getQuote(vocabId));
+	_globals._v0 = -1;
+}
+
 void Scene202::step() {
+	if ((_globals._v0 == 0) && (_game._player._playerPos == Common::Point(77, 105)) && (_game._player._direction == 8) && (_vm->getRandomNumber(999) == 0)) {
+		_scene->_kernelMessages.reset();
+		_globals._v0 = 0;
+		if (_vm->getRandomNumber(4) == 0)
+			setRandomKernelMessage();
+	}
+
+	if (_game._abortTimers == 70)
+		_globals._v0 = 0;
+
+	if (_game._abortTimers == 71) {
+		_vm->_sound->command(3);
+		_vm->_sound->command(9);
+		warning("TODO: dword_8425C = 900 + _scene->_frameStartTime;");
+		Common::Point msgPos;
+		int msgFlag;
+		if (_globals._v4 == 0) {
+			msgPos = Common::Point(0, 0);
+			msgFlag = 2;
+		} else {
+			msgPos = Common::Point(248, 15);
+			msgFlag = 0;
+		}
+		int msgIndex = _scene->_kernelMessages.add(msgPos, 0x1110, msgFlag | 32, 0, 120, _game.getQuote(102));
+		_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+		
+		if (_globals[38] == 1) {
+			MADSAction *action = _game._player._action;
+			action->_activeAction._verbId = 3;
+			action->_activeAction._objectNameId = 39;
+			action->_activeAction._indirectObjectId = 438;
+			_game._abortTimersMode2 = ABORTMODE_0;
+			_scene->_sequences.addTimer(120, 2);
+			_globals._abortVal = -1;
+		} else if (_globals[38] == 2) {
+			_scene->_sequences.addTimer(120, 90);
+		}
+		_globals[38] = 0;
+	}
+
+	switch (_game._abortTimers) {
+	case 90:
+		_vm->_sound->command(41);
+		_scene->_sequences.remove(_globals._spriteIndexes[25]);
+		_globals._spriteIndexes[24] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0); 
+		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
+		_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[24], SM_0, 0, 91);
+		break;
+	case 91:
+		_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
+		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
+		_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
+		_scene->_sequences.addTimer(60, 92);
+		break;
+	case 92: {
+		_scene->_sequences.remove(_globals._spriteIndexes[24]);
+		_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 6, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[26], 1);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_0, 0, 93);
+		_scene->_kernelMessages.reset();
+		int msgIndex = _scene->_kernelMessages.add(Common::Point(0, -65), 0x1110, 32, 0, 60, _game.getQuote(98));
+		_scene->_kernelMessages.setSeqIndex(msgIndex, _globals._spriteIndexes[26]);
+		}
+		break;
+	case 93: {
+		_globals[31] = -1;
+		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 0, 0, 0);
+		_scene->_hotspots.activate(199, false);
+		int idx = _scene->_dynamicHotspots.add(457, 13, _globals._spriteIndexes[20], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, 246, 124, 8);
+		warning("TODO: TimerList_getTimeout(_globals._spriteIndexes[26], _globals._spriteIndexes[20]);");
+		warning("TODO: TimerList_getTimeout(-1, _globals._spriteIndexes[26]);");
+		_game._player._stepEnabled = true;
+		_game._player._visible = true;
+		_globals._v4 = false;
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(99));
+		}
+		break;
+	default:
+		break;
+	}
+	
+	if (!_scene->_activeAnimation && (_globals[33] != 2) && (_globals._v7 <= _scene->_frameStartTime)) {
+		warning("TODO: && (dword_8425C <= _scene->_frameStartTime) {");
+		int randVal = _vm->getRandomNumber(499) + 1;
+		int threshold = 1;
+		if (_globals._v4)
+			threshold = 26;
+		if (!_globals[37])
+			threshold = 25;
+		if (threshold >= randVal) {
+			_vm->_sound->command(17);
+			_scene->loadAnimation(formAnimName('M', -1), 71);
+			warning("TODO: word84266 = -1;");
+			warning("TODO: word84268 = 0;");
+			_globals[37] = true;
+			_globals._v6 = _scene->_frameStartTime;
+			_globals._v8 = 0;
+			warning("TODO: _timerIndex = 0;");
+			warning("TODO: word84264 = 0;");
+			_globals._v7 = _scene->_frameStartTime + 2;
+		}
+	}
+	
+	if (!_scene->_activeAnimation)
+		return;
+
+	if (_globals._v5) {
+		if (_scene->_activeAnimation->getCurrentFrame() >= 200) {
+			if ((_globals[38] == 2) || _globals[31]) {
+				_scene->_nextSceneId = 213;
+			} else {
+				Dialog::show(0x4EE9);
+				_scene->_reloadSceneFlag = true;
+			}
+		}
+
+		if (_scene->_activeAnimation->getCurrentFrame() == 160) {
+			warning("TODO: && (word84260 != _scene->_activeAnimation->getCurrentFrame()) {");
+			Common::Point msgPos;
+			int msgFlag;
+			if (_globals._v4 == 0) {
+				msgPos = Common::Point(0, 0);
+				msgFlag = 2;
+			} else {
+				msgPos = Common::Point(248, 15);
+				msgFlag = 0;
+			}
+			int msgIndex = _scene->_kernelMessages.add(msgPos, 0x1110, msgFlag | 32, 0, 120, _game.getQuote(101));
+			_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+		}
+	}
+
+	if (_globals._v7 + 7200 <= _scene->_frameStartTime) {
+		warning("TODO: word84268 = -1;");
+	}
+
+	warning("TODO: if (_scene->_activeAnimation->getCurrentFrame() == word84260) {");
+//	if (_scene->_activeAnimation->getCurrentFrame() == word84260) {
+//		return;
+//	}
+	
+	warning("TODO: word84260 = _scene->_activeAnimation->getCurrentFrame();");
+	int var2 = _vm->getRandomNumber(999) + 1;
+	int varA = -1;
+	
+	if (_scene->_activeAnimation->getCurrentFrame() == 77) {
+		varA = subStep1(var2);
+	} else if (_scene->_activeAnimation->getCurrentFrame() < 77) {
+		if (_scene->_activeAnimation->getCurrentFrame() == 74) {
+			varA = subStep2(var2);
+		} else if (_scene->_activeAnimation->getCurrentFrame() <= 74) {
+			if (_scene->_activeAnimation->getCurrentFrame() == 27) {
+				varA = subStep3(var2);
+			} else if (_scene->_activeAnimation->getCurrentFrame() == 42) {
+				varA = subStep1(var2);
+			} else if (_scene->_activeAnimation->getCurrentFrame() == 51) {
+				varA = subStep2(var2);
+			} else if (_scene->_activeAnimation->getCurrentFrame() == 59) {
+				warning("TODO: _timerIndex = 3;");
+				warning("TODO: ++word84264;");
+				if (var2 <= 800)
+					varA = 55;
+			} else {
+				// Nothing
+				;
+			}
+		} else {
+			// nothing
+			;
+		}
+	} else if (_scene->_activeAnimation->getCurrentFrame() == 119) {
+		varA = subStep3(var2);
+	} else if (_scene->_activeAnimation->getCurrentFrame() > 119) {
+		if (_scene->_activeAnimation->getCurrentFrame() == 137) {
+			warning("TODO: _timerIndex = 2;");
+			if (var2 <= 700)
+				varA = 126;
+		} else if (_scene->_activeAnimation->getCurrentFrame() == 159) {
+			varA = subStep3(var2);
+		} else if (_scene->_activeAnimation->getCurrentFrame() == 176) {
+			varA = subStep4(var2);
+		} else {
+			// Nothing
+			;
+		}
+	} else if (_scene->_activeAnimation->getCurrentFrame() == 89) {
+		warning("TODO: _timerIndex = 1;");
+		if (var2 <= 700)
+			varA = 83;
+	} else if (_scene->_activeAnimation->getCurrentFrame() == 96) {
+		varA = subStep1(var2);
+	} else {
+		// Nothing
+		;
+	}
+
+	if (varA < 0)
+		return;
+
+	int nextFrame = 1 + _scene->_activeAnimation->getCurrentFrame() - varA;
+	if (nextFrame) {
+		_scene->_activeAnimation->setCurrentFrame(nextFrame);
+		warning("word84260 = nextFrame");
+	}
+}
+
+int Scene202::subStep1(int var2) {
+	warning("TODO: word84264 = 0;");
+
+	warning("TODO: if ((var2 <= 100) || (word84266 != 0))");
+	if (var2 <= 100)
+		return 42;
+
+	warning("TODO: if ((var2 <= 200) || (word84268 != 0))");
+	if (var2 <= 200)
+		return 96;
+
+	warning("TODO: if ((var2 <= 300) && (_timerIndex != 1))");
+	if (var2 <= 300)
+		return 77;
+
+	return 76;
+}
+
+int Scene202::subStep2(int var2) {
+	warning("TODO: word84266 = 0;");
+
+	warning("TODO: if ((var2 <= 150) && (word84264 < 5)");
+	if (var2 <= 150)
+		return 51;
+
+	warning("TODO: if ((var2 <= 300) || word84268)");
+	if (var2 <= 300)
+		return 74;
+
+	if (var2 <= 400)
+		return 64;
+
+	return 44;
+}
+
+int Scene202::subStep3(int var2) {
+	warning("TODO: if ((var2 <= 100) || (word84266 != 0))");
+	if (var2 <= 100)
+		return 27;
+
+	warning("TODO: if ((var2 <= 200) || (word84268 != 0))");
+	if (var2 <= 200)
+		return 159;
+
+	warning("TODO: if ((var2 <= 300) && (_timerIndex != 2))");
+	if (var2 <= 300)
+		return 119;
+
+	return 110;
+}
+
+int Scene202::subStep4(int var2) {
+	warning("TODO: if ((var2 <= 100) || (word84268 != 0))");
+	if (var2 <= 100)
+		return 176;
+
+	if (var2 <= 200)
+		return 19;
+
+	return 166;	
 }
 
 void Scene202::preActions() {
@@ -673,7 +950,7 @@ void Scene202::actions() {
 				}
 			}
 		} else if (action->isAction(0x188, 0xAA, 0)) {
-			warning("TODO - sub_370C8");
+			setRandomKernelMessage();
 		} else if (action->isAction(0x3, 0x129, 0)) {
 			Dialog::show(0x4EEA);
 		} else if (action->isAction(0x3, 0x86, 0)) {
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 35a6ff1..918b2f7 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -61,6 +61,12 @@ public:
 };
 
 class Scene202: public Scene2xx {
+private:
+	int subStep1(int var2);
+	int subStep2(int var2);
+	int subStep3(int var2);
+	int subStep4(int var2);
+
 public:
 	Scene202(MADSEngine *vm) : Scene2xx(vm) {}
 	virtual void setup();
@@ -69,6 +75,8 @@ public:
 	virtual void preActions();
 	virtual void actions();
 	virtual void postActions() {};
+
+	void setRandomKernelMessage();
 };
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/staticres.cpp b/engines/mads/staticres.cpp
index cf43576..d57222c 100644
--- a/engines/mads/staticres.cpp
+++ b/engines/mads/staticres.cpp
@@ -20,6 +20,7 @@
  *
  */
 
+#include "common/scummsys.h"
 #include "mads/staticres.h"
 
 namespace MADS {


Commit: 4fec23ad1cc58911ceb88f259c7721a77224982d
    https://github.com/scummvm/scummvm/commit/4fec23ad1cc58911ceb88f259c7721a77224982d
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-22T15:15:22+01:00

Commit Message:
MADS: Refactor Scene202::step()

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 963a027..90665a8 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -616,127 +616,112 @@ void Scene202::step() {
 //	}
 	
 	warning("TODO: word84260 = _scene->_activeAnimation->getCurrentFrame();");
-	int var2 = _vm->getRandomNumber(999) + 1;
-	int varA = -1;
+	int randVal = _vm->getRandomNumber(999) + 1;
+	int frameStep = -1;
 	
-	if (_scene->_activeAnimation->getCurrentFrame() == 77) {
-		varA = subStep1(var2);
-	} else if (_scene->_activeAnimation->getCurrentFrame() < 77) {
-		if (_scene->_activeAnimation->getCurrentFrame() == 74) {
-			varA = subStep2(var2);
-		} else if (_scene->_activeAnimation->getCurrentFrame() <= 74) {
-			if (_scene->_activeAnimation->getCurrentFrame() == 27) {
-				varA = subStep3(var2);
-			} else if (_scene->_activeAnimation->getCurrentFrame() == 42) {
-				varA = subStep1(var2);
-			} else if (_scene->_activeAnimation->getCurrentFrame() == 51) {
-				varA = subStep2(var2);
-			} else if (_scene->_activeAnimation->getCurrentFrame() == 59) {
-				warning("TODO: _timerIndex = 3;");
-				warning("TODO: ++word84264;");
-				if (var2 <= 800)
-					varA = 55;
-			} else {
-				// Nothing
-				;
-			}
-		} else {
-			// nothing
-			;
-		}
-	} else if (_scene->_activeAnimation->getCurrentFrame() == 119) {
-		varA = subStep3(var2);
-	} else if (_scene->_activeAnimation->getCurrentFrame() > 119) {
-		if (_scene->_activeAnimation->getCurrentFrame() == 137) {
-			warning("TODO: _timerIndex = 2;");
-			if (var2 <= 700)
-				varA = 126;
-		} else if (_scene->_activeAnimation->getCurrentFrame() == 159) {
-			varA = subStep3(var2);
-		} else if (_scene->_activeAnimation->getCurrentFrame() == 176) {
-			varA = subStep4(var2);
-		} else {
-			// Nothing
-			;
-		}
-	} else if (_scene->_activeAnimation->getCurrentFrame() == 89) {
+	switch (_scene->_activeAnimation->getCurrentFrame()) {
+	case 42:
+	case 77:
+	case 96:
+		frameStep = subStep1(randVal);
+		break;
+	case 51:
+	case 74:
+		frameStep = subStep2(randVal);
+		break;
+	case 27:
+	case 119:
+	case 159:
+		frameStep = subStep3(randVal);
+		break;
+	case 176:
+		frameStep = subStep4(randVal);
+		break;
+	case 59:
+		warning("TODO: _timerIndex = 3;");
+		warning("TODO: ++word84264;");
+		if (randVal <= 800)
+			frameStep = 55;
+		break;
+	case 89:
 		warning("TODO: _timerIndex = 1;");
-		if (var2 <= 700)
-			varA = 83;
-	} else if (_scene->_activeAnimation->getCurrentFrame() == 96) {
-		varA = subStep1(var2);
-	} else {
-		// Nothing
-		;
+		if (randVal <= 700)
+			frameStep = 83;
+		break;
+	case 137:
+		warning("TODO: _timerIndex = 2;");
+		if (randVal <= 700)
+			frameStep = 126;
+		break;
 	}
 
-	if (varA < 0)
+	if (frameStep < 0)
 		return;
 
-	int nextFrame = 1 + _scene->_activeAnimation->getCurrentFrame() - varA;
+	int nextFrame = 1 + _scene->_activeAnimation->getCurrentFrame() - frameStep;
 	if (nextFrame) {
 		_scene->_activeAnimation->setCurrentFrame(nextFrame);
 		warning("word84260 = nextFrame");
 	}
 }
 
-int Scene202::subStep1(int var2) {
+int Scene202::subStep1(int randVal) {
 	warning("TODO: word84264 = 0;");
 
-	warning("TODO: if ((var2 <= 100) || (word84266 != 0))");
-	if (var2 <= 100)
+	warning("TODO: if ((randVal <= 100) || (word84266 != 0))");
+	if (randVal <= 100)
 		return 42;
 
-	warning("TODO: if ((var2 <= 200) || (word84268 != 0))");
-	if (var2 <= 200)
+	warning("TODO: if ((randVal <= 200) || (word84268 != 0))");
+	if (randVal <= 200)
 		return 96;
 
-	warning("TODO: if ((var2 <= 300) && (_timerIndex != 1))");
-	if (var2 <= 300)
+	warning("TODO: if ((randVal <= 300) && (_timerIndex != 1))");
+	if (randVal <= 300)
 		return 77;
 
 	return 76;
 }
 
-int Scene202::subStep2(int var2) {
+int Scene202::subStep2(int randVal) {
 	warning("TODO: word84266 = 0;");
 
-	warning("TODO: if ((var2 <= 150) && (word84264 < 5)");
-	if (var2 <= 150)
+	warning("TODO: if ((randVal <= 150) && (word84264 < 5)");
+	if (randVal <= 150)
 		return 51;
 
-	warning("TODO: if ((var2 <= 300) || word84268)");
-	if (var2 <= 300)
+	warning("TODO: if ((randVal <= 300) || word84268)");
+	if (randVal <= 300)
 		return 74;
 
-	if (var2 <= 400)
+	if (randVal <= 400)
 		return 64;
 
 	return 44;
 }
 
-int Scene202::subStep3(int var2) {
-	warning("TODO: if ((var2 <= 100) || (word84266 != 0))");
-	if (var2 <= 100)
+int Scene202::subStep3(int randVal) {
+	warning("TODO: if ((randVal <= 100) || (word84266 != 0))");
+	if (randVal <= 100)
 		return 27;
 
-	warning("TODO: if ((var2 <= 200) || (word84268 != 0))");
-	if (var2 <= 200)
+	warning("TODO: if ((randVal <= 200) || (word84268 != 0))");
+	if (randVal <= 200)
 		return 159;
 
-	warning("TODO: if ((var2 <= 300) && (_timerIndex != 2))");
-	if (var2 <= 300)
+	warning("TODO: if ((randVal <= 300) && (_timerIndex != 2))");
+	if (randVal <= 300)
 		return 119;
 
 	return 110;
 }
 
-int Scene202::subStep4(int var2) {
-	warning("TODO: if ((var2 <= 100) || (word84268 != 0))");
-	if (var2 <= 100)
+int Scene202::subStep4(int randVal) {
+	warning("TODO: if ((randVal <= 100) || (word84268 != 0))");
+	if (randVal <= 100)
 		return 176;
 
-	if (var2 <= 200)
+	if (randVal <= 200)
 		return 19;
 
 	return 166;	
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 918b2f7..a1faf53 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -62,10 +62,10 @@ public:
 
 class Scene202: public Scene2xx {
 private:
-	int subStep1(int var2);
-	int subStep2(int var2);
-	int subStep3(int var2);
-	int subStep4(int var2);
+	int subStep1(int randVal);
+	int subStep2(int randVal);
+	int subStep3(int randVal);
+	int subStep4(int randVal);
 
 public:
 	Scene202(MADSEngine *vm) : Scene2xx(vm) {}


Commit: 7cdaa9648c0c49345460a0ab194a4ca97869e6bd
    https://github.com/scummvm/scummvm/commit/7cdaa9648c0c49345460a0ab194a4ca97869e6bd
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-22T12:02:17-04:00

Commit Message:
MADS: Implemented ScreenObjects::checkScroller

Changed paths:
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/screen.cpp
    engines/mads/screen.h
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 90393d6..fe2a253 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -41,9 +41,10 @@ EventsManager::EventsManager(MADSEngine *vm) {
 	_mouseClicked = false;
 	_mouseReleased = false;
 	_mouseButtons = 0;
+	_vCC = 0;
 	_vD2 = 0;
 	_vD4 = 0;
-	_vD6 = 0;
+	_mouseMoved = false;
 	_vD8 = 0;
 }
 
@@ -100,6 +101,7 @@ void EventsManager::freeCursors() {
 
 void EventsManager::pollEvents() {
 	checkForNextFrameCounter();
+	_mouseMoved = false;
 
 	Common::Event event;
 	while (g_system->getEventManager()->pollEvent(event)) {
@@ -130,9 +132,12 @@ void EventsManager::pollEvents() {
 		case Common::EVENT_LBUTTONUP:
 		case Common::EVENT_RBUTTONUP:
 			_mouseClicked = false;
+			_mouseMoved = true;
 			return;
 		case Common::EVENT_MOUSEMOVE:
 			_mousePos = event.mouse;
+			_currentPos = event.mouse;
+			_mouseMoved = true;
 			break;
 		default:
  			break;
diff --git a/engines/mads/events.h b/engines/mads/events.h
index 1722422..219af20 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -62,7 +62,7 @@ public:
 	int _vCC;
 	int _vD2;
 	int _vD4;
-	int _vD6;
+	bool _mouseMoved;
 	int _vD8;
 public:
 	/**
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 975ec77..3565c1a 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -251,17 +251,22 @@ ScreenObject::ScreenObject() {
 /*------------------------------------------------------------------------*/
 
 ScreenObjects::ScreenObjects(MADSEngine *vm) : _vm(vm) {
+	_objectY = -1;
 	_v8333C = false;
 	_v832EC = 0;
 	_v7FECA = 0;
 	_v7FED6 = 0;
 	_v8332A = 0;
 	_category = CAT_NONE;
-	_objectIndex = 0;
+	_newDescId = 0;
+	_newDescId = 0;
 	_released = false;
 	_uiCount = 0;
 	_hotspotsIndex = 0;
 	_selectedObject = -1;
+	_scrollerY = -1;
+	_milliTime = 0;
+	_eventFlag = false;
 }
 
 void ScreenObjects::add(const Common::Rect &bounds, Layer layer, ScrCategory category, int descId) {
@@ -282,11 +287,13 @@ void ScreenObjects::check(bool scanFlag) {
 	if (!_vm->_events->_mouseButtons || _v832EC)
 		_v7FECA = false;
 
-	if ((_vm->_events->_vD6 || _v8332A || _vm->_game->_scene._userInterface._scrollerY || _v8333C) && scanFlag) {
+	if ((_vm->_events->_mouseMoved || _vm->_game->_scene._userInterface._scrollerY 
+			|| _v8332A || _v8333C) && scanFlag) {
+		_category = CAT_NONE;
 		_selectedObject = scanBackwards(_vm->_events->currentPos(), LAYER_GUI);
 		if (_selectedObject > 0) {
 			_category = (ScrCategory)((*this)[_selectedObject - 1]._category & 7);
-			_objectIndex = (*this)[_selectedObject - 1]._descId;
+			_newDescId = (*this)[_selectedObject - 1]._descId;
 		}
 
 		// Handling for easy mouse
@@ -297,6 +304,8 @@ void ScreenObjects::check(bool scanFlag) {
 			if (category >= CAT_ACTION && category <= CAT_TALK_ENTRY) {
 				scene._userInterface.elementHighlighted();
 			}
+
+			scene._action.checkActionAtMousePos();
 		}
 
 		_released = _vm->_events->_mouseReleased;
@@ -321,7 +330,7 @@ void ScreenObjects::check(bool scanFlag) {
 		}
 
 		if (_vm->_events->_mouseButtons || _vm->_easyMouse || scene._userInterface._scrollerY)
-			proc1();
+			checkScroller();
 
 		if (_vm->_events->_mouseButtons || _vm->_easyMouse)
 			scene._action.set();
@@ -362,8 +371,81 @@ int ScreenObjects::scanBackwards(const Common::Point &pt, int layer) {
 	return 0;
 }
 
-void ScreenObjects::proc1() {
-	warning("TODO: ScreenObjects::proc1");
+void ScreenObjects::checkScroller() {
+	UserInterface &userInterface = _vm->_game->_scene._userInterface;
+	Common::Array<int> &inventoryList = _vm->_game->_objects._inventoryList;
+
+	if (_v832EC)
+		return;
+
+	userInterface._scrollerY = 0;
+	
+	if ((_category == CAT_INV_SCROLLER || (_scrollerY == 3 && _vm->_events->_vD4))
+			&& (_vm->_events->_vD4 || _vm->_easyMouse)) {
+		if ((_vm->_events->_vD2 || (_vm->_easyMouse && !_vm->_events->_vD4))
+				&& _category == CAT_INV_SCROLLER) {
+			_currentDescId = _newDescId;
+		}
+	}
+
+	if (_newDescId == _currentDescId || _scrollerY == 3) {
+		_vm->_game->_scene._userInterface._scrollerY = _currentDescId;
+		uint32 currentMilli = g_system->getMillis();
+		uint32 timeInc = _eventFlag ? 100 : 380;
+		
+		if (_vm->_events->_vD2 || (_milliTime + timeInc) <= currentMilli) {
+			_eventFlag = _vm->_events->_vD2 < 1;
+			_milliTime = currentMilli;
+
+			switch (_currentDescId) {
+			case 1:
+				// Scroll up
+				if (userInterface._inventoryTopIndex > 0 && inventoryList.size() > 0) {
+					--userInterface._inventoryTopIndex;
+					userInterface._inventoryChanged = true;
+				}
+				break;
+
+			case 2:
+				// Scroll down
+				if (userInterface._inventoryTopIndex < (int)inventoryList.size() &&
+						inventoryList.size() > 0) {
+					++userInterface._inventoryTopIndex;
+					userInterface._inventoryChanged = true;
+				}
+				break;
+
+			case 3: {
+				// Inventory slider
+				int newIndex = CLIP((int)_vm->_events->currentPos().y - 170, 0, 17)
+					* inventoryList.size() / 10;
+				if (newIndex >= (int)inventoryList.size())
+					newIndex = inventoryList.size() - 1;
+
+				if (inventoryList.size() > 0) {
+					userInterface._inventoryChanged = newIndex != userInterface._inventoryTopIndex;
+					userInterface._inventoryTopIndex = newIndex;
+				}
+				break;
+			}
+
+			default:
+				break;
+			}
+
+			if (userInterface._inventoryChanged) {
+				int dummy;
+				userInterface.drawInventory(2, 0, &dummy);
+			}
+		}
+	}
+
+	if (userInterface._scrollerY != _scrollerY ||
+			userInterface._objectY != _objectY)
+		userInterface.scrollerChanged();
+
+	_scrollerY = userInterface._scrollerY;
+	_objectY = userInterface._objectY;
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index c1e51cb..c8534a0 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -136,10 +136,16 @@ public:
 class ScreenObjects : public Common::Array<ScreenObject> {
 private:
 	MADSEngine *_vm;
+	int _objectY;
+	int _scrollerY;
 
 	int scanBackwards(const Common::Point &pt, int layer);
 
-	void proc1();
+	/**
+	 * Checks for the mouse being on the user interface inventory scroller,
+	 * and update the scroller and selected inventory object as necessary
+	 */
+	void checkScroller();
 public:
 	int _v832EC;
 	int _v7FECA;
@@ -148,10 +154,13 @@ public:
 	int _v8333C;
 	int _selectedObject;
 	ScrCategory _category;
-	int _objectIndex;
+	int _newDescId;
+	int _currentDescId;
 	bool _released;
 	int _uiCount;
 	int _hotspotsIndex;
+	uint32 _milliTime;
+	bool _eventFlag;
 
 	/*
 	* Constructor
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index baec133..4dba127 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -636,4 +636,12 @@ void UserInterface::selectObject(int invIndex) {
 	warning("TODO: selectObject");
 }
 
+void UserInterface::drawInventory(int v1, int v2, int *v3) {
+	warning("TODO: drawInventory");
+}
+
+void UserInterface::scrollerChanged() {
+	warning("TODO: scrollerChanged");
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index cd3ac1d..06f1e70 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -189,6 +189,10 @@ public:
 	 * @param invIndex	Index in the inventory list of the item to select
 	 */
 	void selectObject(int invIndex);
+
+	void drawInventory(int v1, int v2, int *v3);
+
+	void scrollerChanged();
 };
 
 } // End of namespace MADS


Commit: bbabe2b06b479fb5775b55c0de7b10df7ff67501
    https://github.com/scummvm/scummvm/commit/bbabe2b06b479fb5775b55c0de7b10df7ff67501
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-22T14:20:04-04:00

Commit Message:
MADS: Fix positioning of kernel messages

Changed paths:
    engines/mads/messages.cpp
    engines/mads/messages.h
    engines/mads/player.h



diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index 592dd4b..6dde40b 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -36,7 +36,6 @@ KernelMessages::KernelMessages(MADSEngine *vm): _vm(vm) {
 	}
 
 	_talkFont = _vm->_font->getFont(FONT_CONVERSATION);
-	word_8469E = 0;
 }
 
 KernelMessages::~KernelMessages() {
@@ -89,7 +88,8 @@ int KernelMessages::add(const Common::Point &pt, uint fontColor, uint8 flags,
 
 int KernelMessages::addQuote(int quoteId, int abortTimers, uint32 timeout) {
 	Common::String quoteStr = _vm->_game->getQuote(quoteId);
-	return add(Common::Point(), 0x1110, KMSG_PLAYER_TIMEOUT | KMSG_CENTER_ALIGN, abortTimers, timeout, quoteStr);
+	return add(Common::Point(), 0x1110, KMSG_PLAYER_TIMEOUT | KMSG_CENTER_ALIGN, 
+		abortTimers, timeout, quoteStr);
 }
 
 void KernelMessages::scrollMessage(int msgIndex, int numTicks, bool quoted) {
@@ -203,10 +203,16 @@ void KernelMessages::processText(int msgIndex) {
 		}
 	}
 
+	Player &player = _vm->_game->_player;
 	if (msg._flags & KMSG_PLAYER_TIMEOUT) {
-		if (word_8469E != 0) {
-			warning("TODO: KernelMessages::processText");
-			// TODO: Figure out various flags
+		if (player._visible3) {
+			SpriteAsset &asset = *_vm->_game->_scene._sprites[player._spritesStart + player._spritesIdx];
+			MSprite *frame = asset.getFrame(player._frameNum - 1);
+
+			int yAmount = player._currentScale * player._yScale / 100;
+			x1 = player._playerPos.x;
+			y1 = (frame->h * player._currentScale / -100) + yAmount +
+				player._playerPos.y - 15;
 		} else {
 			x1 = 160;
 			y1 = 78;
@@ -222,11 +228,10 @@ void KernelMessages::processText(int msgIndex) {
 		++msg._msgOffset;
 		msg._msg.setChar(msg._asciiChar2, msg._msgOffset);
 		msg._asciiChar = msg._msg[msg._msgOffset];
-		msg._asciiChar2 = msg._msg[msg._msgOffset + 1];
+		msg._asciiChar2 = !msg._asciiChar ? '\0' : msg._msg[msg._msgOffset + 1];
 
 		if (!msg._asciiChar) {
 			// End of message
-			msg._msg.setChar('\0', msg._msgOffset);
 			msg._flags &= ~KMSG_SCROLL;
 		} else if (msg._flags & KMSG_QUOTED) {
 			msg._msg.setChar('"', msg._msgOffset);
diff --git a/engines/mads/messages.h b/engines/mads/messages.h
index 205cbf8..8fb7595 100644
--- a/engines/mads/messages.h
+++ b/engines/mads/messages.h
@@ -72,8 +72,6 @@ private:
 	Common::Array<KernelMessage> _entries;
 	Font *_talkFont;
 public:
-	int word_8469E;
-public:
 	KernelMessages(MADSEngine *vm);
 	~KernelMessages();
 
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 8bc0ae7..d7e074a 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -40,11 +40,7 @@ private:
 	MADSEngine *_vm;
 	bool _highSprites;
 	bool _spriteSetsPresent[PLAYER_SPRITES_FILE_COUNT];
-	int _currentDepth;
-	int _currentScale;
 	int _frameOffset;
-	int _frameNum;
-	int _yScale;
 	int _frameCount;
 	int _frameListIndex;
 	int _actionIndex;
@@ -111,6 +107,7 @@ public:
 	bool _visible;
 	bool _priorVisible;
 	bool _visible3;
+	int _frameNum;
 	Common::Point _playerPos;
 	Common::Point _destPos;
 	Common::Point _posChange;
@@ -126,6 +123,9 @@ public:
 	int _unk3;
 	bool _unk4;
 	bool _forceRefresh;
+	int _yScale;
+	int _currentDepth;
+	int _currentScale;
 	Common::String _spritesPrefix;
 	int _routeCount;
 	int _routeOffset;


Commit: adddf02e70a82e34e990f932f9955b947f7dcbc0
    https://github.com/scummvm/scummvm/commit/adddf02e70a82e34e990f932f9955b947f7dcbc0
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-22T19:26:41+01:00

Commit Message:
MADS: Implemente Scene::changeDepthSurface()

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.h



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 90665a8..bec3fe4 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -387,7 +387,7 @@ void Scene202::enter() {
 	}
 
 	if (_globals[32])
-		warning("TODO: sub1EB6E(_globals[32];");
+		_scene->changeDepthSurface(_globals[32]);
 
 	if (_scene->_priorSceneId == 201) {
 		_game._player._playerPos = Common::Point(190, 91);
@@ -811,7 +811,7 @@ void Scene202::actions() {
 						_game._objects.addToInventory(OBJ_BONE);
 						warning("TODO: Dialog::showPicture(OBJ_BONE, 0x4EFA, 0);");
 					}
-					warning("TODO: sub1EB6E(_globals[32];");
+					_scene->changeDepthSurface(_globals[32]);
 					_game._player._stepEnabled = true;
 					_game._player._visible = true;
 				} else {
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index ee5ff1f..e01720f 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -514,4 +514,10 @@ void Scene::free() {
 	warning("TODO: Scene::free");
 }
 
+void Scene::changeDepthSurface(int arg1) {
+	_v1 = arg1;
+	_sceneInfo->loadCodes(_depthSurface, nullptr);
+	_spriteSlots.fullRefresh();
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 16684c4..a51d820 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -201,6 +201,9 @@ public:
 	 * Clear the data for the scene
 	 */
 	void free();
+
+	void changeDepthSurface(int arg1);
+
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index d29d4e3..8f03783 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -163,11 +163,6 @@ protected:
 	 * Loads the given surface with depth information of a given scene
 	 */
 	virtual void loadCodes(MSurface &depthSurface) = 0;
-
-	/**
-	* Loads the given surface with depth information of a given scene
-	*/
-	virtual void loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream) = 0;
 public:
 	int _sceneId;
 	int _artFileNum;
@@ -206,6 +201,11 @@ public:
 	 * Set up a route node
 	 */
 	void setRouteNode(int nodeIndex, const Common::Point &pt, MSurface &depthSurface);
+
+	/**
+	* Loads the given surface with depth information of a given scene
+	*/
+	virtual void loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream) = 0;
 };
 
 } // End of namespace MADS


Commit: 74b48ba813b91e240be2f228faacc61be75011e6
    https://github.com/scummvm/scummvm/commit/74b48ba813b91e240be2f228faacc61be75011e6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-22T14:43:08-04:00

Commit Message:
MADS: Fixes for displaying kernel messages

Changed paths:
    engines/mads/messages.cpp
    engines/mads/messages.h
    engines/mads/scene_data.cpp



diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index 6dde40b..be84739 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -102,8 +102,6 @@ void KernelMessages::scrollMessage(int msgIndex, int numTicks, bool quoted) {
 	_entries[msgIndex]._frameTimer2 = _vm->_game->_priorFrameTimer;
 
 	Common::String msg = _entries[msgIndex]._msg;
-	_entries[msgIndex]._asciiChar = msg[0];
-	_entries[msgIndex]._asciiChar2 = msg[1];
 
 	if (_entries[msgIndex]._flags & KMSG_PLAYER_TIMEOUT)
 		_entries[msgIndex]._frameTimer2 = _vm->_game->_player._ticksAmount + 
@@ -125,8 +123,7 @@ void KernelMessages::remove(int msgIndex) {
 
 	if (rec._flags & KMSG_ACTIVE) {
 		if (rec._flags & KMSG_SCROLL) {
-			rec._msg.setChar(rec._asciiChar, rec._msgOffset);
-			rec._msg.setChar(rec._asciiChar2, rec._msgOffset + 1);
+			// WORKAROUND: Code here no longer needed in ScummVM
 		}
 
 		if (rec._textDisplayIndex >= 0)
@@ -144,11 +141,12 @@ void KernelMessages::reset() {
 }
 
 void KernelMessages::update() {
-	uint32 currentTimer = _vm->_game->_priorFrameTimer;
+	uint32 currentTimer = _vm->_game->_scene._frameStartTime;
 
-	for (uint i = 0; i < _entries.size(); ++i) {
-		if (((_entries[i]._flags & KMSG_ACTIVE) != 0) && 
-				(currentTimer >= _entries[i]._frameTimer))
+	for (uint i = 0; i < _entries.size() && !_vm->_game->_abortTimers; ++i) {
+		KernelMessage &msg = _entries[i];
+
+		if (((msg._flags & KMSG_ACTIVE) != 0) && (currentTimer >= msg._frameTimer))
 			processText(i);
 	}
 }
@@ -222,27 +220,23 @@ void KernelMessages::processText(int msgIndex) {
 	x1 += msg._position.x;
 	y1 += msg._position.y;
 
-	if ((msg._flags & KMSG_SCROLL) && (msg._frameTimer >= currentTimer)) {
-		msg._msg.setChar(msg._asciiChar, msg._msgOffset);
+	Common::String displayMsg = msg._msg;
 
+	if ((msg._flags & KMSG_SCROLL) && (msg._frameTimer >= currentTimer)) {
 		++msg._msgOffset;
-		msg._msg.setChar(msg._asciiChar2, msg._msgOffset);
-		msg._asciiChar = msg._msg[msg._msgOffset];
-		msg._asciiChar2 = !msg._asciiChar ? '\0' : msg._msg[msg._msgOffset + 1];
 
-		if (!msg._asciiChar) {
+		if (msg._msgOffset >= msg._msg.size()) {
 			// End of message
 			msg._flags &= ~KMSG_SCROLL;
-		} else if (msg._flags & KMSG_QUOTED) {
-			msg._msg.setChar('"', msg._msgOffset);
-			msg._msg.setChar('\0', msg._msgOffset + 1);
+		} else {
+			displayMsg = Common::String(msg._msg.c_str(), msg._msg.c_str() + msg._msgOffset);
 		}
 
 		msg._frameTimer = msg._frameTimer2 = currentTimer + msg._numTicks;
 		flag = true;
 	}
 
-	int strWidth = _talkFont->getWidth(msg._msg, scene._textSpacing);
+	int strWidth = _talkFont->getWidth(displayMsg, scene._textSpacing);
 
 	if (msg._flags & (KMSG_RIGHT_ALIGN | KMSG_CENTER_ALIGN)) {
 		x1 -= (msg._flags & KMSG_CENTER_ALIGN) ? strWidth / 2 : strWidth;
@@ -275,7 +269,7 @@ void KernelMessages::processText(int msgIndex) {
 	if (msg._textDisplayIndex < 0) {
 		// Need to create a new text display entry for this message
 		int idx = scene._textDisplay.add(x1, y1, msg._color1 | (msg._color2 << 8), 
-			scene._textSpacing, msg._msg, _talkFont);
+			scene._textSpacing, displayMsg, _talkFont);
 		if (idx >= 0)
 			msg._textDisplayIndex = idx;
 	}
@@ -298,8 +292,6 @@ void KernelMessages::setQuoted(int msgIndex, int numTicks, bool quoted) {
 		msg._msgOffset = 0;
 		msg._numTicks = numTicks;
 		msg._frameTimer2 = _vm->_game->_scene._frameStartTime;
-		msg._asciiChar = msg._msg[0];
-		msg._asciiChar2 = msg._msg[1];
 
 		if (msg._flags & KMSG_PLAYER_TIMEOUT) {
 			msg._frameTimer2 = _vm->_game->_player._priorTimer +
diff --git a/engines/mads/messages.h b/engines/mads/messages.h
index 8fb7595..8ca9bc6 100644
--- a/engines/mads/messages.h
+++ b/engines/mads/messages.h
@@ -47,8 +47,6 @@ class KernelMessage {
 public:
 	uint8 _flags;
 	int _sequenceIndex;
-	char _asciiChar;
-	char _asciiChar2;
 	int _color1;
 	int _color2;
 	Common::Point _position;
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 625eec7..a1f2734 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -42,8 +42,6 @@ void SceneNode::load(Common::SeekableReadStream *f) {
 KernelMessage::KernelMessage() {
 	_flags = 0;
 	_sequenceIndex = 0;
-	_asciiChar = '\0';
-	_asciiChar2 = '\0';
 	_color1 = 0;
 	_color2 = 0;
 	_msgOffset = 0;


Commit: 265fbce3dd086cb643b46b5f66790738d9f61bc3
    https://github.com/scummvm/scummvm/commit/265fbce3dd086cb643b46b5f66790738d9f61bc3
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-22T20:47:34+01:00

Commit Message:
MADS: Implement getTimeout()

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/sequence.cpp
    engines/mads/sequence.h



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index bec3fe4..f9da681 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -542,8 +542,8 @@ void Scene202::step() {
 		_scene->_hotspots.activate(199, false);
 		int idx = _scene->_dynamicHotspots.add(457, 13, _globals._spriteIndexes[20], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, 246, 124, 8);
-		warning("TODO: TimerList_getTimeout(_globals._spriteIndexes[26], _globals._spriteIndexes[20]);");
-		warning("TODO: TimerList_getTimeout(-1, _globals._spriteIndexes[26]);");
+		_scene->_sequences.getTimeout(_globals._spriteIndexes[26], _globals._spriteIndexes[20]);
+		_scene->_sequences.getTimeout(-1, _globals._spriteIndexes[26]);
 		_game._player._stepEnabled = true;
 		_game._player._visible = true;
 		_globals._v4 = false;
@@ -742,7 +742,7 @@ void Scene202::preActions() {
 			_scene->_sequences.setDepth(_globals._spriteIndexes[23], 1);
 			_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 1);
 		} else if (_game._abortTimers == 1) {
-			warning("TODO: TimerList_getTimeout(-1, _globals._spriteIndexes[23]);");
+			_scene->_sequences.getTimeout(-1, _globals._spriteIndexes[23]);
 			warning("CHECKME: _scene->_dynamicHotspots.remove(_globals._frameTime);");
 			_scene->_dynamicHotspots.remove(_globals._frameTime);
 			_game._player._visible = true;
@@ -836,7 +836,7 @@ void Scene202::actions() {
 				_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
 				_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
 				_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
-				warning("TODO: TimerList_getTimeout(_globals._spriteIndexes[23], _globals._spriteIndexes[24]);");
+				_scene->_sequences.getTimeout(_globals._spriteIndexes[23], _globals._spriteIndexes[24]);
 				_globals._v4 = -1;
 				_game._player._stepEnabled = true;
 				int msgIndex = _scene->_kernelMessages.add(Common::Point(248, 15), 0x1110, 32, 0, 60, _game.getQuote(97));
@@ -854,7 +854,7 @@ void Scene202::actions() {
 					_scene->_sequences.setAnimRange(_globals._spriteIndexes[25], 1, 6);
 					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
 					_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
-					warning("TODO: TimerList_getTimeout(-1, _globals._spriteIndexes[25]);");
+					_scene->_sequences.getTimeout(-1, _globals._spriteIndexes[25]);
 					_scene->_sequences.addSubEntry(_globals._spriteIndexes[25], SM_0, 0, 1);
 				} else if (_game._abortTimers == 1) {
 					_globals._spriteIndexes[25] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
@@ -877,7 +877,7 @@ void Scene202::actions() {
 					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
 					_scene->_sequences.addSubEntry(_globals._spriteIndexes[25], SM_0, 0, 3);
 				} else if (_game._abortTimers == 3) {
-					warning("TODO: TimerList_getTimeout(-1, _globals._spriteIndexes[25]);");
+					_scene->_sequences.getTimeout(-1, _globals._spriteIndexes[25]);
 					_game._player._stepEnabled = true;
 					_game._player._visible = true;
 				} else {
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index a03d0f8..453d90b 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -473,4 +473,17 @@ int SequenceList::startReverseCycle(int srcSpriteIndex, bool flipped, int numTic
 		numTicks, 0, 0, true, 100, depth - 1, 1, ANIMTYPE_REVERSIBLE, 0, 0);
 }
 
+void SequenceList::getTimeout(int spriteIdx, int arg2) {
+	int timeout;
+	if (spriteIdx >= 0)
+		timeout = _vm->_game->_scene._sequences._entries[spriteIdx]._timeout;
+	else
+		timeout = _vm->_game->_player._priorTimer + _vm->_game->_player._ticksAmount;
+
+	if (arg2 >= 0)
+		_vm->_game->_scene._sequences._entries[arg2]._timeout = timeout;
+	else
+		_vm->_game->_player._priorTimer = timeout - _vm->_game->_player._ticksAmount;
+
+}
 } // End of namespace 
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index f1b963a..69059a9 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -118,6 +118,7 @@ public:
 	int startCycle(int srcSpriteIdx, bool flipped, int cycleIndex);
 	int startReverseCycle(int srcSpriteIndex, bool flipped, int numTicks, int triggerCountdown, 
 		int timeoutTicks, int extraTicks);
+	void getTimeout(int spriteIdx, int arg2);
 };
 
 } // End of namespace MADS


Commit: ef152fa2ba5d6e7040434415f5e472da3abc6c5f
    https://github.com/scummvm/scummvm/commit/ef152fa2ba5d6e7040434415f5e472da3abc6c5f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-22T15:55:50-04:00

Commit Message:
MADS: Added _savedLookFlag to MADSAction

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 40ece8e..52be8ea 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -37,6 +37,7 @@ MADSAction::MADSAction(MADSEngine *vm) : _vm(vm) {
 	_selectedAction = 0;
 	_inProgress = false;
 	_savedSelectedRow = false;
+	_savedLookFlag = false;
 }
 
 void MADSAction::clear() {
diff --git a/engines/mads/action.h b/engines/mads/action.h
index 440990f..04d9c36 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -88,6 +88,7 @@ public:
 	MADSActionSavedFields _savedFields;
 	bool _walkFlag;
 	bool _savedSelectedRow;
+	bool _savedLookFlag;
 
 	// Unknown fields
 	int16 _v86F3A;
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 1ee1990..d12c2d7 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -257,6 +257,11 @@ void Scene103::preActions() {
 }
 
 void Scene103::actions() {
+	if (_action._savedLookFlag) {
+		Dialog::show(0x2852);
+	}
+
+	_action._inProgress = false;
 }
 
 void Scene103::postActions() {


Commit: db4e74f4dd1994bd468f78eca57800f9f3970b11
    https://github.com/scummvm/scummvm/commit/db4e74f4dd1994bd468f78eca57800f9f3970b11
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-22T21:22:55+01:00

Commit Message:
MADS: Add _v8425C, set _globals._v7 as uint32

Changed paths:
    engines/mads/nebular/globals_nebular.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h



diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index 8d9d009..f7e28fc 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -44,7 +44,7 @@ public:
 	int _v4;
 	int _v5;
 	int _v6;
-	int _v7;
+	uint32 _v7;
 	int _v8;
 	int _abortVal;
 public:
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index f9da681..4acbe92 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -418,8 +418,7 @@ void Scene202::enter() {
 		_globals._v4 = 0;
 	}
 
-	_globals._v7 = _scene->_frameStartTime;
-	warning("TODO: dword_8425C = _scene->_frameStartTime;");
+	_game._scene._v8425C = _globals._v7 = _scene->_frameStartTime;
 
 	if (_scene->_roomChanged)
 		_game._objects.addToInventory(OBJ_NONE);
@@ -484,7 +483,7 @@ void Scene202::step() {
 	if (_game._abortTimers == 71) {
 		_vm->_sound->command(3);
 		_vm->_sound->command(9);
-		warning("TODO: dword_8425C = 900 + _scene->_frameStartTime;");
+		_game._scene._v8425C = 900 + _scene->_frameStartTime;
 		Common::Point msgPos;
 		int msgFlag;
 		if (_globals._v4 == 0) {
@@ -555,8 +554,7 @@ void Scene202::step() {
 		break;
 	}
 	
-	if (!_scene->_activeAnimation && (_globals[33] != 2) && (_globals._v7 <= _scene->_frameStartTime)) {
-		warning("TODO: && (dword_8425C <= _scene->_frameStartTime) {");
+	if (!_scene->_activeAnimation && (_globals[33] != 2) && (_globals._v7 <= _scene->_frameStartTime) && (_game._scene._v8425C <= _scene->_frameStartTime)) {
 		int randVal = _vm->getRandomNumber(499) + 1;
 		int threshold = 1;
 		if (_globals._v4)
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 2aa65d9..dd86b56 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -290,7 +290,7 @@ void Scene804::step() {
 	}
 	if (_scene->_activeAnimation->getCurrentFrame() == 80 && !_globals._v7) {
 		_vm->_sound->command(22);
-		_globals._v7 = -1;
+		_globals._v7 = 0xFFFFFFFF;
 	}
 }
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index e01720f..9ad494d 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -48,6 +48,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 	_activeAnimation = nullptr;
 	_textSpacing = -1;
 	_frameStartTime = 0;
+	_v8425C = 0;
 	_layer = LAYER_GUI;
 	_lookFlag = false;
 	_highlightedHotspot = 0;
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index a51d820..787c5e0 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -117,6 +117,7 @@ public:
 	int _destFacing;
 	Common::Point _posAdjust;
 	uint32 _frameStartTime;
+	uint32 _v8425C;
 	Layer _layer;
 	bool _lookFlag;
 	int _highlightedHotspot;


Commit: eb82e63398c2050cbb72008cd849b8d1fda89c3e
    https://github.com/scummvm/scummvm/commit/eb82e63398c2050cbb72008cd849b8d1fda89c3e
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-22T21:45:28+01:00

Commit Message:
MADS: make _msgOffset a uint32

Changed paths:
    engines/mads/messages.h



diff --git a/engines/mads/messages.h b/engines/mads/messages.h
index 8ca9bc6..90269c1 100644
--- a/engines/mads/messages.h
+++ b/engines/mads/messages.h
@@ -51,7 +51,7 @@ public:
 	int _color2;
 	Common::Point _position;
 	int _textDisplayIndex;
-	int _msgOffset;
+	uint32 _msgOffset;
 	int _numTicks;
 	uint32 _frameTimer2;
 	uint32 _frameTimer;


Commit: c42e831817d3eef04f493c08cd288dfe41f764e6
    https://github.com/scummvm/scummvm/commit/c42e831817d3eef04f493c08cd288dfe41f764e6
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-22T22:02:52+01:00

Commit Message:
MADS: Introduce another getRandomNumber function with 2 parameters

Changed paths:
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes8.cpp



diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index d6cd901..68d8579 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -107,6 +107,12 @@ int MADSEngine::getRandomNumber(int maxNumber) {
 	return _randomSource.getRandomNumber(maxNumber);
 }
 
+int MADSEngine::getRandomNumber(int minNumber, int maxNumber) {
+	int range = maxNumber - minNumber;
+
+	return minNumber + _randomSource.getRandomNumber(range);
+}
+
 int MADSEngine::hypotenuse(int xv, int yv) {
 	return (int)sqrt((double)(xv * xv + yv * yv));
 }
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index e9da307..cf8046f 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -116,6 +116,7 @@ public:
 	uint32 getGameFeatures() const;
 
 	int getRandomNumber(int maxNumber);
+	int getRandomNumber(int minNumber, int maxNumber);
 	int hypotenuse(int xv, int yv);
 };
 
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index dc74f39..6dabbec 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -90,7 +90,7 @@ bool CopyProtectionDialog::getHogAnusEntry(HOGANUS &entry) {
 
 	// Read in the total number of entries, and randomly pick an entry to use
 	int numEntries = f.readUint16LE();
-	int entryIndex = _vm->getRandomNumber(numEntries - 2) + 1;
+	int entryIndex = _vm->getRandomNumber(1, numEntries);
 
 	// Read in the encrypted entry
 	f.seek(28 * entryIndex + 2);
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 4acbe92..cc896c6 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -462,7 +462,7 @@ void Scene202::enter() {
 }
 
 void Scene202::setRandomKernelMessage() {
-	int vocabId = 92 + _vm->getRandomNumber(4);
+	int vocabId = _vm->getRandomNumber(92, 96);
 	_scene->_kernelMessages.reset();
 	_game._abortTimersMode2 = ABORTMODE_1;
 	_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 70, 120, _game.getQuote(vocabId));
@@ -555,7 +555,7 @@ void Scene202::step() {
 	}
 	
 	if (!_scene->_activeAnimation && (_globals[33] != 2) && (_globals._v7 <= _scene->_frameStartTime) && (_game._scene._v8425C <= _scene->_frameStartTime)) {
-		int randVal = _vm->getRandomNumber(499) + 1;
+		int randVal = _vm->getRandomNumber(1, 500);
 		int threshold = 1;
 		if (_globals._v4)
 			threshold = 26;
@@ -614,7 +614,7 @@ void Scene202::step() {
 //	}
 	
 	warning("TODO: word84260 = _scene->_activeAnimation->getCurrentFrame();");
-	int randVal = _vm->getRandomNumber(999) + 1;
+	int randVal = _vm->getRandomNumber(1, 1000);
 	int frameStep = -1;
 	
 	switch (_scene->_activeAnimation->getCurrentFrame()) {
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index dd86b56..2a28ede 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -239,7 +239,7 @@ void Scene804::step() {
 
 		switch (_scene->_activeAnimation->getCurrentFrame()) {
 		case 1:
-			_globals[29] = _vm->getRandomNumber(29) + 1;
+			_globals[29] = _vm->getRandomNumber(1, 30);
 			switch (_globals[29]) {
 			case 1:
 				_globals._v5 = 25;


Commit: 2ac614d898159096933df061c5c0bd221cf8d16b
    https://github.com/scummvm/scummvm/commit/2ac614d898159096933df061c5c0bd221cf8d16b
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-22T22:30:45+01:00

Commit Message:
MADS: Add some variables in / move a variable to _globals

Changed paths:
    engines/mads/nebular/globals_nebular.cpp
    engines/mads/nebular/globals_nebular.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h



diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp
index 31b7940..d2a82d5 100644
--- a/engines/mads/nebular/globals_nebular.cpp
+++ b/engines/mads/nebular/globals_nebular.cpp
@@ -44,6 +44,12 @@ Globals::Globals() {
 	_v7 = 0;
 	_v8 = 0;
 	_abortVal = 0;
+	_v8425C = 0;
+	_v84260 = 0;
+	_v84262 = 0;
+	_v84264 = 0;
+	_v84266 = 0;
+	_v84268 = 0;
 }
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index f7e28fc..bbc2353 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -47,6 +47,8 @@ public:
 	uint32 _v7;
 	int _v8;
 	int _abortVal;
+	uint32 _v8425C;
+	int _v84260, _v84262, _v84264, _v84266, _v84268;
 public:
 	/**
 	 * Constructor
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index cc896c6..503e031 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -418,7 +418,7 @@ void Scene202::enter() {
 		_globals._v4 = 0;
 	}
 
-	_game._scene._v8425C = _globals._v7 = _scene->_frameStartTime;
+	_globals._v8425C = _globals._v7 = _scene->_frameStartTime;
 
 	if (_scene->_roomChanged)
 		_game._objects.addToInventory(OBJ_NONE);
@@ -483,7 +483,7 @@ void Scene202::step() {
 	if (_game._abortTimers == 71) {
 		_vm->_sound->command(3);
 		_vm->_sound->command(9);
-		_game._scene._v8425C = 900 + _scene->_frameStartTime;
+		_globals._v8425C = 900 + _scene->_frameStartTime;
 		Common::Point msgPos;
 		int msgFlag;
 		if (_globals._v4 == 0) {
@@ -554,7 +554,7 @@ void Scene202::step() {
 		break;
 	}
 	
-	if (!_scene->_activeAnimation && (_globals[33] != 2) && (_globals._v7 <= _scene->_frameStartTime) && (_game._scene._v8425C <= _scene->_frameStartTime)) {
+	if (!_scene->_activeAnimation && (_globals[33] != 2) && (_globals._v7 <= _scene->_frameStartTime) && (_globals._v8425C <= _scene->_frameStartTime)) {
 		int randVal = _vm->getRandomNumber(1, 500);
 		int threshold = 1;
 		if (_globals._v4)
@@ -564,13 +564,13 @@ void Scene202::step() {
 		if (threshold >= randVal) {
 			_vm->_sound->command(17);
 			_scene->loadAnimation(formAnimName('M', -1), 71);
-			warning("TODO: word84266 = -1;");
-			warning("TODO: word84268 = 0;");
+			_globals._v84266 = -1;
+			_globals._v84268 = 0;
 			_globals[37] = true;
 			_globals._v6 = _scene->_frameStartTime;
 			_globals._v8 = 0;
-			warning("TODO: _timerIndex = 0;");
-			warning("TODO: word84264 = 0;");
+			_globals._v84262 = 0;
+			_globals._v84264 = 0;
 			_globals._v7 = _scene->_frameStartTime + 2;
 		}
 	}
@@ -588,8 +588,7 @@ void Scene202::step() {
 			}
 		}
 
-		if (_scene->_activeAnimation->getCurrentFrame() == 160) {
-			warning("TODO: && (word84260 != _scene->_activeAnimation->getCurrentFrame()) {");
+		if ((_scene->_activeAnimation->getCurrentFrame() == 160) && (_globals._v84260 != _scene->_activeAnimation->getCurrentFrame())) {
 			Common::Point msgPos;
 			int msgFlag;
 			if (_globals._v4 == 0) {
@@ -605,15 +604,14 @@ void Scene202::step() {
 	}
 
 	if (_globals._v7 + 7200 <= _scene->_frameStartTime) {
-		warning("TODO: word84268 = -1;");
+		_globals._v84268 = -1;
 	}
 
-	warning("TODO: if (_scene->_activeAnimation->getCurrentFrame() == word84260) {");
-//	if (_scene->_activeAnimation->getCurrentFrame() == word84260) {
-//		return;
-//	}
+	if (_scene->_activeAnimation->getCurrentFrame() == _globals._v84260) {
+		return;
+	}
 	
-	warning("TODO: word84260 = _scene->_activeAnimation->getCurrentFrame();");
+	_globals._v84260 = _scene->_activeAnimation->getCurrentFrame();
 	int randVal = _vm->getRandomNumber(1, 1000);
 	int frameStep = -1;
 	
@@ -636,18 +634,18 @@ void Scene202::step() {
 		frameStep = subStep4(randVal);
 		break;
 	case 59:
-		warning("TODO: _timerIndex = 3;");
-		warning("TODO: ++word84264;");
+		_globals._v84262 = 3;
+		++_globals._v84264;
 		if (randVal <= 800)
 			frameStep = 55;
 		break;
 	case 89:
-		warning("TODO: _timerIndex = 1;");
+		_globals._v84262 = 1;
 		if (randVal <= 700)
 			frameStep = 83;
 		break;
 	case 137:
-		warning("TODO: _timerIndex = 2;");
+		_globals._v84262 = 2;
 		if (randVal <= 700)
 			frameStep = 126;
 		break;
@@ -659,37 +657,32 @@ void Scene202::step() {
 	int nextFrame = 1 + _scene->_activeAnimation->getCurrentFrame() - frameStep;
 	if (nextFrame) {
 		_scene->_activeAnimation->setCurrentFrame(nextFrame);
-		warning("word84260 = nextFrame");
+		_globals._v84260 = nextFrame;
 	}
 }
 
 int Scene202::subStep1(int randVal) {
-	warning("TODO: word84264 = 0;");
+	_globals._v84264 = 0;
 
-	warning("TODO: if ((randVal <= 100) || (word84266 != 0))");
-	if (randVal <= 100)
+	if ((randVal <= 100) || (_globals._v84266 != 0))
 		return 42;
 
-	warning("TODO: if ((randVal <= 200) || (word84268 != 0))");
-	if (randVal <= 200)
+	if ((randVal <= 200) || (_globals._v84268 != 0))
 		return 96;
 
-	warning("TODO: if ((randVal <= 300) && (_timerIndex != 1))");
-	if (randVal <= 300)
+	if ((randVal <= 300) && (_globals._v84262 != 1))
 		return 77;
 
 	return 76;
 }
 
 int Scene202::subStep2(int randVal) {
-	warning("TODO: word84266 = 0;");
+	_globals._v84266 = 0;
 
-	warning("TODO: if ((randVal <= 150) && (word84264 < 5)");
-	if (randVal <= 150)
+	if ((randVal <= 150) && (_globals._v84264 < 5))
 		return 51;
 
-	warning("TODO: if ((randVal <= 300) || word84268)");
-	if (randVal <= 300)
+	if ((randVal <= 300) || _globals._v84268)
 		return 74;
 
 	if (randVal <= 400)
@@ -699,24 +692,20 @@ int Scene202::subStep2(int randVal) {
 }
 
 int Scene202::subStep3(int randVal) {
-	warning("TODO: if ((randVal <= 100) || (word84266 != 0))");
-	if (randVal <= 100)
+	if ((randVal <= 100) || (_globals._v84266 != 0))
 		return 27;
 
-	warning("TODO: if ((randVal <= 200) || (word84268 != 0))");
-	if (randVal <= 200)
+	if ((randVal <= 200) || (_globals._v84268 != 0))
 		return 159;
 
-	warning("TODO: if ((randVal <= 300) && (_timerIndex != 2))");
-	if (randVal <= 300)
+	if ((randVal <= 300) && (_globals._v84262 != 2))
 		return 119;
 
 	return 110;
 }
 
 int Scene202::subStep4(int randVal) {
-	warning("TODO: if ((randVal <= 100) || (word84268 != 0))");
-	if (randVal <= 100)
+	if ((randVal <= 100) || (_globals._v84268 != 0))
 		return 176;
 
 	if (randVal <= 200)
@@ -884,7 +873,7 @@ void Scene202::actions() {
 				}
 			} else {
 				if (_game._abortTimers == 0) {
-					warning("TODO: word_84268 = 1;");
+					_globals._v84268 = 1;
 					_game._player._stepEnabled = false;
 					_scene->_sequences.remove(_globals._spriteIndexes[24]);
 					_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0);
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 9ad494d..e01720f 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -48,7 +48,6 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 	_activeAnimation = nullptr;
 	_textSpacing = -1;
 	_frameStartTime = 0;
-	_v8425C = 0;
 	_layer = LAYER_GUI;
 	_lookFlag = false;
 	_highlightedHotspot = 0;
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 787c5e0..a51d820 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -117,7 +117,6 @@ public:
 	int _destFacing;
 	Common::Point _posAdjust;
 	uint32 _frameStartTime;
-	uint32 _v8425C;
 	Layer _layer;
 	bool _lookFlag;
 	int _highlightedHotspot;


Commit: 83a8ec14717b8b3c8ec2dced8465905f8c1c233c
    https://github.com/scummvm/scummvm/commit/83a8ec14717b8b3c8ec2dced8465905f8c1c233c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-22T22:55:02+01:00

Commit Message:
MADS: Add a stub for Dialog::showPicture()

Changed paths:
    engines/mads/dialogs.h
    engines/mads/nebular/dialogs_nebular.h
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index bec7f84..b50d07f 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -193,6 +193,7 @@ public:
 	virtual ~Dialogs() {}
 
 	virtual void showDialog() = 0;
+	virtual void showPicture(int objId, int msgId, int arg3) = 0;
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index d4e4fe9..c7b0e52 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -39,6 +39,9 @@ public:
 	virtual void showDialog() {
 		warning("TODO: showDialog");
 	}
+	virtual void showPicture(int objId, int msgId, int arg3) {
+		warning("TODO: showPicture");
+	}
 };
 
 struct HOGANUS {
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 503e031..3d88080 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -793,10 +793,10 @@ void Scene202::actions() {
 					if (_game._objects.isInInventory(OBJ_BONE)) {
 						_game._objects.removeFromInventory(OBJ_BONE, 1);
 						_game._objects.addToInventory(OBJ_BONES);
-						warning("TODO: Dialog::showPicture(OBJ_BONES, 0x4EFA, 0);");
+						_vm->_dialogs->showPicture(OBJ_BONES, 0x4EFA, 0);
 					} else {
 						_game._objects.addToInventory(OBJ_BONE);
-						warning("TODO: Dialog::showPicture(OBJ_BONE, 0x4EFA, 0);");
+						_vm->_dialogs->showPicture(OBJ_BONE, 0x4EFA, 0);
 					}
 					_scene->changeDepthSurface(_globals[32]);
 					_game._player._stepEnabled = true;


Commit: a7c4fc7e234f604923aae0d08e03c6b8268688f4
    https://github.com/scummvm/scummvm/commit/a7c4fc7e234f604923aae0d08e03c6b8268688f4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-22T18:26:41-04:00

Commit Message:
MADS: In progress implementing ScreenObjects::elementHighlighted

Changed paths:
    engines/mads/scene.cpp
    engines/mads/screen.cpp
    engines/mads/screen.h
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index e01720f..e357f8b 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -337,7 +337,8 @@ void Scene::doFrame() {
 			CursorType cursorId = CURSOR_ARROW;
 			if (_action._v83338 == 1 && !_vm->_game->_screenObjects._v7FECA &&
 					_vm->_game->_screenObjects._category == CAT_HOTSPOT) {
-				int idx = _vm->_game->_screenObjects._selectedObject - _vm->_game->_screenObjects._hotspotsIndex;
+				int idx = _vm->_game->_screenObjects._selectedObject - 
+					_userInterface._categoryIndexes[CAT_HOTSPOT - 1];
 				assert(idx >= 0);
 
 				if (idx >= (int)_hotspots.size()) {
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 3565c1a..dac61d5 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -262,7 +262,6 @@ ScreenObjects::ScreenObjects(MADSEngine *vm) : _vm(vm) {
 	_newDescId = 0;
 	_released = false;
 	_uiCount = 0;
-	_hotspotsIndex = 0;
 	_selectedObject = -1;
 	_scrollerY = -1;
 	_milliTime = 0;
@@ -302,7 +301,7 @@ void ScreenObjects::check(bool scanFlag) {
 			&& scene._userInterface._category != CAT_NONE) {
 			_released = true;
 			if (category >= CAT_ACTION && category <= CAT_TALK_ENTRY) {
-				scene._userInterface.elementHighlighted();
+				elementHighlighted();
 			}
 
 			scene._action.checkActionAtMousePos();
@@ -314,7 +313,7 @@ void ScreenObjects::check(bool scanFlag) {
 
 		if (!_vm->_events->_mouseButtons || _vm->_easyMouse) {
 			if (category >= CAT_ACTION && category <= CAT_TALK_ENTRY) {
-				scene._userInterface.elementHighlighted();
+				elementHighlighted();
 			}
 		}
 
@@ -448,6 +447,136 @@ void ScreenObjects::checkScroller() {
 	_objectY = userInterface._objectY;
 }
 
+void ScreenObjects::elementHighlighted() {
+	Scene &scene = _vm->_game->_scene;
+	UserInterface &userInterface = scene._userInterface;
+	Common::Array<int> &invList = _vm->_game->_objects._inventoryList;
+	MADSAction &action = scene._action;
+	int varA;
+	int topIndex;
+	int *var6;
+	int var4;
+	int index, indexEnd;
+	int var8 = 0;
+	int uiCount;
+
+	switch (userInterface._category) {
+	case CAT_ACTION:
+		index = 10;
+		indexEnd = 9;
+		varA = 5;
+		topIndex = 0;
+		var6 = !_v7FECA ? &userInterface._v1A : &userInterface._selectedActionIndex;
+
+		if (_v7FECA && userInterface._selectedItemVocabIdx >= 0)
+			userInterface.drawInventory(3, -1, &userInterface._selectedItemVocabIdx);
+
+		var4 = _released && !_v7FECA ? 1 : 0;
+		break;
+
+	case CAT_INV_LIST:
+		userInterface.scrollInventory();
+
+		index = MIN((int)invList.size() - userInterface._inventoryTopIndex, 5);
+		indexEnd = invList.size() - 1;
+		varA = 0;
+		topIndex = userInterface._inventoryTopIndex;
+		var6 = &userInterface._v1C;
+		var4 = (!_released || (_vm->_events->_mouseButtons && action._v83338 == 1)) ? 0 : 1;
+		break;
+
+	case CAT_INV_VOCAB:
+		if (userInterface._selectedInvIndex >= 0) {
+			InventoryObject &invObject = _vm->_game->_objects.getItem(
+				userInterface._selectedInvIndex);
+			index = invObject._vocabCount;
+			indexEnd = index - 1;
+		} else {
+			index = 0;
+		}
+
+		varA = 0;
+		topIndex = 0;
+		var6 = _v7FECA ? &userInterface._selectedItemVocabIdx : &userInterface._v1E;
+
+		if (_v7FECA && userInterface._selectedActionIndex >= 0)
+			userInterface.drawInventory(1, -1, &userInterface._selectedActionIndex);
+
+		var4 = _released && !_v7FECA ? 1 : 0;
+		break;
+
+	case CAT_INV_ANIM:
+		index = 1;
+		indexEnd = invList.size() - 1;
+		varA = 0;
+		topIndex = userInterface._selectedInvIndex;
+		var6 = &var8;
+		var4 = -1;
+		break;
+
+	case CAT_TALK_ENTRY:
+		uiCount = size() - _uiCount;
+		index = scene._hotspots.size();
+		indexEnd = index - 1;
+		varA = 0;
+		topIndex = 0;
+		var6 = &var8;
+		var4 = -1;
+		break;
+
+	default:
+		index = 0;
+		for (int idx = 0; idx < 5; ++idx) {
+			if (!userInterface._talkStrings[idx].empty())
+				++index;
+		}
+
+		indexEnd = index - 1;
+		varA = 0;
+		topIndex = 0;
+		var6 = &userInterface._v1A;
+		var4 = -1;
+		break;
+	}
+
+	int newIndex = -1;
+	int catIndex = userInterface._categoryIndexes[userInterface._category - 1];
+	int newY = 0;
+	int var1E = 0;
+
+	for (int idx = 0; idx < index & newIndex < 0; ++idx) {
+		warning("TODO");
+	}
+
+	if (newIndex == -1 && index > 0 && !var4) {
+		if (_vm->_events->currentPos().y <= newY) {
+			newIndex = 0;
+			if (varA && _vm->_events->currentPos().x >= var1E)
+				newIndex = varA;
+		} else {
+			newIndex = index - 1;
+		}
+	}
+
+	if (newIndex >= 0)
+		newIndex = MIN(newIndex + topIndex, indexEnd);
+
+	_vm->_game->_scene._highlightedHotspot = newIndex;
+
+	if (_category == CAT_INV_LIST || _category == CAT_INV_ANIM) {
+		if (action._v83338 == 1 && newIndex >= 0 && _released &&
+				(!_vm->_events->_mouseReleased || !_vm->_easyMouse))
+			newIndex = -1;
+	}
+
+	if (_released && !_vm->_game->_screenObjects._v7FECA &&
+			(_vm->_events->_mouseReleased || !_vm->_easyMouse))
+		newIndex = -1;
+
+	if (_category != CAT_HOTSPOT && _category != CAT_INV_ANIM)
+		userInterface.drawInventory(_category, newIndex, var6);
+}
+
 /*------------------------------------------------------------------------*/
 
 ScreenSurface::ScreenSurface() {
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index c8534a0..1d1e6d3 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -158,7 +158,6 @@ public:
 	int _currentDescId;
 	bool _released;
 	int _uiCount;
-	int _hotspotsIndex;
 	uint32 _milliTime;
 	bool _eventFlag;
 
@@ -175,6 +174,11 @@ public:
 	/**
 	*/
 	void check(bool scanFlag);
+
+	/**
+	 * Handle element being highlighted on the screen
+	 */
+	void elementHighlighted();
 };
 
 class ScreenSurface : public MSurface {
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 4dba127..cae5c11 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -188,6 +188,8 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm), _dirtyAreas(vm),
 		_uiSlots(vm) {
 	_invSpritesIndex = -1;
 	_invFrameNumber = 1;
+	_scrollMilli = 0;
+	_scrollFlag = false;
 	_category = CAT_NONE;
 	_inventoryTopIndex = 0;
 	_objectY = 0;
@@ -200,6 +202,7 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm), _dirtyAreas(vm),
 	_v1E = -1;
 	_dirtyAreas.resize(50);
 	_inventoryChanged = false;
+	Common::fill(&_categoryIndexes[0], &_categoryIndexes[7], 0);
 
 	// Map the user interface to the bottom of the game's screen surface
 	byte *pData = _vm->_screen.getBasePtr(0, MADS_SCENE_HEIGHT);
@@ -272,10 +275,6 @@ void UserInterface::setup(int id) {
 	scene._dynamicHotspots.refresh();
 }
 
-void UserInterface::elementHighlighted() {
-	warning("TODO: UserInterface::elementHighlighted");
-}
-
 void UserInterface::drawTextElements() {
 	if (_vm->_game->_screenObjects._v832EC) {
 		drawTalkList();
@@ -415,6 +414,7 @@ void UserInterface::loadElements() {
 		}
 
 		// Set up actions
+		_categoryIndexes[CAT_ACTION - 1] = _vm->_game->_screenObjects.size() + 1;
 		for (int idx = 0; idx < 10; ++idx) {
 			getBounds(CAT_ACTION, idx, bounds);
 			moveRect(bounds);
@@ -423,6 +423,7 @@ void UserInterface::loadElements() {
 		}
 
 		// Set up inventory list
+		_categoryIndexes[CAT_INV_LIST - 1] = _vm->_game->_screenObjects.size() + 1;
 		for (int idx = 0; idx < 5; ++idx) {
 			getBounds(CAT_INV_LIST, idx, bounds);
 			moveRect(bounds);
@@ -431,6 +432,7 @@ void UserInterface::loadElements() {
 		}
 
 		// Set up the inventory vocab list
+		_categoryIndexes[CAT_INV_VOCAB - 1] = _vm->_game->_screenObjects.size() + 1;
 		for (int idx = 0; idx < 5; ++idx) {
 			getBounds(CAT_INV_VOCAB, idx, bounds);
 			moveRect(bounds);
@@ -439,12 +441,13 @@ void UserInterface::loadElements() {
 		}
 
 		// Set up the inventory item picture
+		_categoryIndexes[CAT_INV_ANIM - 1] = _vm->_game->_screenObjects.size() + 1;
 		_vm->_game->_screenObjects.add(Common::Rect(160, 159, 231, 194), LAYER_GUI,
 			CAT_INV_ANIM, 0);
 	}
 
 	if (!_vm->_game->_screenObjects._v832EC || _vm->_game->_screenObjects._v832EC == 2) {
-		_vm->_game->_screenObjects._hotspotsIndex = _vm->_game->_screenObjects.size();
+		_categoryIndexes[CAT_HOTSPOT - 1] = _vm->_game->_screenObjects.size();
 		for (int hotspotIdx = scene._hotspots.size() - 1; hotspotIdx >= 0; --hotspotIdx) {
 			Hotspot &hs = scene._hotspots[hotspotIdx];
 			_vm->_game->_screenObjects.add(hs._bounds, LAYER_GUI, CAT_HOTSPOT, hotspotIdx);
@@ -453,6 +456,7 @@ void UserInterface::loadElements() {
 
 	if (_vm->_game->_screenObjects._v832EC == 1) {
 		// setup areas for talk entries
+		_categoryIndexes[CAT_TALK_ENTRY - 1] = _vm->_game->_screenObjects.size() + 1;
 		for (int idx = 0; idx < 5; ++idx) {
 			getBounds(CAT_TALK_ENTRY, idx, bounds);
 			moveRect(bounds);
@@ -644,4 +648,36 @@ void UserInterface::scrollerChanged() {
 	warning("TODO: scrollerChanged");
 }
 
+void UserInterface::scrollInventory() {
+	Common::Array<int> &invList = _vm->_game->_objects._inventoryList;
+
+	if (_vm->_events->_mouseButtons) {
+		int yp = _vm->_events->currentPos().y;
+		if (yp < MADS_SCENE_HEIGHT || yp == (MADS_SCREEN_HEIGHT - 1)) {
+			uint32 timeDiff = _scrollFlag ? 100 : 380;
+			uint32 currentMilli = g_system->getMillis();
+			_vm->_game->_screenObjects._v8332A = -1;
+
+			if (currentMilli >= (_scrollMilli + timeDiff)) {
+				_scrollMilli = currentMilli;
+				_scrollFlag = true;
+
+				if (yp == (MADS_SCREEN_HEIGHT - 1)) {
+					if (_inventoryTopIndex < (invList.size() - 1)) {
+						++_inventoryTopIndex;
+						_inventoryChanged = true;
+					}
+				} else {
+					if (_inventoryTopIndex > 0) {
+						--_inventoryTopIndex;
+						_inventoryChanged = true;
+					}
+				}
+			}
+		}
+	}
+
+	_vm->_game->_screenObjects._v8332A = 0;
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 06f1e70..abb4619 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -79,6 +79,8 @@ private:
 	MADSEngine *_vm;
 	int _invSpritesIndex;
 	int _invFrameNumber;
+	uint32 _scrollMilli;
+	bool _scrollFlag;
 
 	/**
 	 * Loads the elements of the user interface
@@ -143,6 +145,7 @@ public:
 	int _v1C;
 	int _v1E;
 	bool _inventoryChanged;
+	int _categoryIndexes[8];
 	Common::StringArray _talkStrings;
 	Common::Array<int> _talkIds;
 public:
@@ -161,8 +164,6 @@ public:
 	*/
 	void setup(int id);
 
-	void elementHighlighted();
-
 	void drawTextElements();
 
 	void setBounds(const Common::Rect &r);
@@ -193,6 +194,8 @@ public:
 	void drawInventory(int v1, int v2, int *v3);
 
 	void scrollerChanged();
+
+	void scrollInventory();
 };
 
 } // End of namespace MADS


Commit: c64a024aa07d64ab821514f1c82f51fe33c1af0d
    https://github.com/scummvm/scummvm/commit/c64a024aa07d64ab821514f1c82f51fe33c1af0d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-22T19:09:25-04:00

Commit Message:
MADS: Completed elementHighlighted method

Changed paths:
    engines/mads/screen.cpp



diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index dac61d5..0fc2318 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -541,17 +541,41 @@ void ScreenObjects::elementHighlighted() {
 
 	int newIndex = -1;
 	int catIndex = userInterface._categoryIndexes[userInterface._category - 1];
-	int newY = 0;
-	int var1E = 0;
+	int newX = 0, newY = 0;
+	Common::Point currentPos = _vm->_events->currentPos();
 
 	for (int idx = 0; idx < index & newIndex < 0; ++idx) {
-		warning("TODO");
+		int scrObjIndex = (_category == CAT_HOTSPOT) ? catIndex - idx + index - 1 :
+			catIndex + idx;
+		
+		ScreenObject &scrObject = (*this)[scrObjIndex];
+		Common::Rect bounds = scrObject._bounds;
+		newY = MAX((int)bounds.bottom, newY);
+		newX = MAX((int)bounds.left, newX);
+
+		if (currentPos.y > newY && currentPos.y < bounds.bottom) {
+			if (var4) {
+				if (currentPos.x > newX && currentPos.x < bounds.right) {
+					newIndex = scrObjIndex - catIndex;
+					if (_category == CAT_HOTSPOT && newIndex < scene._hotspots.size())
+						newIndex = scene._hotspots.size() - newIndex - 1;
+				}
+			} else if (!varA) {
+				newIndex = idx;
+			} else if (varA <= idx) {
+				if (currentPos.x > bounds.left)
+					newIndex = idx;
+			} else {
+				if (currentPos.x > bounds.right)
+					newIndex = idx;
+			}
+		}
 	}
 
 	if (newIndex == -1 && index > 0 && !var4) {
 		if (_vm->_events->currentPos().y <= newY) {
 			newIndex = 0;
-			if (varA && _vm->_events->currentPos().x >= var1E)
+			if (varA && _vm->_events->currentPos().x >= newX)
 				newIndex = varA;
 		} else {
 			newIndex = index - 1;


Commit: 06766e930b3c6a858d6dccced7845eeec44708f7
    https://github.com/scummvm/scummvm/commit/06766e930b3c6a858d6dccced7845eeec44708f7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-22T20:02:02-04:00

Commit Message:
MADS: Fix main switch statement in elementHighlighted

Changed paths:
    engines/mads/screen.cpp



diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 0fc2318..d191f49 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -282,6 +282,7 @@ void ScreenObjects::add(const Common::Rect &bounds, Layer layer, ScrCategory cat
 
 void ScreenObjects::check(bool scanFlag) {
 	Scene &scene = _vm->_game->_scene;
+	UserInterface &userInterface = scene._userInterface;
 
 	if (!_vm->_events->_mouseButtons || _v832EC)
 		_v7FECA = false;
@@ -312,7 +313,7 @@ void ScreenObjects::check(bool scanFlag) {
 			scene._userInterface._category = _category;
 
 		if (!_vm->_events->_mouseButtons || _vm->_easyMouse) {
-			if (category >= CAT_ACTION && category <= CAT_TALK_ENTRY) {
+			if (userInterface._category >= CAT_ACTION && userInterface._category <= CAT_TALK_ENTRY) {
 				elementHighlighted();
 			}
 		}
@@ -339,7 +340,6 @@ void ScreenObjects::check(bool scanFlag) {
 
 	scene._action.refresh();
 
-	UserInterface &userInterface = _vm->_game->_scene._userInterface;
 	uint32 currentTicks = _vm->_events->getFrameCounter();
 	if (currentTicks >= _vm->_game->_ticksExpiry) {
 		// Check the user interface slots to see if there's any slots that need to be expired
@@ -456,12 +456,13 @@ void ScreenObjects::elementHighlighted() {
 	int topIndex;
 	int *var6;
 	int var4;
-	int index, indexEnd;
+	int index;
+	int indexEnd = -1;
 	int var8 = 0;
 	int uiCount;
 
 	switch (userInterface._category) {
-	case CAT_ACTION:
+	case CAT_INV_LIST:
 		index = 10;
 		indexEnd = 9;
 		varA = 5;
@@ -474,7 +475,7 @@ void ScreenObjects::elementHighlighted() {
 		var4 = _released && !_v7FECA ? 1 : 0;
 		break;
 
-	case CAT_INV_LIST:
+	case CAT_INV_VOCAB:
 		userInterface.scrollInventory();
 
 		index = MIN((int)invList.size() - userInterface._inventoryTopIndex, 5);
@@ -485,7 +486,7 @@ void ScreenObjects::elementHighlighted() {
 		var4 = (!_released || (_vm->_events->_mouseButtons && action._v83338 == 1)) ? 0 : 1;
 		break;
 
-	case CAT_INV_VOCAB:
+	case CAT_HOTSPOT:
 		if (userInterface._selectedInvIndex >= 0) {
 			InventoryObject &invObject = _vm->_game->_objects.getItem(
 				userInterface._selectedInvIndex);
@@ -505,7 +506,7 @@ void ScreenObjects::elementHighlighted() {
 		var4 = _released && !_v7FECA ? 1 : 0;
 		break;
 
-	case CAT_INV_ANIM:
+	case CAT_TALK_ENTRY:
 		index = 1;
 		indexEnd = invList.size() - 1;
 		varA = 0;
@@ -514,7 +515,7 @@ void ScreenObjects::elementHighlighted() {
 		var4 = -1;
 		break;
 
-	case CAT_TALK_ENTRY:
+	case CAT_INV_SCROLLER:
 		uiCount = size() - _uiCount;
 		index = scene._hotspots.size();
 		indexEnd = index - 1;
@@ -544,7 +545,7 @@ void ScreenObjects::elementHighlighted() {
 	int newX = 0, newY = 0;
 	Common::Point currentPos = _vm->_events->currentPos();
 
-	for (int idx = 0; idx < index & newIndex < 0; ++idx) {
+	for (int idx = 0; idx < index && newIndex < 0; ++idx) {
 		int scrObjIndex = (_category == CAT_HOTSPOT) ? catIndex - idx + index - 1 :
 			catIndex + idx;
 		
@@ -557,7 +558,7 @@ void ScreenObjects::elementHighlighted() {
 			if (var4) {
 				if (currentPos.x > newX && currentPos.x < bounds.right) {
 					newIndex = scrObjIndex - catIndex;
-					if (_category == CAT_HOTSPOT && newIndex < scene._hotspots.size())
+					if (_category == CAT_HOTSPOT && newIndex < (int)scene._hotspots.size())
 						newIndex = scene._hotspots.size() - newIndex - 1;
 				}
 			} else if (!varA) {


Commit: 0b351f79d8ad874ce07fed54eb745a277da28edc
    https://github.com/scummvm/scummvm/commit/0b351f79d8ad874ce07fed54eb745a277da28edc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-22T21:55:36-04:00

Commit Message:
MADS: Further fixes for hotspot highlighting

Changed paths:
    engines/mads/font.cpp
    engines/mads/hotspots.cpp
    engines/mads/hotspots.h
    engines/mads/scene.cpp
    engines/mads/scene_data.cpp
    engines/mads/screen.cpp
    engines/mads/screen.h
    engines/mads/user_interface.cpp



diff --git a/engines/mads/font.cpp b/engines/mads/font.cpp
index ed7542d..e3497b3 100644
--- a/engines/mads/font.cpp
+++ b/engines/mads/font.cpp
@@ -136,13 +136,14 @@ void Font::setColorMode(int mode) {
 
 int Font::writeString(MSurface *surface, const Common::String &msg, const Common::Point &pt,
 		int spaceWidth, int width) {
+	int xEnd;
 	if (width > 0)
-		width = MIN((int)surface->w, pt.x + width);
+		xEnd = MIN((int)surface->w, pt.x + width);
 	else
-		width = surface->w - pt.x;
+		xEnd = surface->w - pt.x;
 
-	int x = pt.x + 1;
-	int y = pt.y + 1;
+	int x = pt.x;
+	int y = pt.y;
 	
 	int skipY = 0;
 	if (y < 0) {
@@ -174,7 +175,7 @@ int Font::writeString(MSurface *surface, const Common::String &msg, const Common
 		
 		if (charWidth > 0) {
 
-			if (xPos + charWidth >= width)
+			if (xPos + charWidth > xEnd)
 				return xPos;
 
 			uint8 *charData = &_charData[_charOffs[(byte)theChar]];
@@ -221,8 +222,12 @@ int Font::getWidth(const Common::String &msg, int spaceWidth) {
 	int width = 0;
 	const char *text = msg.c_str();
 
-	while (*text)
-		width += _charWidths[*text++ & 0x7F] + spaceWidth;
+	if (msg.size() > 0) {
+		while (*text)
+			width += _charWidths[*text++ & 0x7F] + spaceWidth;
+		width -= spaceWidth;
+	}
+
 	return width;
 }
 
diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
index 4356e78..e082a1e 100644
--- a/engines/mads/hotspots.cpp
+++ b/engines/mads/hotspots.cpp
@@ -146,8 +146,40 @@ void DynamicHotspots::refresh() {
 
 /*------------------------------------------------------------------------*/
 
-void Hotspots::activate(int hotspotId, bool active) {
-	warning("TODO: Hotspots::activate");
+Hotspot::Hotspot() {
+	_facing = 0;
+	_articleNumber = 0;
+	_cursor = CURSOR_NONE;
+	_vocabId = 0;
+	_verbId = 0;
+	_active = false;
+}
+
+Hotspot::Hotspot(Common::SeekableReadStream &f) {
+	_bounds.left = f.readSint16LE();
+	_bounds.top = f.readSint16LE();
+	_bounds.right = f.readSint16LE();
+	_bounds.bottom = f.readSint16LE();
+	_feetPos.x = f.readSint16LE();
+	_feetPos.y = f.readSint16LE();
+	_facing = f.readByte();
+	_articleNumber = f.readByte();
+	_active = f.readByte() != 0;
+	_cursor = (CursorType)f.readByte();
+	_vocabId = f.readUint16LE();
+	_verbId = f.readUint16LE();
+}
+
+/*------------------------------------------------------------------------*/
+
+void Hotspots::activate(int vocabId, bool active) {
+	for (uint idx = 0; idx < size(); ++idx) {
+		Hotspot &hotspot = (*this)[idx];
+		if (hotspot._vocabId == vocabId) {
+			hotspot._active = active;
+			_vm->_game->_screenObjects.setActive(CAT_HOTSPOT, idx, active);
+		}
+	}
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/hotspots.h b/engines/mads/hotspots.h
index ed18fbf..a53b86d 100644
--- a/engines/mads/hotspots.h
+++ b/engines/mads/hotspots.h
@@ -30,7 +30,6 @@ namespace MADS {
 
 class MADSEngine;
 
-
 class DynamicHotspot {
 public:
 	bool _active;
@@ -74,6 +73,7 @@ public:
 	Common::Point _feetPos;
 	int _facing;
 	int _articleNumber;
+	bool _active;
 	CursorType _cursor;
 	int _vocabId;
 	int _verbId;
@@ -83,8 +83,15 @@ public:
 };
 
 class Hotspots : public Common::Array<Hotspot> {
+private:
+	MADSEngine *_vm;
 public:
-	void activate(int hotspotId, bool active);
+	Hotspots(MADSEngine *vm) : _vm(vm) {}
+
+	/**
+	 * Sets the active state of a given hotspot
+	 */
+	void activate(int vocabId, bool active);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index e357f8b..da64def 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -29,8 +29,8 @@
 namespace MADS {
 
 Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
-		_dirtyAreas(_vm),  _dynamicHotspots(vm), _kernelMessages(vm), 
-		_sequences(vm), _sprites(vm), _spriteSlots(vm), 
+		_dirtyAreas(_vm),  _dynamicHotspots(vm), _hotspots(vm),
+		_kernelMessages(vm), _sequences(vm), _sprites(vm), _spriteSlots(vm), 
 		_textDisplay(vm), _userInterface(vm) {
 	_priorSceneId = 0;
 	_nextSceneId = 0;
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index a1f2734..712d065 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -58,31 +58,6 @@ KernelMessage::KernelMessage() {
 
 /*------------------------------------------------------------------------*/
 
-Hotspot::Hotspot() {
-	_facing = 0;
-	_articleNumber = 0;
-	_cursor = CURSOR_NONE;
-	_vocabId = 0;
-	_verbId = 0;
-}
-
-Hotspot::Hotspot(Common::SeekableReadStream &f) {
-	_bounds.left = f.readSint16LE();
-	_bounds.top = f.readSint16LE();
-	_bounds.right = f.readSint16LE();
-	_bounds.bottom = f.readSint16LE();
-	_feetPos.x = f.readSint16LE();
-	_feetPos.y = f.readSint16LE();
-	_facing = f.readByte();
-	_articleNumber = f.readByte();
-	f.skip(1);
-	_cursor = (CursorType)f.readByte();
-	_vocabId = f.readUint16LE();
-	_verbId = f.readUint16LE();
-}
-
-/*------------------------------------------------------------------------*/
-
 void ARTHeader::load(Common::SeekableReadStream *f) {
 	// Read in dimensions of image
 	_width = f->readUint16LE();
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index d191f49..22896e0 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -276,6 +276,7 @@ void ScreenObjects::add(const Common::Rect &bounds, Layer layer, ScrCategory cat
 	so._category = category;
 	so._descId = descId;
 	so._layer = layer;
+	so._active = true;
 
 	push_back(so);
 }
@@ -361,9 +362,10 @@ void ScreenObjects::check(bool scanFlag) {
 }
 
 int ScreenObjects::scanBackwards(const Common::Point &pt, int layer) {
-	for (int i = (int)size() - 1; i >= 0; --i) {
-		if ((*this)[i]._bounds.contains(pt) && ((*this)[i]._layer == layer))
-			return i + 1;
+	for (int i = (int)size(); i >= 1; --i) {
+		ScreenObject &sObj = (*this)[i];
+		if (sObj._active && sObj._bounds.contains(pt) && sObj._layer == layer)
+			return i;
 	}
 
 	// Entry not found
@@ -462,7 +464,7 @@ void ScreenObjects::elementHighlighted() {
 	int uiCount;
 
 	switch (userInterface._category) {
-	case CAT_INV_LIST:
+	case CAT_ACTION:
 		index = 10;
 		indexEnd = 9;
 		varA = 5;
@@ -475,7 +477,7 @@ void ScreenObjects::elementHighlighted() {
 		var4 = _released && !_v7FECA ? 1 : 0;
 		break;
 
-	case CAT_INV_VOCAB:
+	case CAT_INV_LIST:
 		userInterface.scrollInventory();
 
 		index = MIN((int)invList.size() - userInterface._inventoryTopIndex, 5);
@@ -486,7 +488,7 @@ void ScreenObjects::elementHighlighted() {
 		var4 = (!_released || (_vm->_events->_mouseButtons && action._v83338 == 1)) ? 0 : 1;
 		break;
 
-	case CAT_HOTSPOT:
+	case CAT_INV_VOCAB:
 		if (userInterface._selectedInvIndex >= 0) {
 			InventoryObject &invObject = _vm->_game->_objects.getItem(
 				userInterface._selectedInvIndex);
@@ -506,7 +508,7 @@ void ScreenObjects::elementHighlighted() {
 		var4 = _released && !_v7FECA ? 1 : 0;
 		break;
 
-	case CAT_TALK_ENTRY:
+	case CAT_INV_ANIM:
 		index = 1;
 		indexEnd = invList.size() - 1;
 		varA = 0;
@@ -515,17 +517,7 @@ void ScreenObjects::elementHighlighted() {
 		var4 = -1;
 		break;
 
-	case CAT_INV_SCROLLER:
-		uiCount = size() - _uiCount;
-		index = scene._hotspots.size();
-		indexEnd = index - 1;
-		varA = 0;
-		topIndex = 0;
-		var6 = &var8;
-		var4 = -1;
-		break;
-
-	default:
+	case CAT_TALK_ENTRY:
 		index = 0;
 		for (int idx = 0; idx < 5; ++idx) {
 			if (!userInterface._talkStrings[idx].empty())
@@ -538,6 +530,16 @@ void ScreenObjects::elementHighlighted() {
 		var6 = &userInterface._v1A;
 		var4 = -1;
 		break;
+
+	default:
+		uiCount = size() - _uiCount;
+		index = scene._hotspots.size();
+		indexEnd = index - 1;
+		varA = 0;
+		topIndex = 0;
+		var6 = &var8;
+		var4 = -1;
+		break;
 	}
 
 	int newIndex = -1;
@@ -548,15 +550,19 @@ void ScreenObjects::elementHighlighted() {
 	for (int idx = 0; idx < index && newIndex < 0; ++idx) {
 		int scrObjIndex = (_category == CAT_HOTSPOT) ? catIndex - idx + index - 1 :
 			catIndex + idx;
-		
+
 		ScreenObject &scrObject = (*this)[scrObjIndex];
-		Common::Rect bounds = scrObject._bounds;
+		if (!scrObject._active)
+			continue;
+
+		const Common::Rect &bounds = scrObject._bounds;
 		newY = MAX((int)bounds.bottom, newY);
 		newX = MAX((int)bounds.left, newX);
 
-		if (currentPos.y > newY && currentPos.y < bounds.bottom) {
+		if (currentPos.y >= bounds.top && currentPos.y < bounds.bottom) {
 			if (var4) {
-				if (currentPos.x > newX && currentPos.x < bounds.right) {
+				if (currentPos.x >= bounds.left && currentPos.x < bounds.right) {
+					// Cursor is inside hotspot bounds
 					newIndex = scrObjIndex - catIndex;
 					if (_category == CAT_HOTSPOT && newIndex < (int)scene._hotspots.size())
 						newIndex = scene._hotspots.size() - newIndex - 1;
@@ -602,6 +608,14 @@ void ScreenObjects::elementHighlighted() {
 		userInterface.drawInventory(_category, newIndex, var6);
 }
 
+void ScreenObjects::setActive(ScrCategory category, int descId, bool active) {
+	for (uint idx = 1; idx < size(); ++idx) {
+		ScreenObject &sObj = (*this)[idx];
+		if (sObj._category == category && sObj._descId == descId)
+			sObj._active = active;
+	}
+}
+
 /*------------------------------------------------------------------------*/
 
 ScreenSurface::ScreenSurface() {
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index 1d1e6d3..7fa5722 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -125,6 +125,7 @@ public:
 
 class ScreenObject {
 public:
+	bool _active;
 	Common::Rect _bounds;
 	ScrCategory _category;
 	int _descId;
@@ -179,6 +180,23 @@ public:
 	 * Handle element being highlighted on the screen
 	 */
 	void elementHighlighted();
+
+	/**
+	 * Retrieve a ScreenObject from the list
+	 * @remarks	This array is 1-based indexed by the game
+	 */
+	ScreenObject &operator[](int idx) {
+		assert(idx > 0);
+		return Common::Array<ScreenObject>::operator[](idx - 1);
+	}
+
+	/**
+	 * Sets an item identified by category and Desc Id as active or not
+	 * @param category		Screen category
+	 * @param descId		Description for item
+	 * @param active		Whether to set item as active or not
+	 */
+	void setActive(ScrCategory category, int descId, bool active);
 };
 
 class ScreenSurface : public MSurface {
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index cae5c11..4a35d24 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -447,7 +447,7 @@ void UserInterface::loadElements() {
 	}
 
 	if (!_vm->_game->_screenObjects._v832EC || _vm->_game->_screenObjects._v832EC == 2) {
-		_categoryIndexes[CAT_HOTSPOT - 1] = _vm->_game->_screenObjects.size();
+		_categoryIndexes[CAT_HOTSPOT - 1] = _vm->_game->_screenObjects.size() + 1;
 		for (int hotspotIdx = scene._hotspots.size() - 1; hotspotIdx >= 0; --hotspotIdx) {
 			Hotspot &hs = scene._hotspots[hotspotIdx];
 			_vm->_game->_screenObjects.add(hs._bounds, LAYER_GUI, CAT_HOTSPOT, hotspotIdx);


Commit: 8dd9dab76c2290a33289ffcc1e1a5582c9550bb4
    https://github.com/scummvm/scummvm/commit/8dd9dab76c2290a33289ffcc1e1a5582c9550bb4
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-23T11:34:12+01:00

Commit Message:
MADS: Implement Sequence::setScale and GameNebular::sub71312.

Changed paths:
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/game_nebular.h
    engines/mads/sequence.cpp
    engines/mads/sequence.h



diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index e5c344b..52e8913 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -194,6 +194,14 @@ void GameNebular::checkShowDialog() {
 	}
 }
 
+void GameNebular::sub71312(int idx) {
+	int yp = _player._playerPos.y + (_player._yScale * _player._currentScale) / 100;
+	_scene._sequences.setMsgPosition(idx, Common::Point(_player._playerPos.x, yp));
+	_scene._sequences.setDepth(idx, _player._currentDepth);
+	_scene._sequences.setScale(idx, _player._currentScale);
+	_scene._sequences.getTimeout(-1, idx);
+}
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index 685e5c7..0197766 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -65,6 +65,8 @@ protected:
 public:
 	Globals _globals;
 	StoryMode _storyMode;
+
+	void sub71312(int idx);
 };
 
 
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 453d90b..53ed02a 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -476,14 +476,18 @@ int SequenceList::startReverseCycle(int srcSpriteIndex, bool flipped, int numTic
 void SequenceList::getTimeout(int spriteIdx, int arg2) {
 	int timeout;
 	if (spriteIdx >= 0)
-		timeout = _vm->_game->_scene._sequences._entries[spriteIdx]._timeout;
+		timeout = _entries[spriteIdx]._timeout;
 	else
 		timeout = _vm->_game->_player._priorTimer + _vm->_game->_player._ticksAmount;
 
 	if (arg2 >= 0)
-		_vm->_game->_scene._sequences._entries[arg2]._timeout = timeout;
+		_entries[arg2]._timeout = timeout;
 	else
 		_vm->_game->_player._priorTimer = timeout - _vm->_game->_player._ticksAmount;
 
 }
+
+void SequenceList::setScale(int spriteIdx, int scale) {
+	_entries[spriteIdx]._scale = scale;
+}
 } // End of namespace 
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index 69059a9..9ff34ab 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -119,6 +119,7 @@ public:
 	int startReverseCycle(int srcSpriteIndex, bool flipped, int numTicks, int triggerCountdown, 
 		int timeoutTicks, int extraTicks);
 	void getTimeout(int spriteIdx, int arg2);
+	void setScale(int spriteIdx, int scale);
 };
 
 } // End of namespace MADS


Commit: 6fed5933a84421f413daeb0983281381acc7c128
    https://github.com/scummvm/scummvm/commit/6fed5933a84421f413daeb0983281381acc7c128
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-23T11:34:50+01:00

Commit Message:
MADS: Implement and get rid of two warnings

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 3d88080..458cd1d 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -777,7 +777,7 @@ void Scene202::actions() {
 						_game._player._stepEnabled = false;
 						_game._player._visible = false;
 						_globals._spriteIndexes[22] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[6], false, 3, 2, 0, 0);
-						warning("TODO: sub71312");
+						_game.sub71312(_globals._spriteIndexes[22]);
 						_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_FRAME_INDEX, 6, 1);
 						_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 2);
 					}
@@ -809,7 +809,7 @@ void Scene202::actions() {
 		} else if ((action->isAction(0x50, 0xC7, 0)) && (_globals[31] == 0)) {
 			if (_game._abortTimers == 0) {
 				_vm->_sound->command(29);
-				warning("TODO: word_8425E = _scene->_frameStartTime;");
+				_globals._v8425C = _scene->_frameStartTime;
 				_game._player._visible = false;
 				_game._player._stepEnabled = false;
 


Commit: 0d158075019940ccf25b4e5b9bd4676e9a06f87d
    https://github.com/scummvm/scummvm/commit/0d158075019940ccf25b4e5b9bd4676e9a06f87d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-23T09:19:28-04:00

Commit Message:
MADS: Fixes for animating inventory item

Changed paths:
    engines/mads/game.cpp
    engines/mads/scene.cpp
    engines/mads/screen.cpp
    engines/mads/user_interface.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 60481c6..4b907d1 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -63,6 +63,9 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 
 	// Load the inventory object list
 	_objects.load();
+	if (_objects._inventoryList.size() > 0)
+		// At least one item in default inventory, so select first item for display
+		_scene._userInterface._selectedInvIndex = 0;
 
 	// Load the quotes
 	loadQuotes();
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index da64def..cfdfa87 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -386,7 +386,7 @@ void Scene::doFrame() {
 				_kernelMessages.update();
 			}
 
-			_userInterface._uiSlots.draw(_vm->_game->_abortTimers2 == kTransitionFadeIn,
+			_userInterface._uiSlots.draw(_vm->_game->_abortTimers2 == 0,
 				_vm->_game->_abortTimers2 != 0);
 
 			// Write any text needed by the interface
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 22896e0..964e836 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -120,8 +120,8 @@ void DirtyArea::setUISlot(const UISlot *slot) {
 	int type = slot->_slotType;
 	if (type <= -20)
 		type += 20;
-	if (type >= 64)
-		type &= 0xBF;
+	if (type >= 0x40)
+		type &= ~0x40;
 
 	MSurface &intSurface = _vm->_game->_scene._userInterface;
 	switch (type) {
@@ -148,7 +148,7 @@ void DirtyArea::setUISlot(const UISlot *slot) {
 			_bounds.top = slot->_position.y;
 		} else {
 			_bounds.left = slot->_position.x + w / 2;
-			_bounds.top = slot->_position.y + h / 2;
+			_bounds.top = slot->_position.y - h + 1;
 		}
 
 		setArea(w, h, intSurface.w, intSurface.h);
@@ -182,7 +182,7 @@ void DirtyAreas::merge(int startIndex, int count) {
 				continue;
 
 			if ((*this)[outerCtr]._textActive && (*this)[innerCtr]._textActive)
-				mergeAreas(outerCtr, innerCtr);
+				mergeAreas(innerCtr, outerCtr);
 		}
 	}
 }
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 4a35d24..2ea656d 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -125,7 +125,7 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 
 		if (slot._slotType >= ST_NONE && !(slot._slotType & 0x40)) {
 			if (!dirtyArea._active) {
-				error("TODO: Original code here doesn't make sense!");
+				error("Should never reach this point, even in original");
 			}
 
 			if (dirtyArea._textActive) {
@@ -133,10 +133,12 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 				
 				if (slot._field2 == 200) {
 					MSprite *sprite = asset->getFrame(slot._frameNumber & 0x7F);
-					sprite->copyTo(&userInterface, slot._position);
+					sprite->copyTo(&userInterface, slot._position, 
+						sprite->getTransparencyIndex());
 				} else {
 					MSprite *sprite = asset->getFrame(slot._frameNumber - 1);
-					sprite->copyTo(&userInterface, slot._position);
+					sprite->copyTo(&userInterface, slot._position,
+						sprite->getTransparencyIndex());
 				}
 			}
 		}
@@ -175,7 +177,7 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 				slot._slotType -= 20;
 		} else {
 			if (updateFlag)
-				slot._slotType &= 0xBF;
+				slot._slotType &= ~0x40;
 			else
 				slot._slotType |= 0x40;
 		}
@@ -613,7 +615,7 @@ void UserInterface::inventoryAnim() {
 	if (++_invFrameNumber > asset->getCount())
 		_invFrameNumber = 1;
 
-	// Loop through the slots list for ?? entry
+	// Loop through the slots list for inventory animation entry
 	for (uint i = 0; i < _uiSlots.size(); ++i) {
 		if (_uiSlots[i]._field2 == 200)
 			_uiSlots[i]._slotType = -5;


Commit: ded2de015ab7daed5c9b34655f1066ebd0bdedc7
    https://github.com/scummvm/scummvm/commit/ded2de015ab7daed5c9b34655f1066ebd0bdedc7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-23T11:07:00-04:00

Commit Message:
MADS: Finished scene 103 action logic

Changed paths:
    engines/mads/dialogs.h
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/sequence.h



diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index b50d07f..56bc8ce 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -193,7 +193,7 @@ public:
 	virtual ~Dialogs() {}
 
 	virtual void showDialog() = 0;
-	virtual void showPicture(int objId, int msgId, int arg3) = 0;
+	virtual void showPicture(int objId, int msgId, int arg3 = 0) = 0;
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index d12c2d7..96c8cea 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -258,7 +258,182 @@ void Scene103::preActions() {
 
 void Scene103::actions() {
 	if (_action._savedLookFlag) {
-		Dialog::show(0x2852);
+		Dialog::show(10322);
+	} else if (_action.isAction(395, 110, 0)) {
+		switch (_vm->_game->_abortTimers) {
+		case 0:
+			_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(
+				_globals._spriteIndexes[6], false, 6, 1);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 1);
+			_game._player._stepEnabled = false;
+			_vm->_sound->command(20);
+			break;
+
+		case 1:
+			_vm->_sound->command(1);
+			_scene->_nextSceneId = 102;
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+	}
+	else if (_action.isAction(OBJ_REBREATHER, 371, 0) && _game._objects.isInRoom(OBJ_TIMER_MODULE)) {
+		switch (_vm->_game->_abortTimers) {
+		case 0:
+			_scene->changeDepthSurface(1);
+			_globals._spriteIndexes[28] = _scene->_sequences.startReverseCycle(
+				_globals._spriteIndexes[13], false, 3, 2);
+			_game.sub71312(_globals._spriteIndexes[28]);
+
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[28], SM_FRAME_INDEX, 7, 1);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[28], SM_0, 0, 2);
+			_vm->_game->_player._visible = false;
+			_vm->_game->_player._stepEnabled = false;
+			break;
+
+		case 1:
+			_scene->_sequences.remove(_globals._spriteIndexes[26]);
+			break;
+
+		case 2:
+			_vm->_sound->command(22);
+			_game._objects.addToInventory(OBJ_TIMER_MODULE);
+			_scene->changeDepthSurface(0);
+			_scene->drawElements(kTransitionNone, false);
+			_scene->_hotspots.activate(371, false);
+			_vm->_game->_player._visible = true;
+			_vm->_game->_player._stepEnabled = true;
+			_vm->_dialogs->showPicture(OBJ_REBREATHER, 804);
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(OBJ_REBREATHER, 289, 0) && _game._objects.isInRoom(OBJ_REBREATHER)) {
+		switch (_vm->_game->_abortTimers) {
+		case 0:
+			_scene->changeDepthSurface(1);
+			_globals._spriteIndexes[27] = _scene->_sequences.startReverseCycle(
+				_globals._spriteIndexes[12], false, 3, 2);
+			_game.sub71312(_globals._spriteIndexes[27]);
+
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[27], SM_FRAME_INDEX, 6, 1);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[27], SM_0, 0, 2);
+			_vm->_game->_player._visible = false;
+			_vm->_game->_player._stepEnabled = false;
+			break;
+
+		case 1:
+			_scene->_sequences.remove(_globals._spriteIndexes[25]);
+			break;
+
+		case 2:
+			_vm->_sound->command(22);
+			_game._objects.addToInventory(OBJ_REBREATHER);
+			_scene->_hotspots.activate(289, false);
+			_vm->_game->_player._visible = true;
+			_vm->_game->_player._stepEnabled = true;
+			_vm->_dialogs->showPicture(OBJ_REBREATHER, 804);
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(OBJ_STUFFED_FISH, 362, 0)) {
+		Dialog::show(10301);
+	} else if (_action.isAction(OBJ_REBREATHER, 362, 0)) {
+		if (!_vm->_game->_abortTimers)
+			_vm->_sound->command(31);
+
+		if (_vm->_game->_abortTimers2 < 2) {
+			_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(
+				_globals._spriteIndexes[9], false, 6,
+				_vm->_game->_abortTimers < 1 ? 1 : 0);
+			if (_vm->_game->_abortTimers) {
+				_scene->_sequences.setAnimRange(_globals._spriteIndexes[24], -1, 0);
+				Common::String msg = _game.getQuote(51);
+				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 18, 0, 60, msg);
+				_scene->_sequences.addTimer(120, _vm->_game->_abortTimers);
+			} else {
+				_scene->_sequences.addSubEntry(_globals._spriteIndexes[24],
+					SM_0, 0, 1);
+			}
+
+			_game._player._stepEnabled = _game._abortTimers == 2;
+			_globals[11] = -1;
+			if (_game._abortTimers == 2) {
+				Dialog::show(1030);
+				_scene->_hotspots.activate(362, false);
+			}
+		}
+	} else if (_action.isAction(OBJ_STUFFED_FISH, 250, 0)) {
+		Dialog::show(!_globals[11] ? 10323 : 10303);
+	}
+	else if (_action.isAction(OBJ_PLANT_STALK, 27, 0)) {
+		switch (_vm->_game->_abortTimers) {
+		case 0: {
+			_game._player._stepEnabled = false;
+			Common::String msg = _game.getQuote(71);
+			_scene->_kernelMessages.add(Common::Point(), 0x1110, 18, 1, 120, msg);
+			break;
+		}
+
+		case 1: {
+			Common::String msg = _game.getQuote(72);
+			_scene->_kernelMessages.add(Common::Point(310, 132), 0xFDFC, 16, 2, 120, msg);
+			_globals._v0 = 0;
+			break;
+		}
+			
+		case 2:
+			_scene->_kernelMessages.reset();
+			_scene->_sequences.addTimer(1, 3);
+			break;
+
+		case 3:
+			_game._player._stepEnabled = true;
+			Dialog::show(10306);
+			break;
+
+		default:
+			break;
+		}
+	} else if (!_action.isAction(OBJ_STUFFED_FISH, 27, 0)) {
+		Dialog::show(10304);
+	} else if (!_action.isAction(OBJ_STUFFED_FISH, 36, 0)) {
+		Dialog::show(10307);
+	} else if (!_action.isAction(OBJ_STUFFED_FISH, 55, 0)) {
+		Dialog::show(10308);
+	} else if (!_action.isAction(OBJ_REBREATHER, 315, 0)) {
+		Dialog::show(10309);
+	} else if (!_action.isAction(OBJ_REBREATHER, 85, 0)) {
+		Dialog::show(10310);
+	} else if (!_action.isAction(OBJ_STUFFED_FISH, 144, 0)) {
+		Dialog::show(10312);
+	} else if (!_action.isAction(OBJ_BIG_LEAVES, 144, 0)) {
+		Dialog::show(10313);
+	} else if (!_action.isAction(OBJ_BONE, 27, 0)) {
+		Dialog::show(10314);
+	} else if (!_action.isAction(OBJ_STUFFED_FISH, 310, 0)) {
+		Dialog::show(10315);
+	} else if (!_action.isAction(OBJ_STUFFED_FISH, 178, 0)) {
+		Dialog::show(10316);
+	} else if (!_action.isAction(OBJ_STUFFED_FISH, 283, 0)) {
+		Dialog::show(10317);
+	} else if (!_action.isAction(OBJ_STUFFED_FISH, 120, 0)) {
+		Dialog::show(10318);
+	} else if (_action.isAction(OBJ_STUFFED_FISH, 289, 0) &&
+			_game._objects.isInInventory(OBJ_REBREATHER)) {
+		Dialog::show(10319);
+	} else if (_action.isAction(OBJ_STUFFED_FISH, 371, 0) &&
+			_game._objects.isInInventory(OBJ_TIMER_MODULE)) {
+		Dialog::show(10320);
+	} else if (!_action.isAction(OBJ_STUFFED_FISH, 137, 0)) {
+		Dialog::show(10321);
+	} else if (_action.isAction(OBJ_STUFFED_FISH, 409, 0)) {
+		Dialog::show(_game._objects.isInInventory(OBJ_TIMER_MODULE) ? 10324 : 10325);
 	}
 
 	_action._inProgress = false;
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index 9ff34ab..f8051bd 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -116,8 +116,8 @@ public:
 		int triggerCountdown = 0, int timeoutTicks = 0, int extraTicks = 0);
 
 	int startCycle(int srcSpriteIdx, bool flipped, int cycleIndex);
-	int startReverseCycle(int srcSpriteIndex, bool flipped, int numTicks, int triggerCountdown, 
-		int timeoutTicks, int extraTicks);
+	int startReverseCycle(int srcSpriteIndex, bool flipped, int numTicks, 
+		int triggerCountdown = 0, int timeoutTicks = 0, int extraTicks = 0);
 	void getTimeout(int spriteIdx, int arg2);
 	void setScale(int spriteIdx, int scale);
 };


Commit: 1a54ae3de856ddc69004bc57a0aee043772490d7
    https://github.com/scummvm/scummvm/commit/1a54ae3de856ddc69004bc57a0aee043772490d7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-23T12:02:49-04:00

Commit Message:
MADS: Fix incorrect constant usage in scene 103 logic

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 96c8cea..9070bca 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -279,7 +279,7 @@ void Scene103::actions() {
 			break;
 		}
 	}
-	else if (_action.isAction(OBJ_REBREATHER, 371, 0) && _game._objects.isInRoom(OBJ_TIMER_MODULE)) {
+	else if (_action.isAction(VERB_TAKE, 371, 0) && _game._objects.isInRoom(OBJ_TIMER_MODULE)) {
 		switch (_vm->_game->_abortTimers) {
 		case 0:
 			_scene->changeDepthSurface(1);
@@ -311,7 +311,7 @@ void Scene103::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(OBJ_REBREATHER, 289, 0) && _game._objects.isInRoom(OBJ_REBREATHER)) {
+	} else if (_action.isAction(VERB_TAKE, 289, 0) && _game._objects.isInRoom(OBJ_REBREATHER)) {
 		switch (_vm->_game->_abortTimers) {
 		case 0:
 			_scene->changeDepthSurface(1);
@@ -341,9 +341,9 @@ void Scene103::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(OBJ_STUFFED_FISH, 362, 0)) {
+	} else if (_action.isAction(VERB_LOOK, 362, 0)) {
 		Dialog::show(10301);
-	} else if (_action.isAction(OBJ_REBREATHER, 362, 0)) {
+	} else if (_action.isAction(VERB_TAKE, 362, 0)) {
 		if (!_vm->_game->_abortTimers)
 			_vm->_sound->command(31);
 
@@ -368,10 +368,10 @@ void Scene103::actions() {
 				_scene->_hotspots.activate(362, false);
 			}
 		}
-	} else if (_action.isAction(OBJ_STUFFED_FISH, 250, 0)) {
+	} else if (_action.isAction(VERB_LOOK, 250, 0)) {
 		Dialog::show(!_globals[11] ? 10323 : 10303);
 	}
-	else if (_action.isAction(OBJ_PLANT_STALK, 27, 0)) {
+	else if (_action.isAction(VERB_TALKTO, 27, 0)) {
 		switch (_vm->_game->_abortTimers) {
 		case 0: {
 			_game._player._stepEnabled = false;
@@ -400,39 +400,39 @@ void Scene103::actions() {
 		default:
 			break;
 		}
-	} else if (!_action.isAction(OBJ_STUFFED_FISH, 27, 0)) {
+	} else if (!_action.isAction(VERB_LOOK, 27, 0)) {
 		Dialog::show(10304);
-	} else if (!_action.isAction(OBJ_STUFFED_FISH, 36, 0)) {
+	} else if (!_action.isAction(VERB_LOOK, 36, 0)) {
 		Dialog::show(10307);
-	} else if (!_action.isAction(OBJ_STUFFED_FISH, 55, 0)) {
+	} else if (!_action.isAction(VERB_LOOK, 55, 0)) {
 		Dialog::show(10308);
-	} else if (!_action.isAction(OBJ_REBREATHER, 315, 0)) {
+	} else if (!_action.isAction(VERB_TAKE, 315, 0)) {
 		Dialog::show(10309);
-	} else if (!_action.isAction(OBJ_REBREATHER, 85, 0)) {
+	} else if (!_action.isAction(VERB_TAKE, 85, 0)) {
 		Dialog::show(10310);
-	} else if (!_action.isAction(OBJ_STUFFED_FISH, 144, 0)) {
+	} else if (!_action.isAction(VERB_LOOK, 144, 0)) {
 		Dialog::show(10312);
-	} else if (!_action.isAction(OBJ_BIG_LEAVES, 144, 0)) {
+	} else if (!_action.isAction(VERB_OPEN, 144, 0)) {
 		Dialog::show(10313);
-	} else if (!_action.isAction(OBJ_BONE, 27, 0)) {
+	} else if (!_action.isAction(VERB_CLOSE, 27, 0)) {
 		Dialog::show(10314);
-	} else if (!_action.isAction(OBJ_STUFFED_FISH, 310, 0)) {
+	} else if (!_action.isAction(VERB_LOOK, 310, 0)) {
 		Dialog::show(10315);
-	} else if (!_action.isAction(OBJ_STUFFED_FISH, 178, 0)) {
+	} else if (!_action.isAction(VERB_LOOK, 178, 0)) {
 		Dialog::show(10316);
-	} else if (!_action.isAction(OBJ_STUFFED_FISH, 283, 0)) {
+	} else if (!_action.isAction(VERB_LOOK, 283, 0)) {
 		Dialog::show(10317);
-	} else if (!_action.isAction(OBJ_STUFFED_FISH, 120, 0)) {
+	} else if (!_action.isAction(VERB_LOOK, 120, 0)) {
 		Dialog::show(10318);
-	} else if (_action.isAction(OBJ_STUFFED_FISH, 289, 0) &&
+	} else if (_action.isAction(VERB_LOOK, 289, 0) &&
 			_game._objects.isInInventory(OBJ_REBREATHER)) {
 		Dialog::show(10319);
-	} else if (_action.isAction(OBJ_STUFFED_FISH, 371, 0) &&
+	} else if (_action.isAction(VERB_LOOK, 371, 0) &&
 			_game._objects.isInInventory(OBJ_TIMER_MODULE)) {
 		Dialog::show(10320);
-	} else if (!_action.isAction(OBJ_STUFFED_FISH, 137, 0)) {
+	} else if (!_action.isAction(VERB_LOOK, 137, 0)) {
 		Dialog::show(10321);
-	} else if (_action.isAction(OBJ_STUFFED_FISH, 409, 0)) {
+	} else if (_action.isAction(VERB_LOOK, 409, 0)) {
 		Dialog::show(_game._objects.isInInventory(OBJ_TIMER_MODULE) ? 10324 : 10325);
 	}
 


Commit: 9ef27c4ea0359d3dce74c49b5f2e9b37050097ae
    https://github.com/scummvm/scummvm/commit/9ef27c4ea0359d3dce74c49b5f2e9b37050097ae
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-23T13:52:32-04:00

Commit Message:
MADS: Moved sub71312 method to be SequenceList::setMsgLayout

Changed paths:
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/game_nebular.h
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/sequence.cpp
    engines/mads/sequence.h



diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 52e8913..e5c344b 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -194,14 +194,6 @@ void GameNebular::checkShowDialog() {
 	}
 }
 
-void GameNebular::sub71312(int idx) {
-	int yp = _player._playerPos.y + (_player._yScale * _player._currentScale) / 100;
-	_scene._sequences.setMsgPosition(idx, Common::Point(_player._playerPos.x, yp));
-	_scene._sequences.setDepth(idx, _player._currentDepth);
-	_scene._sequences.setScale(idx, _player._currentScale);
-	_scene._sequences.getTimeout(-1, idx);
-}
-
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index 0197766..685e5c7 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -65,8 +65,6 @@ protected:
 public:
 	Globals _globals;
 	StoryMode _storyMode;
-
-	void sub71312(int idx);
 };
 
 
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 9070bca..d6287de 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -285,7 +285,7 @@ void Scene103::actions() {
 			_scene->changeDepthSurface(1);
 			_globals._spriteIndexes[28] = _scene->_sequences.startReverseCycle(
 				_globals._spriteIndexes[13], false, 3, 2);
-			_game.sub71312(_globals._spriteIndexes[28]);
+			_scene->_sequences.setMsgLayout(_globals._spriteIndexes[28]);
 
 			_scene->_sequences.addSubEntry(_globals._spriteIndexes[28], SM_FRAME_INDEX, 7, 1);
 			_scene->_sequences.addSubEntry(_globals._spriteIndexes[28], SM_0, 0, 2);
@@ -317,7 +317,7 @@ void Scene103::actions() {
 			_scene->changeDepthSurface(1);
 			_globals._spriteIndexes[27] = _scene->_sequences.startReverseCycle(
 				_globals._spriteIndexes[12], false, 3, 2);
-			_game.sub71312(_globals._spriteIndexes[27]);
+			_scene->_sequences.setMsgLayout(_globals._spriteIndexes[27]);
 
 			_scene->_sequences.addSubEntry(_globals._spriteIndexes[27], SM_FRAME_INDEX, 6, 1);
 			_scene->_sequences.addSubEntry(_globals._spriteIndexes[27], SM_0, 0, 2);
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 458cd1d..0e297e1 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -541,8 +541,8 @@ void Scene202::step() {
 		_scene->_hotspots.activate(199, false);
 		int idx = _scene->_dynamicHotspots.add(457, 13, _globals._spriteIndexes[20], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, 246, 124, 8);
-		_scene->_sequences.getTimeout(_globals._spriteIndexes[26], _globals._spriteIndexes[20]);
-		_scene->_sequences.getTimeout(-1, _globals._spriteIndexes[26]);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[26], _globals._spriteIndexes[20]);
+		_scene->_sequences.updateTimeout(-1, _globals._spriteIndexes[26]);
 		_game._player._stepEnabled = true;
 		_game._player._visible = true;
 		_globals._v4 = false;
@@ -729,7 +729,7 @@ void Scene202::preActions() {
 			_scene->_sequences.setDepth(_globals._spriteIndexes[23], 1);
 			_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 1);
 		} else if (_game._abortTimers == 1) {
-			_scene->_sequences.getTimeout(-1, _globals._spriteIndexes[23]);
+			_scene->_sequences.updateTimeout(-1, _globals._spriteIndexes[23]);
 			warning("CHECKME: _scene->_dynamicHotspots.remove(_globals._frameTime);");
 			_scene->_dynamicHotspots.remove(_globals._frameTime);
 			_game._player._visible = true;
@@ -777,7 +777,7 @@ void Scene202::actions() {
 						_game._player._stepEnabled = false;
 						_game._player._visible = false;
 						_globals._spriteIndexes[22] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[6], false, 3, 2, 0, 0);
-						_game.sub71312(_globals._spriteIndexes[22]);
+						_scene->_sequences.setMsgLayout(_globals._spriteIndexes[22]);
 						_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_FRAME_INDEX, 6, 1);
 						_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 2);
 					}
@@ -823,7 +823,7 @@ void Scene202::actions() {
 				_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
 				_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
 				_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
-				_scene->_sequences.getTimeout(_globals._spriteIndexes[23], _globals._spriteIndexes[24]);
+				_scene->_sequences.updateTimeout(_globals._spriteIndexes[23], _globals._spriteIndexes[24]);
 				_globals._v4 = -1;
 				_game._player._stepEnabled = true;
 				int msgIndex = _scene->_kernelMessages.add(Common::Point(248, 15), 0x1110, 32, 0, 60, _game.getQuote(97));
@@ -841,7 +841,7 @@ void Scene202::actions() {
 					_scene->_sequences.setAnimRange(_globals._spriteIndexes[25], 1, 6);
 					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
 					_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
-					_scene->_sequences.getTimeout(-1, _globals._spriteIndexes[25]);
+					_scene->_sequences.updateTimeout(-1, _globals._spriteIndexes[25]);
 					_scene->_sequences.addSubEntry(_globals._spriteIndexes[25], SM_0, 0, 1);
 				} else if (_game._abortTimers == 1) {
 					_globals._spriteIndexes[25] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
@@ -864,7 +864,7 @@ void Scene202::actions() {
 					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
 					_scene->_sequences.addSubEntry(_globals._spriteIndexes[25], SM_0, 0, 3);
 				} else if (_game._abortTimers == 3) {
-					_scene->_sequences.getTimeout(-1, _globals._spriteIndexes[25]);
+					_scene->_sequences.updateTimeout(-1, _globals._spriteIndexes[25]);
 					_game._player._stepEnabled = true;
 					_game._player._visible = true;
 				} else {
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 53ed02a..bb2454d 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -473,21 +473,33 @@ int SequenceList::startReverseCycle(int srcSpriteIndex, bool flipped, int numTic
 		numTicks, 0, 0, true, 100, depth - 1, 1, ANIMTYPE_REVERSIBLE, 0, 0);
 }
 
-void SequenceList::getTimeout(int spriteIdx, int arg2) {
+void SequenceList::updateTimeout(int spriteIdx, int seqIndex) {
+	Player &player = _vm->_game->_player;
 	int timeout;
+
 	if (spriteIdx >= 0)
 		timeout = _entries[spriteIdx]._timeout;
 	else
-		timeout = _vm->_game->_player._priorTimer + _vm->_game->_player._ticksAmount;
+		timeout = player._priorTimer + player._ticksAmount;
 
-	if (arg2 >= 0)
-		_entries[arg2]._timeout = timeout;
+	if (seqIndex >= 0)
+		_entries[seqIndex]._timeout = timeout;
 	else
-		_vm->_game->_player._priorTimer = timeout - _vm->_game->_player._ticksAmount;
+		player._priorTimer = timeout - player._ticksAmount;
 
 }
 
 void SequenceList::setScale(int spriteIdx, int scale) {
 	_entries[spriteIdx]._scale = scale;
 }
+
+void SequenceList::setMsgLayout(int seqIndex) {
+	Player &player = _vm->_game->_player;
+	int yp = player._playerPos.y + (player._yScale * player._currentScale) / 100;
+	setMsgPosition(seqIndex, Common::Point(player._playerPos.x, yp));
+	setDepth(seqIndex, player._currentDepth);
+	setScale(seqIndex, player._currentScale);
+	updateTimeout(-1, seqIndex);
+}
+
 } // End of namespace 
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index f8051bd..f24a2bd 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -118,8 +118,9 @@ public:
 	int startCycle(int srcSpriteIdx, bool flipped, int cycleIndex);
 	int startReverseCycle(int srcSpriteIndex, bool flipped, int numTicks, 
 		int triggerCountdown = 0, int timeoutTicks = 0, int extraTicks = 0);
-	void getTimeout(int spriteIdx, int arg2);
+	void updateTimeout(int spriteIdx, int seqIndex);
 	void setScale(int spriteIdx, int scale);
+	void setMsgLayout(int seqIndex);
 };
 
 } // End of namespace MADS


Commit: a22318959989caf91916ba792f80103afe71092a
    https://github.com/scummvm/scummvm/commit/a22318959989caf91916ba792f80103afe71092a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-23T14:26:50-04:00

Commit Message:
MADS: Added extra debugger commands

Changed paths:
    engines/mads/debugger.cpp
    engines/mads/debugger.h
    engines/mads/hotspots.h



diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp
index 34b12c1..3bc4ed2 100644
--- a/engines/mads/debugger.cpp
+++ b/engines/mads/debugger.cpp
@@ -20,6 +20,7 @@
  *
  */
 
+#include "common/file.h"
 #include "mads/mads.h"
 #include "mads/debugger.h"
 
@@ -29,8 +30,15 @@ Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) {
 	_showMousePos = false;
 
 	DCmd_Register("continue",		WRAP_METHOD(Debugger, Cmd_Exit));
+	DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_Mouse));
+	DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_LoadScene));
+	DCmd_Register("show_hotspots", WRAP_METHOD(Debugger, Cmd_ShowHotSpots));
+	DCmd_Register("list_hotspots", WRAP_METHOD(Debugger, Cmd_ListHotSpots));
+	DCmd_Register("play_sound", WRAP_METHOD(Debugger, Cmd_PlaySound));
+	DCmd_Register("show_codes", WRAP_METHOD(Debugger, Cmd_ShowCodes));
+	DCmd_Register("dump_file", WRAP_METHOD(Debugger, Cmd_DumpFile));
 }
-/*
+
 static int strToInt(const char *s) {
 	if (!*s)
 		// No string at all
@@ -46,7 +54,6 @@ static int strToInt(const char *s) {
 		error("strToInt failed on string \"%s\"", s);
 	return (int)tmp;
 }
-*/
 
 bool Debugger::Cmd_Mouse(int argc, const char **argv) {
 	if (argc < 2) {
@@ -58,4 +65,97 @@ bool Debugger::Cmd_Mouse(int argc, const char **argv) {
 	return true;
 }
 
+bool Debugger::Cmd_LoadScene(int argc, const char **argv) {
+	if (argc != 2) {
+		DebugPrintf("Usage: %s <scene number>\n", argv[0]);
+		return true;
+	} else {
+		_vm->_game->_scene._nextSceneId = strToInt(argv[1]);
+		return false;
+	}
+}
+
+bool Debugger::Cmd_ShowHotSpots(int argc, const char **argv) {
+	Scene &scene = _vm->_game->_scene;
+
+	// hotspots
+	byte hotspotCol = _vm->getRandomNumber(255);
+	for (uint i = 0; i < scene._hotspots.size(); i++) {
+		scene._backgroundSurface.frameRect(scene._hotspots[i]._bounds, hotspotCol);
+	}
+
+	// Dynamic hotspots (red)
+	hotspotCol = _vm->getRandomNumber(255);
+	for (uint i = 0; i < scene._dynamicHotspots.size(); i++) {
+		scene._backgroundSurface.frameRect(scene._dynamicHotspots[i]._bounds, hotspotCol);
+	}
+
+	scene._spriteSlots.fullRefresh();
+	return false;
+}
+
+bool Debugger::Cmd_ListHotSpots(int argc, const char **argv) {
+	Hotspots &hotspots = _vm->_game->_scene._hotspots;
+
+	DebugPrintf("%d hotspots present\n", hotspots.size());
+
+	for (uint index = 0; index < hotspots.size(); ++index) {
+		DebugPrintf("(%d): %p x1 = %d; y1 = %d; x2 = %d; y2 = %d\n",
+			index, (void *)&hotspots[index],
+			hotspots[index]._bounds.left, hotspots[index]._bounds.top,
+			hotspots[index]._bounds.right, hotspots[index]._bounds.bottom);
+	}
+
+	return true;
+}
+
+bool Debugger::Cmd_PlaySound(int argc, const char **argv) {
+	if (argc < 2) {
+		DebugPrintf("Usage: %s <sound file>\n", argv[0]);
+	} else {
+		int commandId = strToInt(argv[1]);
+		int param = (argc >= 3) ? strToInt(argv[2]) : 0;
+
+		_vm->_sound->command(commandId, param);
+	}
+
+	return false;
+}
+
+bool Debugger::Cmd_ShowCodes(int argc, const char **argv) {
+	Scene &scene = _vm->_game->_scene;
+
+	scene._depthSurface.copyTo(&scene._backgroundSurface);
+	scene._spriteSlots.fullRefresh();
+
+	return false;
+}
+
+bool Debugger::Cmd_DumpFile(int argc, const char **argv) {
+	if (argc != 2) {
+		DebugPrintf("Usage: %s <resource>\n", argv[0]);
+	} else {
+		Common::DumpFile outFile;
+		Common::File inFile;
+
+		if (!inFile.open(argv[1])) {
+			DebugPrintf("Specified resource does not exist\n");
+		} else {
+			outFile.open(argv[1]);
+			byte *data = new byte[inFile.size()];
+			
+			inFile.read(data, inFile.size());
+			outFile.write(data, inFile.size());
+
+			delete[] data;
+			inFile.close();
+			outFile.close();
+
+			DebugPrintf("File written successfully.\n");
+		}
+	}
+	
+	return true;
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/debugger.h b/engines/mads/debugger.h
index 983b993..de450b1 100644
--- a/engines/mads/debugger.h
+++ b/engines/mads/debugger.h
@@ -35,6 +35,12 @@ private:
 	MADSEngine *_vm;
 protected:
 	bool Cmd_Mouse(int argc, const char **argv);
+	bool Cmd_LoadScene(int argc, const char **argv);
+	bool Cmd_ShowHotSpots(int argc, const char **argv);
+	bool Cmd_ListHotSpots(int argc, const char **argv);
+	bool Cmd_PlaySound(int argc, const char **argv);
+	bool Cmd_ShowCodes(int argc, const char **argv);
+	bool Cmd_DumpFile(int argc, const char **argv);
 public:
 	bool _showMousePos;
 public:
diff --git a/engines/mads/hotspots.h b/engines/mads/hotspots.h
index a53b86d..ec9f12d 100644
--- a/engines/mads/hotspots.h
+++ b/engines/mads/hotspots.h
@@ -57,6 +57,7 @@ public:
 public:
 	DynamicHotspots(MADSEngine *vm);
 
+	int size() const { return _entries.size(); }
 	DynamicHotspot &operator[](uint idx) { return _entries[idx]; }
 	int add(int descId, int vocabId, int seqIndex, const Common::Rect &bounds);
 	int setPosition(int index, int xp, int yp, int facing);


Commit: a3952509a91b15ccc959e0dbddd12e1678e3814e
    https://github.com/scummvm/scummvm/commit/a3952509a91b15ccc959e0dbddd12e1678e3814e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-23T17:31:33-04:00

Commit Message:
MADS: In progress work on action starting

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 52be8ea..d52adbf 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -69,6 +69,15 @@ void MADSAction::appendVocab(int vocabId, bool capitalise) {
 	_statusText += " ";
 }
 
+void MADSAction::checkCustomDest(int v) {
+	Scene &scene = _vm->_game->_scene;
+
+	if (_v86F4A && (v == -3 || _savedFields._selectedRow < 0)) {
+		_startWalkFlag = true;
+		scene._destPos = scene._customDest;
+	}
+}
+
 void MADSAction::set() {
 	Scene &scene = _vm->_game->_scene;
 	UserInterface &userInterface = scene._userInterface;
@@ -249,72 +258,76 @@ void MADSAction::refresh() {
 }
 
 void MADSAction::startAction() {
-	/*
-	_madsVm->_player.moveComplete();
+	Game &game = *_vm->_game;
+	Scene &scene = _vm->_game->_scene;
+	DynamicHotspots &dynHotspots = scene._dynamicHotspots;
+	Hotspots &hotspots = scene._hotspots;
+
+	game._player.moveComplete();
 
 	_inProgress = true;
 	_v8453A = ABORTMODE_0;
-	_savedFields.selectedRow = _selectedRow;
-	_savedFields.articleNumber = _articleNumber;
-	_savedFields.actionMode = _actionMode;
-	_savedFields.actionMode2 = _actionMode2;
-	_savedFields.lookFlag = _lookFlag;
-	int savedHotspotId = _hotspotId;
-	int savedV86F3A = _v86F3A;
-	int savedV86F42 = _v86F42;
+	_savedFields._selectedRow = _selectedRow;
+	_savedFields._hotspotId = _hotspotId;
+	_savedFields._v86F3A = _v86F3A;
+	_savedFields._articleNumber = _articleNumber;
+	_savedFields._actionMode = _actionMode;
+	_savedFields._actionMode2 = _actionMode2;
+	_savedFields._v86F42 = _v86F42;
+	_savedFields._lookFlag = _lookFlag;
+	_activeAction = _action;
 
 	// Copy the action to be active
 	_activeAction = _action;
-	strcpy(_dialogTitle, _statusText);
+	_dialogTitle = _statusText;
 
-	if ((_savedFields.actionMode2 == ACTMODE2_4) && (savedV86F42 == 0))
-		_v8453A = ABORTMODE_1;
+	if ((_actionMode2 == ACTIONMODE2_4) && (_v86F42 == 0))
+		_v8453A = -1;
 
 	_startWalkFlag = false;
 	int hotspotId = -1;
-	HotSpotList &dynHotspots = *_madsVm->scene()->getSceneResources().dynamicHotspots;
-	HotSpotList &hotspots = *_madsVm->scene()->getSceneResources().hotspots;
 
-	if (!_savedFields.lookFlag && (_madsVm->scene()->_screenObjects._v832EC != 1)) {
-		if (_savedFields.actionMode2 == ACTMODE2_4)
-			hotspotId = savedHotspotId;
-		else if (savedV86F42 == 4)
-			hotspotId = savedV86F3A;
+	if (!_savedFields._lookFlag && (_vm->_game->_screenObjects._v832EC != 1)) {
+		if (_savedFields._actionMode2 == ACTIONMODE2_4)
+			hotspotId = _savedFields._hotspotId;
+		else if (_v86F42 == 4)
+			hotspotId = _savedFields._v86F3A;
 
 		if (hotspotId >= hotspots.size()) {
-			HotSpot &hs = dynHotspots[hotspotId - hotspots.size()];
-			if ((hs.getFeetX() == -1) || (hs.getFeetX() == -3)) {
-				if (_v86F4A && ((hs.getFeetX() == -3) || (_savedFields.selectedRow < 0))) {
+			DynamicHotspot &hs = dynHotspots[hotspotId - hotspots.size()];
+			if ((hs._feetPos.x == -1) || (hs._feetPos.x == -3)) {
+				if (_v86F4A && ((hs._feetPos.x == -3) || (_savedFields._selectedRow < 0))) {
 					_startWalkFlag = true;
-					_madsVm->scene()->_destPos = _madsVm->scene()->_customDest;
+
+
+					scene._destPos = scene._customDest;
 				}
-			} else if ((hs.getFeetX() >= 0) && ((_savedFields.actionMode == ACTMODE_NONE) || (hs.getCursor() < 2))) {
+			} else if ((hs._feetPos.x >= 0) && ((_savedFields._actionMode == ACTIONMODE_NONE) || 
+					(hs._cursor < 2))) {
 				_startWalkFlag = true;
-				_madsVm->scene()->_destPos.x = hs.getFeetX();
-				_madsVm->scene()->_destPos.y = hs.getFeetY();
+				scene._destPos.x = hs._feetPos.x;
+				scene._destPos.y = hs._feetPos.y;
 			}
-			_madsVm->scene()->_destFacing = hs.getFacing();
+			scene._destFacing = hs._facing;
 			hotspotId = -1;
 		}
 	}
 
 	if (hotspotId >= 0) {
-		HotSpot &hs = hotspots[hotspotId];
-		if ((hs.getFeetX() == -1) || (hs.getFeetX() == -3)) {
-			if (_v86F4A && ((hs.getFeetX() == -3) || (_savedFields.selectedRow < 0))) {
+		Hotspot &hs = hotspots[hotspotId];
+		if ((hs._feetPos.x == -1) || (hs._feetPos.x == -3)) {
+			if (_v86F4A && ((hs._feetPos.x == -3) || (_savedFields._selectedRow < 0))) {
 				_startWalkFlag = true;
-				_madsVm->scene()->_destPos = _madsVm->scene()->_customDest;
+				scene._destPos = scene._customDest;
 			}
-		} else if ((hs.getFeetX() >= 0) && ((_savedFields.actionMode == ACTMODE_NONE) || (hs.getCursor() < 2))) {
+		} else if ((hs._feetPos.x >= 0) && ((_savedFields._actionMode == ACTIONMODE_NONE) || (hs._cursor < 2))) {
 			_startWalkFlag = true;
-			_madsVm->scene()->_destPos.x = hs.getFeetX();
-			_madsVm->scene()->_destPos.y = hs.getFeetY();
+			scene._destPos = hs._feetPos;
 		}
-		_madsVm->scene()->_destFacing = hs.getFacing();
+		scene._destFacing = hs._facing;
 	}
 
 	_walkFlag = _startWalkFlag;
-	*/
 }
 
 void MADSAction::checkAction() {
diff --git a/engines/mads/action.h b/engines/mads/action.h
index 04d9c36..b32720f 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -56,12 +56,15 @@ struct ActionDetails {
 	int _indirectObjectId;
 };
 
-struct MADSActionSavedFields {
-	int articleNumber;
-	int actionMode;
-	int actionMode2;
-	bool lookFlag;
-	int selectedRow;
+struct ActionSavedFields {
+	int _actionMode;
+	int _selectedRow;
+	int _hotspotId;
+	int _v86F3A;
+	int _actionMode2;
+	int _v86F42;
+	int _articleNumber;
+	int _lookFlag;
 };
 
 class MADSAction {
@@ -69,8 +72,11 @@ private:
 	MADSEngine *_vm;
 	Common::String _statusText;
 	Common::String _dialogTitle;
+	ActionSavedFields _savedFields;
 
 	void appendVocab(int vocabId, bool capitalise = false);
+
+	void checkCustomDest(int v);
 public:
 	ActionDetails _action, _activeAction;
 	int _currentAction;
@@ -85,7 +91,6 @@ public:
 	bool _startWalkFlag;
 	int _statusTextIndex;
 	int _hotspotId;
-	MADSActionSavedFields _savedFields;
 	bool _walkFlag;
 	bool _savedSelectedRow;
 	bool _savedLookFlag;
@@ -98,7 +103,7 @@ public:
 	int16 _v86F4C;
 	int _v83338;
 	bool _inProgress;
-	AbortTimerMode _v8453A;
+	int _v8453A;
 
 public:
 	MADSAction(MADSEngine *vm);


Commit: 7f4dbf7d48b6db8d82d33b569c22f104fc153dd3
    https://github.com/scummvm/scummvm/commit/7f4dbf7d48b6db8d82d33b569c22f104fc153dd3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-23T18:48:00-04:00

Commit Message:
MADS: Implemented more action handling methods

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h
    engines/mads/game.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/game_nebular.h
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/scene.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index d52adbf..0c20fec 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -36,8 +36,15 @@ MADSAction::MADSAction(MADSEngine *vm) : _vm(vm) {
 	_statusTextIndex = -1;
 	_selectedAction = 0;
 	_inProgress = false;
-	_savedSelectedRow = false;
-	_savedLookFlag = false;
+
+	_savedFields._actionMode = ABORTMODE_0;
+	_savedFields._actionMode2 = ABORTMODE_0;
+	_savedFields._selectedRow = -1;
+	_savedFields._hotspotId = 0;
+	_savedFields._v86F3A = 0;
+	_savedFields._v86F42 = 0;
+	_savedFields._articleNumber = 0;
+	_savedFields._lookFlag = false;
 }
 
 void MADSAction::clear() {
@@ -293,37 +300,34 @@ void MADSAction::startAction() {
 		else if (_v86F42 == 4)
 			hotspotId = _savedFields._v86F3A;
 
-		if (hotspotId >= hotspots.size()) {
+		if (hotspotId >= (int)hotspots.size()) {
 			DynamicHotspot &hs = dynHotspots[hotspotId - hotspots.size()];
 			if ((hs._feetPos.x == -1) || (hs._feetPos.x == -3)) {
-				if (_v86F4A && ((hs._feetPos.x == -3) || (_savedFields._selectedRow < 0))) {
-					_startWalkFlag = true;
-
-
-					scene._destPos = scene._customDest;
-				}
-			} else if ((hs._feetPos.x >= 0) && ((_savedFields._actionMode == ACTIONMODE_NONE) || 
-					(hs._cursor < 2))) {
+				checkCustomDest(hs._feetPos.x);
+			} else if (hs._feetPos.x == 0) {
+				scene._destFacing = hs._facing;
+			} else if (_savedFields._actionMode == ACTIONMODE_NONE || hs._cursor >= CURSOR_WAIT) {
 				_startWalkFlag = true;
-				scene._destPos.x = hs._feetPos.x;
-				scene._destPos.y = hs._feetPos.y;
+				scene._destPos = hs._feetPos;
 			}
+
 			scene._destFacing = hs._facing;
 			hotspotId = -1;
 		}
 	}
 
-	if (hotspotId >= 0) {
+	if (hotspotId >= 0 && hotspotId < (int)hotspots.size()) {
 		Hotspot &hs = hotspots[hotspotId];
-		if ((hs._feetPos.x == -1) || (hs._feetPos.x == -3)) {
-			if (_v86F4A && ((hs._feetPos.x == -3) || (_savedFields._selectedRow < 0))) {
+
+		if (hs._feetPos.x == -1 || hs._feetPos.x != -3) {
+			checkCustomDest(hs._feetPos.x);
+		} else if (hs._feetPos.x >= 0) {
+			if (_savedFields._actionMode == ACTIONMODE_NONE || hs._cursor < CURSOR_WAIT) {
 				_startWalkFlag = true;
-				scene._destPos = scene._customDest;
+				scene._destPos = hs._feetPos;
 			}
-		} else if ((hs._feetPos.x >= 0) && ((_savedFields._actionMode == ACTIONMODE_NONE) || (hs._cursor < 2))) {
-			_startWalkFlag = true;
-			scene._destPos = hs._feetPos;
 		}
+
 		scene._destFacing = hs._facing;
 	}
 
@@ -331,21 +335,18 @@ void MADSAction::startAction() {
 }
 
 void MADSAction::checkAction() {
-	/*
-	if (isAction(kVerbLookAt) || isAction(kVerbThrow))
+	if (isAction(VERB_LOOK) || isAction(VERB_THROW))
 		_startWalkFlag = 0;
-	*/
 }
 
 bool MADSAction::isAction(int verbId, int objectNameId, int indirectObjectId) {
-	/*
-	if (_activeAction.verbId != verbId)
+	if (_activeAction._verbId != verbId)
 		return false;
-	if ((objectNameId != 0) && (_activeAction.objectNameId != objectNameId))
+	if ((objectNameId != 0) && (_activeAction._objectNameId != objectNameId))
 		return false;
-	if ((indirectObjectId != 0) && (_activeAction.indirectObjectId != indirectObjectId))
+	if ((indirectObjectId != 0) && (_activeAction._indirectObjectId != indirectObjectId))
 		return false;
-	*/
+
 	return true;
 }
 
diff --git a/engines/mads/action.h b/engines/mads/action.h
index b32720f..802dfb0 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -72,7 +72,6 @@ private:
 	MADSEngine *_vm;
 	Common::String _statusText;
 	Common::String _dialogTitle;
-	ActionSavedFields _savedFields;
 
 	void appendVocab(int vocabId, bool capitalise = false);
 
@@ -92,8 +91,7 @@ public:
 	int _statusTextIndex;
 	int _hotspotId;
 	bool _walkFlag;
-	bool _savedSelectedRow;
-	bool _savedLookFlag;
+	ActionSavedFields _savedFields;
 
 	// Unknown fields
 	int16 _v86F3A;
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 32491ce..bf81c23 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -143,6 +143,11 @@ public:
 	uint32 getQuotesSize() { return _quotes.size(); }
 	const Common::String &getQuote(uint32 index) { return _quotes[index - 1]; }
 
+	/**
+	* Standard object handling across the game
+	*/
+	virtual void doObjectAction() = 0;
+
 	// DEPRECATED: ScummVM re-implementation keeps all the quotes loaded, so the methods below are stubs
 	void clearQuotes() {}
 	void loadQuoteRange(int startNum, int endNum) {}
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index e5c344b..76ea1f5 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -194,6 +194,10 @@ void GameNebular::checkShowDialog() {
 	}
 }
 
+void GameNebular::doObjectAction() {
+	warning("TODO: GameNebular::doObjectAction");
+}
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index 685e5c7..98ecb0a 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -61,10 +61,11 @@ protected:
 	virtual void setSectionHandler();
 
 	virtual void checkShowDialog();
-
 public:
 	Globals _globals;
 	StoryMode _storyMode;
+
+	virtual void doObjectAction();
 };
 
 
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index d6287de..652ee99 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -257,7 +257,7 @@ void Scene103::preActions() {
 }
 
 void Scene103::actions() {
-	if (_action._savedLookFlag) {
+	if (_action._savedFields._lookFlag) {
 		Dialog::show(10322);
 	} else if (_action.isAction(395, 110, 0)) {
 		switch (_vm->_game->_abortTimers) {
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index cfdfa87..565ef47 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -302,7 +302,7 @@ void Scene::doFrame() {
 		_action.startAction();
 		if (_action._activeAction._verbId == Nebular::NOUN_LOOK_AT) {
 			_action._activeAction._verbId = VERB_LOOK;
-			_action._savedSelectedRow = false;
+			_action._savedFields._selectedRow = false;
 		}
 
 		flag = true;
@@ -470,11 +470,59 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
 }
 
 void Scene::doPreactions() {
-	warning("TODO: Scene::doPreactions");
+	if (_vm->_game->_screenObjects._v832EC == 0 || _vm->_game->_screenObjects._v832EC == 2) {
+		_vm->_game->_abortTimersMode2 = ABORTMODE_2;
+		_action.checkAction();
+		_sceneLogic->preActions();
+
+		if (_vm->_game->_abortTimersMode == ABORTMODE_2)
+			_vm->_game->_abortTimers = 0;
+	}
 }
 
 void Scene::doAction() {
-	warning("TODO: Scene::doAction");
+	int flag = 0;
+
+	_vm->_game->_abortTimersMode2 = ABORTMODE_0;
+	if ((_action._inProgress || _vm->_game->_abortTimers) && !_action._v8453A) {
+		_sceneLogic->actions();
+		_action._inProgress = true;
+		flag = -1;
+	}
+
+	if (_vm->_game->_screenObjects._v832EC == 1) {
+		_action._inProgress = false;
+	} else {
+		if ((_action._inProgress || _vm->_game->_abortTimers) ||
+				(!flag && _action._v8453A == flag)) {
+			_vm->_game->_sectionHandler->sectionPtr2();
+			_action._inProgress = true;
+			flag = -1;
+		}
+
+		if ((_action._inProgress || _vm->_game->_abortTimers) && (!flag || _action._v8453A == flag)) {
+			_vm->_game->doObjectAction();
+		}
+
+		if (!_action._savedFields._lookFlag) {
+			if (!_action._inProgress) {
+				_action._v8453A = -1;
+				_sceneLogic->postActions();
+			}
+
+			if (!_action._inProgress) {
+				_action._v8453A = -1;
+				warning("TODO: PtrUnk4");
+			}
+
+			if (_action._inProgress)
+				warning("TODO: sub_1D9DE");
+		}
+	}
+
+	_action._inProgress = false;
+	if (_vm->_game->_abortTimersMode == ABORTMODE_0)
+		_vm->_game->_abortTimers = 0;
 }
 
 void Scene::checkStartWalk() {


Commit: c57acfb154999b3976c07d6512657c02cc4ef468
    https://github.com/scummvm/scummvm/commit/c57acfb154999b3976c07d6512657c02cc4ef468
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-24T01:14:16+01:00

Commit Message:
MADS: Implement scene 203

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h
    engines/mads/palette.cpp
    engines/mads/palette.h
    engines/mads/scene.cpp
    engines/mads/scene.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 42a44a2..6f79947 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -53,6 +53,10 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	// Scene group #2
 	case 201:
 		return new Scene201(vm);
+	case 202:
+		return new Scene202(vm);
+	case 203:
+		return new Scene203(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 0e297e1..65a2858 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -975,5 +975,117 @@ void Scene202::actions() {
 	action->_inProgress = false;
 }
 
+/*****************************************************************************/
+
+void Scene203::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(477);
+}
+
+void Scene203::enter() {
+	if (_scene->_priorSceneId == 202) {
+		_game._player._playerPos = Common::Point(187, 99);
+		_game._player._direction = 2;
+	} else if (_scene->_priorSceneId == 209) {
+		_game._player._playerPos = Common::Point(308, 117);
+		_game._player._direction = 4;
+	} else if (_scene->_priorSceneId == -2) {
+		_game._player._playerPos = Common::Point(155, 152);
+		_game._player._direction = 8;
+	}
+
+	_globals._v0 = 0;
+	_globals._frameTime = 0;
+
+	if ((_globals[34] == 0) && (_scene->_roomChanged == 0)) {
+		_globals._v0 = -1;
+		_game._player.startWalking(Common::Point(158, 135), 2);
+		int idx = _scene->_dynamicHotspots.add(131, 396, 0, Common::Rect(0, 0, 320, 156));
+		_scene->_dynamicHotspots.setPosition(idx, 155, 152, 2);
+		_scene->_dynamicHotspots.setCursor(idx, CURSOR_GO_DOWN);
+	}
+
+	if (_globals._v0 == 0) {
+		_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('b', -1), 0);
+		if (_vm->getRandomNumber(1, 3) == 2) {
+			_globals._spriteIndexes[15] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 9, 1, 0, 0);
+			int idx = _scene->_dynamicHotspots.add(477, 209, _globals._spriteIndexes[15], Common::Rect(0, 0, 0, 0));
+			_scene->_dynamicHotspots.setPosition(idx, -2, 0, 0);
+			_vm->_sound->command(14);
+		}
+	}
+
+	_game.loadQuoteSet(0x67, 0x68, 0x69, 0x6A, 0x5A, 0);
+
+	if (_globals._v0 != 0) {
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(_vm->getRandomNumber(103, 106)));
+	}
+
+	sceneEntrySound();
+}
+
+void Scene203::step() {
+	if (_globals._v0 == 0)
+		return;
+
+	if ((_game._abortTimers == 0) && (_globals._frameTime != 0))
+		return;
+
+	if ((_game._player._playerPos != Common::Point(158, 136)) || (_game._player._direction != 2))
+		return;
+
+	_globals._frameTime = 0xFFFF;
+
+	if (_game._abortTimers == 0) {
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+		_vm->_palette->sub7BBF8();
+		_scene->_kernelMessages.reset();
+		_scene->resetScene();
+		_vm->_events->setCursor2(CURSOR_WAIT);
+		_scene->loadAnimation(Resources::formatName(203, 'a', -1, EXT_AA, ""), 81);
+	} else if (_game._abortTimers == 81) {
+		_scene->_nextSceneId = 208;
+		_scene->_reloadSceneFlag = true;
+	} 
+}
+
+void Scene203::preActions() {
+	if (_globals._v0 && !_action.isAction(0x18C, 0x83, 0)) {
+		_game._player.startWalking(Common::Point(158, 136), 2);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(0xD, 0xF3, 0))
+		_game._player._v844BE = 209;
+}
+
+void Scene203::actions() {
+	if (_action._savedFields._lookFlag) {
+		Dialog::show(0x4F53);
+	} else if (_action.isAction(0x18C, 0x83, 0)) {
+		_scene->_nextSceneId = 208;
+	} else if (_action.isAction(0x18C, 0x82, 0)) {
+		_scene->_nextSceneId = 202;
+	} else if (_action.isAction(0x3, 0x142, 0)) {
+		Dialog::show(0x4F4D);
+	} else if (_action.isAction(0x3, 0x4D, 0)) {
+		Dialog::show(0x4F4E);
+	} else if (_action.isAction(0x3, 0x100, 0)) {
+		Dialog::show(0x4F4F);
+	} else if (_action.isAction(0x3, 0x82, 0)) {
+		Dialog::show(0x4F50);
+	} else if (_action.isAction(0x3, 0x1A6, 0)) {
+		Dialog::show(0x4F51);
+	} else if (_action.isAction(0x3, 0x30, 0)) {
+		Dialog::show(0x4F51);
+	} else
+		return;
+
+	_action._inProgress = false;
+}
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index a1faf53..b49cf96 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -78,6 +78,17 @@ public:
 
 	void setRandomKernelMessage();
 };
+
+class Scene203: public Scene2xx {
+public:
+	Scene203(MADSEngine *vm) : Scene2xx(vm) {}
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index bd467aa..4a62cca 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -517,8 +517,19 @@ void Palette::setLowRange() {
 }
 
 void Palette::fadeOut(byte palette[PALETTE_SIZE], int v1, int v2, int v3, int v4, int v5, int v6) {
-
 }
 
+void Palette::sub7BBF8() {
+	if ((_rgbList[31] != 0) && (_v1 == 0))
+		error("Palette - Unexpected values");
+
+	_v1 = -1;
+	_rgbList[31] = -1;
+
+	for (int i = 0; i < 256; i++) {
+		if (_palFlags[i])
+			_palFlags[i] |= 0x80000000;
+	}
+}
 
 } // End of namespace MADS
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index e9549fd..2fdb386 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -229,6 +229,8 @@ public:
 	}
 
 	void fadeOut(byte palette[PALETTE_SIZE], int v1, int v2, int v3, int v4, int v5, int v6);
+
+	void sub7BBF8();
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 565ef47..00460a9 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -569,4 +569,10 @@ void Scene::changeDepthSurface(int arg1) {
 	_spriteSlots.fullRefresh();
 }
 
+void Scene::resetScene() {
+	_vm->_game->clearQuotes();
+	_spriteSlots.fullRefresh(true);
+	_sequences.clear();
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index a51d820..f7d0e56 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -204,6 +204,7 @@ public:
 
 	void changeDepthSurface(int arg1);
 
+	void resetScene();
 };
 
 } // End of namespace MADS


Commit: ce9a15f010d84c8596380eec5226ef22704022e5
    https://github.com/scummvm/scummvm/commit/ce9a15f010d84c8596380eec5226ef22704022e5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-23T21:52:18-04:00

Commit Message:
MADS: Fix the setting/clearing of _mouseReleased flag

Changed paths:
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/scene.cpp



diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index fe2a253..a4e1a96 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -132,6 +132,7 @@ void EventsManager::pollEvents() {
 		case Common::EVENT_LBUTTONUP:
 		case Common::EVENT_RBUTTONUP:
 			_mouseClicked = false;
+			_mouseReleased = true;
 			_mouseMoved = true;
 			return;
 		case Common::EVENT_MOUSEMOVE:
@@ -186,4 +187,9 @@ void EventsManager::initVars() {
 	_vD2 = _vD8 = 0;
 }
 
+void EventsManager::resetMouseFlags() {
+	_mouseClicked = false;
+	_mouseReleased = false;
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/events.h b/engines/mads/events.h
index 219af20..b7af148 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -141,6 +141,8 @@ public:
 	uint32 getFrameCounter() const { return _frameCounter; }
 
 	void initVars();
+
+	void resetMouseFlags();
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 00460a9..8360c1e 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -272,6 +272,12 @@ void Scene::loop() {
 		// Handle drawing a game frame
 		doFrame();
 
+		// Reset mouse flags
+		_vm->_events->resetMouseFlags();
+
+		// TODO: Verify correctness of frame wait
+		_vm->_events->waitForNextFrame();
+
 		if (_vm->_dialogs->_pendingDialog != DIALOG_NONE && !_vm->_game->_abortTimers
 			&& _vm->_game->_player._stepEnabled)
 			_reloadSceneFlag = true;
@@ -421,9 +427,6 @@ void Scene::doFrame() {
 		_activeAnimation->free();
 		_activeAnimation = nullptr;
 	}
-
-	// TODO: Verify correctness of frame wait
-	_vm->_events->waitForNextFrame();
 }
 
 void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {


Commit: 0dfa60ae00428ad83c6b6d19963e2d7352707637
    https://github.com/scummvm/scummvm/commit/0dfa60ae00428ad83c6b6d19963e2d7352707637
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-23T22:11:35-04:00

Commit Message:
MADS: Refactored out and fixed cursor changes for hotspots

Changed paths:
    engines/mads/scene.cpp
    engines/mads/scene.h



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 8360c1e..1b3143f 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -340,33 +340,7 @@ void Scene::doFrame() {
 			player.nextFrame();
 
 			// Cursor update code
-			CursorType cursorId = CURSOR_ARROW;
-			if (_action._v83338 == 1 && !_vm->_game->_screenObjects._v7FECA &&
-					_vm->_game->_screenObjects._category == CAT_HOTSPOT) {
-				int idx = _vm->_game->_screenObjects._selectedObject - 
-					_userInterface._categoryIndexes[CAT_HOTSPOT - 1];
-				assert(idx >= 0);
-
-				if (idx >= (int)_hotspots.size()) {
-					idx -= _hotspots.size();
-					_vm->_events->_newCursorId = _dynamicHotspots[idx]._cursor;
-				} else {
-					_vm->_events->_newCursorId = _hotspots[idx]._cursor;
-				}
-
-				cursorId = _vm->_events->_newCursorId == CURSOR_NONE ? 
-					CURSOR_ARROW : _vm->_events->_newCursorId;
-			}
-
-			if (!player._stepEnabled)
-				cursorId = CURSOR_WAIT;
-			if (cursorId >= _vm->_events->_cursorSprites->getCount())
-				cursorId = (CursorType)_vm->_events->_cursorSprites->getCount();
-			_vm->_events->_newCursorId = cursorId;
-
-			if (cursorId != _vm->_events->_cursorId) {
-				_vm->_events->setCursor(cursorId);
-			}
+			updateCursor();
 
 			if (!_vm->_game->_abortTimers) {
 				// Handle any active sequences
@@ -562,6 +536,39 @@ void Scene::loadAnimation(const Common::String &resName, int abortTimers) {
 	_activeAnimation->startAnimation(abortTimers);
 }
 
+void Scene::updateCursor() {
+	Player &player = _vm->_game->_player;
+
+	CursorType cursorId = CURSOR_ARROW;
+	if (_action._v83338 == 1 && !_vm->_game->_screenObjects._v7FECA &&
+		_vm->_game->_screenObjects._category == CAT_HOTSPOT) {
+		int idx = _vm->_game->_screenObjects._selectedObject -
+			_userInterface._categoryIndexes[CAT_HOTSPOT - 1];
+		assert(idx >= 0);
+
+		if (idx >= (int)_hotspots.size()) {
+			idx -= _hotspots.size();
+			_vm->_events->_newCursorId = _dynamicHotspots[idx]._cursor;
+		} else {
+			idx = _hotspots.size() - idx - 1;
+			_vm->_events->_newCursorId = _hotspots[idx]._cursor;
+		}
+
+		cursorId = _vm->_events->_newCursorId == CURSOR_NONE ?
+		CURSOR_ARROW : _vm->_events->_newCursorId;
+	}
+
+	if (!player._stepEnabled)
+		cursorId = CURSOR_WAIT;
+	if (cursorId >= _vm->_events->_cursorSprites->getCount())
+		cursorId = (CursorType)_vm->_events->_cursorSprites->getCount();
+	_vm->_events->_newCursorId = cursorId;
+
+	if (cursorId != _vm->_events->_cursorId) {
+		_vm->_events->setCursor(cursorId);
+	}
+}
+
 void Scene::free() {
 	warning("TODO: Scene::free");
 }
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index f7d0e56..e2eec23 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -70,6 +70,11 @@ private:
 	void doSceneStep();
 
 	void checkKeyboard();
+
+	/**
+	 * Checks for a highlighted hotspot, and updates the cursor accordingly
+	 */
+	void updateCursor();
 protected:
 	MADSEngine *_vm;
 public:


Commit: 0b1c15e6dcd2f16d5ef67e61fd4c8c0157f66706
    https://github.com/scummvm/scummvm/commit/0b1c15e6dcd2f16d5ef67e61fd4c8c0157f66706
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-23T22:40:37-04:00

Commit Message:
MADS: Fix setting category/desc Id from highlighted screen elements

Changed paths:
    engines/mads/screen.cpp



diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 964e836..5b0d442 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -293,8 +293,9 @@ void ScreenObjects::check(bool scanFlag) {
 		_category = CAT_NONE;
 		_selectedObject = scanBackwards(_vm->_events->currentPos(), LAYER_GUI);
 		if (_selectedObject > 0) {
-			_category = (ScrCategory)((*this)[_selectedObject - 1]._category & 7);
-			_newDescId = (*this)[_selectedObject - 1]._descId;
+			ScreenObject &scrObject = (*this)[_selectedObject];
+			_category = (ScrCategory)(scrObject._category & 7);
+			_newDescId = scrObject._descId;
 		}
 
 		// Handling for easy mouse


Commit: 48e785c329937868b403869414344dbc78525a95
    https://github.com/scummvm/scummvm/commit/48e785c329937868b403869414344dbc78525a95
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-24T19:15:59+01:00

Commit Message:
MADS: Fix a couple of warnings in the hotspot code

Changed paths:
    engines/mads/hotspots.h
    engines/mads/user_interface.cpp



diff --git a/engines/mads/hotspots.h b/engines/mads/hotspots.h
index ec9f12d..37c37fa 100644
--- a/engines/mads/hotspots.h
+++ b/engines/mads/hotspots.h
@@ -57,7 +57,7 @@ public:
 public:
 	DynamicHotspots(MADSEngine *vm);
 
-	int size() const { return _entries.size(); }
+	Common::Array<MADS::DynamicHotspot>::size_type size() const { return _entries.size(); }
 	DynamicHotspot &operator[](uint idx) { return _entries[idx]; }
 	int add(int descId, int vocabId, int seqIndex, const Common::Rect &bounds);
 	int setPosition(int index, int xp, int yp, int facing);
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 2ea656d..28fc5a6 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -665,7 +665,7 @@ void UserInterface::scrollInventory() {
 				_scrollFlag = true;
 
 				if (yp == (MADS_SCREEN_HEIGHT - 1)) {
-					if (_inventoryTopIndex < (invList.size() - 1)) {
+					if (_inventoryTopIndex < (int)(invList.size() - 1)) {
 						++_inventoryTopIndex;
 						_inventoryChanged = true;
 					}


Commit: aef340c25a7c7cae2b0955549e412abf842e4f47
    https://github.com/scummvm/scummvm/commit/aef340c25a7c7cae2b0955549e412abf842e4f47
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-24T19:16:52+01:00

Commit Message:
MADS: Implement Scene205::setup and Scene205::enter

Changed paths:
    engines/mads/animation.h
    engines/mads/nebular/globals_nebular.cpp
    engines/mads/nebular/globals_nebular.h
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index dd902b8..1207ff6 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -121,7 +121,6 @@ private:
 	Font *_font;
 
 	int _currentFrame, _oldFrameEntry;
-	bool _resetFlag;
 	bool _freeFlag;
 	bool _skipLoad;
 	int _unkIndex;
@@ -154,8 +153,9 @@ private:
 protected:
 	Animation(MADSEngine *vm, Scene *scene);
 public:
+	bool _resetFlag;
+
 	static Animation *init(MADSEngine *vm, Scene *scene);
-public:
 	/*
 	 * Destructor
 	 */
diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp
index d2a82d5..adc58e6 100644
--- a/engines/mads/nebular/globals_nebular.cpp
+++ b/engines/mads/nebular/globals_nebular.cpp
@@ -50,6 +50,7 @@ Globals::Globals() {
 	_v84264 = 0;
 	_v84266 = 0;
 	_v84268 = 0;
+	_v84274 = 0;
 }
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index bbc2353..95117a3 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -48,7 +48,7 @@ public:
 	int _v8;
 	int _abortVal;
 	uint32 _v8425C;
-	int _v84260, _v84262, _v84264, _v84266, _v84268;
+	int _v84260, _v84262, _v84264, _v84266, _v84268, _v84274;
 public:
 	/**
 	 * Constructor
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 6b2b101..895ee51 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -44,6 +44,7 @@ enum Noun {
 	NOUN_2C             = 0x2C,
 	NOUN_BURGER			= 0x35,
 	NOUN_CHAIR			= 0x47,
+	NOUN_49             = 0x49,
 	NOUN_4E             = 0x4E,
 	NOUN_DEAD_FISH		= 0x65,
 	NOUN_DOOR			= 0x6E,
@@ -70,6 +71,7 @@ enum Noun {
 	NOUN_OUTER_HULL		= 0x0F8,
 	NOUN_OUTSIDE		= 0x0F9,
 	NOUN_PEER_THROUGH	= 0x103,
+	NOUN_10D            = 0x10D,
 	NOUN_PLANT_STALK	= 0x10F,
 	NOUN_READ			= 0x11F,
 	NOUN_REFRIDGERATOR	= 0x122,
@@ -109,7 +111,7 @@ protected:
 	MADSAction &_action;
 
 	/**
-	 * Forms an animation resoucre name
+	 * Forms an animation resource name
 	 */
 	Common::String formAnimName(char sepChar, int suffixNum);
 
@@ -122,6 +124,8 @@ public:
 	 * Constructor
 	 */
 	NebularScene(MADSEngine *vm);
+
+	void sub7178C();
 };
 
 class SceneInfoNebular : public SceneInfo {
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 65a2858..c6ae09c 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1087,5 +1087,99 @@ void Scene203::actions() {
 	_action._inProgress = false;
 }
 
+/*****************************************************************************/
+
+void Scene205::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(NOUN_D);
+	_scene->addActiveVocab(NOUN_49);
+	_scene->addActiveVocab(NOUN_10D);
+}
+
+void Scene205::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0), 0);
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 1), 0);
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 2), 0);
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('f', -1), 0);
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('c', -1), 0);
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('p', -1), 0);
+	
+	if (_globals[0] == SEX_MALE)
+		_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('a', 1), 0);
+
+	_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 10, 0, 0, 3);
+	int idx = _scene->_dynamicHotspots.add(73, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
+	_scene->_dynamicHotspots.setPosition(idx, 162, 120, 9);
+
+	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 15, 0, 0, 0);
+	idx = _scene->_dynamicHotspots.add(73, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
+	_scene->_dynamicHotspots.setPosition(idx, 162, 120, 9);
+
+	_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 9, 0, 0, 0);
+	_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 0, 0, 0);
+	_scene->_sequences.setDepth(_globals._spriteIndexes[20], 11);
+
+	if (!_game._visitedScenes._sceneRevisited) {
+		_globals._v2 = _scene->_frameStartTime & 0xFFFF;
+		_globals._v3 = _scene->_frameStartTime >> 16;
+		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 7, 1, 0, 0);
+		idx = _scene->_dynamicHotspots.add(269, 13, _globals._spriteIndexes[21], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, 49, 86, 8);
+	}
+
+	if (_game._objects[12]._roomNumber == 0) {
+		_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 7, 0, 0, 0);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[19], 11);
+	} else {
+		_scene->_hotspots.activate(450, false);
+	}
+
+	_globals._frameTime &= 0xFFFF;
+	_game.loadQuoteSet(0x6B, 0x70, 0x71, 0x72, 0x5A, 0x74, 0x75, 0x76, 0x77, 0x78, 0x73, 0x79, 0x7A, 0x7B, 0x7C,
+		0x7D, 0x7E, 0x7F, 0x80, 0xAC, 0xAD, 0xAE, 0x6C, 0x6D, 0x6E, 0x6F, 0x2, 0);
+	warning("TODO: sub71A50(_globals._v4, 0x5A, 0x78, 0x74, 0x75, 0x76, 0x77, 0);");
+
+	if (!_game._visitedScenes._sceneRevisited)
+		warning("TODO: sub71B18(_globals._v4, 0x5A, 0x74, 0x75, 0x77, 0);");
+
+
+	_vm->_palette->setEntry(250, 63, 50, 20);
+	_vm->_palette->setEntry(251, 50, 40, 15);
+	_vm->_palette->setEntry(252, 63, 63, 40);
+	_vm->_palette->setEntry(253, 50, 50, 30);
+
+	_globals._v0 = _globals._frameTime & 0xFFFF;
+	_globals._frameTime >>= 16;
+
+	if (_globals[0] == SEX_FEMALE)
+		warning("sub71704(0x3, 0xC3, 0x108, 0x63, 0x86, 0xD, 2, 0xFDFC, 0x3C, 0x6C, 0x6C, 0x6D, 0x6D, 0x6E, 0x6E, 0x6F, 0x6C, 0);");
+
+	if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(99, 152);	
+
+	if (_globals[0] != SEX_MALE) {
+		_scene->loadAnimation(formAnimName('a', -1), 0);
+		_scene->_activeAnimation->_resetFlag = false;
+	} else {
+		_globals._frameTime |= 0xFFFF0000;
+		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+		_scene->_sequences.setDepth(_globals._spriteIndexes[23], 2);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_FRAME_INDEX, 6, 73);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_FRAME_INDEX, 11, 74);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 0);
+	}
+	_globals._v84274 = -1;
+	sceneEntrySound();
+}
+
+void Scene205::step() {
+}
+
+void Scene205::actions() {
+}
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index b49cf96..5346b34 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -89,6 +89,17 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene205: public Scene2xx {
+public:
+	Scene205(MADSEngine *vm) : Scene2xx(vm) {}
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: c177056653d09f16dbf8a28bd93d048f95e9398a
    https://github.com/scummvm/scummvm/commit/c177056653d09f16dbf8a28bd93d048f95e9398a
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-24T21:13:46+01:00

Commit Message:
MADS: Add detection for another Rex

Changed paths:
    engines/mads/detection_tables.h



diff --git a/engines/mads/detection_tables.h b/engines/mads/detection_tables.h
index ac5316d..d7614cf 100644
--- a/engines/mads/detection_tables.h
+++ b/engines/mads/detection_tables.h
@@ -41,6 +41,24 @@ static const MADSGameDescription gameDescriptions[] = {
 		0
 	},
 
+	{
+		// Rex Nebular and the Cosmic Gender Bender DOS English
+		{
+			"nebular",
+			0,
+			{
+				{"section1.hag", 0, "6f725eb38660de8af31ec7cdd628d615", 927222},
+				AD_LISTEND
+			},
+			Common::EN_ANY,
+			Common::kPlatformDOS,
+			ADGF_NO_FLAGS,
+			GUIO1(GUIO_NONE)
+		},
+		GType_RexNebular,
+		0
+	},
+
 	{ AD_TABLE_END_MARKER }
 };
 


Commit: d958f509241714f140c95e7afa0005b1fe5c8352
    https://github.com/scummvm/scummvm/commit/d958f509241714f140c95e7afa0005b1fe5c8352
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-24T22:33:49-04:00

Commit Message:
MADS: Fix incorrect palette for player sprites

Changed paths:
    engines/mads/palette.cpp



diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 4a62cca..f57766e 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -107,10 +107,10 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 	bool flag1 = false;
 
 	if (hasUsage) {
-		if (varA || !_vm->_palette->_paletteUsage[0])
+		if (varA || _vm->_palette->_paletteUsage.empty())
 			hasUsage = false;
 
-		if (varA && _vm->_palette->_paletteUsage[0])
+		if (varA && !_vm->_palette->_paletteUsage.empty())
 			flag1 = true;
 	}
 
@@ -178,10 +178,9 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 		}
 
 		if (!var48 && !varA) {
-			int var2 = !(palette[palIndex]._flags & 0x20) && (
-				((flags & 0x2000) && !(palette[palIndex]._flags & 0x40)) ||
-				((flags & 0x1000) && (palCount > 0))
-				) ? 1 : 0x7fff;
+			int var2 = (palette[palIndex]._flags & 0x20) ||
+				(((flags & 0x2000) || (palette[palIndex]._flags & 0x4000)) &&
+				((flags & 0x1000) || (palCount == 0))) ? 0x7fff : 1;
 			int var36 = (palette[palIndex]._flags & 0x80) ? 0 : 2;
 			
 			for (int idx = palLow; idx < palIdx; ++idx) {


Commit: 3c504f4d028efdec39b6b250948eb41522de18e2
    https://github.com/scummvm/scummvm/commit/3c504f4d028efdec39b6b250948eb41522de18e2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-24T22:34:09-04:00

Commit Message:
MADS: Cleanup of user interface selection code

Changed paths:
    engines/mads/game.cpp
    engines/mads/screen.cpp
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 4b907d1..f155bc8 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -199,7 +199,7 @@ void Game::sectionLoop() {
 		}
 
 		_vm->_events->initVars();
-		_scene._userInterface._v1A = -1;
+		_scene._userInterface._highlightedActionIndex = -1;
 		_scene._userInterface._v1C = -1;
 		_scene._userInterface._v1E = -1;
 
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 5b0d442..ba68752 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -437,7 +437,7 @@ void ScreenObjects::checkScroller() {
 
 			if (userInterface._inventoryChanged) {
 				int dummy;
-				userInterface.drawInventory(2, 0, &dummy);
+				userInterface.updateSelection(CAT_INV_LIST, 0, &dummy);
 			}
 		}
 	}
@@ -457,7 +457,7 @@ void ScreenObjects::elementHighlighted() {
 	MADSAction &action = scene._action;
 	int varA;
 	int topIndex;
-	int *var6;
+	int *idxP;
 	int var4;
 	int index;
 	int indexEnd = -1;
@@ -470,10 +470,11 @@ void ScreenObjects::elementHighlighted() {
 		indexEnd = 9;
 		varA = 5;
 		topIndex = 0;
-		var6 = !_v7FECA ? &userInterface._v1A : &userInterface._selectedActionIndex;
+		idxP = !_v7FECA ? &userInterface._highlightedActionIndex : 
+			&userInterface._selectedActionIndex;
 
 		if (_v7FECA && userInterface._selectedItemVocabIdx >= 0)
-			userInterface.drawInventory(3, -1, &userInterface._selectedItemVocabIdx);
+			userInterface.updateSelection(CAT_INV_VOCAB, -1, &userInterface._selectedItemVocabIdx);
 
 		var4 = _released && !_v7FECA ? 1 : 0;
 		break;
@@ -485,7 +486,7 @@ void ScreenObjects::elementHighlighted() {
 		indexEnd = invList.size() - 1;
 		varA = 0;
 		topIndex = userInterface._inventoryTopIndex;
-		var6 = &userInterface._v1C;
+		idxP = &userInterface._v1C;
 		var4 = (!_released || (_vm->_events->_mouseButtons && action._v83338 == 1)) ? 0 : 1;
 		break;
 
@@ -501,10 +502,10 @@ void ScreenObjects::elementHighlighted() {
 
 		varA = 0;
 		topIndex = 0;
-		var6 = _v7FECA ? &userInterface._selectedItemVocabIdx : &userInterface._v1E;
+		idxP = _v7FECA ? &userInterface._selectedItemVocabIdx : &userInterface._v1E;
 
 		if (_v7FECA && userInterface._selectedActionIndex >= 0)
-			userInterface.drawInventory(1, -1, &userInterface._selectedActionIndex);
+			userInterface.updateSelection(CAT_ACTION, -1, &userInterface._selectedActionIndex);
 
 		var4 = _released && !_v7FECA ? 1 : 0;
 		break;
@@ -514,7 +515,7 @@ void ScreenObjects::elementHighlighted() {
 		indexEnd = invList.size() - 1;
 		varA = 0;
 		topIndex = userInterface._selectedInvIndex;
-		var6 = &var8;
+		idxP = &var8;
 		var4 = -1;
 		break;
 
@@ -528,7 +529,7 @@ void ScreenObjects::elementHighlighted() {
 		indexEnd = index - 1;
 		varA = 0;
 		topIndex = 0;
-		var6 = &userInterface._v1A;
+		idxP = &userInterface._highlightedActionIndex;
 		var4 = -1;
 		break;
 
@@ -538,7 +539,7 @@ void ScreenObjects::elementHighlighted() {
 		indexEnd = index - 1;
 		varA = 0;
 		topIndex = 0;
-		var6 = &var8;
+		idxP = &var8;
 		var4 = -1;
 		break;
 	}
@@ -606,7 +607,7 @@ void ScreenObjects::elementHighlighted() {
 		newIndex = -1;
 
 	if (_category != CAT_HOTSPOT && _category != CAT_INV_ANIM)
-		userInterface.drawInventory(_category, newIndex, var6);
+		userInterface.updateSelection(_category, newIndex, idxP);
 }
 
 void ScreenObjects::setActive(ScrCategory category, int descId, bool active) {
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 28fc5a6..67fb50e 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -199,7 +199,7 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm), _dirtyAreas(vm),
 	_selectedActionIndex = -1;
 	_selectedItemVocabIdx = -1;
 	_scrollerY = 0;
-	_v1A = -1;
+	_highlightedActionIndex = -1;
 	_v1C = -1;
 	_v1E = -1;
 	_dirtyAreas.resize(50);
@@ -264,7 +264,7 @@ void UserInterface::setup(int id) {
 	scene._userInterface._uiSlots.clear();
 	scene._userInterface._uiSlots.fullRefresh();
 	_vm->_game->_ticksExpiry = _vm->_events->getFrameCounter();
-	_v1A = -1;
+	_highlightedActionIndex = -1;
 	_v1E = -1;
 	_v1C = -1;
 
@@ -331,7 +331,7 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
 	case CAT_ACTION:
 		font = _vm->_font->getFont(FONT_INTERFACE);
 		vocabId = scene._verbList[id]._id;
-		if (_v1A) {
+		if (_highlightedActionIndex) {
 			_vm->_font->setColorMode(1);
 		} else {
 			_vm->_font->setColorMode(id == _selectedActionIndex ? 2 : 0);
@@ -642,8 +642,50 @@ void UserInterface::selectObject(int invIndex) {
 	warning("TODO: selectObject");
 }
 
-void UserInterface::drawInventory(int v1, int v2, int *v3) {
-	warning("TODO: drawInventory");
+void UserInterface::updateSelection(ScrCategory category, int newIndex, int *idx) {
+	Game &game = *_vm->_game;
+	Common::Rect bounds;
+
+	if (category == CAT_INV_LIST && _inventoryChanged) {
+		*idx = newIndex;
+		bounds = Common::Rect(90, 3, 90 + 69, 3 + 40);
+		_uiSlots.add(Common::Point(90, 3), 69, 40);
+		_uiSlots.draw(false, false);
+		drawInventoryList();
+		updateRect(bounds);
+		_inventoryChanged = false;
+
+		if (game._objects._inventoryList.size() > 1) {
+			_objectY = 0;
+		} else {
+			int v = _inventoryTopIndex * 18 / (game._objects._inventoryList.size() - 1);
+			_objectY = MIN(v, 17);
+		}
+	} else {
+		int oldIndex = *idx;
+		*idx = newIndex;
+
+		if (oldIndex >= 0) {
+			Common::Rect bounds;
+			writeVocab(category, oldIndex);
+			
+			if (getBounds(category, oldIndex, bounds))
+				updateRect(bounds);
+		}
+
+		if (newIndex >= 0) {
+			writeVocab(category, newIndex);
+
+			if (getBounds(category, newIndex, bounds))
+				updateRect(bounds);
+		}
+	}
+}
+
+void UserInterface::updateRect(const Common::Rect &bounds) {
+	_vm->_screen.setPointer(&_surface);
+	setBounds(Common::Rect(0, MADS_SCENE_HEIGHT, MADS_SCREEN_WIDTH - 1, MADS_SCREEN_HEIGHT));
+	_vm->_screen.copyRectToScreen(bounds);
 }
 
 void UserInterface::scrollerChanged() {
@@ -665,7 +707,7 @@ void UserInterface::scrollInventory() {
 				_scrollFlag = true;
 
 				if (yp == (MADS_SCREEN_HEIGHT - 1)) {
-					if (_inventoryTopIndex < (int)(invList.size() - 1)) {
+					if (_inventoryTopIndex < ((int)invList.size() - 1)) {
 						++_inventoryTopIndex;
 						_inventoryChanged = true;
 					}
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index abb4619..ee5bc7a 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -128,6 +128,8 @@ private:
 	void writeVocab(ScrCategory category, int id);
 
 	void refresh();
+
+	void updateRect(const Common::Rect &bounds);
 public:
 	MSurface _surface;
 	UISlots _uiSlots;
@@ -141,7 +143,7 @@ public:
 	int _selectedActionIndex;
 	int _selectedItemVocabIdx;
 	int _scrollerY;
-	int _v1A;
+	int _highlightedActionIndex;
 	int _v1C;
 	int _v1E;
 	bool _inventoryChanged;
@@ -191,7 +193,7 @@ public:
 	 */
 	void selectObject(int invIndex);
 
-	void drawInventory(int v1, int v2, int *v3);
+	void updateSelection(ScrCategory category, int newIndex, int *idx);
 
 	void scrollerChanged();
 


Commit: 2879b895bc301b46a4d9098de56fabfc2434f0f8
    https://github.com/scummvm/scummvm/commit/2879b895bc301b46a4d9098de56fabfc2434f0f8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-25T08:55:29-04:00

Commit Message:
MADS: Fixes for UI item selection, add added an enum for Font::setColorMode

Changed paths:
    engines/mads/font.cpp
    engines/mads/font.h
    engines/mads/screen.cpp
    engines/mads/user_interface.cpp



diff --git a/engines/mads/font.cpp b/engines/mads/font.cpp
index e3497b3..e511bd8 100644
--- a/engines/mads/font.cpp
+++ b/engines/mads/font.cpp
@@ -118,15 +118,15 @@ void Font::setColors(uint8 v1, uint8 v2, uint8 v3, uint8 v4) {
 	_fontColors[2] = v3;
 }
 
-void Font::setColorMode(int mode) {
+void Font::setColorMode(SelectionMode mode) {
 	switch (mode) {
-	case 0:
+	case SELMODE_UNSELECTED:
 		setColors(0xFF, 4, 4, 0);
 		break;
-	case 1:
+	case SELMODE_HIGHLIGHTED:
 		setColors(0xFF, 5, 5, 0);
 		break;
-	case 2:
+	case SELMODE_SELECTED:
 		setColors(0xFF, 6, 6, 0);
 		break;
 	default:
diff --git a/engines/mads/font.h b/engines/mads/font.h
index 5079f12..1511b60 100644
--- a/engines/mads/font.h
+++ b/engines/mads/font.h
@@ -39,6 +39,10 @@ namespace MADS {
 #define FONT_TELE "*FONTTELE.FF"	// Not in Phantom
 #define FONT_PHAN "*FONTPHAN.FF"	// Phantom only
 
+enum SelectionMode { 
+	SELMODE_UNSELECTED = 0, SELMODE_HIGHLIGHTED = 1, SELMODE_SELECTED = 2 
+};
+
 class MADSEngine;
 
 class Font {
@@ -77,7 +81,7 @@ public:
 	virtual ~Font();
 
 	void setColors(uint8 v1, uint8 v2, uint8 v3, uint8 v4);
-	void setColorMode(int mode);
+	void setColorMode(SelectionMode mode);
 
 	int maxWidth() const { return _maxWidth; }
 	int getWidth(const Common::String &msg, int spaceWidth = -1);
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index ba68752..a2cc75f 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -575,7 +575,7 @@ void ScreenObjects::elementHighlighted() {
 				if (currentPos.x > bounds.left)
 					newIndex = idx;
 			} else {
-				if (currentPos.x > bounds.right)
+				if (currentPos.x < bounds.right)
 					newIndex = idx;
 			}
 		}
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 67fb50e..b45ff14 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -331,10 +331,10 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
 	case CAT_ACTION:
 		font = _vm->_font->getFont(FONT_INTERFACE);
 		vocabId = scene._verbList[id]._id;
-		if (_highlightedActionIndex) {
-			_vm->_font->setColorMode(1);
+		if (id == _highlightedActionIndex) {
+			_vm->_font->setColorMode(SELMODE_HIGHLIGHTED);
 		} else {
-			_vm->_font->setColorMode(id == _selectedActionIndex ? 2 : 0);
+			_vm->_font->setColorMode(id == _selectedActionIndex ? SELMODE_SELECTED : SELMODE_UNSELECTED);
 		}
 		vocabStr = scene.getVocab(vocabId);
 		vocabStr.setChar(toupper(vocabStr[0]), 0);
@@ -344,10 +344,10 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
 	case CAT_INV_LIST:
 		font = _vm->_font->getFont(FONT_INTERFACE);
 		vocabId = _vm->_game->_objects.getItem(id)._descId;
-		if (_v1C == id) {
-			_vm->_font->setColorMode(1);
+		if (id == _v1C) {
+			_vm->_font->setColorMode(SELMODE_HIGHLIGHTED);
 		} else {
-			_vm->_font->setColorMode(id == _selectedInvIndex ? 2 : 0);
+			_vm->_font->setColorMode(id == _selectedInvIndex ? SELMODE_SELECTED : SELMODE_UNSELECTED);
 			vocabStr = scene.getVocab(vocabId);
 			vocabStr.setChar(toupper(vocabStr[0]), 0);
 			font->writeString(this, vocabStr, Common::Point(bounds.left, bounds.top));
@@ -378,16 +378,17 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
 			break;
 		}
 
-		font->setColorMode((id == 4) || (_scrollerY == 3) ? 1 : 0);
+		font->setColorMode((id == 4) || (_scrollerY == 3) ? SELMODE_HIGHLIGHTED : SELMODE_UNSELECTED);
 		font->writeString(this, vocabStr, Common::Point(bounds.left, bounds.top));
 		break;
 	default:
+		// Item specific verbs
 		font = _vm->_font->getFont(FONT_INTERFACE);
 		vocabId = _vm->_game->_objects.getItem(_selectedInvIndex)._vocabList[id]._vocabId;
-		if (_v1E == id) {
-			_vm->_font->setColorMode(1);
+		if (id == _v1E) {
+			_vm->_font->setColorMode(SELMODE_HIGHLIGHTED);
 		} else {
-			_vm->_font->setColorMode(id == _selectedInvIndex ? 2 : 0);
+			_vm->_font->setColorMode(id == _selectedInvIndex ? SELMODE_SELECTED : SELMODE_UNSELECTED);
 			vocabStr = scene.getVocab(vocabId);
 			vocabStr.setChar(toupper(vocabStr[0]), 0);
 			font->writeString(this, vocabStr, Common::Point(bounds.left, bounds.top));


Commit: 9028484d4b277565005a5a46444ac7b83cba6fe8
    https://github.com/scummvm/scummvm/commit/9028484d4b277565005a5a46444ac7b83cba6fe8
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-25T20:36:26+01:00

Commit Message:
MADS: Start work on Scene 207

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 6f79947..0f35e5d 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -57,6 +57,10 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene202(vm);
 	case 203:
 		return new Scene203(vm);
+	case 205:
+		return new Scene205(vm);
+	case 207:
+		return new Scene207(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index c6ae09c..ed254a4 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1176,9 +1176,134 @@ void Scene205::enter() {
 }
 
 void Scene205::step() {
+	warning("TODO: Scene205::step");
 }
 
 void Scene205::actions() {
+	warning("TODO: Scene205::actions");
+}
+
+/*****************************************************************************/
+
+void Scene207::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x185);
+	_scene->addActiveVocab(NOUN_D);
+	_scene->addActiveVocab(0x14D);
+	_scene->addActiveVocab(NOUN_D);
+}
+
+void Scene207::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('h', 0), 0);
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('h', 1), 0);
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('c', -1), 0);
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('e', 0), 0);
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('e', 1), 0);
+	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('g', 1), 0);
+	_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('g', 0), 0);
+	_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 7, 0, 0, 0);
+	_scene->_sequences.setDepth(_globals._spriteIndexes[20], 7);
+
+	int var2;
+	if (!_game._visitedScenes._sceneRevisited) {
+		var2 = 1;
+	} else {
+		var2 = _vm->getRandomNumber(4) + 1;
+	}
+
+	if (var2 > 2)
+		_globals._v0 = 0;
+	else
+		_globals._v0 = 1;
+
+	_globals._v5 = (var2 & 1);
+	
+	if (_globals._v0) {
+		_globals._spriteIndexes[16] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 30, 0, 0, 400);
+		_globals._frameTime = _game._player._priorTimer;
+
+		int idx = _scene->_dynamicHotspots.add(389, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, 254, 94, 4);
+	}
+
+	if (_globals._v5) {
+		_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 7, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], -1, -1);
+		_globals._v3 = _game._player._priorTimer & 0xFFFF;
+		_globals._v4 = _game._player._priorTimer >> 16;
+		int idx = _scene->_dynamicHotspots.add(333, 13, _globals._spriteIndexes[19], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, 59, 132, 2);
+	}
+
+	_globals._v2 = 0;
+	if (_scene->_priorSceneId == 211) {
+		_game._player._playerPos = Common::Point(13, 105);
+		_game._player._direction = 6;
+	} else if (_scene->_priorSceneId == 214) {
+		_game._player._playerPos = Common::Point(164, 117);
+		_game._player._direction = 2;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(305, 131);
+	}
+
+	_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 10, 1, 0, 0);
+	_scene->_sequences.setAnimRange(_globals._spriteIndexes[21], 1, 22);
+	_scene->_sequences.setDepth(_globals._spriteIndexes[21], 6);
+	_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 70);
+}
+
+void Scene207::step() {
+	if (!_globals._v0) {
+		warning("TODO: sub3AD90(...)");
+	}
+
+	if (_globals._v5) {
+		warning("TODO: sub3ADD6(...)");
+	}
+
+	if (_game._abortTimers == 70) {
+		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 10, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[21], 23, 34);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 6);
+	}
+
+	if (_game._abortTimers == 71)
+		_globals._v2 = 0;
+
+	if (_globals._v2)
+		return;
+
+	if ((_game._player._playerPos.x >= 124) && (_game._player._playerPos.x <= 201)) {
+		_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 10, 1, 0, 0);
+		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[22], 6);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[23], 6);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 71);
+		_globals._v2 = -1;
+	}
+}
+
+void Scene207::preActions() {
+	if (_action.isAction(0x1AD, 0x1AE, 0))
+		_game._player._v844BE = 211;
+
+	if (_action.isAction(0x18C, 0x1AB, 0))
+		_game._player._v844BE = 208;
+
+	if ((_action.isAction(0xD, 0)) || (_action.isAction(0x3, 0))) {
+		if (_action.isAction(0x185, 0)) {
+			_globals._frameTime = 0xD8F1;
+			_globals._frameTime |= 0xFFFF0000;
+		} else if (_action.isAction(0x14D, 0)) {
+			_globals._v3 = 0xD8F1;
+			_globals._v4 = -1;
+		}
+	}
+}
+
+void Scene207::actions() {
+
 }
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 5346b34..6d25f5d 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -100,6 +100,17 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene207: public Scene2xx {
+public:
+	Scene207(MADSEngine *vm) : Scene2xx(vm) {}
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: c09bfdab2f00c888debb0e81d956fb0c2397ef9c
    https://github.com/scummvm/scummvm/commit/c09bfdab2f00c888debb0e81d956fb0c2397ef9c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-25T20:46:10+01:00

Commit Message:
MADS: Finish Scene 207

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index ed254a4..0e6e715 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1303,8 +1303,63 @@ void Scene207::preActions() {
 }
 
 void Scene207::actions() {
+	if (_action._savedFields._lookFlag) {
+		Dialog::show(0x50E7);
+	} else {
+		if (_action.isAction(0x18B, 0x70, 0))
+			_scene->_nextSceneId = 214;
+		else {
+			if ((_game._player._playerPos.x > 150) && (_game._player._playerPos.x < 189) &&
+			    (_game._player._playerPos.y > 111) && (_game._player._playerPos.y < 130)) {
+				if ((_game._player._playerPos.x <= 162) && (_game._player._playerPos.x >= 181) &&
+				    (_game._player._playerPos.y <= 115) && (_game._player._playerPos.y >= 126)) {
+					_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 10, 2, 0, 0);
+					_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 2, 0, 0);
+					_scene->_sequences.setDepth(_globals._spriteIndexes[22], 6);
+					_scene->_sequences.setDepth(_globals._spriteIndexes[23], 6);
+				}
+			} else if (_globals._v2) {
+				_scene->_sequences.remove(_globals._spriteIndexes[22]);
+				_scene->_sequences.remove(_globals._spriteIndexes[23]);
+				_globals._v2 = 0;
+			}
 
+			if (_action.isAction(3, 0x69, 0)) {
+				Dialog::show(0x50DD);
+			} else if (_action.isAction(3, 0x1AF, 0)) {
+				Dialog::show(0x50DE);
+			} else if (_action.isAction(3, 0x141, 0)) {
+				Dialog::show(0x50DF);
+			} else if (_action.isAction(3, 0x3E, 0)) {
+				Dialog::show(0x50E0);
+			} else if (_action.isAction(3, 0x198, 0)) {
+				Dialog::show(0x50E1);
+			} else if (_action.isAction(3, 0x1AE, 0)) {
+				Dialog::show(0x50E2);
+			} else if (_action.isAction(3, 0xE8, 0)) {
+				Dialog::show(0x50E3);
+			} else if (_action.isAction(3, 0x12, 0)) {
+				Dialog::show(0x50E4);
+			} else if (_action.isAction(3, 0x1AC, 0)) {
+				Dialog::show(0x50E5);
+			} else if (_action.isAction(3, 0x185, 0)) {
+				Dialog::show(0x50E6);
+			} else if (_action.isAction(4, 0x141, 0)) {
+				Dialog::show(0x50E8);
+			} else if (_action.isAction(4, 0x12, 0)) {
+				Dialog::show(0x50E9);
+			} else if (_action.isAction(3, 0x14D, 0)) {
+				Dialog::show(0x50EA);
+			} else if (_action.isAction(4, 0x14D, 0)) {
+				Dialog::show(0x50EB);
+			} else
+				return;
+		}
+	}
+	_action._inProgress = false;
 }
 
+/*****************************************************************************/
+
 } // End of namespace Nebular
 } // End of namespace MADS


Commit: 633da299f694a9998a0cdb002a08613750f36e61
    https://github.com/scummvm/scummvm/commit/633da299f694a9998a0cdb002a08613750f36e61
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-25T22:01:25+01:00

Commit Message:
MADS: Add scene 208

Changed paths:
    engines/mads/game.h
    engines/mads/messages.h
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/game.h b/engines/mads/game.h
index bf81c23..c5a3dd3 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -62,7 +62,6 @@ private:
 protected:
 	MADSEngine *_vm;
 	MSurface *_surface;
-	Difficulty _difficultyLevel;
 	int _saveSlot;
 	int _statusFlag;
 	Common::StringArray _quotes;
@@ -110,9 +109,11 @@ protected:
 
 public:
 	static Game *init(MADSEngine *vm);
+
 public:
 	Player _player;
 	ScreenObjects _screenObjects;
+	Difficulty _difficultyLevel;
 	int _sectionNumber;
 	int _priorSectionNumber;
 	int _currentSectionNumber;
diff --git a/engines/mads/messages.h b/engines/mads/messages.h
index 90269c1..03a4e01 100644
--- a/engines/mads/messages.h
+++ b/engines/mads/messages.h
@@ -68,8 +68,8 @@ class KernelMessages {
 private:
 	MADSEngine *_vm;
 	Common::Array<KernelMessage> _entries;
-	Font *_talkFont;
 public:
+	Font *_talkFont;
 	KernelMessages(MADSEngine *vm);
 	~KernelMessages();
 
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 0f35e5d..39a8ed5 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -61,6 +61,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene205(vm);
 	case 207:
 		return new Scene207(vm);
+	case 208:
+		return new Scene208(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 0e6e715..c4fee2b 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1361,5 +1361,186 @@ void Scene207::actions() {
 
 /*****************************************************************************/
 
+void Scene208::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x1A8);
+	_scene->addActiveVocab(0x1A9);
+	_scene->addActiveVocab(0x1AA);
+	_scene->addActiveVocab(NOUN_D);
+}
+
+void Scene208::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('a', 1), 0);
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 0), 0);
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 1), 0);
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 2), 0);
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RXMBD_8");
+
+	warning("TODO: sub34648()");
+
+	_globals._v0 = 0;
+	_globals._frameTime = 0;
+	_scene->_kernelMessages._talkFont = _vm->_font->getFont(FONT_INTERFACE);
+	_scene->_textSpacing = 0;
+
+	if (_scene->_priorSceneId == 207) {
+		_game._player._playerPos = Common::Point(8, 122);
+		_game._player._direction = 6;
+	} else if (_scene->_priorSceneId == 203) {
+		_game._player._playerPos = Common::Point(142, 108);
+		_game._player._direction = 2;
+	} else if (_scene->_priorSceneId == 209) {
+		_game._player._playerPos = Common::Point(307, 123);
+		_game._player._direction = 4;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(162, 149);
+		_game._player._direction = 8;
+	}
+
+	_game.loadQuoteSet(0x81, 0x46, 0);
+
+	if ((_scene->_priorSceneId == 207) && (_globals[36] == 1)) {
+		int msgIndex = _scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(129));
+		_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+	}
+
+	_vm->_palette->setEntry(16, 0, 0, 63);
+	_vm->_palette->setEntry(17, 0, 0, 45);
+	sceneEntrySound();
+}
+
+void Scene208::step() {
+	if ((_globals._frameTime & 0xFFFF)  && ((_globals._frameTime >> 16) <= _scene->_activeAnimation->getCurrentFrame())) {
+		_globals._frameTime = (_globals._frameTime & 0xFFFF) | (_scene->_activeAnimation->getCurrentFrame() << 16);
+
+		if (_scene->_activeAnimation->getCurrentFrame() == 125)
+			_scene->_sequences.remove(_globals._spriteIndexes[19]);
+	}
+
+	if (_globals._v0 == 0)
+		return;
+
+	if ((_game._player._playerPos != Common::Point(20, 148)) || (_game._player._direction != 6))
+		return;
+
+	if ((_game._abortTimers == 0) && ((_globals._frameTime & 0xFFFF) != 0))
+		return;
+	
+	_globals._frameTime |= 0xFFFF;
+	
+	if (_game._abortTimers == 82) {
+		_game._player._stepEnabled = true;
+		return;
+	}
+	
+	if (_game._abortTimers > 82)
+		return;
+	
+	if (_game._abortTimers & 0xFF) {
+		if ((_game._abortTimers & 0xFF) == 81) {
+			_scene->_sequences.remove(_globals._spriteIndexes[15]);
+			_globals[34] = 1;
+			warning("TODO: sub34648(...)");
+			_scene->_sequences.addTimer(90, 82);
+		}
+	} else {
+		_scene->loadAnimation(formAnimName('A', -1), 81);
+	}
+}
+
+void Scene208::preActions() {
+	if (_action.isAction(3, 0) && _action._walkFlag)
+		_action._startWalkFlag = true;
+
+	if (_action.isAction(0x18C, 0x9B, 0))
+		_game._player._v844BE = 209;
+
+	if (_action.isAction(0x18C, 0xF6, 0))
+		_game._player._v844BE = 207;
+}
+
+void Scene208::actions() {
+	if (_action.isAction(0x18C, 0x19F, 0)) {
+		if (_globals[34])
+			_scene->_nextSceneId = 203;
+		else if (_game._abortTimers == 0) {
+			_game._player._stepEnabled = false;
+			int msgIndex = _scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 1, 120, _game.getQuote(70));
+			_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+		} else if (_game._abortTimers == 1) {
+			_scene->_nextSceneId = 203;
+		}
+	} else if (_action.isAction(0x18C, 0x83, 0)) {
+		_scene->_nextSceneId = 212;
+	} else if (_action.isAction(0x4, 0x1AA, 0) && (!_globals[35] || _game._abortTimers)) {
+		warning("TODO: sub3B282(1);");
+		if (_game._player._stepEnabled)
+			_vm->_dialogs->showPicture(OBJ_BIG_LEAVES, 0x326, 0);
+	} else if (_action.isAction(0x7, 0x23, 0x19E) && (_globals[35] == 1 || _game._abortTimers)) {
+		warning("TODO: sub3B282(2);");
+	} else if (_action.isAction(0x7, 0x17A, 0x1A9)) {
+		warning("TODO: sub3B282(3);");
+		if (_game._player._stepEnabled) {
+			_game._player._stepEnabled = false;
+			_globals._v0 = true;
+			_game._player.startWalking(Common::Point(20, 148), 6);
+		}
+	} else if (_action.isAction(0x7, 0x35, 0x1A9)) {
+		warning("TODO: sub3B282(4);");
+		if (_game._player._stepEnabled) {
+			Dialog::show(0x514C);
+		}
+	} else if (_action.isAction(0x7, 0x65, 0x1A9)) {
+		warning("TODO: sub3B282(5);");
+		if (_game._player._stepEnabled) {
+			Dialog::show(0x514C);
+		}
+	} else if (_action.isAction(0x3, 0x5D, 0)) {
+		Dialog::show(0x5141);
+	} else if (_action.isAction(0x3, 0xF6, 0)) {
+		Dialog::show(0x5142);
+	} else if (_action.isAction(0x3, 0x16F, 0)) {
+		Dialog::show(0x5143);
+	} else if (_action.isAction(0x3, 0x129, 0)) {
+		Dialog::show(0x5144);
+	} else if (_action.isAction(0x3, 0x1A1, 0)) {
+		Dialog::show(0x5145);
+	} else if (_action.isAction(0x4, 0x1A1, 0)) {
+		Dialog::show(0x5146);
+	} else if (_action.isAction(0x3, 0x9B, 0)) {
+		Dialog::show(0x5147);
+	} else if (_action.isAction(0x3, 0x19E, 0)) {
+		Dialog::show(0x5148);
+	} else if (_action.isAction(0x3, 0x1AA, 0)) {
+		Dialog::show(0x5149);
+	} else if (_action.isAction(0x3, 0x1A9, 0)) {
+		if (_game._difficultyLevel == DIFFICULTY_EASY)
+			Dialog::show(0x514A);
+		else
+			Dialog::show(0x514B);
+	} else if (_action.isAction(0x3, 0x174, 0) || _action.isAction(0x3, 0x175, 0)) {
+		Dialog::show(0x514D);
+	} else if (_action.isAction(0x4, 0x1A9, 0)) {
+		Dialog::show(0x514E);
+	} else if (_action.isAction(0x3, 0x1A8, 0)) {
+		Dialog::show(0x514F);
+	} else if (_action.isAction(0x4, 0x1A8, 0) || _action.isAction(0xA, 0x1A8, 0)) {
+		Dialog::show(0x5150);
+	} else if (_action._savedFields._lookFlag == 0) {
+		return;
+	} else if (_globals[34] == 1) {
+		Dialog::show(0x5153);
+	} else if (_globals[35] == 2) {
+		Dialog::show(0x5152);
+	} else {
+		Dialog::show(0x5151);
+	}
+
+	_action._inProgress = false;
+}
+
+/*****************************************************************************/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 6d25f5d..7a5af6f 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -111,6 +111,18 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene208: public Scene2xx {
+public:
+	Scene208(MADSEngine *vm) : Scene2xx(vm) {}
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: e9977e81d0c3ab13d934755e37a93f62b78a65cb
    https://github.com/scummvm/scummvm/commit/e9977e81d0c3ab13d934755e37a93f62b78a65cb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-25T21:20:44-04:00

Commit Message:
MADS: Fixes and cleanup for palette loading

Changed paths:
    engines/mads/assets.cpp
    engines/mads/palette.cpp
    engines/mads/palette.h
    engines/mads/staticres.cpp
    engines/mads/staticres.h
    engines/mads/user_interface.cpp



diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index a84d194..02b91aa 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -84,10 +84,15 @@ void SpriteAsset::load(Common::SeekableReadStream *stream, int flags) {
 	palette.resize(numColors);
 	for (int i = 0; i < numColors; ++i)
 		palette[i].load(palStream);
+	delete palStream;
 
 	// Process the palette data
-	_vm->_palette->_paletteUsage.process(palette, flags);
-	delete palStream;
+	if (flags & 9) {
+		warning("TODO: Unknown palette processing");
+	} else {
+		_usageIndex = _vm->_palette->_paletteUsage.process(palette, flags);
+		assert(_usageIndex >= 0);
+	}
 
 	spriteStream = sprite.getItemStream(1);
 	Common::SeekableReadStream *spriteDataStream = sprite.getItemStream(3);
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index f57766e..94ce52e 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -25,6 +25,7 @@
 #include "graphics/palette.h"
 #include "mads/mads.h"
 #include "mads/msurface.h"
+#include "mads/staticres.h"
 
 namespace MADS {
 
@@ -464,54 +465,19 @@ void Palette::initPalette() {
 	_rgbList.reset();
 }
 
-const uint32 DEFAULT_VGA_PALETTE[PALETTE_COUNT] = {
-	0x000000, 0x0000a8, 0x00a800, 0x00a8a8, 0xa80000, 0xa800a8, 0xa85400, 0xa8a8a8,
-	0x545454, 0x5454fc, 0x54fc54, 0x54fcfc, 0xfc5454, 0xfc54fc, 0xfcfc54, 0xfcfcfc,
-	0x000000, 0x141414, 0x202020, 0x2c2c2c, 0x383838, 0x444444, 0x505050, 0x606060,
-	0x707070, 0x808080, 0x909090, 0xa0a0a0, 0xb4b4b4, 0xc8c8c8, 0xe0e0e0, 0xfcfcfc,
-	0x0000fc, 0x4000fc, 0x7c00fc, 0xbc00fc, 0xfc00fc, 0xfc00bc, 0xfc007c, 0xfc0040,
-	0xfc0000, 0xfc4000, 0xfc7c00, 0xfcbc00, 0xfcfc00, 0xbcfc00, 0x7cfc00, 0x40fc00,
-	0x00fc00, 0x00fc40, 0x00fc7c, 0x00fcbc, 0x00fcfc, 0x00bcfc, 0x007cfc, 0x0040fc,
-	0x7c7cfc, 0x9c7cfc, 0xbc7cfc, 0xdc7cfc, 0xfc7cfc, 0xfc7cdc, 0xfc7cbc, 0xfc7c9c,
-	0xfc7c7c, 0xfc9c7c, 0xfcbc7c, 0xfcdc7c, 0xfcfc7c, 0xdcfc7c, 0xbcfc7c, 0x9cfc7c,
-	0x7cfc7c, 0x7cfc9c, 0x7cfcbc, 0x7cfcdc, 0x7cfcfc, 0x7cdcfc, 0x7cbcfc, 0x7c9cfc,
-	0xb4b4fc, 0xc4b4fc, 0xd8b4fc, 0xe8b4fc, 0xfcb4fc, 0xfcb4e8, 0xfcb4d8, 0xfcb4c4,
-	0xfcb4b4, 0xfcc4b4, 0xfcd8b4, 0xfce8b4, 0xfcfcb4, 0xe8fcb4, 0xd8fcb4, 0xc4fcb4,
-	0xb4fcb4, 0xb4fcc4, 0xb4fcd8, 0xb4fce8, 0xb4fcfc, 0xb4e8fc, 0xb4d8fc, 0xb4c4fc,
-	0x000070, 0x1c0070, 0x380070, 0x540070, 0x700070, 0x700054, 0x700038, 0x70001c,
-	0x700000, 0x701c00, 0x703800, 0x705400, 0x707000, 0x547000, 0x387000, 0x1c7000,
-	0x007000, 0x00701c, 0x007038, 0x007054, 0x007070, 0x005470, 0x003870, 0x001c70,
-	0x383870, 0x443870, 0x543870, 0x603870, 0x703870, 0x703860, 0x703854, 0x703844,
-	0x703838, 0x704438, 0x705438, 0x706038, 0x707038, 0x607038, 0x547038, 0x447038,
-	0x387038, 0x387044, 0x387054, 0x387060, 0x387070, 0x386070, 0x385470, 0x384470,
-	0x505070, 0x585070, 0x605070, 0x685070, 0x705070, 0x705068, 0x705060, 0x705058,
-	0x705050, 0x705850, 0x706050, 0x706850, 0x707050, 0x687050, 0x607050, 0x587050,
-	0x507050, 0x507058, 0x507060, 0x507068, 0x507070, 0x506870, 0x506070, 0x505870,
-	0x000040, 0x100040, 0x200040, 0x300040, 0x400040, 0x400030, 0x400020, 0x400010,
-	0x400000, 0x401000, 0x402000, 0x403000, 0x404000, 0x304000, 0x204000, 0x104000,
-	0x004000, 0x004010, 0x004020, 0x004030, 0x004040, 0x003040, 0x002040, 0x001040,
-	0x202040, 0x282040, 0x302040, 0x382040, 0x402040, 0x402038, 0x402030, 0x402028,
-	0x402020, 0x402820, 0x403020, 0x403820, 0x404020, 0x384020, 0x304020, 0x284020,
-	0x204020, 0x204028, 0x204030, 0x204038, 0x204040, 0x203840, 0x203040, 0x202840,
-	0x2c2c40, 0x302c40, 0x342c40, 0x3c2c40, 0x402c40, 0x402c3c, 0x402c34, 0x402c30,
-	0x402c2c, 0x40302c, 0x40342c, 0x403c2c, 0x40402c, 0x3c402c, 0x34402c, 0x30402c,
-	0x2c402c, 0x2c4030, 0x2c4034, 0x2c403c, 0x2c4040, 0x2c3c40, 0x2c3440, 0x2c3040,
-	0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000
-};
-
 void Palette::initVGAPalette(byte *palette) {
 	byte *destP = palette;
-	for (int palIndex = 0; palIndex < PALETTE_COUNT; ++palIndex) {
+	for (int palIndex = 0; palIndex < 16; ++palIndex) {
 		for (int byteCtr = 2; byteCtr >= 0; --byteCtr)
 			*destP++ = ((DEFAULT_VGA_PALETTE[palIndex] >> (8 * byteCtr)) & 0xff) >> 2;
 	}
 }
 
 void Palette::setLowRange() {
-	_mainPalette[0] = _mainPalette[1] = _mainPalette[2] = 0; 
-	_mainPalette[3] = _mainPalette[4] = _mainPalette[5] = 0x15; 
-	_mainPalette[6] = _mainPalette[7] = _mainPalette[8] = 0x2A; 
-	_mainPalette[9] = _mainPalette[10] = _mainPalette[11] = 0x3F; 
+	_mainPalette[0] = _mainPalette[1] = _mainPalette[2] = VGA_COLOR_TRANS(0);
+	_mainPalette[3] = _mainPalette[4] = _mainPalette[5] = VGA_COLOR_TRANS(0x15);
+	_mainPalette[6] = _mainPalette[7] = _mainPalette[8] = VGA_COLOR_TRANS(0x2A);
+	_mainPalette[9] = _mainPalette[10] = _mainPalette[11] = VGA_COLOR_TRANS(0x3F);
 	_vm->_palette->setPalette(_mainPalette, 0, 4);
 }
 
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 2fdb386..0f04230 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -32,7 +32,7 @@ class MADSEngine;
 
 #define PALETTE_USAGE_COUNT 4
 
-#define VGA_COLOR_TRANS(x) (((((int)(x)) + 1) << 2) - 1)
+#define VGA_COLOR_TRANS(x) ((x) * 255 / 63)
 
 struct RGB4 {
 	byte r;
@@ -134,7 +134,8 @@ public:
 class Palette {
 private:
 	/**
-	 * Initialises a stanadrd VGA palette
+	 * Initialises the first 16 palette indexes with the equivalent
+	 * standard VGA palette
 	 */
 	void initVGAPalette(byte *palette);
 protected:
diff --git a/engines/mads/staticres.cpp b/engines/mads/staticres.cpp
index d57222c..92d2740 100644
--- a/engines/mads/staticres.cpp
+++ b/engines/mads/staticres.cpp
@@ -46,4 +46,9 @@ const char *const kOverStr = "over";
 const char *const kGameReleaseInfoStr = "ScummVM rev: 8.43 14-Sept-92";
 const char *const kGameReleaseTitleStr = "GAME RELASE VERSION INFO";
 
+const uint32 DEFAULT_VGA_PALETTE[16] = {
+	0x000000, 0x0000a8, 0x00a800, 0x00a8a8, 0xa80000, 0xa800a8, 0xa85400, 0xa8a8a8,
+	0x545454, 0x5454fc, 0x54fc54, 0x54fcfc, 0xfc5454, 0xfc54fc, 0xfcfc54, 0xfcfcfc
+};
+
 } // End of namespace MADS
diff --git a/engines/mads/staticres.h b/engines/mads/staticres.h
index 5aaa331..b4132c8 100644
--- a/engines/mads/staticres.h
+++ b/engines/mads/staticres.h
@@ -40,6 +40,8 @@ extern const char *const kOverStr;
 extern const char *const kGameReleaseInfoStr;
 extern const char *const kGameReleaseTitleStr;
 
+extern const uint32 DEFAULT_VGA_PALETTE[16];
+
 } // End of namespace MADS
 
 #endif /* MADS_STATICRES_H */
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index b45ff14..05e9b70 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -224,11 +224,12 @@ void UserInterface::load(const Common::String &resName) {
 	byte *palP = &_vm->_palette->_mainPalette[0];
 
 	for (int i = 0; i < 16; ++i, gamePalP++, palP += 3) {
-		palP[0] = VGA_COLOR_TRANS(palStream->readByte());
-		palP[1] = VGA_COLOR_TRANS(palStream->readByte());
-		palP[2] = VGA_COLOR_TRANS(palStream->readByte());
+		RGB6 rgb;
+		rgb.load(palStream);
+		palP[0] = rgb.r;
+		palP[1] = rgb.g;
+		palP[2] = rgb.b;
 		*gamePalP |= 1;
-		palStream->skip(3);
 	}
 	delete palStream;
 


Commit: 7b15d2e379ce6ecfc131db803fbe704caaf8d385
    https://github.com/scummvm/scummvm/commit/7b15d2e379ce6ecfc131db803fbe704caaf8d385
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-25T22:06:21-04:00

Commit Message:
MADS: Moved palette translation define into source file

Changed paths:
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 94ce52e..311bd63 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -29,6 +29,8 @@
 
 namespace MADS {
 
+#define VGA_COLOR_TRANS(x) ((x) * 255 / 63)
+
 void RGB6::load(Common::SeekableReadStream *f) {
 	r = VGA_COLOR_TRANS(f->readByte());
 	g = VGA_COLOR_TRANS(f->readByte());
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 0f04230..ae29d18 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -32,8 +32,6 @@ class MADSEngine;
 
 #define PALETTE_USAGE_COUNT 4
 
-#define VGA_COLOR_TRANS(x) ((x) * 255 / 63)
-
 struct RGB4 {
 	byte r;
 	byte g;


Commit: 407021d245f1e0446867824c6306337f18fe8eb3
    https://github.com/scummvm/scummvm/commit/407021d245f1e0446867824c6306337f18fe8eb3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-25T22:07:33-04:00

Commit Message:
MADS: Added a Facing enum for the player directions

Changed paths:
    engines/mads/action.cpp
    engines/mads/game.cpp
    engines/mads/hotspots.cpp
    engines/mads/hotspots.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/player.cpp
    engines/mads/player.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 0c20fec..ca29527 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -305,13 +305,13 @@ void MADSAction::startAction() {
 			if ((hs._feetPos.x == -1) || (hs._feetPos.x == -3)) {
 				checkCustomDest(hs._feetPos.x);
 			} else if (hs._feetPos.x == 0) {
-				scene._destFacing = hs._facing;
+				scene._targetFacing = hs._facing;
 			} else if (_savedFields._actionMode == ACTIONMODE_NONE || hs._cursor >= CURSOR_WAIT) {
 				_startWalkFlag = true;
 				scene._destPos = hs._feetPos;
 			}
 
-			scene._destFacing = hs._facing;
+			scene._targetFacing = hs._facing;
 			hotspotId = -1;
 		}
 	}
@@ -328,7 +328,7 @@ void MADSAction::startAction() {
 			}
 		}
 
-		scene._destFacing = hs._facing;
+		scene._targetFacing = hs._facing;
 	}
 
 	_walkFlag = _startWalkFlag;
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index f155bc8..6e7c530 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -230,7 +230,7 @@ void Game::sectionLoop() {
 		// Set player data
 		_player._destPos = _player._playerPos;
 		_player._newDirection = _player._direction;
-		_player._destFacing = _player._direction;
+		_player._targetFacing = _player._direction;
 		_player.setupFrame();
 		_player.updateFrame();
 		_player._visible3 = _player._visible;
diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
index e082a1e..22e4feb 100644
--- a/engines/mads/hotspots.cpp
+++ b/engines/mads/hotspots.cpp
@@ -27,7 +27,7 @@ namespace MADS {
 
 DynamicHotspot::DynamicHotspot() {
 	_seqIndex = 0;
-	_facing = 0;
+	_facing = FACING_NONE;
 	_descId = 0;
 	_vocabId = 0;
 	_articleNumber = 0;
@@ -61,7 +61,7 @@ int DynamicHotspots::add(int descId, int vocabId, int seqIndex, const Common::Re
 	_entries[idx]._bounds = bounds;
 	_entries[idx]._feetPos.x = -3;
 	_entries[idx]._feetPos.y = 0;
-	_entries[idx]._facing = 5;
+	_entries[idx]._facing = FACING_NONE;
 	_entries[idx]._vocabId = vocabId;
 	_entries[idx]._articleNumber = 6;
 	_entries[idx]._cursor = CURSOR_NONE;
@@ -75,7 +75,7 @@ int DynamicHotspots::add(int descId, int vocabId, int seqIndex, const Common::Re
 	return idx;
 }
 
-int DynamicHotspots::setPosition(int index, int xp, int yp, int facing) {
+int DynamicHotspots::setPosition(int index, int xp, int yp, Facing facing) {
 	if (index >= 0) {
 		_entries[index]._feetPos.x = xp;
 		_entries[index]._feetPos.y = yp;
@@ -147,7 +147,7 @@ void DynamicHotspots::refresh() {
 /*------------------------------------------------------------------------*/
 
 Hotspot::Hotspot() {
-	_facing = 0;
+	_facing = FACING_NONE;
 	_articleNumber = 0;
 	_cursor = CURSOR_NONE;
 	_vocabId = 0;
@@ -162,7 +162,7 @@ Hotspot::Hotspot(Common::SeekableReadStream &f) {
 	_bounds.bottom = f.readSint16LE();
 	_feetPos.x = f.readSint16LE();
 	_feetPos.y = f.readSint16LE();
-	_facing = f.readByte();
+	_facing = (Facing)f.readByte();
 	_articleNumber = f.readByte();
 	_active = f.readByte() != 0;
 	_cursor = (CursorType)f.readByte();
diff --git a/engines/mads/hotspots.h b/engines/mads/hotspots.h
index 37c37fa..a36993f 100644
--- a/engines/mads/hotspots.h
+++ b/engines/mads/hotspots.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "mads/events.h"
+#include "mads/player.h"
 
 namespace MADS {
 
@@ -36,7 +37,7 @@ public:
 	int _seqIndex;
 	Common::Rect _bounds;
 	Common::Point _feetPos;
-	int _facing;
+	Facing _facing;
 	int _descId;
 	int _vocabId;
 	int _articleNumber;
@@ -60,7 +61,7 @@ public:
 	Common::Array<MADS::DynamicHotspot>::size_type size() const { return _entries.size(); }
 	DynamicHotspot &operator[](uint idx) { return _entries[idx]; }
 	int add(int descId, int vocabId, int seqIndex, const Common::Rect &bounds);
-	int setPosition(int index, int xp, int yp, int facing);
+	int setPosition(int index, int xp, int yp, Facing facing);
 	int setCursor(int index, CursorType cursor);
 	void remove(int index);
 	void clear();
@@ -72,7 +73,7 @@ class Hotspot {
 public:
 	Common::Rect _bounds;
 	Common::Point _feetPos;
-	int _facing;
+	Facing _facing;
 	int _articleNumber;
 	bool _active;
 	CursorType _cursor;
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 76ea1f5..f452746 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -146,8 +146,8 @@ void GameNebular::initialiseGlobals() {
 		break;
 	}
 
-	_player._direction = 8;
-	_player._newDirection = 8;
+	_player._direction = FACING_NORTH;
+	_player._newDirection = FACING_NORTH;
 
 	loadResourceSequence("RXM", 1);
 	loadResourceSequence("ROX", 1);
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index c4fee2b..4cec40c 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -144,7 +144,7 @@ void Scene201::enter() {
 	_scene->_sequences.setMsgPosition(_globals._spriteIndexes[19], Common::Point(185, 46));
 
 	int idx = _scene->_dynamicHotspots.add(1159, 209, _globals._spriteIndexes[19], Common::Rect(0, 0, 0, 0));
-	_scene->_dynamicHotspots.setPosition(idx, 186, 81, 8);
+	_scene->_dynamicHotspots.setPosition(idx, 186, 81, FACING_NORTH);
 
 	_globals._v0 = 0;
 
@@ -152,7 +152,7 @@ void Scene201::enter() {
 		_game._player._playerPos = Common::Point(165, 152);
 	} else {
 		_game._player._playerPos = Common::Point(223, 149);
-		_game._player._direction = 2;
+		_game._player._direction = FACING_SOUTH;
 	}
 
 	if (_globals[39] != 0) {
@@ -197,7 +197,7 @@ void Scene201::enter() {
 		_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_FRAME_INDEX, 12, 70);
 		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 1);
 		_globals._frameTime = 0;
-		_game._player.startWalking(Common::Point(157, 143), 8);
+		_game._player.startWalking(Common::Point(157, 143), FACING_NORTH);
 		_vm->_palette->setEntry(252, 45, 63, 45);
 		_vm->_palette->setEntry(253, 20, 45, 20);
 		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 2, 0, 120, _game.getQuote(90));
@@ -214,7 +214,7 @@ void Scene201::step() {
 	if ((_globals._frameTime) && (_vm->getRandomNumber(5000) == 9)) {
 		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 5, 1, 6, 0);
 		int idx = _scene->_dynamicHotspots.add(351, 13, _globals._spriteIndexes[20], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 270, 80, 6);
+		_scene->_dynamicHotspots.setPosition(idx, 270, 80, FACING_EAST);
 		_scene->_sequences.setDepth(_globals._spriteIndexes[20], 8);
 		_vm->_sound->command(14);
 		_globals._frameTime = 0;
@@ -368,14 +368,14 @@ void Scene202::enter() {
 	_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(149, 113));
 	_scene->_sequences.setDepth(_globals._spriteIndexes[17], 10);
 	int idx = _scene->_dynamicHotspots.add(320, 13, _globals._spriteIndexes[17], Common::Rect(0, 0, 0, 0));
-	_scene->_dynamicHotspots.setPosition(idx, 153, 97, 2);
+	_scene->_dynamicHotspots.setPosition(idx, 153, 97, FACING_SOUTH);
 
 	if (_globals[32] & 1) {
 		_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
 		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[16], Common::Point(130, 108));
 		_scene->_sequences.setDepth(_globals._spriteIndexes[16], 10);
 		idx = _scene->_dynamicHotspots.add(44, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 132, 97, 2);
+		_scene->_dynamicHotspots.setPosition(idx, 132, 97, FACING_SOUTH);
 	}
 
 	if (_globals[32] & 2) {
@@ -383,7 +383,7 @@ void Scene202::enter() {
 		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[21], Common::Point(166, 110));
 		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 10);
 		idx = _scene->_dynamicHotspots.add(44, 13, _globals._spriteIndexes[21], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 165, 99, 2);
+		_scene->_dynamicHotspots.setPosition(idx, 165, 99, FACING_SOUTH);
 	}
 
 	if (_globals[32])
@@ -391,10 +391,10 @@ void Scene202::enter() {
 
 	if (_scene->_priorSceneId == 201) {
 		_game._player._playerPos = Common::Point(190, 91);
-		_game._player._direction = 2;
+		_game._player._direction = FACING_SOUTH;
 	} else if (_scene->_priorSceneId != -2) {
 		_game._player._playerPos = Common::Point(178, 152);
-		_game._player._direction = 8;
+		_game._player._direction = FACING_NORTH;
 	}
 
 	if (_globals[31]) {
@@ -402,7 +402,7 @@ void Scene202::enter() {
 		_scene->_sequences.setDepth(_globals._spriteIndexes[20], 6);
 		_scene->_hotspots.activate(199, false);
 		idx = _scene->_dynamicHotspots.add(457, 13, _globals._spriteIndexes[20], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 246, 124, 8);
+		_scene->_dynamicHotspots.setPosition(idx, 246, 124, FACING_NORTH);
 	}
 
 	_game.loadQuoteSet(0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x62, 0x63, 0x64, 0x65, 0x66, 0x61, 0);
@@ -440,12 +440,12 @@ void Scene202::enter() {
 		if (_globals._v4) {
 			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(247, 82));
 			_game._player._playerPos = Common::Point(246, 124);
-			_game._player._direction = 8;
+			_game._player._direction = FACING_NORTH;
 			_globals[41] = -1;
 		} else {
 			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
 			_game._player._playerPos = Common::Point(171, 122);
-			_game._player._direction = 8;
+			_game._player._direction = FACING_NORTH;
 		}
 
 		_scene->loadAnimation(formAnimName('M', -1), 71);
@@ -456,7 +456,7 @@ void Scene202::enter() {
 		_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
 		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
 		_game._player._playerPos = Common::Point(246, 124);
-		_game._player._direction = 8;
+		_game._player._direction = FACING_NORTH;
 	}
 	_globals._abortVal = 0;
 }
@@ -540,7 +540,7 @@ void Scene202::step() {
 		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 0, 0, 0);
 		_scene->_hotspots.activate(199, false);
 		int idx = _scene->_dynamicHotspots.add(457, 13, _globals._spriteIndexes[20], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 246, 124, 8);
+		_scene->_dynamicHotspots.setPosition(idx, 246, 124, FACING_NORTH);
 		_scene->_sequences.updateTimeout(_globals._spriteIndexes[26], _globals._spriteIndexes[20]);
 		_scene->_sequences.updateTimeout(-1, _globals._spriteIndexes[26]);
 		_game._player._stepEnabled = true;
@@ -748,7 +748,7 @@ void Scene202::preActions() {
 			action->_startWalkFlag = true;
 
 		if (_globals._v4 == 0)
-			_game._player.startWalking(Common::Point(171, 122), 8);
+			_game._player.startWalking(Common::Point(171, 122), FACING_NORTH);
 	}
 }
 
@@ -815,7 +815,7 @@ void Scene202::actions() {
 
 				int idx = _scene->_dynamicHotspots.add(199, 79, -1, Common::Rect(241, 68, 12, 54));
 				warning("CHECKME: _globals._frameTime = _scene->_dynamicHotspots.setPosition(idx, 246, 124, 8);");
-				_globals._frameTime = _scene->_dynamicHotspots.setPosition(idx, 246, 124, 8);
+				_globals._frameTime = _scene->_dynamicHotspots.setPosition(idx, 246, 124, FACING_NORTH);
 				_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
 				_scene->_sequences.setDepth(_globals._spriteIndexes[23], 1);
 				_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 1);
@@ -986,13 +986,13 @@ void Scene203::setup() {
 void Scene203::enter() {
 	if (_scene->_priorSceneId == 202) {
 		_game._player._playerPos = Common::Point(187, 99);
-		_game._player._direction = 2;
+		_game._player._direction = FACING_SOUTH;
 	} else if (_scene->_priorSceneId == 209) {
 		_game._player._playerPos = Common::Point(308, 117);
-		_game._player._direction = 4;
+		_game._player._direction = FACING_WEST;
 	} else if (_scene->_priorSceneId == -2) {
 		_game._player._playerPos = Common::Point(155, 152);
-		_game._player._direction = 8;
+		_game._player._direction = FACING_NORTH;
 	}
 
 	_globals._v0 = 0;
@@ -1000,9 +1000,9 @@ void Scene203::enter() {
 
 	if ((_globals[34] == 0) && (_scene->_roomChanged == 0)) {
 		_globals._v0 = -1;
-		_game._player.startWalking(Common::Point(158, 135), 2);
+		_game._player.startWalking(Common::Point(158, 135), FACING_SOUTH);
 		int idx = _scene->_dynamicHotspots.add(131, 396, 0, Common::Rect(0, 0, 320, 156));
-		_scene->_dynamicHotspots.setPosition(idx, 155, 152, 2);
+		_scene->_dynamicHotspots.setPosition(idx, 155, 152, FACING_SOUTH);
 		_scene->_dynamicHotspots.setCursor(idx, CURSOR_GO_DOWN);
 	}
 
@@ -1011,7 +1011,7 @@ void Scene203::enter() {
 		if (_vm->getRandomNumber(1, 3) == 2) {
 			_globals._spriteIndexes[15] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 9, 1, 0, 0);
 			int idx = _scene->_dynamicHotspots.add(477, 209, _globals._spriteIndexes[15], Common::Rect(0, 0, 0, 0));
-			_scene->_dynamicHotspots.setPosition(idx, -2, 0, 0);
+			_scene->_dynamicHotspots.setPosition(idx, -2, 0, FACING_NONE);
 			_vm->_sound->command(14);
 		}
 	}
@@ -1053,7 +1053,7 @@ void Scene203::step() {
 
 void Scene203::preActions() {
 	if (_globals._v0 && !_action.isAction(0x18C, 0x83, 0)) {
-		_game._player.startWalking(Common::Point(158, 136), 2);
+		_game._player.startWalking(Common::Point(158, 136), FACING_SOUTH);
 		_action._inProgress = false;
 		return;
 	}
@@ -1110,11 +1110,11 @@ void Scene205::enter() {
 
 	_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 10, 0, 0, 3);
 	int idx = _scene->_dynamicHotspots.add(73, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
-	_scene->_dynamicHotspots.setPosition(idx, 162, 120, 9);
+	_scene->_dynamicHotspots.setPosition(idx, 162, 120, FACING_NORTHEAST);
 
 	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 15, 0, 0, 0);
 	idx = _scene->_dynamicHotspots.add(73, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
-	_scene->_dynamicHotspots.setPosition(idx, 162, 120, 9);
+	_scene->_dynamicHotspots.setPosition(idx, 162, 120, FACING_NORTHEAST);
 
 	_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 9, 0, 0, 0);
 	_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 0, 0, 0);
@@ -1125,7 +1125,7 @@ void Scene205::enter() {
 		_globals._v3 = _scene->_frameStartTime >> 16;
 		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 7, 1, 0, 0);
 		idx = _scene->_dynamicHotspots.add(269, 13, _globals._spriteIndexes[21], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 49, 86, 8);
+		_scene->_dynamicHotspots.setPosition(idx, 49, 86, FACING_NORTH);
 	}
 
 	if (_game._objects[12]._roomNumber == 0) {
@@ -1224,7 +1224,7 @@ void Scene207::enter() {
 		_globals._frameTime = _game._player._priorTimer;
 
 		int idx = _scene->_dynamicHotspots.add(389, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 254, 94, 4);
+		_scene->_dynamicHotspots.setPosition(idx, 254, 94, FACING_WEST);
 	}
 
 	if (_globals._v5) {
@@ -1233,16 +1233,16 @@ void Scene207::enter() {
 		_globals._v3 = _game._player._priorTimer & 0xFFFF;
 		_globals._v4 = _game._player._priorTimer >> 16;
 		int idx = _scene->_dynamicHotspots.add(333, 13, _globals._spriteIndexes[19], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 59, 132, 2);
+		_scene->_dynamicHotspots.setPosition(idx, 59, 132, FACING_SOUTH);
 	}
 
 	_globals._v2 = 0;
 	if (_scene->_priorSceneId == 211) {
 		_game._player._playerPos = Common::Point(13, 105);
-		_game._player._direction = 6;
+		_game._player._direction = FACING_EAST;
 	} else if (_scene->_priorSceneId == 214) {
 		_game._player._playerPos = Common::Point(164, 117);
-		_game._player._direction = 2;
+		_game._player._direction = FACING_SOUTH;
 	} else if (_scene->_priorSceneId != -2) {
 		_game._player._playerPos = Common::Point(305, 131);
 	}
@@ -1386,16 +1386,16 @@ void Scene208::enter() {
 
 	if (_scene->_priorSceneId == 207) {
 		_game._player._playerPos = Common::Point(8, 122);
-		_game._player._direction = 6;
+		_game._player._direction = FACING_EAST;
 	} else if (_scene->_priorSceneId == 203) {
 		_game._player._playerPos = Common::Point(142, 108);
-		_game._player._direction = 2;
+		_game._player._direction = FACING_SOUTH;
 	} else if (_scene->_priorSceneId == 209) {
 		_game._player._playerPos = Common::Point(307, 123);
-		_game._player._direction = 4;
+		_game._player._direction = FACING_WEST;
 	} else if (_scene->_priorSceneId != -2) {
 		_game._player._playerPos = Common::Point(162, 149);
-		_game._player._direction = 8;
+		_game._player._direction = FACING_NORTH;
 	}
 
 	_game.loadQuoteSet(0x81, 0x46, 0);
@@ -1484,7 +1484,7 @@ void Scene208::actions() {
 		if (_game._player._stepEnabled) {
 			_game._player._stepEnabled = false;
 			_globals._v0 = true;
-			_game._player.startWalking(Common::Point(20, 148), 6);
+			_game._player.startWalking(Common::Point(20, 148), FACING_EAST);
 		}
 	} else if (_action.isAction(0x7, 0x35, 0x1A9)) {
 		warning("TODO: sub3B282(4);");
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 1e886ae..03d03cb 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -34,9 +34,9 @@ const int Player::_directionListIndexes[32] = {
 
 Player::Player(MADSEngine *vm): _vm(vm) {
 	_action = nullptr;
-	_direction = 8;
-	_newDirection = 8;
-	_destFacing = 0;
+	_direction = FACING_NORTH;
+	_newDirection = FACING_NORTH;
+	_targetFacing = FACING_NORTH;
 	_spritesLoaded = false;
 	_spritesStart = 0;
 	_spritesIdx = 0;
@@ -72,7 +72,7 @@ Player::Player(MADSEngine *vm): _vm(vm) {
 void Player::reset() {
 	_action = &_vm->_game->_scene._action;
 	_destPos = _playerPos;
-	_destFacing = 5;
+	_targetFacing = FACING_NONE;
 	_newDirection = _direction;
 	_moving = false;
 	_newSceneId = _v844BE = 0;
@@ -132,8 +132,8 @@ bool Player::loadSprites(const Common::String &prefix) {
 }
 
 void Player::turnToDestFacing() {
-	if (_destFacing != 5)
-		_newDirection = _destFacing;
+	if (_targetFacing != 5)
+		_newDirection = _targetFacing;
 }
 
 void Player::dirChanged() {
@@ -165,7 +165,8 @@ void Player::dirChanged() {
 	if (diff == 0)
 		diff = newDir - newDir2;
 
-	_direction = (diff >= 0) ? _directionListIndexes[_direction + 20] : _directionListIndexes[_direction + 10];
+	_direction = (diff >= 0) ? (Facing)_directionListIndexes[_direction + 20] : 
+		(Facing)_directionListIndexes[_direction + 10];
 	setupFrame();
 	if ((_direction == _newDirection) && !_moving)
 		updateFrame();
@@ -330,13 +331,13 @@ void Player::resetActionList() {
 	_unk3 = 0;
 }
 
-void Player::setDest(const Common::Point &pt, int facing) {
+void Player::setDest(const Common::Point &pt, Facing facing) {
 	Scene &scene = _vm->_game->_scene;
 
 	resetActionList();
 	setTicksAmount();
 	_moving = true;
-	_destFacing = facing;
+	_targetFacing = facing;
 
 	scene._sceneInfo->setRouteNode(scene._sceneInfo->_nodes.size() - 2,
 		_playerPos, scene._depthSurface);
@@ -359,14 +360,14 @@ void Player::setDest(const Common::Point &pt, int facing) {
 	}
 }
 
-void Player::startWalking(const Common::Point &pos, int direction) {
+void Player::startWalking(const Common::Point &pos, Facing direction) {
 	Scene &scene = _vm->_game->_scene;
 
 	reset();
 	scene._action._startWalkFlag = true;
 	scene._action._walkFlag = true;
 	scene._destPos = pos;
-	scene._destFacing = direction;
+	scene._targetFacing = direction;
 }
 
 void Player::nextFrame() {
@@ -716,14 +717,14 @@ void Player::startMovement() {
 
 	switch (majorDir) {
 	case 1:
-		_newDirection = (_yDirection <= 0) ? 8 : 2;
+		_newDirection = (_yDirection <= 0) ? FACING_NORTH : FACING_SOUTH;
 		break;
 	case 2: {
-				_newDirection = ((_yDirection <= 0) ? 9 : 3) - ((_xDirection <= 0) ? 2 : 0);
-				break;
+		_newDirection = (Facing)(((_yDirection <= 0) ? 9 : 3) - ((_xDirection <= 0) ? 2 : 0));
+		break;
 	}
 	case 3:
-		_newDirection = (_xDirection <= 0) ? 4 : 6;
+		_newDirection = (_xDirection <= 0) ? FACING_WEST : FACING_EAST;
 		break;
 	default:
 		break;
diff --git a/engines/mads/player.h b/engines/mads/player.h
index d7e074a..6daacd9 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -29,9 +29,20 @@
 namespace MADS {
 
 class MADSEngine;
-class Action;
+class MADSAction;
 
 #define PLAYER_SPRITES_FILE_COUNT 8
+#define MAX_ROUTE_NODES 22
+
+/**
+ * Player facings
+ */
+enum Facing {
+	FACING_NORTH = 8, FACING_SOUTH = 2, FACING_EAST = 6, FACING_WEST = 4,
+	FACING_NORTHEAST = 9, FACING_SOUTHEAST = 3,
+	FACING_SOUTHWEST = 1, FACING_NORTHWEST = 7,
+	FACING_NONE = 5
+};
 
 class Player {
 private:
@@ -94,10 +105,10 @@ private:
 public:
 	MADSAction *_action;
 
-	int _direction;
-	int _newDirection;
+	Facing _direction;
+	Facing _newDirection;
 	int _xDirection, _yDirection;
-	int _destFacing;
+	Facing _targetFacing;
 	bool _spritesLoaded;
 	int _spritesStart;
 	int _spritesIdx;
@@ -151,9 +162,9 @@ public:
 
 	void idle();
 
-	void setDest(const Common::Point &pt, int facing);
+	void setDest(const Common::Point &pt, Facing facing);
 
-	void startWalking(const Common::Point &pos, int direction);
+	void startWalking(const Common::Point &pos, Facing direction);
 
 	void nextFrame();
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 1b3143f..6a42ed9 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -42,7 +42,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 	_depthStyle = 0;
 	_roomChanged = false;
 	_reloadSceneFlag = false;
-	_destFacing = 0;
+	_targetFacing = FACING_NONE;
 	_freeAnimationFlag = false;
 	_animationData = nullptr;
 	_activeAnimation = nullptr;
@@ -504,7 +504,7 @@ void Scene::doAction() {
 
 void Scene::checkStartWalk() {
 	if (_action._startWalkFlag && _action._walkFlag) {
-		_vm->_game->_player.setDest(_destPos, _destFacing);
+		_vm->_game->_player.setDest(_destPos, _targetFacing);
 		_action._startWalkFlag = false;
 	}
 }
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index e2eec23..ee1a0c7 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -119,7 +119,7 @@ public:
 	bool _roomChanged;
 	bool _reloadSceneFlag;
 	Common::Point _destPos;
-	int _destFacing;
+	Facing _targetFacing;
 	Common::Point _posAdjust;
 	uint32 _frameStartTime;
 	Layer _layer;
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 8f03783..d7c008b 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -32,6 +32,7 @@
 #include "mads/assets.h"
 #include "mads/events.h"
 #include "mads/game_data.h"
+#include "mads/hotspots.h"
 #include "mads/messages.h"
 #include "mads/user_interface.h"
 
@@ -45,7 +46,6 @@ class SpriteSlot;
 #define MADS_SCENE_HEIGHT 156
 
 #define DEPTH_BANDS_SIZE 15
-#define MAX_ROUTE_NODES 22
 
 #define SPRITE_SLOTS_MAX_SIZE 50
 #define TEXT_DISPLAY_MAX_SIZE 40


Commit: 04cbbb5f0a5cc761c71ead882187c02a0000ec0b
    https://github.com/scummvm/scummvm/commit/04cbbb5f0a5cc761c71ead882187c02a0000ec0b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-25T23:59:57-04:00

Commit Message:
MADS: Added enums for copy protection result and globals

Changed paths:
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/game_nebular.h
    engines/mads/nebular/globals_nebular.h
    engines/mads/nebular/nebular_scenes8.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 6e7c530..631ce20 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -59,7 +59,7 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 	_abortTimersMode = ABORTMODE_0;
 	_abortTimersMode2 = ABORTMODE_0;
 	_ticksExpiry = 0;
-	_exitFlag = 0;
+	_winStatus = 0;
 
 	// Load the inventory object list
 	_objects.load();
@@ -82,15 +82,17 @@ void Game::run() {
 	_statusFlag = true;
 	int protectionResult = checkCopyProtection();
 	switch (protectionResult) {
-	case 1:
+	case PROTECTION_FAIL:
 		// Copy protection failed
 		_scene._nextSceneId = 804;
 		_saveSlot = -1;
 		break;
-	case 2:
-		_statusFlag = 0;
+	case PROTECTION_ESCAPE:
+		// User escaped out of copy protection dialog
+		_vm->quitGame();
 		break;
 	default:
+		// Copy protection check succeeded
 		_scene._nextSceneId = 103;
 		_scene._priorSceneId = 102;
 		break;
diff --git a/engines/mads/game.h b/engines/mads/game.h
index c5a3dd3..0abb70b 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -43,6 +43,10 @@ enum Difficulty {
 	DIFFICULTY_HARD = 1, DIFFICULTY_MEDIUM = 2, DIFFICULTY_EASY = 3
 };
 
+enum ProtectionResult {
+	PROTECTION_SUCCEED = 0, PROTECTION_FAIL = 1, PROTECTION_ESCAPE = 2
+};
+
 class Game {
 private:
 	/**
@@ -88,7 +92,7 @@ protected:
 	/**
 	 * Perform any copy protection check
 	 */
-	virtual int checkCopyProtection() = 0;
+	virtual ProtectionResult checkCopyProtection() = 0;
 
 	/**
 	 * Initialises global variables for a new game
@@ -132,12 +136,12 @@ public:
 	uint32 _priorFrameTimer;
 	Common::String _aaName;
 	uint32 _ticksExpiry;
-	int _exitFlag;
+	int _winStatus;
 public:
 	virtual ~Game();
 
 	/**
-	 * Run the game
+	 * Main outer loop for the game
 	 */
 	void run();
 
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index f452746..9b48bde 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -39,7 +39,7 @@ GameNebular::GameNebular(MADSEngine *vm): Game(vm) {
 	_storyMode = STORYMODE_NAUGHTY;
 }
 
-int GameNebular::checkCopyProtection() {
+ProtectionResult GameNebular::checkCopyProtection() {
 	/*
 	// DEBUG: Flag copy protection failure
 	_globals[5] = -1;
@@ -54,7 +54,7 @@ int GameNebular::checkCopyProtection() {
 	*/
 
 	// DEBUG: Return that copy protection failed
-	return -2;
+	return PROTECTION_SUCCEED;
 }
 
 void GameNebular::initialiseGlobals() {
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index 98ecb0a..d3d908d 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -54,7 +54,7 @@ class GameNebular: public Game {
 protected:
 	GameNebular(MADSEngine *vm);
 
-	virtual int checkCopyProtection();
+	virtual ProtectionResult checkCopyProtection();
 
 	virtual void initialiseGlobals();
 
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index 95117a3..f83c0fa 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -31,6 +31,212 @@ namespace MADS {
 
 namespace Nebular {
 
+enum GlobalId {
+	KSexOfRex				= 0,
+	kOldSexOfRex			= 1,
+	kWalkerTiming           = 2,
+	kWalkerTiming0			= 3,
+
+	kTalkInanimateCount		= 4,
+
+	kCopyProtectFailed		= 5,
+
+	/* Section #1 variables */
+	kNeedToStandUp			= 10,
+
+	kTurkeyExploded			= 11,
+	kMedicineCabinetOpen	= 12,
+	kMedicineCabinetVirgin	= 13,
+	kWatchedViewScreen		= 14,
+
+	kHoovicAlive            = 15,
+	kHoovicSated            = 16,
+	kHoovicFishEaten        = 17,
+
+	kWaterInAPuddle			= 18,
+
+	kFishIn105				= 19,
+	kFishIn107				= 20,
+	kFishIn108				= 21,
+
+
+	/* Section #2 variables */
+	kCurtainOpen            = 30,
+	kLadderBroken           = 31,
+	kBone202Status			= 32,
+
+	kMeteorologistStatus    = 33,
+
+	kRhotundaStatus         = 34,
+	kLeavesStatus           = 35,
+
+	kMonkeyStatus           = 36,
+
+	kMeteorologistEverSeen  = 37,
+	kMeteorologistWatch     = 38,
+
+	kTeleporterCommand      = 39,
+	kTeleporterDestination  = 40,
+	kTeleporterUnderstood   = 41,
+
+	kConv205                = 42,
+	kChickenPpermitted      = 43,
+
+	kTwinklesStatus         = 44,
+	kTwinklesApproached     = 45,
+
+	kConvTwinkles1          = 46,
+	kConvTwinkles2          = 47,
+	kConvTwinkles3          = 48,
+	kConvTwinkles5			= 49,
+	kConvTwinkles6          = 50,
+	kConvTwinkles7          = 51,
+	kConvTwinkles8          = 52,
+
+	kBlowgunStatus          = 53,
+
+
+	/* Section #3 Variables */
+	kAfterHavoc             = 60,
+	kHaveYourStuff          = 61,
+
+	kRightView320			= 62,
+
+	kConvBuddy1				= 63,
+	kConvBuddy2				= 64,
+	kMetBuddyBeast          = 65,
+	kKnowsBuddyBeast        = 66,
+
+	kConvSlache1			= 67,
+	kConvSlache2			= 68,
+	kConvSlache3			= 69,
+
+	kRexHasMetSlache		= 70,
+
+	kConvIntern             = 71,
+	kHasSeenProfPyro		= 72,
+
+	kKickedIn391Grate		= 73,
+
+
+	/* Section #4 Variables */
+	kArmoryDoorOpen			= 80,
+	kStorageDoorOpen		= 81,
+
+	kNextIngredient         = 82,
+
+	kIngredientList         = 83,
+	kIngredientList1		= 84,
+	kIngredientList2		= 85,
+	kIngredientList3		= 86,
+
+	kIngredientQuantity     = 87,
+	kIngredientQuantity1	= 88,
+	kIngredientQuantity2	= 89,
+	kIngredientQuantity3	= 90,
+
+
+	conv_pyro_1             = 91,
+	conv_pyro_2             = 92,
+	conv_pyro_3             = 93,
+	conv_pyro_4             = 94,
+	bad_first_ingredient    = 95,
+
+	kConvBartender1         = 96,
+	kConvBartender2			= 97,
+	kConvBartender3			= 98,
+	kConvBartender4			= 99,
+	kHasPurchased			= 100,
+	kBeenThruHelgaScene		= 101,
+	kHasSaidBinocs			= 102,
+	kHasSaidTimer			= 103,
+	kBottleDisplayed		= 104,
+	kHasBeenScanned			= 105,
+	kSomeoneHasExploded		= 106,
+
+
+	/* Section #5 Variables */
+	kBoatRaised				= 110,
+
+	kCarStatus				= 111,
+
+	kCityFlooded			= 112,
+	kLaserOn				= 113,
+	kLaserHoleIsThere		= 114,
+	kCarIsGone				= 115,
+	kRegisterOpen			= 116,
+	kSafeStatus				= 117,
+	kDogStatus              = 118,
+	kLineStatus             = 119,
+
+	kHoverCarLocation		= 120,
+	kHoverCarDestination	= 121,
+
+
+	/* Section #6 Variables */
+	kConvHermit1			= 130,
+	kconvHermit2			= 131,
+	kHasTalkedToHermit		= 132,
+	kExecuted_1_11			= 133,
+	kHandsetCellStatus		= 134,
+	kBeenInVideoStore		= 135,
+	kDurafailRecharged		= 136,
+	kPenlightCellStatus		= 137,
+	kTimebombStatus			= 138,
+	kCheckDaemonTimebomb	= 140,
+	kResurrectRoom			= 141,
+
+
+	/* Section #6 Time-Bomb Variables */
+	kTimebombClock			= 142,
+	kTimebombClock0			= 143,
+
+	kTimebombTimer			= 144,
+	kTimebombTimer0			= 145,
+
+	kWarnedFloodCity		= 146,
+
+	/* Section #7 Variables */
+	kBottleStatus			= 150,
+	kMonsterAlive			= 151,
+
+	kConvBottleFillNode		= 152,
+	kBoatStatus				= 153,
+
+
+	/* Section #8 Variables */
+	kAntigravClock			= 160,
+	kAntigravClock0			= 161,
+
+	kAntigravTiming			= 162,
+	kAntigravTiming0		= 163,
+
+	kWindowFixed			= 164,
+	kinSpace                = 165,
+	kReturnFromCut			= 166,
+	kBeamIsUp               = 167,
+	kForceBeamDown          = 168,
+	kCameFromCut            = 169,
+	kCutX                   = 170,
+	kCutY                   = 171,
+	kCutFacing				= 172,
+	kDontRepeat             = 173,
+	kHoppyDead              = 174,
+	kHasWatchedAntigrav		= 175,
+	kRemoteSequenceRan		= 176,
+	kRemoteOnGround			= 177,
+	kFromCockpit            = 178,
+	kExitShip               = 179,
+	kBetweenRooms           = 180,
+	kTopButtonPushed		= 181,
+	kTargetModInstalled		= 182,
+	kShieldModInstalled		= 183,
+	kUpBecauseOfRemote		= 184,
+
+	kTeleporterRoom         = 190,
+	kTeleporterCode         = 200
+};
+
 class Globals {
 private:
 	Common::Array<int16> _flags;
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 2a28ede..920467f 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -194,7 +194,7 @@ void Scene804::step() {
 				_globals[165] = 0;
 				_globals[167] = -1;
 				assert(!_globals[5]);
-				_game._exitFlag = 4;
+				_game._winStatus = 4;
 				_vm->quitGame();
 			}
 			break;
@@ -206,7 +206,7 @@ void Scene804::step() {
 				_globals[165] = 0;
 				_globals[167] = -1;
 				assert(!_globals[5]);
-				_game._exitFlag = 4;
+				_game._winStatus = 4;
 				_vm->quitGame();
 			}
 			break;


Commit: 46021c487b1d0d528a6f9199bff9f2006263bd33
    https://github.com/scummvm/scummvm/commit/46021c487b1d0d528a6f9199bff9f2006263bd33
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-26T07:49:37+01:00

Commit Message:
MADS: Use globalId enum, add a skeletton for scene 209

Changed paths:
    engines/mads/nebular/globals_nebular.h
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h
    engines/mads/nebular/nebular_scenes8.cpp



diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index f83c0fa..d8500e2 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -32,120 +32,95 @@ namespace MADS {
 namespace Nebular {
 
 enum GlobalId {
-	KSexOfRex				= 0,
+	kSexOfRex				= 0,
 	kOldSexOfRex			= 1,
 	kWalkerTiming           = 2,
 	kWalkerTiming0			= 3,
-
 	kTalkInanimateCount		= 4,
-
 	kCopyProtectFailed		= 5,
 
 	/* Section #1 variables */
 	kNeedToStandUp			= 10,
-
 	kTurkeyExploded			= 11,
 	kMedicineCabinetOpen	= 12,
 	kMedicineCabinetVirgin	= 13,
 	kWatchedViewScreen		= 14,
-
 	kHoovicAlive            = 15,
 	kHoovicSated            = 16,
 	kHoovicFishEaten        = 17,
-
 	kWaterInAPuddle			= 18,
-
 	kFishIn105				= 19,
 	kFishIn107				= 20,
 	kFishIn108				= 21,
 
-
 	/* Section #2 variables */
 	kCurtainOpen            = 30,
 	kLadderBroken           = 31,
 	kBone202Status			= 32,
-
 	kMeteorologistStatus    = 33,
-
 	kRhotundaStatus         = 34,
 	kLeavesStatus           = 35,
-
 	kMonkeyStatus           = 36,
-
 	kMeteorologistEverSeen  = 37,
 	kMeteorologistWatch     = 38,
-
 	kTeleporterCommand      = 39,
+
 	kTeleporterDestination  = 40,
 	kTeleporterUnderstood   = 41,
-
 	kConv205                = 42,
 	kChickenPpermitted      = 43,
-
 	kTwinklesStatus         = 44,
 	kTwinklesApproached     = 45,
-
 	kConvTwinkles1          = 46,
 	kConvTwinkles2          = 47,
 	kConvTwinkles3          = 48,
 	kConvTwinkles5			= 49,
+
 	kConvTwinkles6          = 50,
 	kConvTwinkles7          = 51,
 	kConvTwinkles8          = 52,
-
 	kBlowgunStatus          = 53,
 
-
 	/* Section #3 Variables */
 	kAfterHavoc             = 60,
 	kHaveYourStuff          = 61,
-
 	kRightView320			= 62,
-
 	kConvBuddy1				= 63,
 	kConvBuddy2				= 64,
 	kMetBuddyBeast          = 65,
 	kKnowsBuddyBeast        = 66,
-
 	kConvSlache1			= 67,
 	kConvSlache2			= 68,
 	kConvSlache3			= 69,
 
 	kRexHasMetSlache		= 70,
-
 	kConvIntern             = 71,
 	kHasSeenProfPyro		= 72,
-
 	kKickedIn391Grate		= 73,
 
-
 	/* Section #4 Variables */
 	kArmoryDoorOpen			= 80,
 	kStorageDoorOpen		= 81,
-
 	kNextIngredient         = 82,
-
 	kIngredientList         = 83,
 	kIngredientList1		= 84,
 	kIngredientList2		= 85,
 	kIngredientList3		= 86,
-
 	kIngredientQuantity     = 87,
 	kIngredientQuantity1	= 88,
 	kIngredientQuantity2	= 89,
-	kIngredientQuantity3	= 90,
-
-
-	conv_pyro_1             = 91,
-	conv_pyro_2             = 92,
-	conv_pyro_3             = 93,
-	conv_pyro_4             = 94,
-	bad_first_ingredient    = 95,
 
+	kIngredientQuantity3	= 90,
+	kconvPyro_1             = 91,
+	kconvPyro_2             = 92,
+	kconvPyro_3             = 93,
+	kconvPyro_4             = 94,
+	kBadFirstIngredient     = 95,
 	kConvBartender1         = 96,
 	kConvBartender2			= 97,
 	kConvBartender3			= 98,
 	kConvBartender4			= 99,
+
 	kHasPurchased			= 100,
 	kBeenThruHelgaScene		= 101,
 	kHasSaidBinocs			= 102,
@@ -154,12 +129,9 @@ enum GlobalId {
 	kHasBeenScanned			= 105,
 	kSomeoneHasExploded		= 106,
 
-
 	/* Section #5 Variables */
 	kBoatRaised				= 110,
-
 	kCarStatus				= 111,
-
 	kCityFlooded			= 112,
 	kLaserOn				= 113,
 	kLaserHoleIsThere		= 114,
@@ -172,7 +144,6 @@ enum GlobalId {
 	kHoverCarLocation		= 120,
 	kHoverCarDestination	= 121,
 
-
 	/* Section #6 Variables */
 	kConvHermit1			= 130,
 	kconvHermit2			= 131,
@@ -184,39 +155,34 @@ enum GlobalId {
 	kPenlightCellStatus		= 137,
 	kTimebombStatus			= 138,
 	kCheckDaemonTimebomb	= 140,
-	kResurrectRoom			= 141,
 
+	kResurrectRoom			= 141,
 
 	/* Section #6 Time-Bomb Variables */
 	kTimebombClock			= 142,
 	kTimebombClock0			= 143,
-
 	kTimebombTimer			= 144,
 	kTimebombTimer0			= 145,
-
 	kWarnedFloodCity		= 146,
 
 	/* Section #7 Variables */
 	kBottleStatus			= 150,
 	kMonsterAlive			= 151,
-
 	kConvBottleFillNode		= 152,
 	kBoatStatus				= 153,
 
-
 	/* Section #8 Variables */
 	kAntigravClock			= 160,
 	kAntigravClock0			= 161,
-
 	kAntigravTiming			= 162,
 	kAntigravTiming0		= 163,
-
 	kWindowFixed			= 164,
 	kinSpace                = 165,
 	kReturnFromCut			= 166,
 	kBeamIsUp               = 167,
 	kForceBeamDown          = 168,
 	kCameFromCut            = 169,
+
 	kCutX                   = 170,
 	kCutY                   = 171,
 	kCutFacing				= 172,
@@ -227,6 +193,7 @@ enum GlobalId {
 	kRemoteOnGround			= 177,
 	kFromCockpit            = 178,
 	kExitShip               = 179,
+
 	kBetweenRooms           = 180,
 	kTopButtonPushed		= 181,
 	kTargetModInstalled		= 182,
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 39a8ed5..3a6e6a6 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -63,6 +63,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene207(vm);
 	case 208:
 		return new Scene208(vm);
+	case 209:
+		return new Scene209(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 652ee99..4c3b67f 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -72,22 +72,22 @@ void Scene1xx::setPlayerSpritesPrefix() {
 	_vm->_sound->command(5);
 	Common::String oldName = _game._player._spritesPrefix;
 	if (_scene->_nextSceneId <= 103 || _scene->_nextSceneId == 111) {
-		if (_globals[0] == SEX_FEMALE) {
+		if (_globals[kSexOfRex] == SEX_FEMALE) {
 			_game._player._spritesPrefix = "ROX";
 		} else {
 			_game._player._spritesPrefix = "RXM";
-			_globals[0] = SEX_MALE;
+			_globals[kSexOfRex] = SEX_MALE;
 		}
 	} else if (_scene->_nextSceneId <= 110) {
 		_game._player._spritesPrefix = "RXSW";
-		_globals[0] = SEX_UNKNOWN;
+		_globals[kSexOfRex] = SEX_UNKNOWN;
 	} else if (_scene->_nextSceneId == 112) {
 		_game._player._spritesPrefix = "";
 	}
 
 	if (oldName == _game._player._spritesPrefix)
 		_game._player._spritesChanged = true;
-	if (_scene->_nextSceneId == 105 || (_scene->_nextSceneId == 109 && _globals[15])) {
+	if (_scene->_nextSceneId == 105 || (_scene->_nextSceneId == 109 && _globals[kHoovicAlive])) {
 		_game._player._spritesChanged = true;
 		_game._v3 = 0;
 	}
@@ -176,7 +176,7 @@ void Scene103::enter() {
 			_globals._spriteIndexes[10], false, 6);
 	}
 	
-	if (_globals[11]) {
+	if (_globals[kTurkeyExploded]) {
 		_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(
 			_globals._spriteIndexes[9], false, 6);
 		_scene->_sequences.setAnimRange(_globals._spriteIndexes[24], -2, -2);
@@ -362,14 +362,14 @@ void Scene103::actions() {
 			}
 
 			_game._player._stepEnabled = _game._abortTimers == 2;
-			_globals[11] = -1;
+			_globals[kTurkeyExploded] = -1;
 			if (_game._abortTimers == 2) {
 				Dialog::show(1030);
 				_scene->_hotspots.activate(362, false);
 			}
 		}
 	} else if (_action.isAction(VERB_LOOK, 250, 0)) {
-		Dialog::show(!_globals[11] ? 10323 : 10303);
+		Dialog::show(!_globals[kTurkeyExploded] ? 10323 : 10303);
 	}
 	else if (_action.isAction(VERB_TALKTO, 27, 0)) {
 		switch (_vm->_game->_abortTimers) {
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 4cec40c..4fc1e3e 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -45,7 +45,7 @@ void Scene2xx::setPlayerSpritesPrefix() {
 		_game._player._spritesPrefix = "";
 		break;
 	default:
-		if (_globals[0] != SEX_MALE) {
+		if (_globals[kSexOfRex] != SEX_MALE) {
 			_game._player._spritesPrefix = "ROX";
 		} else {
 			_game._player._spritesPrefix = "RXM";
@@ -61,7 +61,7 @@ void Scene2xx::setPlayerSpritesPrefix() {
 	if (oldName != _game._player._spritesPrefix)
 		_game._player._spritesChanged = true;
 	
-	if ((_scene->_nextSceneId == 203 || _scene->_nextSceneId == 204) && _globals[34])
+	if ((_scene->_nextSceneId == 203 || _scene->_nextSceneId == 204) && _globals[kRhotundaStatus])
 		_game._v3 = 0;
 
 	_vm->_palette->setEntry(16, 10, 63, 63);
@@ -72,7 +72,7 @@ void Scene2xx::sceneEntrySound() {
 	if (_vm->_musicFlag) {
 		switch (_scene->_nextSceneId) {
 		case 201:
-			if ((_globals[39] == 2) || (_globals[39] == 4) || (_globals[33] != 1))
+			if ((_globals[kTeleporterCommand] == 2) || (_globals[kTeleporterCommand] == 4) || (_globals[kMeteorologistStatus] != 1))
 				_vm->_sound->command(17);
 			else
 				_vm->_sound->command(9);
@@ -96,13 +96,13 @@ void Scene2xx::sceneEntrySound() {
 			_vm->_sound->command(11);
 			break;
 		case 210:
-			if (_globals[44] == 0)
+			if (_globals[kTwinklesStatus] == 0)
 				_vm->_sound->command(15);
 			else
 				_vm->_sound->command(10);
 			break;
 		case 213:
-			if (_globals[38] == 0)
+			if (_globals[kMeteorologistWatch] == 0)
 				_vm->_sound->command(1);
 			else
 				_vm->_sound->command(9);
@@ -155,18 +155,18 @@ void Scene201::enter() {
 		_game._player._direction = FACING_SOUTH;
 	}
 
-	if (_globals[39] != 0) {
+	if (_globals[kTeleporterCommand] != 0) {
 		_game._player._visible = false;
 		_game._player._stepEnabled = false;
-		int sepChar = (_globals[0] == SEX_UNKNOWN) ? 't' : 'u';
+		int sepChar = (_globals[kSexOfRex] == SEX_UNKNOWN) ? 't' : 'u';
 		// Guess values. What is the default value used by the compiler?
 		int suffixNum = -1;
 		int abortTimers = -1; 
-		switch(_globals[39]) {
+		switch(_globals[kTeleporterCommand]) {
 		case 1:
 			suffixNum = 3;
 			abortTimers = 76;
-			_globals[41] = -1;
+			_globals[kTeleporterUnderstood] = -1;
 			break;
 		case 2:
 			suffixNum = 1;
@@ -182,12 +182,12 @@ void Scene201::enter() {
 			abortTimers = 78;
 			break;
 		}
-		_globals[39] = 0;
+		_globals[kTeleporterCommand] = 0;
 		if (suffixNum >= 0)
 			_scene->loadAnimation(formAnimName(sepChar, suffixNum), abortTimers);
 	}
 	
-	if ((_scene->_priorSceneId == 202) && (_globals[33] == 1) && !_scene->_roomChanged) {
+	if ((_scene->_priorSceneId == 202) && (_globals[kMeteorologistStatus] == 1) && !_scene->_roomChanged) {
 		_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('a', 0), 0);
 		_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('a', 1), 0);
 		_game.loadQuoteSet(90, 91, 0);
@@ -204,7 +204,7 @@ void Scene201::enter() {
 	} else
 		_globals._frameTime = 0xFFFF;
 
-	if (_globals[41] != 0)
+	if (_globals[kTeleporterUnderstood] != 0)
 		_scene->_hotspots.activate(438, false);
 
 	sceneEntrySound();
@@ -261,7 +261,7 @@ void Scene201::step() {
 	}
 
 	if (_game._abortTimers == 75) {
-		_globals[37] = 0;
+		_globals[kMeteorologistEverSeen] = 0;
 		_scene->_nextSceneId = 202;
 	}
 
@@ -272,8 +272,8 @@ void Scene201::step() {
 	}
 
 	if (_game._abortTimers == 77) {
-		_globals[39] = 1;
-		_scene->_nextSceneId = _globals[40];
+		_globals[kTeleporterCommand] = 1;
+		_scene->_nextSceneId = _globals[kTeleporterDestination];
 		_scene->_reloadSceneFlag = true;
 	}
 
@@ -296,7 +296,7 @@ void Scene201::actions() {
 			} else {
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
-				int sepChar = (_globals[0] == SEX_UNKNOWN) ? 't' : 'u';
+				int sepChar = (_globals[kSexOfRex] == SEX_UNKNOWN) ? 't' : 'u';
 				_scene->loadAnimation(formAnimName(sepChar, 0), 1);
 			}
 		} else if (action->isAction(0x3, 0x1A6, 0)) {
@@ -318,7 +318,7 @@ void Scene201::actions() {
 		} else if (action->isAction(0x3, 0x83, 0)) {
 			Dialog::show(0x4E8E);
 		} else if (action->isAction(0x3, 0x1B6, 0)) {
-			if (_globals[37])
+			if (_globals[kMeteorologistEverSeen])
 				Dialog::show(0x4E90);
 			else
 				Dialog::show(0x4E8D);
@@ -354,7 +354,7 @@ void Scene202::enter() {
 	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('b', 2), 0);
 	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 0), 0);
 	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('l', -1), 0);
-	if (_globals[0] != SEX_MALE) {
+	if (_globals[kSexOfRex] != SEX_MALE) {
 		_globals._spriteIndexes[7] = _scene->_sprites.addSprites("*ROXBD_2");
 	} else {
 		_globals._spriteIndexes[7] = _scene->_sprites.addSprites("*RXMBD_2");
@@ -370,7 +370,7 @@ void Scene202::enter() {
 	int idx = _scene->_dynamicHotspots.add(320, 13, _globals._spriteIndexes[17], Common::Rect(0, 0, 0, 0));
 	_scene->_dynamicHotspots.setPosition(idx, 153, 97, FACING_SOUTH);
 
-	if (_globals[32] & 1) {
+	if (_globals[kBone202Status] & 1) {
 		_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
 		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[16], Common::Point(130, 108));
 		_scene->_sequences.setDepth(_globals._spriteIndexes[16], 10);
@@ -378,7 +378,7 @@ void Scene202::enter() {
 		_scene->_dynamicHotspots.setPosition(idx, 132, 97, FACING_SOUTH);
 	}
 
-	if (_globals[32] & 2) {
+	if (_globals[kBone202Status] & 2) {
 		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 0, 0, 0);
 		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[21], Common::Point(166, 110));
 		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 10);
@@ -386,8 +386,8 @@ void Scene202::enter() {
 		_scene->_dynamicHotspots.setPosition(idx, 165, 99, FACING_SOUTH);
 	}
 
-	if (_globals[32])
-		_scene->changeDepthSurface(_globals[32]);
+	if (_globals[kBone202Status])
+		_scene->changeDepthSurface(_globals[kBone202Status]);
 
 	if (_scene->_priorSceneId == 201) {
 		_game._player._playerPos = Common::Point(190, 91);
@@ -397,7 +397,7 @@ void Scene202::enter() {
 		_game._player._direction = FACING_NORTH;
 	}
 
-	if (_globals[31]) {
+	if (_globals[kLadderBroken]) {
 		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 0, 0, 0);
 		_scene->_sequences.setDepth(_globals._spriteIndexes[20], 6);
 		_scene->_hotspots.activate(199, false);
@@ -423,15 +423,15 @@ void Scene202::enter() {
 	if (_scene->_roomChanged)
 		_game._objects.addToInventory(OBJ_NONE);
 	
-	if (_globals[38]) {
+	if (_globals[kMeteorologistWatch]) {
 		_game._player._visible = false;
 		_game._player._stepEnabled = false;
-		if (_globals[38] == 2)
+		if (_globals[kMeteorologistWatch] == 2)
 			_globals._v4 = 1;
 		else
 			_globals._v4 = 0;
 
-		if (_globals[38] < 1)
+		if (_globals[kMeteorologistWatch] < 1)
 			_globals._spriteIndexes[25] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
 		else
 			_globals._spriteIndexes[25] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 8);
@@ -441,7 +441,7 @@ void Scene202::enter() {
 			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(247, 82));
 			_game._player._playerPos = Common::Point(246, 124);
 			_game._player._direction = FACING_NORTH;
-			_globals[41] = -1;
+			_globals[kTeleporterUnderstood] = -1;
 		} else {
 			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
 			_game._player._playerPos = Common::Point(171, 122);
@@ -496,7 +496,7 @@ void Scene202::step() {
 		int msgIndex = _scene->_kernelMessages.add(msgPos, 0x1110, msgFlag | 32, 0, 120, _game.getQuote(102));
 		_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
 		
-		if (_globals[38] == 1) {
+		if (_globals[kMeteorologistWatch] == 1) {
 			MADSAction *action = _game._player._action;
 			action->_activeAction._verbId = 3;
 			action->_activeAction._objectNameId = 39;
@@ -504,10 +504,10 @@ void Scene202::step() {
 			_game._abortTimersMode2 = ABORTMODE_0;
 			_scene->_sequences.addTimer(120, 2);
 			_globals._abortVal = -1;
-		} else if (_globals[38] == 2) {
+		} else if (_globals[kMeteorologistWatch] == 2) {
 			_scene->_sequences.addTimer(120, 90);
 		}
-		_globals[38] = 0;
+		_globals[kMeteorologistWatch] = 0;
 	}
 
 	switch (_game._abortTimers) {
@@ -536,7 +536,7 @@ void Scene202::step() {
 		}
 		break;
 	case 93: {
-		_globals[31] = -1;
+		_globals[kLadderBroken] = -1;
 		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 0, 0, 0);
 		_scene->_hotspots.activate(199, false);
 		int idx = _scene->_dynamicHotspots.add(457, 13, _globals._spriteIndexes[20], Common::Rect(0, 0, 0, 0));
@@ -554,19 +554,19 @@ void Scene202::step() {
 		break;
 	}
 	
-	if (!_scene->_activeAnimation && (_globals[33] != 2) && (_globals._v7 <= _scene->_frameStartTime) && (_globals._v8425C <= _scene->_frameStartTime)) {
+	if (!_scene->_activeAnimation && (_globals[kMeteorologistStatus] != 2) && (_globals._v7 <= _scene->_frameStartTime) && (_globals._v8425C <= _scene->_frameStartTime)) {
 		int randVal = _vm->getRandomNumber(1, 500);
 		int threshold = 1;
 		if (_globals._v4)
 			threshold = 26;
-		if (!_globals[37])
+		if (!_globals[kMeteorologistEverSeen])
 			threshold = 25;
 		if (threshold >= randVal) {
 			_vm->_sound->command(17);
 			_scene->loadAnimation(formAnimName('M', -1), 71);
 			_globals._v84266 = -1;
 			_globals._v84268 = 0;
-			_globals[37] = true;
+			_globals[kMeteorologistEverSeen] = true;
 			_globals._v6 = _scene->_frameStartTime;
 			_globals._v8 = 0;
 			_globals._v84262 = 0;
@@ -580,7 +580,7 @@ void Scene202::step() {
 
 	if (_globals._v5) {
 		if (_scene->_activeAnimation->getCurrentFrame() >= 200) {
-			if ((_globals[38] == 2) || _globals[31]) {
+			if ((_globals[kMeteorologistWatch] == 2) || _globals[kLadderBroken]) {
 				_scene->_nextSceneId = 213;
 			} else {
 				Dialog::show(0x4EE9);
@@ -761,11 +761,11 @@ void Scene202::actions() {
 		} else if (action->isAction(0x18C, 0x83, 0)) {
 			_scene->_nextSceneId = 203;
 		} else if (action->isAction(0x18C, 0x82, 0)) {
-			if (_globals[33] != 2) {
+			if (_globals[kMeteorologistStatus] != 2) {
 				if (_scene->_activeAnimation)
-					_globals[33] = 1;
+					_globals[kMeteorologistStatus] = 1;
 				else
-					_globals[33] = 0;
+					_globals[kMeteorologistStatus] = 0;
 			}
 			_scene->_nextSceneId = 201;
 		} else if (action->isAction(0x4, 0x2C, 0)) {
@@ -784,10 +784,10 @@ void Scene202::actions() {
 				} else if (_game._abortTimers == 1) {
 					if ((_game._player._playerPos.x == 132) && (_game._player._playerPos.y == 97)) {
 						_scene->_sequences.remove(_globals._spriteIndexes[16]);
-						_globals[32] |= 1;
+						_globals[kBone202Status] |= 1;
 					} else {
 						_scene->_sequences.remove(_globals._spriteIndexes[21]);
-						_globals[32] |= 2;
+						_globals[kBone202Status] |= 2;
 					}
 				} else if (_game._abortTimers == 2) {
 					if (_game._objects.isInInventory(OBJ_BONE)) {
@@ -798,7 +798,7 @@ void Scene202::actions() {
 						_game._objects.addToInventory(OBJ_BONE);
 						_vm->_dialogs->showPicture(OBJ_BONE, 0x4EFA, 0);
 					}
-					_scene->changeDepthSurface(_globals[32]);
+					_scene->changeDepthSurface(_globals[kBone202Status]);
 					_game._player._stepEnabled = true;
 					_game._player._visible = true;
 				} else {
@@ -806,7 +806,7 @@ void Scene202::actions() {
 					return;
 				}
 			}
-		} else if ((action->isAction(0x50, 0xC7, 0)) && (_globals[31] == 0)) {
+		} else if ((action->isAction(0x50, 0xC7, 0)) && (_globals[kLadderBroken] == 0)) {
 			if (_game._abortTimers == 0) {
 				_vm->_sound->command(29);
 				_globals._v8425C = _scene->_frameStartTime;
@@ -832,7 +832,7 @@ void Scene202::actions() {
 				action->_inProgress = false;
 				return;
 			}
-		} else if (((action->isAction(0x3, 0x27, 0x82)) || (action->isAction(0x3, 0x27, 0x1B6))) && (_globals[0] == SEX_MALE)) {
+		} else if (((action->isAction(0x3, 0x27, 0x82)) || (action->isAction(0x3, 0x27, 0x1B6))) && (_globals[kSexOfRex] == SEX_MALE)) {
 			if (_globals._v4 == 0) {
 				if (_game._abortTimers == 0) {
 					_game._player._stepEnabled = false;
@@ -849,7 +849,7 @@ void Scene202::actions() {
 					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
 					if (_scene->_activeAnimation) {
 						_globals._v5 = -1;
-						_globals[38] = 1;
+						_globals[kMeteorologistWatch] = 1;
 					} else {
 						_scene->_sequences.addTimer(120, 2);
 					}
@@ -889,7 +889,7 @@ void Scene202::actions() {
 							_scene->_sequences.addTimer(120, 2);
 						} else {
 							_globals._v5 = -1;
-							_globals[38] = 2;
+							_globals[kMeteorologistWatch] = 2;
 							if ((_scene->_activeAnimation->getCurrentFrame() >= 44) && (_scene->_activeAnimation->getCurrentFrame() <= 75)) {
 								_scene->_kernelMessages.reset();
 								int msgIndex = _scene->_kernelMessages.add(Common::Point(248, 15), 0x1110, 32, 0, 60, _game.getQuote(100));
@@ -930,9 +930,9 @@ void Scene202::actions() {
 		} else if (action->isAction(0x3, 0x19C, 0)) {
 			Dialog::show(0x4EEC);
 		} else if (action->isAction(0x3, 0x82, 0)) {
-			if ((_globals[33] == 0) || (_globals[33] == 2)) {
+			if ((_globals[kMeteorologistStatus] == 0) || (_globals[kMeteorologistStatus] == 2)) {
 				Dialog::show(0x4EED);
-			} else if (_globals[33] == 1) {
+			} else if (_globals[kMeteorologistStatus] == 1) {
 				Dialog::show(0x4EFC);
 			} else {
 				action->_inProgress = false;
@@ -998,7 +998,7 @@ void Scene203::enter() {
 	_globals._v0 = 0;
 	_globals._frameTime = 0;
 
-	if ((_globals[34] == 0) && (_scene->_roomChanged == 0)) {
+	if ((_globals[kRhotundaStatus] == 0) && (_scene->_roomChanged == 0)) {
 		_globals._v0 = -1;
 		_game._player.startWalking(Common::Point(158, 135), FACING_SOUTH);
 		int idx = _scene->_dynamicHotspots.add(131, 396, 0, Common::Rect(0, 0, 320, 156));
@@ -1105,7 +1105,7 @@ void Scene205::enter() {
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('c', -1), 0);
 	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('p', -1), 0);
 	
-	if (_globals[0] == SEX_MALE)
+	if (_globals[kSexOfRex] == SEX_MALE)
 		_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('a', 1), 0);
 
 	_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 10, 0, 0, 3);
@@ -1152,13 +1152,13 @@ void Scene205::enter() {
 	_globals._v0 = _globals._frameTime & 0xFFFF;
 	_globals._frameTime >>= 16;
 
-	if (_globals[0] == SEX_FEMALE)
+	if (_globals[kSexOfRex] == SEX_FEMALE)
 		warning("sub71704(0x3, 0xC3, 0x108, 0x63, 0x86, 0xD, 2, 0xFDFC, 0x3C, 0x6C, 0x6C, 0x6D, 0x6D, 0x6E, 0x6E, 0x6F, 0x6C, 0);");
 
 	if (_scene->_priorSceneId != -2)
 		_game._player._playerPos = Common::Point(99, 152);	
 
-	if (_globals[0] != SEX_MALE) {
+	if (_globals[kSexOfRex] != SEX_MALE) {
 		_scene->loadAnimation(formAnimName('a', -1), 0);
 		_scene->_activeAnimation->_resetFlag = false;
 	} else {
@@ -1400,7 +1400,7 @@ void Scene208::enter() {
 
 	_game.loadQuoteSet(0x81, 0x46, 0);
 
-	if ((_scene->_priorSceneId == 207) && (_globals[36] == 1)) {
+	if ((_scene->_priorSceneId == 207) && (_globals[kMonkeyStatus] == 1)) {
 		int msgIndex = _scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(129));
 		_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
 	}
@@ -1440,7 +1440,7 @@ void Scene208::step() {
 	if (_game._abortTimers & 0xFF) {
 		if ((_game._abortTimers & 0xFF) == 81) {
 			_scene->_sequences.remove(_globals._spriteIndexes[15]);
-			_globals[34] = 1;
+			_globals[kRhotundaStatus] = 1;
 			warning("TODO: sub34648(...)");
 			_scene->_sequences.addTimer(90, 82);
 		}
@@ -1462,7 +1462,7 @@ void Scene208::preActions() {
 
 void Scene208::actions() {
 	if (_action.isAction(0x18C, 0x19F, 0)) {
-		if (_globals[34])
+		if (_globals[kRhotundaStatus])
 			_scene->_nextSceneId = 203;
 		else if (_game._abortTimers == 0) {
 			_game._player._stepEnabled = false;
@@ -1473,11 +1473,11 @@ void Scene208::actions() {
 		}
 	} else if (_action.isAction(0x18C, 0x83, 0)) {
 		_scene->_nextSceneId = 212;
-	} else if (_action.isAction(0x4, 0x1AA, 0) && (!_globals[35] || _game._abortTimers)) {
+	} else if (_action.isAction(0x4, 0x1AA, 0) && (!_globals[kLeavesStatus] || _game._abortTimers)) {
 		warning("TODO: sub3B282(1);");
 		if (_game._player._stepEnabled)
 			_vm->_dialogs->showPicture(OBJ_BIG_LEAVES, 0x326, 0);
-	} else if (_action.isAction(0x7, 0x23, 0x19E) && (_globals[35] == 1 || _game._abortTimers)) {
+	} else if (_action.isAction(0x7, 0x23, 0x19E) && (_globals[kLeavesStatus] == 1 || _game._abortTimers)) {
 		warning("TODO: sub3B282(2);");
 	} else if (_action.isAction(0x7, 0x17A, 0x1A9)) {
 		warning("TODO: sub3B282(3);");
@@ -1529,9 +1529,9 @@ void Scene208::actions() {
 		Dialog::show(0x5150);
 	} else if (_action._savedFields._lookFlag == 0) {
 		return;
-	} else if (_globals[34] == 1) {
+	} else if (_globals[kRhotundaStatus] == 1) {
 		Dialog::show(0x5153);
-	} else if (_globals[35] == 2) {
+	} else if (_globals[kLeavesStatus] == 2) {
 		Dialog::show(0x5152);
 	} else {
 		Dialog::show(0x5151);
@@ -1542,5 +1542,23 @@ void Scene208::actions() {
 
 /*****************************************************************************/
 
+void Scene209::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x10F);
+}
+
+void Scene209::enter() {
+}
+
+void Scene209::step() {
+}
+
+void Scene209::preActions() {
+}
+
+void Scene209::actions() {
+}
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 7a5af6f..a23ae98 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -123,6 +123,17 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene209: public Scene2xx {
+public:
+	Scene209(MADSEngine *vm) : Scene2xx(vm) {}
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 920467f..b802c3e 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -32,12 +32,12 @@ namespace Nebular {
 
 void Scene8xx::setup1() {
 	_vm->_sound->command(5);
-	if ((_globals[178] && !_globals[179]) ||
+	if ((_globals[kFromCockpit] && !_globals[kExitShip]) ||
 			_scene->_nextSceneId == 804 || _scene->_nextSceneId == 805 ||
 			_scene->_nextSceneId == 808 || _scene->_nextSceneId == 810) {
 		_game._player._spritesPrefix = "";
 	} else {
-		_game._player._spritesPrefix = _globals[0] == SEX_FEMALE ? "ROX" : "RXM";
+		_game._player._spritesPrefix = _globals[kSexOfRex] == SEX_FEMALE ? "ROX" : "RXM";
 	}
 
 	_vm->_palette->setEntry(16, 0x0A, 0x3F, 0x3F);
@@ -88,10 +88,10 @@ void Scene804::enter() {
 	_globals._v6 = 0;
 	_globals._v7 = 0;
 	_globals._v8 = 0;
-	if (_globals[5]) {
+	if (_globals[kCopyProtectFailed]) {
 		// Copy protection failed
-		_globals[165] = -1;
-		_globals[164] = 0;
+		_globals[kinSpace] = -1;
+		_globals[kWindowFixed] = 0;
 	}
 
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 0));
@@ -103,8 +103,8 @@ void Scene804::enter() {
 
 	_game.loadQuoteSet(791, 0);
 
-	if (_globals[165]) {
-		if (_globals[164]) {
+	if (_globals[kinSpace]) {
+		if (_globals[kWindowFixed]) {
 			_globals._spriteIndexes[20] = _scene->_sequences.startCycle(
 				_globals._spriteIndexes[5], 0, 1);
 			_scene->_sequences.addTimer(60, 100);
@@ -117,12 +117,12 @@ void Scene804::enter() {
 			_game._player._stepEnabled = false;
 		}
 	} else {
-		if (_globals[167] == 0) {
+		if (_globals[kBeamIsUp] == 0) {
 			_globals._spriteIndexes[23] = _scene->_sequences.startCycle(
 				_globals._spriteIndexes[8], false, 1);
 		}
 
-		if (_globals[164] == 0) {
+		if (_globals[kWindowFixed] == 0) {
 			_globals._spriteIndexes[23] = _scene->_sequences.startCycle(
 				_globals._spriteIndexes[19], false, 1);
 		}
@@ -137,7 +137,7 @@ void Scene804::enter() {
 
 	Scene8xx::enter1();
 
-	if (_globals[165] && !_globals[164]) {
+	if (_globals[kinSpace] && !_globals[kWindowFixed]) {
 		_scene->_userInterface.setup(2);
 		_vm->_sound->command(19);
 	}
@@ -191,9 +191,9 @@ void Scene804::step() {
 			if (_scene->_activeAnimation->getCurrentFrame() == 81) {
 				_globals._v5 = 80;
 			} else {
-				_globals[165] = 0;
-				_globals[167] = -1;
-				assert(!_globals[5]);
+				_globals[kinSpace] = 0;
+				_globals[kBeamIsUp] = -1;
+				assert(!_globals[kCopyProtectFailed]);
 				_game._winStatus = 4;
 				_vm->quitGame();
 			}
@@ -203,9 +203,9 @@ void Scene804::step() {
 			if (_scene->_activeAnimation->getCurrentFrame() == 68) {
 				_globals._v5 = 66;
 			} else {
-				_globals[165] = 0;
-				_globals[167] = -1;
-				assert(!_globals[5]);
+				_globals[kinSpace] = 0;
+				_globals[kBeamIsUp] = -1;
+				assert(!_globals[kCopyProtectFailed]);
 				_game._winStatus = 4;
 				_vm->quitGame();
 			}
@@ -225,10 +225,10 @@ void Scene804::step() {
 		if (_game._abortTimers == 80)
 			_scene->_nextSceneId = 803;
 
-		if (_scene->_activeAnimation->getCurrentFrame() == 7 && !_globals[164]) {
+		if (_scene->_activeAnimation->getCurrentFrame() == 7 && !_globals[kWindowFixed]) {
 			_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 			_scene->_sequences.addTimer(20, 110);
-			_globals[164] = -1;
+			_globals[kWindowFixed] = -1;
 		}
 
 		if (_scene->_activeAnimation->getCurrentFrame() == 10) {
@@ -239,6 +239,7 @@ void Scene804::step() {
 
 		switch (_scene->_activeAnimation->getCurrentFrame()) {
 		case 1:
+			// CHECKME: GlobalID not in enum
 			_globals[29] = _vm->getRandomNumber(1, 30);
 			switch (_globals[29]) {
 			case 1:


Commit: 56f7b51754e30ec75c596cd80c76991ac158da66
    https://github.com/scummvm/scummvm/commit/56f7b51754e30ec75c596cd80c76991ac158da66
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-26T07:57:27+01:00

Commit Message:
MADS: Add an enum for kRandomNumber

Changed paths:
    engines/mads/nebular/globals_nebular.h
    engines/mads/nebular/nebular_scenes8.cpp



diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index d8500e2..b3cc94a 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -52,6 +52,7 @@ enum GlobalId {
 	kFishIn105				= 19,
 	kFishIn107				= 20,
 	kFishIn108				= 21,
+	kRandomNumber           = 29,
 
 	/* Section #2 variables */
 	kCurtainOpen            = 30,
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index b802c3e..c60a43a 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -239,9 +239,8 @@ void Scene804::step() {
 
 		switch (_scene->_activeAnimation->getCurrentFrame()) {
 		case 1:
-			// CHECKME: GlobalID not in enum
-			_globals[29] = _vm->getRandomNumber(1, 30);
-			switch (_globals[29]) {
+			_globals[kRandomNumber] = _vm->getRandomNumber(1, 30);
+			switch (_globals[kRandomNumber]) {
 			case 1:
 				_globals._v5 = 25;
 				break;


Commit: f9e2c1c71f29f6dc1ba8e860d597fe93bc79646a
    https://github.com/scummvm/scummvm/commit/f9e2c1c71f29f6dc1ba8e860d597fe93bc79646a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-26T09:32:33-04:00

Commit Message:
MADS: Cleaned up game initialisation code to use more constants

Changed paths:
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/inventory.cpp
    engines/mads/inventory.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/globals_nebular.cpp
    engines/mads/nebular/globals_nebular.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/player.cpp
    engines/mads/player.h
    engines/mads/scene.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 631ce20..50a4f63 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -42,7 +42,7 @@ Game *Game::init(MADSEngine *vm) {
 Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm), 
 		_scene(vm), _screenObjects(vm), _player(vm) {
 	_sectionNumber = _priorSectionNumber = 0;
-	_difficultyLevel = DIFFICULTY_HARD;
+	_difficulty = DIFFICULTY_HARD;
 	_saveSlot = -1;
 	_statusFlag = 0;
 	_sectionHandler = nullptr;
@@ -207,7 +207,7 @@ void Game::sectionLoop() {
 
 		_scene._action.clear();
 		_player.turnToDestFacing();
-		_player._direction = _player._newDirection;
+		_player._facing = _player._turnToFacing;
 		_player.moveComplete();
 
 		switch (_vm->_screenFade) {
@@ -231,8 +231,8 @@ void Game::sectionLoop() {
 
 		// Set player data
 		_player._destPos = _player._playerPos;
-		_player._newDirection = _player._direction;
-		_player._targetFacing = _player._direction;
+		_player._turnToFacing = _player._facing;
+		_player._targetFacing = _player._facing;
 		_player.setupFrame();
 		_player.updateFrame();
 		_player._visible3 = _player._visible;
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 0abb70b..0d7178a 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -40,7 +40,7 @@ enum {
 };
 
 enum Difficulty {
-	DIFFICULTY_HARD = 1, DIFFICULTY_MEDIUM = 2, DIFFICULTY_EASY = 3
+	DIFFICULTY_HARD = 1, DIFFICULTY_REALLY_HARD = 2, DIFFICULTY_IMPOSSIBLE = 3
 };
 
 enum ProtectionResult {
@@ -117,7 +117,7 @@ public:
 public:
 	Player _player;
 	ScreenObjects _screenObjects;
-	Difficulty _difficultyLevel;
+	Difficulty _difficulty;
 	int _sectionNumber;
 	int _priorSectionNumber;
 	int _currentSectionNumber;
diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index 1443761..3237d55 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -66,7 +66,7 @@ void InventoryObjects::load() {
 	}
 }
 
-void InventoryObjects::setData(int objIndex, int id, const byte *p) {
+void InventoryObjects::setQuality(int objIndex, int id, const byte *p) {
 	// TODO: This whole method seems weird. Check it out more thoroughly once
 	// more of the engine is implemented
 	for (int i = 0; i < (int)size(); ++i) {
diff --git a/engines/mads/inventory.h b/engines/mads/inventory.h
index 2ca27064..eec272b 100644
--- a/engines/mads/inventory.h
+++ b/engines/mads/inventory.h
@@ -28,6 +28,10 @@
 
 namespace MADS {
 
+enum {
+	NOWHERE = 1
+};
+
 class MADSEngine;
 
 class InventoryObject {
@@ -75,9 +79,9 @@ public:
 	}
 
 	/**
-	 * Set the associated data? pointer with an inventory object
+	 * Set the associated quality data for an inventory object
 	 */
-	void setData(int objIndex, int id, const byte *p);
+	void setQuality(int objIndex, int id, const byte *p);
 
 	/**
 	 * Sets an item's scene number
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 9b48bde..55a348a 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -58,96 +58,178 @@ ProtectionResult GameNebular::checkCopyProtection() {
 }
 
 void GameNebular::initialiseGlobals() {
-	// Set specific values needed by the game
-	_globals[4] = 8;
-	_globals[33] = 1;
-	_globals[10] = -1;
-	_globals[13] = -1;
-	_globals[15] = -1;
-	_globals[19] = -1;
-	_globals[20] = -1;
-	_globals[21] = -1;
-	_globals[95] = -1;
-
-	_objects.setData(3, 17, nullptr);
-
-	// Put the values 0 through 3 in a random order in global slots 83 to 86
-	for (int i = 0; i < 4;) {
-		int randomVal = _vm->getRandomNumber(3);
-		_globals[83 + i] = randomVal;
-
-		bool flag = false;
-		for (int idx2 = 0; idx2 < i; ++idx2) {
-			if (_globals[83 + idx2] == randomVal)
-				flag = true;
-		}
-
-		if (!flag)
-			++i;
-	}
+	int count, count2;
+	int bad;
+
+	_globals.reset();
+	_globals[kTalkInanimateCount] = 8;
+
+	/* Section #1 variables */
+	_globals[kNeedToStandUp] = true;
+	_globals[kTurkeyExploded] = false;
+	_globals[kMedicineCabinetOpen] = false;
+	_globals[kMedicineCabinetVirgin] = true;
+	_globals[kWatchedViewScreen] = false;
+	_globals[kHoovicAlive] = true;
+	_globals[kWaterInAPuddle] = false;
+
+	_globals[kFishIn105] = true;
+	_globals[kFishIn107] = true;
+	_globals[kFishIn108] = true;
+
+	/* Section #2 variables */
+	_globals[kLadderBroken] = false;
+	_globals[kBone202Status] = 0;
+	_globals[kRhotundaStatus] = RHOTUNDA_HUNGRY;
+	_globals[kMonkeyStatus] = MONKEY_AMBUSH_READY;
+	_globals[kMeteorologistStatus] = METEOROLOGIST_PRESENT;
+	_globals[kMeteorologistEverSeen] = false;
+	_globals[kMeteorologistWatch] = METEOROLOGIST_NORMAL;
+	_globals[kTeleporterCommand] = TELEPORTER_NONE;
+	_globals[kTeleporterUnderstood] = false;
+	_globals[kTwinklesStatus] = TWINKLES_AT_HOME;
+	_globals[kTwinklesApproached] = 0;
+
+	/* Section #3 variables */
+	_globals[kAfterHavoc] = false;
+	_globals[kKickedIn391Grate] = false;
 
-	// Put the values 0 through 3 in a random order in global slots 87 to 90
-	for (int i = 0; i < 4;) {
-		int randomVal = _vm->getRandomNumber(3);
-		_globals[87 + i] = randomVal;
+	/* Section #4 variables */
+	_globals[kBadFirstIngredient] = -1;
+	_objects.setQuality(OBJ_CHARGE_CASES, EXPLOSIVES_INSIDE, nullptr);
+	_globals[kHasPurchased] = false;
+	_globals[kBeenThruHelgaScene] = false;
+	_globals[kNextIngredient] = 0;
+	_globals[kHasSaidTimer] = false;
+	_globals[kHasSaidBinocs] = false;
+	_globals[kBottleDisplayed] = false;
+	_globals[kHasBeenScanned] = false;
+	_globals[kSomeoneHasExploded] = false;
 
-		bool flag = false;
-		for (int idx2 = 0; idx2 < i; ++idx2) {
-			if (_globals[87 + idx2] == randomVal)
-				flag = true;
-		}
+	// Generate a random ingredient list
+	for (count = 0; count < 4; ++count) {
+		do {
+			_globals[kIngredientList + count] = _vm->getRandomNumber(3);
+			bad = false;
+			for (count2 = 0; count2 < count; ++count2) {
+				if (_globals[kIngredientList + count] == _globals[kIngredientList + count2]) {
+					bad = true;
+				}
+			}
+		} while (bad);
+	}
 
-		if (!flag)
-			++i;
+	// Generate random ingredient quantities
+	for (count = 0; count < 4; ++count) {
+		do {
+			_globals[kIngredientQuantity + count] = _vm->getRandomNumber(3);
+			bad = false;
+			for (count2 = 0; count2 < count; ++count2) {
+				if (_globals[kIngredientQuantity + count] == _globals[kIngredientQuantity + count2]) {
+					bad = true;
+				}
+			}
+		} while (bad);
 	}
 
-	_globals[120] = 501;
-	_globals[121] = -1;
-	_globals[55] = -1;
-	_globals[119] = 1;
-	_globals[134] = 4;
-
-	// Fill out the globals 200 to 209 with unique random values less than 10000
-	for (int i = 0; i < 10; ++i) {
-		int randomVal = _vm->getRandomNumber(9999);
-		_globals[200 + i] = randomVal;
-
-		bool flag = false;
-		for (int idx2 = 0; idx2 < i; ++idx2) {
-			if (_globals[200 + idx2] == randomVal)
-				flag = true;
-		}
-
-		if (!flag)
-			++i;
+
+	/* Section #5 variables */
+	_globals[kHoverCarLocation] = 501;
+	_globals[kHoverCarDestination] = -1;
+	_globals[kCityFlooded] = false;
+	_globals[kBoatRaised] = true;
+	_globals[kLaserHoleIsThere] = false;
+	_globals[kLineStatus] = LINE_NOT_DROPPED;
+
+
+	/* Section #6 variables */
+	_globals[kHasTalkedToHermit] = false;
+	_globals[kHandsetCellStatus] = FIRST_TIME_PHONE_CELLS;
+	_globals[kTimebombStatus] = TIMEBOMB_DEACTIVATED;
+	_globals[kWarnedFloodCity] = false;
+	_globals._timebombClock = 0;
+	_globals._timebombTimer = 0;
+
+
+	/* Section #7 variables */
+	_globals[kBottleStatus] = BOTTLE_EMPTY;
+	_globals[kBoatStatus] = BOAT_UNFLOODED;
+
+
+	/* Section #8 variables */
+	_globals[kWindowFixed] = false;
+	_globals[kInSpace] = false;
+	_globals[kReturnFromCut] = false;
+	_globals[kBeamIsUp] = false;
+	_globals[kForceBeamDown] = false;
+	_globals[kCameFromCut] = false;
+	_globals[kDontRepeat] = false;
+	_globals[kHoppyDead] = false;
+	_globals[kHasWatchedAntigrav] = false;
+	_globals[kRemoteSequenceRan] = false;
+	_globals[kRemoteOnGround] = false;
+	_globals[kFromCockpit] = false;
+	_globals[kExitShip] = false;
+	_globals[kBetweenRooms] = false;
+	_globals[kTopButtonPushed] = false;
+	_globals[kShieldModInstalled] = false;
+	_globals[kTargetModInstalled] = false;
+	_globals[kUpBecauseOfRemote] = false;
+
+
+	/* Set up the game's teleporters */
+	_globals[kTeleporterRoom] = 201;
+	_globals[kTeleporterRoom + 1] = 301;
+	_globals[kTeleporterRoom + 2] = 413;
+	_globals[kTeleporterRoom + 3] = 706;
+	_globals[kTeleporterRoom + 4] = 801;
+	_globals[kTeleporterRoom + 5] = 551;
+	_globals[kTeleporterRoom + 6] = 752;
+	_globals[kTeleporterRoom + 7] = 0;
+	_globals[kTeleporterRoom + 8] = 0;
+	_globals[kTeleporterRoom + 9] = 0;
+
+	for (count = 0; count < TELEPORTER_COUNT; ++count) {
+		do {
+			_globals[kTeleporterCode + count] = _vm->getRandomNumber(9999);
+			bad = false;
+			for (count2 = 0; count2 < count; ++count2) {
+				if (_globals[kTeleporterCode + count] == _globals[kTeleporterCode + count2]) {
+					bad = true;
+				}
+			}
+		} while (bad);
 	}
 
-	// Difficulty level control
-	switch (_difficultyLevel) {
+	// Final setup based on selected difficulty level
+	switch (_difficulty) {
 	case DIFFICULTY_HARD:
-		_globals[35] = 0;
-		_objects.setRoom(9, 1);
-		_objects.setRoom(50, 1);
-		_globals[137] = 5;
-		_globals[136] = 0;
-		break;
-	case DIFFICULTY_MEDIUM:
-		_globals[35] = 0;
-		_objects.setRoom(8, 1);
-		_globals[137] = -1;
-		_globals[136] = 6;
+		_objects.setRoom(OBJ_PLANT_STALK, NOWHERE);
+		_objects.setRoom(OBJ_PENLIGHT, NOWHERE);
+
+		_globals[kLeavesStatus] = LEAVES_ON_TRAP;
 		break;
-	case DIFFICULTY_EASY:
-		_globals[35] = 2;
-		_objects.setRoom(8, 1);
-		_objects.setRoom(27, 1);
+
+	case DIFFICULTY_REALLY_HARD:
+		_objects.setRoom(OBJ_PLANT_STALK, NOWHERE);
+
+		_globals[kLeavesStatus] = LEAVES_ON_GROUND;
+		_globals[kDurafailRecharged] = true;
+		_globals[kPenlightCellStatus] = FIRST_TIME_CHARGED_DURAFAIL;
 		break;
-	default:
+
+	case DIFFICULTY_IMPOSSIBLE:
+		_objects.setRoom(OBJ_BLOWGUN, NOWHERE);
+		_objects.setRoom(OBJ_NOTE, NOWHERE);
+
+		_globals[kLeavesStatus] = LEAVES_ON_GROUND;
+		_globals[kPenlightCellStatus] = FIRST_TIME_UNCHARGED_DURAFAIL;
+		_globals[kDurafailRecharged] = false;
 		break;
 	}
 
-	_player._direction = FACING_NORTH;
-	_player._newDirection = FACING_NORTH;
+	_player._facing = FACING_NORTH;
+	_player._turnToFacing = FACING_NORTH;
 
 	loadResourceSequence("RXM", 1);
 	loadResourceSequence("ROX", 1);
diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp
index adc58e6..c0df800 100644
--- a/engines/mads/nebular/globals_nebular.cpp
+++ b/engines/mads/nebular/globals_nebular.cpp
@@ -34,6 +34,8 @@ Globals::Globals() {
 	_spriteIndexes.resize(30);
 
 	// Initialise game flags
+	_timebombClock = 0;
+	_timebombTimer = 0;
 	_v0 = 0;
 	_frameTime = 0;
 	_v2 = 0;
@@ -53,6 +55,11 @@ Globals::Globals() {
 	_v84274 = 0;
 }
 
+void Globals::reset() {
+	for (uint i = 0; i < _flags.size(); ++i)
+		_flags[i] = 0;
+}
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index b3cc94a..703dc1b 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -178,7 +178,7 @@ enum GlobalId {
 	kAntigravTiming			= 162,
 	kAntigravTiming0		= 163,
 	kWindowFixed			= 164,
-	kinSpace                = 165,
+	kInSpace                = 165,
 	kReturnFromCut			= 166,
 	kBeamIsUp               = 167,
 	kForceBeamDown          = 168,
@@ -205,12 +205,85 @@ enum GlobalId {
 	kTeleporterCode         = 200
 };
 
+/* Enums used for specific individual globals */
+/* Section #1 */
+// State of Meteorologist in the outpost
+enum { METEOROLOGIST_ABSENT = 0, METEOROLOGIST_PRESENT = 1, METEOROLOGIST_GONE = 2 };
+
+// State of watching the Meteorologist
+enum { METEOROLOGIST_NORMAL = 0, METEOROLOGIST_GROUND = 1, METEOROLOGIST_TOWER = 2 };
+
+// The fat bouncy lady that can squish you on the plains
+enum { RHOTUNDA_HUNGRY = 0, RHOTUNDA_STUCK = 1, RHOTUNDA_GONE = 2 };
+
+// Flags for the bones you can take
+enum { BONE_202_LEFT_GONE = 1, BONE_202_RIGHT_GONE = 2 };
+
+// Leaves used to cover the trap
+enum { LEAVES_ON_GROUND = 0, LEAVES_WITH_PLAYER = 1, LEAVES_ON_TRAP = 2 };
+
+// Monkey ambush state
+enum { MONKEY_AMBUSH_READY = 0, MONKEY_HAS_BINOCULARS = 1, MONKEY_IS_GONE = 2 };
+
+// Teleporter status flags
+enum {
+	TELEPORTER_NONE = 0, TELEPORTER_BEAM_IN = 1, TELEPORTER_BEAM_OUT = 2,
+	TELEPORTER_STEP_OUT = 3, TELEPORTER_WRONG = 4
+};
+
+// TWinkies status
+enum { TWINKLES_AT_HOME = 0, TWINKLES_GONE = 1 };
+
+/* Section #4 */
+// Status of the explosives
+enum { EXPLOSIVES_INSIDE = 3 };
+
+/* Section # 5 */
+enum { LINE_NOT_DROPPED = 1, LINE_DROPPED = 2, LINE_TIED = 3, LINE_NOW_UNTIED = 4 };
+
+/* Section #6 */
+enum {
+	NO_CELLS = 0,				// Handset doesn't contain any cells
+	CHARGED_DURAFAIL = 1,		// Handset has charged durafail cells
+	UNCHARGED_DURAFAIL = 2,		// Handset has uncharged durafail cells */
+	PHONE_CELLS = 3,			// Handset has already charged phone cells
+	FIRST_TIME_PHONE_CELLS = 4,	// First time phone cells are in the handset
+	FIRST_TIME_UNCHARGED_DURAFAIL = 5,	// First time uncharged cells are in penlight
+	FIRST_TIME_CHARGED_DURAFAIL = 6		// First time charged cells are in penlight
+};
+
+// Time bomb status
+enum {
+	TIMEBOMB_DEACTIVATED = 0, TIMEBOMB_ACTIVATED = 1,
+	TIMEBOMB_BLOW_UP = 2, TIMEBOMB_DEAD = 3
+};
+
+/* Section #7 */
+// Status of the the bottle
+enum {
+	BOTTLE_EMPTY = 0, BOTTLE_ONE_QUARTER_FULL = 1, BOTTLE_HALF_FULL = 2,
+	BOTTLE_THREE_QUARTERS_FULL = 3, BOTTLE_FULL = 4
+};
+
+// Status of the boat
+enum {
+	BOAT_UNFLOODED = 0, BOAT_ADRIFT = 1, BOAT_TIED_FLOATING = 2,
+	BOAT_TIED = 3, BOAT_GONE = 4
+};
+
+
+/* Miscellaneous defines */
+#define TELEPORTER_COUNT 10      // Total number of teleporters
+#define TELEPORTER_WORK_COUNT 6  // Total number that actually work
+
+
 class Globals {
 private:
 	Common::Array<int16> _flags;
 public:
 	Common::Array<int> _spriteIndexes;
-
+	
+	int _timebombClock, _timebombTimer;
 	int _v0;
 	uint32 _frameTime;
 	int _v2;
@@ -233,6 +306,11 @@ public:
 	 * Square brackets operator for accessing flags
 	 */
 	int16 &operator[](int idx) { return _flags[idx]; }
+
+	/*
+	 * Resets all the globals to empty
+	 */
+	void reset();
 };
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 4fc1e3e..d0814f0 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -152,7 +152,7 @@ void Scene201::enter() {
 		_game._player._playerPos = Common::Point(165, 152);
 	} else {
 		_game._player._playerPos = Common::Point(223, 149);
-		_game._player._direction = FACING_SOUTH;
+		_game._player._facing = FACING_SOUTH;
 	}
 
 	if (_globals[kTeleporterCommand] != 0) {
@@ -391,10 +391,10 @@ void Scene202::enter() {
 
 	if (_scene->_priorSceneId == 201) {
 		_game._player._playerPos = Common::Point(190, 91);
-		_game._player._direction = FACING_SOUTH;
+		_game._player._facing = FACING_SOUTH;
 	} else if (_scene->_priorSceneId != -2) {
 		_game._player._playerPos = Common::Point(178, 152);
-		_game._player._direction = FACING_NORTH;
+		_game._player._facing = FACING_NORTH;
 	}
 
 	if (_globals[kLadderBroken]) {
@@ -440,12 +440,12 @@ void Scene202::enter() {
 		if (_globals._v4) {
 			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(247, 82));
 			_game._player._playerPos = Common::Point(246, 124);
-			_game._player._direction = FACING_NORTH;
+			_game._player._facing = FACING_NORTH;
 			_globals[kTeleporterUnderstood] = -1;
 		} else {
 			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
 			_game._player._playerPos = Common::Point(171, 122);
-			_game._player._direction = FACING_NORTH;
+			_game._player._facing = FACING_NORTH;
 		}
 
 		_scene->loadAnimation(formAnimName('M', -1), 71);
@@ -456,7 +456,7 @@ void Scene202::enter() {
 		_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
 		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
 		_game._player._playerPos = Common::Point(246, 124);
-		_game._player._direction = FACING_NORTH;
+		_game._player._facing = FACING_NORTH;
 	}
 	_globals._abortVal = 0;
 }
@@ -470,7 +470,7 @@ void Scene202::setRandomKernelMessage() {
 }
 
 void Scene202::step() {
-	if ((_globals._v0 == 0) && (_game._player._playerPos == Common::Point(77, 105)) && (_game._player._direction == 8) && (_vm->getRandomNumber(999) == 0)) {
+	if ((_globals._v0 == 0) && (_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == 8) && (_vm->getRandomNumber(999) == 0)) {
 		_scene->_kernelMessages.reset();
 		_globals._v0 = 0;
 		if (_vm->getRandomNumber(4) == 0)
@@ -949,7 +949,7 @@ void Scene202::actions() {
 		} else if (action->isAction(0x3, 0x142, 0)) {
 			Dialog::show(0x4EF2);
 		} else if (action->isAction(0x3, 0xAA, 0)) {
-			if ((_game._player._playerPos == Common::Point(77, 105)) && (_game._player._direction == 8))
+			if ((_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == 8))
 				Dialog::show(0x4EF4);
 			else
 				Dialog::show(0x4EF3);
@@ -986,13 +986,13 @@ void Scene203::setup() {
 void Scene203::enter() {
 	if (_scene->_priorSceneId == 202) {
 		_game._player._playerPos = Common::Point(187, 99);
-		_game._player._direction = FACING_SOUTH;
+		_game._player._facing = FACING_SOUTH;
 	} else if (_scene->_priorSceneId == 209) {
 		_game._player._playerPos = Common::Point(308, 117);
-		_game._player._direction = FACING_WEST;
+		_game._player._facing = FACING_WEST;
 	} else if (_scene->_priorSceneId == -2) {
 		_game._player._playerPos = Common::Point(155, 152);
-		_game._player._direction = FACING_NORTH;
+		_game._player._facing = FACING_NORTH;
 	}
 
 	_globals._v0 = 0;
@@ -1032,7 +1032,7 @@ void Scene203::step() {
 	if ((_game._abortTimers == 0) && (_globals._frameTime != 0))
 		return;
 
-	if ((_game._player._playerPos != Common::Point(158, 136)) || (_game._player._direction != 2))
+	if ((_game._player._playerPos != Common::Point(158, 136)) || (_game._player._facing != 2))
 		return;
 
 	_globals._frameTime = 0xFFFF;
@@ -1239,10 +1239,10 @@ void Scene207::enter() {
 	_globals._v2 = 0;
 	if (_scene->_priorSceneId == 211) {
 		_game._player._playerPos = Common::Point(13, 105);
-		_game._player._direction = FACING_EAST;
+		_game._player._facing = FACING_EAST;
 	} else if (_scene->_priorSceneId == 214) {
 		_game._player._playerPos = Common::Point(164, 117);
-		_game._player._direction = FACING_SOUTH;
+		_game._player._facing = FACING_SOUTH;
 	} else if (_scene->_priorSceneId != -2) {
 		_game._player._playerPos = Common::Point(305, 131);
 	}
@@ -1386,16 +1386,16 @@ void Scene208::enter() {
 
 	if (_scene->_priorSceneId == 207) {
 		_game._player._playerPos = Common::Point(8, 122);
-		_game._player._direction = FACING_EAST;
+		_game._player._facing = FACING_EAST;
 	} else if (_scene->_priorSceneId == 203) {
 		_game._player._playerPos = Common::Point(142, 108);
-		_game._player._direction = FACING_SOUTH;
+		_game._player._facing = FACING_SOUTH;
 	} else if (_scene->_priorSceneId == 209) {
 		_game._player._playerPos = Common::Point(307, 123);
-		_game._player._direction = FACING_WEST;
+		_game._player._facing = FACING_WEST;
 	} else if (_scene->_priorSceneId != -2) {
 		_game._player._playerPos = Common::Point(162, 149);
-		_game._player._direction = FACING_NORTH;
+		_game._player._facing = FACING_NORTH;
 	}
 
 	_game.loadQuoteSet(0x81, 0x46, 0);
@@ -1421,7 +1421,7 @@ void Scene208::step() {
 	if (_globals._v0 == 0)
 		return;
 
-	if ((_game._player._playerPos != Common::Point(20, 148)) || (_game._player._direction != 6))
+	if ((_game._player._playerPos != Common::Point(20, 148)) || (_game._player._facing != 6))
 		return;
 
 	if ((_game._abortTimers == 0) && ((_globals._frameTime & 0xFFFF) != 0))
@@ -1515,7 +1515,7 @@ void Scene208::actions() {
 	} else if (_action.isAction(0x3, 0x1AA, 0)) {
 		Dialog::show(0x5149);
 	} else if (_action.isAction(0x3, 0x1A9, 0)) {
-		if (_game._difficultyLevel == DIFFICULTY_EASY)
+		if (_game._difficulty == DIFFICULTY_IMPOSSIBLE)
 			Dialog::show(0x514A);
 		else
 			Dialog::show(0x514B);
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index c60a43a..fa92891 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -90,7 +90,7 @@ void Scene804::enter() {
 	_globals._v8 = 0;
 	if (_globals[kCopyProtectFailed]) {
 		// Copy protection failed
-		_globals[kinSpace] = -1;
+		_globals[kInSpace] = true;
 		_globals[kWindowFixed] = 0;
 	}
 
@@ -103,7 +103,7 @@ void Scene804::enter() {
 
 	_game.loadQuoteSet(791, 0);
 
-	if (_globals[kinSpace]) {
+	if (_globals[kInSpace]) {
 		if (_globals[kWindowFixed]) {
 			_globals._spriteIndexes[20] = _scene->_sequences.startCycle(
 				_globals._spriteIndexes[5], 0, 1);
@@ -137,7 +137,7 @@ void Scene804::enter() {
 
 	Scene8xx::enter1();
 
-	if (_globals[kinSpace] && !_globals[kWindowFixed]) {
+	if (_globals[kInSpace] && !_globals[kWindowFixed]) {
 		_scene->_userInterface.setup(2);
 		_vm->_sound->command(19);
 	}
@@ -191,7 +191,7 @@ void Scene804::step() {
 			if (_scene->_activeAnimation->getCurrentFrame() == 81) {
 				_globals._v5 = 80;
 			} else {
-				_globals[kinSpace] = 0;
+				_globals[kInSpace] = 0;
 				_globals[kBeamIsUp] = -1;
 				assert(!_globals[kCopyProtectFailed]);
 				_game._winStatus = 4;
@@ -203,7 +203,7 @@ void Scene804::step() {
 			if (_scene->_activeAnimation->getCurrentFrame() == 68) {
 				_globals._v5 = 66;
 			} else {
-				_globals[kinSpace] = 0;
+				_globals[kInSpace] = 0;
 				_globals[kBeamIsUp] = -1;
 				assert(!_globals[kCopyProtectFailed]);
 				_game._winStatus = 4;
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 03d03cb..115a630 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -34,8 +34,8 @@ const int Player::_directionListIndexes[32] = {
 
 Player::Player(MADSEngine *vm): _vm(vm) {
 	_action = nullptr;
-	_direction = FACING_NORTH;
-	_newDirection = FACING_NORTH;
+	_facing = FACING_NORTH;
+	_turnToFacing = FACING_NORTH;
 	_targetFacing = FACING_NORTH;
 	_spritesLoaded = false;
 	_spritesStart = 0;
@@ -73,7 +73,7 @@ void Player::reset() {
 	_action = &_vm->_game->_scene._action;
 	_destPos = _playerPos;
 	_targetFacing = FACING_NONE;
-	_newDirection = _direction;
+	_turnToFacing = _facing;
 	_moving = false;
 	_newSceneId = _v844BE = 0;
 	_next = 0;
@@ -133,42 +133,42 @@ bool Player::loadSprites(const Common::String &prefix) {
 
 void Player::turnToDestFacing() {
 	if (_targetFacing != 5)
-		_newDirection = _targetFacing;
+		_turnToFacing = _targetFacing;
 }
 
 void Player::dirChanged() {
 	int dirIndex = 0, dirIndex2 = 0;
 	int newDir = 0, newDir2 = 0;
 
-	if (_direction != _newDirection) {
+	if (_facing != _turnToFacing) {
 		// Find the index for the given direction in the player direction list
-		int tempDir = _direction;
+		int tempDir = _facing;
 		do {
 			++dirIndex;
 			newDir += tempDir;
 			tempDir = _directionListIndexes[tempDir + 10];
-		} while (tempDir != _newDirection);
+		} while (tempDir != _turnToFacing);
 	}
 
 
-	if (_direction != _newDirection) {
+	if (_facing != _turnToFacing) {
 		// Find the index for the given direction in the player direction list
-		int tempDir = _direction;
+		int tempDir = _facing;
 		do {
 			++dirIndex2;
 			newDir2 += tempDir;
 			tempDir = _directionListIndexes[tempDir + 20];
-		} while (tempDir != _newDirection);
+		} while (tempDir != _turnToFacing);
 	}
 
 	int diff = dirIndex - dirIndex2;
 	if (diff == 0)
 		diff = newDir - newDir2;
 
-	_direction = (diff >= 0) ? (Facing)_directionListIndexes[_direction + 20] : 
-		(Facing)_directionListIndexes[_direction + 10];
+	_facing = (diff >= 0) ? (Facing)_directionListIndexes[_facing + 20] :
+		(Facing)_directionListIndexes[_facing + 10];
 	setupFrame();
-	if ((_direction == _newDirection) && !_moving)
+	if ((_facing == _turnToFacing) && !_moving)
 		updateFrame();
 
 	_priorTimer += 1;
@@ -184,7 +184,7 @@ void Player::setupFrame() {
 
 	resetActionList();
 	_frameOffset = 0;
-	_spritesIdx = _directionListIndexes[_direction];
+	_spritesIdx = _directionListIndexes[_facing];
 	if (!_spriteSetsPresent[_spritesIdx]) {
 		// Direction isn't present, so use alternate direction, with entries flipped
 		_spritesIdx -= 4;
@@ -425,7 +425,7 @@ void Player::move() {
 	if (routeFlag && _moving)
 		startMovement();
 
-	if (_newDirection != _direction)
+	if (_turnToFacing != _facing)
 		dirChanged();
 	else if (!_moving)
 		updateFrame();
@@ -436,7 +436,7 @@ void Player::move() {
 		var1 = MAX(1, 10000 / (v1 * _currentScale * var1));
 	}
 
-	if (!_moving || (_direction != _newDirection))
+	if (!_moving || (_facing != _turnToFacing))
 		return;
 
 	Common::Point newPos = _playerPos;
@@ -490,7 +490,7 @@ void Player::move() {
 void Player::idle() {
 	Scene &scene = _vm->_game->_scene;
 
-	if (_direction != _newDirection) {
+	if (_facing != _turnToFacing) {
 		// The direction has changed, so reset for new direction
 		dirChanged();
 		return;
@@ -717,14 +717,14 @@ void Player::startMovement() {
 
 	switch (majorDir) {
 	case 1:
-		_newDirection = (_yDirection <= 0) ? FACING_NORTH : FACING_SOUTH;
+		_turnToFacing = (_yDirection <= 0) ? FACING_NORTH : FACING_SOUTH;
 		break;
 	case 2: {
-		_newDirection = (Facing)(((_yDirection <= 0) ? 9 : 3) - ((_xDirection <= 0) ? 2 : 0));
+		_turnToFacing = (Facing)(((_yDirection <= 0) ? 9 : 3) - ((_xDirection <= 0) ? 2 : 0));
 		break;
 	}
 	case 3:
-		_newDirection = (_xDirection <= 0) ? FACING_WEST : FACING_EAST;
+		_turnToFacing = (_xDirection <= 0) ? FACING_WEST : FACING_EAST;
 		break;
 	default:
 		break;
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 6daacd9..754ac7e 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -105,8 +105,8 @@ private:
 public:
 	MADSAction *_action;
 
-	Facing _direction;
-	Facing _newDirection;
+	Facing _facing;
+	Facing _turnToFacing;
 	int _xDirection, _yDirection;
 	Facing _targetFacing;
 	bool _spritesLoaded;
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 6a42ed9..c90a54c 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -323,7 +323,7 @@ void Scene::doFrame() {
 		_frameStartTime = _vm->_events->getFrameCounter();
 
 	if ((_action._inProgress && !player._moving && !_action._startWalkFlag &&
-			player._newDirection == player._direction) ||
+			player._turnToFacing == player._facing) ||
 			(_vm->_game->_abortTimers && _vm->_game->_abortTimersMode == ABORTMODE_0)) {
 		doAction();
 	}


Commit: 2eaafe1579abf6ab895c903bbe802451cd36f98d
    https://github.com/scummvm/scummvm/commit/2eaafe1579abf6ab895c903bbe802451cd36f98d
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-26T23:28:40+01:00

Commit Message:
MADS: Review scene 201

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index d0814f0..dbd3ccc 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -73,9 +73,9 @@ void Scene2xx::sceneEntrySound() {
 		switch (_scene->_nextSceneId) {
 		case 201:
 			if ((_globals[kTeleporterCommand] == 2) || (_globals[kTeleporterCommand] == 4) || (_globals[kMeteorologistStatus] != 1))
-				_vm->_sound->command(17);
-			else
 				_vm->_sound->command(9);
+			else
+				_vm->_sound->command(17);
 			break;
 		case 202:
 		case 203:
@@ -146,8 +146,6 @@ void Scene201::enter() {
 	int idx = _scene->_dynamicHotspots.add(1159, 209, _globals._spriteIndexes[19], Common::Rect(0, 0, 0, 0));
 	_scene->_dynamicHotspots.setPosition(idx, 186, 81, FACING_NORTH);
 
-	_globals._v0 = 0;
-
 	if ((_scene->_priorSceneId == 202) || (_scene->_priorSceneId == -1)) {
 		_game._player._playerPos = Common::Point(165, 152);
 	} else {
@@ -155,7 +153,7 @@ void Scene201::enter() {
 		_game._player._facing = FACING_SOUTH;
 	}
 
-	if (_globals[kTeleporterCommand] != 0) {
+	if (_globals[kTeleporterCommand]) {
 		_game._player._visible = false;
 		_game._player._stepEnabled = false;
 		int sepChar = (_globals[kSexOfRex] == SEX_UNKNOWN) ? 't' : 'u';
@@ -166,7 +164,7 @@ void Scene201::enter() {
 		case 1:
 			suffixNum = 3;
 			abortTimers = 76;
-			_globals[kTeleporterUnderstood] = -1;
+			_globals[kTeleporterUnderstood] = true;
 			break;
 		case 2:
 			suffixNum = 1;
@@ -196,28 +194,28 @@ void Scene201::enter() {
 		_scene->_sequences.setAnimRange(_globals._spriteIndexes[21], -1, 12);
 		_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_FRAME_INDEX, 12, 70);
 		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 1);
-		_globals._frameTime = 0;
+		_pterodactylFlag = false;
 		_game._player.startWalking(Common::Point(157, 143), FACING_NORTH);
 		_vm->_palette->setEntry(252, 45, 63, 45);
 		_vm->_palette->setEntry(253, 20, 45, 20);
 		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 2, 0, 120, _game.getQuote(90));
 	} else
-		_globals._frameTime = 0xFFFF;
+		_pterodactylFlag = true;
 
-	if (_globals[kTeleporterUnderstood] != 0)
+	if (_globals[kTeleporterUnderstood])
 		_scene->_hotspots.activate(438, false);
 
 	sceneEntrySound();
 }
 
 void Scene201::step() {
-	if ((_globals._frameTime) && (_vm->getRandomNumber(5000) == 9)) {
+	if (_pterodactylFlag && (_vm->getRandomNumber(5000) == 9)) {
 		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 5, 1, 6, 0);
 		int idx = _scene->_dynamicHotspots.add(351, 13, _globals._spriteIndexes[20], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, 270, 80, FACING_EAST);
 		_scene->_sequences.setDepth(_globals._spriteIndexes[20], 8);
 		_vm->_sound->command(14);
-		_globals._frameTime = 0;
+		_pterodactylFlag = false;
 	}
 
 	if (_game._abortTimers == 70) {
@@ -290,14 +288,13 @@ void Scene201::actions() {
 		if (action->isAction(0x18C, 0x83, 0))
 			_scene->_nextSceneId = 202;
 		else if ((action->isAction(0x50, 0x156, 0)) || (action->isAction(0x188, 0x16C, 0)) || (action->isAction(0x188, 0x1B6, 0))) {
-			if (_game._abortTimers != 0) { 
-				if (_game._abortTimers != 1)
-					_scene->_nextSceneId = 213;
-			} else {
+			if (_game._abortTimers == 0) { 
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
 				int sepChar = (_globals[kSexOfRex] == SEX_UNKNOWN) ? 't' : 'u';
 				_scene->loadAnimation(formAnimName(sepChar, 0), 1);
+			} else if (_game._abortTimers == 1) {
+				_scene->_nextSceneId = 213;
 			}
 		} else if (action->isAction(0x3, 0x1A6, 0)) {
 			Dialog::show(0x4E85);
@@ -441,7 +438,7 @@ void Scene202::enter() {
 			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(247, 82));
 			_game._player._playerPos = Common::Point(246, 124);
 			_game._player._facing = FACING_NORTH;
-			_globals[kTeleporterUnderstood] = -1;
+			_globals[kTeleporterUnderstood] = true;
 		} else {
 			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
 			_game._player._playerPos = Common::Point(171, 122);
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index a23ae98..fef9f3c 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -50,6 +50,7 @@ public:
 };
 
 class Scene201: public Scene2xx {
+	bool _pterodactylFlag;
 public:
 	Scene201(MADSEngine *vm) : Scene2xx(vm) {}
 	virtual void setup();


Commit: 253023b9bb35547c1afe9678f051fb83329d3245
    https://github.com/scummvm/scummvm/commit/253023b9bb35547c1afe9678f051fb83329d3245
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-26T20:35:18-04:00

Commit Message:
MADS: Add missing case for sprite assets palette loading

Changed paths:
    engines/mads/assets.cpp
    engines/mads/user_interface.cpp



diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index 02b91aa..ec5d542 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -88,7 +88,37 @@ void SpriteAsset::load(Common::SeekableReadStream *stream, int flags) {
 
 	// Process the palette data
 	if (flags & 9) {
-		warning("TODO: Unknown palette processing");
+		_usageIndex = 0;
+
+		if (flags & 8) {
+			int newPalCtr = 0;
+
+			for (uint i = 0; i < palette.size(); ++i) {
+				RGB6 &rgb = palette[i];
+
+				// Scan for existing rgb at beginning of the main palette
+				bool found = false;
+				for (int pIndex = 0; pIndex < 4 && !found; ++pIndex) {
+					byte *palP = &_vm->_palette->_mainPalette[pIndex * 3];
+					if (palP[0] == rgb.r && palP[1] == rgb.g && palP[2] == rgb.b) {
+						rgb._palIndex = pIndex;
+						found = true;
+					}
+				}
+
+				if (!found) {
+					// Existing palette entry not found, so need to add it in
+					int palIndex = (0xF7F607 >> (8 * newPalCtr)) & 0xff;
+					byte *palP = &_vm->_palette->_mainPalette[palIndex * 3];
+					palP[0] = rgb.r;
+					palP[1] = rgb.g;
+					palP[2] = rgb.b;
+					rgb._palIndex = palIndex;
+
+					newPalCtr = MIN(newPalCtr + 1, 2);
+				}
+			}
+		}
 	} else {
 		_usageIndex = _vm->_palette->_paletteUsage.process(palette, flags);
 		assert(_usageIndex >= 0);
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 05e9b70..67e6718 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -196,7 +196,7 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm), _dirtyAreas(vm),
 	_inventoryTopIndex = 0;
 	_objectY = 0;
 	_selectedInvIndex = -1;
-	_selectedActionIndex = -1;
+	_selectedActionIndex = 0;
 	_selectedItemVocabIdx = -1;
 	_scrollerY = 0;
 	_highlightedActionIndex = -1;


Commit: eeb4b940b7245aedb7056947b4f5c435a43fc136
    https://github.com/scummvm/scummvm/commit/eeb4b940b7245aedb7056947b4f5c435a43fc136
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-26T20:47:46-04:00

Commit Message:
MADS: Fixes for highlighting game actions

Changed paths:
    engines/mads/font.cpp
    engines/mads/user_interface.cpp



diff --git a/engines/mads/font.cpp b/engines/mads/font.cpp
index e511bd8..294139c 100644
--- a/engines/mads/font.cpp
+++ b/engines/mads/font.cpp
@@ -116,6 +116,7 @@ void Font::setColors(uint8 v1, uint8 v2, uint8 v3, uint8 v4) {
 	_fontColors[0] = v1;
 	_fontColors[1] = v2;
 	_fontColors[2] = v3;
+	_fontColors[3] = v4;
 }
 
 void Font::setColorMode(SelectionMode mode) {
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 67e6718..2a99b61 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -687,7 +687,10 @@ void UserInterface::updateSelection(ScrCategory category, int newIndex, int *idx
 void UserInterface::updateRect(const Common::Rect &bounds) {
 	_vm->_screen.setPointer(&_surface);
 	setBounds(Common::Rect(0, MADS_SCENE_HEIGHT, MADS_SCREEN_WIDTH - 1, MADS_SCREEN_HEIGHT));
-	_vm->_screen.copyRectToScreen(bounds);
+
+	Common::Rect r = bounds;
+	r.translate(0, MADS_SCENE_HEIGHT);
+	_vm->_screen.copyRectToScreen(r);
 }
 
 void UserInterface::scrollerChanged() {


Commit: fc03e5a4fadaa30efa98902f6650eb3a98651abb
    https://github.com/scummvm/scummvm/commit/fc03e5a4fadaa30efa98902f6650eb3a98651abb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-26T22:22:50-04:00

Commit Message:
MADS: Fix for selecting actions from the list

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h
    engines/mads/events.cpp
    engines/mads/screen.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index ca29527..07af95e 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -31,7 +31,6 @@ namespace MADS {
 
 MADSAction::MADSAction(MADSEngine *vm) : _vm(vm) {
 	clear();
-	_currentAction = VERB_NONE;
 	_startWalkFlag = false;
 	_statusTextIndex = -1;
 	_selectedAction = 0;
@@ -124,18 +123,18 @@ void MADSAction::set() {
 			if (_selectedRow >= 0) {
 				if (_actionMode == ACTIONMODE_VERB) {
 					// Standard verb action
-					_currentAction = scene._verbList[_selectedRow]._id;
+					_action._verbId = scene._verbList[_selectedRow]._id;
 				} else {
 					// Selected action on an inventory object
 					int invIndex = userInterface._selectedInvIndex;
 					InventoryObject &objEntry = _vm->_game->_objects.getItem(invIndex);
 
-					_currentAction = objEntry._vocabList[_selectedRow]._vocabId;
+					_action._verbId = objEntry._vocabList[_selectedRow]._vocabId;
 				}
 
 				appendVocab(_action._verbId, true);
 
-				if (_currentAction == VERB_LOOK) {
+				if (_action._verbId == VERB_LOOK) {
 					// Add in the word 'add'
 					_statusText += kAtStr;
 					_statusText += " ";
@@ -164,11 +163,11 @@ void MADSAction::set() {
 
 					if (verbId > 0) {
 						// Set the specified action
-						_currentAction = verbId;
-						appendVocab(_currentAction, true);
+						_action._verbId = verbId;
+						appendVocab(_action._verbId, true);
 					} else {
 						// Default to a standard 'walk to'
-						_currentAction = VERB_WALKTO;
+						_action._verbId = VERB_WALKTO;
 						_statusText += kWalkToStr;
 					}
 				}
diff --git a/engines/mads/action.h b/engines/mads/action.h
index 802dfb0..26ab062 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -78,7 +78,6 @@ private:
 	void checkCustomDest(int v);
 public:
 	ActionDetails _action, _activeAction;
-	int _currentAction;
 	int8 _flags1, _flags2;
 	ActionMode _actionMode;
 	ActionMode2 _actionMode2;
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index a4e1a96..70ca166 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -128,6 +128,7 @@ void EventsManager::pollEvents() {
 		case Common::EVENT_RBUTTONDOWN:
 			_mouseClicked = true;
 			_mouseButtons = 1;
+			_mouseMoved = true;
 			return;
 		case Common::EVENT_LBUTTONUP:
 		case Common::EVENT_RBUTTONUP:
@@ -190,6 +191,7 @@ void EventsManager::initVars() {
 void EventsManager::resetMouseFlags() {
 	_mouseClicked = false;
 	_mouseReleased = false;
+	_mouseButtons = 0;
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index a2cc75f..c881e95 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -300,7 +300,7 @@ void ScreenObjects::check(bool scanFlag) {
 
 		// Handling for easy mouse
 		ScrCategory category = scene._userInterface._category;
-		if (_vm->_easyMouse && !_vm->_events->_vD4 && category != _category
+		if (_vm->_easyMouse && _vm->_events->_mouseButtons && category != _category
 			&& scene._userInterface._category != CAT_NONE) {
 			_released = true;
 			if (category >= CAT_ACTION && category <= CAT_TALK_ENTRY) {
@@ -310,7 +310,7 @@ void ScreenObjects::check(bool scanFlag) {
 			scene._action.checkActionAtMousePos();
 		}
 
-		_released = _vm->_events->_mouseReleased;
+		//_released = _vm->_events->_mouseReleased;
 		if (_vm->_events->_vD2 || (_vm->_easyMouse && !_vm->_events->_vD4))
 			scene._userInterface._category = _category;
 


Commit: 0a4c4c8eda3500915372a6c9987e524016ec566f
    https://github.com/scummvm/scummvm/commit/0a4c4c8eda3500915372a6c9987e524016ec566f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-26T22:58:24-04:00

Commit Message:
MADS: Walking is now sort of working

Changed paths:
    engines/mads/action.cpp
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/scene.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 07af95e..c13f65a 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -557,8 +557,11 @@ void MADSAction::leftClick() {
 			_v86F4C = -1;
 			_v86F4E = 0;
 
-			if (_vm->_events->currentPos().y < MADS_SCENE_HEIGHT)
+			if (_vm->_events->currentPos().y < MADS_SCENE_HEIGHT) {
 				scene._customDest = _vm->_events->currentPos() + scene._posAdjust;
+				_selectedAction = -1;
+				_v86F4A = -1;
+			}
 			break;
 
 		case CAT_TALK_ENTRY:
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 70ca166..4b143ec 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -177,9 +177,27 @@ void EventsManager::delay(int cycles) {
 }
 
 void EventsManager::waitForNextFrame() {
+	_mouseClicked = false;
+	_mouseReleased = false;
+	_mouseButtons = 0;
+
+	bool mouseClicked = false;
+	bool mouseReleased = false;
+	int mouseButtons = 0;
+
 	uint32 frameCtr = getFrameCounter();
-	while (!_vm->shouldQuit() && frameCtr == _frameCounter)
+	while (!_vm->shouldQuit() && frameCtr == _frameCounter) {
 		delay(1);
+
+		mouseClicked |= _mouseClicked;
+		mouseReleased |= _mouseReleased;
+		mouseButtons |= _mouseButtons;
+	}
+
+	_mouseClicked = mouseClicked;
+	_mouseReleased = mouseReleased;
+	_mouseButtons = mouseButtons;
+	_mouseMoved = _mouseClicked || _mouseReleased;
 }
 
 void EventsManager::initVars() {
@@ -188,10 +206,4 @@ void EventsManager::initVars() {
 	_vD2 = _vD8 = 0;
 }
 
-void EventsManager::resetMouseFlags() {
-	_mouseClicked = false;
-	_mouseReleased = false;
-	_mouseButtons = 0;
-}
-
 } // End of namespace MADS
diff --git a/engines/mads/events.h b/engines/mads/events.h
index b7af148..219af20 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -141,8 +141,6 @@ public:
 	uint32 getFrameCounter() const { return _frameCounter; }
 
 	void initVars();
-
-	void resetMouseFlags();
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index c90a54c..f16b2c3 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -272,9 +272,6 @@ void Scene::loop() {
 		// Handle drawing a game frame
 		doFrame();
 
-		// Reset mouse flags
-		_vm->_events->resetMouseFlags();
-
 		// TODO: Verify correctness of frame wait
 		_vm->_events->waitForNextFrame();
 


Commit: 0e0792b37fae4f812593b6e167be5d51250a9caa
    https://github.com/scummvm/scummvm/commit/0e0792b37fae4f812593b6e167be5d51250a9caa
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-27T23:06:27+01:00

Commit Message:
MADS: Some polishing work on Scene 202

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index dbd3ccc..4a1dd09 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -367,7 +367,7 @@ void Scene202::enter() {
 	int idx = _scene->_dynamicHotspots.add(320, 13, _globals._spriteIndexes[17], Common::Rect(0, 0, 0, 0));
 	_scene->_dynamicHotspots.setPosition(idx, 153, 97, FACING_SOUTH);
 
-	if (_globals[kBone202Status] & 1) {
+	if (!(_globals[kBone202Status] & 1)) {
 		_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
 		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[16], Common::Point(130, 108));
 		_scene->_sequences.setDepth(_globals._spriteIndexes[16], 10);
@@ -375,7 +375,7 @@ void Scene202::enter() {
 		_scene->_dynamicHotspots.setPosition(idx, 132, 97, FACING_SOUTH);
 	}
 
-	if (_globals[kBone202Status] & 2) {
+	if (!(_globals[kBone202Status] & 2)) {
 		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 0, 0, 0);
 		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[21], Common::Point(166, 110));
 		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 10);
@@ -403,16 +403,16 @@ void Scene202::enter() {
 	}
 
 	_game.loadQuoteSet(0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x62, 0x63, 0x64, 0x65, 0x66, 0x61, 0);
-	_globals._v0 = 0;
+	_activeMsgFl = false;
 
-	if (_scene->_priorSceneId == -1) {
-		if (_globals._v5) {
+	if (_scene->_priorSceneId == -2) {
+		if (_waitingMeteorologistFl) {
 			_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
 			_game._player._visible = false;
 		}
 	} else {
-		_globals._v5 = 0;
-		_globals._v4 = 0;
+		_waitingMeteorologistFl = false;
+		_ladderTopFl = false;
 	}
 
 	_globals._v8425C = _globals._v7 = _scene->_frameStartTime;
@@ -424,9 +424,9 @@ void Scene202::enter() {
 		_game._player._visible = false;
 		_game._player._stepEnabled = false;
 		if (_globals[kMeteorologistWatch] == 2)
-			_globals._v4 = 1;
+			_ladderTopFl = true;
 		else
-			_globals._v4 = 0;
+			_ladderTopFl = false;
 
 		if (_globals[kMeteorologistWatch] < 1)
 			_globals._spriteIndexes[25] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
@@ -434,7 +434,7 @@ void Scene202::enter() {
 			_globals._spriteIndexes[25] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 8);
 		_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
 
-		if (_globals._v4) {
+		if (_ladderTopFl) {
 			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(247, 82));
 			_game._player._playerPos = Common::Point(246, 124);
 			_game._player._facing = FACING_NORTH;
@@ -463,19 +463,19 @@ void Scene202::setRandomKernelMessage() {
 	_scene->_kernelMessages.reset();
 	_game._abortTimersMode2 = ABORTMODE_1;
 	_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 70, 120, _game.getQuote(vocabId));
-	_globals._v0 = -1;
+	_activeMsgFl = true;
 }
 
 void Scene202::step() {
-	if ((_globals._v0 == 0) && (_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == 8) && (_vm->getRandomNumber(999) == 0)) {
+	if (!_activeMsgFl && (_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == 8) && (_vm->getRandomNumber(999) == 0)) {
 		_scene->_kernelMessages.reset();
-		_globals._v0 = 0;
+		_activeMsgFl = false;
 		if (_vm->getRandomNumber(4) == 0)
 			setRandomKernelMessage();
 	}
 
 	if (_game._abortTimers == 70)
-		_globals._v0 = 0;
+		_activeMsgFl = false;
 
 	if (_game._abortTimers == 71) {
 		_vm->_sound->command(3);
@@ -483,7 +483,7 @@ void Scene202::step() {
 		_globals._v8425C = 900 + _scene->_frameStartTime;
 		Common::Point msgPos;
 		int msgFlag;
-		if (_globals._v4 == 0) {
+		if (!_ladderTopFl) {
 			msgPos = Common::Point(0, 0);
 			msgFlag = 2;
 		} else {
@@ -542,7 +542,7 @@ void Scene202::step() {
 		_scene->_sequences.updateTimeout(-1, _globals._spriteIndexes[26]);
 		_game._player._stepEnabled = true;
 		_game._player._visible = true;
-		_globals._v4 = false;
+		_ladderTopFl = false;
 		_scene->_kernelMessages.reset();
 		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(99));
 		}
@@ -554,7 +554,7 @@ void Scene202::step() {
 	if (!_scene->_activeAnimation && (_globals[kMeteorologistStatus] != 2) && (_globals._v7 <= _scene->_frameStartTime) && (_globals._v8425C <= _scene->_frameStartTime)) {
 		int randVal = _vm->getRandomNumber(1, 500);
 		int threshold = 1;
-		if (_globals._v4)
+		if (_ladderTopFl)
 			threshold = 26;
 		if (!_globals[kMeteorologistEverSeen])
 			threshold = 25;
@@ -575,7 +575,7 @@ void Scene202::step() {
 	if (!_scene->_activeAnimation)
 		return;
 
-	if (_globals._v5) {
+	if (_waitingMeteorologistFl) {
 		if (_scene->_activeAnimation->getCurrentFrame() >= 200) {
 			if ((_globals[kMeteorologistWatch] == 2) || _globals[kLadderBroken]) {
 				_scene->_nextSceneId = 213;
@@ -588,7 +588,7 @@ void Scene202::step() {
 		if ((_scene->_activeAnimation->getCurrentFrame() == 160) && (_globals._v84260 != _scene->_activeAnimation->getCurrentFrame())) {
 			Common::Point msgPos;
 			int msgFlag;
-			if (_globals._v4 == 0) {
+			if (!_ladderTopFl) {
 				msgPos = Common::Point(0, 0);
 				msgFlag = 2;
 			} else {
@@ -716,7 +716,7 @@ void Scene202::preActions() {
 	if (action->_walkFlag)
 		_scene->_kernelMessages.reset();
 
-	if ((_globals._v4 == 0) && (action->isAction(0x4E, 0xC7, 0) || !action->_walkFlag)) {
+	if (!_ladderTopFl && (action->isAction(0x4E, 0xC7, 0) || !action->_walkFlag)) {
 		if (_game._abortTimers == 0) {
 			_vm->_sound->command(29);
 			action->_walkFlag = false;
@@ -732,19 +732,17 @@ void Scene202::preActions() {
 			_game._player._visible = true;
 			action->_walkFlag = true;
 			_game._player._stepEnabled = true;
-			_globals._v4 = 0;
-		} else {
-			// nothing
+			_ladderTopFl = false;
 		}		
 	}
 
 	if (action->isAction(0x3, 0x27, 0) && action->_activeAction._indirectObjectId > 0) {
-		if (!action->_walkFlag || (_globals._v4 != 0))
+		if (!action->_walkFlag || _ladderTopFl)
 			action->_startWalkFlag = false;
 		else
 			action->_startWalkFlag = true;
 
-		if (_globals._v4 == 0)
+		if (!_ladderTopFl)
 			_game._player.startWalking(Common::Point(171, 122), FACING_NORTH);
 	}
 }
@@ -821,7 +819,7 @@ void Scene202::actions() {
 				_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
 				_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
 				_scene->_sequences.updateTimeout(_globals._spriteIndexes[23], _globals._spriteIndexes[24]);
-				_globals._v4 = -1;
+				_ladderTopFl = true;
 				_game._player._stepEnabled = true;
 				int msgIndex = _scene->_kernelMessages.add(Common::Point(248, 15), 0x1110, 32, 0, 60, _game.getQuote(97));
 				_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
@@ -830,7 +828,7 @@ void Scene202::actions() {
 				return;
 			}
 		} else if (((action->isAction(0x3, 0x27, 0x82)) || (action->isAction(0x3, 0x27, 0x1B6))) && (_globals[kSexOfRex] == SEX_MALE)) {
-			if (_globals._v4 == 0) {
+			if (!_ladderTopFl) {
 				if (_game._abortTimers == 0) {
 					_game._player._stepEnabled = false;
 					_game._player._visible= false;
@@ -845,7 +843,7 @@ void Scene202::actions() {
 					_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
 					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
 					if (_scene->_activeAnimation) {
-						_globals._v5 = -1;
+						_waitingMeteorologistFl = true;
 						_globals[kMeteorologistWatch] = 1;
 					} else {
 						_scene->_sequences.addTimer(120, 2);
@@ -885,7 +883,7 @@ void Scene202::actions() {
 						if (_scene->_activeAnimation->getCurrentFrame() > 200) {
 							_scene->_sequences.addTimer(120, 2);
 						} else {
-							_globals._v5 = -1;
+							_waitingMeteorologistFl = true;
 							_globals[kMeteorologistWatch] = 2;
 							if ((_scene->_activeAnimation->getCurrentFrame() >= 44) && (_scene->_activeAnimation->getCurrentFrame() <= 75)) {
 								_scene->_kernelMessages.reset();
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index fef9f3c..7ef50e1 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -52,7 +52,7 @@ public:
 class Scene201: public Scene2xx {
 	bool _pterodactylFlag;
 public:
-	Scene201(MADSEngine *vm) : Scene2xx(vm) {}
+	Scene201(MADSEngine *vm) : Scene2xx(vm), _pterodactylFlag(false) {}
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
@@ -63,13 +63,15 @@ public:
 
 class Scene202: public Scene2xx {
 private:
+	bool _activeMsgFl, _ladderTopFl, _waitingMeteorologistFl;
+
 	int subStep1(int randVal);
 	int subStep2(int randVal);
 	int subStep3(int randVal);
 	int subStep4(int randVal);
 
 public:
-	Scene202(MADSEngine *vm) : Scene2xx(vm) {}
+	Scene202(MADSEngine *vm) : Scene2xx(vm), _activeMsgFl(false), _ladderTopFl(false), _waitingMeteorologistFl(false) {}
 	virtual void setup();
 	virtual void enter();
 	virtual void step();


Commit: 103e87b4049f05a5f7901110c9a685a435f60c2b
    https://github.com/scummvm/scummvm/commit/103e87b4049f05a5f7901110c9a685a435f60c2b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-27T21:03:41-04:00

Commit Message:
Merge branch 'mads' of github.com:/dreammaster/scummvm into mads

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h





Commit: 377cbbe77d5c7f16aba086e4fb1707de843ddc1a
    https://github.com/scummvm/scummvm/commit/377cbbe77d5c7f16aba086e4fb1707de843ddc1a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-27T21:04:27-04:00

Commit Message:
MADS: Cleanup of game and player fields used during initialization

Changed paths:
    engines/mads/dialogs.cpp
    engines/mads/dialogs.h
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/inventory.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/player.cpp
    engines/mads/player.h
    engines/mads/user_interface.cpp



diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index d5d7d64..c5e99f8 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -341,4 +341,8 @@ Dialogs::Dialogs(MADSEngine *vm): _vm(vm) {
 	_pendingDialog = DIALOG_NONE;
 }
 
+void Dialogs::show(int msgId) {
+
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index 56bc8ce..3f623a6 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -68,10 +68,6 @@ public:
 	 * Destructor
 	 */
 	virtual ~Dialog();
-
-	static void show(int msgId) {
-		warning("TODO: Dialog::show");
-	}
 };
 
 enum {
@@ -194,6 +190,7 @@ public:
 
 	virtual void showDialog() = 0;
 	virtual void showPicture(int objId, int msgId, int arg3 = 0) = 0;
+	void show(int msgId);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 4b143ec..37a1eec 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -76,7 +76,7 @@ void EventsManager::hideCursor() {
 	CursorMan.showMouse(false);
 }
 
-void EventsManager::resetCursor() {
+void EventsManager::waitCursor() {
 	CursorType cursorId = (CursorType)MIN(_cursorSprites->getCount(), (int)CURSOR_WAIT);
 	_newCursorId = cursorId;
 	if (_cursorId != _newCursorId) {
diff --git a/engines/mads/events.h b/engines/mads/events.h
index 219af20..b0b20b4 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -101,9 +101,9 @@ public:
 	void hideCursor();
 
 	/**
-	 * Resets the cursor, if necessary
+	 * Shows the wait cursor
 	 */
-	void resetCursor();
+	void waitCursor();
 
 	/**
 	 * Free currently loaded cursors
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 50a4f63..b89f833 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -49,9 +49,10 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 	_sectionNumber = 1;
 	_priorSectionNumber = 0;
 	_currentSectionNumber = -1;
-	_v1 = _v2 = 0;
-	_v3 = _v4 = 0;
-	_v5 = _v6 = 0;
+	_kernelMode = KERNEL_GAME_LOAD;
+	_v2 = 0;
+	_quoteEmergency = false;
+	_vocabEmergency = false;
 	_aaName = "*I0.AA";
 	_playerSpritesFlag = false;
 	_priorFrameTimer = 0;
@@ -142,7 +143,7 @@ void Game::gameLoop() {
 		}
 
 		// TODO: Extra reset methods
-		_vm->_events->resetCursor();
+		_vm->_events->waitCursor();
 		_vm->_events->freeCursors();
 		_vm->_sound->closeDriver();
 	}
@@ -152,29 +153,31 @@ void Game::gameLoop() {
 
 void Game::sectionLoop() {
 	while (!_vm->shouldQuit() && _statusFlag && _sectionNumber == _currentSectionNumber) {
-		_v1 = 3;
+		_kernelMode = KERNEL_ROOM_PRELOAD;
 		_player._spritesChanged = true;
-		_v5 = 0;
-		_v6 = 0;
-		_vm->_events->resetCursor();
+		_quoteEmergency = false;
+		_vocabEmergency = false;
+		_vm->_events->waitCursor();
 
 		_scene.clearVocab();
 		_scene._dynamicHotspots.clear();
 		_scene.loadSceneLogic();
 
-		_v4 = 0;
+		_player._walkAnywhere = false;
 		_player._stepEnabled = true;
 		_player._visible = true;
 		_vm->_dialogs->_defaultPosition = Common::Point(-1, -1);
 		_visitedScenes.add(_scene._nextSceneId);
 
+		// Reset the user interface
 		_screenObjects._v8333C = true;
 		_screenObjects._v832EC = 0;
 		_scene._userInterface._scrollerY = 0;
-		_v3 = -1;
+		
+		_player._loadsFirst = true;
 
 		_scene._sceneLogic->setup();
-		if (_player._spritesChanged || _v3) {
+		if (_player._spritesChanged || _player._loadsFirst) {
 			if (_player._spritesLoaded)
 				_scene._spriteSlots.releasePlayerSprites();
 			_vm->_palette->resetGamePalette(18, 10);
@@ -185,7 +188,7 @@ void Game::sectionLoop() {
 
 		_vm->_palette->_paletteUsage.load(3, 0xF0, 0xF1, 0xF2);
 		
-		if (!_player._spritesLoaded && _v3) {
+		if (!_player._spritesLoaded && _player._loadsFirst) {
 			if (_player.loadSprites(""))
 				_vm->quitGame();
 			_playerSpritesFlag = true;
@@ -247,10 +250,10 @@ void Game::sectionLoop() {
 			_scene._userInterface.noInventoryAnim();
 		}
 
-		_v1 = 5;
+		_kernelMode = KERNEL_ACTIVE_CODE;
 		_scene._roomChanged = false;
 
-		if ((_v5 || _v6) && !_updateSceneFlag) {
+		if ((_quoteEmergency || _vocabEmergency) && !_updateSceneFlag) {
 			_scene._currentSceneId = _scene._priorSceneId;
 			_updateSceneFlag = true;
 		} else {
@@ -258,8 +261,8 @@ void Game::sectionLoop() {
 			_scene.loop();
 		}
 
-		_vm->_events->resetCursor();
-		_v1 = 3;
+		_vm->_events->waitCursor();
+		_kernelMode = KERNEL_ROOM_PRELOAD;
 
 		delete _scene._animationData;
 		_scene._animationData = nullptr;
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 0d7178a..11fd954 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -43,9 +43,15 @@ enum Difficulty {
 	DIFFICULTY_HARD = 1, DIFFICULTY_REALLY_HARD = 2, DIFFICULTY_IMPOSSIBLE = 3
 };
 
+enum KernelMode {
+	KERNEL_GAME_LOAD = 0, KERNEL_SECTION_PRELOAD = 1, KERNEL_SECTION_INIT = 2,
+	KERNEL_ROOM_PRELOAD = 3, KERNEL_ROOM_INIT = 4, KERNEL_ACTIVE_CODE = 5
+};
+
 enum ProtectionResult {
 	PROTECTION_SUCCEED = 0, PROTECTION_FAIL = 1, PROTECTION_ESCAPE = 2
 };
+;
 
 class Game {
 private:
@@ -69,8 +75,8 @@ protected:
 	int _saveSlot;
 	int _statusFlag;
 	Common::StringArray _quotes;
-	int _v5;
-	int _v6;
+	bool _quoteEmergency;
+	bool _vocabEmergency;
 	bool _updateSceneFlag;
 	bool _playerSpritesFlag;
 
@@ -125,10 +131,8 @@ public:
 	SectionHandler *_sectionHandler;
 	VisitedScenes _visitedScenes;
 	Scene _scene;
-	int _v1;
+	KernelMode _kernelMode;
 	int _v2;
-	int _v3;
-	int _v4;
 	int _abortTimers;
 	int _abortTimers2;
 	AbortTimerMode _abortTimersMode;
diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index 3237d55..a8e50e6 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -116,7 +116,7 @@ void InventoryObjects::addToInventory(int objectId) {
 
 		(*this)[objectId]._roomNumber = PLAYER_INVENTORY;
 
-		if (_vm->_game->_v1 == 5 && !_vm->_game->_screenObjects._v832EC) {
+		if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE && !_vm->_game->_screenObjects._v832EC) {
 			userInterface.categoryChanged();
 			userInterface.selectObject(userInterface._selectedInvIndex);
 		}
@@ -137,7 +137,7 @@ void InventoryObjects::removeFromInventory(int objectId, int newScene) {
 	int selectedIndex = userInterface._selectedInvIndex;
 	bool noSelection = selectedIndex < 0;
 
-	if (_vm->_game->_v1 == 5 && !_vm->_game->_screenObjects._v832EC)
+	if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE && !_vm->_game->_screenObjects._v832EC)
 		userInterface.selectObject(-1);
 
 	// Remove the item from the inventory list
@@ -158,7 +158,7 @@ void InventoryObjects::removeFromInventory(int objectId, int newScene) {
 			newIndex = 0;
 	}
 
-	if (_vm->_game->_v1 == 5 && !_vm->_game->_screenObjects._v832EC) {
+	if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE && !_vm->_game->_screenObjects._v832EC) {
 		userInterface.categoryChanged();
 		userInterface.selectObject(newIndex);
 	}
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 4c3b67f..554c73d 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -89,7 +89,7 @@ void Scene1xx::setPlayerSpritesPrefix() {
 		_game._player._spritesChanged = true;
 	if (_scene->_nextSceneId == 105 || (_scene->_nextSceneId == 109 && _globals[kHoovicAlive])) {
 		_game._player._spritesChanged = true;
-		_game._v3 = 0;
+		_game._player._loadsFirst = false;
 	}
 
 	_game._player._unk3 = 0;
@@ -258,7 +258,7 @@ void Scene103::preActions() {
 
 void Scene103::actions() {
 	if (_action._savedFields._lookFlag) {
-		Dialog::show(10322);
+		_vm->_dialogs->show(10322);
 	} else if (_action.isAction(395, 110, 0)) {
 		switch (_vm->_game->_abortTimers) {
 		case 0:
@@ -342,7 +342,7 @@ void Scene103::actions() {
 			break;
 		}
 	} else if (_action.isAction(VERB_LOOK, 362, 0)) {
-		Dialog::show(10301);
+		_vm->_dialogs->show(10301);
 	} else if (_action.isAction(VERB_TAKE, 362, 0)) {
 		if (!_vm->_game->_abortTimers)
 			_vm->_sound->command(31);
@@ -364,12 +364,12 @@ void Scene103::actions() {
 			_game._player._stepEnabled = _game._abortTimers == 2;
 			_globals[kTurkeyExploded] = -1;
 			if (_game._abortTimers == 2) {
-				Dialog::show(1030);
+				_vm->_dialogs->show(1030);
 				_scene->_hotspots.activate(362, false);
 			}
 		}
 	} else if (_action.isAction(VERB_LOOK, 250, 0)) {
-		Dialog::show(!_globals[kTurkeyExploded] ? 10323 : 10303);
+		_vm->_dialogs->show(!_globals[kTurkeyExploded] ? 10323 : 10303);
 	}
 	else if (_action.isAction(VERB_TALKTO, 27, 0)) {
 		switch (_vm->_game->_abortTimers) {
@@ -394,46 +394,46 @@ void Scene103::actions() {
 
 		case 3:
 			_game._player._stepEnabled = true;
-			Dialog::show(10306);
+			_vm->_dialogs->show(10306);
 			break;
 
 		default:
 			break;
 		}
 	} else if (!_action.isAction(VERB_LOOK, 27, 0)) {
-		Dialog::show(10304);
+		_vm->_dialogs->show(10304);
 	} else if (!_action.isAction(VERB_LOOK, 36, 0)) {
-		Dialog::show(10307);
+		_vm->_dialogs->show(10307);
 	} else if (!_action.isAction(VERB_LOOK, 55, 0)) {
-		Dialog::show(10308);
+		_vm->_dialogs->show(10308);
 	} else if (!_action.isAction(VERB_TAKE, 315, 0)) {
-		Dialog::show(10309);
+		_vm->_dialogs->show(10309);
 	} else if (!_action.isAction(VERB_TAKE, 85, 0)) {
-		Dialog::show(10310);
+		_vm->_dialogs->show(10310);
 	} else if (!_action.isAction(VERB_LOOK, 144, 0)) {
-		Dialog::show(10312);
+		_vm->_dialogs->show(10312);
 	} else if (!_action.isAction(VERB_OPEN, 144, 0)) {
-		Dialog::show(10313);
+		_vm->_dialogs->show(10313);
 	} else if (!_action.isAction(VERB_CLOSE, 27, 0)) {
-		Dialog::show(10314);
+		_vm->_dialogs->show(10314);
 	} else if (!_action.isAction(VERB_LOOK, 310, 0)) {
-		Dialog::show(10315);
+		_vm->_dialogs->show(10315);
 	} else if (!_action.isAction(VERB_LOOK, 178, 0)) {
-		Dialog::show(10316);
+		_vm->_dialogs->show(10316);
 	} else if (!_action.isAction(VERB_LOOK, 283, 0)) {
-		Dialog::show(10317);
+		_vm->_dialogs->show(10317);
 	} else if (!_action.isAction(VERB_LOOK, 120, 0)) {
-		Dialog::show(10318);
+		_vm->_dialogs->show(10318);
 	} else if (_action.isAction(VERB_LOOK, 289, 0) &&
 			_game._objects.isInInventory(OBJ_REBREATHER)) {
-		Dialog::show(10319);
+		_vm->_dialogs->show(10319);
 	} else if (_action.isAction(VERB_LOOK, 371, 0) &&
 			_game._objects.isInInventory(OBJ_TIMER_MODULE)) {
-		Dialog::show(10320);
+		_vm->_dialogs->show(10320);
 	} else if (!_action.isAction(VERB_LOOK, 137, 0)) {
-		Dialog::show(10321);
+		_vm->_dialogs->show(10321);
 	} else if (_action.isAction(VERB_LOOK, 409, 0)) {
-		Dialog::show(_game._objects.isInInventory(OBJ_TIMER_MODULE) ? 10324 : 10325);
+		_vm->_dialogs->show(_game._objects.isInInventory(OBJ_TIMER_MODULE) ? 10324 : 10325);
 	}
 
 	_action._inProgress = false;
@@ -441,7 +441,7 @@ void Scene103::actions() {
 
 void Scene103::postActions() {
 	if (_action.isAction(27) && !_action.isAction(13)) {
-		Dialog::show(0x2841);
+		_vm->_dialogs->show(0x2841);
 		_action._inProgress = false;
 	} else {
 		if (_action.isAction(7, 85, 144)) {
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 4a1dd09..83dcfa3 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -62,7 +62,7 @@ void Scene2xx::setPlayerSpritesPrefix() {
 		_game._player._spritesChanged = true;
 	
 	if ((_scene->_nextSceneId == 203 || _scene->_nextSceneId == 204) && _globals[kRhotundaStatus])
-		_game._v3 = 0;
+		_game._player._loadsFirst = false;
 
 	_vm->_palette->setEntry(16, 10, 63, 63);
 	_vm->_palette->setEntry(17, 10, 45, 45);
@@ -277,7 +277,7 @@ void Scene201::step() {
 
 	if (_game._abortTimers == 78) {
 		_vm->_sound->command(40);
-		Dialog::show(0x4E92);
+		_vm->_dialogs->show(0x4E92);
 		_scene->_reloadSceneFlag = true;
 	}
 }
@@ -297,34 +297,34 @@ void Scene201::actions() {
 				_scene->_nextSceneId = 213;
 			}
 		} else if (action->isAction(0x3, 0x1A6, 0)) {
-			Dialog::show(0x4E85);
+			_vm->_dialogs->show(0x4E85);
 		} else if (action->isAction(0x3, 0x129, 0)) {
-			Dialog::show(0x4E86);
+			_vm->_dialogs->show(0x4E86);
 		} else if (action->isAction(0x3, 0x16F, 0)) {
-			Dialog::show(0x4E87);
+			_vm->_dialogs->show(0x4E87);
 		} else if (action->isAction(0x3, 0x142, 0)) {
-			Dialog::show(0x4E88);
+			_vm->_dialogs->show(0x4E88);
 		} else if (action->isAction(0x3, 0x18F, 0)) {
-			Dialog::show(0x4E89);
+			_vm->_dialogs->show(0x4E89);
 		} else if (action->isAction(0x3, 0x1B9, 0)) {
-			Dialog::show(0x4E8A);
+			_vm->_dialogs->show(0x4E8A);
 		} else if (action->isAction(0x3, 0x192, 0)) {
-			Dialog::show(0x4E8B);
+			_vm->_dialogs->show(0x4E8B);
 		} else if (action->isAction(0x3, 0x1BA, 0)) {
-			Dialog::show(0x4E8C);
+			_vm->_dialogs->show(0x4E8C);
 		} else if (action->isAction(0x3, 0x83, 0)) {
-			Dialog::show(0x4E8E);
+			_vm->_dialogs->show(0x4E8E);
 		} else if (action->isAction(0x3, 0x1B6, 0)) {
 			if (_globals[kMeteorologistEverSeen])
-				Dialog::show(0x4E90);
+				_vm->_dialogs->show(0x4E90);
 			else
-				Dialog::show(0x4E8D);
+				_vm->_dialogs->show(0x4E8D);
 		} else if (action->isAction(0x3, 0x16C, 0)) {
-			Dialog::show(0x4E91);
+			_vm->_dialogs->show(0x4E91);
 		} else
 			return;
 	} else {
-		Dialog::show(0x4E8F);
+		_vm->_dialogs->show(0x4E8F);
 	}
 	action->_inProgress = false;
 }
@@ -580,7 +580,7 @@ void Scene202::step() {
 			if ((_globals[kMeteorologistWatch] == 2) || _globals[kLadderBroken]) {
 				_scene->_nextSceneId = 213;
 			} else {
-				Dialog::show(0x4EE9);
+				_vm->_dialogs->show(0x4EE9);
 				_scene->_reloadSceneFlag = true;
 			}
 		}
@@ -767,7 +767,7 @@ void Scene202::actions() {
 			if (action->_actionMode2 == 4) {
 				if (_game._abortTimers == 0) {
 					if (_game._objects.isInInventory(OBJ_BONES)) {
-						Dialog::show(0x4EFB);
+						_vm->_dialogs->show(0x4EFB);
 					} else {
 						_game._player._stepEnabled = false;
 						_game._player._visible = false;
@@ -850,7 +850,7 @@ void Scene202::actions() {
 					}
 				} else if (_game._abortTimers == 2) {
 					if (!_scene->_activeAnimation && (_globals._abortVal == 0)) {
-						Dialog::show(0x4EFE);
+						_vm->_dialogs->show(0x4EFE);
 					}
 					_scene->_sequences.remove(_globals._spriteIndexes[25]);
 					_globals._spriteIndexes[25] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
@@ -899,7 +899,7 @@ void Scene202::actions() {
 					}
 				} else if (_game._abortTimers == 2) {
 					if (!_scene->_activeAnimation)
-						Dialog::show(0x4EFE);
+						_vm->_dialogs->show(0x4EFE);
 					_globals._abortVal = 0;
 					_scene->_sequences.remove(_globals._spriteIndexes[25]);
 					_globals._spriteIndexes[24] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
@@ -919,53 +919,53 @@ void Scene202::actions() {
 		} else if (action->isAction(0x188, 0xAA, 0)) {
 			setRandomKernelMessage();
 		} else if (action->isAction(0x3, 0x129, 0)) {
-			Dialog::show(0x4EEA);
+			_vm->_dialogs->show(0x4EEA);
 		} else if (action->isAction(0x3, 0x86, 0)) {
-			Dialog::show(0x4EEB);
+			_vm->_dialogs->show(0x4EEB);
 		} else if (action->isAction(0x3, 0x19C, 0)) {
-			Dialog::show(0x4EEC);
+			_vm->_dialogs->show(0x4EEC);
 		} else if (action->isAction(0x3, 0x82, 0)) {
 			if ((_globals[kMeteorologistStatus] == 0) || (_globals[kMeteorologistStatus] == 2)) {
-				Dialog::show(0x4EED);
+				_vm->_dialogs->show(0x4EED);
 			} else if (_globals[kMeteorologistStatus] == 1) {
-				Dialog::show(0x4EFC);
+				_vm->_dialogs->show(0x4EFC);
 			} else {
 				action->_inProgress = false;
 				return;
 			} 
 		} else if (action->isAction(0x3, 0x18E, 0)) {
-			Dialog::show(0x4EEE);
+			_vm->_dialogs->show(0x4EEE);
 		} else if (action->isAction(0x3, 0x164, 0)) {
-			Dialog::show(0x4EEF);
+			_vm->_dialogs->show(0x4EEF);
 		} else if (action->isAction(0x3, 0x175, 0)) {
-			Dialog::show(0x4EF0);
+			_vm->_dialogs->show(0x4EF0);
 		} else if (action->isAction(0x3, 0x174, 0)) {
-			Dialog::show(0x4EF1);
+			_vm->_dialogs->show(0x4EF1);
 		} else if (action->isAction(0x3, 0x142, 0)) {
-			Dialog::show(0x4EF2);
+			_vm->_dialogs->show(0x4EF2);
 		} else if (action->isAction(0x3, 0xAA, 0)) {
 			if ((_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == 8))
-				Dialog::show(0x4EF4);
+				_vm->_dialogs->show(0x4EF4);
 			else
-				Dialog::show(0x4EF3);
+				_vm->_dialogs->show(0x4EF3);
 		} else if (action->isAction(0x3, 0x186, 0)) {
-			Dialog::show(0x4EF5);
+			_vm->_dialogs->show(0x4EF5);
 		} else if (action->isAction(0x3, 0x1B5, 0)) {
-			Dialog::show(0x4EF6);
+			_vm->_dialogs->show(0x4EF6);
 		} else if (action->isAction(0x3, 0x140, 0)) {
-			Dialog::show(0x4EF7);
+			_vm->_dialogs->show(0x4EF7);
 		} else if (action->isAction(0x4, 0x140, 0)) {
-			Dialog::show(0x4EF8);
+			_vm->_dialogs->show(0x4EF8);
 		} else if (action->isAction(0x3, 0x2D, 0)) {
 			if (action->_actionMode == 4)
-				Dialog::show(0x4EF9);
+				_vm->_dialogs->show(0x4EF9);
 			else
 				return;
 		} else {
 			return;			
 		}
 	} else {
-		Dialog::show(0x4EFB);
+		_vm->_dialogs->show(0x4EFB);
 	}
 	action->_inProgress = false;
 }
@@ -1059,23 +1059,23 @@ void Scene203::preActions() {
 
 void Scene203::actions() {
 	if (_action._savedFields._lookFlag) {
-		Dialog::show(0x4F53);
+		_vm->_dialogs->show(0x4F53);
 	} else if (_action.isAction(0x18C, 0x83, 0)) {
 		_scene->_nextSceneId = 208;
 	} else if (_action.isAction(0x18C, 0x82, 0)) {
 		_scene->_nextSceneId = 202;
 	} else if (_action.isAction(0x3, 0x142, 0)) {
-		Dialog::show(0x4F4D);
+		_vm->_dialogs->show(0x4F4D);
 	} else if (_action.isAction(0x3, 0x4D, 0)) {
-		Dialog::show(0x4F4E);
+		_vm->_dialogs->show(0x4F4E);
 	} else if (_action.isAction(0x3, 0x100, 0)) {
-		Dialog::show(0x4F4F);
+		_vm->_dialogs->show(0x4F4F);
 	} else if (_action.isAction(0x3, 0x82, 0)) {
-		Dialog::show(0x4F50);
+		_vm->_dialogs->show(0x4F50);
 	} else if (_action.isAction(0x3, 0x1A6, 0)) {
-		Dialog::show(0x4F51);
+		_vm->_dialogs->show(0x4F51);
 	} else if (_action.isAction(0x3, 0x30, 0)) {
-		Dialog::show(0x4F51);
+		_vm->_dialogs->show(0x4F51);
 	} else
 		return;
 
@@ -1299,7 +1299,7 @@ void Scene207::preActions() {
 
 void Scene207::actions() {
 	if (_action._savedFields._lookFlag) {
-		Dialog::show(0x50E7);
+		_vm->_dialogs->show(0x50E7);
 	} else {
 		if (_action.isAction(0x18B, 0x70, 0))
 			_scene->_nextSceneId = 214;
@@ -1320,33 +1320,33 @@ void Scene207::actions() {
 			}
 
 			if (_action.isAction(3, 0x69, 0)) {
-				Dialog::show(0x50DD);
+				_vm->_dialogs->show(0x50DD);
 			} else if (_action.isAction(3, 0x1AF, 0)) {
-				Dialog::show(0x50DE);
+				_vm->_dialogs->show(0x50DE);
 			} else if (_action.isAction(3, 0x141, 0)) {
-				Dialog::show(0x50DF);
+				_vm->_dialogs->show(0x50DF);
 			} else if (_action.isAction(3, 0x3E, 0)) {
-				Dialog::show(0x50E0);
+				_vm->_dialogs->show(0x50E0);
 			} else if (_action.isAction(3, 0x198, 0)) {
-				Dialog::show(0x50E1);
+				_vm->_dialogs->show(0x50E1);
 			} else if (_action.isAction(3, 0x1AE, 0)) {
-				Dialog::show(0x50E2);
+				_vm->_dialogs->show(0x50E2);
 			} else if (_action.isAction(3, 0xE8, 0)) {
-				Dialog::show(0x50E3);
+				_vm->_dialogs->show(0x50E3);
 			} else if (_action.isAction(3, 0x12, 0)) {
-				Dialog::show(0x50E4);
+				_vm->_dialogs->show(0x50E4);
 			} else if (_action.isAction(3, 0x1AC, 0)) {
-				Dialog::show(0x50E5);
+				_vm->_dialogs->show(0x50E5);
 			} else if (_action.isAction(3, 0x185, 0)) {
-				Dialog::show(0x50E6);
+				_vm->_dialogs->show(0x50E6);
 			} else if (_action.isAction(4, 0x141, 0)) {
-				Dialog::show(0x50E8);
+				_vm->_dialogs->show(0x50E8);
 			} else if (_action.isAction(4, 0x12, 0)) {
-				Dialog::show(0x50E9);
+				_vm->_dialogs->show(0x50E9);
 			} else if (_action.isAction(3, 0x14D, 0)) {
-				Dialog::show(0x50EA);
+				_vm->_dialogs->show(0x50EA);
 			} else if (_action.isAction(4, 0x14D, 0)) {
-				Dialog::show(0x50EB);
+				_vm->_dialogs->show(0x50EB);
 			} else
 				return;
 		}
@@ -1484,52 +1484,52 @@ void Scene208::actions() {
 	} else if (_action.isAction(0x7, 0x35, 0x1A9)) {
 		warning("TODO: sub3B282(4);");
 		if (_game._player._stepEnabled) {
-			Dialog::show(0x514C);
+			_vm->_dialogs->show(0x514C);
 		}
 	} else if (_action.isAction(0x7, 0x65, 0x1A9)) {
 		warning("TODO: sub3B282(5);");
 		if (_game._player._stepEnabled) {
-			Dialog::show(0x514C);
+			_vm->_dialogs->show(0x514C);
 		}
 	} else if (_action.isAction(0x3, 0x5D, 0)) {
-		Dialog::show(0x5141);
+		_vm->_dialogs->show(0x5141);
 	} else if (_action.isAction(0x3, 0xF6, 0)) {
-		Dialog::show(0x5142);
+		_vm->_dialogs->show(0x5142);
 	} else if (_action.isAction(0x3, 0x16F, 0)) {
-		Dialog::show(0x5143);
+		_vm->_dialogs->show(0x5143);
 	} else if (_action.isAction(0x3, 0x129, 0)) {
-		Dialog::show(0x5144);
+		_vm->_dialogs->show(0x5144);
 	} else if (_action.isAction(0x3, 0x1A1, 0)) {
-		Dialog::show(0x5145);
+		_vm->_dialogs->show(0x5145);
 	} else if (_action.isAction(0x4, 0x1A1, 0)) {
-		Dialog::show(0x5146);
+		_vm->_dialogs->show(0x5146);
 	} else if (_action.isAction(0x3, 0x9B, 0)) {
-		Dialog::show(0x5147);
+		_vm->_dialogs->show(0x5147);
 	} else if (_action.isAction(0x3, 0x19E, 0)) {
-		Dialog::show(0x5148);
+		_vm->_dialogs->show(0x5148);
 	} else if (_action.isAction(0x3, 0x1AA, 0)) {
-		Dialog::show(0x5149);
+		_vm->_dialogs->show(0x5149);
 	} else if (_action.isAction(0x3, 0x1A9, 0)) {
 		if (_game._difficulty == DIFFICULTY_IMPOSSIBLE)
-			Dialog::show(0x514A);
+			_vm->_dialogs->show(0x514A);
 		else
-			Dialog::show(0x514B);
+			_vm->_dialogs->show(0x514B);
 	} else if (_action.isAction(0x3, 0x174, 0) || _action.isAction(0x3, 0x175, 0)) {
-		Dialog::show(0x514D);
+		_vm->_dialogs->show(0x514D);
 	} else if (_action.isAction(0x4, 0x1A9, 0)) {
-		Dialog::show(0x514E);
+		_vm->_dialogs->show(0x514E);
 	} else if (_action.isAction(0x3, 0x1A8, 0)) {
-		Dialog::show(0x514F);
+		_vm->_dialogs->show(0x514F);
 	} else if (_action.isAction(0x4, 0x1A8, 0) || _action.isAction(0xA, 0x1A8, 0)) {
-		Dialog::show(0x5150);
+		_vm->_dialogs->show(0x5150);
 	} else if (_action._savedFields._lookFlag == 0) {
 		return;
 	} else if (_globals[kRhotundaStatus] == 1) {
-		Dialog::show(0x5153);
+		_vm->_dialogs->show(0x5153);
 	} else if (_globals[kLeavesStatus] == 2) {
-		Dialog::show(0x5152);
+		_vm->_dialogs->show(0x5152);
 	} else {
-		Dialog::show(0x5151);
+		_vm->_dialogs->show(0x5151);
 	}
 
 	_action._inProgress = false;
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index fa92891..64c4916 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -268,9 +268,9 @@ void Scene804::step() {
 	}
 
 	if (_game._abortTimers == 120)
-		Dialog::show(0x13a26);
+		_vm->_dialogs->show(0x13a26);
 	if (_game._abortTimers == 110)
-		Dialog::show(0x13a2a);
+		_vm->_dialogs->show(0x13a2a);
 
 	if (_globals._v6) {
 		_globals._v5 = 32;
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 115a630..7e1ceba 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -45,6 +45,8 @@ Player::Player(MADSEngine *vm): _vm(vm) {
 	_visible = false;
 	_priorVisible = false;
 	_visible3 = false;
+	_loadsFirst = false;
+	_walkAnywhere = false;
 	_special = 0;
 	_ticksAmount = 0;
 	_priorTimer = 0;
@@ -78,8 +80,8 @@ void Player::reset() {
 	_newSceneId = _v844BE = 0;
 	_next = 0;
 	_routeCount = 0;
+	_walkAnywhere = false;
 
-	_vm->_game->_v4 = 0;
 	_action->_startWalkFlag = false;
 	_action->_walkFlag = false;
 }
@@ -311,7 +313,7 @@ void Player::update() {
 						playerY < 0 || (playerY + yScale) >= MADS_SCENE_HEIGHT) {
 					scene._nextSceneId = _newSceneId;
 					_newSceneId = 0;
-					_vm->_game->_v4 = 0;
+					_walkAnywhere = false;
 				}
 			}
 
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 754ac7e..afd55b2 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -118,7 +118,9 @@ public:
 	bool _visible;
 	bool _priorVisible;
 	bool _visible3;
+	bool _walkAnywhere;
 	int _frameNum;
+	bool _loadsFirst;
 	Common::Point _playerPos;
 	Common::Point _destPos;
 	Common::Point _posChange;
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 2a99b61..8a7bac1 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -269,7 +269,7 @@ void UserInterface::setup(int id) {
 	_v1E = -1;
 	_v1C = -1;
 
-	if (_vm->_game->_v1 == 5)
+	if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE)
 		scene._userInterface._uiSlots.draw(false, false);
 
 	scene._action.clear();


Commit: 6c85572d76245f616ae3bf2ac1ccc713d8271fa9
    https://github.com/scummvm/scummvm/commit/6c85572d76245f616ae3bf2ac1ccc713d8271fa9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-27T22:38:28-04:00

Commit Message:
MADS: Initial cleanup of action/player handling

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h
    engines/mads/animation.cpp
    engines/mads/animation.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/messages.cpp
    engines/mads/messages.h
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/player.cpp
    engines/mads/player.h
    engines/mads/scene.cpp
    engines/mads/scene_data.cpp
    engines/mads/screen.cpp
    engines/mads/screen.h
    engines/mads/sequence.cpp
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index c13f65a..e997261 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -47,7 +47,7 @@ MADSAction::MADSAction(MADSEngine *vm) : _vm(vm) {
 }
 
 void MADSAction::clear() {
-	_v83338 = 1;
+	_interAwaiting = AWAITING_COMMAND;
 	_actionMode = ACTIONMODE_NONE;
 	_actionMode2 = ACTIONMODE2_0;
 	_v86F42 = 0;
@@ -269,7 +269,7 @@ void MADSAction::startAction() {
 	DynamicHotspots &dynHotspots = scene._dynamicHotspots;
 	Hotspots &hotspots = scene._hotspots;
 
-	game._player.moveComplete();
+	game._player.cancelCommand();
 
 	_inProgress = true;
 	_v8453A = ABORTMODE_0;
@@ -354,12 +354,12 @@ void MADSAction::checkActionAtMousePos() {
 	UserInterface &userInterface = scene._userInterface;
 	ScreenObjects &screenObjects = _vm->_game->_screenObjects;
 
-	if ((userInterface._category == CAT_ACTION || userInterface._category == CAT_INV_VOCAB) &&
-			_v83338 != 1 && scene._highlightedHotspot >= 0) {
+	if ((userInterface._category == CAT_COMMAND || userInterface._category == CAT_INV_VOCAB) &&
+			_interAwaiting != 1 && scene._highlightedHotspot >= 0) {
 		if (_v86F4E == userInterface._category || _v86F4C != scene._highlightedHotspot ||
-			(_v83338 != 2 && _v83338 != 3))
+			(_interAwaiting != 2 && _interAwaiting != 3))
 			clear();
-		else if (_selectedRow != 0 || userInterface._category != CAT_ACTION)
+		else if (_selectedRow != 0 || userInterface._category != CAT_COMMAND)
 			scene._lookFlag = false;
 		else
 			scene._lookFlag = true;
@@ -367,19 +367,19 @@ void MADSAction::checkActionAtMousePos() {
 
 	if (screenObjects._v7FECA && _vm->_events->_mouseButtons) {
 		switch (userInterface._category) {
-		case CAT_ACTION:
+		case CAT_COMMAND:
 		case CAT_INV_VOCAB:
 			return;
 
 		case CAT_INV_LIST:
 		case CAT_TALK_ENTRY:
-			if (_v83338 != 3) {
+			if (_interAwaiting != 3) {
 				if (userInterface._selectedActionIndex >= 0) {
 					_actionMode = ACTIONMODE_VERB;
 					_selectedRow = userInterface._selectedActionIndex;
 					_flags1 = scene._verbList[_selectedRow]._action1;
 					_flags2 = scene._verbList[_selectedRow]._action2;
-					_v83338 = 2;
+					_interAwaiting = AWAITING_THIS;
 				} else if (userInterface._selectedItemVocabIdx >= 0) {
 					_actionMode = ACTIONMODE_OBJECT;
 					_selectedRow = userInterface._selectedItemVocabIdx;
@@ -393,20 +393,20 @@ void MADSAction::checkActionAtMousePos() {
 					_articleNumber = _flags2;
 
 					if ((_flags1 == 1 && _flags2 == 0) || (_flags1 == 2 && _flags2 != 0))
-						_v83338 = 4;
+						_interAwaiting = AWAITING_RIGHT_MOUSE;
 					else
-						_v83338 = 3;
+						_interAwaiting = AWAITING_THAT;
 				}
 			}
 			break;
 		}
 	}
 
-	switch (_v83338) {
+	switch (_interAwaiting) {
 	case 1:
 		_articleNumber = 0;
 		switch (userInterface._category) {
-		case CAT_ACTION:
+		case CAT_COMMAND:
 			_actionMode = ACTIONMODE_VERB;
 			_selectedRow = scene._highlightedHotspot;
 			if (_selectedRow >= 0) {
@@ -491,13 +491,13 @@ void MADSAction::leftClick() {
 	ScreenObjects &screenObjects = _vm->_game->_screenObjects;
 	bool abortFlag = false;
 
-	if ((userInterface._category == CAT_ACTION || userInterface._category == CAT_INV_VOCAB) &&
-			_v83338 != 1 && scene._highlightedHotspot >= 0 && 
+	if ((userInterface._category == CAT_COMMAND || userInterface._category == CAT_INV_VOCAB) &&
+			_interAwaiting != 1 && scene._highlightedHotspot >= 0 && 
 			_v86F4E == userInterface._category && _v86F4C == scene._highlightedHotspot &&
-			(_v83338 == 2 || userInterface._category == CAT_INV_VOCAB)) {
+			(_interAwaiting == 2 || userInterface._category == CAT_INV_VOCAB)) {
 		abortFlag = true;
-		if (_selectedRow == 0 && userInterface._category == CAT_ACTION) {
-			_selectedAction = CAT_ACTION;
+		if (_selectedRow == 0 && userInterface._category == CAT_COMMAND) {
+			_selectedAction = CAT_COMMAND;
 			scene._lookFlag = true;
 		} else {
 			_selectedAction = CAT_NONE;
@@ -506,14 +506,14 @@ void MADSAction::leftClick() {
 		}
 	}
 
-	if (abortFlag || (screenObjects._v7FECA && (userInterface._category == CAT_ACTION ||
+	if (abortFlag || (screenObjects._v7FECA && (userInterface._category == CAT_COMMAND ||
 			userInterface._category == CAT_INV_VOCAB)))
 		return;
 
-	switch (_v83338) {
-	case 1:
+	switch (_interAwaiting) {
+	case AWAITING_COMMAND:
 		switch (userInterface._category) {
-		case CAT_ACTION:
+		case CAT_COMMAND:
 			if (_selectedRow >= 0) {
 				if (!_flags1) {
 					_selectedAction = -1;
@@ -521,7 +521,7 @@ void MADSAction::leftClick() {
 				else {
 					_v86F4C = _selectedRow;
 					_v86F4E = _actionMode;
-					_v83338 = 2;
+					_interAwaiting = AWAITING_THIS;
 				}
 			}
 			break;
@@ -536,7 +536,7 @@ void MADSAction::leftClick() {
 			if (_selectedRow >= 0) {
 				if (_flags1 != 1 || _flags2 != 0) {
 					if (_flags1 != 2 || _flags2 == 0) {
-						_v83338 = 3;
+						_interAwaiting = AWAITING_THAT;
 						_articleNumber = _flags2;
 					}
 					else {
@@ -560,7 +560,7 @@ void MADSAction::leftClick() {
 			if (_vm->_events->currentPos().y < MADS_SCENE_HEIGHT) {
 				scene._customDest = _vm->_events->currentPos() + scene._posAdjust;
 				_selectedAction = -1;
-				_v86F4A = -1;
+				_v86F4A = true;
 			}
 			break;
 
@@ -574,7 +574,7 @@ void MADSAction::leftClick() {
 		}
 		break;
 
-	case 2:
+	case AWAITING_THIS:
 		switch (userInterface._category) {
 		case CAT_INV_LIST:
 		case CAT_HOTSPOT:
@@ -582,7 +582,7 @@ void MADSAction::leftClick() {
 			if (_hotspotId >= 0) {
 				if (_flags2) {
 					_articleNumber = _flags2;
-					_v83338 = 3;
+					_interAwaiting = AWAITING_THAT;
 				}
 				else {
 					_selectedAction = -1;
@@ -599,7 +599,7 @@ void MADSAction::leftClick() {
 		}
 		break;
 
-	case 3:
+	case AWAITING_THAT:
 		switch (userInterface._category) {
 		case CAT_INV_LIST:
 		case CAT_HOTSPOT:
diff --git a/engines/mads/action.h b/engines/mads/action.h
index 26ab062..74de167 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -32,6 +32,14 @@ enum ActionMode { ACTIONMODE_NONE = 0, ACTIONMODE_VERB = 1, ACTIONMODE_OBJECT =
 enum ActionMode2 { ACTIONMODE2_0 = 0, ACTIONMODE2_2 = 2, ACTIONMODE2_4 = 4, ACTIONMODE2_5 = 5 };
 enum AbortTimerMode { ABORTMODE_0 = 0, ABORTMODE_1 = 1, ABORTMODE_2 = 2 };
 
+enum InterAwaiting {
+	AWAITING_NONE = 0,
+	AWAITING_COMMAND = 1,       // Initial state: waiting for a command verb
+	AWAITING_THIS = 2,			// Waiting for object
+	AWAITING_THAT = 3,			// Waiting for a second object
+	AWAITING_RIGHT_MOUSE = 4	// Waiting for mouse button release
+};
+
 enum {
 	VERB_NONE = 0,
 	VERB_LOOK = 3,
@@ -98,7 +106,7 @@ public:
 	int16 _v86F4E;
 	bool _v86F4A;
 	int16 _v86F4C;
-	int _v83338;
+	InterAwaiting _interAwaiting;
 	bool _inProgress;
 	int _v8453A;
 
diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index b0b69b9..96b9cfb 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -316,7 +316,7 @@ void Animation::startAnimation(int abortTimers) {
 	_currentFrame = 0;
 	_oldFrameEntry = 0;
 	_nextFrameTimer = _vm->_game->_scene._frameStartTime;
-	_abortTimers = abortTimers;
+	_trigger = abortTimers;
 	_abortTimersMode = _vm->_game->_abortTimersMode2;
 	_vm->_game->_scene._action._activeAction = _actionDetails;
 
@@ -530,8 +530,8 @@ void Animation::update() {
 	_currentFrame++;
 	if (_currentFrame >= (int)_miscEntries.size()) {
 		// Animation is complete
-		if (_abortTimers != 0) {
-			_vm->_game->_abortTimers = _abortTimers;
+		if (_trigger != 0) {
+			_vm->_game->_trigger = _trigger;
 			_vm->_game->_abortTimersMode = _abortTimersMode;
 
 			if (_abortTimersMode != ABORTMODE_1) {
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 1207ff6..7c3d864 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -128,7 +128,7 @@ private:
 	uint32 _nextFrameTimer;
 	uint32 _nextScrollTimer;
 	int _messageCtr;
-	int _abortTimers;
+	int _trigger;
 	AbortTimerMode _abortTimersMode;
 	ActionDetails _actionDetails;
 
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index b89f833..900d4dc 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -54,7 +54,6 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 	_quoteEmergency = false;
 	_vocabEmergency = false;
 	_aaName = "*I0.AA";
-	_playerSpritesFlag = false;
 	_priorFrameTimer = 0;
 	_updateSceneFlag = false;
 	_abortTimersMode = ABORTMODE_0;
@@ -191,7 +190,7 @@ void Game::sectionLoop() {
 		if (!_player._spritesLoaded && _player._loadsFirst) {
 			if (_player.loadSprites(""))
 				_vm->quitGame();
-			_playerSpritesFlag = true;
+			_player._loadedFirst = true;
 		}
 
 		_scene.loadScene(_scene._nextSceneId, _aaName, 0);
@@ -200,33 +199,33 @@ void Game::sectionLoop() {
 		if (!_player._spritesLoaded) {
 			if (_player.loadSprites(""))
 				_vm->quitGame();
-			_playerSpritesFlag = false;
+			_player._loadedFirst = false;
 		}
 
 		_vm->_events->initVars();
+		_scene._userInterface._highlightedCommandIndex = -1;
+		_scene._userInterface._highlightedItemIndex = -1;
 		_scene._userInterface._highlightedActionIndex = -1;
-		_scene._userInterface._v1C = -1;
-		_scene._userInterface._v1E = -1;
 
 		_scene._action.clear();
-		_player.turnToDestFacing();
+		_player.setFinalFacing();
 		_player._facing = _player._turnToFacing;
-		_player.moveComplete();
+		_player.cancelCommand();
+		_kernelMode = KERNEL_ROOM_INIT;
 
 		switch (_vm->_screenFade) {
 		case SCREEN_FADE_SMOOTH:
-			_abortTimers2 = kTransitionFadeOutIn;
+			_fx = kTransitionFadeOutIn;
 			break;
 		case SCREEN_FADE_FAST:
-			_abortTimers2 = kCenterVertTransition;
+			_fx = kCenterVertTransition;
 			break;
 		default:
-			_abortTimers2 = kTransitionNone;
+			_fx = kTransitionNone;
 			break;
 		}
 
-		_abortTimers = 0;
-		_abortTimersMode2 = ABORTMODE_1;
+		_trigger = 0;
 		_priorFrameTimer = _scene._frameStartTime;
 
 		// Call the scene logic for entering the given scene
@@ -271,7 +270,7 @@ void Game::sectionLoop() {
 
 		warning("TODO: sub_1DD8C, sub_1DD7E");
 
-		if (!_playerSpritesFlag) {
+		if (!_player._loadedFirst) {
 			_player._spritesLoaded = false;
 			_player._spritesChanged = true;
 		}
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 11fd954..f3e2a67 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -78,7 +78,6 @@ protected:
 	bool _quoteEmergency;
 	bool _vocabEmergency;
 	bool _updateSceneFlag;
-	bool _playerSpritesFlag;
 
 	/**
 	 * Constructor
@@ -133,8 +132,8 @@ public:
 	Scene _scene;
 	KernelMode _kernelMode;
 	int _v2;
-	int _abortTimers;
-	int _abortTimers2;
+	int _trigger;
+	ScreenTransition _fx;
 	AbortTimerMode _abortTimersMode;
 	AbortTimerMode _abortTimersMode2;
 	uint32 _priorFrameTimer;
diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index be84739..617bd6d 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -74,7 +74,7 @@ int KernelMessages::add(const Common::Point &pt, uint fontColor, uint8 flags,
 	rec._textDisplayIndex = -1;
 	rec._timeout = timeout;
 	rec._frameTimer = _vm->_game->_priorFrameTimer;
-	rec._abortTimers = abortTimers;
+	rec._trigger = abortTimers;
 	rec._abortMode = _vm->_game->_abortTimersMode2;
 
 	rec._actionDetails = scene._action._activeAction;
@@ -143,7 +143,7 @@ void KernelMessages::reset() {
 void KernelMessages::update() {
 	uint32 currentTimer = _vm->_game->_scene._frameStartTime;
 
-	for (uint i = 0; i < _entries.size() && !_vm->_game->_abortTimers; ++i) {
+	for (uint i = 0; i < _entries.size() && !_vm->_game->_trigger; ++i) {
 		KernelMessage &msg = _entries[i];
 
 		if (((msg._flags & KMSG_ACTIVE) != 0) && (currentTimer >= msg._frameTimer))
@@ -173,10 +173,10 @@ void KernelMessages::processText(int msgIndex) {
 			msg._timeout = 0;
 	}
 
-	if ((msg._timeout <= 0) && (_vm->_game->_abortTimers == 0)) {
+	if ((msg._timeout <= 0) && (_vm->_game->_trigger == 0)) {
 		msg._flags |= KMSG_EXPIRE;
-		if (msg._abortTimers != 0) {
-			_vm->_game->_abortTimers = msg._abortTimers;
+		if (msg._trigger != 0) {
+			_vm->_game->_trigger = msg._trigger;
 			_vm->_game->_abortTimersMode = msg._abortMode;
 
 			if (_vm->_game->_abortTimersMode != ABORTMODE_1) {
diff --git a/engines/mads/messages.h b/engines/mads/messages.h
index 03a4e01..1254b1d 100644
--- a/engines/mads/messages.h
+++ b/engines/mads/messages.h
@@ -56,7 +56,7 @@ public:
 	uint32 _frameTimer2;
 	uint32 _frameTimer;
 	uint32 _timeout;
-	int _abortTimers;
+	int _trigger;
 	AbortTimerMode _abortMode;
 	ActionDetails _actionDetails;
 	Common::String _msg;
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 554c73d..e5c0abd 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -215,7 +215,7 @@ void Scene103::step() {
 	Common::Point pt;
 	int dist;
 
-	switch (_vm->_game->_abortTimers) {
+	switch (_vm->_game->_trigger) {
 	case 70:
 		_vm->_game->_player._stepEnabled = true;
 		break;
@@ -260,7 +260,7 @@ void Scene103::actions() {
 	if (_action._savedFields._lookFlag) {
 		_vm->_dialogs->show(10322);
 	} else if (_action.isAction(395, 110, 0)) {
-		switch (_vm->_game->_abortTimers) {
+		switch (_vm->_game->_trigger) {
 		case 0:
 			_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(
 				_globals._spriteIndexes[6], false, 6, 1);
@@ -280,7 +280,7 @@ void Scene103::actions() {
 		}
 	}
 	else if (_action.isAction(VERB_TAKE, 371, 0) && _game._objects.isInRoom(OBJ_TIMER_MODULE)) {
-		switch (_vm->_game->_abortTimers) {
+		switch (_vm->_game->_trigger) {
 		case 0:
 			_scene->changeDepthSurface(1);
 			_globals._spriteIndexes[28] = _scene->_sequences.startReverseCycle(
@@ -312,7 +312,7 @@ void Scene103::actions() {
 			break;
 		}
 	} else if (_action.isAction(VERB_TAKE, 289, 0) && _game._objects.isInRoom(OBJ_REBREATHER)) {
-		switch (_vm->_game->_abortTimers) {
+		switch (_vm->_game->_trigger) {
 		case 0:
 			_scene->changeDepthSurface(1);
 			_globals._spriteIndexes[27] = _scene->_sequences.startReverseCycle(
@@ -344,26 +344,26 @@ void Scene103::actions() {
 	} else if (_action.isAction(VERB_LOOK, 362, 0)) {
 		_vm->_dialogs->show(10301);
 	} else if (_action.isAction(VERB_TAKE, 362, 0)) {
-		if (!_vm->_game->_abortTimers)
+		if (!_vm->_game->_trigger)
 			_vm->_sound->command(31);
 
-		if (_vm->_game->_abortTimers2 < 2) {
+		if (_vm->_game->_fx < 2) {
 			_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(
 				_globals._spriteIndexes[9], false, 6,
-				_vm->_game->_abortTimers < 1 ? 1 : 0);
-			if (_vm->_game->_abortTimers) {
+				_vm->_game->_trigger < 1 ? 1 : 0);
+			if (_vm->_game->_trigger) {
 				_scene->_sequences.setAnimRange(_globals._spriteIndexes[24], -1, 0);
 				Common::String msg = _game.getQuote(51);
 				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 18, 0, 60, msg);
-				_scene->_sequences.addTimer(120, _vm->_game->_abortTimers);
+				_scene->_sequences.addTimer(120, _vm->_game->_trigger);
 			} else {
 				_scene->_sequences.addSubEntry(_globals._spriteIndexes[24],
 					SM_0, 0, 1);
 			}
 
-			_game._player._stepEnabled = _game._abortTimers == 2;
+			_game._player._stepEnabled = _game._trigger == 2;
 			_globals[kTurkeyExploded] = -1;
-			if (_game._abortTimers == 2) {
+			if (_game._trigger == 2) {
 				_vm->_dialogs->show(1030);
 				_scene->_hotspots.activate(362, false);
 			}
@@ -372,7 +372,7 @@ void Scene103::actions() {
 		_vm->_dialogs->show(!_globals[kTurkeyExploded] ? 10323 : 10303);
 	}
 	else if (_action.isAction(VERB_TALKTO, 27, 0)) {
-		switch (_vm->_game->_abortTimers) {
+		switch (_vm->_game->_trigger) {
 		case 0: {
 			_game._player._stepEnabled = false;
 			Common::String msg = _game.getQuote(71);
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 83dcfa3..38f87ba 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -218,7 +218,7 @@ void Scene201::step() {
 		_pterodactylFlag = false;
 	}
 
-	if (_game._abortTimers == 70) {
+	if (_game._trigger == 70) {
 		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 9, 1, 0, 0);
 		_game._player._visible = false;
 		_scene->_sequences.setAnimRange(_globals._spriteIndexes[21], 12, 16);
@@ -231,24 +231,24 @@ void Scene201::step() {
 		_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 73);
 	}
 
-	if (_game._abortTimers == 81) {
+	if (_game._trigger == 81) {
 		_scene->_kernelMessages.reset();
 	}
 
-	if (_game._abortTimers == 71) {
+	if (_game._trigger == 71) {
 		_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 9, 0, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._spriteIndexes[22], -2, -2);
 		_scene->_sequences.setDepth(_globals._spriteIndexes[22], 1);
 	}
 
-	if (_game._abortTimers == 73) {
+	if (_game._trigger == 73) {
 		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 9, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._spriteIndexes[21], 17, -2);
 		_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 74);
 		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 1);
 	}
 
-	if (_game._abortTimers == 74) {
+	if (_game._trigger == 74) {
 		_vm->_sound->command(40);
 
 		_scene->_kernelMessages.add(Common::Point(125, 56), 0xFDFC, 32, 82, 180, _game.getQuote(91));
@@ -258,24 +258,24 @@ void Scene201::step() {
 		_scene->_sequences.addTimer(180, 75);
 	}
 
-	if (_game._abortTimers == 75) {
+	if (_game._trigger == 75) {
 		_globals[kMeteorologistEverSeen] = 0;
 		_scene->_nextSceneId = 202;
 	}
 
-	if (_game._abortTimers == 76) {
+	if (_game._trigger == 76) {
 		_game._player._stepEnabled = true;
 		_game._player._visible = true;
 		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
 	}
 
-	if (_game._abortTimers == 77) {
+	if (_game._trigger == 77) {
 		_globals[kTeleporterCommand] = 1;
 		_scene->_nextSceneId = _globals[kTeleporterDestination];
 		_scene->_reloadSceneFlag = true;
 	}
 
-	if (_game._abortTimers == 78) {
+	if (_game._trigger == 78) {
 		_vm->_sound->command(40);
 		_vm->_dialogs->show(0x4E92);
 		_scene->_reloadSceneFlag = true;
@@ -288,12 +288,12 @@ void Scene201::actions() {
 		if (action->isAction(0x18C, 0x83, 0))
 			_scene->_nextSceneId = 202;
 		else if ((action->isAction(0x50, 0x156, 0)) || (action->isAction(0x188, 0x16C, 0)) || (action->isAction(0x188, 0x1B6, 0))) {
-			if (_game._abortTimers == 0) { 
+			if (_game._trigger == 0) { 
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
 				int sepChar = (_globals[kSexOfRex] == SEX_UNKNOWN) ? 't' : 'u';
 				_scene->loadAnimation(formAnimName(sepChar, 0), 1);
-			} else if (_game._abortTimers == 1) {
+			} else if (_game._trigger == 1) {
 				_scene->_nextSceneId = 213;
 			}
 		} else if (action->isAction(0x3, 0x1A6, 0)) {
@@ -474,10 +474,10 @@ void Scene202::step() {
 			setRandomKernelMessage();
 	}
 
-	if (_game._abortTimers == 70)
+	if (_game._trigger == 70)
 		_activeMsgFl = false;
 
-	if (_game._abortTimers == 71) {
+	if (_game._trigger == 71) {
 		_vm->_sound->command(3);
 		_vm->_sound->command(9);
 		_globals._v8425C = 900 + _scene->_frameStartTime;
@@ -507,7 +507,7 @@ void Scene202::step() {
 		_globals[kMeteorologistWatch] = 0;
 	}
 
-	switch (_game._abortTimers) {
+	switch (_game._trigger) {
 	case 90:
 		_vm->_sound->command(41);
 		_scene->_sequences.remove(_globals._spriteIndexes[25]);
@@ -717,7 +717,7 @@ void Scene202::preActions() {
 		_scene->_kernelMessages.reset();
 
 	if (!_ladderTopFl && (action->isAction(0x4E, 0xC7, 0) || !action->_walkFlag)) {
-		if (_game._abortTimers == 0) {
+		if (_game._trigger == 0) {
 			_vm->_sound->command(29);
 			action->_walkFlag = false;
 			_game._player._stepEnabled = false;
@@ -725,7 +725,7 @@ void Scene202::preActions() {
 			_globals._spriteIndexes[23] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
 			_scene->_sequences.setDepth(_globals._spriteIndexes[23], 1);
 			_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 1);
-		} else if (_game._abortTimers == 1) {
+		} else if (_game._trigger == 1) {
 			_scene->_sequences.updateTimeout(-1, _globals._spriteIndexes[23]);
 			warning("CHECKME: _scene->_dynamicHotspots.remove(_globals._frameTime);");
 			_scene->_dynamicHotspots.remove(_globals._frameTime);
@@ -765,7 +765,7 @@ void Scene202::actions() {
 			_scene->_nextSceneId = 201;
 		} else if (action->isAction(0x4, 0x2C, 0)) {
 			if (action->_actionMode2 == 4) {
-				if (_game._abortTimers == 0) {
+				if (_game._trigger == 0) {
 					if (_game._objects.isInInventory(OBJ_BONES)) {
 						_vm->_dialogs->show(0x4EFB);
 					} else {
@@ -776,7 +776,7 @@ void Scene202::actions() {
 						_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_FRAME_INDEX, 6, 1);
 						_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 2);
 					}
-				} else if (_game._abortTimers == 1) {
+				} else if (_game._trigger == 1) {
 					if ((_game._player._playerPos.x == 132) && (_game._player._playerPos.y == 97)) {
 						_scene->_sequences.remove(_globals._spriteIndexes[16]);
 						_globals[kBone202Status] |= 1;
@@ -784,7 +784,7 @@ void Scene202::actions() {
 						_scene->_sequences.remove(_globals._spriteIndexes[21]);
 						_globals[kBone202Status] |= 2;
 					}
-				} else if (_game._abortTimers == 2) {
+				} else if (_game._trigger == 2) {
 					if (_game._objects.isInInventory(OBJ_BONE)) {
 						_game._objects.removeFromInventory(OBJ_BONE, 1);
 						_game._objects.addToInventory(OBJ_BONES);
@@ -802,7 +802,7 @@ void Scene202::actions() {
 				}
 			}
 		} else if ((action->isAction(0x50, 0xC7, 0)) && (_globals[kLadderBroken] == 0)) {
-			if (_game._abortTimers == 0) {
+			if (_game._trigger == 0) {
 				_vm->_sound->command(29);
 				_globals._v8425C = _scene->_frameStartTime;
 				_game._player._visible = false;
@@ -814,7 +814,7 @@ void Scene202::actions() {
 				_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
 				_scene->_sequences.setDepth(_globals._spriteIndexes[23], 1);
 				_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 1);
-			} else if (_game._abortTimers == 1) {
+			} else if (_game._trigger == 1) {
 				_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
 				_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
 				_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
@@ -829,7 +829,7 @@ void Scene202::actions() {
 			}
 		} else if (((action->isAction(0x3, 0x27, 0x82)) || (action->isAction(0x3, 0x27, 0x1B6))) && (_globals[kSexOfRex] == SEX_MALE)) {
 			if (!_ladderTopFl) {
-				if (_game._abortTimers == 0) {
+				if (_game._trigger == 0) {
 					_game._player._stepEnabled = false;
 					_game._player._visible= false;
 					_globals._spriteIndexes[25] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
@@ -838,7 +838,7 @@ void Scene202::actions() {
 					_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
 					_scene->_sequences.updateTimeout(-1, _globals._spriteIndexes[25]);
 					_scene->_sequences.addSubEntry(_globals._spriteIndexes[25], SM_0, 0, 1);
-				} else if (_game._abortTimers == 1) {
+				} else if (_game._trigger == 1) {
 					_globals._spriteIndexes[25] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
 					_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
 					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
@@ -848,7 +848,7 @@ void Scene202::actions() {
 					} else {
 						_scene->_sequences.addTimer(120, 2);
 					}
-				} else if (_game._abortTimers == 2) {
+				} else if (_game._trigger == 2) {
 					if (!_scene->_activeAnimation && (_globals._abortVal == 0)) {
 						_vm->_dialogs->show(0x4EFE);
 					}
@@ -858,7 +858,7 @@ void Scene202::actions() {
 					_scene->_sequences.setAnimRange(_globals._spriteIndexes[25], 1, 6);
 					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
 					_scene->_sequences.addSubEntry(_globals._spriteIndexes[25], SM_0, 0, 3);
-				} else if (_game._abortTimers == 3) {
+				} else if (_game._trigger == 3) {
 					_scene->_sequences.updateTimeout(-1, _globals._spriteIndexes[25]);
 					_game._player._stepEnabled = true;
 					_game._player._visible = true;
@@ -867,7 +867,7 @@ void Scene202::actions() {
 					return;
 				}
 			} else {
-				if (_game._abortTimers == 0) {
+				if (_game._trigger == 0) {
 					_globals._v84268 = 1;
 					_game._player._stepEnabled = false;
 					_scene->_sequences.remove(_globals._spriteIndexes[24]);
@@ -875,7 +875,7 @@ void Scene202::actions() {
 					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
 					_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
 					_scene->_sequences.addSubEntry(_globals._spriteIndexes[24], SM_0, 0, 1);
-				} else if (_game._abortTimers == 1) {
+				} else if (_game._trigger == 1) {
 					_globals._spriteIndexes[25] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, -2);
 					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(247, 82));
 					_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
@@ -897,7 +897,7 @@ void Scene202::actions() {
 					} else {
 						_scene->_sequences.addTimer(120, 2);
 					}
-				} else if (_game._abortTimers == 2) {
+				} else if (_game._trigger == 2) {
 					if (!_scene->_activeAnimation)
 						_vm->_dialogs->show(0x4EFE);
 					_globals._abortVal = 0;
@@ -906,7 +906,7 @@ void Scene202::actions() {
 					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
 					_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
 					_scene->_sequences.addSubEntry(_globals._spriteIndexes[24], SM_0, 0, 3);
-				} else if (_game._abortTimers == 3) {
+				} else if (_game._trigger == 3) {
 					_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
 					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
 					_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
@@ -1024,7 +1024,7 @@ void Scene203::step() {
 	if (_globals._v0 == 0)
 		return;
 
-	if ((_game._abortTimers == 0) && (_globals._frameTime != 0))
+	if ((_game._trigger == 0) && (_globals._frameTime != 0))
 		return;
 
 	if ((_game._player._playerPos != Common::Point(158, 136)) || (_game._player._facing != 2))
@@ -1032,7 +1032,7 @@ void Scene203::step() {
 
 	_globals._frameTime = 0xFFFF;
 
-	if (_game._abortTimers == 0) {
+	if (_game._trigger == 0) {
 		_game._player._visible = false;
 		_game._player._stepEnabled = false;
 		_vm->_palette->sub7BBF8();
@@ -1040,7 +1040,7 @@ void Scene203::step() {
 		_scene->resetScene();
 		_vm->_events->setCursor2(CURSOR_WAIT);
 		_scene->loadAnimation(Resources::formatName(203, 'a', -1, EXT_AA, ""), 81);
-	} else if (_game._abortTimers == 81) {
+	} else if (_game._trigger == 81) {
 		_scene->_nextSceneId = 208;
 		_scene->_reloadSceneFlag = true;
 	} 
@@ -1257,13 +1257,13 @@ void Scene207::step() {
 		warning("TODO: sub3ADD6(...)");
 	}
 
-	if (_game._abortTimers == 70) {
+	if (_game._trigger == 70) {
 		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 10, 0, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._spriteIndexes[21], 23, 34);
 		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 6);
 	}
 
-	if (_game._abortTimers == 71)
+	if (_game._trigger == 71)
 		_globals._v2 = 0;
 
 	if (_globals._v2)
@@ -1419,21 +1419,21 @@ void Scene208::step() {
 	if ((_game._player._playerPos != Common::Point(20, 148)) || (_game._player._facing != 6))
 		return;
 
-	if ((_game._abortTimers == 0) && ((_globals._frameTime & 0xFFFF) != 0))
+	if ((_game._trigger == 0) && ((_globals._frameTime & 0xFFFF) != 0))
 		return;
 	
 	_globals._frameTime |= 0xFFFF;
 	
-	if (_game._abortTimers == 82) {
+	if (_game._trigger == 82) {
 		_game._player._stepEnabled = true;
 		return;
 	}
 	
-	if (_game._abortTimers > 82)
+	if (_game._trigger > 82)
 		return;
 	
-	if (_game._abortTimers & 0xFF) {
-		if ((_game._abortTimers & 0xFF) == 81) {
+	if (_game._trigger & 0xFF) {
+		if ((_game._trigger & 0xFF) == 81) {
 			_scene->_sequences.remove(_globals._spriteIndexes[15]);
 			_globals[kRhotundaStatus] = 1;
 			warning("TODO: sub34648(...)");
@@ -1459,20 +1459,20 @@ void Scene208::actions() {
 	if (_action.isAction(0x18C, 0x19F, 0)) {
 		if (_globals[kRhotundaStatus])
 			_scene->_nextSceneId = 203;
-		else if (_game._abortTimers == 0) {
+		else if (_game._trigger == 0) {
 			_game._player._stepEnabled = false;
 			int msgIndex = _scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 1, 120, _game.getQuote(70));
 			_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
-		} else if (_game._abortTimers == 1) {
+		} else if (_game._trigger == 1) {
 			_scene->_nextSceneId = 203;
 		}
 	} else if (_action.isAction(0x18C, 0x83, 0)) {
 		_scene->_nextSceneId = 212;
-	} else if (_action.isAction(0x4, 0x1AA, 0) && (!_globals[kLeavesStatus] || _game._abortTimers)) {
+	} else if (_action.isAction(0x4, 0x1AA, 0) && (!_globals[kLeavesStatus] || _game._trigger)) {
 		warning("TODO: sub3B282(1);");
 		if (_game._player._stepEnabled)
 			_vm->_dialogs->showPicture(OBJ_BIG_LEAVES, 0x326, 0);
-	} else if (_action.isAction(0x7, 0x23, 0x19E) && (_globals[kLeavesStatus] == 1 || _game._abortTimers)) {
+	} else if (_action.isAction(0x7, 0x23, 0x19E) && (_globals[kLeavesStatus] == 1 || _game._trigger)) {
 		warning("TODO: sub3B282(2);");
 	} else if (_action.isAction(0x7, 0x17A, 0x1A9)) {
 		warning("TODO: sub3B282(3);");
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 64c4916..cb761ca 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -181,7 +181,7 @@ void Scene804::step() {
 			_globals._v2 = 0;
 		}
 
-		if (_game._abortTimers == 70)
+		if (_game._trigger == 70)
 			_globals._v5 = 42;
 		if (_scene->_activeAnimation->getCurrentFrame() == 65)
 			_scene->_sequences.remove(_globals._spriteIndexes[22]);
@@ -222,7 +222,7 @@ void Scene804::step() {
 				_scene->_sequences.addTimer(60, 80);
 		}
 
-		if (_game._abortTimers == 80)
+		if (_game._trigger == 80)
 			_scene->_nextSceneId = 803;
 
 		if (_scene->_activeAnimation->getCurrentFrame() == 7 && !_globals[kWindowFixed]) {
@@ -267,9 +267,9 @@ void Scene804::step() {
 		}
 	}
 
-	if (_game._abortTimers == 120)
+	if (_game._trigger == 120)
 		_vm->_dialogs->show(0x13a26);
-	if (_game._abortTimers == 110)
+	if (_game._trigger == 110)
 		_vm->_dialogs->show(0x13a2a);
 
 	if (_globals._v6) {
@@ -281,7 +281,7 @@ void Scene804::step() {
 		_globals._v5 = -1;
 	}
 
-	if (_game._abortTimers == 90)
+	if (_game._trigger == 90)
 		_scene->_nextSceneId = 803;
 
 	if (_scene->_activeAnimation->getCurrentFrame() == 7 &&!_globals._v8) {
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 7e1ceba..eaec85c 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -46,6 +46,7 @@ Player::Player(MADSEngine *vm): _vm(vm) {
 	_priorVisible = false;
 	_visible3 = false;
 	_loadsFirst = false;
+	_loadedFirst = false;
 	_walkAnywhere = false;
 	_special = 0;
 	_ticksAmount = 0;
@@ -71,7 +72,7 @@ Player::Player(MADSEngine *vm): _vm(vm) {
 	Common::fill(&_spriteSetsPresent[0], &_spriteSetsPresent[PLAYER_SPRITES_FILE_COUNT], false);
 }
 
-void Player::reset() {
+void Player::cancelWalk() {
 	_action = &_vm->_game->_scene._action;
 	_destPos = _playerPos;
 	_targetFacing = FACING_NONE;
@@ -133,8 +134,8 @@ bool Player::loadSprites(const Common::String &prefix) {
 	}
 }
 
-void Player::turnToDestFacing() {
-	if (_targetFacing != 5)
+void Player::setFinalFacing() {
+	if (_targetFacing != FACING_NONE)
 		_turnToFacing = _targetFacing;
 }
 
@@ -176,8 +177,8 @@ void Player::dirChanged() {
 	_priorTimer += 1;
 }
 
-void Player::moveComplete() {
-	reset();
+void Player::cancelCommand() {
+	cancelWalk();
 	_action->_inProgress = false;
 }
 
@@ -365,7 +366,7 @@ void Player::setDest(const Common::Point &pt, Facing facing) {
 void Player::startWalking(const Common::Point &pos, Facing direction) {
 	Scene &scene = _vm->_game->_scene;
 
-	reset();
+	cancelWalk();
 	scene._action._startWalkFlag = true;
 	scene._action._walkFlag = true;
 	scene._destPos = pos;
@@ -406,7 +407,7 @@ void Player::move() {
 				// End of walking path
 				_routeCount = 0;
 				_moving = false;
-				turnToDestFacing();
+				setFinalFacing();
 				routeFlag = true;
 				idx = _routeCount;
 			}
@@ -475,7 +476,7 @@ void Player::move() {
 	_v8452E -= var1;
 
 	if (routeFlag)
-		moveComplete();
+		cancelCommand();
 	else {
 		if (!_newSceneId) {
 			// If the move is complete, make sure the position is exactly on the given destination
diff --git a/engines/mads/player.h b/engines/mads/player.h
index afd55b2..004c412 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -64,8 +64,6 @@ private:
 	int _actionList2[12];
 	int _hypotenuse;
 
-	void reset();
-
 	void resetActionList();
 
 	void move();
@@ -121,6 +119,7 @@ public:
 	bool _walkAnywhere;
 	int _frameNum;
 	bool _loadsFirst;
+	bool _loadedFirst;
 	Common::Point _playerPos;
 	Common::Point _destPos;
 	Common::Point _posChange;
@@ -152,9 +151,21 @@ public:
 	 */
 	bool loadSprites(const Common::String &prefix);
 
-	void turnToDestFacing();
+	/**
+	 * Called when the player has reached the given destination, start him
+	 * turning to the specified facing
+	 */
+	void setFinalFacing();
+
+	/**
+	 * Stops the player walking
+	 */
+	void cancelWalk();
 
-	void moveComplete();
+	/**
+	 * Cancels any oustanding player action
+	 */
+	void cancelCommand();
 
 	void setupFrame();
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index f16b2c3..aa57a7e 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -275,7 +275,7 @@ void Scene::loop() {
 		// TODO: Verify correctness of frame wait
 		_vm->_events->waitForNextFrame();
 
-		if (_vm->_dialogs->_pendingDialog != DIALOG_NONE && !_vm->_game->_abortTimers
+		if (_vm->_dialogs->_pendingDialog != DIALOG_NONE && !_vm->_game->_trigger
 			&& _vm->_game->_player._stepEnabled)
 			_reloadSceneFlag = true;
 	}
@@ -290,18 +290,18 @@ void Scene::doFrame() {
 		_action._selectedAction = 0;
 	}
 
-	if (!_vm->_game->_abortTimers && !player._unk3) {
+	if (!_vm->_game->_trigger && !player._unk3) {
 		// Refresh the dynamic hotspots if they've changed
 		if (_dynamicHotspots._changed)
 			_dynamicHotspots.refresh();
 
 		// Check all on-screen visual objects
 		_vm->_game->_screenObjects.check(player._stepEnabled && !_action._startWalkFlag &&
-				!_vm->_game->_abortTimers2);
+				!_vm->_game->_fx);
 	}
 
 	if (_action._selectedAction && player._stepEnabled && !_action._startWalkFlag &&
-			!_vm->_game->_abortTimers && !player._unk3) {
+			!_vm->_game->_trigger && !player._unk3) {
 		_action.startAction();
 		if (_action._activeAction._verbId == Nebular::NOUN_LOOK_AT) {
 			_action._activeAction._verbId = VERB_LOOK;
@@ -311,17 +311,17 @@ void Scene::doFrame() {
 		flag = true;
 	}
 
-	if (flag || (_vm->_game->_abortTimers && _vm->_game->_abortTimersMode == ABORTMODE_2)) {
+	if (flag || (_vm->_game->_trigger && _vm->_game->_abortTimersMode == ABORTMODE_2)) {
 		doPreactions();
 	}
 
 	checkStartWalk();
-	if (!_vm->_game->_abortTimers2)
+	if (!_vm->_game->_fx)
 		_frameStartTime = _vm->_events->getFrameCounter();
 
 	if ((_action._inProgress && !player._moving && !_action._startWalkFlag &&
 			player._turnToFacing == player._facing) ||
-			(_vm->_game->_abortTimers && _vm->_game->_abortTimersMode == ABORTMODE_0)) {
+			(_vm->_game->_trigger && _vm->_game->_abortTimersMode == ABORTMODE_0)) {
 		doAction();
 	}
 
@@ -339,7 +339,7 @@ void Scene::doFrame() {
 			// Cursor update code
 			updateCursor();
 
-			if (!_vm->_game->_abortTimers) {
+			if (!_vm->_game->_trigger) {
 				// Handle any active sequences
 				_sequences.tick();
 
@@ -357,24 +357,24 @@ void Scene::doFrame() {
 					0x203, 0, 0, 1, msg);
 			}
 
-			if (!_vm->_game->_abortTimers) {
+			if (!_vm->_game->_trigger) {
 				if (_reloadSceneFlag || _currentSceneId != _nextSceneId)
 					_kernelMessages.reset();
 				_kernelMessages.update();
 			}
 
-			_userInterface._uiSlots.draw(_vm->_game->_abortTimers2 == 0,
-				_vm->_game->_abortTimers2 != 0);
+			_userInterface._uiSlots.draw(_vm->_game->_fx == 0,
+				_vm->_game->_fx != 0);
 
 			// Write any text needed by the interface
-			if (_vm->_game->_abortTimers2)
+			if (_vm->_game->_fx)
 				_userInterface.drawTextElements();
 
 			// Draw any elements
-			drawElements((ScreenTransition)_vm->_game->_abortTimers2, _vm->_game->_abortTimers2);
+			drawElements((ScreenTransition)_vm->_game->_fx, _vm->_game->_fx);
 
 			// Handle message updates
-			if (_vm->_game->_abortTimers2) {
+			if (_vm->_game->_fx) {
 				uint32 priorTime = _vm->_game->_priorFrameTimer;
 				uint32 newTime = _vm->_events->getFrameCounter();
 				_sequences.delay(newTime, priorTime);
@@ -390,9 +390,9 @@ void Scene::doFrame() {
 		}
 	}
 
-	if (_vm->_game->_abortTimers2)
+	if (_vm->_game->_fx)
 		_animFlag = true;
-	_vm->_game->_abortTimers2 = 0;
+	_vm->_game->_fx = kTransitionNone;
 
 	if (_freeAnimationFlag) {
 		_activeAnimation->free();
@@ -450,7 +450,7 @@ void Scene::doPreactions() {
 		_sceneLogic->preActions();
 
 		if (_vm->_game->_abortTimersMode == ABORTMODE_2)
-			_vm->_game->_abortTimers = 0;
+			_vm->_game->_trigger = 0;
 	}
 }
 
@@ -458,7 +458,7 @@ void Scene::doAction() {
 	int flag = 0;
 
 	_vm->_game->_abortTimersMode2 = ABORTMODE_0;
-	if ((_action._inProgress || _vm->_game->_abortTimers) && !_action._v8453A) {
+	if ((_action._inProgress || _vm->_game->_trigger) && !_action._v8453A) {
 		_sceneLogic->actions();
 		_action._inProgress = true;
 		flag = -1;
@@ -467,14 +467,14 @@ void Scene::doAction() {
 	if (_vm->_game->_screenObjects._v832EC == 1) {
 		_action._inProgress = false;
 	} else {
-		if ((_action._inProgress || _vm->_game->_abortTimers) ||
+		if ((_action._inProgress || _vm->_game->_trigger) ||
 				(!flag && _action._v8453A == flag)) {
 			_vm->_game->_sectionHandler->sectionPtr2();
 			_action._inProgress = true;
 			flag = -1;
 		}
 
-		if ((_action._inProgress || _vm->_game->_abortTimers) && (!flag || _action._v8453A == flag)) {
+		if ((_action._inProgress || _vm->_game->_trigger) && (!flag || _action._v8453A == flag)) {
 			_vm->_game->doObjectAction();
 		}
 
@@ -496,7 +496,7 @@ void Scene::doAction() {
 
 	_action._inProgress = false;
 	if (_vm->_game->_abortTimersMode == ABORTMODE_0)
-		_vm->_game->_abortTimers = 0;
+		_vm->_game->_trigger = 0;
 }
 
 void Scene::checkStartWalk() {
@@ -515,7 +515,7 @@ void Scene::doSceneStep() {
 	_vm->_game->_player._unk3 = 0;
 
 	if (_vm->_game->_abortTimersMode == ABORTMODE_1)
-		_vm->_game->_abortTimers = 0;
+		_vm->_game->_trigger = 0;
 }
 
 void Scene::checkKeyboard() {
@@ -537,7 +537,7 @@ void Scene::updateCursor() {
 	Player &player = _vm->_game->_player;
 
 	CursorType cursorId = CURSOR_ARROW;
-	if (_action._v83338 == 1 && !_vm->_game->_screenObjects._v7FECA &&
+	if (_action._interAwaiting == 1 && !_vm->_game->_screenObjects._v7FECA &&
 		_vm->_game->_screenObjects._category == CAT_HOTSPOT) {
 		int idx = _vm->_game->_screenObjects._selectedObject -
 			_userInterface._categoryIndexes[CAT_HOTSPOT - 1];
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 712d065..b630467 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -49,7 +49,7 @@ KernelMessage::KernelMessage() {
 	_frameTimer2 = 0;
 	_frameTimer = 0;
 	_timeout = 0;
-	_abortTimers = 0;
+	_trigger = 0;
 	_abortMode = ABORTMODE_0;
 	_actionDetails._verbId = 0;
 	_actionDetails._objectNameId = 0;
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index c881e95..0c78b0c 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -303,7 +303,7 @@ void ScreenObjects::check(bool scanFlag) {
 		if (_vm->_easyMouse && _vm->_events->_mouseButtons && category != _category
 			&& scene._userInterface._category != CAT_NONE) {
 			_released = true;
-			if (category >= CAT_ACTION && category <= CAT_TALK_ENTRY) {
+			if (category >= CAT_COMMAND && category <= CAT_TALK_ENTRY) {
 				elementHighlighted();
 			}
 
@@ -315,12 +315,12 @@ void ScreenObjects::check(bool scanFlag) {
 			scene._userInterface._category = _category;
 
 		if (!_vm->_events->_mouseButtons || _vm->_easyMouse) {
-			if (userInterface._category >= CAT_ACTION && userInterface._category <= CAT_TALK_ENTRY) {
+			if (userInterface._category >= CAT_COMMAND && userInterface._category <= CAT_TALK_ENTRY) {
 				elementHighlighted();
 			}
 		}
 
-		if (_vm->_events->_mouseButtons || (_vm->_easyMouse && scene._action._v83338 > 1
+		if (_vm->_events->_mouseButtons || (_vm->_easyMouse && scene._action._interAwaiting > 1
 			&& scene._userInterface._category == CAT_INV_LIST) ||
 			(_vm->_easyMouse && scene._userInterface._category == CAT_HOTSPOT)) {
 			scene._action.checkActionAtMousePos();
@@ -465,12 +465,12 @@ void ScreenObjects::elementHighlighted() {
 	int uiCount;
 
 	switch (userInterface._category) {
-	case CAT_ACTION:
+	case CAT_COMMAND:
 		index = 10;
 		indexEnd = 9;
 		varA = 5;
 		topIndex = 0;
-		idxP = !_v7FECA ? &userInterface._highlightedActionIndex : 
+		idxP = !_v7FECA ? &userInterface._highlightedCommandIndex : 
 			&userInterface._selectedActionIndex;
 
 		if (_v7FECA && userInterface._selectedItemVocabIdx >= 0)
@@ -486,8 +486,8 @@ void ScreenObjects::elementHighlighted() {
 		indexEnd = invList.size() - 1;
 		varA = 0;
 		topIndex = userInterface._inventoryTopIndex;
-		idxP = &userInterface._v1C;
-		var4 = (!_released || (_vm->_events->_mouseButtons && action._v83338 == 1)) ? 0 : 1;
+		idxP = &userInterface._highlightedItemIndex;
+		var4 = (!_released || (_vm->_events->_mouseButtons && action._interAwaiting == 1)) ? 0 : 1;
 		break;
 
 	case CAT_INV_VOCAB:
@@ -502,10 +502,10 @@ void ScreenObjects::elementHighlighted() {
 
 		varA = 0;
 		topIndex = 0;
-		idxP = _v7FECA ? &userInterface._selectedItemVocabIdx : &userInterface._v1E;
+		idxP = _v7FECA ? &userInterface._selectedItemVocabIdx : &userInterface._highlightedActionIndex;
 
 		if (_v7FECA && userInterface._selectedActionIndex >= 0)
-			userInterface.updateSelection(CAT_ACTION, -1, &userInterface._selectedActionIndex);
+			userInterface.updateSelection(CAT_COMMAND, -1, &userInterface._selectedActionIndex);
 
 		var4 = _released && !_v7FECA ? 1 : 0;
 		break;
@@ -529,7 +529,7 @@ void ScreenObjects::elementHighlighted() {
 		indexEnd = index - 1;
 		varA = 0;
 		topIndex = 0;
-		idxP = &userInterface._highlightedActionIndex;
+		idxP = &userInterface._highlightedCommandIndex;
 		var4 = -1;
 		break;
 
@@ -597,7 +597,7 @@ void ScreenObjects::elementHighlighted() {
 	_vm->_game->_scene._highlightedHotspot = newIndex;
 
 	if (_category == CAT_INV_LIST || _category == CAT_INV_ANIM) {
-		if (action._v83338 == 1 && newIndex >= 0 && _released &&
+		if (action._interAwaiting == 1 && newIndex >= 0 && _released &&
 				(!_vm->_events->_mouseReleased || !_vm->_easyMouse))
 			newIndex = -1;
 	}
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index 7fa5722..c733452 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -33,7 +33,7 @@ namespace MADS {
 #define MADS_SCREEN_HEIGHT 200
 
 enum ScrCategory {
-	CAT_NONE = 0, CAT_ACTION = 1, CAT_INV_LIST = 2, CAT_INV_VOCAB = 3,
+	CAT_NONE = 0, CAT_COMMAND = 1, CAT_INV_LIST = 2, CAT_INV_VOCAB = 3,
 	CAT_HOTSPOT = 4, CAT_INV_ANIM = 5, CAT_TALK_ENTRY = 6, CAT_INV_SCROLLER = 7,
 	CAT_12 = 12
 };
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index bb2454d..97d8674 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -327,7 +327,7 @@ bool SequenceList::loadSprites(int seqIndex) {
 	}
 
 	if (idx >= 0) {
-		_vm->_game->_abortTimers = seqEntry._entries._abortVal[idx];
+		_vm->_game->_trigger = seqEntry._entries._abortVal[idx];
 		_vm->_game->_abortTimersMode = seqEntry._abortMode;
 
 		if (seqEntry._abortMode == ABORTMODE_1)
@@ -343,7 +343,7 @@ bool SequenceList::loadSprites(int seqIndex) {
 void SequenceList::tick() {
 	Scene &scene = _vm->_game->_scene;
 	for (uint idx = 0; idx < _entries.size(); ++idx) {
-		if ((_vm->_game->_abortTimers2 == 0) && (_vm->_game->_abortTimers != 0))
+		if ((_vm->_game->_fx == 0) && (_vm->_game->_trigger != 0))
 			break;
 
 		SequenceEntry &seqEntry = _entries[idx];
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 8a7bac1..d0139e2 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -199,9 +199,9 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm), _dirtyAreas(vm),
 	_selectedActionIndex = 0;
 	_selectedItemVocabIdx = -1;
 	_scrollerY = 0;
+	_highlightedCommandIndex = -1;
+	_highlightedItemIndex = -1;
 	_highlightedActionIndex = -1;
-	_v1C = -1;
-	_v1E = -1;
 	_dirtyAreas.resize(50);
 	_inventoryChanged = false;
 	Common::fill(&_categoryIndexes[0], &_categoryIndexes[7], 0);
@@ -265,9 +265,9 @@ void UserInterface::setup(int id) {
 	scene._userInterface._uiSlots.clear();
 	scene._userInterface._uiSlots.fullRefresh();
 	_vm->_game->_ticksExpiry = _vm->_events->getFrameCounter();
+	_highlightedCommandIndex = -1;
 	_highlightedActionIndex = -1;
-	_v1E = -1;
-	_v1C = -1;
+	_highlightedItemIndex = -1;
 
 	if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE)
 		scene._userInterface._uiSlots.draw(false, false);
@@ -291,7 +291,7 @@ void UserInterface::drawTextElements() {
 
 void UserInterface::drawActions() {
 	for (int idx = 0; idx < 10; ++idx) {
-		writeVocab(CAT_ACTION, idx);
+		writeVocab(CAT_COMMAND, idx);
 	}
 }
 
@@ -329,10 +329,10 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
 	int vocabId;
 	Common::String vocabStr;
 	switch (category) {
-	case CAT_ACTION:
+	case CAT_COMMAND:
 		font = _vm->_font->getFont(FONT_INTERFACE);
 		vocabId = scene._verbList[id]._id;
-		if (id == _highlightedActionIndex) {
+		if (id == _highlightedCommandIndex) {
 			_vm->_font->setColorMode(SELMODE_HIGHLIGHTED);
 		} else {
 			_vm->_font->setColorMode(id == _selectedActionIndex ? SELMODE_SELECTED : SELMODE_UNSELECTED);
@@ -345,7 +345,7 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
 	case CAT_INV_LIST:
 		font = _vm->_font->getFont(FONT_INTERFACE);
 		vocabId = _vm->_game->_objects.getItem(id)._descId;
-		if (id == _v1C) {
+		if (id == _highlightedItemIndex) {
 			_vm->_font->setColorMode(SELMODE_HIGHLIGHTED);
 		} else {
 			_vm->_font->setColorMode(id == _selectedInvIndex ? SELMODE_SELECTED : SELMODE_UNSELECTED);
@@ -386,7 +386,7 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
 		// Item specific verbs
 		font = _vm->_font->getFont(FONT_INTERFACE);
 		vocabId = _vm->_game->_objects.getItem(_selectedInvIndex)._vocabList[id]._vocabId;
-		if (id == _v1E) {
+		if (id == _highlightedActionIndex) {
 			_vm->_font->setColorMode(SELMODE_HIGHLIGHTED);
 		} else {
 			_vm->_font->setColorMode(id == _selectedInvIndex ? SELMODE_SELECTED : SELMODE_UNSELECTED);
@@ -418,12 +418,12 @@ void UserInterface::loadElements() {
 		}
 
 		// Set up actions
-		_categoryIndexes[CAT_ACTION - 1] = _vm->_game->_screenObjects.size() + 1;
+		_categoryIndexes[CAT_COMMAND - 1] = _vm->_game->_screenObjects.size() + 1;
 		for (int idx = 0; idx < 10; ++idx) {
-			getBounds(CAT_ACTION, idx, bounds);
+			getBounds(CAT_COMMAND, idx, bounds);
 			moveRect(bounds);
 
-			_vm->_game->_screenObjects.add(bounds, LAYER_GUI, CAT_ACTION, idx);
+			_vm->_game->_screenObjects.add(bounds, LAYER_GUI, CAT_COMMAND, idx);
 		}
 
 		// Set up inventory list
@@ -478,7 +478,7 @@ bool UserInterface::getBounds(ScrCategory category, int v, Common::Rect &bounds)
 	int leftStart, yOffset, widthAmt;
 
 	switch (category) {
-	case CAT_ACTION:
+	case CAT_COMMAND:
 		heightMultiplier = v % 5;
 		widthMultiplier = v / 5;
 		leftStart = 2;
@@ -635,7 +635,7 @@ void UserInterface::inventoryAnim() {
 }
 
 void UserInterface::categoryChanged() {
-	_v1C = -1;
+	_highlightedItemIndex = -1;
 	_vm->_events->initVars();
 	_category = CAT_NONE;
 }
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index ee5bc7a..740ea66 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -143,9 +143,9 @@ public:
 	int _selectedActionIndex;
 	int _selectedItemVocabIdx;
 	int _scrollerY;
+	int _highlightedCommandIndex;
+	int _highlightedItemIndex;
 	int _highlightedActionIndex;
-	int _v1C;
-	int _v1E;
 	bool _inventoryChanged;
 	int _categoryIndexes[8];
 	Common::StringArray _talkStrings;


Commit: b9daf53bcd14332624f3d18fd21514b1f9146107
    https://github.com/scummvm/scummvm/commit/b9daf53bcd14332624f3d18fd21514b1f9146107
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-28T09:19:55-04:00

Commit Message:
MADS: Cleanup of direction setup, fix sprite mirroring for walking

Changed paths:
    engines/mads/assets.cpp
    engines/mads/assets.h
    engines/mads/game.cpp
    engines/mads/messages.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/player.cpp
    engines/mads/player.h
    engines/mads/scene.cpp
    engines/mads/sequence.cpp



diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index ec5d542..9d02287 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -224,9 +224,9 @@ SpriteSetCharInfo::SpriteSetCharInfo(Common::SeekableReadStream *s) {
 	for (int i = 0; i < 16; ++i)
 		_ticksList[i] = s->readUint16LE();
 
-	_unk1 = s->readUint16LE();
+	_velocity = s->readUint16LE();
 	_ticksAmount = s->readByte();
-	_yScale = s->readByte();
+	_centerOfGravity = s->readByte();
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/assets.h b/engines/mads/assets.h
index 31d4688..b5b3512 100644
--- a/engines/mads/assets.h
+++ b/engines/mads/assets.h
@@ -51,9 +51,9 @@ public:
 	int _frameList2[16];
 	int _frameList[16];
 	int _ticksList[16];
-	int _unk1;
+	int _velocity;
 	int _ticksAmount;
-	int _yScale;
+	int _centerOfGravity;
 };
 
 class SpriteAsset {
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 900d4dc..28a1d1d 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -235,7 +235,7 @@ void Game::sectionLoop() {
 		_player._destPos = _player._playerPos;
 		_player._turnToFacing = _player._facing;
 		_player._targetFacing = _player._facing;
-		_player.setupFrame();
+		_player.selectSeries();
 		_player.updateFrame();
 		_player._visible3 = _player._visible;
 		_player._special = _scene.getDepthHighBits(_player._playerPos);
diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index 617bd6d..5c6e113 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -205,9 +205,9 @@ void KernelMessages::processText(int msgIndex) {
 	if (msg._flags & KMSG_PLAYER_TIMEOUT) {
 		if (player._visible3) {
 			SpriteAsset &asset = *_vm->_game->_scene._sprites[player._spritesStart + player._spritesIdx];
-			MSprite *frame = asset.getFrame(player._frameNum - 1);
+			MSprite *frame = asset.getFrame(player._frameNumber - 1);
 
-			int yAmount = player._currentScale * player._yScale / 100;
+			int yAmount = player._currentScale * player._centerOfGravity / 100;
 			x1 = player._playerPos.x;
 			y1 = (frame->h * player._currentScale / -100) + yAmount +
 				player._playerPos.y - 15;
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index e5c0abd..839c001 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -92,7 +92,7 @@ void Scene1xx::setPlayerSpritesPrefix() {
 		_game._player._loadsFirst = false;
 	}
 
-	_game._player._unk3 = 0;
+	_game._player._trigger = 0;
 	_vm->_palette->setEntry(16, 10, 63, 63);
 	_vm->_palette->setEntry(17, 10, 45, 45);
 }
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index eaec85c..f569e7e 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -37,6 +37,7 @@ Player::Player(MADSEngine *vm): _vm(vm) {
 	_facing = FACING_NORTH;
 	_turnToFacing = FACING_NORTH;
 	_targetFacing = FACING_NORTH;
+	_mirror = false;
 	_spritesLoaded = false;
 	_spritesStart = 0;
 	_spritesIdx = 0;
@@ -51,24 +52,24 @@ Player::Player(MADSEngine *vm): _vm(vm) {
 	_special = 0;
 	_ticksAmount = 0;
 	_priorTimer = 0;
-	_unk3 = _unk4 = 0;
+	_trigger = _unk4 = 0;
+	_spritesChanged = false;
 	_forceRefresh = false;
 	_highSprites = false;
 	_currentDepth = 0;
 	_currentScale = 0;
-	_frameOffset = 0;
-	_frameNum = 0;
-	_yScale = 0;
+	_frameNumber = 0;
+	_centerOfGravity = 0;
 	_frameCount = 0;
-	_unk1 = 0;
-	_unk2 = 0;
-	_unk3 = 0;
+	_velocity = 0;
+	_upcomingTrigger = 0;
+	_trigger = 0;
 	_frameListIndex = 0;
-	_actionIndex = 0;
+	_stopWalkerIndex = 0;
 	_hypotenuse = 0;
 	
-	Common::fill(&_actionList[0], &_actionList[12], 0);
-	Common::fill(&_actionList2[0], &_actionList2[12], 0);
+	Common::fill(&_stopWalkerList[0], &_stopWalkerList[12], 0);
+	Common::fill(&_stopWalkerTrigger[0], &_stopWalkerTrigger[12], 0);
 	Common::fill(&_spriteSetsPresent[0], &_spriteSetsPresent[PLAYER_SPRITES_FILE_COUNT], false);
 }
 
@@ -170,7 +171,8 @@ void Player::dirChanged() {
 
 	_facing = (diff >= 0) ? (Facing)_directionListIndexes[_facing + 20] :
 		(Facing)_directionListIndexes[_facing + 10];
-	setupFrame();
+	selectSeries();
+
 	if ((_facing == _turnToFacing) && !_moving)
 		updateFrame();
 
@@ -182,31 +184,33 @@ void Player::cancelCommand() {
 	_action->_inProgress = false;
 }
 
-void Player::setupFrame() {
+void Player::selectSeries() {
 	Scene &scene = _vm->_game->_scene;
 
-	resetActionList();
-	_frameOffset = 0;
+	clearStopList();
+	_mirror = false;
+
 	_spritesIdx = _directionListIndexes[_facing];
 	if (!_spriteSetsPresent[_spritesIdx]) {
 		// Direction isn't present, so use alternate direction, with entries flipped
 		_spritesIdx -= 4;
-		_frameOffset = 0x8000;
+		_mirror = true;
 	}
 
 	SpriteAsset &spriteSet = *scene._sprites[_spritesStart + _spritesIdx];
 	assert(spriteSet._charInfo);
-	_unk1 = MAX(spriteSet._charInfo->_unk1, 100);
-	setTicksAmount();
+	_velocity = MAX(spriteSet._charInfo->_velocity, 100);
+	setBaseFrameRate();
 
 	_frameCount = spriteSet._charInfo->_totalFrames;
 	if (_frameCount == 0)
 		_frameCount = spriteSet.getCount();
 
-	_yScale = spriteSet._charInfo->_yScale;
+	_centerOfGravity = spriteSet._charInfo->_centerOfGravity;
+
+	if ((_frameNumber <= 0) || (_frameNumber > _frameCount))
+		_frameNumber = 1;
 
-	if ((_frameNum <= 0) || (_frameNum > _frameCount))
-		_frameNum = 1;
 	_forceRefresh = true;
 }
 
@@ -216,32 +220,34 @@ void Player::updateFrame() {
 	assert(spriteSet._charInfo);
 
 	if (!spriteSet._charInfo->_numEntries) {
-		_frameNum = 1;
+		_frameNumber = 1;
 	} else {
-		_frameListIndex = _actionList[_actionIndex];
+		_frameListIndex = _stopWalkerList[_stopWalkerIndex];
 
 		if (!_visible) {
-			_unk2 = 0;
+			_upcomingTrigger = 0;
 		}
 		else {
-			_unk2 = _actionList2[_actionIndex];
+			_upcomingTrigger = _stopWalkerTrigger[_stopWalkerIndex];
 
-			if (_actionIndex > 0)
-				--_actionIndex;
+			if (_stopWalkerIndex > 0)
+				--_stopWalkerIndex;
 		}
 
 		// Set the player frame number
 		int frameIndex = ABS(_frameListIndex);
-		_frameNum = (_frameListIndex <= 0) ? spriteSet._charInfo->_frameList[frameIndex] :
+		_frameNumber = (_frameListIndex <= 0) ? spriteSet._charInfo->_frameList[frameIndex] :
 			spriteSet._charInfo->_frameList2[frameIndex];
 
 		// Set next waiting period in ticks
 		if (frameIndex == 0) {
-			setTicksAmount();
+			setBaseFrameRate();
 		} else {
 			_ticksAmount = spriteSet._charInfo->_ticksList[frameIndex];
 		}
 	}
+
+	_forceRefresh = true;
 }
 
 void Player::update() {
@@ -271,9 +277,9 @@ void Player::update() {
 			slot._SlotType = ST_FOREGROUND;
 			slot._seqIndex = PLAYER_SEQ_INDEX;
 			slot._spritesIndex = _spritesStart + _spritesIdx;
-			slot._frameNumber = _frameOffset + _frameNum;
+			slot._frameNumber = _mirror ? -_frameNumber : _frameNumber;
 			slot._position.x = _playerPos.x;
-			slot._position.y = _playerPos.y + (_yScale * newScale) / 100;
+			slot._position.y = _playerPos.y + (_centerOfGravity * newScale) / 100;
 			slot._depth = newDepth;
 			slot._scale = newScale;
 
@@ -304,7 +310,7 @@ void Player::update() {
 			// has moved off-screen
 			if (_newSceneId) {
 				SpriteAsset *asset = scene._sprites[slot._spritesIndex];
-				MSprite *frame = asset->getFrame(_frameNum - 1);
+				MSprite *frame = asset->getFrame(_frameNumber - 1);
 				int xScale = frame->w * newScale / 200;
 				int yScale = frame->h * newScale / 100;
 				int playerX = slot._position.x;
@@ -326,19 +332,19 @@ void Player::update() {
 	_forceRefresh = false;
 }
 
-void Player::resetActionList() {
-	_actionList[0] = 0;
-	_actionList2[0] = 0;
-	_actionIndex = 0;
-	_unk2 = 0;
-	_unk3 = 0;
+void Player::clearStopList() {
+	_stopWalkerList[0] = 0;
+	_stopWalkerTrigger[0] = 0;
+	_stopWalkerIndex = 0;
+	_upcomingTrigger = 0;
+	_trigger = 0;
 }
 
 void Player::setDest(const Common::Point &pt, Facing facing) {
 	Scene &scene = _vm->_game->_scene;
 
-	resetActionList();
-	setTicksAmount();
+	clearStopList();
+	setBaseFrameRate();
 	_moving = true;
 	_targetFacing = facing;
 
@@ -433,10 +439,10 @@ void Player::move() {
 	else if (!_moving)
 		updateFrame();
 
-	int var1 = _unk1;
+	int velocity = _velocity;
 	if (_unk4 && (_hypotenuse > 0)) {
 		int v1 = -(_currentScale - 100) * (_posDiff.x - 1) / _hypotenuse + _currentScale;
-		var1 = MAX(1, 10000 / (v1 * _currentScale * var1));
+		velocity = MAX(1, 10000 / (v1 * _currentScale * velocity));
 	}
 
 	if (!_moving || (_facing != _turnToFacing))
@@ -444,7 +450,7 @@ void Player::move() {
 
 	Common::Point newPos = _playerPos;
 
-	if (_v8452E < var1) {
+	if (_v8452E < velocity) {
 		do {
 			if (_v8452C < _posDiff.x)
 				_v8452C += _posDiff.y;
@@ -470,10 +476,10 @@ void Player::move() {
 
 			_v8452E += _v84530;
 
-		} while ((_v8452E < var1) && !routeFlag && ((_posChange.x > 0) || (_posChange.y > 0) || (_newSceneId != 0)));
+		} while ((_v8452E < velocity) && !routeFlag && ((_posChange.x > 0) || (_posChange.y > 0) || (_newSceneId != 0)));
 	}
 
-	_v8452E -= var1;
+	_v8452E -= velocity;
 
 	if (routeFlag)
 		cancelCommand();
@@ -512,15 +518,15 @@ void Player::idle() {
 		// Reset back to the start of the list
 		_frameListIndex = 0;
 	else {
-		_frameNum += direction;
+		_frameNumber += direction;
 		_forceRefresh = true;
 
-		if (spriteSet._charInfo->_frameList2[frameIndex] < _frameNum) {
-			_unk3 = _unk2;
+		if (spriteSet._charInfo->_frameList2[frameIndex] < _frameNumber) {
+			_trigger = _upcomingTrigger;
 			updateFrame();
 		}
-		if (spriteSet._charInfo->_frameList[frameIndex] < _frameNum) {
-			_unk3 = _unk2;
+		if (spriteSet._charInfo->_frameList[frameIndex] < _frameNumber) {
+			_trigger = _upcomingTrigger;
 			updateFrame();
 		}
 	}
@@ -528,8 +534,8 @@ void Player::idle() {
 
 void Player::postUpdate() {
 	if (_moving) {
-		if (++_frameNum > _frameCount)
-			_frameNum = 1;
+		if (++_frameNumber > _frameCount)
+			_frameNumber = 1;
 		_forceRefresh = true;
 	} else {
 		if (!_forceRefresh)
@@ -559,7 +565,7 @@ int Player::getScale(int yp) {
 	return MIN(scale, 100);
 }
 
-void Player::setTicksAmount() {
+void Player::setBaseFrameRate() {
 	Scene &scene = _vm->_game->_scene;
 
 	SpriteAsset &spriteSet = *scene._sprites[_spritesStart + _spritesIdx];
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 004c412..71f3406 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -51,20 +51,20 @@ private:
 	MADSEngine *_vm;
 	bool _highSprites;
 	bool _spriteSetsPresent[PLAYER_SPRITES_FILE_COUNT];
-	int _frameOffset;
+	bool _mirror;
 	int _frameCount;
 	int _frameListIndex;
-	int _actionIndex;
 	bool _v844BC;
 	int _v8452E;
 	int _v8452C;
 	int _v84530;
 	int _routeLength;
-	int _actionList[12];
-	int _actionList2[12];
+	int _stopWalkerList[12];
+	int _stopWalkerTrigger[12];
+	int _stopWalkerIndex;
 	int _hypotenuse;
 
-	void resetActionList();
+	void clearStopList();
 
 	void move();
 
@@ -80,7 +80,7 @@ private:
 	 */
 	int getScale(int yp);
 
-	void setTicksAmount();
+	void setBaseFrameRate();
 
 	void setupRoute();
 
@@ -117,7 +117,7 @@ public:
 	bool _priorVisible;
 	bool _visible3;
 	bool _walkAnywhere;
-	int _frameNum;
+	int _frameNumber;
 	bool _loadsFirst;
 	bool _loadedFirst;
 	Common::Point _playerPos;
@@ -130,12 +130,12 @@ public:
 	int _special;
 	int _ticksAmount;
 	uint32 _priorTimer;
-	int _unk1;
-	int _unk2;
-	int _unk3;
+	int _velocity;
+	int _upcomingTrigger;
+	int _trigger;
 	bool _unk4;
 	bool _forceRefresh;
-	int _yScale;
+	int _centerOfGravity;
 	int _currentDepth;
 	int _currentScale;
 	Common::String _spritesPrefix;
@@ -167,7 +167,10 @@ public:
 	 */
 	void cancelCommand();
 
-	void setupFrame();
+	/**
+	 * Set up control parameters for the current active series (the
+	 * direction which the player is facing in) */
+	void selectSeries();
 
 	void updateFrame();
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index aa57a7e..6270251 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -290,7 +290,7 @@ void Scene::doFrame() {
 		_action._selectedAction = 0;
 	}
 
-	if (!_vm->_game->_trigger && !player._unk3) {
+	if (!_vm->_game->_trigger && !player._trigger) {
 		// Refresh the dynamic hotspots if they've changed
 		if (_dynamicHotspots._changed)
 			_dynamicHotspots.refresh();
@@ -301,7 +301,7 @@ void Scene::doFrame() {
 	}
 
 	if (_action._selectedAction && player._stepEnabled && !_action._startWalkFlag &&
-			!_vm->_game->_trigger && !player._unk3) {
+			!_vm->_game->_trigger && !player._trigger) {
 		_action.startAction();
 		if (_action._activeAction._verbId == Nebular::NOUN_LOOK_AT) {
 			_action._activeAction._verbId = VERB_LOOK;
@@ -512,7 +512,7 @@ void Scene::doSceneStep() {
 	_vm->_game->_sectionHandler->step();
 
 	_vm->_game->_player.step();
-	_vm->_game->_player._unk3 = 0;
+	_vm->_game->_player._trigger = 0;
 
 	if (_vm->_game->_abortTimersMode == ABORTMODE_1)
 		_vm->_game->_trigger = 0;
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 97d8674..9a8e2c6 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -495,7 +495,7 @@ void SequenceList::setScale(int spriteIdx, int scale) {
 
 void SequenceList::setMsgLayout(int seqIndex) {
 	Player &player = _vm->_game->_player;
-	int yp = player._playerPos.y + (player._yScale * player._currentScale) / 100;
+	int yp = player._playerPos.y + (player._centerOfGravity * player._currentScale) / 100;
 	setMsgPosition(seqIndex, Common::Point(player._playerPos.x, yp));
 	setDepth(seqIndex, player._currentDepth);
 	setScale(seqIndex, player._currentScale);


Commit: 5df6ff9329c46bf4df8fc4dcaa378959eab1d8ee
    https://github.com/scummvm/scummvm/commit/5df6ff9329c46bf4df8fc4dcaa378959eab1d8ee
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-28T20:15:51+01:00

Commit Message:
MADS: suppress optional parameters of isAction, rework and renaming in scene 202

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 839c001..48e9b4b 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -259,7 +259,7 @@ void Scene103::preActions() {
 void Scene103::actions() {
 	if (_action._savedFields._lookFlag) {
 		_vm->_dialogs->show(10322);
-	} else if (_action.isAction(395, 110, 0)) {
+	} else if (_action.isAction(395, 110)) {
 		switch (_vm->_game->_trigger) {
 		case 0:
 			_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(
@@ -279,7 +279,7 @@ void Scene103::actions() {
 			break;
 		}
 	}
-	else if (_action.isAction(VERB_TAKE, 371, 0) && _game._objects.isInRoom(OBJ_TIMER_MODULE)) {
+	else if (_action.isAction(VERB_TAKE, 371) && _game._objects.isInRoom(OBJ_TIMER_MODULE)) {
 		switch (_vm->_game->_trigger) {
 		case 0:
 			_scene->changeDepthSurface(1);
@@ -341,9 +341,9 @@ void Scene103::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_LOOK, 362, 0)) {
+	} else if (_action.isAction(VERB_LOOK, 362)) {
 		_vm->_dialogs->show(10301);
-	} else if (_action.isAction(VERB_TAKE, 362, 0)) {
+	} else if (_action.isAction(VERB_TAKE, 362)) {
 		if (!_vm->_game->_trigger)
 			_vm->_sound->command(31);
 
@@ -368,10 +368,10 @@ void Scene103::actions() {
 				_scene->_hotspots.activate(362, false);
 			}
 		}
-	} else if (_action.isAction(VERB_LOOK, 250, 0)) {
+	} else if (_action.isAction(VERB_LOOK, 250)) {
 		_vm->_dialogs->show(!_globals[kTurkeyExploded] ? 10323 : 10303);
 	}
-	else if (_action.isAction(VERB_TALKTO, 27, 0)) {
+	else if (_action.isAction(VERB_TALKTO, 27)) {
 		switch (_vm->_game->_trigger) {
 		case 0: {
 			_game._player._stepEnabled = false;
@@ -400,39 +400,39 @@ void Scene103::actions() {
 		default:
 			break;
 		}
-	} else if (!_action.isAction(VERB_LOOK, 27, 0)) {
+	} else if (!_action.isAction(VERB_LOOK, 27)) {
 		_vm->_dialogs->show(10304);
-	} else if (!_action.isAction(VERB_LOOK, 36, 0)) {
+	} else if (!_action.isAction(VERB_LOOK, 36)) {
 		_vm->_dialogs->show(10307);
-	} else if (!_action.isAction(VERB_LOOK, 55, 0)) {
+	} else if (!_action.isAction(VERB_LOOK, 55)) {
 		_vm->_dialogs->show(10308);
-	} else if (!_action.isAction(VERB_TAKE, 315, 0)) {
+	} else if (!_action.isAction(VERB_TAKE, 315)) {
 		_vm->_dialogs->show(10309);
-	} else if (!_action.isAction(VERB_TAKE, 85, 0)) {
+	} else if (!_action.isAction(VERB_TAKE, 85)) {
 		_vm->_dialogs->show(10310);
-	} else if (!_action.isAction(VERB_LOOK, 144, 0)) {
+	} else if (!_action.isAction(VERB_LOOK, 144)) {
 		_vm->_dialogs->show(10312);
-	} else if (!_action.isAction(VERB_OPEN, 144, 0)) {
+	} else if (!_action.isAction(VERB_OPEN, 144)) {
 		_vm->_dialogs->show(10313);
-	} else if (!_action.isAction(VERB_CLOSE, 27, 0)) {
+	} else if (!_action.isAction(VERB_CLOSE, 27)) {
 		_vm->_dialogs->show(10314);
-	} else if (!_action.isAction(VERB_LOOK, 310, 0)) {
+	} else if (!_action.isAction(VERB_LOOK, 310)) {
 		_vm->_dialogs->show(10315);
-	} else if (!_action.isAction(VERB_LOOK, 178, 0)) {
+	} else if (!_action.isAction(VERB_LOOK, 178)) {
 		_vm->_dialogs->show(10316);
-	} else if (!_action.isAction(VERB_LOOK, 283, 0)) {
+	} else if (!_action.isAction(VERB_LOOK, 283)) {
 		_vm->_dialogs->show(10317);
-	} else if (!_action.isAction(VERB_LOOK, 120, 0)) {
+	} else if (!_action.isAction(VERB_LOOK, 120)) {
 		_vm->_dialogs->show(10318);
-	} else if (_action.isAction(VERB_LOOK, 289, 0) &&
+	} else if (_action.isAction(VERB_LOOK, 289) &&
 			_game._objects.isInInventory(OBJ_REBREATHER)) {
 		_vm->_dialogs->show(10319);
-	} else if (_action.isAction(VERB_LOOK, 371, 0) &&
+	} else if (_action.isAction(VERB_LOOK, 371) &&
 			_game._objects.isInInventory(OBJ_TIMER_MODULE)) {
 		_vm->_dialogs->show(10320);
-	} else if (!_action.isAction(VERB_LOOK, 137, 0)) {
+	} else if (!_action.isAction(VERB_LOOK, 137)) {
 		_vm->_dialogs->show(10321);
-	} else if (_action.isAction(VERB_LOOK, 409, 0)) {
+	} else if (_action.isAction(VERB_LOOK, 409)) {
 		_vm->_dialogs->show(_game._objects.isInInventory(OBJ_TIMER_MODULE) ? 10324 : 10325);
 	}
 
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 38f87ba..4f404f6 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -285,9 +285,9 @@ void Scene201::step() {
 void Scene201::actions() {
 	MADSAction *action = _game._player._action;
 	if (action->_lookFlag == false) {
-		if (action->isAction(0x18C, 0x83, 0))
+		if (action->isAction(0x18C, 0x83))
 			_scene->_nextSceneId = 202;
-		else if ((action->isAction(0x50, 0x156, 0)) || (action->isAction(0x188, 0x16C, 0)) || (action->isAction(0x188, 0x1B6, 0))) {
+		else if ((action->isAction(0x50, 0x156)) || (action->isAction(0x188, 0x16C)) || (action->isAction(0x188, 0x1B6))) {
 			if (_game._trigger == 0) { 
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
@@ -296,30 +296,30 @@ void Scene201::actions() {
 			} else if (_game._trigger == 1) {
 				_scene->_nextSceneId = 213;
 			}
-		} else if (action->isAction(0x3, 0x1A6, 0)) {
+		} else if (action->isAction(0x3, 0x1A6)) {
 			_vm->_dialogs->show(0x4E85);
-		} else if (action->isAction(0x3, 0x129, 0)) {
+		} else if (action->isAction(0x3, 0x129)) {
 			_vm->_dialogs->show(0x4E86);
-		} else if (action->isAction(0x3, 0x16F, 0)) {
+		} else if (action->isAction(0x3, 0x16F)) {
 			_vm->_dialogs->show(0x4E87);
-		} else if (action->isAction(0x3, 0x142, 0)) {
+		} else if (action->isAction(0x3, 0x142)) {
 			_vm->_dialogs->show(0x4E88);
-		} else if (action->isAction(0x3, 0x18F, 0)) {
+		} else if (action->isAction(0x3, 0x18F)) {
 			_vm->_dialogs->show(0x4E89);
-		} else if (action->isAction(0x3, 0x1B9, 0)) {
+		} else if (action->isAction(0x3, 0x1B9)) {
 			_vm->_dialogs->show(0x4E8A);
-		} else if (action->isAction(0x3, 0x192, 0)) {
+		} else if (action->isAction(0x3, 0x192)) {
 			_vm->_dialogs->show(0x4E8B);
-		} else if (action->isAction(0x3, 0x1BA, 0)) {
+		} else if (action->isAction(0x3, 0x1BA)) {
 			_vm->_dialogs->show(0x4E8C);
-		} else if (action->isAction(0x3, 0x83, 0)) {
+		} else if (action->isAction(0x3, 0x83)) {
 			_vm->_dialogs->show(0x4E8E);
-		} else if (action->isAction(0x3, 0x1B6, 0)) {
+		} else if (action->isAction(0x3, 0x1B6)) {
 			if (_globals[kMeteorologistEverSeen])
 				_vm->_dialogs->show(0x4E90);
 			else
 				_vm->_dialogs->show(0x4E8D);
-		} else if (action->isAction(0x3, 0x16C, 0)) {
+		} else if (action->isAction(0x3, 0x16C)) {
 			_vm->_dialogs->show(0x4E91);
 		} else
 			return;
@@ -406,16 +406,16 @@ void Scene202::enter() {
 	_activeMsgFl = false;
 
 	if (_scene->_priorSceneId == -2) {
-		if (_waitingMeteorologistFl) {
+		if (_waitingMeteoFl) {
 			_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
 			_game._player._visible = false;
 		}
 	} else {
-		_waitingMeteorologistFl = false;
+		_waitingMeteoFl = false;
 		_ladderTopFl = false;
 	}
 
-	_globals._v8425C = _globals._v7 = _scene->_frameStartTime;
+	_meteoClock1 = _meteoClock2 = _scene->_frameStartTime;
 
 	if (_scene->_roomChanged)
 		_game._objects.addToInventory(OBJ_NONE);
@@ -480,7 +480,7 @@ void Scene202::step() {
 	if (_game._trigger == 71) {
 		_vm->_sound->command(3);
 		_vm->_sound->command(9);
-		_globals._v8425C = 900 + _scene->_frameStartTime;
+		_meteoClock1 = 900 + _scene->_frameStartTime;
 		Common::Point msgPos;
 		int msgFlag;
 		if (!_ladderTopFl) {
@@ -551,31 +551,29 @@ void Scene202::step() {
 		break;
 	}
 	
-	if (!_scene->_activeAnimation && (_globals[kMeteorologistStatus] != 2) && (_globals._v7 <= _scene->_frameStartTime) && (_globals._v8425C <= _scene->_frameStartTime)) {
+	if (!_scene->_activeAnimation && (_globals[kMeteorologistStatus] != 2) && (_meteoClock2 <= _scene->_frameStartTime) && (_meteoClock1 <= _scene->_frameStartTime)) {
 		int randVal = _vm->getRandomNumber(1, 500);
 		int threshold = 1;
 		if (_ladderTopFl)
-			threshold = 26;
+			threshold += 25;
 		if (!_globals[kMeteorologistEverSeen])
-			threshold = 25;
+			threshold += 25;
 		if (threshold >= randVal) {
 			_vm->_sound->command(17);
 			_scene->loadAnimation(formAnimName('M', -1), 71);
-			_globals._v84266 = -1;
-			_globals._v84268 = 0;
+			_toStationFl = true;
+			_toTeleportFl = false;
 			_globals[kMeteorologistEverSeen] = true;
-			_globals._v6 = _scene->_frameStartTime;
-			_globals._v8 = 0;
-			_globals._v84262 = 0;
-			_globals._v84264 = 0;
-			_globals._v7 = _scene->_frameStartTime + 2;
+			_lastRoute = 0;
+			_stationCounter = 0;
+			_meteoClock2 = _scene->_frameStartTime + 2;
 		}
 	}
 	
 	if (!_scene->_activeAnimation)
 		return;
 
-	if (_waitingMeteorologistFl) {
+	if (_waitingMeteoFl) {
 		if (_scene->_activeAnimation->getCurrentFrame() >= 200) {
 			if ((_globals[kMeteorologistWatch] == 2) || _globals[kLadderBroken]) {
 				_scene->_nextSceneId = 213;
@@ -600,8 +598,8 @@ void Scene202::step() {
 		}
 	}
 
-	if (_globals._v7 + 7200 <= _scene->_frameStartTime) {
-		_globals._v84268 = -1;
+	if (_meteoClock2 + 7200 <= _scene->_frameStartTime) {
+		_toTeleportFl = true;
 	}
 
 	if (_scene->_activeAnimation->getCurrentFrame() == _globals._v84260) {
@@ -631,18 +629,18 @@ void Scene202::step() {
 		frameStep = subStep4(randVal);
 		break;
 	case 59:
-		_globals._v84262 = 3;
-		++_globals._v84264;
+		_lastRoute = 3;
+		++_stationCounter;
 		if (randVal <= 800)
 			frameStep = 55;
 		break;
 	case 89:
-		_globals._v84262 = 1;
+		_lastRoute = 1;
 		if (randVal <= 700)
 			frameStep = 83;
 		break;
 	case 137:
-		_globals._v84262 = 2;
+		_lastRoute = 2;
 		if (randVal <= 700)
 			frameStep = 126;
 		break;
@@ -659,27 +657,27 @@ void Scene202::step() {
 }
 
 int Scene202::subStep1(int randVal) {
-	_globals._v84264 = 0;
+	_stationCounter = 0;
 
-	if ((randVal <= 100) || (_globals._v84266 != 0))
+	if ((randVal <= 100) || _toStationFl)
 		return 42;
 
-	if ((randVal <= 200) || (_globals._v84268 != 0))
+	if ((randVal <= 200) || _toTeleportFl)
 		return 96;
 
-	if ((randVal <= 300) && (_globals._v84262 != 1))
+	if ((randVal <= 300) && (_lastRoute != 1))
 		return 77;
 
 	return 76;
 }
 
 int Scene202::subStep2(int randVal) {
-	_globals._v84266 = 0;
+	_toStationFl = false;
 
-	if ((randVal <= 150) && (_globals._v84264 < 5))
+	if ((randVal <= 150) && (_stationCounter < 5))
 		return 51;
 
-	if ((randVal <= 300) || _globals._v84268)
+	if ((randVal <= 300) || _toTeleportFl)
 		return 74;
 
 	if (randVal <= 400)
@@ -689,20 +687,20 @@ int Scene202::subStep2(int randVal) {
 }
 
 int Scene202::subStep3(int randVal) {
-	if ((randVal <= 100) || (_globals._v84266 != 0))
+	if ((randVal <= 100) || _toStationFl)
 		return 27;
 
-	if ((randVal <= 200) || (_globals._v84268 != 0))
+	if ((randVal <= 200) || _toTeleportFl)
 		return 159;
 
-	if ((randVal <= 300) && (_globals._v84262 != 2))
+	if ((randVal <= 300) && (_lastRoute != 2))
 		return 119;
 
 	return 110;
 }
 
 int Scene202::subStep4(int randVal) {
-	if ((randVal <= 100) || (_globals._v84268 != 0))
+	if ((randVal <= 100) || _toTeleportFl)
 		return 176;
 
 	if (randVal <= 200)
@@ -716,7 +714,7 @@ void Scene202::preActions() {
 	if (action->_walkFlag)
 		_scene->_kernelMessages.reset();
 
-	if (!_ladderTopFl && (action->isAction(0x4E, 0xC7, 0) || !action->_walkFlag)) {
+	if (!_ladderTopFl && (action->isAction(0x4E, 0xC7) || !action->_walkFlag)) {
 		if (_game._trigger == 0) {
 			_vm->_sound->command(29);
 			action->_walkFlag = false;
@@ -727,8 +725,7 @@ void Scene202::preActions() {
 			_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 1);
 		} else if (_game._trigger == 1) {
 			_scene->_sequences.updateTimeout(-1, _globals._spriteIndexes[23]);
-			warning("CHECKME: _scene->_dynamicHotspots.remove(_globals._frameTime);");
-			_scene->_dynamicHotspots.remove(_globals._frameTime);
+			_scene->_dynamicHotspots.remove(_ladderHotspotId);
 			_game._player._visible = true;
 			action->_walkFlag = true;
 			_game._player._stepEnabled = true;
@@ -736,7 +733,7 @@ void Scene202::preActions() {
 		}		
 	}
 
-	if (action->isAction(0x3, 0x27, 0) && action->_activeAction._indirectObjectId > 0) {
+	if (action->isAction(0x3, 0x27) && action->_activeAction._indirectObjectId > 0) {
 		if (!action->_walkFlag || _ladderTopFl)
 			action->_startWalkFlag = false;
 		else
@@ -750,12 +747,12 @@ void Scene202::preActions() {
 void Scene202::actions() {
 	MADSAction *action = _game._player._action;
 	if (action->_lookFlag == false) {
-		if (action->isAction(0x4E, 0xC7, 0)) {
+		if (action->isAction(0x4E, 0xC7)) {
 			action->_inProgress = false;
 			return;
-		} else if (action->isAction(0x18C, 0x83, 0)) {
+		} else if (action->isAction(0x18C, 0x83)) {
 			_scene->_nextSceneId = 203;
-		} else if (action->isAction(0x18C, 0x82, 0)) {
+		} else if (action->isAction(0x18C, 0x82)) {
 			if (_globals[kMeteorologistStatus] != 2) {
 				if (_scene->_activeAnimation)
 					_globals[kMeteorologistStatus] = 1;
@@ -763,7 +760,7 @@ void Scene202::actions() {
 					_globals[kMeteorologistStatus] = 0;
 			}
 			_scene->_nextSceneId = 201;
-		} else if (action->isAction(0x4, 0x2C, 0)) {
+		} else if (action->isAction(0x4, 0x2C)) {
 			if (action->_actionMode2 == 4) {
 				if (_game._trigger == 0) {
 					if (_game._objects.isInInventory(OBJ_BONES)) {
@@ -801,16 +798,15 @@ void Scene202::actions() {
 					return;
 				}
 			}
-		} else if ((action->isAction(0x50, 0xC7, 0)) && (_globals[kLadderBroken] == 0)) {
+		} else if ((action->isAction(0x50, 0xC7)) && (_globals[kLadderBroken] == 0)) {
 			if (_game._trigger == 0) {
 				_vm->_sound->command(29);
-				_globals._v8425C = _scene->_frameStartTime;
+				_meteoClock1 = _scene->_frameStartTime;
 				_game._player._visible = false;
 				_game._player._stepEnabled = false;
 
 				int idx = _scene->_dynamicHotspots.add(199, 79, -1, Common::Rect(241, 68, 12, 54));
-				warning("CHECKME: _globals._frameTime = _scene->_dynamicHotspots.setPosition(idx, 246, 124, 8);");
-				_globals._frameTime = _scene->_dynamicHotspots.setPosition(idx, 246, 124, FACING_NORTH);
+				_ladderHotspotId = _scene->_dynamicHotspots.setPosition(idx, 246, 124, FACING_NORTH);
 				_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
 				_scene->_sequences.setDepth(_globals._spriteIndexes[23], 1);
 				_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 1);
@@ -843,7 +839,7 @@ void Scene202::actions() {
 					_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
 					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
 					if (_scene->_activeAnimation) {
-						_waitingMeteorologistFl = true;
+						_waitingMeteoFl = true;
 						_globals[kMeteorologistWatch] = 1;
 					} else {
 						_scene->_sequences.addTimer(120, 2);
@@ -868,7 +864,7 @@ void Scene202::actions() {
 				}
 			} else {
 				if (_game._trigger == 0) {
-					_globals._v84268 = 1;
+					_toTeleportFl = true;
 					_game._player._stepEnabled = false;
 					_scene->_sequences.remove(_globals._spriteIndexes[24]);
 					_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0);
@@ -883,7 +879,7 @@ void Scene202::actions() {
 						if (_scene->_activeAnimation->getCurrentFrame() > 200) {
 							_scene->_sequences.addTimer(120, 2);
 						} else {
-							_waitingMeteorologistFl = true;
+							_waitingMeteoFl = true;
 							_globals[kMeteorologistWatch] = 2;
 							if ((_scene->_activeAnimation->getCurrentFrame() >= 44) && (_scene->_activeAnimation->getCurrentFrame() <= 75)) {
 								_scene->_kernelMessages.reset();
@@ -916,15 +912,15 @@ void Scene202::actions() {
 					return;
 				}
 			}
-		} else if (action->isAction(0x188, 0xAA, 0)) {
+		} else if (action->isAction(0x188, 0xAA)) {
 			setRandomKernelMessage();
-		} else if (action->isAction(0x3, 0x129, 0)) {
+		} else if (action->isAction(0x3, 0x129)) {
 			_vm->_dialogs->show(0x4EEA);
-		} else if (action->isAction(0x3, 0x86, 0)) {
+		} else if (action->isAction(0x3, 0x86)) {
 			_vm->_dialogs->show(0x4EEB);
-		} else if (action->isAction(0x3, 0x19C, 0)) {
+		} else if (action->isAction(0x3, 0x19C)) {
 			_vm->_dialogs->show(0x4EEC);
-		} else if (action->isAction(0x3, 0x82, 0)) {
+		} else if (action->isAction(0x3, 0x82)) {
 			if ((_globals[kMeteorologistStatus] == 0) || (_globals[kMeteorologistStatus] == 2)) {
 				_vm->_dialogs->show(0x4EED);
 			} else if (_globals[kMeteorologistStatus] == 1) {
@@ -933,30 +929,30 @@ void Scene202::actions() {
 				action->_inProgress = false;
 				return;
 			} 
-		} else if (action->isAction(0x3, 0x18E, 0)) {
+		} else if (action->isAction(0x3, 0x18E)) {
 			_vm->_dialogs->show(0x4EEE);
-		} else if (action->isAction(0x3, 0x164, 0)) {
+		} else if (action->isAction(0x3, 0x164)) {
 			_vm->_dialogs->show(0x4EEF);
-		} else if (action->isAction(0x3, 0x175, 0)) {
+		} else if (action->isAction(0x3, 0x175)) {
 			_vm->_dialogs->show(0x4EF0);
-		} else if (action->isAction(0x3, 0x174, 0)) {
+		} else if (action->isAction(0x3, 0x174)) {
 			_vm->_dialogs->show(0x4EF1);
-		} else if (action->isAction(0x3, 0x142, 0)) {
+		} else if (action->isAction(0x3, 0x142)) {
 			_vm->_dialogs->show(0x4EF2);
-		} else if (action->isAction(0x3, 0xAA, 0)) {
+		} else if (action->isAction(0x3, 0xAA)) {
 			if ((_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == 8))
 				_vm->_dialogs->show(0x4EF4);
 			else
 				_vm->_dialogs->show(0x4EF3);
-		} else if (action->isAction(0x3, 0x186, 0)) {
+		} else if (action->isAction(0x3, 0x186)) {
 			_vm->_dialogs->show(0x4EF5);
-		} else if (action->isAction(0x3, 0x1B5, 0)) {
+		} else if (action->isAction(0x3, 0x1B5)) {
 			_vm->_dialogs->show(0x4EF6);
-		} else if (action->isAction(0x3, 0x140, 0)) {
+		} else if (action->isAction(0x3, 0x140)) {
 			_vm->_dialogs->show(0x4EF7);
-		} else if (action->isAction(0x4, 0x140, 0)) {
+		} else if (action->isAction(0x4, 0x140)) {
 			_vm->_dialogs->show(0x4EF8);
-		} else if (action->isAction(0x3, 0x2D, 0)) {
+		} else if (action->isAction(0x3, 0x2D)) {
 			if (action->_actionMode == 4)
 				_vm->_dialogs->show(0x4EF9);
 			else
@@ -1047,34 +1043,34 @@ void Scene203::step() {
 }
 
 void Scene203::preActions() {
-	if (_globals._v0 && !_action.isAction(0x18C, 0x83, 0)) {
+	if (_globals._v0 && !_action.isAction(0x18C, 0x83)) {
 		_game._player.startWalking(Common::Point(158, 136), FACING_SOUTH);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(0xD, 0xF3, 0))
+	if (_action.isAction(0xD, 0xF3))
 		_game._player._v844BE = 209;
 }
 
 void Scene203::actions() {
 	if (_action._savedFields._lookFlag) {
 		_vm->_dialogs->show(0x4F53);
-	} else if (_action.isAction(0x18C, 0x83, 0)) {
+	} else if (_action.isAction(0x18C, 0x83)) {
 		_scene->_nextSceneId = 208;
-	} else if (_action.isAction(0x18C, 0x82, 0)) {
+	} else if (_action.isAction(0x18C, 0x82)) {
 		_scene->_nextSceneId = 202;
-	} else if (_action.isAction(0x3, 0x142, 0)) {
+	} else if (_action.isAction(0x3, 0x142)) {
 		_vm->_dialogs->show(0x4F4D);
-	} else if (_action.isAction(0x3, 0x4D, 0)) {
+	} else if (_action.isAction(0x3, 0x4D)) {
 		_vm->_dialogs->show(0x4F4E);
-	} else if (_action.isAction(0x3, 0x100, 0)) {
+	} else if (_action.isAction(0x3, 0x100)) {
 		_vm->_dialogs->show(0x4F4F);
-	} else if (_action.isAction(0x3, 0x82, 0)) {
+	} else if (_action.isAction(0x3, 0x82)) {
 		_vm->_dialogs->show(0x4F50);
-	} else if (_action.isAction(0x3, 0x1A6, 0)) {
+	} else if (_action.isAction(0x3, 0x1A6)) {
 		_vm->_dialogs->show(0x4F51);
-	} else if (_action.isAction(0x3, 0x30, 0)) {
+	} else if (_action.isAction(0x3, 0x30)) {
 		_vm->_dialogs->show(0x4F51);
 	} else
 		return;
@@ -1280,17 +1276,17 @@ void Scene207::step() {
 }
 
 void Scene207::preActions() {
-	if (_action.isAction(0x1AD, 0x1AE, 0))
+	if (_action.isAction(0x1AD, 0x1AE))
 		_game._player._v844BE = 211;
 
-	if (_action.isAction(0x18C, 0x1AB, 0))
+	if (_action.isAction(0x18C, 0x1AB))
 		_game._player._v844BE = 208;
 
-	if ((_action.isAction(0xD, 0)) || (_action.isAction(0x3, 0))) {
-		if (_action.isAction(0x185, 0)) {
+	if ((_action.isAction(0xD)) || (_action.isAction(0x3))) {
+		if (_action.isAction(0x185)) {
 			_globals._frameTime = 0xD8F1;
 			_globals._frameTime |= 0xFFFF0000;
-		} else if (_action.isAction(0x14D, 0)) {
+		} else if (_action.isAction(0x14D)) {
 			_globals._v3 = 0xD8F1;
 			_globals._v4 = -1;
 		}
@@ -1301,7 +1297,7 @@ void Scene207::actions() {
 	if (_action._savedFields._lookFlag) {
 		_vm->_dialogs->show(0x50E7);
 	} else {
-		if (_action.isAction(0x18B, 0x70, 0))
+		if (_action.isAction(0x18B, 0x70))
 			_scene->_nextSceneId = 214;
 		else {
 			if ((_game._player._playerPos.x > 150) && (_game._player._playerPos.x < 189) &&
@@ -1319,33 +1315,33 @@ void Scene207::actions() {
 				_globals._v2 = 0;
 			}
 
-			if (_action.isAction(3, 0x69, 0)) {
+			if (_action.isAction(3, 0x69)) {
 				_vm->_dialogs->show(0x50DD);
-			} else if (_action.isAction(3, 0x1AF, 0)) {
+			} else if (_action.isAction(3, 0x1AF)) {
 				_vm->_dialogs->show(0x50DE);
-			} else if (_action.isAction(3, 0x141, 0)) {
+			} else if (_action.isAction(3, 0x141)) {
 				_vm->_dialogs->show(0x50DF);
-			} else if (_action.isAction(3, 0x3E, 0)) {
+			} else if (_action.isAction(3, 0x3E)) {
 				_vm->_dialogs->show(0x50E0);
-			} else if (_action.isAction(3, 0x198, 0)) {
+			} else if (_action.isAction(3, 0x198)) {
 				_vm->_dialogs->show(0x50E1);
-			} else if (_action.isAction(3, 0x1AE, 0)) {
+			} else if (_action.isAction(3, 0x1AE)) {
 				_vm->_dialogs->show(0x50E2);
-			} else if (_action.isAction(3, 0xE8, 0)) {
+			} else if (_action.isAction(3, 0xE8)) {
 				_vm->_dialogs->show(0x50E3);
-			} else if (_action.isAction(3, 0x12, 0)) {
+			} else if (_action.isAction(3, 0x12)) {
 				_vm->_dialogs->show(0x50E4);
-			} else if (_action.isAction(3, 0x1AC, 0)) {
+			} else if (_action.isAction(3, 0x1AC)) {
 				_vm->_dialogs->show(0x50E5);
-			} else if (_action.isAction(3, 0x185, 0)) {
+			} else if (_action.isAction(3, 0x185)) {
 				_vm->_dialogs->show(0x50E6);
-			} else if (_action.isAction(4, 0x141, 0)) {
+			} else if (_action.isAction(4, 0x141)) {
 				_vm->_dialogs->show(0x50E8);
-			} else if (_action.isAction(4, 0x12, 0)) {
+			} else if (_action.isAction(4, 0x12)) {
 				_vm->_dialogs->show(0x50E9);
-			} else if (_action.isAction(3, 0x14D, 0)) {
+			} else if (_action.isAction(3, 0x14D)) {
 				_vm->_dialogs->show(0x50EA);
-			} else if (_action.isAction(4, 0x14D, 0)) {
+			} else if (_action.isAction(4, 0x14D)) {
 				_vm->_dialogs->show(0x50EB);
 			} else
 				return;
@@ -1445,18 +1441,18 @@ void Scene208::step() {
 }
 
 void Scene208::preActions() {
-	if (_action.isAction(3, 0) && _action._walkFlag)
+	if (_action.isAction(3) && _action._walkFlag)
 		_action._startWalkFlag = true;
 
-	if (_action.isAction(0x18C, 0x9B, 0))
+	if (_action.isAction(0x18C, 0x9B))
 		_game._player._v844BE = 209;
 
-	if (_action.isAction(0x18C, 0xF6, 0))
+	if (_action.isAction(0x18C, 0xF6))
 		_game._player._v844BE = 207;
 }
 
 void Scene208::actions() {
-	if (_action.isAction(0x18C, 0x19F, 0)) {
+	if (_action.isAction(0x18C, 0x19F)) {
 		if (_globals[kRhotundaStatus])
 			_scene->_nextSceneId = 203;
 		else if (_game._trigger == 0) {
@@ -1466,9 +1462,9 @@ void Scene208::actions() {
 		} else if (_game._trigger == 1) {
 			_scene->_nextSceneId = 203;
 		}
-	} else if (_action.isAction(0x18C, 0x83, 0)) {
+	} else if (_action.isAction(0x18C, 0x83)) {
 		_scene->_nextSceneId = 212;
-	} else if (_action.isAction(0x4, 0x1AA, 0) && (!_globals[kLeavesStatus] || _game._trigger)) {
+	} else if (_action.isAction(0x4, 0x1AA) && (!_globals[kLeavesStatus] || _game._trigger)) {
 		warning("TODO: sub3B282(1);");
 		if (_game._player._stepEnabled)
 			_vm->_dialogs->showPicture(OBJ_BIG_LEAVES, 0x326, 0);
@@ -1491,36 +1487,36 @@ void Scene208::actions() {
 		if (_game._player._stepEnabled) {
 			_vm->_dialogs->show(0x514C);
 		}
-	} else if (_action.isAction(0x3, 0x5D, 0)) {
+	} else if (_action.isAction(0x3, 0x5D)) {
 		_vm->_dialogs->show(0x5141);
-	} else if (_action.isAction(0x3, 0xF6, 0)) {
+	} else if (_action.isAction(0x3, 0xF6)) {
 		_vm->_dialogs->show(0x5142);
-	} else if (_action.isAction(0x3, 0x16F, 0)) {
+	} else if (_action.isAction(0x3, 0x16F)) {
 		_vm->_dialogs->show(0x5143);
-	} else if (_action.isAction(0x3, 0x129, 0)) {
+	} else if (_action.isAction(0x3, 0x129)) {
 		_vm->_dialogs->show(0x5144);
-	} else if (_action.isAction(0x3, 0x1A1, 0)) {
+	} else if (_action.isAction(0x3, 0x1A1)) {
 		_vm->_dialogs->show(0x5145);
-	} else if (_action.isAction(0x4, 0x1A1, 0)) {
+	} else if (_action.isAction(0x4, 0x1A1)) {
 		_vm->_dialogs->show(0x5146);
-	} else if (_action.isAction(0x3, 0x9B, 0)) {
+	} else if (_action.isAction(0x3, 0x9B)) {
 		_vm->_dialogs->show(0x5147);
-	} else if (_action.isAction(0x3, 0x19E, 0)) {
+	} else if (_action.isAction(0x3, 0x19E)) {
 		_vm->_dialogs->show(0x5148);
-	} else if (_action.isAction(0x3, 0x1AA, 0)) {
+	} else if (_action.isAction(0x3, 0x1AA)) {
 		_vm->_dialogs->show(0x5149);
-	} else if (_action.isAction(0x3, 0x1A9, 0)) {
+	} else if (_action.isAction(0x3, 0x1A9)) {
 		if (_game._difficulty == DIFFICULTY_IMPOSSIBLE)
 			_vm->_dialogs->show(0x514A);
 		else
 			_vm->_dialogs->show(0x514B);
-	} else if (_action.isAction(0x3, 0x174, 0) || _action.isAction(0x3, 0x175, 0)) {
+	} else if (_action.isAction(0x3, 0x174) || _action.isAction(0x3, 0x175)) {
 		_vm->_dialogs->show(0x514D);
-	} else if (_action.isAction(0x4, 0x1A9, 0)) {
+	} else if (_action.isAction(0x4, 0x1A9)) {
 		_vm->_dialogs->show(0x514E);
-	} else if (_action.isAction(0x3, 0x1A8, 0)) {
+	} else if (_action.isAction(0x3, 0x1A8)) {
 		_vm->_dialogs->show(0x514F);
-	} else if (_action.isAction(0x4, 0x1A8, 0) || _action.isAction(0xA, 0x1A8, 0)) {
+	} else if (_action.isAction(0x4, 0x1A8) || _action.isAction(0xA, 0x1A8)) {
 		_vm->_dialogs->show(0x5150);
 	} else if (_action._savedFields._lookFlag == 0) {
 		return;
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 7ef50e1..40ccae6 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -63,7 +63,9 @@ public:
 
 class Scene202: public Scene2xx {
 private:
-	bool _activeMsgFl, _ladderTopFl, _waitingMeteorologistFl;
+	bool _activeMsgFl, _ladderTopFl, _waitingMeteoFl, _toStationFl, _toTeleportFl;
+	int _ladderHotspotId, _lastRoute, _stationCounter;
+	uint32 _meteoClock1, _meteoClock2, _startTime;
 
 	int subStep1(int randVal);
 	int subStep2(int randVal);
@@ -71,7 +73,9 @@ private:
 	int subStep4(int randVal);
 
 public:
-	Scene202(MADSEngine *vm) : Scene2xx(vm), _activeMsgFl(false), _ladderTopFl(false), _waitingMeteorologistFl(false) {}
+	Scene202(MADSEngine *vm) : Scene2xx(vm), _activeMsgFl(false), _ladderTopFl(false), _waitingMeteoFl(false),
+		_ladderHotspotId(-1), _meteoClock1(0), _meteoClock2(0), _toStationFl(false), _toTeleportFl(false),
+		_lastRoute(0), _stationCounter(0) {}
 	virtual void setup();
 	virtual void enter();
 	virtual void step();


Commit: 5abec8506bc1e6ad5617544b76bd2cc4f42dcc5b
    https://github.com/scummvm/scummvm/commit/5abec8506bc1e6ad5617544b76bd2cc4f42dcc5b
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-28T23:23:46+01:00

Commit Message:
MADS: Some work on scene 205

Changed paths:
    engines/mads/nebular/globals_nebular.cpp
    engines/mads/nebular/globals_nebular.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp
index c0df800..e2886ee 100644
--- a/engines/mads/nebular/globals_nebular.cpp
+++ b/engines/mads/nebular/globals_nebular.cpp
@@ -52,7 +52,6 @@ Globals::Globals() {
 	_v84264 = 0;
 	_v84266 = 0;
 	_v84268 = 0;
-	_v84274 = 0;
 }
 
 void Globals::reset() {
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index 703dc1b..eebbd8e 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -295,7 +295,7 @@ public:
 	int _v8;
 	int _abortVal;
 	uint32 _v8425C;
-	int _v84260, _v84262, _v84264, _v84266, _v84268, _v84274;
+	int _v84260, _v84262, _v84264, _v84266, _v84268;
 public:
 	/**
 	 * Constructor
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 4f404f6..d6ce493 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1112,14 +1112,13 @@ void Scene205::enter() {
 	_scene->_sequences.setDepth(_globals._spriteIndexes[20], 11);
 
 	if (!_game._visitedScenes._sceneRevisited) {
-		_globals._v2 = _scene->_frameStartTime & 0xFFFF;
-		_globals._v3 = _scene->_frameStartTime >> 16;
+		_lastFishTime = _scene->_frameStartTime;
 		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 7, 1, 0, 0);
 		idx = _scene->_dynamicHotspots.add(269, 13, _globals._spriteIndexes[21], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, 49, 86, FACING_NORTH);
 	}
 
-	if (_game._objects[12]._roomNumber == 0) {
+	if (_game._objects[12]._roomNumber == 205) {
 		_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 7, 0, 0, 0);
 		_scene->_sequences.setDepth(_globals._spriteIndexes[19], 11);
 	} else {
@@ -1140,8 +1139,7 @@ void Scene205::enter() {
 	_vm->_palette->setEntry(252, 63, 63, 40);
 	_vm->_palette->setEntry(253, 50, 50, 30);
 
-	_globals._v0 = _globals._frameTime & 0xFFFF;
-	_globals._frameTime >>= 16;
+	_chickenTime = _globals._frameTime;
 
 	if (_globals[kSexOfRex] == SEX_FEMALE)
 		warning("sub71704(0x3, 0xC3, 0x108, 0x63, 0x86, 0xD, 2, 0xFDFC, 0x3C, 0x6C, 0x6C, 0x6D, 0x6D, 0x6E, 0x6E, 0x6F, 0x6C, 0);");
@@ -1162,12 +1160,52 @@ void Scene205::enter() {
 		_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_FRAME_INDEX, 11, 74);
 		_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 0);
 	}
-	_globals._v84274 = -1;
 	sceneEntrySound();
 }
 
 void Scene205::step() {
-	warning("TODO: Scene205::step");
+	if (_globals[kSexOfRex] == SEX_FEMALE) {
+		warning("TODO: sub7178C()");
+
+		if (_globals._frameTime >= _chickenTime) {
+			warning("minVal = 1 + sub7176C();");
+			int minVal = 1;
+
+			warning("TODO: sub717B2(100, minVal);");
+//			if (sub717B2(100, minVal)) {
+				_vm->_sound->command(28);
+//			}
+			_chickenTime = _globals._frameTime + 2;
+		}
+	}
+
+	if (_globals._frameTime - _lastFishTime > 1300) {
+		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 5, 1, 0, 0);
+		int idx = _scene->_dynamicHotspots.add(269, 13, _globals._spriteIndexes[21], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, 49, 86, FACING_NORTH);
+		_lastFishTime = _globals._frameTime;
+	}
+
+	if (_game._trigger == 73) {
+		_scene->_kernelMessages.add(Common::Point(160, 68), 0xFBFA, 32, 0, 60, _game.getQuote(112));
+	}
+
+	if (_game._trigger == 74) {
+		_vm->_sound->command(26);
+		_scene->_kernelMessages.add(Common::Point(106, 90), 0x1110, 32, 0, 60, _game.getQuote(113));
+	}
+
+	if (_game._trigger == 71) {
+		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 0, 0, 0);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[23], 2);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[23], -2, -2);
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(160, 68), 0xFBFA, 32, 72, 180, _game.getQuote(114));
+	}
+
+	if (_game._trigger == 72) {
+		_scene->_nextSceneId = 211;
+	}
 }
 
 void Scene205::actions() {
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 40ccae6..143b24c 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -98,8 +98,10 @@ public:
 };
 
 class Scene205: public Scene2xx {
+	uint32 _lastFishTime, _chickenTime;
 public:
-	Scene205(MADSEngine *vm) : Scene2xx(vm) {}
+	Scene205(MADSEngine *vm) : Scene2xx(vm), _lastFishTime(0), _chickenTime(0) {}
+
 	virtual void setup();
 	virtual void enter();
 	virtual void step();


Commit: 49278129f6efffaa531ad29d32119d4ab83f3108
    https://github.com/scummvm/scummvm/commit/49278129f6efffaa531ad29d32119d4ab83f3108
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-28T20:23:25-04:00

Commit Message:
MADS: Cleanup of Player::updateFrame

Changed paths:
    engines/mads/assets.cpp
    engines/mads/assets.h
    engines/mads/game.cpp
    engines/mads/player.cpp
    engines/mads/player.h



diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index 9d02287..47b2763 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -218,9 +218,9 @@ SpriteSetCharInfo::SpriteSetCharInfo(Common::SeekableReadStream *s) {
 	_numEntries = s->readUint16LE();
 
 	for (int i = 0; i < 16; ++i)
-		_frameList[i] = s->readUint16LE();
+		_startFrames[i] = s->readUint16LE();
 	for (int i = 0; i < 16; ++i)
-		_frameList2[i] = s->readUint16LE();
+		_stopFrames[i] = s->readUint16LE();
 	for (int i = 0; i < 16; ++i)
 		_ticksList[i] = s->readUint16LE();
 
diff --git a/engines/mads/assets.h b/engines/mads/assets.h
index b5b3512..54417f8 100644
--- a/engines/mads/assets.h
+++ b/engines/mads/assets.h
@@ -48,8 +48,8 @@ public:
 
 	int _totalFrames;
 	int _numEntries;
-	int _frameList2[16];
-	int _frameList[16];
+	int _startFrames[16];
+	int _stopFrames[16];
 	int _ticksList[16];
 	int _velocity;
 	int _ticksAmount;
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 28a1d1d..3b22e37 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -237,6 +237,7 @@ void Game::sectionLoop() {
 		_player._targetFacing = _player._facing;
 		_player.selectSeries();
 		_player.updateFrame();
+
 		_player._visible3 = _player._visible;
 		_player._special = _scene.getDepthHighBits(_player._playerPos);
 		_player._priorTimer = _scene._frameStartTime - _player._ticksAmount;
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index f569e7e..d1759d8 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -235,15 +235,15 @@ void Player::updateFrame() {
 		}
 
 		// Set the player frame number
-		int frameIndex = ABS(_frameListIndex);
-		_frameNumber = (_frameListIndex <= 0) ? spriteSet._charInfo->_frameList[frameIndex] :
-			spriteSet._charInfo->_frameList2[frameIndex];
+		int listIndex = ABS(_frameListIndex);
+		_frameNumber = (_frameListIndex >= 0) ? spriteSet._charInfo->_startFrames[listIndex] :
+			spriteSet._charInfo->_stopFrames[listIndex];
 
 		// Set next waiting period in ticks
-		if (frameIndex == 0) {
+		if (listIndex == 0) {
 			setBaseFrameRate();
 		} else {
-			_ticksAmount = spriteSet._charInfo->_ticksList[frameIndex];
+			_ticksAmount = spriteSet._charInfo->_ticksList[listIndex];
 		}
 	}
 
@@ -521,11 +521,11 @@ void Player::idle() {
 		_frameNumber += direction;
 		_forceRefresh = true;
 
-		if (spriteSet._charInfo->_frameList2[frameIndex] < _frameNumber) {
+		if (spriteSet._charInfo->_stopFrames[frameIndex] < _frameNumber) {
 			_trigger = _upcomingTrigger;
 			updateFrame();
 		}
-		if (spriteSet._charInfo->_frameList[frameIndex] < _frameNumber) {
+		if (spriteSet._charInfo->_startFrames[frameIndex] < _frameNumber) {
 			_trigger = _upcomingTrigger;
 			updateFrame();
 		}
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 71f3406..eee1cee 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -172,6 +172,9 @@ public:
 	 * direction which the player is facing in) */
 	void selectSeries();
 
+	/*
+	 * Moves to the next frame for the currently active player sprite set
+	 */
 	void updateFrame();
 
 	void update();


Commit: 05459ac27f7a4838e6a81e569e6d0d075226780b
    https://github.com/scummvm/scummvm/commit/05459ac27f7a4838e6a81e569e6d0d075226780b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-28T22:02:35-04:00

Commit Message:
MADS: Clean up of Player::move method

Changed paths:
    engines/mads/game.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/player.cpp
    engines/mads/player.h



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 3b22e37..a1ca02c 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -232,7 +232,7 @@ void Game::sectionLoop() {
 		_scene._sceneLogic->enter();
 
 		// Set player data
-		_player._destPos = _player._playerPos;
+		_player._targetPos = _player._playerPos;
 		_player._turnToFacing = _player._facing;
 		_player._targetFacing = _player._facing;
 		_player.selectSeries();
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index d6ce493..96347ea 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -53,10 +53,7 @@ void Scene2xx::setPlayerSpritesPrefix() {
 		break;
 	}
 
-	if (_scene->_nextSceneId > 212)
-		_game._player._unk4 = false;
-	else
-		_game._player._unk4 = true;
+	_game._player._scalingVelocity = (_scene->_nextSceneId <= 212);
 
 	if (oldName != _game._player._spritesPrefix)
 		_game._player._spritesChanged = true;
@@ -1050,7 +1047,7 @@ void Scene203::preActions() {
 	}
 
 	if (_action.isAction(0xD, 0xF3))
-		_game._player._v844BE = 209;
+		_game._player._walkOffScreenSceneId = 209;
 }
 
 void Scene203::actions() {
@@ -1315,10 +1312,10 @@ void Scene207::step() {
 
 void Scene207::preActions() {
 	if (_action.isAction(0x1AD, 0x1AE))
-		_game._player._v844BE = 211;
+		_game._player._walkOffScreenSceneId = 211;
 
 	if (_action.isAction(0x18C, 0x1AB))
-		_game._player._v844BE = 208;
+		_game._player._walkOffScreenSceneId = 208;
 
 	if ((_action.isAction(0xD)) || (_action.isAction(0x3))) {
 		if (_action.isAction(0x185)) {
@@ -1483,10 +1480,10 @@ void Scene208::preActions() {
 		_action._startWalkFlag = true;
 
 	if (_action.isAction(0x18C, 0x9B))
-		_game._player._v844BE = 209;
+		_game._player._walkOffScreenSceneId = 209;
 
 	if (_action.isAction(0x18C, 0xF6))
-		_game._player._v844BE = 207;
+		_game._player._walkOffScreenSceneId = 207;
 }
 
 void Scene208::actions() {
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index d1759d8..fe92f87 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -52,7 +52,8 @@ Player::Player(MADSEngine *vm): _vm(vm) {
 	_special = 0;
 	_ticksAmount = 0;
 	_priorTimer = 0;
-	_trigger = _unk4 = 0;
+	_trigger = 0;
+	_scalingVelocity = false;
 	_spritesChanged = false;
 	_forceRefresh = false;
 	_highSprites = false;
@@ -66,7 +67,7 @@ Player::Player(MADSEngine *vm): _vm(vm) {
 	_trigger = 0;
 	_frameListIndex = 0;
 	_stopWalkerIndex = 0;
-	_hypotenuse = 0;
+	_totalDistance = 0;
 	
 	Common::fill(&_stopWalkerList[0], &_stopWalkerList[12], 0);
 	Common::fill(&_stopWalkerTrigger[0], &_stopWalkerTrigger[12], 0);
@@ -75,11 +76,11 @@ Player::Player(MADSEngine *vm): _vm(vm) {
 
 void Player::cancelWalk() {
 	_action = &_vm->_game->_scene._action;
-	_destPos = _playerPos;
+	_targetPos = _playerPos;
 	_targetFacing = FACING_NONE;
 	_turnToFacing = _facing;
 	_moving = false;
-	_newSceneId = _v844BE = 0;
+	_walkOffScreen = _walkOffScreenSceneId = 0;
 	_next = 0;
 	_routeCount = 0;
 	_walkAnywhere = false;
@@ -140,7 +141,7 @@ void Player::setFinalFacing() {
 		_turnToFacing = _targetFacing;
 }
 
-void Player::dirChanged() {
+void Player::changeFacing() {
 	int dirIndex = 0, dirIndex2 = 0;
 	int newDir = 0, newDir2 = 0;
 
@@ -308,7 +309,7 @@ void Player::update() {
 
 			// If changing a scene, check to change the scene when the player 
 			// has moved off-screen
-			if (_newSceneId) {
+			if (_walkOffScreen) {
 				SpriteAsset *asset = scene._sprites[slot._spritesIndex];
 				MSprite *frame = asset->getFrame(_frameNumber - 1);
 				int xScale = frame->w * newScale / 200;
@@ -318,8 +319,8 @@ void Player::update() {
 
 				if ((playerX + xScale) < 0 || (playerX + xScale) >= MADS_SCREEN_WIDTH ||
 						playerY < 0 || (playerY + yScale) >= MADS_SCENE_HEIGHT) {
-					scene._nextSceneId = _newSceneId;
-					_newSceneId = 0;
+					scene._nextSceneId = _walkOffScreen;
+					_walkOffScreen = 0;
 					_walkAnywhere = false;
 				}
 			}
@@ -398,31 +399,29 @@ void Player::nextFrame() {
 
 void Player::move() {
 	Scene &scene = _vm->_game->_scene;
-	bool routeFlag = false;
+	bool newFacing = false;
 
 	if (_moving) {
 		int idx = _routeCount;
-		while (!_newSceneId && (_destPos.x == _playerPos.x) && (_destPos.y == _playerPos.y)) {
+		while (!_walkOffScreen && _playerPos == _targetPos) {
 			if (idx != 0) {
 				--idx;
 				SceneNode &node = scene._sceneInfo->_nodes[_routeIndexes[idx]];
-				_destPos = node._walkPos;
-				routeFlag = true;
-			}
-			else if (_v844BE == idx) {
+				_targetPos = node._walkPos;
+				newFacing = true;
+			} else if (_walkOffScreenSceneId == idx) {
 				// End of walking path
 				_routeCount = 0;
 				_moving = false;
 				setFinalFacing();
-				routeFlag = true;
+				newFacing = true;
 				idx = _routeCount;
-			}
-			else {
-				_newSceneId = _v844BE;
-				_v844BC = true;
-				_v844BE = 0;
+			} else {
+				_walkOffScreen = _walkOffScreenSceneId;
+				_walkAnywhere = true;
+				_walkOffScreenSceneId = 0;
 				_stepEnabled = true;
-				routeFlag = false;
+				newFacing = false;
 			}
 
 			if (!_moving)
@@ -431,18 +430,19 @@ void Player::move() {
 		_routeCount = idx;
 	}
 
-	if (routeFlag && _moving)
+	if (newFacing && _moving)
 		startMovement();
 
 	if (_turnToFacing != _facing)
-		dirChanged();
+		changeFacing();
 	else if (!_moving)
 		updateFrame();
 
 	int velocity = _velocity;
-	if (_unk4 && (_hypotenuse > 0)) {
-		int v1 = -(_currentScale - 100) * (_posDiff.x - 1) / _hypotenuse + _currentScale;
-		velocity = MAX(1, 10000 / (v1 * _currentScale * velocity));
+	if (_scalingVelocity && (_totalDistance > 0)) {
+		int angleRange = 100 - _currentScale;
+		int angleScale = angleRange * (_posDiff.x - 1) / _totalDistance + _currentScale;
+		velocity = MAX(1, 10000 / (angleScale * _currentScale * velocity));
 	}
 
 	if (!_moving || (_facing != _turnToFacing))
@@ -450,46 +450,46 @@ void Player::move() {
 
 	Common::Point newPos = _playerPos;
 
-	if (_v8452E < velocity) {
+	if (_distAccum < velocity) {
 		do {
-			if (_v8452C < _posDiff.x)
-				_v8452C += _posDiff.y;
-			if (_v8452C >= _posDiff.x) {
-				if ((_posChange.y > 0) || (_newSceneId != 0))
+			if (_pixelAccum < _posDiff.x)
+				_pixelAccum += _posDiff.y;
+			if (_pixelAccum >= _posDiff.x) {
+				if ((_posChange.y > 0) || (_walkOffScreen != 0))
 					newPos.y += _yDirection;
 				--_posChange.y;
-				_v8452C -= _posDiff.x;
+				_pixelAccum -= _posDiff.x;
 			}
 
-			if (_v8452C < _posDiff.x) {
-				if ((_posChange.x > 0) || (_newSceneId != 0))
+			if (_pixelAccum < _posDiff.x) {
+				if ((_posChange.x > 0) || (_walkOffScreen != 0))
 					newPos.x += _xDirection;
 				--_posChange.x;
 			}
 
-			if ((_v844BC == 0) && (_newSceneId == 0) && (_v844BE == 0)) {
-				routeFlag = scene._depthSurface.getDepthHighBit(newPos);
+			if (!_walkAnywhere && !_walkOffScreen && (_walkOffScreenSceneId == 0)) {
+				newFacing = scene._depthSurface.getDepthHighBit(newPos);
 
 				if (_special == 0)
 					_special = scene.getDepthHighBits(newPos);
 			}
 
-			_v8452E += _v84530;
+			_distAccum += _deltaDistance;
 
-		} while ((_v8452E < velocity) && !routeFlag && ((_posChange.x > 0) || (_posChange.y > 0) || (_newSceneId != 0)));
+		} while ((_distAccum < velocity) && !newFacing && ((_posChange.x > 0) || (_posChange.y > 0) || (_walkOffScreen != 0)));
 	}
 
-	_v8452E -= velocity;
+	_distAccum -= velocity;
 
-	if (routeFlag)
+	if (newFacing) {
 		cancelCommand();
-	else {
-		if (!_newSceneId) {
+	} else {
+		if (!_walkOffScreen) {
 			// If the move is complete, make sure the position is exactly on the given destination
 			if (_posChange.x == 0)
-				newPos.x = _destPos.x;
+				newPos.x = _targetPos.x;
 			if (_posChange.y == 0)
-				newPos.y = _destPos.y;
+				newPos.y = _targetPos.y;
 		}
 
 		_playerPos = newPos;
@@ -501,7 +501,7 @@ void Player::idle() {
 
 	if (_facing != _turnToFacing) {
 		// The direction has changed, so reset for new direction
-		dirChanged();
+		changeFacing();
 		return;
 	}
 
@@ -675,10 +675,10 @@ int Player::scanPath(MSurface &depthSurface, const Common::Point &srcPos, const
 }
 
 void Player::startMovement() {
-	int xDiff = _destPos.x - _playerPos.x;
-	int yDiff = _destPos.y - _playerPos.y;
+	int xDiff = _targetPos.x - _playerPos.x;
+	int yDiff = _targetPos.y - _playerPos.y;
 	int srcScale = getScale(_playerPos.y);
-	int destScale = getScale(_destPos.y);
+	int destScale = getScale(_targetPos.y);
 
 	// Sets the X direction
 	if (xDiff > 0)
@@ -704,7 +704,7 @@ void Player::startMovement() {
 	int yAmt100 = yDiff * 100;
 	int xAmt33 = xDiff * 33;
 
-	int scaleAmount = (_unk4 ? scaleDiff * 3 : 0) + 100 * yDiff / 100;
+	int scaleAmount = (_scalingVelocity ? scaleDiff * 3 : 0) + 100 * yDiff / 100;
 	int scaleAmount100 = scaleAmount * 100;
 
 	// Figure out direction that will need to be moved in
@@ -739,22 +739,22 @@ void Player::startMovement() {
 		break;
 	}
 
-	_hypotenuse = sqrt((double)(xAmt100 * xAmt100 + yAmt100 * yAmt100));
+	_totalDistance = sqrt((double)(xAmt100 * xAmt100 + yAmt100 * yAmt100));
 	_posDiff.x = xDiff + 1;
 	_posDiff.y = yDiff + 1;
 	_posChange.x = xDiff;
 	_posChange.y = yDiff;
 
 	int majorChange = MAX(xDiff, yDiff);
-	_v84530 = (majorChange == 0) ? 0 : _hypotenuse / majorChange;
+	_deltaDistance = (majorChange == 0) ? 0 : _totalDistance / majorChange;
 
-	if (_playerPos.x > _destPos.x)
-		_v8452C = MAX(_posChange.x, _posChange.y);
+	if (_playerPos.x > _targetPos.x)
+		_pixelAccum = MAX(_posChange.x, _posChange.y);
 	else
-		_v8452C = 0;
+		_pixelAccum = 0;
 
-	_hypotenuse /= 100;
-	_v8452E = -_v84530;
+	_totalDistance /= 100;
+	_distAccum = -_deltaDistance;
 }
 
 void Player::step() {
diff --git a/engines/mads/player.h b/engines/mads/player.h
index eee1cee..6500806 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -54,18 +54,20 @@ private:
 	bool _mirror;
 	int _frameCount;
 	int _frameListIndex;
-	bool _v844BC;
-	int _v8452E;
-	int _v8452C;
-	int _v84530;
+	int _distAccum;
+	int _pixelAccum;
+	int _deltaDistance;
 	int _routeLength;
 	int _stopWalkerList[12];
 	int _stopWalkerTrigger[12];
 	int _stopWalkerIndex;
-	int _hypotenuse;
+	int _totalDistance;
 
 	void clearStopList();
 
+	/**
+	 * If the player is moving, handles figuring out the correct motion
+	 */
 	void move();
 
 	void postUpdate();
@@ -99,7 +101,7 @@ private:
 	*/
 	void startMovement();
 
-	void dirChanged();
+	void changeFacing();
 public:
 	MADSAction *_action;
 
@@ -121,11 +123,11 @@ public:
 	bool _loadsFirst;
 	bool _loadedFirst;
 	Common::Point _playerPos;
-	Common::Point _destPos;
+	Common::Point _targetPos;
 	Common::Point _posChange;
 	Common::Point _posDiff;
 	bool _moving;
-	int _newSceneId, _v844BE;
+	int _walkOffScreen, _walkOffScreenSceneId;
 	int _next;
 	int _special;
 	int _ticksAmount;
@@ -133,7 +135,7 @@ public:
 	int _velocity;
 	int _upcomingTrigger;
 	int _trigger;
-	bool _unk4;
+	bool _scalingVelocity;
 	bool _forceRefresh;
 	int _centerOfGravity;
 	int _currentDepth;


Commit: fac216be332ac1540d5ddcf0cffcc7ccf34c4a81
    https://github.com/scummvm/scummvm/commit/fac216be332ac1540d5ddcf0cffcc7ccf34c4a81
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-28T23:07:22-04:00

Commit Message:
MADS: Cleanup of Scene::checkStartWalk to become Player::newWalk

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/player.cpp
    engines/mads/player.h
    engines/mads/scene.cpp
    engines/mads/scene.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index e997261..fe90305 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -31,7 +31,6 @@ namespace MADS {
 
 MADSAction::MADSAction(MADSEngine *vm) : _vm(vm) {
 	clear();
-	_startWalkFlag = false;
 	_statusTextIndex = -1;
 	_selectedAction = 0;
 	_inProgress = false;
@@ -63,7 +62,6 @@ void MADSAction::clear() {
 	_action._objectNameId = -1;
 	_action._indirectObjectId = -1;
 	_textChanged = true;
-	_walkFlag = false;
 }
 
 void MADSAction::appendVocab(int vocabId, bool capitalise) {
@@ -77,10 +75,11 @@ void MADSAction::appendVocab(int vocabId, bool capitalise) {
 
 void MADSAction::checkCustomDest(int v) {
 	Scene &scene = _vm->_game->_scene;
+	Player &player = _vm->_game->_player;
 
 	if (_v86F4A && (v == -3 || _savedFields._selectedRow < 0)) {
-		_startWalkFlag = true;
-		scene._destPos = scene._customDest;
+		_vm->_game->_player._needToWalk = true;
+		player._prepareWalkPos = scene._customDest;
 	}
 }
 
@@ -265,11 +264,12 @@ void MADSAction::refresh() {
 
 void MADSAction::startAction() {
 	Game &game = *_vm->_game;
+	Player &player = game._player;
 	Scene &scene = _vm->_game->_scene;
 	DynamicHotspots &dynHotspots = scene._dynamicHotspots;
 	Hotspots &hotspots = scene._hotspots;
 
-	game._player.cancelCommand();
+	player.cancelCommand();
 
 	_inProgress = true;
 	_v8453A = ABORTMODE_0;
@@ -290,7 +290,7 @@ void MADSAction::startAction() {
 	if ((_actionMode2 == ACTIONMODE2_4) && (_v86F42 == 0))
 		_v8453A = -1;
 
-	_startWalkFlag = false;
+	player._needToWalk = false;
 	int hotspotId = -1;
 
 	if (!_savedFields._lookFlag && (_vm->_game->_screenObjects._v832EC != 1)) {
@@ -304,13 +304,13 @@ void MADSAction::startAction() {
 			if ((hs._feetPos.x == -1) || (hs._feetPos.x == -3)) {
 				checkCustomDest(hs._feetPos.x);
 			} else if (hs._feetPos.x == 0) {
-				scene._targetFacing = hs._facing;
+				player._prepareWalkFacing = hs._facing;
 			} else if (_savedFields._actionMode == ACTIONMODE_NONE || hs._cursor >= CURSOR_WAIT) {
-				_startWalkFlag = true;
-				scene._destPos = hs._feetPos;
+				player._needToWalk = true;
+				player._prepareWalkPos = hs._feetPos;
 			}
 
-			scene._targetFacing = hs._facing;
+			player._prepareWalkFacing = hs._facing;
 			hotspotId = -1;
 		}
 	}
@@ -322,20 +322,20 @@ void MADSAction::startAction() {
 			checkCustomDest(hs._feetPos.x);
 		} else if (hs._feetPos.x >= 0) {
 			if (_savedFields._actionMode == ACTIONMODE_NONE || hs._cursor < CURSOR_WAIT) {
-				_startWalkFlag = true;
-				scene._destPos = hs._feetPos;
+				player._needToWalk = true;
+				player._prepareWalkPos = hs._feetPos;
 			}
 		}
 
-		scene._targetFacing = hs._facing;
+		player._prepareWalkFacing = hs._facing;
 	}
 
-	_walkFlag = _startWalkFlag;
+	player._readyToWalk = player._needToWalk;
 }
 
 void MADSAction::checkAction() {
 	if (isAction(VERB_LOOK) || isAction(VERB_THROW))
-		_startWalkFlag = 0;
+		_vm->_game->_player._needToWalk = false;
 }
 
 bool MADSAction::isAction(int verbId, int objectNameId, int indirectObjectId) {
diff --git a/engines/mads/action.h b/engines/mads/action.h
index 74de167..a517a65 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -94,10 +94,8 @@ public:
 	int _selectedRow;
 	bool _textChanged;
 	int _selectedAction;
-	bool _startWalkFlag;
 	int _statusTextIndex;
 	int _hotspotId;
-	bool _walkFlag;
 	ActionSavedFields _savedFields;
 
 	// Unknown fields
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 96347ea..d90aa93 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -192,7 +192,7 @@ void Scene201::enter() {
 		_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_FRAME_INDEX, 12, 70);
 		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 1);
 		_pterodactylFlag = false;
-		_game._player.startWalking(Common::Point(157, 143), FACING_NORTH);
+		_game._player.walk(Common::Point(157, 143), FACING_NORTH);
 		_vm->_palette->setEntry(252, 45, 63, 45);
 		_vm->_palette->setEntry(253, 20, 45, 20);
 		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 2, 0, 120, _game.getQuote(90));
@@ -707,14 +707,16 @@ int Scene202::subStep4(int randVal) {
 }
 
 void Scene202::preActions() {
-	MADSAction *action = _game._player._action;
-	if (action->_walkFlag)
+	Player &player = _vm->_game->_player;
+	MADSAction *action = player._action;
+
+	if (player._readyToWalk)
 		_scene->_kernelMessages.reset();
 
-	if (!_ladderTopFl && (action->isAction(0x4E, 0xC7) || !action->_walkFlag)) {
+	if (!_ladderTopFl && (action->isAction(0x4E, 0xC7) || !player._readyToWalk)) {
 		if (_game._trigger == 0) {
 			_vm->_sound->command(29);
-			action->_walkFlag = false;
+			player._readyToWalk = false;
 			_game._player._stepEnabled = false;
 			_scene->_sequences.remove(_globals._spriteIndexes[24]);
 			_globals._spriteIndexes[23] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
@@ -724,20 +726,20 @@ void Scene202::preActions() {
 			_scene->_sequences.updateTimeout(-1, _globals._spriteIndexes[23]);
 			_scene->_dynamicHotspots.remove(_ladderHotspotId);
 			_game._player._visible = true;
-			action->_walkFlag = true;
+			player._readyToWalk = true;
 			_game._player._stepEnabled = true;
 			_ladderTopFl = false;
 		}		
 	}
 
 	if (action->isAction(0x3, 0x27) && action->_activeAction._indirectObjectId > 0) {
-		if (!action->_walkFlag || _ladderTopFl)
-			action->_startWalkFlag = false;
+		if (!player._readyToWalk || _ladderTopFl)
+			_game._player._needToWalk = false;
 		else
-			action->_startWalkFlag = true;
+			_game._player._needToWalk = true;
 
 		if (!_ladderTopFl)
-			_game._player.startWalking(Common::Point(171, 122), FACING_NORTH);
+			_game._player.walk(Common::Point(171, 122), FACING_NORTH);
 	}
 }
 
@@ -988,7 +990,7 @@ void Scene203::enter() {
 
 	if ((_globals[kRhotundaStatus] == 0) && (_scene->_roomChanged == 0)) {
 		_globals._v0 = -1;
-		_game._player.startWalking(Common::Point(158, 135), FACING_SOUTH);
+		_game._player.walk(Common::Point(158, 135), FACING_SOUTH);
 		int idx = _scene->_dynamicHotspots.add(131, 396, 0, Common::Rect(0, 0, 320, 156));
 		_scene->_dynamicHotspots.setPosition(idx, 155, 152, FACING_SOUTH);
 		_scene->_dynamicHotspots.setCursor(idx, CURSOR_GO_DOWN);
@@ -1041,7 +1043,7 @@ void Scene203::step() {
 
 void Scene203::preActions() {
 	if (_globals._v0 && !_action.isAction(0x18C, 0x83)) {
-		_game._player.startWalking(Common::Point(158, 136), FACING_SOUTH);
+		_game._player.walk(Common::Point(158, 136), FACING_SOUTH);
 		_action._inProgress = false;
 		return;
 	}
@@ -1476,14 +1478,16 @@ void Scene208::step() {
 }
 
 void Scene208::preActions() {
-	if (_action.isAction(3) && _action._walkFlag)
-		_action._startWalkFlag = true;
+	Player &player = _vm->_game->_player;
+
+	if (_action.isAction(3) && player._readyToWalk)
+		player._needToWalk = true;
 
 	if (_action.isAction(0x18C, 0x9B))
-		_game._player._walkOffScreenSceneId = 209;
+		player._walkOffScreenSceneId = 209;
 
 	if (_action.isAction(0x18C, 0xF6))
-		_game._player._walkOffScreenSceneId = 207;
+		player._walkOffScreenSceneId = 207;
 }
 
 void Scene208::actions() {
@@ -1510,7 +1514,7 @@ void Scene208::actions() {
 		if (_game._player._stepEnabled) {
 			_game._player._stepEnabled = false;
 			_globals._v0 = true;
-			_game._player.startWalking(Common::Point(20, 148), FACING_EAST);
+			_game._player.walk(Common::Point(20, 148), FACING_EAST);
 		}
 	} else if (_action.isAction(0x7, 0x35, 0x1A9)) {
 		warning("TODO: sub3B282(4);");
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index fe92f87..57726e7 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -37,6 +37,7 @@ Player::Player(MADSEngine *vm): _vm(vm) {
 	_facing = FACING_NORTH;
 	_turnToFacing = FACING_NORTH;
 	_targetFacing = FACING_NORTH;
+	_prepareWalkFacing = FACING_NONE;
 	_mirror = false;
 	_spritesLoaded = false;
 	_spritesStart = 0;
@@ -45,6 +46,8 @@ Player::Player(MADSEngine *vm): _vm(vm) {
 	_stepEnabled = false;
 	_visible = false;
 	_priorVisible = false;
+	_needToWalk = false;
+	_readyToWalk = false;
 	_visible3 = false;
 	_loadsFirst = false;
 	_loadedFirst = false;
@@ -85,8 +88,8 @@ void Player::cancelWalk() {
 	_routeCount = 0;
 	_walkAnywhere = false;
 
-	_action->_startWalkFlag = false;
-	_action->_walkFlag = false;
+	_needToWalk = false;
+	_readyToWalk = false;
 }
 
 bool Player::loadSprites(const Common::String &prefix) {
@@ -341,7 +344,7 @@ void Player::clearStopList() {
 	_trigger = 0;
 }
 
-void Player::setDest(const Common::Point &pt, Facing facing) {
+void Player::startWalking(const Common::Point &pt, Facing facing) {
 	Scene &scene = _vm->_game->_scene;
 
 	clearStopList();
@@ -370,14 +373,14 @@ void Player::setDest(const Common::Point &pt, Facing facing) {
 	}
 }
 
-void Player::startWalking(const Common::Point &pos, Facing direction) {
+void Player::walk(const Common::Point &pos, Facing facing) {
 	Scene &scene = _vm->_game->_scene;
 
 	cancelWalk();
-	scene._action._startWalkFlag = true;
-	scene._action._walkFlag = true;
-	scene._destPos = pos;
-	scene._targetFacing = direction;
+	_needToWalk = true;
+	_readyToWalk = true;
+	_prepareWalkPos = pos;
+	_prepareWalkFacing = facing;
 }
 
 void Player::nextFrame() {
@@ -392,7 +395,7 @@ void Player::nextFrame() {
 			idle();
 		}
 
-		postUpdate();
+		setFrame();
 		update();
 	}
 }
@@ -514,10 +517,10 @@ void Player::idle() {
 	int frameIndex = ABS(_frameListIndex);
 	int direction = (_frameListIndex < 0) ? -1 : 1;
 
-	if (frameIndex >= spriteSet._charInfo->_numEntries)
+	if (frameIndex >= spriteSet._charInfo->_numEntries) {
 		// Reset back to the start of the list
 		_frameListIndex = 0;
-	else {
+	}  else {
 		_frameNumber += direction;
 		_forceRefresh = true;
 
@@ -532,7 +535,7 @@ void Player::idle() {
 	}
 }
 
-void Player::postUpdate() {
+void Player::setFrame() {
 	if (_moving) {
 		if (++_frameNumber > _frameCount)
 			_frameNumber = 1;
@@ -757,6 +760,13 @@ void Player::startMovement() {
 	_distAccum = -_deltaDistance;
 }
 
+void Player::newWalk() {
+	if (_needToWalk && _readyToWalk) {
+		startWalking(_prepareWalkPos, _prepareWalkFacing);
+		_needToWalk = false;
+	}
+}
+
 void Player::step() {
 	warning("TODO: Player::step");
 }
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 6500806..2a92748 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -70,7 +70,10 @@ private:
 	 */
 	void move();
 
-	void postUpdate();
+	/**
+	 * Update the player's frame number
+	 */
+	void setFrame();
 
 	/**
 	 * Get the sprite slot index for the player
@@ -82,6 +85,9 @@ private:
 	 */
 	int getScale(int yp);
 
+	/**
+	 * Sets the frame rate for the current sprite set
+	 */
 	void setBaseFrameRate();
 
 	void setupRoute();
@@ -107,6 +113,7 @@ public:
 
 	Facing _facing;
 	Facing _turnToFacing;
+	Facing _prepareWalkFacing;
 	int _xDirection, _yDirection;
 	Facing _targetFacing;
 	bool _spritesLoaded;
@@ -126,6 +133,7 @@ public:
 	Common::Point _targetPos;
 	Common::Point _posChange;
 	Common::Point _posDiff;
+	Common::Point _prepareWalkPos;
 	bool _moving;
 	int _walkOffScreen, _walkOffScreenSceneId;
 	int _next;
@@ -137,6 +145,8 @@ public:
 	int _trigger;
 	bool _scalingVelocity;
 	bool _forceRefresh;
+	bool _needToWalk;
+	bool _readyToWalk;
 	int _centerOfGravity;
 	int _currentDepth;
 	int _currentScale;
@@ -181,11 +191,30 @@ public:
 
 	void update();
 
+	/**
+	 * Handler method for when the player is not moving
+	 */
 	void idle();
 
-	void setDest(const Common::Point &pt, Facing facing);
+	/**
+	 * Starts the player walking towards a given point and direction facing
+	 * @param pos		Destination location
+	 * @param facing	Direction to face once the destination is reached
+	 */
+	void startWalking(const Common::Point &pt, Facing facing);
+
+	/**
+	 * Used by the game scripst to make the player walk to a given destination.
+	 * The difference from startWalking is that this contains several extra
+	 * layers of checking that startWalking bypasses.
+	 */
+	void walk(const Common::Point &pos, Facing facing);
 
-	void startWalking(const Common::Point &pos, Facing direction);
+	/**
+	 * If a new walk sequence is pending, and has been okayed by the preparser,
+	 * start the actual walking
+	 */
+	void newWalk();
 
 	void nextFrame();
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 6270251..2e78811 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -42,7 +42,6 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 	_depthStyle = 0;
 	_roomChanged = false;
 	_reloadSceneFlag = false;
-	_targetFacing = FACING_NONE;
 	_freeAnimationFlag = false;
 	_animationData = nullptr;
 	_activeAnimation = nullptr;
@@ -296,11 +295,11 @@ void Scene::doFrame() {
 			_dynamicHotspots.refresh();
 
 		// Check all on-screen visual objects
-		_vm->_game->_screenObjects.check(player._stepEnabled && !_action._startWalkFlag &&
+		_vm->_game->_screenObjects.check(player._stepEnabled && !player._needToWalk &&
 				!_vm->_game->_fx);
 	}
 
-	if (_action._selectedAction && player._stepEnabled && !_action._startWalkFlag &&
+	if (_action._selectedAction && player._stepEnabled && !player._needToWalk &&
 			!_vm->_game->_trigger && !player._trigger) {
 		_action.startAction();
 		if (_action._activeAction._verbId == Nebular::NOUN_LOOK_AT) {
@@ -315,11 +314,11 @@ void Scene::doFrame() {
 		doPreactions();
 	}
 
-	checkStartWalk();
+	player.newWalk();
 	if (!_vm->_game->_fx)
 		_frameStartTime = _vm->_events->getFrameCounter();
 
-	if ((_action._inProgress && !player._moving && !_action._startWalkFlag &&
+	if ((_action._inProgress && !player._moving && !player._needToWalk &&
 			player._turnToFacing == player._facing) ||
 			(_vm->_game->_trigger && _vm->_game->_abortTimersMode == ABORTMODE_0)) {
 		doAction();
@@ -499,13 +498,6 @@ void Scene::doAction() {
 		_vm->_game->_trigger = 0;
 }
 
-void Scene::checkStartWalk() {
-	if (_action._startWalkFlag && _action._walkFlag) {
-		_vm->_game->_player.setDest(_destPos, _targetFacing);
-		_action._startWalkFlag = false;
-	}
-}
-
 void Scene::doSceneStep() {
 	_vm->_game->_abortTimersMode2 = ABORTMODE_1;
 	_sceneLogic->step();
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index ee1a0c7..0af5fa6 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -65,8 +65,6 @@ private:
 
 	void doAction();
 
-	void checkStartWalk();
-
 	void doSceneStep();
 
 	void checkKeyboard();
@@ -118,8 +116,6 @@ public:
 	MADSAction _action;
 	bool _roomChanged;
 	bool _reloadSceneFlag;
-	Common::Point _destPos;
-	Facing _targetFacing;
 	Common::Point _posAdjust;
 	uint32 _frameStartTime;
 	Layer _layer;


Commit: f983add480db83a47ccdf2a860d5c9c1fbc664a2
    https://github.com/scummvm/scummvm/commit/f983add480db83a47ccdf2a860d5c9c1fbc664a2
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-29T08:44:17+01:00

Commit Message:
MADS: Replace some magic values by enums

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 48e9b4b..51a2d95 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -440,11 +440,11 @@ void Scene103::actions() {
 }
 
 void Scene103::postActions() {
-	if (_action.isAction(27) && !_action.isAction(13)) {
+	if (_action.isAction(27) && !_action.isAction(VERB_WALKTO)) {
 		_vm->_dialogs->show(0x2841);
 		_action._inProgress = false;
 	} else {
-		if (_action.isAction(7, 85, 144)) {
+		if (_action.isAction(VERB_PUT, 85, 144)) {
 			Common::String msg = _game.getQuote(73);
 			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110,
 				34, 0, 120, msg);
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index d90aa93..2f81b78 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -293,30 +293,30 @@ void Scene201::actions() {
 			} else if (_game._trigger == 1) {
 				_scene->_nextSceneId = 213;
 			}
-		} else if (action->isAction(0x3, 0x1A6)) {
+		} else if (action->isAction(VERB_LOOK, 0x1A6)) {
 			_vm->_dialogs->show(0x4E85);
-		} else if (action->isAction(0x3, 0x129)) {
+		} else if (action->isAction(VERB_LOOK, 0x129)) {
 			_vm->_dialogs->show(0x4E86);
-		} else if (action->isAction(0x3, 0x16F)) {
+		} else if (action->isAction(VERB_LOOK, 0x16F)) {
 			_vm->_dialogs->show(0x4E87);
-		} else if (action->isAction(0x3, 0x142)) {
+		} else if (action->isAction(VERB_LOOK, 0x142)) {
 			_vm->_dialogs->show(0x4E88);
-		} else if (action->isAction(0x3, 0x18F)) {
+		} else if (action->isAction(VERB_LOOK, 0x18F)) {
 			_vm->_dialogs->show(0x4E89);
-		} else if (action->isAction(0x3, 0x1B9)) {
+		} else if (action->isAction(VERB_LOOK, 0x1B9)) {
 			_vm->_dialogs->show(0x4E8A);
-		} else if (action->isAction(0x3, 0x192)) {
+		} else if (action->isAction(VERB_LOOK, 0x192)) {
 			_vm->_dialogs->show(0x4E8B);
-		} else if (action->isAction(0x3, 0x1BA)) {
+		} else if (action->isAction(VERB_LOOK, 0x1BA)) {
 			_vm->_dialogs->show(0x4E8C);
-		} else if (action->isAction(0x3, 0x83)) {
+		} else if (action->isAction(VERB_LOOK, 0x83)) {
 			_vm->_dialogs->show(0x4E8E);
-		} else if (action->isAction(0x3, 0x1B6)) {
+		} else if (action->isAction(VERB_LOOK, 0x1B6)) {
 			if (_globals[kMeteorologistEverSeen])
 				_vm->_dialogs->show(0x4E90);
 			else
 				_vm->_dialogs->show(0x4E8D);
-		} else if (action->isAction(0x3, 0x16C)) {
+		} else if (action->isAction(VERB_LOOK, 0x16C)) {
 			_vm->_dialogs->show(0x4E91);
 		} else
 			return;
@@ -732,7 +732,7 @@ void Scene202::preActions() {
 		}		
 	}
 
-	if (action->isAction(0x3, 0x27) && action->_activeAction._indirectObjectId > 0) {
+	if (action->isAction(VERB_LOOK, 0x27) && action->_activeAction._indirectObjectId > 0) {
 		if (!player._readyToWalk || _ladderTopFl)
 			_game._player._needToWalk = false;
 		else
@@ -759,7 +759,7 @@ void Scene202::actions() {
 					_globals[kMeteorologistStatus] = 0;
 			}
 			_scene->_nextSceneId = 201;
-		} else if (action->isAction(0x4, 0x2C)) {
+		} else if (action->isAction(VERB_TAKE, 0x2C)) {
 			if (action->_actionMode2 == 4) {
 				if (_game._trigger == 0) {
 					if (_game._objects.isInInventory(OBJ_BONES)) {
@@ -822,7 +822,7 @@ void Scene202::actions() {
 				action->_inProgress = false;
 				return;
 			}
-		} else if (((action->isAction(0x3, 0x27, 0x82)) || (action->isAction(0x3, 0x27, 0x1B6))) && (_globals[kSexOfRex] == SEX_MALE)) {
+		} else if (((action->isAction(VERB_LOOK, 0x27, 0x82)) || (action->isAction(VERB_LOOK, 0x27, 0x1B6))) && (_globals[kSexOfRex] == SEX_MALE)) {
 			if (!_ladderTopFl) {
 				if (_game._trigger == 0) {
 					_game._player._stepEnabled = false;
@@ -913,13 +913,13 @@ void Scene202::actions() {
 			}
 		} else if (action->isAction(0x188, 0xAA)) {
 			setRandomKernelMessage();
-		} else if (action->isAction(0x3, 0x129)) {
+		} else if (action->isAction(VERB_LOOK, 0x129)) {
 			_vm->_dialogs->show(0x4EEA);
-		} else if (action->isAction(0x3, 0x86)) {
+		} else if (action->isAction(VERB_LOOK, 0x86)) {
 			_vm->_dialogs->show(0x4EEB);
-		} else if (action->isAction(0x3, 0x19C)) {
+		} else if (action->isAction(VERB_LOOK, 0x19C)) {
 			_vm->_dialogs->show(0x4EEC);
-		} else if (action->isAction(0x3, 0x82)) {
+		} else if (action->isAction(VERB_LOOK, 0x82)) {
 			if ((_globals[kMeteorologistStatus] == 0) || (_globals[kMeteorologistStatus] == 2)) {
 				_vm->_dialogs->show(0x4EED);
 			} else if (_globals[kMeteorologistStatus] == 1) {
@@ -928,30 +928,30 @@ void Scene202::actions() {
 				action->_inProgress = false;
 				return;
 			} 
-		} else if (action->isAction(0x3, 0x18E)) {
+		} else if (action->isAction(VERB_LOOK, 0x18E)) {
 			_vm->_dialogs->show(0x4EEE);
-		} else if (action->isAction(0x3, 0x164)) {
+		} else if (action->isAction(VERB_LOOK, 0x164)) {
 			_vm->_dialogs->show(0x4EEF);
-		} else if (action->isAction(0x3, 0x175)) {
+		} else if (action->isAction(VERB_LOOK, 0x175)) {
 			_vm->_dialogs->show(0x4EF0);
-		} else if (action->isAction(0x3, 0x174)) {
+		} else if (action->isAction(VERB_LOOK, 0x174)) {
 			_vm->_dialogs->show(0x4EF1);
-		} else if (action->isAction(0x3, 0x142)) {
+		} else if (action->isAction(VERB_LOOK, 0x142)) {
 			_vm->_dialogs->show(0x4EF2);
-		} else if (action->isAction(0x3, 0xAA)) {
+		} else if (action->isAction(VERB_LOOK, 0xAA)) {
 			if ((_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == 8))
 				_vm->_dialogs->show(0x4EF4);
 			else
 				_vm->_dialogs->show(0x4EF3);
-		} else if (action->isAction(0x3, 0x186)) {
+		} else if (action->isAction(VERB_LOOK, 0x186)) {
 			_vm->_dialogs->show(0x4EF5);
-		} else if (action->isAction(0x3, 0x1B5)) {
+		} else if (action->isAction(VERB_LOOK, 0x1B5)) {
 			_vm->_dialogs->show(0x4EF6);
-		} else if (action->isAction(0x3, 0x140)) {
+		} else if (action->isAction(VERB_LOOK, 0x140)) {
 			_vm->_dialogs->show(0x4EF7);
-		} else if (action->isAction(0x4, 0x140)) {
+		} else if (action->isAction(VERB_TAKE, 0x140)) {
 			_vm->_dialogs->show(0x4EF8);
-		} else if (action->isAction(0x3, 0x2D)) {
+		} else if (action->isAction(VERB_LOOK, 0x2D)) {
 			if (action->_actionMode == 4)
 				_vm->_dialogs->show(0x4EF9);
 			else
@@ -1048,7 +1048,7 @@ void Scene203::preActions() {
 		return;
 	}
 
-	if (_action.isAction(0xD, 0xF3))
+	if (_action.isAction(VERB_WALKTO, 0xF3))
 		_game._player._walkOffScreenSceneId = 209;
 }
 
@@ -1059,17 +1059,17 @@ void Scene203::actions() {
 		_scene->_nextSceneId = 208;
 	} else if (_action.isAction(0x18C, 0x82)) {
 		_scene->_nextSceneId = 202;
-	} else if (_action.isAction(0x3, 0x142)) {
+	} else if (_action.isAction(VERB_LOOK, 0x142)) {
 		_vm->_dialogs->show(0x4F4D);
-	} else if (_action.isAction(0x3, 0x4D)) {
+	} else if (_action.isAction(VERB_LOOK, 0x4D)) {
 		_vm->_dialogs->show(0x4F4E);
-	} else if (_action.isAction(0x3, 0x100)) {
+	} else if (_action.isAction(VERB_LOOK, 0x100)) {
 		_vm->_dialogs->show(0x4F4F);
-	} else if (_action.isAction(0x3, 0x82)) {
+	} else if (_action.isAction(VERB_LOOK, 0x82)) {
 		_vm->_dialogs->show(0x4F50);
-	} else if (_action.isAction(0x3, 0x1A6)) {
+	} else if (_action.isAction(VERB_LOOK, 0x1A6)) {
 		_vm->_dialogs->show(0x4F51);
-	} else if (_action.isAction(0x3, 0x30)) {
+	} else if (_action.isAction(VERB_LOOK, 0x30)) {
 		_vm->_dialogs->show(0x4F51);
 	} else
 		return;
@@ -1319,7 +1319,7 @@ void Scene207::preActions() {
 	if (_action.isAction(0x18C, 0x1AB))
 		_game._player._walkOffScreenSceneId = 208;
 
-	if ((_action.isAction(0xD)) || (_action.isAction(0x3))) {
+	if ((_action.isAction(VERB_WALKTO)) || (_action.isAction(VERB_LOOK))) {
 		if (_action.isAction(0x185)) {
 			_globals._frameTime = 0xD8F1;
 			_globals._frameTime |= 0xFFFF0000;
@@ -1352,33 +1352,33 @@ void Scene207::actions() {
 				_globals._v2 = 0;
 			}
 
-			if (_action.isAction(3, 0x69)) {
+			if (_action.isAction(VERB_LOOK, 0x69)) {
 				_vm->_dialogs->show(0x50DD);
-			} else if (_action.isAction(3, 0x1AF)) {
+			} else if (_action.isAction(VERB_LOOK, 0x1AF)) {
 				_vm->_dialogs->show(0x50DE);
-			} else if (_action.isAction(3, 0x141)) {
+			} else if (_action.isAction(VERB_LOOK, 0x141)) {
 				_vm->_dialogs->show(0x50DF);
-			} else if (_action.isAction(3, 0x3E)) {
+			} else if (_action.isAction(VERB_LOOK, 0x3E)) {
 				_vm->_dialogs->show(0x50E0);
-			} else if (_action.isAction(3, 0x198)) {
+			} else if (_action.isAction(VERB_LOOK, 0x198)) {
 				_vm->_dialogs->show(0x50E1);
-			} else if (_action.isAction(3, 0x1AE)) {
+			} else if (_action.isAction(VERB_LOOK, 0x1AE)) {
 				_vm->_dialogs->show(0x50E2);
-			} else if (_action.isAction(3, 0xE8)) {
+			} else if (_action.isAction(VERB_LOOK, 0xE8)) {
 				_vm->_dialogs->show(0x50E3);
-			} else if (_action.isAction(3, 0x12)) {
+			} else if (_action.isAction(VERB_LOOK, 0x12)) {
 				_vm->_dialogs->show(0x50E4);
-			} else if (_action.isAction(3, 0x1AC)) {
+			} else if (_action.isAction(VERB_LOOK, 0x1AC)) {
 				_vm->_dialogs->show(0x50E5);
-			} else if (_action.isAction(3, 0x185)) {
+			} else if (_action.isAction(VERB_LOOK, 0x185)) {
 				_vm->_dialogs->show(0x50E6);
-			} else if (_action.isAction(4, 0x141)) {
+			} else if (_action.isAction(VERB_TAKE, 0x141)) {
 				_vm->_dialogs->show(0x50E8);
-			} else if (_action.isAction(4, 0x12)) {
+			} else if (_action.isAction(VERB_TAKE, 0x12)) {
 				_vm->_dialogs->show(0x50E9);
-			} else if (_action.isAction(3, 0x14D)) {
+			} else if (_action.isAction(VERB_LOOK, 0x14D)) {
 				_vm->_dialogs->show(0x50EA);
-			} else if (_action.isAction(4, 0x14D)) {
+			} else if (_action.isAction(VERB_TAKE, 0x14D)) {
 				_vm->_dialogs->show(0x50EB);
 			} else
 				return;
@@ -1480,7 +1480,7 @@ void Scene208::step() {
 void Scene208::preActions() {
 	Player &player = _vm->_game->_player;
 
-	if (_action.isAction(3) && player._readyToWalk)
+	if (_action.isAction(VERB_LOOK) && player._readyToWalk)
 		player._needToWalk = true;
 
 	if (_action.isAction(0x18C, 0x9B))
@@ -1503,59 +1503,59 @@ void Scene208::actions() {
 		}
 	} else if (_action.isAction(0x18C, 0x83)) {
 		_scene->_nextSceneId = 212;
-	} else if (_action.isAction(0x4, 0x1AA) && (!_globals[kLeavesStatus] || _game._trigger)) {
+	} else if (_action.isAction(VERB_TAKE, 0x1AA) && (!_globals[kLeavesStatus] || _game._trigger)) {
 		warning("TODO: sub3B282(1);");
 		if (_game._player._stepEnabled)
 			_vm->_dialogs->showPicture(OBJ_BIG_LEAVES, 0x326, 0);
-	} else if (_action.isAction(0x7, 0x23, 0x19E) && (_globals[kLeavesStatus] == 1 || _game._trigger)) {
+	} else if (_action.isAction(VERB_PUT, 0x23, 0x19E) && (_globals[kLeavesStatus] == 1 || _game._trigger)) {
 		warning("TODO: sub3B282(2);");
-	} else if (_action.isAction(0x7, 0x17A, 0x1A9)) {
+	} else if (_action.isAction(VERB_PUT, 0x17A, 0x1A9)) {
 		warning("TODO: sub3B282(3);");
 		if (_game._player._stepEnabled) {
 			_game._player._stepEnabled = false;
 			_globals._v0 = true;
 			_game._player.walk(Common::Point(20, 148), FACING_EAST);
 		}
-	} else if (_action.isAction(0x7, 0x35, 0x1A9)) {
+	} else if (_action.isAction(VERB_PUT, 0x35, 0x1A9)) {
 		warning("TODO: sub3B282(4);");
 		if (_game._player._stepEnabled) {
 			_vm->_dialogs->show(0x514C);
 		}
-	} else if (_action.isAction(0x7, 0x65, 0x1A9)) {
+	} else if (_action.isAction(VERB_PUT, 0x65, 0x1A9)) {
 		warning("TODO: sub3B282(5);");
 		if (_game._player._stepEnabled) {
 			_vm->_dialogs->show(0x514C);
 		}
-	} else if (_action.isAction(0x3, 0x5D)) {
+	} else if (_action.isAction(VERB_LOOK, 0x5D)) {
 		_vm->_dialogs->show(0x5141);
-	} else if (_action.isAction(0x3, 0xF6)) {
+	} else if (_action.isAction(VERB_LOOK, 0xF6)) {
 		_vm->_dialogs->show(0x5142);
-	} else if (_action.isAction(0x3, 0x16F)) {
+	} else if (_action.isAction(VERB_LOOK, 0x16F)) {
 		_vm->_dialogs->show(0x5143);
-	} else if (_action.isAction(0x3, 0x129)) {
+	} else if (_action.isAction(VERB_LOOK, 0x129)) {
 		_vm->_dialogs->show(0x5144);
-	} else if (_action.isAction(0x3, 0x1A1)) {
+	} else if (_action.isAction(VERB_LOOK, 0x1A1)) {
 		_vm->_dialogs->show(0x5145);
-	} else if (_action.isAction(0x4, 0x1A1)) {
+	} else if (_action.isAction(VERB_TAKE, 0x1A1)) {
 		_vm->_dialogs->show(0x5146);
-	} else if (_action.isAction(0x3, 0x9B)) {
+	} else if (_action.isAction(VERB_LOOK, 0x9B)) {
 		_vm->_dialogs->show(0x5147);
-	} else if (_action.isAction(0x3, 0x19E)) {
+	} else if (_action.isAction(VERB_LOOK, 0x19E)) {
 		_vm->_dialogs->show(0x5148);
-	} else if (_action.isAction(0x3, 0x1AA)) {
+	} else if (_action.isAction(VERB_LOOK, 0x1AA)) {
 		_vm->_dialogs->show(0x5149);
-	} else if (_action.isAction(0x3, 0x1A9)) {
+	} else if (_action.isAction(VERB_LOOK, 0x1A9)) {
 		if (_game._difficulty == DIFFICULTY_IMPOSSIBLE)
 			_vm->_dialogs->show(0x514A);
 		else
 			_vm->_dialogs->show(0x514B);
-	} else if (_action.isAction(0x3, 0x174) || _action.isAction(0x3, 0x175)) {
+	} else if (_action.isAction(VERB_LOOK, 0x174) || _action.isAction(VERB_LOOK, 0x175)) {
 		_vm->_dialogs->show(0x514D);
-	} else if (_action.isAction(0x4, 0x1A9)) {
+	} else if (_action.isAction(VERB_TAKE, 0x1A9)) {
 		_vm->_dialogs->show(0x514E);
-	} else if (_action.isAction(0x3, 0x1A8)) {
+	} else if (_action.isAction(VERB_LOOK, 0x1A8)) {
 		_vm->_dialogs->show(0x514F);
-	} else if (_action.isAction(0x4, 0x1A8) || _action.isAction(0xA, 0x1A8)) {
+	} else if (_action.isAction(VERB_TAKE, 0x1A8) || _action.isAction(0xA, 0x1A8)) {
 		_vm->_dialogs->show(0x5150);
 	} else if (_action._savedFields._lookFlag == 0) {
 		return;


Commit: e8de00f8770ab43259176400a9245006bc3b327a
    https://github.com/scummvm/scummvm/commit/e8de00f8770ab43259176400a9245006bc3b327a
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-29T08:54:25+01:00

Commit Message:
MADS: Some more renaming in scene 202

Changed paths:
    engines/mads/nebular/globals_nebular.cpp
    engines/mads/nebular/globals_nebular.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp
index e2886ee..80e8ded 100644
--- a/engines/mads/nebular/globals_nebular.cpp
+++ b/engines/mads/nebular/globals_nebular.cpp
@@ -47,7 +47,6 @@ Globals::Globals() {
 	_v8 = 0;
 	_abortVal = 0;
 	_v8425C = 0;
-	_v84260 = 0;
 	_v84262 = 0;
 	_v84264 = 0;
 	_v84266 = 0;
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index eebbd8e..992e00a 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -295,7 +295,7 @@ public:
 	int _v8;
 	int _abortVal;
 	uint32 _v8425C;
-	int _v84260, _v84262, _v84264, _v84266, _v84268;
+	int _v84262, _v84264, _v84266, _v84268;
 public:
 	/**
 	 * Constructor
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 2f81b78..ed43275 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -580,7 +580,7 @@ void Scene202::step() {
 			}
 		}
 
-		if ((_scene->_activeAnimation->getCurrentFrame() == 160) && (_globals._v84260 != _scene->_activeAnimation->getCurrentFrame())) {
+		if ((_scene->_activeAnimation->getCurrentFrame() == 160) && (_meteoFrame != _scene->_activeAnimation->getCurrentFrame())) {
 			Common::Point msgPos;
 			int msgFlag;
 			if (!_ladderTopFl) {
@@ -599,11 +599,11 @@ void Scene202::step() {
 		_toTeleportFl = true;
 	}
 
-	if (_scene->_activeAnimation->getCurrentFrame() == _globals._v84260) {
+	if (_scene->_activeAnimation->getCurrentFrame() == _meteoFrame) {
 		return;
 	}
 	
-	_globals._v84260 = _scene->_activeAnimation->getCurrentFrame();
+	_meteoFrame = _scene->_activeAnimation->getCurrentFrame();
 	int randVal = _vm->getRandomNumber(1, 1000);
 	int frameStep = -1;
 	
@@ -649,7 +649,7 @@ void Scene202::step() {
 	int nextFrame = 1 + _scene->_activeAnimation->getCurrentFrame() - frameStep;
 	if (nextFrame) {
 		_scene->_activeAnimation->setCurrentFrame(nextFrame);
-		_globals._v84260 = nextFrame;
+		_meteoFrame = nextFrame;
 	}
 }
 
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 143b24c..0f247f3 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -64,7 +64,7 @@ public:
 class Scene202: public Scene2xx {
 private:
 	bool _activeMsgFl, _ladderTopFl, _waitingMeteoFl, _toStationFl, _toTeleportFl;
-	int _ladderHotspotId, _lastRoute, _stationCounter;
+	int _ladderHotspotId, _lastRoute, _stationCounter, _meteoFrame;
 	uint32 _meteoClock1, _meteoClock2, _startTime;
 
 	int subStep1(int randVal);
@@ -75,7 +75,7 @@ private:
 public:
 	Scene202(MADSEngine *vm) : Scene2xx(vm), _activeMsgFl(false), _ladderTopFl(false), _waitingMeteoFl(false),
 		_ladderHotspotId(-1), _meteoClock1(0), _meteoClock2(0), _toStationFl(false), _toTeleportFl(false),
-		_lastRoute(0), _stationCounter(0) {}
+		_lastRoute(0), _stationCounter(0), _meteoFrame(0) {}
 	virtual void setup();
 	virtual void enter();
 	virtual void step();


Commit: d801c2ffdd1b2e5cfefcea18309a4779e0a824a1
    https://github.com/scummvm/scummvm/commit/d801c2ffdd1b2e5cfefcea18309a4779e0a824a1
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-29T09:41:55+01:00

Commit Message:
MADS: Implement palette::lock() and unlock(), get rid of some magic values in scene 202 and 203, some renaming

Changed paths:
    engines/mads/game.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index a1ca02c..faa2bfa 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -142,6 +142,7 @@ void Game::gameLoop() {
 		}
 
 		// TODO: Extra reset methods
+		_vm->_palette->unlock();
 		_vm->_events->waitCursor();
 		_vm->_events->freeCursors();
 		_vm->_sound->closeDriver();
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index ed43275..99c6cf4 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -464,7 +464,7 @@ void Scene202::setRandomKernelMessage() {
 }
 
 void Scene202::step() {
-	if (!_activeMsgFl && (_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == 8) && (_vm->getRandomNumber(999) == 0)) {
+	if (!_activeMsgFl && (_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == FACING_NORTH) && (_vm->getRandomNumber(999) == 0)) {
 		_scene->_kernelMessages.reset();
 		_activeMsgFl = false;
 		if (_vm->getRandomNumber(4) == 0)
@@ -939,7 +939,7 @@ void Scene202::actions() {
 		} else if (action->isAction(VERB_LOOK, 0x142)) {
 			_vm->_dialogs->show(0x4EF2);
 		} else if (action->isAction(VERB_LOOK, 0xAA)) {
-			if ((_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == 8))
+			if ((_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == FACING_NORTH))
 				_vm->_dialogs->show(0x4EF4);
 			else
 				_vm->_dialogs->show(0x4EF3);
@@ -980,23 +980,23 @@ void Scene203::enter() {
 	} else if (_scene->_priorSceneId == 209) {
 		_game._player._playerPos = Common::Point(308, 117);
 		_game._player._facing = FACING_WEST;
-	} else if (_scene->_priorSceneId == -2) {
+	} else if (_scene->_priorSceneId != -2) {
 		_game._player._playerPos = Common::Point(155, 152);
 		_game._player._facing = FACING_NORTH;
 	}
 
-	_globals._v0 = 0;
-	_globals._frameTime = 0;
+	_rhotundaEatFl = false;
+	_rhotundaEat2Fl = false;
 
-	if ((_globals[kRhotundaStatus] == 0) && (_scene->_roomChanged == 0)) {
-		_globals._v0 = -1;
+	if ((_globals[kRhotundaStatus] == 0) && (!_scene->_roomChanged)) {
+		_rhotundaEatFl = true;
 		_game._player.walk(Common::Point(158, 135), FACING_SOUTH);
 		int idx = _scene->_dynamicHotspots.add(131, 396, 0, Common::Rect(0, 0, 320, 156));
 		_scene->_dynamicHotspots.setPosition(idx, 155, 152, FACING_SOUTH);
 		_scene->_dynamicHotspots.setCursor(idx, CURSOR_GO_DOWN);
 	}
 
-	if (_globals._v0 == 0) {
+	if (!_rhotundaEatFl) {
 		_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('b', -1), 0);
 		if (_vm->getRandomNumber(1, 3) == 2) {
 			_globals._spriteIndexes[15] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 9, 1, 0, 0);
@@ -1008,7 +1008,7 @@ void Scene203::enter() {
 
 	_game.loadQuoteSet(0x67, 0x68, 0x69, 0x6A, 0x5A, 0);
 
-	if (_globals._v0 != 0) {
+	if (_rhotundaEatFl) {
 		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(_vm->getRandomNumber(103, 106)));
 	}
 
@@ -1016,21 +1016,21 @@ void Scene203::enter() {
 }
 
 void Scene203::step() {
-	if (_globals._v0 == 0)
+	if (!_rhotundaEatFl)
 		return;
 
-	if ((_game._trigger == 0) && (_globals._frameTime != 0))
+	if ((_game._trigger == 0) && _rhotundaEat2Fl)
 		return;
 
-	if ((_game._player._playerPos != Common::Point(158, 136)) || (_game._player._facing != 2))
+	if ((_game._player._playerPos != Common::Point(158, 136)) || (_game._player._facing != FACING_SOUTH))
 		return;
 
-	_globals._frameTime = 0xFFFF;
+	_rhotundaEat2Fl = true;
 
 	if (_game._trigger == 0) {
 		_game._player._visible = false;
 		_game._player._stepEnabled = false;
-		_vm->_palette->sub7BBF8();
+		_vm->_palette->lock();
 		_scene->_kernelMessages.reset();
 		_scene->resetScene();
 		_vm->_events->setCursor2(CURSOR_WAIT);
@@ -1042,7 +1042,7 @@ void Scene203::step() {
 }
 
 void Scene203::preActions() {
-	if (_globals._v0 && !_action.isAction(0x18C, 0x83)) {
+	if (_rhotundaEatFl && !_action.isAction(0x18C, 0x83)) {
 		_game._player.walk(Common::Point(158, 136), FACING_SOUTH);
 		_action._inProgress = false;
 		return;
@@ -1449,7 +1449,7 @@ void Scene208::step() {
 	if (_globals._v0 == 0)
 		return;
 
-	if ((_game._player._playerPos != Common::Point(20, 148)) || (_game._player._facing != 6))
+	if ((_game._player._playerPos != Common::Point(20, 148)) || (_game._player._facing != FACING_EAST))
 		return;
 
 	if ((_game._trigger == 0) && ((_globals._frameTime & 0xFFFF) != 0))
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 0f247f3..44ee528 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -87,8 +87,10 @@ public:
 };
 
 class Scene203: public Scene2xx {
+private:
+	bool _rhotundaEat2Fl, _rhotundaEatFl;
 public:
-	Scene203(MADSEngine *vm) : Scene2xx(vm) {}
+	Scene203(MADSEngine *vm) : Scene2xx(vm), _rhotundaEat2Fl(false), _rhotundaEatFl(false) {}
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 311bd63..34ba0ac 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -235,7 +235,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 		palette[palIndex]._palIndex = var4;
 	}
 
-	_vm->_palette->_rgbList[rgbIndex] = -1;
+	_vm->_palette->_rgbList[rgbIndex] = true;
 
 	return rgbIndex;
 }
@@ -263,7 +263,7 @@ void PaletteUsage::updateUsage(Common::Array<int> &usageList, int sceneUsageInde
 		uint32 bitMask = 1 << usageList[idx];
 		mask1 ^= bitMask;
 		mask2 |= bitMask;
-		_vm->_palette->_rgbList[usageList[idx]] = 0;
+		_vm->_palette->_rgbList[usageList[idx]] = false;
 	}
 
 	uint32 mask3 = 1 << sceneUsageIndex;
@@ -276,7 +276,7 @@ void PaletteUsage::updateUsage(Common::Array<int> &usageList, int sceneUsageInde
 		}
 	}
 
-	_vm->_palette->_rgbList[sceneUsageIndex] = -1;
+	_vm->_palette->_rgbList[sceneUsageIndex] = true;
 }
 
 int PaletteUsage::getGamePalFreeIndex(int *palIndex) {
@@ -306,11 +306,13 @@ int PaletteUsage::rgbFactor(byte *palEntry, RGB6 &pal6) {
 /*------------------------------------------------------------------------*/
 
 void RGBList::clear() {
-	Common::fill(&_data[0], &_data[32], 0);
+	for (int i = 0; i < 32; i++)
+		_data[i] = false;
 }
 
 void RGBList::reset() {
-	Common::fill(&_data[2], &_data[32], 0);
+	for (int i = 2; i < 32; i++)
+		_data[i] = false;
 }
 
 int RGBList::scan() {
@@ -319,7 +321,7 @@ int RGBList::scan() {
 			return i;
 	}
 
-	error("List was full");
+	error("RGBList was full");
 }
 
 /*------------------------------------------------------------------------*/
@@ -327,7 +329,7 @@ int RGBList::scan() {
 Palette::Palette(MADSEngine *vm) : _vm(vm), _paletteUsage(vm) {
 	reset();
 
-	_v1 = 0;
+	_lockFl = false;
 	_lowRange = 0;
 	_highRange = 0;
 	Common::fill(&_mainPalette[0], &_mainPalette[PALETTE_SIZE], 0);
@@ -435,9 +437,9 @@ void Palette::resetGamePalette(int lowRange, int highRange) {
 	}
 
 	_rgbList.clear();
-	_rgbList[0] = _rgbList[1] = -1;
+	_rgbList[0] = _rgbList[1] = true;
 
-	_v1 = 0;
+	_lockFl = false;
 	_lowRange = lowRange;
 	_highRange = highRange;
 }
@@ -463,7 +465,7 @@ void Palette::initPalette() {
 	for (int idx = 0; idx < PALETTE_COUNT; ++idx)
 		_palFlags[idx] = palMask;
 
-	_v1 = 0;
+	_lockFl = false;
 	_rgbList.reset();
 }
 
@@ -486,12 +488,12 @@ void Palette::setLowRange() {
 void Palette::fadeOut(byte palette[PALETTE_SIZE], int v1, int v2, int v3, int v4, int v5, int v6) {
 }
 
-void Palette::sub7BBF8() {
-	if ((_rgbList[31] != 0) && (_v1 == 0))
-		error("Palette - Unexpected values");
+void Palette::lock() {
+	if (_rgbList[31] && !_lockFl)
+		error("Palette Lock - Unexpected values");
 
-	_v1 = -1;
-	_rgbList[31] = -1;
+	_lockFl = true;
+	_rgbList[31] = true;
 
 	for (int i = 0; i < 256; i++) {
 		if (_palFlags[i])
@@ -499,4 +501,14 @@ void Palette::sub7BBF8() {
 	}
 }
 
+void Palette::unlock() {
+	if (!_lockFl)
+		return;
+
+	for (int i = 0; i < 256; i++)
+		_palFlags[i] &= 0x7FFFFFFF;
+
+	_rgbList[31] = false;
+	_lockFl = false;
+}
 } // End of namespace MADS
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index ae29d18..dd5eaf6 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -110,7 +110,7 @@ public:
 
 class RGBList {
 private:
-	int16 _data[32];
+	bool _data[32];
 public:
 	RGBList() { clear(); }
 
@@ -123,7 +123,7 @@ public:
 	 */
 	int scan();
 
-	int16 &operator[](int idx) { return _data[idx]; }
+	bool &operator[](int idx) { return _data[idx]; }
 };
 
 #define PALETTE_COUNT 256
@@ -146,7 +146,7 @@ public:
 	uint32 _palFlags[PALETTE_COUNT];
 	PaletteUsage _paletteUsage;
 	RGBList _rgbList;
-	int _v1;
+	bool _lockFl;
 	int _lowRange;
 	int _highRange;
 public:
@@ -229,7 +229,8 @@ public:
 
 	void fadeOut(byte palette[PALETTE_SIZE], int v1, int v2, int v3, int v4, int v5, int v6);
 
-	void sub7BBF8();
+	void lock();
+	void unlock();
 };
 
 } // End of namespace MADS


Commit: 71b1343adf6e886cfd2e1a0040a12b5025672d14
    https://github.com/scummvm/scummvm/commit/71b1343adf6e886cfd2e1a0040a12b5025672d14
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-29T11:18:07-04:00

Commit Message:
MADS: Implemented NebularGame::step

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h
    engines/mads/animation.cpp
    engines/mads/animation.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/messages.cpp
    engines/mads/messages.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/game_nebular.h
    engines/mads/nebular/globals_nebular.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/player.cpp
    engines/mads/player.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/sequence.cpp
    engines/mads/sequence.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index fe90305..c2cc05e 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -35,8 +35,8 @@ MADSAction::MADSAction(MADSEngine *vm) : _vm(vm) {
 	_selectedAction = 0;
 	_inProgress = false;
 
-	_savedFields._actionMode = ABORTMODE_0;
-	_savedFields._actionMode2 = ABORTMODE_0;
+	_savedFields._actionMode = KERNEL_TRIGGER_PARSER;
+	_savedFields._actionMode2 = KERNEL_TRIGGER_PARSER;
 	_savedFields._selectedRow = -1;
 	_savedFields._hotspotId = 0;
 	_savedFields._v86F3A = 0;
@@ -272,7 +272,7 @@ void MADSAction::startAction() {
 	player.cancelCommand();
 
 	_inProgress = true;
-	_v8453A = ABORTMODE_0;
+	_v8453A = KERNEL_TRIGGER_PARSER;
 	_savedFields._selectedRow = _selectedRow;
 	_savedFields._hotspotId = _hotspotId;
 	_savedFields._v86F3A = _v86F3A;
diff --git a/engines/mads/action.h b/engines/mads/action.h
index a517a65..4f748f2 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -30,7 +30,11 @@ namespace MADS {
 
 enum ActionMode { ACTIONMODE_NONE = 0, ACTIONMODE_VERB = 1, ACTIONMODE_OBJECT = 3, ACTIONMODE_TALK = 6 };
 enum ActionMode2 { ACTIONMODE2_0 = 0, ACTIONMODE2_2 = 2, ACTIONMODE2_4 = 4, ACTIONMODE2_5 = 5 };
-enum AbortTimerMode { ABORTMODE_0 = 0, ABORTMODE_1 = 1, ABORTMODE_2 = 2 };
+enum TriggerMode { 
+	KERNEL_TRIGGER_PARSER = 0,		// Triggers parser
+	KERNEL_TRIGGER_DAEMON = 1,		// Triggers step/daemon code
+	KERNEL_TRIGGER_PREPARE = 2		// Triggers preparser
+};
 
 enum InterAwaiting {
 	AWAITING_NONE = 0,
diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 96b9cfb..a8adfe3 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -317,7 +317,7 @@ void Animation::startAnimation(int abortTimers) {
 	_oldFrameEntry = 0;
 	_nextFrameTimer = _vm->_game->_scene._frameStartTime;
 	_trigger = abortTimers;
-	_abortTimersMode = _vm->_game->_abortTimersMode2;
+	_triggerMode = _vm->_game->_triggerSetupMode;
 	_vm->_game->_scene._action._activeAction = _actionDetails;
 
 	for (int idx = 0; idx < _header._messagesCount; ++idx) {
@@ -532,9 +532,9 @@ void Animation::update() {
 		// Animation is complete
 		if (_trigger != 0) {
 			_vm->_game->_trigger = _trigger;
-			_vm->_game->_abortTimersMode = _abortTimersMode;
+			_vm->_game->_triggerMode = _triggerMode;
 
-			if (_abortTimersMode != ABORTMODE_1) {
+			if (_triggerMode != KERNEL_TRIGGER_DAEMON) {
 				// Copy the noun list
 				scene._action._action = _actionDetails;
 			}
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 7c3d864..63f77d1 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -129,7 +129,7 @@ private:
 	uint32 _nextScrollTimer;
 	int _messageCtr;
 	int _trigger;
-	AbortTimerMode _abortTimersMode;
+	TriggerMode _triggerMode;
 	ActionDetails _actionDetails;
 
 	/**
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index faa2bfa..f81c752 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -56,8 +56,8 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 	_aaName = "*I0.AA";
 	_priorFrameTimer = 0;
 	_updateSceneFlag = false;
-	_abortTimersMode = ABORTMODE_0;
-	_abortTimersMode2 = ABORTMODE_0;
+	_triggerMode = KERNEL_TRIGGER_PARSER;
+	_triggerSetupMode = KERNEL_TRIGGER_PARSER;
 	_ticksExpiry = 0;
 	_winStatus = 0;
 
diff --git a/engines/mads/game.h b/engines/mads/game.h
index f3e2a67..9da2694 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -134,8 +134,8 @@ public:
 	int _v2;
 	int _trigger;
 	ScreenTransition _fx;
-	AbortTimerMode _abortTimersMode;
-	AbortTimerMode _abortTimersMode2;
+	TriggerMode _triggerMode;
+	TriggerMode _triggerSetupMode;
 	uint32 _priorFrameTimer;
 	Common::String _aaName;
 	uint32 _ticksExpiry;
@@ -156,6 +156,11 @@ public:
 	*/
 	virtual void doObjectAction() = 0;
 
+	/**
+	 * Global game step
+	 */
+	virtual void step() = 0;
+
 	// DEPRECATED: ScummVM re-implementation keeps all the quotes loaded, so the methods below are stubs
 	void clearQuotes() {}
 	void loadQuoteRange(int startNum, int endNum) {}
diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index 5c6e113..3903b71 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -75,7 +75,7 @@ int KernelMessages::add(const Common::Point &pt, uint fontColor, uint8 flags,
 	rec._timeout = timeout;
 	rec._frameTimer = _vm->_game->_priorFrameTimer;
 	rec._trigger = abortTimers;
-	rec._abortMode = _vm->_game->_abortTimersMode2;
+	rec._abortMode = _vm->_game->_triggerSetupMode;
 
 	rec._actionDetails = scene._action._activeAction;
 
@@ -177,9 +177,9 @@ void KernelMessages::processText(int msgIndex) {
 		msg._flags |= KMSG_EXPIRE;
 		if (msg._trigger != 0) {
 			_vm->_game->_trigger = msg._trigger;
-			_vm->_game->_abortTimersMode = msg._abortMode;
+			_vm->_game->_triggerMode = msg._abortMode;
 
-			if (_vm->_game->_abortTimersMode != ABORTMODE_1) {
+			if (_vm->_game->_triggerMode != KERNEL_TRIGGER_DAEMON) {
 				scene._action._activeAction = msg._actionDetails;
 			}
 		}
diff --git a/engines/mads/messages.h b/engines/mads/messages.h
index 1254b1d..4778efd 100644
--- a/engines/mads/messages.h
+++ b/engines/mads/messages.h
@@ -57,7 +57,7 @@ public:
 	uint32 _frameTimer;
 	uint32 _timeout;
 	int _trigger;
-	AbortTimerMode _abortMode;
+	TriggerMode _abortMode;
 	ActionDetails _actionDetails;
 	Common::String _msg;
 
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 55a348a..34af685 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -280,6 +280,71 @@ void GameNebular::doObjectAction() {
 	warning("TODO: GameNebular::doObjectAction");
 }
 
+void GameNebular::step() {
+	if (_player._visible && _player._stepEnabled && !_player._moving &&
+		(_player._facing == _player._turnToFacing)) {
+		if (_scene._frameStartTime >= *((uint32 *)&_globals[kWalkerTiming])) {
+			if (!_player._stopWalkerIndex) {
+				int randomVal = _vm->getRandomNumber(29999);;
+				if (_globals[kSexOfRex] == REX_MALE) {
+					switch (_player._facing) {
+					case FACING_SOUTHWEST:
+					case FACING_SOUTHEAST:
+					case FACING_NORTHWEST:
+					case FACING_NORTHEAST:
+						if (randomVal < 200) {
+							_player.addWalker(-1, 0);
+							_player.addWalker(1, 0);
+						}
+						break;
+
+					case FACING_WEST:
+					case FACING_EAST:
+						if (randomVal < 500) {
+							for (int count = 0; count < 10; ++count) {
+								_player.addWalker(1, 0);
+							}
+						}
+						break;
+
+					case 2:
+						if (randomVal < 500) {
+							for (int count = 0; count < 10; ++count) {
+								_player.addWalker((randomVal < 250) ? 1 : 2, 0);
+							}
+						} else if (randomVal < 750) {
+							for (int count = 0; count < 5; ++count) {
+								_player.addWalker(1, 0);
+							}
+
+							_player.addWalker(0, 0);
+							_player.addWalker(0, 0);
+
+							for (int count = 0; count < 5; ++count) {
+								_player.addWalker(2, 0);
+							}
+						}
+						break;
+					}
+				}
+			}
+
+			*((uint32 *)&_globals[kWalkerTiming]) += 6;
+		}
+	}
+
+	// Below is countdown to set the timebomb off in room 604
+	if (_globals[kTimebombStatus] == TIMEBOMB_ACTIVATED) {
+		int diff = _scene._frameStartTime - *((uint32 *)&_globals[kTimebombClock]);
+		if ((diff >= 0) && (diff <= 60)) {
+			*((uint32 *)&_globals[kTimebombTimer]) += diff;
+		} else {
+			++*((uint32 *)&_globals[kTimebombTimer]);
+		}
+		*((uint32 *)&_globals[kTimebombClock]) = _scene._frameStartTime;
+	}
+}
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index d3d908d..5b88f63 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -66,6 +66,8 @@ public:
 	StoryMode _storyMode;
 
 	virtual void doObjectAction();
+
+	virtual void step();
 };
 
 
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index 992e00a..14bb2fb 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -207,6 +207,8 @@ enum GlobalId {
 
 /* Enums used for specific individual globals */
 /* Section #1 */
+// Rex's sex/swimming state
+enum { REX_MALE = 0, REX_MALE_SWIMMER = 1, REX_FEMALE = 2 };
 // State of Meteorologist in the outpost
 enum { METEOROLOGIST_ABSENT = 0, METEOROLOGIST_PRESENT = 1, METEOROLOGIST_GONE = 2 };
 
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 99c6cf4..da9341a 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -458,7 +458,7 @@ void Scene202::enter() {
 void Scene202::setRandomKernelMessage() {
 	int vocabId = _vm->getRandomNumber(92, 96);
 	_scene->_kernelMessages.reset();
-	_game._abortTimersMode2 = ABORTMODE_1;
+	_game._triggerSetupMode = KERNEL_TRIGGER_DAEMON;
 	_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 70, 120, _game.getQuote(vocabId));
 	_activeMsgFl = true;
 }
@@ -495,7 +495,7 @@ void Scene202::step() {
 			action->_activeAction._verbId = 3;
 			action->_activeAction._objectNameId = 39;
 			action->_activeAction._indirectObjectId = 438;
-			_game._abortTimersMode2 = ABORTMODE_0;
+			_game._triggerSetupMode = KERNEL_TRIGGER_PARSER;
 			_scene->_sequences.addTimer(120, 2);
 			_globals._abortVal = -1;
 		} else if (_globals[kMeteorologistWatch] == 2) {
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 57726e7..3625493 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -767,8 +767,8 @@ void Player::newWalk() {
 	}
 }
 
-void Player::step() {
-	warning("TODO: Player::step");
+void Player::addWalker(int walker, int trigger) {
+	warning("TODO: Player::addWalker");
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 2a92748..7ff14be 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -60,7 +60,6 @@ private:
 	int _routeLength;
 	int _stopWalkerList[12];
 	int _stopWalkerTrigger[12];
-	int _stopWalkerIndex;
 	int _totalDistance;
 
 	void clearStopList();
@@ -147,6 +146,7 @@ public:
 	bool _forceRefresh;
 	bool _needToWalk;
 	bool _readyToWalk;
+	int _stopWalkerIndex;
 	int _centerOfGravity;
 	int _currentDepth;
 	int _currentScale;
@@ -218,7 +218,10 @@ public:
 
 	void nextFrame();
 
-	void step();
+	/**
+	 * Add a walker to the current queue
+	 */
+	void addWalker(int walker, int trigger);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 2e78811..f61928f 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -310,7 +310,7 @@ void Scene::doFrame() {
 		flag = true;
 	}
 
-	if (flag || (_vm->_game->_trigger && _vm->_game->_abortTimersMode == ABORTMODE_2)) {
+	if (flag || (_vm->_game->_trigger && _vm->_game->_triggerMode == KERNEL_TRIGGER_PREPARE)) {
 		doPreactions();
 	}
 
@@ -320,7 +320,7 @@ void Scene::doFrame() {
 
 	if ((_action._inProgress && !player._moving && !player._needToWalk &&
 			player._turnToFacing == player._facing) ||
-			(_vm->_game->_trigger && _vm->_game->_abortTimersMode == ABORTMODE_0)) {
+			(_vm->_game->_trigger && _vm->_game->_triggerMode == KERNEL_TRIGGER_PARSER)) {
 		doAction();
 	}
 
@@ -444,11 +444,11 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
 
 void Scene::doPreactions() {
 	if (_vm->_game->_screenObjects._v832EC == 0 || _vm->_game->_screenObjects._v832EC == 2) {
-		_vm->_game->_abortTimersMode2 = ABORTMODE_2;
+		_vm->_game->_triggerSetupMode = KERNEL_TRIGGER_PREPARE;
 		_action.checkAction();
 		_sceneLogic->preActions();
 
-		if (_vm->_game->_abortTimersMode == ABORTMODE_2)
+		if (_vm->_game->_triggerMode == KERNEL_TRIGGER_PREPARE)
 			_vm->_game->_trigger = 0;
 	}
 }
@@ -456,7 +456,7 @@ void Scene::doPreactions() {
 void Scene::doAction() {
 	int flag = 0;
 
-	_vm->_game->_abortTimersMode2 = ABORTMODE_0;
+	_vm->_game->_triggerSetupMode = KERNEL_TRIGGER_PARSER;
 	if ((_action._inProgress || _vm->_game->_trigger) && !_action._v8453A) {
 		_sceneLogic->actions();
 		_action._inProgress = true;
@@ -494,19 +494,17 @@ void Scene::doAction() {
 	}
 
 	_action._inProgress = false;
-	if (_vm->_game->_abortTimersMode == ABORTMODE_0)
+	if (_vm->_game->_triggerMode == KERNEL_TRIGGER_PARSER)
 		_vm->_game->_trigger = 0;
 }
 
 void Scene::doSceneStep() {
-	_vm->_game->_abortTimersMode2 = ABORTMODE_1;
+	_vm->_game->_triggerSetupMode = KERNEL_TRIGGER_DAEMON;
 	_sceneLogic->step();
 	_vm->_game->_sectionHandler->step();
+	_vm->_game->step();
 
-	_vm->_game->_player.step();
-	_vm->_game->_player._trigger = 0;
-
-	if (_vm->_game->_abortTimersMode == ABORTMODE_1)
+	if (_vm->_game->_triggerMode == KERNEL_TRIGGER_DAEMON)
 		_vm->_game->_trigger = 0;
 }
 
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 0af5fa6..7b5d791 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -65,6 +65,9 @@ private:
 
 	void doAction();
 
+	/**
+	 * Calls all the necessary step handlers for the current frame
+	 */
 	void doSceneStep();
 
 	void checkKeyboard();
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index b630467..5b5c47f 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -50,7 +50,7 @@ KernelMessage::KernelMessage() {
 	_frameTimer = 0;
 	_timeout = 0;
 	_trigger = 0;
-	_abortMode = ABORTMODE_0;
+	_abortMode = KERNEL_TRIGGER_PARSER;
 	_actionDetails._verbId = 0;
 	_actionDetails._objectNameId = 0;
 	_actionDetails._indirectObjectId = 0;
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 9a8e2c6..6b9bd9e 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -47,7 +47,7 @@ SequenceEntry::SequenceEntry() {
 	_field22 = 0;
 	_triggerCountdown = 0;
 	_doneFlag = 0;
-	_abortMode = ABORTMODE_0;
+	_abortMode = KERNEL_TRIGGER_PARSER;
 	_numTicks = 0;
 	_extraTicks = 0;
 	_timeout = 0;
@@ -135,7 +135,7 @@ int SequenceList::add(int spriteListIndex, bool flipped, int frameIndex, int tri
 	_entries[seqIndex]._flags = 0;
 	_entries[seqIndex]._dynamicHotspotIndex = -1;
 	_entries[seqIndex]._entries._count = 0;
-	_entries[seqIndex]._abortMode = _vm->_game->_abortTimersMode2;
+	_entries[seqIndex]._abortMode = _vm->_game->_triggerSetupMode;
 
 	_entries[seqIndex]._actionNouns = _vm->_game->_scene._action._activeAction;
 
@@ -160,7 +160,7 @@ int SequenceList::addTimer(int time, int abortVal) {
 	se._triggerCountdown = true;
 	se._doneFlag = false;
 	se._entries._count = 0;
-	se._abortMode = _vm->_game->_abortTimersMode2;
+	se._abortMode = _vm->_game->_triggerSetupMode;
 	se._actionNouns = _vm->_game->_scene._action._activeAction;
 	addSubEntry(seqIndex, SM_0, 0, abortVal);
 
@@ -328,9 +328,9 @@ bool SequenceList::loadSprites(int seqIndex) {
 
 	if (idx >= 0) {
 		_vm->_game->_trigger = seqEntry._entries._abortVal[idx];
-		_vm->_game->_abortTimersMode = seqEntry._abortMode;
+		_vm->_game->_triggerMode = seqEntry._abortMode;
 
-		if (seqEntry._abortMode == ABORTMODE_1)
+		if (seqEntry._abortMode == KERNEL_TRIGGER_DAEMON)
 			scene._action._activeAction = seqEntry._actionNouns;
 	}
 
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index f24a2bd..5dfdbce 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -74,7 +74,7 @@ struct SequenceEntry {
 	int _triggerCountdown;
 	bool _doneFlag;
 	SequenceSubEntries _entries;
-	AbortTimerMode _abortMode;
+	TriggerMode _abortMode;
 
 	ActionDetails _actionNouns;
 	int _numTicks;


Commit: addb3e2900ee417fb71a75f9afae08b00007daa5
    https://github.com/scummvm/scummvm/commit/addb3e2900ee417fb71a75f9afae08b00007daa5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-29T13:38:52-04:00

Commit Message:
MADS: Minor renamings and added display of walk nodes to debugger

Changed paths:
    engines/mads/action.cpp
    engines/mads/debugger.cpp
    engines/mads/player.cpp
    engines/mads/scene.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index c2cc05e..c762b9b 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -78,7 +78,7 @@ void MADSAction::checkCustomDest(int v) {
 	Player &player = _vm->_game->_player;
 
 	if (_v86F4A && (v == -3 || _savedFields._selectedRow < 0)) {
-		_vm->_game->_player._needToWalk = true;
+		player._needToWalk = true;
 		player._prepareWalkPos = scene._customDest;
 	}
 }
diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp
index 3bc4ed2..58bf838 100644
--- a/engines/mads/debugger.cpp
+++ b/engines/mads/debugger.cpp
@@ -125,9 +125,19 @@ bool Debugger::Cmd_PlaySound(int argc, const char **argv) {
 bool Debugger::Cmd_ShowCodes(int argc, const char **argv) {
 	Scene &scene = _vm->_game->_scene;
 
+	// Copy the depth/walk surface to the background and flag for screen refresh
 	scene._depthSurface.copyTo(&scene._backgroundSurface);
 	scene._spriteSlots.fullRefresh();
 
+	// Draw the locations of scene nodes onto the background
+	int color = _vm->getRandomNumber(255);
+	for (int i = 0; i < (int)scene._sceneInfo->_nodes.size(); ++i) {
+		Common::Point &pt = scene._sceneInfo->_nodes[i]._walkPos;
+
+		scene._backgroundSurface.hLine(pt.x - 2, pt.y, pt.x + 2, color);
+		scene._backgroundSurface.vLine(pt.x, pt.y - 2, pt.y + 2, color);
+	}
+
 	return false;
 }
 
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 3625493..1705b11 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -768,7 +768,15 @@ void Player::newWalk() {
 }
 
 void Player::addWalker(int walker, int trigger) {
-	warning("TODO: Player::addWalker");
+	Scene &scene = _vm->_game->_scene;
+	SpriteAsset &spriteSet = *scene._sprites[_spritesStart + _spritesIdx];
+	assert(spriteSet._charInfo);
+
+	if (walker < spriteSet._charInfo->_numEntries && _stopWalkerIndex < 11) {
+		++_stopWalkerIndex;
+		_stopWalkerList[_stopWalkerIndex] = walker;
+		_stopWalkerTrigger[_stopWalkerIndex] = trigger;
+	}
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index f61928f..b8b8888 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -136,6 +136,10 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	for (uint i = 0; i < _sceneInfo->_nodes.size(); ++i)
 		_nodes.push_back(_sceneInfo->_nodes[i]);
 
+	// Add two more empty nodes for the start and end points of any walk sequence
+	_nodes.push_back(SceneNode());
+	_nodes.push_back(SceneNode());
+
 	// Load hotspots
 	loadHotspots();
 


Commit: 5f3a15022584c3eb7377291a278165a1b1b8dd7b
    https://github.com/scummvm/scummvm/commit/5f3a15022584c3eb7377291a278165a1b1b8dd7b
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-29T19:44:52+01:00

Commit Message:
MADS: Some renaming in scene 207

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index da9341a..61ce589 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1241,30 +1241,29 @@ void Scene207::enter() {
 	}
 
 	if (var2 > 2)
-		_globals._v0 = 0;
+		_vultureFl = false;
 	else
-		_globals._v0 = 1;
+		_vultureFl = true;
 
-	_globals._v5 = (var2 & 1);
+	_spiderFl = (var2 & 1);
 	
-	if (_globals._v0) {
+	if (_vultureFl) {
 		_globals._spriteIndexes[16] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 30, 0, 0, 400);
-		_globals._frameTime = _game._player._priorTimer;
+		_vultureTime = _game._player._priorTimer;
 
 		int idx = _scene->_dynamicHotspots.add(389, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, 254, 94, FACING_WEST);
 	}
 
-	if (_globals._v5) {
+	if (_spiderFl) {
 		_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 7, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], -1, -1);
-		_globals._v3 = _game._player._priorTimer & 0xFFFF;
-		_globals._v4 = _game._player._priorTimer >> 16;
-		int idx = _scene->_dynamicHotspots.add(333, 13, _globals._spriteIndexes[19], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 59, 132, FACING_SOUTH);
+		_spiderTime = _game._player._priorTimer;
+		_spiderHotspotId = _scene->_dynamicHotspots.add(333, 13, _globals._spriteIndexes[19], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(_spiderHotspotId, 59, 132, FACING_SOUTH);
 	}
 
-	_globals._v2 = 0;
+	_eyeFl = false;
 	if (_scene->_priorSceneId == 211) {
 		_game._player._playerPos = Common::Point(13, 105);
 		_game._player._facing = FACING_EAST;
@@ -1282,11 +1281,11 @@ void Scene207::enter() {
 }
 
 void Scene207::step() {
-	if (!_globals._v0) {
+	if (!_vultureFl) {
 		warning("TODO: sub3AD90(...)");
 	}
 
-	if (_globals._v5) {
+	if (_spiderFl) {
 		warning("TODO: sub3ADD6(...)");
 	}
 
@@ -1297,9 +1296,9 @@ void Scene207::step() {
 	}
 
 	if (_game._trigger == 71)
-		_globals._v2 = 0;
+		_eyeFl = false;
 
-	if (_globals._v2)
+	if (_eyeFl)
 		return;
 
 	if ((_game._player._playerPos.x >= 124) && (_game._player._playerPos.x <= 201)) {
@@ -1308,7 +1307,7 @@ void Scene207::step() {
 		_scene->_sequences.setDepth(_globals._spriteIndexes[22], 6);
 		_scene->_sequences.setDepth(_globals._spriteIndexes[23], 6);
 		_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 71);
-		_globals._v2 = -1;
+		_eyeFl = true;
 	}
 }
 
@@ -1321,11 +1320,9 @@ void Scene207::preActions() {
 
 	if ((_action.isAction(VERB_WALKTO)) || (_action.isAction(VERB_LOOK))) {
 		if (_action.isAction(0x185)) {
-			_globals._frameTime = 0xD8F1;
-			_globals._frameTime |= 0xFFFF0000;
+			_vultureTime = -9999;
 		} else if (_action.isAction(0x14D)) {
-			_globals._v3 = 0xD8F1;
-			_globals._v4 = -1;
+			_spiderTime = -9999;
 		}
 	}
 }
@@ -1333,57 +1330,56 @@ void Scene207::preActions() {
 void Scene207::actions() {
 	if (_action._savedFields._lookFlag) {
 		_vm->_dialogs->show(0x50E7);
-	} else {
-		if (_action.isAction(0x18B, 0x70))
-			_scene->_nextSceneId = 214;
-		else {
-			if ((_game._player._playerPos.x > 150) && (_game._player._playerPos.x < 189) &&
-			    (_game._player._playerPos.y > 111) && (_game._player._playerPos.y < 130)) {
-				if ((_game._player._playerPos.x <= 162) && (_game._player._playerPos.x >= 181) &&
-				    (_game._player._playerPos.y <= 115) && (_game._player._playerPos.y >= 126)) {
-					_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 10, 2, 0, 0);
-					_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 2, 0, 0);
-					_scene->_sequences.setDepth(_globals._spriteIndexes[22], 6);
-					_scene->_sequences.setDepth(_globals._spriteIndexes[23], 6);
-				}
-			} else if (_globals._v2) {
-				_scene->_sequences.remove(_globals._spriteIndexes[22]);
-				_scene->_sequences.remove(_globals._spriteIndexes[23]);
-				_globals._v2 = 0;
+	} else if (_action.isAction(0x18B, 0x70))
+		_scene->_nextSceneId = 214;
+	else {
+		if ((_game._player._playerPos.x > 150) && (_game._player._playerPos.x < 189) &&
+		    (_game._player._playerPos.y > 111) && (_game._player._playerPos.y < 130)) {
+			if ((_game._player._playerPos.x <= 162) && (_game._player._playerPos.x >= 181) &&
+			    (_game._player._playerPos.y <= 115) && (_game._player._playerPos.y >= 126)) {
+				_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 10, 2, 0, 0);
+				_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 2, 0, 0);
+				_scene->_sequences.setDepth(_globals._spriteIndexes[22], 6);
+				_scene->_sequences.setDepth(_globals._spriteIndexes[23], 6);
 			}
-
-			if (_action.isAction(VERB_LOOK, 0x69)) {
-				_vm->_dialogs->show(0x50DD);
-			} else if (_action.isAction(VERB_LOOK, 0x1AF)) {
-				_vm->_dialogs->show(0x50DE);
-			} else if (_action.isAction(VERB_LOOK, 0x141)) {
-				_vm->_dialogs->show(0x50DF);
-			} else if (_action.isAction(VERB_LOOK, 0x3E)) {
-				_vm->_dialogs->show(0x50E0);
-			} else if (_action.isAction(VERB_LOOK, 0x198)) {
-				_vm->_dialogs->show(0x50E1);
-			} else if (_action.isAction(VERB_LOOK, 0x1AE)) {
-				_vm->_dialogs->show(0x50E2);
-			} else if (_action.isAction(VERB_LOOK, 0xE8)) {
-				_vm->_dialogs->show(0x50E3);
-			} else if (_action.isAction(VERB_LOOK, 0x12)) {
-				_vm->_dialogs->show(0x50E4);
-			} else if (_action.isAction(VERB_LOOK, 0x1AC)) {
-				_vm->_dialogs->show(0x50E5);
-			} else if (_action.isAction(VERB_LOOK, 0x185)) {
-				_vm->_dialogs->show(0x50E6);
-			} else if (_action.isAction(VERB_TAKE, 0x141)) {
-				_vm->_dialogs->show(0x50E8);
-			} else if (_action.isAction(VERB_TAKE, 0x12)) {
-				_vm->_dialogs->show(0x50E9);
-			} else if (_action.isAction(VERB_LOOK, 0x14D)) {
-				_vm->_dialogs->show(0x50EA);
-			} else if (_action.isAction(VERB_TAKE, 0x14D)) {
-				_vm->_dialogs->show(0x50EB);
-			} else
-				return;
+		} else if (_eyeFl) {
+			_scene->_sequences.remove(_globals._spriteIndexes[22]);
+			_scene->_sequences.remove(_globals._spriteIndexes[23]);
+			_eyeFl = false;
 		}
+
+		if (_action.isAction(VERB_LOOK, 0x69)) {
+			_vm->_dialogs->show(0x50DD);
+		} else if (_action.isAction(VERB_LOOK, 0x1AF)) {
+			_vm->_dialogs->show(0x50DE);
+		} else if (_action.isAction(VERB_LOOK, 0x141)) {
+			_vm->_dialogs->show(0x50DF);
+		} else if (_action.isAction(VERB_LOOK, 0x3E)) {
+			_vm->_dialogs->show(0x50E0);
+		} else if (_action.isAction(VERB_LOOK, 0x198)) {
+			_vm->_dialogs->show(0x50E1);
+		} else if (_action.isAction(VERB_LOOK, 0x1AE)) {
+			_vm->_dialogs->show(0x50E2);
+		} else if (_action.isAction(VERB_LOOK, 0xE8)) {
+			_vm->_dialogs->show(0x50E3);
+		} else if (_action.isAction(VERB_LOOK, 0x12)) {
+			_vm->_dialogs->show(0x50E4);
+		} else if (_action.isAction(VERB_LOOK, 0x1AC)) {
+			_vm->_dialogs->show(0x50E5);
+		} else if (_action.isAction(VERB_LOOK, 0x185)) {
+			_vm->_dialogs->show(0x50E6);
+		} else if (_action.isAction(VERB_TAKE, 0x141)) {
+			_vm->_dialogs->show(0x50E8);
+		} else if (_action.isAction(VERB_TAKE, 0x12)) {
+			_vm->_dialogs->show(0x50E9);
+		} else if (_action.isAction(VERB_LOOK, 0x14D)) {
+			_vm->_dialogs->show(0x50EA);
+		} else if (_action.isAction(VERB_TAKE, 0x14D)) {
+			_vm->_dialogs->show(0x50EB);
+		} else
+			return;
 	}
+
 	_action._inProgress = false;
 }
 
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 44ee528..1c19ae4 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -113,8 +113,11 @@ public:
 };
 
 class Scene207: public Scene2xx {
+	bool _vultureFl, _spiderFl, _eyeFl;
+	int _spiderHotspotId;
+	int32 _spiderTime, _vultureTime;
 public:
-	Scene207(MADSEngine *vm) : Scene2xx(vm) {}
+	Scene207(MADSEngine *vm) : Scene2xx(vm), _vultureFl(false), _spiderFl(false), _spiderHotspotId(-1), _spiderTime(0), _vultureTime(0) {}
 	virtual void setup();
 	virtual void enter();
 	virtual void step();


Commit: f3db90b646d4af5b6daf43d11e99d59de0649b03
    https://github.com/scummvm/scummvm/commit/f3db90b646d4af5b6daf43d11e99d59de0649b03
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-29T17:12:12-04:00

Commit Message:
MADS: Refactored pathfinder into it's own class

Changed paths:
  A engines/mads/rails.cpp
  A engines/mads/rails.h
    engines/mads/module.mk
    engines/mads/player.cpp
    engines/mads/player.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 54126b1..13b4f85 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -27,6 +27,7 @@ MODULE_OBJS := \
 	msurface.o \
 	palette.o \
 	player.o \
+	rails.o \
 	resources.o \
 	scene.o \
 	scene_data.o \
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 1705b11..e726c80 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -78,14 +78,14 @@ Player::Player(MADSEngine *vm): _vm(vm) {
 }
 
 void Player::cancelWalk() {
-	_action = &_vm->_game->_scene._action;
+	Scene &scene = _vm->_game->_scene;
+	_action = &scene._action;
 	_targetPos = _playerPos;
 	_targetFacing = FACING_NONE;
 	_turnToFacing = _facing;
 	_moving = false;
 	_walkOffScreen = _walkOffScreenSceneId = 0;
-	_next = 0;
-	_routeCount = 0;
+	scene._rails.resetRoute();
 	_walkAnywhere = false;
 
 	_needToWalk = false;
@@ -352,30 +352,12 @@ void Player::startWalking(const Common::Point &pt, Facing facing) {
 	_moving = true;
 	_targetFacing = facing;
 
-	scene._sceneInfo->setRouteNode(scene._sceneInfo->_nodes.size() - 2,
-		_playerPos, scene._depthSurface);
-	scene._sceneInfo->setRouteNode(scene._sceneInfo->_nodes.size() - 1,
-		pt, scene._depthSurface);
-
 	bool v = scene._depthSurface.getDepthHighBit(pt);
-	setupRoute(v);
-	_next = 0;
-
-	if (_routeCount > 0) {
-		Common::Point srcPos = _playerPos;
-		for (int routeCtr = _routeCount - 1; (routeCtr >= 0) && (_next == 0); --routeCtr) {
-			int idx = _routeIndexes[routeCtr];
-			const Common::Point &pt =scene._sceneInfo->_nodes[idx]._walkPos;
 
-			_next = scanPath(scene._depthSurface, srcPos, pt);
-			srcPos = pt;
-		}
-	}
+	scene._rails.setupRoute(v, _playerPos, pt);
 }
 
 void Player::walk(const Common::Point &pos, Facing facing) {
-	Scene &scene = _vm->_game->_scene;
-
 	cancelWalk();
 	_needToWalk = true;
 	_readyToWalk = true;
@@ -402,23 +384,23 @@ void Player::nextFrame() {
 
 void Player::move() {
 	Scene &scene = _vm->_game->_scene;
+	Rails &rails = scene._rails;
 	bool newFacing = false;
 
 	if (_moving) {
-		int idx = _routeCount;
+		bool isRouteEmpty = rails.empty();
 		while (!_walkOffScreen && _playerPos == _targetPos) {
-			if (idx != 0) {
-				--idx;
-				SceneNode &node = scene._sceneInfo->_nodes[_routeIndexes[idx]];
+			if (!isRouteEmpty) {
+				const WalkNode &node = rails.popNode();
+
 				_targetPos = node._walkPos;
 				newFacing = true;
-			} else if (_walkOffScreenSceneId == idx) {
+			} else if (!_walkOffScreenSceneId) {
 				// End of walking path
-				_routeCount = 0;
+				rails.resetRoute();
 				_moving = false;
 				setFinalFacing();
 				newFacing = true;
-				idx = _routeCount;
 			} else {
 				_walkOffScreen = _walkOffScreenSceneId;
 				_walkAnywhere = true;
@@ -430,7 +412,6 @@ void Player::move() {
 			if (!_moving)
 				break;
 		}
-		_routeCount = idx;
 	}
 
 	if (newFacing && _moving)
@@ -579,104 +560,6 @@ void Player::setBaseFrameRate() {
 		_ticksAmount = 6;
 }
 
-void Player::setupRoute(bool bitFlag) {
-	Scene &scene = _vm->_game->_scene;
-
-	// Reset the flag set of nodes in use
-	SceneNodeList &nodes = scene._sceneInfo->_nodes;
-	for (uint i = 0; i < nodes.size(); ++i)
-		nodes[i]._active = false;
-
-	// Start constructing route node list
-	_routeLength = 0x3FFF;
-	_routeCount = 0;
-
-	setupRouteNode(_tempRoute, nodes.size() - 1, bitFlag ? 0xC000 : 0x8000, 0);
-}
-
-void Player::setupRouteNode(int *routeIndexP, int nodeIndex, int flags, int routeLength) {
-	Scene &scene = _vm->_game->_scene;
-	SceneNodeList &nodes = scene._sceneInfo->_nodes;
-	SceneNode &currentNode = nodes[nodeIndex];
-	currentNode._active = true;
-
-	*routeIndexP++ = nodeIndex;
-
-	int subIndex = nodes.size() - 2;
-	int indexVal = nodes[nodeIndex]._indexes[subIndex];
-	if (indexVal & flags) {
-		routeLength += indexVal & 0x3FFF;
-		if (routeLength < _routeLength) {
-			// Found a new shorter route to destination, so set up the route with the found one
-			Common::copy(_tempRoute, routeIndexP, _routeIndexes);
-			_routeCount = routeIndexP - _tempRoute;
-			_routeLength = indexVal & 0x3FFF;
-		}
-	} else {
-		for (int idx = nodes.size() - 2; idx > 0; --idx) {
-			int nodePos = idx - 1;
-			if (!nodes[nodePos]._active && ((currentNode._indexes[nodePos] & flags) != 0))
-				setupRouteNode(routeIndexP, nodePos, 0x8000, indexVal & 0x3fff);
-		}
-	}
-
-	currentNode._active = false;
-}
-
-int Player::scanPath(MSurface &depthSurface, const Common::Point &srcPos, const Common::Point &destPos) {
-	Scene &scene = _vm->_game->_scene;
-	
-	// For compressed depth surfaces, always return 0
-	if (scene._sceneInfo->_depthStyle != 2)
-		return 0;
-
-	int yDiff = destPos.y - srcPos.y;
-	int yAmount = MADS_SCREEN_WIDTH;
-
-	if (yDiff < 0) {
-		yDiff = -yDiff;
-		yAmount = -yAmount;
-	}
-
-	int xDiff = destPos.x - srcPos.y;
-	int xDirection = 1;
-	int xAmount = 0;
-	if (xDiff < 0) {
-		xDiff = -xDiff;
-		xDirection = -xDirection;
-		xAmount = MIN(yDiff, xDiff);
-	}
-
-	++xDiff;
-	++yDiff;
-
-	const byte *srcP = depthSurface.getBasePtr(srcPos.x, srcPos.y);
-	int index = xAmount;
-
-	// Outer horizontal movement loop
-	for (int yIndex = 0; yIndex < yDiff; ++yIndex) {
-		index += yDiff;
-		int v = (*srcP & 0x7F) >> 4;
-		if (v)
-			return v;
-
-		// Inner loop for handling vertical movement
-		while (index >= xDiff) {
-			index -= xDiff;
-
-			v = (*srcP & 0x7F) >> 4;
-			if (v)
-				return v;
-
-			srcP += yAmount;
-		}
-
-		srcP += xDirection;
-	}
-
-	return 0;
-}
-
 void Player::startMovement() {
 	int xDiff = _targetPos.x - _playerPos.x;
 	int yDiff = _targetPos.y - _playerPos.y;
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 7ff14be..986971b 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -57,7 +57,6 @@ private:
 	int _distAccum;
 	int _pixelAccum;
 	int _deltaDistance;
-	int _routeLength;
 	int _stopWalkerList[12];
 	int _stopWalkerTrigger[12];
 	int _totalDistance;
@@ -89,18 +88,6 @@ private:
 	 */
 	void setBaseFrameRate();
 
-	void setupRoute();
-
-	void setupRoute(bool bitFlag);
-
-	void setupRouteNode(int *routeIndexP, int nodeIndex, int flags, int routeLength);
-
-	/**
-	* Scans along an edge connecting two points within the depths/walk surface, and returns the information of the first
-	* pixel high nibble encountered with a non-zero value
-	*/
-	int scanPath(MSurface &depthSurface, const Common::Point &srcPos, const Common::Point &destPos);
-
 	/**
 	* Starts a player moving to a given destination
 	*/
@@ -151,10 +138,6 @@ public:
 	int _currentDepth;
 	int _currentScale;
 	Common::String _spritesPrefix;
-	int _routeCount;
-	int _routeOffset;
-	int _tempRoute[MAX_ROUTE_NODES];
-	int _routeIndexes[MAX_ROUTE_NODES];
 public:
 	Player(MADSEngine *vm);
 
diff --git a/engines/mads/rails.cpp b/engines/mads/rails.cpp
new file mode 100644
index 0000000..0baaa12
--- /dev/null
+++ b/engines/mads/rails.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/rails.h"
+
+namespace MADS {
+
+WalkNode::WalkNode() {
+	_active = false;
+	Common::fill(&_distances[0], &_distances[MAX_ROUTE_NODES], 0);
+}
+
+void WalkNode::load(Common::SeekableReadStream *f) {
+	_walkPos.x = f->readSint16LE();
+	_walkPos.y = f->readSint16LE();
+	for (int i = 0; i < MAX_ROUTE_NODES; ++i)
+		_distances[i] = f->readUint16LE();
+}
+
+/*------------------------------------------------------------------------*/
+
+Rails::Rails() {
+	_depthSurface = nullptr;
+	_routeLength = 0;
+}
+
+void Rails::load(const WalkNodeList &nodes, DepthSurface *depthSurface, int depthStyle) {
+	// Store the depth surface and depth style to use
+	_depthSurface = depthSurface;
+	_depthStyle = depthStyle;
+
+	// Load the passed node list
+	_nodes.clear();
+
+	for (uint i = 0; i < nodes.size(); ++i)
+		_nodes.push_back(nodes[i]);
+
+	// Add two more empty nodes for the start and end points of any walk sequence
+	_nodes.push_back(WalkNode());
+	_nodes.push_back(WalkNode());
+}
+
+
+void Rails::setupRoute(bool bitFlag, const Common::Point &srcPos, const Common::Point &destPos) {
+	// Reset the nodes in as being inactive
+	for (uint i = 0; i < _nodes.size(); ++i)
+		_nodes[i]._active = false;
+
+	// Set the two extra walk nodes to the start and destination positions
+	setNodePosition(_nodes.size() - 2, srcPos);
+	setNodePosition(_nodes.size() - 1, destPos);
+
+	// Start constructing route node list
+	_routeLength = 0x3FFF;
+	_routeIndexes.clear();
+
+	// Recursively form a route from the destination walk node back to the player's position
+	setupRouteNode(&_tempRoute[0], _nodes.size() - 1, bitFlag ? 0xC000 : 0x8000, 0);
+
+	_next = 0;
+	if (_routeIndexes.size() > 0) {
+		Common::Point currPos = srcPos;
+		for (int routeCtr = size() - 1; (routeCtr >= 0) && (_next == 0); --routeCtr) {
+			int idx = _routeIndexes[routeCtr];
+			const Common::Point &pt = _nodes[idx]._walkPos;
+
+			_next = scanPath(currPos, pt);
+			currPos = pt;
+		}
+	}
+}
+
+void Rails::setupRouteNode(int *routeIndexP, int nodeIndex, int flags, int routeLength) {
+	WalkNode &currentNode = _nodes[nodeIndex];
+	currentNode._active = true;
+
+	*routeIndexP++ = nodeIndex;
+
+	// Get the index of the ultimate source position (the player)
+	int subIndex = _nodes.size() - 2;
+
+	int distanceVal = _nodes[nodeIndex]._distances[subIndex];
+	if (distanceVal & flags) {                                                                                                                                                   
+		routeLength += distanceVal & 0x3FFF;
+		if (routeLength < _routeLength) {
+			// Found a new shorter route to destination, so set up the route with the found one
+			_routeIndexes.clear();
+			for (int i = 0; routeIndexP != &_tempRoute[i]; ++i)
+				_routeIndexes.push(_tempRoute[i]);
+			_routeLength = routeLength;
+		}
+	} else {
+		for (int idx = _nodes.size() - 2; idx > 0; --idx) {
+			int nodePos = idx - 1;
+			if (!_nodes[nodePos]._active && ((currentNode._distances[nodePos] & flags) != 0))
+				setupRouteNode(routeIndexP, nodePos, 0x8000, distanceVal & 0x3fff);
+		}
+	}
+
+	currentNode._active = false;
+}
+
+
+int Rails::scanPath(const Common::Point &srcPos, const Common::Point &destPos) {
+	// For compressed depth surfaces, always return 0
+	if (_depthStyle != 2)
+		return 0;
+
+	int yDiff = destPos.y - srcPos.y;
+	int yAmount = MADS_SCREEN_WIDTH;
+
+	if (yDiff < 0) {
+		yDiff = -yDiff;
+		yAmount = -yAmount;
+	}
+
+	int xDiff = destPos.x - srcPos.y;
+	int xDirection = 1;
+	int xAmount = 0;
+	if (xDiff < 0) {
+		xDiff = -xDiff;
+		xDirection = -xDirection;
+		xAmount = MIN(yDiff, xDiff);
+	}
+
+	++xDiff;
+	++yDiff;
+
+	const byte *srcP = _depthSurface->getBasePtr(srcPos.x, srcPos.y);
+	int index = xAmount;
+
+	// Outer horizontal movement loop
+	for (int yIndex = 0; yIndex < yDiff; ++yIndex) {
+		index += yDiff;
+		int v = (*srcP & 0x7F) >> 4;
+		if (v)
+			return v;
+
+		// Inner loop for handling vertical movement
+		while (index >= xDiff) {
+			index -= xDiff;
+
+			v = (*srcP & 0x7F) >> 4;
+			if (v)
+				return v;
+
+			srcP += yAmount;
+		}
+
+		srcP += xDirection;
+	}
+
+	return 0;
+}
+
+void Rails::resetRoute() {
+	_routeIndexes.clear();
+	_next = 0;
+}
+
+const WalkNode &Rails::popNode() {
+	assert(!_routeIndexes.empty());
+
+	return _nodes[_routeIndexes.pop()];
+}
+
+void Rails::setNodePosition(int nodeIndex, const Common::Point &pt) {
+	int flags, hypotenuse;
+
+	_nodes[nodeIndex]._walkPos = pt;
+
+	// Recalculate inter-node lengths
+	for (uint idx = 0; idx < _nodes.size(); ++idx) {
+		int entry;
+		if (idx == (uint)nodeIndex) {
+			entry = 0x3FFF;
+		}
+		else {
+			// Process the node
+			flags = getRouteFlags(pt, _nodes[idx]._walkPos);
+
+			int xDiff = ABS(_nodes[idx]._walkPos.x - pt.x);
+			int yDiff = ABS(_nodes[idx]._walkPos.y - pt.y);
+			hypotenuse = sqrt((double)(xDiff * xDiff + yDiff * yDiff));
+
+			if (hypotenuse >= 0x3FFF)
+				// Shouldn't ever be this large
+				hypotenuse = 0x3FFF;
+
+			entry = hypotenuse | flags;
+			_nodes[idx]._distances[nodeIndex] = entry;
+			_nodes[nodeIndex]._distances[idx] = entry;
+		}
+	}
+}
+
+int Rails::getRouteFlags(const Common::Point &src, const Common::Point &dest) {
+	int result = 0x8000;
+	bool flag = false;
+
+	int xDiff = ABS(dest.x - src.x);
+	int yDiff = ABS(dest.y - src.y);
+	int xDirection = dest.x >= src.x ? 1 : -1;
+	int yDirection = dest.y >= src.y ? _depthSurface->w : -_depthSurface->w;
+	int majorDiff = 0;
+	if (dest.x < src.x)
+		majorDiff = MAX(xDiff, yDiff);
+	++xDiff;
+	++yDiff;
+
+	byte *srcP = _depthSurface->getBasePtr(src.x, src.y);
+
+	int totalCtr = majorDiff;
+	for (int xCtr = 0; xCtr < xDiff; ++xCtr, srcP += xDirection) {
+		totalCtr += yDiff;
+
+		if ((*srcP & 0x80) == 0)
+			flag = false;
+		else if (!flag) {
+			flag = true;
+			result -= 0x4000;
+			if (result == 0)
+				break;
+		}
+
+		while (totalCtr >= xDiff) {
+			totalCtr -= xDiff;
+
+			if ((*srcP & 0x80) == 0)
+				flag = false;
+			else if (!flag) {
+				flag = true;
+				result -= 0x4000;
+				if (result == 0)
+					break;
+			}
+
+			srcP += yDirection;
+		}
+		if (result == 0)
+			break;
+	}
+
+	return result;
+}
+
+
+} // End of namespace MADS
diff --git a/engines/mads/rails.h b/engines/mads/rails.h
new file mode 100644
index 0000000..026edda
--- /dev/null
+++ b/engines/mads/rails.h
@@ -0,0 +1,128 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_RAILS_H
+#define MADS_RAILS_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+#include "common/rect.h"
+#include "common/stack.h"
+#include "mads/msurface.h"
+
+namespace MADS {
+
+class WalkNode {
+public:
+	Common::Point _walkPos;
+	int _distances[MAX_ROUTE_NODES];
+	bool _active;
+
+	/**
+	 * Constructor
+	 */
+	WalkNode();
+
+	/**
+	 * Loads the scene node
+	 */
+	void load(Common::SeekableReadStream *f);
+};
+typedef Common::Array<WalkNode> WalkNodeList;
+
+/**
+ * This class handles storing the intermediate walk node points for a 
+ * given scene, and calculating walking routes between any two positions.
+ */
+class Rails {
+private:
+	WalkNodeList _nodes;
+	DepthSurface *_depthSurface;
+	int _depthStyle;
+	int _routeLength;
+	int _next;
+	int _routeOffset;
+	int _tempRoute[MAX_ROUTE_NODES];
+	Common::Stack<int> _routeIndexes;
+private:
+	/**
+	* Change the position of a walking node. Doing so causes a recalculation of the
+	* distance between it and every other node, and vice versa
+	*/
+	void setNodePosition(int nodeIndex, const Common::Point &pt);
+
+	int getRouteFlags(const Common::Point &src, const Common::Point &dest);
+public:
+	/**
+	 * Constructor
+	 */
+	Rails();
+
+	/**
+	 * Loads the scene data for the list of intermediate walk nodes and the
+	 * depth surface to use.
+	 * @param nodes			Intermediate walk-points
+	 * @param depthSurface	Depth surface to use
+	 */
+	void load(const WalkNodeList &nodes, DepthSurface *depthSurface, int depthStyle);
+
+	/**
+	 * Set up a route between two points in a scene
+	 */
+	void setupRoute(bool bitFlag, const Common::Point &srcPos, const Common::Point &destPos);
+
+	void setupRouteNode(int *routeIndexP, int nodeIndex, int flags, int routeLength);
+
+	/**
+	 * Resets any currently running route
+	 */
+	void resetRoute();
+
+	/**
+	* Scans along an edge connecting two points within the depths/walk surface, and returns the information of the first
+	* pixel high nibble encountered with a non-zero value
+	*/
+	int scanPath(const Common::Point &srcPos, const Common::Point &destPos);
+
+	/*
+	 * Return the number of walk nodes in the calculated route
+	 */
+	int size() const { return _routeIndexes.size(); }
+
+	/**
+	 * Returns true if the current calculated walk route is empty
+	 */
+	bool empty() const { return _routeIndexes.empty(); }
+
+	/**
+	 * Returns the data for a given walk node
+	 */
+	const WalkNode &operator[](int idx) { return _nodes[_routeIndexes[idx]]; }
+
+	const WalkNode &popNode();
+
+	void resetNext() { _next = 0; }
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_RAILS_H */
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index b8b8888..83c0594 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -132,13 +132,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	initPaletteAnimation(_sceneInfo->_palAnimData, false);
 
 	// Copy over nodes
-	_nodes.clear();
-	for (uint i = 0; i < _sceneInfo->_nodes.size(); ++i)
-		_nodes.push_back(_sceneInfo->_nodes[i]);
-
-	// Add two more empty nodes for the start and end points of any walk sequence
-	_nodes.push_back(SceneNode());
-	_nodes.push_back(SceneNode());
+	_rails.load(_sceneInfo->_nodes, &_depthSurface, _sceneInfo->_depthStyle);
 
 	// Load hotspots
 	loadHotspots();
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 7b5d791..1caba12 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -33,6 +33,7 @@
 #include "mads/msurface.h"
 #include "mads/scene_data.h"
 #include "mads/animation.h"
+#include "mads/rails.h"
 #include "mads/sequence.h"
 #include "mads/sprites.h"
 #include "mads/user_interface.h"
@@ -92,6 +93,7 @@ public:
 	Common::Array<int> _activeVocabs;
 	SequenceList _sequences;
 	KernelMessages _kernelMessages;
+	Rails _rails;
 	Common::String _talkFont;
 	int _textSpacing;
 	Hotspots _hotspots;
@@ -106,7 +108,6 @@ public:
 	int _animCount;
 	Common::Array<uint32> _animTicksList;
 	Common::Array<RGB4> _animPalData;
-	SceneNodeList _nodes;
 	Common::StringArray _vocabStrings;
 	Animation *_animationData;
 	Animation *_activeAnimation;
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 5b5c47f..abe0b7b 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -30,15 +30,6 @@
 
 namespace MADS {
 
-void SceneNode::load(Common::SeekableReadStream *f) {
-	_walkPos.x = f->readSint16LE();
-	_walkPos.y = f->readSint16LE();
-	for (int i = 0; i < MAX_ROUTE_NODES; ++i)
-		_indexes[i] = f->readUint16LE();
-}
-
-/*------------------------------------------------------------------------*/
-
 KernelMessage::KernelMessage() {
 	_flags = 0;
 	_sequenceIndex = 0;
@@ -97,87 +88,6 @@ void SceneInfo::SpriteInfo::load(Common::SeekableReadStream *f) {
 	_scale = f->readByte();
 }
 
-void SceneInfo::setRouteNode(int nodeIndex, const Common::Point &pt, MSurface &depthSurface) {
-	int flags, hypotenuse;
-
-	_nodes[nodeIndex]._walkPos = pt;
-
-	// Recalculate inter-node lengths
-	for (uint idx = 0; idx < _nodes.size(); ++idx) {
-		int entry;
-		if (idx == (uint)nodeIndex) {
-			entry = 0x3FFF;
-		}
-		else {
-			// Process the node
-			flags = getRouteFlags(pt, _nodes[idx]._walkPos, depthSurface);
-
-			int xDiff = ABS(_nodes[idx]._walkPos.x - pt.x);
-			int yDiff = ABS(_nodes[idx]._walkPos.y - pt.y);
-			hypotenuse = sqrt((double)(xDiff * xDiff + yDiff * yDiff));
-
-			if (hypotenuse >= 0x3FFF)
-				// Shouldn't ever be this large
-				hypotenuse = 0x3FFF;
-
-			entry = hypotenuse | flags;
-			_nodes[idx]._indexes[nodeIndex] = entry;
-			_nodes[nodeIndex]._indexes[idx] = entry;
-		}
-	}
-}
-
-int SceneInfo::getRouteFlags(const Common::Point &src, const Common::Point &dest, 
-		MSurface &depthSurface) {
-	int result = 0x8000;
-	bool flag = false;
-
-	int xDiff = ABS(dest.x - src.x);
-	int yDiff = ABS(dest.y - src.y);
-	int xDirection = dest.x >= src.x ? 1 : -1;
-	int yDirection = dest.y >= src.y ? depthSurface.w : -depthSurface.w;
-	int majorDiff = 0;
-	if (dest.x < src.x)
-		majorDiff = MAX(xDiff, yDiff);
-	++xDiff;
-	++yDiff;
-
-	byte *srcP = depthSurface.getBasePtr(src.x, src.y);
-
-	int totalCtr = majorDiff;
-	for (int xCtr = 0; xCtr < xDiff; ++xCtr, srcP += xDirection) {
-		totalCtr += yDiff;
-
-		if ((*srcP & 0x80) == 0)
-			flag = false;
-		else if (!flag) {
-			flag = true;
-			result -= 0x4000;
-			if (result == 0)
-				break;
-		}
-
-		while (totalCtr >= xDiff) {
-			totalCtr -= xDiff;
-
-			if ((*srcP & 0x80) == 0)
-				flag = false;
-			else if (!flag) {
-				flag = true;
-				result -= 0x4000;
-				if (result == 0)
-					break;
-			}
-
-			srcP += yDirection;
-		}
-		if (result == 0)
-			break;
-	}
-
-	return result;
-}
-
 /*------------------------------------------------------------------------*/
 
 SceneInfo *SceneInfo::init(MADSEngine *vm) {
@@ -225,7 +135,7 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
 
 	// Load the set of objects that are associated with the scene
 	for (int i = 0; i < 20; ++i) {
-		SceneNode node;
+		WalkNode node;
 		node.load(infoStream);
 		
 		if (i < nodeCount)
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index d7c008b..33c053f 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -34,6 +34,7 @@
 #include "mads/game_data.h"
 #include "mads/hotspots.h"
 #include "mads/messages.h"
+#include "mads/rails.h"
 #include "mads/user_interface.h"
 
 namespace MADS {
@@ -116,25 +117,6 @@ struct ARTHeader {
 	void load(Common::SeekableReadStream *f);
 };
 
-class SceneNode {
-public:
-	Common::Point _walkPos;
-	int _indexes[MAX_ROUTE_NODES];
-	bool _active;
-
-	/**
-	 * Constructor
-	 */
-	SceneNode() : _active(false) {}
-
-	/**
-	 * Loads the scene node
-	 */
-	void load(Common::SeekableReadStream *f);
-};
-typedef Common::Array<SceneNode> SceneNodeList;
-
-
 /**
  * Handles general data for a given scene
  */
@@ -179,7 +161,7 @@ public:
 
 	int _usageIndex;
 	Common::Array<RGB4> _palAnimData;
-	SceneNodeList _nodes;
+	WalkNodeList _nodes;
 public:
 	/**
 	 * Destructor
@@ -198,11 +180,6 @@ public:
 		MSurface &depthSurface, MSurface &bgSurface);
 
 	/**
-	 * Set up a route node
-	 */
-	void setRouteNode(int nodeIndex, const Common::Point &pt, MSurface &depthSurface);
-
-	/**
 	* Loads the given surface with depth information of a given scene
 	*/
 	virtual void loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream) = 0;


Commit: 87c97a1bcba272245865b8f221ed38d7e7b29e12
    https://github.com/scummvm/scummvm/commit/87c97a1bcba272245865b8f221ed38d7e7b29e12
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-29T22:31:55+01:00

Commit Message:
MADS: Implement two stubs in scene 207 (which is now complete)

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 61ce589..f00aae4 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1250,9 +1250,8 @@ void Scene207::enter() {
 	if (_vultureFl) {
 		_globals._spriteIndexes[16] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 30, 0, 0, 400);
 		_vultureTime = _game._player._priorTimer;
-
-		int idx = _scene->_dynamicHotspots.add(389, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 254, 94, FACING_WEST);
+		_vultureHotspotId = _scene->_dynamicHotspots.add(389, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(_vultureHotspotId, 254, 94, FACING_WEST);
 	}
 
 	if (_spiderFl) {
@@ -1280,14 +1279,29 @@ void Scene207::enter() {
 	_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 70);
 }
 
+void Scene207::moveVulture() {
+	_scene->_sequences.remove(_globals._spriteIndexes[16]);
+	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
+	_vm->_sound->command(43);
+	_vultureFl = false;
+	_vultureTime = _game._player._priorTimer;
+	_scene->_dynamicHotspots.remove(_vultureHotspotId);
+}
+
+void Scene207::moveSpider() {
+	_scene->_sequences.remove(_globals._spriteIndexes[19]);
+	_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 5, 1, 0, 0);
+	_spiderFl = false;
+	_spiderTime = _game._player._priorTimer;
+	_scene->_dynamicHotspots.remove(_spiderHotspotId);
+}
+
 void Scene207::step() {
-	if (!_vultureFl) {
-		warning("TODO: sub3AD90(...)");
-	}
+	if (!_vultureFl)
+		moveVulture();
 
-	if (_spiderFl) {
-		warning("TODO: sub3ADD6(...)");
-	}
+	if (_spiderFl)
+		moveSpider();
 
 	if (_game._trigger == 70) {
 		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 10, 0, 0, 0);
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 1c19ae4..84cd245 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -114,10 +114,14 @@ public:
 
 class Scene207: public Scene2xx {
 	bool _vultureFl, _spiderFl, _eyeFl;
-	int _spiderHotspotId;
+	int _spiderHotspotId, _vultureHotspotId;
 	int32 _spiderTime, _vultureTime;
+
+	void moveVulture();
+	void moveSpider();
+
 public:
-	Scene207(MADSEngine *vm) : Scene2xx(vm), _vultureFl(false), _spiderFl(false), _spiderHotspotId(-1), _spiderTime(0), _vultureTime(0) {}
+	Scene207(MADSEngine *vm) : Scene2xx(vm), _vultureFl(false), _spiderFl(false), _spiderHotspotId(-1), _vultureHotspotId(-1), _spiderTime(0), _vultureTime(0) {}
 	virtual void setup();
 	virtual void enter();
 	virtual void step();


Commit: 03af091a16c937844eb3bd33f7870de79e1cc8b5
    https://github.com/scummvm/scummvm/commit/03af091a16c937844eb3bd33f7870de79e1cc8b5
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-29T22:47:21+01:00

Commit Message:
MADS: Remove some magic values related to verbs

Changed paths:
    engines/mads/action.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/scene_data.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index c762b9b..240b493 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -58,7 +58,7 @@ void MADSAction::clear() {
 	_hotspotId = -1;
 	_v86F3A = -1;
 	_v86F4C = -1;
-	_action._verbId = -1;
+	_action._verbId = VERB_NONE;
 	_action._objectNameId = -1;
 	_action._indirectObjectId = -1;
 	_textChanged = true;
@@ -89,7 +89,7 @@ void MADSAction::set() {
 	bool flag = false;
 	_statusText = "";
 
-	_action._verbId = -1;
+	_action._verbId = VERB_NONE;
 	_action._objectNameId = -1;
 	_action._indirectObjectId = -1;
 
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index f00aae4..79143a9 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -492,7 +492,7 @@ void Scene202::step() {
 		
 		if (_globals[kMeteorologistWatch] == 1) {
 			MADSAction *action = _game._player._action;
-			action->_activeAction._verbId = 3;
+			action->_activeAction._verbId = VERB_LOOK;
 			action->_activeAction._objectNameId = 39;
 			action->_activeAction._indirectObjectId = 438;
 			_game._triggerSetupMode = KERNEL_TRIGGER_PARSER;
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index abe0b7b..4c19202 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -42,7 +42,7 @@ KernelMessage::KernelMessage() {
 	_timeout = 0;
 	_trigger = 0;
 	_abortMode = KERNEL_TRIGGER_PARSER;
-	_actionDetails._verbId = 0;
+	_actionDetails._verbId = VERB_NONE;
 	_actionDetails._objectNameId = 0;
 	_actionDetails._indirectObjectId = 0;
 }


Commit: 0f3d4c02ad6bc3e81381e0efea4c66fba7f8a018
    https://github.com/scummvm/scummvm/commit/0f3d4c02ad6bc3e81381e0efea4c66fba7f8a018
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-30T00:01:29+01:00

Commit Message:
MADS: Implement Scene208::updateTrap()

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 79143a9..9421eae 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -804,8 +804,8 @@ void Scene202::actions() {
 				_game._player._visible = false;
 				_game._player._stepEnabled = false;
 
-				int idx = _scene->_dynamicHotspots.add(199, 79, -1, Common::Rect(241, 68, 12, 54));
-				_ladderHotspotId = _scene->_dynamicHotspots.setPosition(idx, 246, 124, FACING_NORTH);
+				_ladderHotspotId = _scene->_dynamicHotspots.add(199, 79, -1, Common::Rect(241, 68, 12, 54));
+				_scene->_dynamicHotspots.setPosition(_ladderHotspotId, 246, 124, FACING_NORTH);
 				_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
 				_scene->_sequences.setDepth(_globals._spriteIndexes[23], 1);
 				_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 1);
@@ -1408,6 +1408,36 @@ void Scene208::setup() {
 	_scene->addActiveVocab(NOUN_D);
 }
 
+void Scene208::updateTrap() {
+	if (_globals[kRhotundaStatus] == 1) {
+		_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 0, 0, 24);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[16], 5);
+		int idx = _scene->_dynamicHotspots.add(424, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, 100, 146, FACING_NORTH);
+		_scene->_hotspots.activate(414, false);
+		return;
+	}
+
+	switch (_globals[35]) {
+	case 0: {
+		_globals._spriteIndexes[17] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[17], 15);
+		int idx = _scene->_dynamicHotspots.add(426, 13, _globals._spriteIndexes[17], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, 60, 152, FACING_NORTH);
+		}
+		break;
+	case 2: {
+		_scene->_sequences.setDepth(_globals._spriteIndexes[18], 15);
+		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+		_scene->_hotspots.activate(414, false);
+		int idx = _scene->_dynamicHotspots.add(425, 13, _globals._spriteIndexes[17], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, 100, 146, FACING_NORTH);
+		_scene->_dynamicHotspots[idx]._articleNumber = 5;
+		}
+		break;
+	}
+}
+
 void Scene208::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('a', 1), 0);
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 0), 0);
@@ -1415,7 +1445,7 @@ void Scene208::enter() {
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 2), 0);
 	_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RXMBD_8");
 
-	warning("TODO: sub34648()");
+	updateTrap();
 
 	_globals._v0 = 0;
 	_globals._frameTime = 0;
@@ -1479,7 +1509,7 @@ void Scene208::step() {
 		if ((_game._trigger & 0xFF) == 81) {
 			_scene->_sequences.remove(_globals._spriteIndexes[15]);
 			_globals[kRhotundaStatus] = 1;
-			warning("TODO: sub34648(...)");
+			updateTrap();
 			_scene->_sequences.addTimer(90, 82);
 		}
 	} else {
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 84cd245..21d1028 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -50,7 +50,9 @@ public:
 };
 
 class Scene201: public Scene2xx {
+private:
 	bool _pterodactylFlag;
+
 public:
 	Scene201(MADSEngine *vm) : Scene2xx(vm), _pterodactylFlag(false) {}
 	virtual void setup();
@@ -89,6 +91,7 @@ public:
 class Scene203: public Scene2xx {
 private:
 	bool _rhotundaEat2Fl, _rhotundaEatFl;
+
 public:
 	Scene203(MADSEngine *vm) : Scene2xx(vm), _rhotundaEat2Fl(false), _rhotundaEatFl(false) {}
 	virtual void setup();
@@ -100,7 +103,9 @@ public:
 };
 
 class Scene205: public Scene2xx {
+private:
 	uint32 _lastFishTime, _chickenTime;
+
 public:
 	Scene205(MADSEngine *vm) : Scene2xx(vm), _lastFishTime(0), _chickenTime(0) {}
 
@@ -113,6 +118,7 @@ public:
 };
 
 class Scene207: public Scene2xx {
+private:
 	bool _vultureFl, _spiderFl, _eyeFl;
 	int _spiderHotspotId, _vultureHotspotId;
 	int32 _spiderTime, _vultureTime;
@@ -131,6 +137,9 @@ public:
 };
 
 class Scene208: public Scene2xx {
+private:
+	void updateTrap();
+
 public:
 	Scene208(MADSEngine *vm) : Scene2xx(vm) {}
 	virtual void setup();


Commit: 32b9530789e1c308e3afe849c27c21285dfe1ab3
    https://github.com/scummvm/scummvm/commit/32b9530789e1c308e3afe849c27c21285dfe1ab3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-29T19:26:05-04:00

Commit Message:
MADS: Fixes for the pathfinder

Changed paths:
    engines/mads/rails.cpp
    engines/mads/rails.h
    engines/mads/scene_data.h



diff --git a/engines/mads/rails.cpp b/engines/mads/rails.cpp
index 0baaa12..4daa774 100644
--- a/engines/mads/rails.cpp
+++ b/engines/mads/rails.cpp
@@ -114,7 +114,7 @@ void Rails::setupRouteNode(int *routeIndexP, int nodeIndex, int flags, int route
 		for (int idx = _nodes.size() - 2; idx > 0; --idx) {
 			int nodePos = idx - 1;
 			if (!_nodes[nodePos]._active && ((currentNode._distances[nodePos] & flags) != 0))
-				setupRouteNode(routeIndexP, nodePos, 0x8000, distanceVal & 0x3fff);
+				setupRouteNode(routeIndexP, nodePos, 0x8000, routeLength + distanceVal & 0x3fff);
 		}
 	}
 
@@ -209,9 +209,10 @@ void Rails::setNodePosition(int nodeIndex, const Common::Point &pt) {
 				hypotenuse = 0x3FFF;
 
 			entry = hypotenuse | flags;
-			_nodes[idx]._distances[nodeIndex] = entry;
-			_nodes[nodeIndex]._distances[idx] = entry;
 		}
+
+		_nodes[idx]._distances[nodeIndex] = entry;
+		_nodes[nodeIndex]._distances[idx] = entry;
 	}
 }
 
@@ -223,15 +224,15 @@ int Rails::getRouteFlags(const Common::Point &src, const Common::Point &dest) {
 	int yDiff = ABS(dest.y - src.y);
 	int xDirection = dest.x >= src.x ? 1 : -1;
 	int yDirection = dest.y >= src.y ? _depthSurface->w : -_depthSurface->w;
-	int majorDiff = 0;
+	int minorDiff = 0;
 	if (dest.x < src.x)
-		majorDiff = MAX(xDiff, yDiff);
+		minorDiff = MIN(xDiff, yDiff);
 	++xDiff;
 	++yDiff;
 
 	byte *srcP = _depthSurface->getBasePtr(src.x, src.y);
 
-	int totalCtr = majorDiff;
+	int totalCtr = minorDiff;
 	for (int xCtr = 0; xCtr < xDiff; ++xCtr, srcP += xDirection) {
 		totalCtr += yDiff;
 
diff --git a/engines/mads/rails.h b/engines/mads/rails.h
index 026edda..55f6f8b 100644
--- a/engines/mads/rails.h
+++ b/engines/mads/rails.h
@@ -34,7 +34,7 @@ namespace MADS {
 class WalkNode {
 public:
 	Common::Point _walkPos;
-	int _distances[MAX_ROUTE_NODES];
+	uint16 _distances[MAX_ROUTE_NODES];
 	bool _active;
 
 	/**
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 33c053f..81c24ed 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -130,9 +130,6 @@ class SceneInfo {
 
 		void load(Common::SeekableReadStream *f);
 	};
-
-
-	int getRouteFlags(const Common::Point &src, const Common::Point &dest, MSurface &depthSurface);
 protected:
 	MADSEngine *_vm;
 


Commit: 89af9dde8c412b4d11cd0107fe20f9bbbfd2e3bc
    https://github.com/scummvm/scummvm/commit/89af9dde8c412b4d11cd0107fe20f9bbbfd2e3bc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-29T22:28:22-04:00

Commit Message:
MADS: Implemented message loading/decoding

Changed paths:
    engines/mads/dialogs.cpp
    engines/mads/dialogs.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/nebular/game_nebular.cpp



diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index c5e99f8..04e89fa 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -342,7 +342,8 @@ Dialogs::Dialogs(MADSEngine *vm): _vm(vm) {
 }
 
 void Dialogs::show(int msgId) {
-
+	Common::StringArray msg = _vm->_game->getMessage(msgId);
+	warning("%s\n", msg[0].c_str());
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index 3f623a6..35e4a85 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -190,6 +190,7 @@ public:
 
 	virtual void showDialog() = 0;
 	virtual void showPicture(int objId, int msgId, int arg3 = 0) = 0;
+
 	void show(int msgId);
 };
 
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index f81c752..33cb52c 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -21,7 +21,9 @@
  */
 
 #include "common/scummsys.h"
+#include "common/memstream.h"
 #include "mads/mads.h"
+#include "mads/compression.h"
 #include "mads/game.h"
 #include "mads/game_data.h"
 #include "mads/events.h"
@@ -329,4 +331,51 @@ void Game::loadQuotes() {
 	f.close();
 }
 
+Common::StringArray Game::getMessage(uint32 id) {
+	File f("*MESSAGES.DAT");
+	int count = f.readUint16LE();
+
+	for (int idx = 0; idx < count; ++idx) {
+		uint32 itemId = f.readUint32LE();
+		uint32 offset = f.readUint32LE();
+		uint16 size = f.readUint16LE();
+
+		if (itemId == id) {
+			// Get the source buffer size
+			uint16 sizeIn;
+			if (idx == (count - 1)) {
+				sizeIn = f.size() - offset;
+			} else {
+				f.skip(4);
+				uint32 nextOffset = f.readUint32LE();
+				sizeIn = nextOffset - offset;
+			}
+
+			// Get the compressed data
+			f.seek(offset);
+			byte *bufferIn = new byte[sizeIn];
+			f.read(bufferIn, sizeIn);
+
+			// Decompress it
+			char *bufferOut = new char[size];
+			FabDecompressor fab;
+			fab.decompress(bufferIn, sizeIn, (byte *)bufferOut, size);
+
+			// Form the output string list
+			Common::StringArray result;
+			const char *p = bufferOut;
+			while (p < (bufferOut + size)) {
+				result.push_back(p);
+				p += strlen(p) + 1;
+			}
+
+			delete[] bufferIn;
+			delete[] bufferOut;
+			return result;
+		}
+	}
+
+	error("Invalid message Id specified");
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 9da2694..4521ad6 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -150,6 +150,7 @@ public:
 
 	uint32 getQuotesSize() { return _quotes.size(); }
 	const Common::String &getQuote(uint32 index) { return _quotes[index - 1]; }
+	Common::StringArray getMessage(uint32 id);
 
 	/**
 	* Standard object handling across the game
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 34af685..2c6be6c 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -52,6 +52,8 @@ ProtectionResult GameNebular::checkCopyProtection() {
 	dlg->show();
 	delete dlg;
 	*/
+	// Debug
+	_vm->_dialogs->show(1);
 
 	// DEBUG: Return that copy protection failed
 	return PROTECTION_SUCCEED;


Commit: fc61e79f29e1f9e734fc05a737849f5952450781
    https://github.com/scummvm/scummvm/commit/fc61e79f29e1f9e734fc05a737849f5952450781
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-30T11:51:36+02:00

Commit Message:
MADS: Implement Scene208::subAction()

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 9421eae..ccf2bb5 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1530,6 +1530,83 @@ void Scene208::preActions() {
 		player._walkOffScreenSceneId = 207;
 }
 
+void Scene208::subAction(int mode) {
+	int nextTrigger;
+
+	switch (_game._trigger) {
+	case 0:
+		_game._player._stepEnabled = false;
+		_game._player._visible   = false;
+		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 1, 0, 0);
+		_scene->_sequences.setMsgLayout(_globals._spriteIndexes[20]);
+
+		if ((mode == 1) || (mode == 2))
+			nextTrigger = 1;
+		else
+			nextTrigger = 2;
+
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[20], SM_0, 0, nextTrigger);
+		break;
+
+	case 1: {
+		int oldVal = _globals._spriteIndexes[20];
+		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 12, 3, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[20], 3, 4);
+		_scene->_sequences.setMsgLayout(_globals._spriteIndexes[20]);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[20], oldVal);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[20], SM_0, 0, 2);
+		_vm->_sound->command(20);
+		}
+		break;
+
+	case 2: {
+		switch (mode) {
+		case 1:
+			_game._objects.addToInventory(6);
+			_scene->_sequences.remove(_globals._spriteIndexes[17]);
+			_globals[kLeavesStatus] = 1;
+			break;
+
+		case 2:
+			_game._objects.setRoom(6, 1);
+			_globals[kLeavesStatus] = 2;
+			updateTrap();
+			break;
+
+		case 3:
+			_scene->_sequences.remove(_globals._spriteIndexes[18]);
+			_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
+			_game._objects.removeFromInventory(10, 1);
+			_vm->_sound->command(34);
+			break;
+
+		case 4:
+			_game._objects.removeFromInventory(1, 1);
+			_vm->_sound->command(33);
+			break;
+
+		case 5:
+			_game._objects.removeFromInventory(2, 1);
+			_vm->_sound->command(33);
+			break;
+		}
+
+		int oldVal = _globals._spriteIndexes[20];
+		_globals._spriteIndexes[20] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[5], false, 6, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[20], 1, 3);
+		_scene->_sequences.setMsgLayout(_globals._spriteIndexes[20]);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[20], oldVal);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[20], SM_0, 0, 3);
+		}
+		break;
+
+	case 3:
+		_game._player._visible   = true;
+		_game._player._stepEnabled = true;
+		break;
+	}
+}
+
 void Scene208::actions() {
 	if (_action.isAction(0x18C, 0x19F)) {
 		if (_globals[kRhotundaStatus])
@@ -1544,20 +1621,20 @@ void Scene208::actions() {
 	} else if (_action.isAction(0x18C, 0x83)) {
 		_scene->_nextSceneId = 212;
 	} else if (_action.isAction(VERB_TAKE, 0x1AA) && (!_globals[kLeavesStatus] || _game._trigger)) {
-		warning("TODO: sub3B282(1);");
+		subAction(1);
 		if (_game._player._stepEnabled)
 			_vm->_dialogs->showPicture(OBJ_BIG_LEAVES, 0x326, 0);
 	} else if (_action.isAction(VERB_PUT, 0x23, 0x19E) && (_globals[kLeavesStatus] == 1 || _game._trigger)) {
-		warning("TODO: sub3B282(2);");
+		subAction(2);
 	} else if (_action.isAction(VERB_PUT, 0x17A, 0x1A9)) {
-		warning("TODO: sub3B282(3);");
+		subAction(3);
 		if (_game._player._stepEnabled) {
 			_game._player._stepEnabled = false;
 			_globals._v0 = true;
 			_game._player.walk(Common::Point(20, 148), FACING_EAST);
 		}
 	} else if (_action.isAction(VERB_PUT, 0x35, 0x1A9)) {
-		warning("TODO: sub3B282(4);");
+		subAction(4);
 		if (_game._player._stepEnabled) {
 			_vm->_dialogs->show(0x514C);
 		}
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 21d1028..6d71665 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -139,6 +139,7 @@ public:
 class Scene208: public Scene2xx {
 private:
 	void updateTrap();
+	void subAction(int mode);
 
 public:
 	Scene208(MADSEngine *vm) : Scene2xx(vm) {}


Commit: 30b1bd99eb9ddc847c911bc012b14c3fff66ead9
    https://github.com/scummvm/scummvm/commit/30b1bd99eb9ddc847c911bc012b14c3fff66ead9
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-30T12:05:43+02:00

Commit Message:
MADS: Reduce the scope of a variable in scene 208::subAction()

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index ccf2bb5..2281568 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1531,21 +1531,22 @@ void Scene208::preActions() {
 }
 
 void Scene208::subAction(int mode) {
-	int nextTrigger;
 
 	switch (_game._trigger) {
-	case 0:
+	case 0: {
 		_game._player._stepEnabled = false;
 		_game._player._visible   = false;
 		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 1, 0, 0);
 		_scene->_sequences.setMsgLayout(_globals._spriteIndexes[20]);
 
+		int nextTrigger;
 		if ((mode == 1) || (mode == 2))
 			nextTrigger = 1;
 		else
 			nextTrigger = 2;
 
 		_scene->_sequences.addSubEntry(_globals._spriteIndexes[20], SM_0, 0, nextTrigger);
+		}
 		break;
 
 	case 1: {
@@ -1601,7 +1602,7 @@ void Scene208::subAction(int mode) {
 		break;
 
 	case 3:
-		_game._player._visible   = true;
+		_game._player._visible = true;
 		_game._player._stepEnabled = true;
 		break;
 	}


Commit: 49310e4a8eb41aa33eab3d75a6bcfb6d0d89333a
    https://github.com/scummvm/scummvm/commit/49310e4a8eb41aa33eab3d75a6bcfb6d0d89333a
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-03-30T21:16:45+02:00

Commit Message:
MADS: Some more rework in scene 208

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 2281568..e8d8a28 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1447,8 +1447,8 @@ void Scene208::enter() {
 
 	updateTrap();
 
-	_globals._v0 = 0;
-	_globals._frameTime = 0;
+	_rhotundaTurnFl = false;
+	_boundingFl = false;
 	_scene->_kernelMessages._talkFont = _vm->_font->getFont(FONT_INTERFACE);
 	_scene->_textSpacing = 0;
 
@@ -1479,41 +1479,38 @@ void Scene208::enter() {
 }
 
 void Scene208::step() {
-	if ((_globals._frameTime & 0xFFFF)  && ((_globals._frameTime >> 16) <= _scene->_activeAnimation->getCurrentFrame())) {
-		_globals._frameTime = (_globals._frameTime & 0xFFFF) | (_scene->_activeAnimation->getCurrentFrame() << 16);
+	if (_boundingFl  && (_rhotundaTime <= _scene->_activeAnimation->getCurrentFrame())) {
+		_rhotundaTime = _scene->_activeAnimation->getCurrentFrame();
 
-		if (_scene->_activeAnimation->getCurrentFrame() == 125)
+		if (_rhotundaTime == 125)
 			_scene->_sequences.remove(_globals._spriteIndexes[19]);
 	}
 
-	if (_globals._v0 == 0)
+	if (!_rhotundaTurnFl)
 		return;
 
 	if ((_game._player._playerPos != Common::Point(20, 148)) || (_game._player._facing != FACING_EAST))
 		return;
 
-	if ((_game._trigger == 0) && ((_globals._frameTime & 0xFFFF) != 0))
+	if ((_game._trigger == 0) && _boundingFl)
 		return;
 	
-	_globals._frameTime |= 0xFFFF;
+	_boundingFl = true;
 	
-	if (_game._trigger == 82) {
-		_game._player._stepEnabled = true;
-		return;
-	}
-	
-	if (_game._trigger > 82)
-		return;
-	
-	if (_game._trigger & 0xFF) {
-		if ((_game._trigger & 0xFF) == 81) {
-			_scene->_sequences.remove(_globals._spriteIndexes[15]);
-			_globals[kRhotundaStatus] = 1;
-			updateTrap();
-			_scene->_sequences.addTimer(90, 82);
-		}
-	} else {
+	switch (_game._trigger) {
+	case 0:
 		_scene->loadAnimation(formAnimName('A', -1), 81);
+		_rhotundaTime = 0;
+		break;
+	case 81:
+		_scene->_sequences.remove(_globals._spriteIndexes[15]);
+		_globals[kRhotundaStatus] = 1;
+		updateTrap();
+		_scene->_sequences.addTimer(90, 82);
+		break;
+	case 82:
+		_game._player._stepEnabled = true;
+		break;
 	}
 }
 
@@ -1539,16 +1536,15 @@ void Scene208::subAction(int mode) {
 		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 1, 0, 0);
 		_scene->_sequences.setMsgLayout(_globals._spriteIndexes[20]);
 
-		int nextTrigger;
+		int abortVal;
 		if ((mode == 1) || (mode == 2))
-			nextTrigger = 1;
+			abortVal = 1;
 		else
-			nextTrigger = 2;
+			abortVal = 2;
 
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[20], SM_0, 0, nextTrigger);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[20], SM_0, 0, abortVal);
 		}
 		break;
-
 	case 1: {
 		int oldVal = _globals._spriteIndexes[20];
 		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 12, 3, 0, 0);
@@ -1559,7 +1555,6 @@ void Scene208::subAction(int mode) {
 		_vm->_sound->command(20);
 		}
 		break;
-
 	case 2: {
 		switch (mode) {
 		case 1:
@@ -1567,25 +1562,21 @@ void Scene208::subAction(int mode) {
 			_scene->_sequences.remove(_globals._spriteIndexes[17]);
 			_globals[kLeavesStatus] = 1;
 			break;
-
 		case 2:
 			_game._objects.setRoom(6, 1);
 			_globals[kLeavesStatus] = 2;
 			updateTrap();
 			break;
-
 		case 3:
 			_scene->_sequences.remove(_globals._spriteIndexes[18]);
 			_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 			_game._objects.removeFromInventory(10, 1);
 			_vm->_sound->command(34);
 			break;
-
 		case 4:
 			_game._objects.removeFromInventory(1, 1);
 			_vm->_sound->command(33);
 			break;
-
 		case 5:
 			_game._objects.removeFromInventory(2, 1);
 			_vm->_sound->command(33);
@@ -1600,7 +1591,6 @@ void Scene208::subAction(int mode) {
 		_scene->_sequences.addSubEntry(_globals._spriteIndexes[20], SM_0, 0, 3);
 		}
 		break;
-
 	case 3:
 		_game._player._visible = true;
 		_game._player._stepEnabled = true;
@@ -1631,7 +1621,7 @@ void Scene208::actions() {
 		subAction(3);
 		if (_game._player._stepEnabled) {
 			_game._player._stepEnabled = false;
-			_globals._v0 = true;
+			_rhotundaTurnFl = true;
 			_game._player.walk(Common::Point(20, 148), FACING_EAST);
 		}
 	} else if (_action.isAction(VERB_PUT, 0x35, 0x1A9)) {
@@ -1640,7 +1630,7 @@ void Scene208::actions() {
 			_vm->_dialogs->show(0x514C);
 		}
 	} else if (_action.isAction(VERB_PUT, 0x65, 0x1A9)) {
-		warning("TODO: sub3B282(5);");
+		subAction(5);
 		if (_game._player._stepEnabled) {
 			_vm->_dialogs->show(0x514C);
 		}
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 6d71665..a749e8a 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -138,11 +138,14 @@ public:
 
 class Scene208: public Scene2xx {
 private:
+	bool _rhotundaTurnFl, _boundingFl;
+	int32 _rhotundaTime;
+
 	void updateTrap();
 	void subAction(int mode);
 
 public:
-	Scene208(MADSEngine *vm) : Scene2xx(vm) {}
+	Scene208(MADSEngine *vm) : Scene2xx(vm), _rhotundaTurnFl(false), _boundingFl(false), _rhotundaTime(0) {}
 	virtual void setup();
 	virtual void enter();
 	virtual void step();


Commit: 57f1c6e9d9ff82513205a1dc8ec05c335486759f
    https://github.com/scummvm/scummvm/commit/57f1c6e9d9ff82513205a1dc8ec05c335486759f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-30T21:10:07-04:00

Commit Message:
MADS: Implemented message parser for action dialog display

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h
    engines/mads/dialogs.cpp
    engines/mads/dialogs.h
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/dialogs_nebular.h
    engines/mads/nebular/game_nebular.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 240b493..35e989b 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -285,7 +285,7 @@ void MADSAction::startAction() {
 
 	// Copy the action to be active
 	_activeAction = _action;
-	_dialogTitle = _statusText;
+	_sentence = _statusText;
 
 	if ((_actionMode2 == ACTIONMODE2_4) && (_v86F42 == 0))
 		_v8453A = -1;
diff --git a/engines/mads/action.h b/engines/mads/action.h
index 4f748f2..e7a3323 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -83,7 +83,6 @@ class MADSAction {
 private:
 	MADSEngine *_vm;
 	Common::String _statusText;
-	Common::String _dialogTitle;
 
 	void appendVocab(int vocabId, bool capitalise = false);
 
@@ -101,6 +100,7 @@ public:
 	int _statusTextIndex;
 	int _hotspotId;
 	ActionSavedFields _savedFields;
+	Common::String _sentence;
 
 	// Unknown fields
 	int16 _v86F3A;
diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index 04e89fa..1215df3 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -157,6 +157,10 @@ void TextDialog::underlineLine() {
 	_lineXp[_numLines] |= 0x80;
 }
 
+void TextDialog::downPixelLine() {
+	_lineXp[_numLines] |= 0x40;
+}
+
 void TextDialog::incNumLines() {
 	_lineWidth = 0;
 	_currentX = 0;
@@ -234,6 +238,18 @@ void TextDialog::addInput() {
 	incNumLines();
 }
 
+void TextDialog::addBarLine() {
+	if (_lineWidth > 0 || _currentX > 0)
+		incNumLines();
+
+	_lineXp[_numLines] = 0xFF;
+	incNumLines();
+}
+
+void TextDialog::setLineXp(int xp) {
+	_lineXp[_numLines] = xp;
+}
+
 void TextDialog::draw() {
 	if (!_lineWidth)
 		--_numLines;
@@ -302,6 +318,16 @@ void TextDialog::restorePalette() {
 	_vm->_palette->setPalette(_vm->_palette->_mainPalette, 248, 8);
 }
 
+void TextDialog::show() {
+	draw();
+	_vm->_events->showCursor();
+
+	while (!_vm->shouldQuit() && !_vm->_events->_keyPressed &&
+		!_vm->_events->_mouseClicked) {
+		_vm->_events->delay(1);
+	}
+}
+
 /*------------------------------------------------------------------------*/
 
 MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...): 
@@ -318,16 +344,6 @@ MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...):
 	va_end(va);
 }
 
-void MessageDialog::show() {
-	draw();
-	_vm->_events->showCursor();
-
-	while (!_vm->shouldQuit() && !_vm->_events->_keyPressed &&
-			!_vm->_events->_mouseClicked) {
-		_vm->_events->delay(1);
-	}
-}
-
 /*------------------------------------------------------------------------*/
 
 Dialogs *Dialogs::init(MADSEngine *vm) {
@@ -341,9 +357,4 @@ Dialogs::Dialogs(MADSEngine *vm): _vm(vm) {
 	_pendingDialog = DIALOG_NONE;
 }
 
-void Dialogs::show(int msgId) {
-	Common::StringArray msg = _vm->_game->getMessage(msgId);
-	warning("%s\n", msg[0].c_str());
-}
-
 } // End of namespace MADS
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index 35e4a85..fe6041e 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -86,16 +86,6 @@ enum {
 class TextDialog: protected Dialog {
 private:
 	/**
-	 * Increments the number of text lines the text dialog uses
-	 */
-	void incNumLines();
-
-	/**
-	 * Flags the previously added line to be underlined
-	 */
-	void underlineLine();
-
-	/**
 	 * Append text to the currently end line.
 	 */
 	void appendLine(const Common::String &line);
@@ -116,21 +106,6 @@ protected:
 	Common::String _lines[TEXT_DIALOG_MAX_LINES];
 	int _lineXp[TEXT_DIALOG_MAX_LINES];
 	byte _savedPalette[8 * 3];
-
-	/**
-	 * Add a new line to the dialog
-	 */
-	void addLine(const Common::String &line, bool underline = false);
-
-	/**
-	 * Adds one or more lines, word wrapping the passed text
-	 */
-	void wordWrap(const Common::String &line);
-
-	/**
-	 * Adds an input area following previously added text
-	 */
-	void addInput();
 public:
 	/**
 	 * Constructor
@@ -156,6 +131,48 @@ public:
 	 * Draw the dialog along with any input box
 	 */
 	void drawWithInput();
+
+	/**
+	* Add a new line to the dialog
+	*/
+	void addLine(const Common::String &line, bool underline = false);
+
+	/**
+	* Adds one or more lines, word wrapping the passed text
+	*/
+	void wordWrap(const Common::String &line);
+
+	/**
+	* Increments the number of text lines the text dialog uses
+	*/
+	void incNumLines();
+
+	/**
+	* Adds an input area following previously added text
+	*/
+	void addInput();
+
+	/**
+	 * Adds a bar line to separate sections of text 
+	 */
+	void addBarLine();
+
+	/**
+	* Flags the previously added line to be underlined
+	*/
+	void underlineLine();
+
+	void downPixelLine();
+
+	/**
+	 * Set the x position for the given line
+	 */
+	void setLineXp(int xp);
+
+	/**
+	* Show the dialog, and wait until a key or mouse press.
+	*/
+	void show();
 };
 
 class MessageDialog: protected TextDialog {
@@ -163,11 +180,6 @@ public:
 	MessageDialog(MADSEngine *vm, int lines, ...);
 
 	virtual ~MessageDialog() {}
-
-	/**
-	 * Show the dialog, and wait until a key or mouse press.
-	 */
-	void show();
 };
 
 enum DialogId {
@@ -185,13 +197,14 @@ public:
 public:
 	Common::Point _defaultPosition;
 	DialogId _pendingDialog;
+	int _indexList[10];
 
 	virtual ~Dialogs() {}
 
 	virtual void showDialog() = 0;
 	virtual void showPicture(int objId, int msgId, int arg3 = 0) = 0;
 
-	void show(int msgId);
+	virtual bool show(int msgId) = 0;
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 6dabbec..fea5fa5 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -22,9 +22,11 @@
 
 #include "common/scummsys.h"
 #include "common/config-manager.h"
+#include "common/util.h"
 #include "mads/mads.h"
 #include "mads/screen.h"
 #include "mads/msurface.h"
+#include "mads/staticres.h"
 #include "mads/nebular/dialogs_nebular.h"
 
 namespace MADS {
@@ -112,6 +114,181 @@ bool CopyProtectionDialog::getHogAnusEntry(HOGANUS &entry) {
 	return true;
 }
 
+/*------------------------------------------------------------------------*/
+
+bool DialogsNebular::show(int msgId) {
+	MADSAction &action = _vm->_game->_scene._action;
+	Common::StringArray msg = _vm->_game->getMessage(msgId);
+	Common::String title;
+	Common::String commandText;
+	Common::String valStr;
+	Common::String dialogText;
+	bool result = true;
+	bool centerFlag;
+	bool underlineFlag;
+	bool commandFlag;
+	bool crFlag;
+	TextDialog *dialog = nullptr;
+	_dialogWidth = 17; 
+	_capitalizationMode = kUppercase;
+
+	// Loop through the lines of the returned text
+	for (uint idx = 0; idx < msg.size(); ++idx) {
+		Common::String srcLine = msg[idx];
+
+		const char *srcP = srcLine.c_str();
+		commandFlag = false;
+		underlineFlag = false;
+		centerFlag = false;
+		crFlag = false;
+
+		// Loop through the text of the line
+		while (srcP < srcLine.c_str() + srcLine.size()) {
+			if (*srcP == '[') {
+				// Starting a command
+				commandText = "";
+				commandFlag = true;
+			} else if (*srcP == ']') {
+				// Ending a command
+				if (commandFlag) {
+					if (commandCheck("CENTER", valStr, commandText)) {
+						centerFlag = true;
+					} else if (commandCheck("TITLE", valStr, commandText)) {
+						centerFlag = true;
+						underlineFlag = true;
+						crFlag = true;
+						int v = atoi(valStr.c_str());
+						if (v != 0)
+							_dialogWidth = v;
+					} else if (commandCheck("CR", valStr, commandText)) {
+						if (centerFlag) {
+							crFlag = true;
+						} else {
+							dialog = new TextDialog(_vm, FONT_INTERFACE, _defaultPosition, _dialogWidth);
+							dialog->wordWrap(dialogText);
+							dialog->incNumLines();
+						}
+					} else if (commandCheck("ASK", valStr, commandText)) {
+						dialog->addInput();
+					} else if (commandCheck("VERB", valStr, commandText)) {
+						dialogText += getVocab(action._activeAction._verbId);
+					} else if (commandCheck("INDEX", valStr, commandText)) {
+						int idx = atoi(valStr.c_str());
+						if (_indexList[idx])
+							dialogText += getVocab(_indexList[idx]);
+					} else if (commandCheck("NUMBER", valStr, commandText)) {
+						int idx = atoi(valStr.c_str());
+						dialogText += Common::String::format("%.4d", _indexList[idx]);
+					} else if (commandCheck("NOUN1", valStr, commandText)) {
+						if (!textNoun(dialogText, 1, valStr))
+							dialogText += getVocab(action._activeAction._objectNameId);
+					} else if (commandCheck("NOUN2", valStr, commandText)) {
+						if (!textNoun(dialogText, 2, valStr))
+							dialogText += getVocab(action._activeAction._indirectObjectId);
+					} else if (commandCheck("PREP", valStr, commandText)) {
+						dialogText += kArticleList[action._savedFields._articleNumber];
+					} else if (commandCheck("SENTENCE", valStr, commandText)) {
+						dialogText += action._sentence;
+					} else if (commandCheck("WIDTH", valStr, commandText)) {
+						_dialogWidth = atoi(valStr.c_str());
+					} else if (commandCheck("BAR", valStr, commandText)) {
+						dialog->addBarLine();
+					} else if (commandCheck("UNDER", valStr, commandText)) {
+						underlineFlag = true;
+					} else if (commandCheck("DOWN", valStr, commandText)) {
+						dialog->downPixelLine();
+					} else if (commandCheck("TAB", valStr, commandText)) {
+						int xp = atoi(valStr.c_str());
+						dialog->setLineXp(xp);
+					}
+				}
+
+				commandFlag = false;
+			} else if (commandFlag) {
+				// Add the next character to the command
+				commandText += *srcP;
+			} else {
+				// Add to the text to be displayed in the dialog
+				dialogText += *srcP;
+			}
+
+			++srcP;
+		}
+
+		if (!dialog) {
+			dialog = new TextDialog(_vm, FONT_INTERFACE, _defaultPosition, _dialogWidth);
+		}
+
+		if (centerFlag) {
+			dialog->addLine(dialogText, underlineFlag);
+			if (crFlag)
+				dialog->incNumLines();
+		} else {
+			dialog->wordWrap(dialogText);
+		}
+	}
+
+	if (!centerFlag)
+		dialog->incNumLines();
+	
+	// Show the dialog
+	dialog->show();
+
+	delete dialog;
+	return result;
+}
+
+Common::String DialogsNebular::getVocab(int vocabId) {
+	assert(vocabId > 0);
+
+	Common::String vocab = _vm->_game->_scene.getVocab(vocabId);
+
+	switch (_capitalizationMode) {
+	case kUppercase:
+		vocab.toUppercase();
+		break;
+	case kLowercase:
+		vocab.toLowercase();
+		break;
+	case kUpperAndLower:
+		vocab.toLowercase();
+		vocab.setChar(toupper(vocab[0]), 0);
+	default:
+		break;
+	}
+
+	return vocab;
+}
+
+bool DialogsNebular::textNoun(Common::String &dialogText, int nounNum,
+		const Common::String &valStr) {
+	warning("TODO: textNoun");
+	return false;
+}
+
+bool DialogsNebular::commandCheck(const char *idStr, Common::String &valStr,
+		const Common::String &command) {
+	int idLen = strlen(idStr);
+	
+	valStr = (command.size() <= idLen) ? "" : Common::String(command.c_str() + idLen);
+
+	// Check whether the command starts with the given Id
+	int result = scumm_strnicmp(idStr, command.c_str(), idLen) == 0;
+	if (!result)
+		return false;
+
+	// It does, so set the command case mode
+	if (Common::isUpper(command[0]) && Common::isUpper(command[1])) {
+		_capitalizationMode = kUppercase;
+	} else if (Common::isUpper(command[0])) {
+		_capitalizationMode = kUpperAndLower;
+	} else {
+		_capitalizationMode = kLowercase;
+	}
+
+	return true;
+}
+
 
 } // End of namespace Nebular
 
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index c7b0e52..84bbaed 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -31,10 +31,21 @@ namespace MADS {
 
 namespace Nebular {
 
+enum CapitalizationMode { kUppercase = 0, kLowercase = 1, kUpperAndLower = 2 };
+
 class DialogsNebular: public Dialogs {
 	friend class Dialogs;
-protected:
+private:
+	int _dialogWidth;
+	CapitalizationMode _capitalizationMode;
+
 	DialogsNebular(MADSEngine *vm): Dialogs(vm) {}
+
+	Common::String getVocab(int vocabId);
+
+	bool textNoun(Common::String &dialogText, int nounNum, const Common::String &valStr);
+
+	bool commandCheck(const char *idStr, Common::String &valStr, const Common::String &command);
 public:
 	virtual void showDialog() {
 		warning("TODO: showDialog");
@@ -42,6 +53,7 @@ public:
 	virtual void showPicture(int objId, int msgId, int arg3) {
 		warning("TODO: showPicture");
 	}
+	virtual bool show(int id);
 };
 
 struct HOGANUS {
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 2c6be6c..34af685 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -52,8 +52,6 @@ ProtectionResult GameNebular::checkCopyProtection() {
 	dlg->show();
 	delete dlg;
 	*/
-	// Debug
-	_vm->_dialogs->show(1);
 
 	// DEBUG: Return that copy protection failed
 	return PROTECTION_SUCCEED;


Commit: 195c53a68853db6a77c6a63d392968ba912cf2f4
    https://github.com/scummvm/scummvm/commit/195c53a68853db6a77c6a63d392968ba912cf2f4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-30T22:37:08-04:00

Commit Message:
MADS: Added some missing code for scene change freeing

Changed paths:
    engines/mads/game.cpp
    engines/mads/nebular/game_nebular.cpp
    engines/mads/player.cpp
    engines/mads/player.h
    engines/mads/scene.cpp
    engines/mads/sprites.cpp
    engines/mads/sprites.h



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 33cb52c..fd03799 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -143,7 +143,7 @@ void Game::gameLoop() {
 			sectionLoop();
 		}
 
-		// TODO: Extra reset methods
+		_player.releasePlayerSprites();
 		_vm->_palette->unlock();
 		_vm->_events->waitCursor();
 		_vm->_events->freeCursors();
@@ -181,7 +181,7 @@ void Game::sectionLoop() {
 		_scene._sceneLogic->setup();
 		if (_player._spritesChanged || _player._loadsFirst) {
 			if (_player._spritesLoaded)
-				_scene._spriteSlots.releasePlayerSprites();
+				_player.releasePlayerSprites();
 			_vm->_palette->resetGamePalette(18, 10);
 			_scene._spriteSlots.reset();
 		} else {
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 34af685..638432a 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -270,7 +270,7 @@ void GameNebular::setSectionHandler() {
 
 void GameNebular::checkShowDialog() {
 	if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globals[5]) {
-		_scene._spriteSlots.releasePlayerSprites();
+		_player.releasePlayerSprites();
 		_vm->_dialogs->showDialog();
 		_vm->_dialogs->_pendingDialog = DIALOG_NONE;
 	}
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index e726c80..5546784 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -662,4 +662,19 @@ void Player::addWalker(int walker, int trigger) {
 	}
 }
 
+
+/**
+* Releases any sprites used by the player
+*/
+void Player::releasePlayerSprites() {
+	Scene &scene = _vm->_game->_scene;
+
+	if (_spritesLoaded && _numSprites > 0) {
+		int spriteEnd = _spritesStart + _numSprites - 1;
+		do {
+			scene._sprites.remove(spriteEnd);
+		} while (--spriteEnd >= _spritesStart);
+	}
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 986971b..8315206 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -205,6 +205,11 @@ public:
 	 * Add a walker to the current queue
 	 */
 	void addWalker(int walker, int trigger);
+
+	/**
+	* Delete any sprites used by the player
+	*/
+	void releasePlayerSprites();
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 83c0594..21d09fb 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -555,7 +555,21 @@ void Scene::updateCursor() {
 }
 
 void Scene::free() {
-	warning("TODO: Scene::free");
+	if (_animationData) {
+		delete _animationData;
+		_animationData = nullptr;
+	}
+	if (_activeAnimation) {
+		delete _activeAnimation;
+		_activeAnimation = nullptr;
+	}
+
+	_hotspots.clear();
+	_backgroundSurface.free();
+	_depthSurface.free();
+
+	delete _sceneInfo;
+	_sceneInfo = nullptr;
 }
 
 void Scene::changeDepthSurface(int arg1) {
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index c0467ff..226835b 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -186,20 +186,6 @@ void SpriteSlots::reset(bool flag) {
 	push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1));
 }
 
-/**
-* Releases any sprites used by the player
-*/
-void SpriteSlots::releasePlayerSprites() {
-	Player &player = _vm->_game->_player;
-
-	if (player._spritesLoaded && player._numSprites > 0) {
-		int spriteEnd = player._spritesStart + player._numSprites - 1;
-		do {
-			deleteEntry(spriteEnd);
-		} while (--spriteEnd >= player._spritesStart);
-	}
-}
-
 void SpriteSlots::deleteEntry(int index) {
 	remove_at(index);
 }
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index 2017961..a9b4e97 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -153,11 +153,6 @@ public:
 	void reset(bool flag = true);
 
 	/**
-	* Delete any sprites used by the player
-	*/
-	void releasePlayerSprites();
-
-	/**
 	* Delete a sprite entry
 	* @param index		Specifies the index in the array
 	*/


Commit: 87124b4380abf077a3c97f3997777228f7d825cf
    https://github.com/scummvm/scummvm/commit/87124b4380abf077a3c97f3997777228f7d825cf
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-03-30T23:03:11-04:00

Commit Message:
MADS: Fix for hotspot highlighting when mouse moves

Changed paths:
    engines/mads/events.cpp



diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 37a1eec..c61512c 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -197,7 +197,7 @@ void EventsManager::waitForNextFrame() {
 	_mouseClicked = mouseClicked;
 	_mouseReleased = mouseReleased;
 	_mouseButtons = mouseButtons;
-	_mouseMoved = _mouseClicked || _mouseReleased;
+	_mouseMoved |= _mouseClicked || _mouseReleased;
 }
 
 void EventsManager::initVars() {


Commit: 0c1001fbf4c37379ec685b036e63d6d59055997a
    https://github.com/scummvm/scummvm/commit/0c1001fbf4c37379ec685b036e63d6d59055997a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-01T22:50:03-04:00

Commit Message:
MADS: Minor variable renaming and remove incorrect variable set in scene loop

Changed paths:
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/scene.cpp
    engines/mads/screen.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index fd03799..2b42080 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -57,7 +57,7 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 	_vocabEmergency = false;
 	_aaName = "*I0.AA";
 	_priorFrameTimer = 0;
-	_updateSceneFlag = false;
+	_anyEmergency = false;
 	_triggerMode = KERNEL_TRIGGER_PARSER;
 	_triggerSetupMode = KERNEL_TRIGGER_PARSER;
 	_ticksExpiry = 0;
@@ -256,11 +256,11 @@ void Game::sectionLoop() {
 		_kernelMode = KERNEL_ACTIVE_CODE;
 		_scene._roomChanged = false;
 
-		if ((_quoteEmergency || _vocabEmergency) && !_updateSceneFlag) {
+		if ((_quoteEmergency || _vocabEmergency) && !_anyEmergency) {
 			_scene._currentSceneId = _scene._priorSceneId;
-			_updateSceneFlag = true;
+			_anyEmergency = true;
 		} else {
-			_updateSceneFlag = false;
+			_anyEmergency = false;
 			_scene.loop();
 		}
 
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 4521ad6..54aef44 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -77,7 +77,7 @@ protected:
 	Common::StringArray _quotes;
 	bool _quoteEmergency;
 	bool _vocabEmergency;
-	bool _updateSceneFlag;
+	bool _anyEmergency;
 
 	/**
 	 * Constructor
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 21d09fb..71e6873 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -263,8 +263,6 @@ bool Scene::getDepthHighBits(const Common::Point &pt) {
 }
 
 void Scene::loop() {
-	_nextSceneId = _currentSceneId;
-
 	while (!_vm->shouldQuit() && !_reloadSceneFlag && _nextSceneId == _currentSceneId) {
 		// Handle drawing a game frame
 		doFrame();
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 0c78b0c..8bb17d3 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -254,7 +254,7 @@ ScreenObjects::ScreenObjects(MADSEngine *vm) : _vm(vm) {
 	_objectY = -1;
 	_v8333C = false;
 	_v832EC = 0;
-	_v7FECA = 0;
+	_v7FECA = true;
 	_v7FED6 = 0;
 	_v8332A = 0;
 	_category = CAT_NONE;


Commit: 041773705be6dd1fb09d71e482f4974247cee61f
    https://github.com/scummvm/scummvm/commit/041773705be6dd1fb09d71e482f4974247cee61f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-02T20:28:57-04:00

Commit Message:
MADS: Fix/clean up ending of ScreenObjects::check

Changed paths:
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/screen.cpp
    engines/mads/screen.h
    engines/mads/user_interface.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 2b42080..2736e77 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -60,7 +60,6 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 	_anyEmergency = false;
 	_triggerMode = KERNEL_TRIGGER_PARSER;
 	_triggerSetupMode = KERNEL_TRIGGER_PARSER;
-	_ticksExpiry = 0;
 	_winStatus = 0;
 
 	// Load the inventory object list
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 54aef44..f41e7d2 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -138,7 +138,6 @@ public:
 	TriggerMode _triggerSetupMode;
 	uint32 _priorFrameTimer;
 	Common::String _aaName;
-	uint32 _ticksExpiry;
 	int _winStatus;
 public:
 	virtual ~Game();
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 71e6873..d37834a 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -582,4 +582,8 @@ void Scene::resetScene() {
 	_sequences.clear();
 }
 
+void Scene::backgroundAnimation() {
+	warning("TODO: Scene::backgroundAnimation");
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 1caba12..1b0c9c9 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -210,6 +210,8 @@ public:
 	void changeDepthSurface(int arg1);
 
 	void resetScene();
+
+	void backgroundAnimation();
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 8bb17d3..391ba71 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -266,6 +266,7 @@ ScreenObjects::ScreenObjects(MADSEngine *vm) : _vm(vm) {
 	_scrollerY = -1;
 	_milliTime = 0;
 	_eventFlag = false;
+	_baseTime = 0;
 }
 
 void ScreenObjects::add(const Common::Rect &bounds, Layer layer, ScrCategory category, int descId) {
@@ -343,7 +344,7 @@ void ScreenObjects::check(bool scanFlag) {
 	scene._action.refresh();
 
 	uint32 currentTicks = _vm->_events->getFrameCounter();
-	if (currentTicks >= _vm->_game->_ticksExpiry) {
+	if (currentTicks >= _baseTime) {
 		// Check the user interface slots to see if there's any slots that need to be expired
 		UISlots &uiSlots = userInterface._uiSlots;
 		for (uint idx = 0; idx <  uiSlots.size(); ++idx) {
@@ -354,12 +355,16 @@ void ScreenObjects::check(bool scanFlag) {
 				slot._slotType = ST_EXPIRED;
 		}
 
+		// TODO: The stuff here could probably be moved to Scene::doFrame
+		// Any background animation
+		scene.backgroundAnimation();
+
 		// Handle animating the selected inventory animation
 		userInterface.inventoryAnim();
 
-		// Set the next frame expiry
-		_vm->_game->_ticksExpiry = currentTicks + 6;
-	}	
+		// Set the base time
+		_baseTime = currentTicks + 6;
+	}
 }
 
 int ScreenObjects::scanBackwards(const Common::Point &pt, int layer) {
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index c733452..d292a7a 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -161,6 +161,7 @@ public:
 	int _uiCount;
 	uint32 _milliTime;
 	bool _eventFlag;
+	uint32 _baseTime;
 
 	/*
 	* Constructor
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index d0139e2..2cd1662 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -264,7 +264,7 @@ void UserInterface::setup(int id) {
 
 	scene._userInterface._uiSlots.clear();
 	scene._userInterface._uiSlots.fullRefresh();
-	_vm->_game->_ticksExpiry = _vm->_events->getFrameCounter();
+	_vm->_game->_screenObjects._baseTime = _vm->_events->getFrameCounter();
 	_highlightedCommandIndex = -1;
 	_highlightedActionIndex = -1;
 	_highlightedItemIndex = -1;
@@ -590,7 +590,7 @@ void UserInterface::noInventoryAnim() {
 
 	if (_invSpritesIndex >= 0) {
 		scene._sprites.remove(_invSpritesIndex);
-		_vm->_game->_ticksExpiry = _vm->_events->getFrameCounter();
+		_vm->_game->_screenObjects._baseTime = _vm->_events->getFrameCounter();
 		_invSpritesIndex = -1;
 	}
 


Commit: 3f8ee8fafa0166204a6c0b9ec311aa9fb0aa3c39
    https://github.com/scummvm/scummvm/commit/3f8ee8fafa0166204a6c0b9ec311aa9fb0aa3c39
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-02T21:24:22-04:00

Commit Message:
MADS: Cleanup of UISlots and flag types

Changed paths:
    engines/mads/animation.cpp
    engines/mads/player.cpp
    engines/mads/screen.cpp
    engines/mads/sequence.cpp
    engines/mads/sprites.cpp
    engines/mads/sprites.h
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index a8adfe3..f4fee20 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -403,7 +403,7 @@ void Animation::update() {
 
 	for (uint idx = 0; idx < scene._spriteSlots.size(); ++idx) {
 		if (scene._spriteSlots[idx]._seqIndex >= 0x80)
-			scene._spriteSlots[idx]._SlotType = ST_EXPIRED;
+			scene._spriteSlots[idx]._flags = IMG_ERASE;
 	}
 
 	// Validate the current frame
@@ -445,7 +445,7 @@ void Animation::update() {
 	if (paChanged) {
 		newIndex = scene._spriteSlots.add();
 		scene._spriteSlots[newIndex]._seqIndex = -1;
-		scene._spriteSlots[newIndex]._SlotType = ST_FULL_SCREEN_REFRESH;
+		scene._spriteSlots[newIndex]._flags = IMG_REFRESH;
 	}
 
 	// Main frame animation loop - frames get animated by being placed, as necessary, into the
@@ -463,7 +463,7 @@ void Animation::update() {
 					int seqIndex = _frameEntries[_oldFrameEntry]._seqIndex - scene._spriteSlots[index]._seqIndex;
 					if (seqIndex == 0x80) {
 						if (scene._spriteSlots[index] == _frameEntries[_oldFrameEntry]._spriteSlot) {
-							scene._spriteSlots[index]._SlotType = ST_NONE;
+							scene._spriteSlots[index]._flags = IMG_STATIC;
 							spriteSlotIndex = -1;
 						}
 					}
@@ -479,7 +479,7 @@ void Animation::update() {
 
 					SpriteAsset &spriteSet = *scene._sprites[
 						scene._spriteSlots[slotIndex]._spritesIndex];
-					slot._SlotType = spriteSet.isBackground() ? ST_BACKGROUND : ST_FOREGROUND;
+					slot._flags = spriteSet.isBackground() ? IMG_DELTA : IMG_UPDATE;
 				}
 				break;
 			}
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 5546784..a98fdb1 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -260,7 +260,7 @@ void Player::update() {
 	if (_forceRefresh || (_visible != _priorVisible)) {
 		int slotIndex = getSpriteSlot();
 		if (slotIndex >= 0)
-			scene._spriteSlots[slotIndex]._SlotType = ST_EXPIRED;
+			scene._spriteSlots[slotIndex]._flags = IMG_ERASE;
 
 		int newDepth = 1;
 		int yp = MAX(_playerPos.y, (int16)(MADS_SCENE_HEIGHT - 1));
@@ -278,7 +278,7 @@ void Player::update() {
 		if (_visible) {
 			// Player sprite needs to be rendered
 			SpriteSlot slot;
-			slot._SlotType = ST_FOREGROUND;
+			slot._flags = IMG_UPDATE;
 			slot._seqIndex = PLAYER_SEQ_INDEX;
 			slot._spritesIndex = _spritesStart + _spritesIdx;
 			slot._frameNumber = _mirror ? -_frameNumber : _frameNumber;
@@ -299,7 +299,7 @@ void Player::update() {
 
 				if (equal)
 					// Undo the prior expiry of the player sprite
-					s2._SlotType = ST_NONE;
+					s2._flags = IMG_STATIC;
 				else
 					slotIndex = -1;
 			}
@@ -532,7 +532,7 @@ int Player::getSpriteSlot() {
 
 	for (uint idx = 0; idx < spriteSlots.size(); ++idx) {
 		if (spriteSlots[idx]._seqIndex == PLAYER_SEQ_INDEX && 
-				spriteSlots[idx]._SlotType >= ST_NONE)
+				spriteSlots[idx]._flags >= IMG_STATIC)
 			return idx;
 	}
 
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 391ba71..ca7235a 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -78,7 +78,7 @@ void DirtyArea::setSpriteSlot(const SpriteSlot *spriteSlot) {
 	int width, height;
 	Scene &scene = _vm->_game->_scene;
 
-	if (spriteSlot->_SlotType == ST_FULL_SCREEN_REFRESH) {
+	if (spriteSlot->_flags == IMG_REFRESH) {
 		// Special entry to refresh the entire screen
 		_bounds.left = 0;
 		_bounds.top = 0;
@@ -117,24 +117,24 @@ void DirtyArea::setTextDisplay(const TextDisplay *textDisplay) {
 }
 
 void DirtyArea::setUISlot(const UISlot *slot) {
-	int type = slot->_slotType;
-	if (type <= -20)
-		type += 20;
+	int type = slot->_flags;
+	if (type <= IMG_UPDATE_ONLY)
+		type += -IMG_UPDATE_ONLY;
 	if (type >= 0x40)
 		type &= ~0x40;
 
 	MSurface &intSurface = _vm->_game->_scene._userInterface;
 	switch (type) {
-	case ST_FULL_SCREEN_REFRESH:
+	case IMG_REFRESH:
 		_bounds.left = 0;
 		_bounds.top = 0;
 		setArea(intSurface.w, intSurface.h, intSurface.w, intSurface.h);
 		break;
-	case ST_MINUS3:
+	case IMG_OVERPRINT:
 		_bounds.left = slot->_position.x;
 		_bounds.top = slot->_position.y;
 		// TODO: spritesIndex & frameNumber used as w & h??!
-		error("TODO: Figure out ST_MINUS3. Maybe need a union?");
+		error("TODO: Figure out IMG_OVERPRINT. Maybe need a union?");
 		break;
 
 	default: {
@@ -143,7 +143,7 @@ void DirtyArea::setUISlot(const UISlot *slot) {
 		int w = frame->w;
 		int h = frame->h;
 
-		if (slot->_field2 == 200) {
+		if (slot->_segmentId == IMG_SPINNING_OBJECT) {
 			_bounds.left = slot->_position.x;
 			_bounds.top = slot->_position.y;
 		} else {
@@ -350,12 +350,11 @@ void ScreenObjects::check(bool scanFlag) {
 		for (uint idx = 0; idx <  uiSlots.size(); ++idx) {
 			UISlot &slot = uiSlots[idx];
 
-			if (slot._slotType != ST_FULL_SCREEN_REFRESH && slot._slotType > -20
-					&& slot._field2 != 200)
-				slot._slotType = ST_EXPIRED;
+			if (slot._flags != IMG_REFRESH && slot._flags > -20
+				&& slot._segmentId != IMG_SPINNING_OBJECT)
+					slot._flags = IMG_ERASE;
 		}
 
-		// TODO: The stuff here could probably be moved to Scene::doFrame
 		// Any background animation
 		scene.backgroundAnimation();
 
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 6b9bd9e..01ca696 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -184,7 +184,7 @@ void SequenceList::setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot) {
 	SequenceEntry &timerEntry = _entries[seqIndex];
 	SpriteAsset &spriteSet = *scene._sprites[timerEntry._spritesIndex];
 
-	spriteSlot._SlotType = spriteSet.isBackground() ? ST_BACKGROUND : ST_FOREGROUND;
+	spriteSlot._flags = spriteSet.isBackground() ? IMG_DELTA : IMG_UPDATE;
 	spriteSlot._seqIndex = seqIndex;
 	spriteSlot._spritesIndex = timerEntry._spritesIndex;
 	spriteSlot._frameNumber = timerEntry._flipped ? -timerEntry._frameIndex : timerEntry._frameIndex;
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 226835b..442125e 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -139,7 +139,7 @@ byte MSprite::getTransparencyIndex() const {
 MADSEngine *SpriteSlot::_vm = nullptr;
 
 SpriteSlot::SpriteSlot() {
-	_SlotType = ST_NONE;
+	_flags = IMG_STATIC;
 	_seqIndex = 0;
 	_spritesIndex = 0;
 	_frameNumber = 0;
@@ -147,8 +147,8 @@ SpriteSlot::SpriteSlot() {
 	_scale = 0;
 }
 
-SpriteSlot::SpriteSlot(SlotType type, int seqIndex) {
-	_SlotType = type;
+SpriteSlot::SpriteSlot(SpriteFlags type, int seqIndex) {
+	_flags = type;
 	_seqIndex = seqIndex;
 	_spritesIndex = 0;
 	_frameNumber = 0;
@@ -183,7 +183,7 @@ void SpriteSlots::reset(bool flag) {
 		_vm->_game->_scene._sprites.clear();
 
 	Common::Array<SpriteSlot>::clear();
-	push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1));
+	push_back(SpriteSlot(IMG_REFRESH, -1));
 }
 
 void SpriteSlots::deleteEntry(int index) {
@@ -194,11 +194,11 @@ void SpriteSlots::setDirtyAreas() {
 	Scene &scene = _vm->_game->_scene;
 
 	for (uint i = 0; i < size(); ++i) {
-		if ((*this)[i]._SlotType >= ST_NONE) {
+		if ((*this)[i]._flags >= IMG_STATIC) {
 			scene._dirtyAreas[i].setSpriteSlot(&(*this)[i]);
 
-			scene._dirtyAreas[i]._textActive = ((*this)[i]._SlotType <= ST_NONE) ? 0 : 1;
-			(*this)[i]._SlotType = ST_NONE;
+			scene._dirtyAreas[i]._textActive = ((*this)[i]._flags <= IMG_STATIC) ? 0 : 1;
+			(*this)[i]._flags = IMG_STATIC;
 		}
 	}
 }
@@ -207,7 +207,7 @@ void SpriteSlots::fullRefresh(bool clearAll) {
 	if (clearAll)
 		Common::Array<SpriteSlot>::clear();
 
-	push_back(SpriteSlot(ST_FULL_SCREEN_REFRESH, -1));
+	push_back(SpriteSlot(IMG_REFRESH, -1));
 }
 
 void SpriteSlots::deleteTimer(int seqIndex) {
@@ -233,14 +233,14 @@ void SpriteSlots::drawBackground() {
 		SpriteSlot &spriteSlot = (*this)[i];
 		DirtyArea &dirtyArea = scene._dirtyAreas[i];
 
-		if (spriteSlot._SlotType >= ST_NONE) {
+		if (spriteSlot._flags >= IMG_STATIC) {
 			// Foreground sprite, so we can ignore it
 			dirtyArea._active = false;
 		} else {
 			dirtyArea._active = true;
 			dirtyArea.setSpriteSlot(&spriteSlot);
 
-			if (spriteSlot._SlotType == ST_BACKGROUND) {
+			if (spriteSlot._flags == IMG_DELTA) {
 				// Background object, so need to draw it
 				assert(spriteSlot._frameNumber > 0);
 				SpriteAsset *asset = scene._sprites[spriteSlot._spritesIndex];
@@ -290,7 +290,7 @@ void SpriteSlots::drawForeground(MSurface *s) {
 	// Get a list of sprite object depths for active objects
 	for (uint i = 0; i < size(); ++i) {
 		SpriteSlot &spriteSlot = (*this)[i];
-		if (spriteSlot._SlotType >= ST_NONE) {
+		if (spriteSlot._flags >= IMG_STATIC) {
 			DepthEntry rec(16 - spriteSlot._depth, i);
 			depthList.push_back(rec);
 		}
@@ -353,7 +353,7 @@ void SpriteSlots::drawForeground(MSurface *s) {
 
 void SpriteSlots::cleanUp() {
 	for (int i = (int)size() - 1; i >= 0; --i) {
-		if ((*this)[i]._SlotType < ST_NONE)
+		if ((*this)[i]._flags < IMG_STATIC)
 			remove_at(i);
 	}
 }
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index a9b4e97..962d8c9 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -30,9 +30,15 @@
 
 namespace MADS {
 
-enum SlotType {
-	ST_NONE = 0, ST_FOREGROUND = 1, ST_MINUS5 = -5, ST_BACKGROUND = -4, 
-	ST_MINUS3 = -3, ST_FULL_SCREEN_REFRESH = -2, ST_EXPIRED = -1
+enum SpriteFlags {
+	IMG_STATIC = 0,			// Item should remain fixed on the screen
+	IMG_UPDATE = 1,			// Item needs to be redrawn
+	IMG_ERASE = -1,			// Erase image and remove it
+	IMG_REFRESH = -2,		// Full refresh
+	IMG_OVERPRINT = -3,		// Interface overprint
+	IMG_DELTA = -4,			// Delta change
+	IMG_FULL_UPDATE = -5,	// Interface refresh
+	IMG_UPDATE_ONLY = -20	// Update the active screen area only
 };
 
 class MADSEngine;
@@ -129,11 +135,11 @@ private:
 	static MADSEngine *_vm;
 	friend class SpriteSlots;
 public:
-	SlotType _SlotType;
+	SpriteFlags _flags;
 	int _seqIndex;
 public:
 	SpriteSlot();
-	SpriteSlot(SlotType type, int seqIndex);
+	SpriteSlot(SpriteFlags type, int seqIndex);
 
 	void setup(int dirtyAreaIndex);
 	bool operator==(const SpriteSlotSubset &other) const;
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 2cd1662..7ed1884 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -28,8 +28,8 @@
 namespace MADS {
 
 UISlot::UISlot() {
-	_slotType = ST_NONE;
-	_field2 = 0;
+	_flags = IMG_STATIC;
+	_segmentId = 0;
 	_spritesIndex = 0;
 	_frameNumber = 0;
 }
@@ -38,8 +38,8 @@ UISlot::UISlot() {
 
 void UISlots::fullRefresh() {
 	UISlot slot;
-	slot._slotType = ST_FULL_SCREEN_REFRESH;
-	slot._field2 = -1;
+	slot._flags = IMG_REFRESH;
+	slot._segmentId = -1;
 
 	push_back(slot);
 }
@@ -48,8 +48,8 @@ void UISlots::add(const Common::Point &pt, int frameNumber, int spritesIndex) {
 	assert(size() < 50);
 
 	UISlot ie;
-	ie._slotType = -3;
-	ie._field2 = 201;
+	ie._flags = -3;
+	ie._segmentId = IMG_TEXT_UPDATE;
 	ie._position = pt;
 	ie._frameNumber = frameNumber;
 	ie._spritesIndex = spritesIndex;
@@ -67,12 +67,12 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 		DirtyArea &dirtyArea = userInterface._dirtyAreas[idx];
 		UISlot &slot = (*this)[idx];
 
-		if (slot._slotType >= ST_NONE) {
+		if (slot._flags >= IMG_STATIC) {
 			dirtyArea._active = false;
 		} else {
 			dirtyArea.setUISlot(&slot);
 			dirtyArea._textActive = true;
-			if (slot._field2 == 200 && slot._slotType == ST_MINUS5) {
+			if (slot._segmentId == IMG_SPINNING_OBJECT && slot._flags == IMG_FULL_UPDATE) {
 				dirtyArea._active = false;
 				dirtyAreaPtr = &dirtyArea;
 			}
@@ -89,10 +89,10 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 		UISlot &slot = (*this)[idx];
 
 		if (dirtyArea._active && dirtyArea._bounds.width() > 0
-				&& dirtyArea._bounds.height() > 0 && slot._slotType >= -20) {
+				&& dirtyArea._bounds.height() > 0 && slot._flags >= -20) {
 
 			// TODO: Figure out the difference between two copy methods used
-			if (slot._slotType >= ST_EXPIRED) {
+			if (slot._flags >= IMG_ERASE) {
 				userInterface._surface.copyTo(&userInterface, dirtyArea._bounds,
 					Common::Point(dirtyArea._bounds.left, dirtyArea._bounds.top));
 			} else {
@@ -106,14 +106,14 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 		DirtyArea &dirtyArea = userInterface._dirtyAreas[idx];
 		UISlot &slot = (*this)[idx];
 
-		int slotType = slot._slotType;
-		if (slotType >= ST_NONE) {
+		int slotType = slot._flags;
+		if (slotType >= IMG_STATIC) {
 			dirtyArea.setUISlot(&slot);
 			if (!updateFlag)
 				slotType &= ~0x40;
 
 			dirtyArea._textActive = slotType > 0;
-			slot._slotType &= 0x40;
+			slot._flags &= 0x40;
 		}
 	}
 
@@ -123,7 +123,7 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 		DirtyArea &dirtyArea = userInterface._dirtyAreas[idx];
 		UISlot &slot = (*this)[idx];
 
-		if (slot._slotType >= ST_NONE && !(slot._slotType & 0x40)) {
+		if (slot._flags >= IMG_STATIC && !(slot._flags & 0x40)) {
 			if (!dirtyArea._active) {
 				error("Should never reach this point, even in original");
 			}
@@ -131,7 +131,7 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 			if (dirtyArea._textActive) {
 				SpriteAsset *asset = scene._sprites[slot._spritesIndex];
 				
-				if (slot._field2 == 200) {
+				if (slot._segmentId == IMG_SPINNING_OBJECT) {
 					MSprite *sprite = asset->getFrame(slot._frameNumber & 0x7F);
 					sprite->copyTo(&userInterface, slot._position, 
 						sprite->getTransparencyIndex());
@@ -170,16 +170,16 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 	for (int idx = (int)size() - 1; idx >= 0; --idx) {
 		UISlot &slot = (*this)[idx];
 
-		if (slot._slotType < ST_NONE) {
+		if (slot._flags < IMG_STATIC) {
 			if (delFlag || updateFlag)
 				remove_at(idx);
-			else if (slot._slotType >= -20)
-				slot._slotType -= 20;
+			else if (slot._flags >= -20)
+				slot._flags -= 20;
 		} else {
 			if (updateFlag)
-				slot._slotType &= ~0x40;
+				slot._flags &= ~0x40;
 			else
-				slot._slotType |= 0x40;
+				slot._flags |= 0x40;
 		}
 	}
 }
@@ -619,14 +619,14 @@ void UserInterface::inventoryAnim() {
 
 	// Loop through the slots list for inventory animation entry
 	for (uint i = 0; i < _uiSlots.size(); ++i) {
-		if (_uiSlots[i]._field2 == 200)
-			_uiSlots[i]._slotType = -5;
+		if (_uiSlots[i]._segmentId == IMG_SPINNING_OBJECT)
+			_uiSlots[i]._flags = -5;
 	}
 
 	// Add a new slot entry for the inventory animation
 	UISlot slot;
-	slot._slotType = ST_FOREGROUND;
-	slot._field2 = 200;
+	slot._flags = IMG_UPDATE;
+	slot._segmentId = IMG_SPINNING_OBJECT;
 	slot._frameNumber = _invFrameNumber;
 	slot._spritesIndex = _invSpritesIndex;
 	slot._position = Common::Point(160, 3);
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 740ea66..53c1e10 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -31,10 +31,12 @@
 
 namespace MADS {
 
+enum { IMG_SPINNING_OBJECT = 200, IMG_TEXT_UPDATE = 201 };
+
 class UISlot {
 public:
-	int _slotType;
-	int _field2;
+	int _flags;
+	int _segmentId;
 	int _spritesIndex;
 	int _frameNumber;
 	Common::Point _position;


Commit: f0458042f212e10155e4206312e46ce0beb7c06f
    https://github.com/scummvm/scummvm/commit/f0458042f212e10155e4206312e46ce0beb7c06f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-02T22:27:11-04:00

Commit Message:
MADS: In progress cleanup of checkActionAtMousePos

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/screen.cpp
    engines/mads/screen.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 35e989b..7a95e64 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -50,18 +50,19 @@ void MADSAction::clear() {
 	_actionMode = ACTIONMODE_NONE;
 	_actionMode2 = ACTIONMODE2_0;
 	_v86F42 = 0;
-	_v86F4E = 0;
+	_recentCommandSource = 0;
 	_articleNumber = 0;
 	_lookFlag = false;
 	_v86F4A = 0;
 	_selectedRow = -1;
 	_hotspotId = -1;
 	_v86F3A = -1;
-	_v86F4C = -1;
+	_recentCommand = -1;
 	_action._verbId = VERB_NONE;
 	_action._objectNameId = -1;
 	_action._indirectObjectId = -1;
 	_textChanged = true;
+	_pickedWord = 0;
 }
 
 void MADSAction::appendVocab(int vocabId, bool capitalise) {
@@ -355,9 +356,9 @@ void MADSAction::checkActionAtMousePos() {
 	ScreenObjects &screenObjects = _vm->_game->_screenObjects;
 
 	if ((userInterface._category == CAT_COMMAND || userInterface._category == CAT_INV_VOCAB) &&
-			_interAwaiting != 1 && scene._highlightedHotspot >= 0) {
-		if (_v86F4E == userInterface._category || _v86F4C != scene._highlightedHotspot ||
-			(_interAwaiting != 2 && _interAwaiting != 3))
+			_interAwaiting != AWAITING_COMMAND && _pickedWord >= 0) {
+		if (_recentCommandSource == userInterface._category || _recentCommand != _pickedWord ||
+			(_interAwaiting != AWAITING_THIS && _interAwaiting != 3))
 			clear();
 		else if (_selectedRow != 0 || userInterface._category != CAT_COMMAND)
 			scene._lookFlag = false;
@@ -408,7 +409,7 @@ void MADSAction::checkActionAtMousePos() {
 		switch (userInterface._category) {
 		case CAT_COMMAND:
 			_actionMode = ACTIONMODE_VERB;
-			_selectedRow = scene._highlightedHotspot;
+			_selectedRow = _pickedWord;
 			if (_selectedRow >= 0) {
 				_flags1 = scene._verbList[_selectedRow]._action1;
 				_flags2 = scene._verbList[_selectedRow]._action2;
@@ -417,7 +418,7 @@ void MADSAction::checkActionAtMousePos() {
 
 		case CAT_INV_VOCAB:
 			_actionMode = ACTIONMODE_OBJECT;
-			_selectedRow = scene._highlightedHotspot;
+			_selectedRow = _pickedWord;
 			if (_selectedRow < 0) {
 				_hotspotId = -1;
 				_actionMode2 = ACTIONMODE2_0;
@@ -439,12 +440,12 @@ void MADSAction::checkActionAtMousePos() {
 			_selectedRow = -1;
 			_actionMode = ACTIONMODE_NONE;
 			_actionMode2 = ACTIONMODE2_4;
-			_hotspotId = scene._highlightedHotspot;
+			_hotspotId = _pickedWord;
 			break;
 
 		case CAT_TALK_ENTRY:
 			_actionMode = ACTIONMODE_TALK;
-			_selectedRow = scene._highlightedHotspot;
+			_selectedRow = _pickedWord;
 			break;
 
 		default:
@@ -460,7 +461,7 @@ void MADSAction::checkActionAtMousePos() {
 		case CAT_INV_ANIM:
 			// TODO: We may not need a separate ActionMode2 enum
 			_actionMode2 = (ActionMode2)userInterface._category;
-			_hotspotId = scene._highlightedHotspot;
+			_hotspotId = _pickedWord;
 			break;
 		default:
 			break;
@@ -473,7 +474,7 @@ void MADSAction::checkActionAtMousePos() {
 		case CAT_HOTSPOT:
 		case CAT_INV_ANIM:
 			_v86F42 = userInterface._category;
-			_v86F3A = scene._highlightedHotspot;
+			_v86F3A = _pickedWord;
 			break;
 		default:
 			break;
@@ -492,8 +493,8 @@ void MADSAction::leftClick() {
 	bool abortFlag = false;
 
 	if ((userInterface._category == CAT_COMMAND || userInterface._category == CAT_INV_VOCAB) &&
-			_interAwaiting != 1 && scene._highlightedHotspot >= 0 && 
-			_v86F4E == userInterface._category && _v86F4C == scene._highlightedHotspot &&
+		_interAwaiting != 1 && _pickedWord >= 0 &&
+			_recentCommandSource == userInterface._category && _recentCommand == _pickedWord &&
 			(_interAwaiting == 2 || userInterface._category == CAT_INV_VOCAB)) {
 		abortFlag = true;
 		if (_selectedRow == 0 && userInterface._category == CAT_COMMAND) {
@@ -519,16 +520,16 @@ void MADSAction::leftClick() {
 					_selectedAction = -1;
 				}
 				else {
-					_v86F4C = _selectedRow;
-					_v86F4E = _actionMode;
+					_recentCommand = _selectedRow;
+					_recentCommandSource = _actionMode;
 					_interAwaiting = AWAITING_THIS;
 				}
 			}
 			break;
 
 		case CAT_INV_LIST:
-			if (scene._highlightedHotspot >= 0) {
-				userInterface.selectObject(scene._highlightedHotspot);
+			if (_pickedWord >= 0) {
+				userInterface.selectObject(_pickedWord);
 			}
 			break;
 
@@ -548,14 +549,14 @@ void MADSAction::leftClick() {
 					_selectedAction = -1;
 				}
 
-				_v86F4C = _selectedRow;
-				_v86F4E = _actionMode;
+				_recentCommand = _selectedRow;
+				_recentCommandSource = _actionMode;
 			}
 			break;
 
 		case CAT_HOTSPOT:
-			_v86F4C = -1;
-			_v86F4E = 0;
+			_recentCommand = -1;
+			_recentCommandSource = 0;
 
 			if (_vm->_events->currentPos().y < MADS_SCENE_HEIGHT) {
 				scene._customDest = _vm->_events->currentPos() + scene._posAdjust;
diff --git a/engines/mads/action.h b/engines/mads/action.h
index e7a3323..45886c1 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -105,12 +105,13 @@ public:
 	// Unknown fields
 	int16 _v86F3A;
 	int16 _v86F42;
-	int16 _v86F4E;
+	int16 _recentCommandSource;
 	bool _v86F4A;
-	int16 _v86F4C;
+	int16 _recentCommand;
 	InterAwaiting _interAwaiting;
 	bool _inProgress;
 	int _v8453A;
+	int _pickedWord;
 
 public:
 	MADSAction(MADSEngine *vm);
@@ -123,6 +124,10 @@ public:
 	void checkAction();
 	bool isAction(int verbId, int objectNameId = 0, int indirectObjectId = 0);
 	
+	/**
+	 * Check the result of the current action on the sentence
+	 * with the provision that the action is not yet complete.
+	 */
 	void checkActionAtMousePos();
 
 	/**
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index d37834a..97a131a 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -49,7 +49,6 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 	_frameStartTime = 0;
 	_layer = LAYER_GUI;
 	_lookFlag = false;
-	_highlightedHotspot = 0;
 
 	_verbList.push_back(VerbInit(VERB_LOOK, 2, 0));
 	_verbList.push_back(VerbInit(VERB_TAKE, 2, 0));
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 1b0c9c9..4e3829b 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -124,7 +124,6 @@ public:
 	uint32 _frameStartTime;
 	Layer _layer;
 	bool _lookFlag;
-	int _highlightedHotspot;
 	Common::Point _customDest;
 
 	/**
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index ca7235a..f00146e 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -350,7 +350,7 @@ void ScreenObjects::check(bool scanFlag) {
 		for (uint idx = 0; idx <  uiSlots.size(); ++idx) {
 			UISlot &slot = uiSlots[idx];
 
-			if (slot._flags != IMG_REFRESH && slot._flags > -20
+			if (slot._flags != IMG_REFRESH && slot._flags > IMG_UPDATE_ONLY
 				&& slot._segmentId != IMG_SPINNING_OBJECT)
 					slot._flags = IMG_ERASE;
 		}
@@ -598,7 +598,7 @@ void ScreenObjects::elementHighlighted() {
 	if (newIndex >= 0)
 		newIndex = MIN(newIndex + topIndex, indexEnd);
 
-	_vm->_game->_scene._highlightedHotspot = newIndex;
+	action._pickedWord = newIndex;
 
 	if (_category == CAT_INV_LIST || _category == CAT_INV_ANIM) {
 		if (action._interAwaiting == 1 && newIndex >= 0 && _released &&
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index d292a7a..e6e0f28 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -178,7 +178,7 @@ public:
 	void check(bool scanFlag);
 
 	/**
-	 * Handle element being highlighted on the screen
+	 * Handle an element being highlighted on the screen, and make it active.
 	 */
 	void elementHighlighted();
 


Commit: 74c6bafed4eb80f93284a60219f27c150eb2baf5
    https://github.com/scummvm/scummvm/commit/74c6bafed4eb80f93284a60219f27c150eb2baf5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-02T22:41:25-04:00

Commit Message:
MADS: Further clean up/renaming of checkActionAtMousePos

Changed paths:
    engines/mads/action.cpp
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/scene.cpp
    engines/mads/screen.cpp
    engines/mads/screen.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 7a95e64..b5c92c0 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -366,7 +366,7 @@ void MADSAction::checkActionAtMousePos() {
 			scene._lookFlag = true;
 	}
 
-	if (screenObjects._v7FECA && _vm->_events->_mouseButtons) {
+	if (_vm->_events->_anyStroke && _vm->_events->_mouseButtons) {
 		switch (userInterface._category) {
 		case CAT_COMMAND:
 		case CAT_INV_VOCAB:
@@ -507,7 +507,7 @@ void MADSAction::leftClick() {
 		}
 	}
 
-	if (abortFlag || (screenObjects._v7FECA && (userInterface._category == CAT_COMMAND ||
+	if (abortFlag || (_vm->_events->_anyStroke && (userInterface._category == CAT_COMMAND ||
 			userInterface._category == CAT_INV_VOCAB)))
 		return;
 
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index c61512c..29ea927 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -46,6 +46,7 @@ EventsManager::EventsManager(MADSEngine *vm) {
 	_vD4 = 0;
 	_mouseMoved = false;
 	_vD8 = 0;
+	_anyStroke = false;
 }
 
 EventsManager::~EventsManager() {
@@ -129,17 +130,20 @@ void EventsManager::pollEvents() {
 			_mouseClicked = true;
 			_mouseButtons = 1;
 			_mouseMoved = true;
+			_anyStroke = true;
 			return;
 		case Common::EVENT_LBUTTONUP:
 		case Common::EVENT_RBUTTONUP:
 			_mouseClicked = false;
 			_mouseReleased = true;
 			_mouseMoved = true;
+			_anyStroke = true;
 			return;
 		case Common::EVENT_MOUSEMOVE:
 			_mousePos = event.mouse;
 			_currentPos = event.mouse;
 			_mouseMoved = true;
+			_anyStroke = true;
 			break;
 		default:
  			break;
diff --git a/engines/mads/events.h b/engines/mads/events.h
index b0b20b4..8537605 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -58,6 +58,7 @@ public:
 	bool _mouseClicked;
 	bool _mouseReleased;
 	byte _mouseButtons;
+	bool _anyStroke;
 	bool _keyPressed;
 	int _vCC;
 	int _vD2;
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 97a131a..9e27f27 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -522,7 +522,7 @@ void Scene::updateCursor() {
 	Player &player = _vm->_game->_player;
 
 	CursorType cursorId = CURSOR_ARROW;
-	if (_action._interAwaiting == 1 && !_vm->_game->_screenObjects._v7FECA &&
+	if (_action._interAwaiting == 1 && !_vm->_events->_anyStroke &&
 		_vm->_game->_screenObjects._category == CAT_HOTSPOT) {
 		int idx = _vm->_game->_screenObjects._selectedObject -
 			_userInterface._categoryIndexes[CAT_HOTSPOT - 1];
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index f00146e..b55d80c9 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -254,7 +254,6 @@ ScreenObjects::ScreenObjects(MADSEngine *vm) : _vm(vm) {
 	_objectY = -1;
 	_v8333C = false;
 	_v832EC = 0;
-	_v7FECA = true;
 	_v7FED6 = 0;
 	_v8332A = 0;
 	_category = CAT_NONE;
@@ -287,7 +286,7 @@ void ScreenObjects::check(bool scanFlag) {
 	UserInterface &userInterface = scene._userInterface;
 
 	if (!_vm->_events->_mouseButtons || _v832EC)
-		_v7FECA = false;
+		_vm->_events->_anyStroke = false;
 
 	if ((_vm->_events->_mouseMoved || _vm->_game->_scene._userInterface._scrollerY 
 			|| _v8332A || _v8333C) && scanFlag) {
@@ -474,13 +473,13 @@ void ScreenObjects::elementHighlighted() {
 		indexEnd = 9;
 		varA = 5;
 		topIndex = 0;
-		idxP = !_v7FECA ? &userInterface._highlightedCommandIndex : 
+		idxP = !_vm->_events->_anyStroke ? &userInterface._highlightedCommandIndex : 
 			&userInterface._selectedActionIndex;
 
-		if (_v7FECA && userInterface._selectedItemVocabIdx >= 0)
+		if (_vm->_events->_anyStroke && userInterface._selectedItemVocabIdx >= 0)
 			userInterface.updateSelection(CAT_INV_VOCAB, -1, &userInterface._selectedItemVocabIdx);
 
-		var4 = _released && !_v7FECA ? 1 : 0;
+		var4 = _released && !_vm->_events->_anyStroke ? 1 : 0;
 		break;
 
 	case CAT_INV_LIST:
@@ -506,12 +505,12 @@ void ScreenObjects::elementHighlighted() {
 
 		varA = 0;
 		topIndex = 0;
-		idxP = _v7FECA ? &userInterface._selectedItemVocabIdx : &userInterface._highlightedActionIndex;
+		idxP = _vm->_events->_anyStroke ? &userInterface._selectedItemVocabIdx : &userInterface._highlightedActionIndex;
 
-		if (_v7FECA && userInterface._selectedActionIndex >= 0)
+		if (_vm->_events->_anyStroke && userInterface._selectedActionIndex >= 0)
 			userInterface.updateSelection(CAT_COMMAND, -1, &userInterface._selectedActionIndex);
 
-		var4 = _released && !_v7FECA ? 1 : 0;
+		var4 = _released && !_vm->_events->_anyStroke ? 1 : 0;
 		break;
 
 	case CAT_INV_ANIM:
@@ -606,7 +605,7 @@ void ScreenObjects::elementHighlighted() {
 			newIndex = -1;
 	}
 
-	if (_released && !_vm->_game->_screenObjects._v7FECA &&
+	if (_released && !_vm->_events->_anyStroke &&
 			(_vm->_events->_mouseReleased || !_vm->_easyMouse))
 		newIndex = -1;
 
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index e6e0f28..31fdd2a 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -149,7 +149,6 @@ private:
 	void checkScroller();
 public:
 	int _v832EC;
-	int _v7FECA;
 	int _v7FED6;
 	int _v8332A;
 	int _v8333C;


Commit: 83ac9489231e164154ad812034eb6aac9a0fe78b
    https://github.com/scummvm/scummvm/commit/83ac9489231e164154ad812034eb6aac9a0fe78b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-03T20:38:18-04:00

Commit Message:
MADS: Renaming to use InterWaiting enum entries

Changed paths:
    engines/mads/action.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index b5c92c0..134d474 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -373,8 +373,9 @@ void MADSAction::checkActionAtMousePos() {
 			return;
 
 		case CAT_INV_LIST:
-		case CAT_TALK_ENTRY:
-			if (_interAwaiting != 3) {
+		case CAT_HOTSPOT:
+		case CAT_INV_ANIM:
+			if (_interAwaiting != AWAITING_THAT) {
 				if (userInterface._selectedActionIndex >= 0) {
 					_actionMode = ACTIONMODE_VERB;
 					_selectedRow = userInterface._selectedActionIndex;
@@ -404,7 +405,7 @@ void MADSAction::checkActionAtMousePos() {
 	}
 
 	switch (_interAwaiting) {
-	case 1:
+	case AWAITING_COMMAND:
 		_articleNumber = 0;
 		switch (userInterface._category) {
 		case CAT_COMMAND:
@@ -453,7 +454,7 @@ void MADSAction::checkActionAtMousePos() {
 		}
 		break;
 
-	case 2:
+	case AWAITING_THIS:
 		_articleNumber = 0;
 		switch (userInterface._category) {
 		case CAT_INV_LIST:
@@ -468,7 +469,7 @@ void MADSAction::checkActionAtMousePos() {
 		}
 		break;
 
-	case 3:
+	case AWAITING_THAT:
 		switch (userInterface._category) {
 		case CAT_INV_LIST:
 		case CAT_HOTSPOT:


Commit: d163ee088a9f3e49463fddd05a41d1b1530e77db
    https://github.com/scummvm/scummvm/commit/d163ee088a9f3e49463fddd05a41d1b1530e77db
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-03T22:02:12-04:00

Commit Message:
MADS: Renamings for saving fields in MADSAction::startAction

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h
    engines/mads/game.cpp
    engines/mads/hotspots.cpp
    engines/mads/inventory.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/scene.cpp
    engines/mads/screen.cpp
    engines/mads/screen.h
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 134d474..8ee46e2 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -35,28 +35,28 @@ MADSAction::MADSAction(MADSEngine *vm) : _vm(vm) {
 	_selectedAction = 0;
 	_inProgress = false;
 
-	_savedFields._actionMode = KERNEL_TRIGGER_PARSER;
-	_savedFields._actionMode2 = KERNEL_TRIGGER_PARSER;
-	_savedFields._selectedRow = -1;
-	_savedFields._hotspotId = 0;
-	_savedFields._v86F3A = 0;
-	_savedFields._v86F42 = 0;
+	_savedFields._commandSource = 0;
+	_savedFields._mainObjectSource = 0;
+	_savedFields._command = -1;
+	_savedFields._mainObject = 0;
+	_savedFields._secondObject = 0;
+	_savedFields._secondObjectSource = 0;
 	_savedFields._articleNumber = 0;
 	_savedFields._lookFlag = false;
 }
 
 void MADSAction::clear() {
 	_interAwaiting = AWAITING_COMMAND;
-	_actionMode = ACTIONMODE_NONE;
-	_actionMode2 = ACTIONMODE2_0;
-	_v86F42 = 0;
+	_commandSource = ACTIONMODE_NONE;
+	_mainObjectSource = ACTIONMODE2_0;
+	_secondObjectSource = 0;
 	_recentCommandSource = 0;
 	_articleNumber = 0;
 	_lookFlag = false;
 	_v86F4A = 0;
 	_selectedRow = -1;
 	_hotspotId = -1;
-	_v86F3A = -1;
+	_secondObject = -1;
 	_recentCommand = -1;
 	_action._verbId = VERB_NONE;
 	_action._objectNameId = -1;
@@ -78,7 +78,7 @@ void MADSAction::checkCustomDest(int v) {
 	Scene &scene = _vm->_game->_scene;
 	Player &player = _vm->_game->_player;
 
-	if (_v86F4A && (v == -3 || _savedFields._selectedRow < 0)) {
+	if (_v86F4A && (v == -3 || _savedFields._command < 0)) {
 		player._needToWalk = true;
 		player._prepareWalkPos = scene._customDest;
 	}
@@ -94,7 +94,7 @@ void MADSAction::set() {
 	_action._objectNameId = -1;
 	_action._indirectObjectId = -1;
 
-	if (_actionMode == ACTIONMODE_TALK) {
+	if (_commandSource == ACTIONMODE_TALK) {
 		// Handle showing the conversation selection. Rex at least doesn't actually seem to use this
 		if (_selectedRow >= 0) {
 			Common::String desc = userInterface._talkStrings[userInterface._talkIds[_selectedRow]];
@@ -105,7 +105,7 @@ void MADSAction::set() {
 		// Two 'look' actions in succession, so the action becomes 'Look around'
 		_statusText = kLookAroundStr;
 	} else {
-		if ((_actionMode == ACTIONMODE_OBJECT) && (_selectedRow >= 0) && (_flags1 == 2) && (_flags2 == 0)) {
+		if ((_commandSource == ACTIONMODE_OBJECT) && (_selectedRow >= 0) && (_flags1 == 2) && (_flags2 == 0)) {
 			// Use/to action
 			int invIndex = userInterface._selectedInvIndex;
 			InventoryObject &objEntry = _vm->_game->_objects.getItem(invIndex);
@@ -121,7 +121,7 @@ void MADSAction::set() {
 		} else {
 			// Handling for if an action has been selected
 			if (_selectedRow >= 0) {
-				if (_actionMode == ACTIONMODE_VERB) {
+				if (_commandSource == ACTIONMODE_VERB) {
 					// Standard verb action
 					_action._verbId = scene._verbList[_selectedRow]._id;
 				} else {
@@ -172,7 +172,7 @@ void MADSAction::set() {
 					}
 				}
 
-				if ((_actionMode2 == ACTIONMODE2_2) || (_actionMode2 == ACTIONMODE2_5)) {
+				if ((_mainObjectSource == ACTIONMODE2_2) || (_mainObjectSource == ACTIONMODE2_5)) {
 					// Get name from given inventory object
 					InventoryObject &invObject = _vm->_game->_objects.getItem(_hotspotId);
 					_action._objectNameId = invObject._descId;
@@ -189,13 +189,13 @@ void MADSAction::set() {
 
 		if ((_hotspotId >= 0) && (_articleNumber > 0) && !flag) {
 			if (_articleNumber == -1) {
-				if (_v86F3A >= 0) {
+				if (_secondObject >= 0) {
 					int articleNum = 0;
 
-					if ((_v86F42 == 2) || (_v86F42 == 5)) {
+					if ((_secondObjectSource == 2) || (_secondObjectSource == 5)) {
 						InventoryObject &invObject = _vm->_game->_objects.getItem(_hotspotId);
 						articleNum = invObject._article;
-					} else if (_v86F3A < (int)scene._hotspots.size()) {
+					} else if (_secondObject < (int)scene._hotspots.size()) {
 						articleNum = scene._hotspots[_hotspotId]._articleNumber;
 					} else {
 						articleNum = scene._hotspots[_hotspotId - scene._hotspots.size()]._articleNumber;
@@ -217,7 +217,7 @@ void MADSAction::set() {
 		}
 
 		// Append object description if necessary
-		if (_v86F3A >= 0)
+		if (_secondObject >= 0)
 			appendVocab(_action._indirectObjectId);
 
 		// Remove any trailing space character
@@ -242,7 +242,8 @@ void MADSAction::refresh() {
 	}
 
 	if (!_statusText.empty()) {
-		if ((_vm->_game->_screenObjects._v832EC == 0) || (_vm->_game->_screenObjects._v832EC == 2)) {
+		if ((_vm->_game->_screenObjects._inputMode == kInputBuildingSentences) || 
+				(_vm->_game->_screenObjects._inputMode == kInputLimitedSentences)) {
 			Font *font = _vm->_font->getFont(FONT_MAIN);
 			int textSpacing = -1;
 
@@ -273,14 +274,14 @@ void MADSAction::startAction() {
 	player.cancelCommand();
 
 	_inProgress = true;
-	_v8453A = KERNEL_TRIGGER_PARSER;
-	_savedFields._selectedRow = _selectedRow;
-	_savedFields._hotspotId = _hotspotId;
-	_savedFields._v86F3A = _v86F3A;
+	_savedFields._commandError = false;
+	_savedFields._command = _selectedRow;
+	_savedFields._mainObject = _hotspotId;
+	_savedFields._secondObject = _secondObject;
 	_savedFields._articleNumber = _articleNumber;
-	_savedFields._actionMode = _actionMode;
-	_savedFields._actionMode2 = _actionMode2;
-	_savedFields._v86F42 = _v86F42;
+	_savedFields._commandSource = _commandSource;
+	_savedFields._mainObjectSource = _mainObjectSource;
+	_savedFields._secondObjectSource = _secondObjectSource;
 	_savedFields._lookFlag = _lookFlag;
 	_activeAction = _action;
 
@@ -288,17 +289,17 @@ void MADSAction::startAction() {
 	_activeAction = _action;
 	_sentence = _statusText;
 
-	if ((_actionMode2 == ACTIONMODE2_4) && (_v86F42 == 0))
-		_v8453A = -1;
+	if ((_mainObjectSource == ACTIONMODE2_4) && (_secondObjectSource == 0))
+		_savedFields._commandError = true;
 
 	player._needToWalk = false;
 	int hotspotId = -1;
 
-	if (!_savedFields._lookFlag && (_vm->_game->_screenObjects._v832EC != 1)) {
-		if (_savedFields._actionMode2 == ACTIONMODE2_4)
-			hotspotId = _savedFields._hotspotId;
-		else if (_v86F42 == 4)
-			hotspotId = _savedFields._v86F3A;
+	if (!_savedFields._lookFlag && (_vm->_game->_screenObjects._inputMode != kInputConversation)) {
+		if (_savedFields._mainObjectSource == ACTIONMODE2_4)
+			hotspotId = _savedFields._mainObject;
+		else if (_secondObjectSource == 4)
+			hotspotId = _savedFields._secondObject;
 
 		if (hotspotId >= (int)hotspots.size()) {
 			DynamicHotspot &hs = dynHotspots[hotspotId - hotspots.size()];
@@ -306,7 +307,7 @@ void MADSAction::startAction() {
 				checkCustomDest(hs._feetPos.x);
 			} else if (hs._feetPos.x == 0) {
 				player._prepareWalkFacing = hs._facing;
-			} else if (_savedFields._actionMode == ACTIONMODE_NONE || hs._cursor >= CURSOR_WAIT) {
+			} else if (_savedFields._commandSource == ACTIONMODE_NONE || hs._cursor >= CURSOR_WAIT) {
 				player._needToWalk = true;
 				player._prepareWalkPos = hs._feetPos;
 			}
@@ -322,7 +323,7 @@ void MADSAction::startAction() {
 		if (hs._feetPos.x == -1 || hs._feetPos.x != -3) {
 			checkCustomDest(hs._feetPos.x);
 		} else if (hs._feetPos.x >= 0) {
-			if (_savedFields._actionMode == ACTIONMODE_NONE || hs._cursor < CURSOR_WAIT) {
+			if (_savedFields._commandSource == ACTIONMODE_NONE || hs._cursor < CURSOR_WAIT) {
 				player._needToWalk = true;
 				player._prepareWalkPos = hs._feetPos;
 			}
@@ -353,7 +354,6 @@ bool MADSAction::isAction(int verbId, int objectNameId, int indirectObjectId) {
 void MADSAction::checkActionAtMousePos() {
 	Scene &scene = _vm->_game->_scene;
 	UserInterface &userInterface = scene._userInterface;
-	ScreenObjects &screenObjects = _vm->_game->_screenObjects;
 
 	if ((userInterface._category == CAT_COMMAND || userInterface._category == CAT_INV_VOCAB) &&
 			_interAwaiting != AWAITING_COMMAND && _pickedWord >= 0) {
@@ -377,20 +377,20 @@ void MADSAction::checkActionAtMousePos() {
 		case CAT_INV_ANIM:
 			if (_interAwaiting != AWAITING_THAT) {
 				if (userInterface._selectedActionIndex >= 0) {
-					_actionMode = ACTIONMODE_VERB;
+					_commandSource = ACTIONMODE_VERB;
 					_selectedRow = userInterface._selectedActionIndex;
 					_flags1 = scene._verbList[_selectedRow]._action1;
 					_flags2 = scene._verbList[_selectedRow]._action2;
 					_interAwaiting = AWAITING_THIS;
 				} else if (userInterface._selectedItemVocabIdx >= 0) {
-					_actionMode = ACTIONMODE_OBJECT;
+					_commandSource = ACTIONMODE_OBJECT;
 					_selectedRow = userInterface._selectedItemVocabIdx;
 					int objectId = _vm->_game->_objects._inventoryList[_selectedRow];
 					InventoryObject &invObject = _vm->_game->_objects[objectId];
 
 					_flags1 = invObject._vocabList[_selectedRow - 1]._actionFlags1;
 					_flags2 = invObject._vocabList[_selectedRow - 1]._actionFlags2;
-					_actionMode2 = ACTIONMODE2_2;
+					_mainObjectSource = ACTIONMODE2_2;
 					_hotspotId = userInterface._selectedInvIndex;
 					_articleNumber = _flags2;
 
@@ -409,7 +409,7 @@ void MADSAction::checkActionAtMousePos() {
 		_articleNumber = 0;
 		switch (userInterface._category) {
 		case CAT_COMMAND:
-			_actionMode = ACTIONMODE_VERB;
+			_commandSource = ACTIONMODE_VERB;
 			_selectedRow = _pickedWord;
 			if (_selectedRow >= 0) {
 				_flags1 = scene._verbList[_selectedRow]._action1;
@@ -418,11 +418,11 @@ void MADSAction::checkActionAtMousePos() {
 			break;
 
 		case CAT_INV_VOCAB:
-			_actionMode = ACTIONMODE_OBJECT;
+			_commandSource = ACTIONMODE_OBJECT;
 			_selectedRow = _pickedWord;
 			if (_selectedRow < 0) {
 				_hotspotId = -1;
-				_actionMode2 = ACTIONMODE2_0;
+				_mainObjectSource = ACTIONMODE2_0;
 			} else {
 				int objectId = _vm->_game->_objects._inventoryList[_selectedRow];
 				InventoryObject &invObject = _vm->_game->_objects[objectId];
@@ -430,7 +430,7 @@ void MADSAction::checkActionAtMousePos() {
 				_flags1 = invObject._vocabList[_selectedRow - 2]._actionFlags1;
 				_flags2 = invObject._vocabList[_selectedRow - 2]._actionFlags2;
 				_hotspotId = userInterface._selectedInvIndex;
-				_actionMode2 = ACTIONMODE2_2;
+				_mainObjectSource = ACTIONMODE2_2;
 
 				if (_flags1 == 2)
 					_articleNumber = _flags2;
@@ -439,13 +439,13 @@ void MADSAction::checkActionAtMousePos() {
 
 		case CAT_HOTSPOT:
 			_selectedRow = -1;
-			_actionMode = ACTIONMODE_NONE;
-			_actionMode2 = ACTIONMODE2_4;
+			_commandSource = ACTIONMODE_NONE;
+			_mainObjectSource = ACTIONMODE2_4;
 			_hotspotId = _pickedWord;
 			break;
 
 		case CAT_TALK_ENTRY:
-			_actionMode = ACTIONMODE_TALK;
+			_commandSource = ACTIONMODE_TALK;
 			_selectedRow = _pickedWord;
 			break;
 
@@ -461,7 +461,7 @@ void MADSAction::checkActionAtMousePos() {
 		case CAT_HOTSPOT:
 		case CAT_INV_ANIM:
 			// TODO: We may not need a separate ActionMode2 enum
-			_actionMode2 = (ActionMode2)userInterface._category;
+			_mainObjectSource = userInterface._category;
 			_hotspotId = _pickedWord;
 			break;
 		default:
@@ -474,8 +474,8 @@ void MADSAction::checkActionAtMousePos() {
 		case CAT_INV_LIST:
 		case CAT_HOTSPOT:
 		case CAT_INV_ANIM:
-			_v86F42 = userInterface._category;
-			_v86F3A = _pickedWord;
+			_secondObjectSource = userInterface._category;
+			_secondObject = _pickedWord;
 			break;
 		default:
 			break;
@@ -490,7 +490,6 @@ void MADSAction::checkActionAtMousePos() {
 void MADSAction::leftClick() {
 	Scene &scene = _vm->_game->_scene;
 	UserInterface &userInterface = scene._userInterface;
-	ScreenObjects &screenObjects = _vm->_game->_screenObjects;
 	bool abortFlag = false;
 
 	if ((userInterface._category == CAT_COMMAND || userInterface._category == CAT_INV_VOCAB) &&
@@ -522,7 +521,7 @@ void MADSAction::leftClick() {
 				}
 				else {
 					_recentCommand = _selectedRow;
-					_recentCommandSource = _actionMode;
+					_recentCommandSource = _commandSource;
 					_interAwaiting = AWAITING_THIS;
 				}
 			}
@@ -551,7 +550,7 @@ void MADSAction::leftClick() {
 				}
 
 				_recentCommand = _selectedRow;
-				_recentCommandSource = _actionMode;
+				_recentCommandSource = _commandSource;
 			}
 			break;
 
@@ -606,7 +605,7 @@ void MADSAction::leftClick() {
 		case CAT_INV_LIST:
 		case CAT_HOTSPOT:
 		case CAT_INV_ANIM:
-			if (_v86F3A >= 0) {
+			if (_secondObject >= 0) {
 				_selectedAction = -1;
 
 				if (userInterface._category == CAT_HOTSPOT) {
diff --git a/engines/mads/action.h b/engines/mads/action.h
index 45886c1..4b51ec9 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -28,8 +28,9 @@
 
 namespace MADS {
 
-enum ActionMode { ACTIONMODE_NONE = 0, ACTIONMODE_VERB = 1, ACTIONMODE_OBJECT = 3, ACTIONMODE_TALK = 6 };
-enum ActionMode2 { ACTIONMODE2_0 = 0, ACTIONMODE2_2 = 2, ACTIONMODE2_4 = 4, ACTIONMODE2_5 = 5 };
+enum { ACTIONMODE_NONE = 0, ACTIONMODE_VERB = 1, ACTIONMODE_OBJECT = 3, ACTIONMODE_TALK = 6 };
+enum { ACTIONMODE2_0 = 0, ACTIONMODE2_2 = 2, ACTIONMODE2_4 = 4, ACTIONMODE2_5 = 5 };
+
 enum TriggerMode { 
 	KERNEL_TRIGGER_PARSER = 0,		// Triggers parser
 	KERNEL_TRIGGER_DAEMON = 1,		// Triggers step/daemon code
@@ -69,12 +70,13 @@ struct ActionDetails {
 };
 
 struct ActionSavedFields {
-	int _actionMode;
-	int _selectedRow;
-	int _hotspotId;
-	int _v86F3A;
-	int _actionMode2;
-	int _v86F42;
+	bool _commandError;
+	int _commandSource;
+	int _command;
+	int _mainObject;
+	int _secondObject;
+	int _mainObjectSource;
+	int _secondObjectSource;
 	int _articleNumber;
 	int _lookFlag;
 };
@@ -90,8 +92,8 @@ private:
 public:
 	ActionDetails _action, _activeAction;
 	int8 _flags1, _flags2;
-	ActionMode _actionMode;
-	ActionMode2 _actionMode2;
+	int _commandSource;
+	int _mainObjectSource;
 	int _articleNumber;
 	bool _lookFlag;
 	int _selectedRow;
@@ -103,14 +105,13 @@ public:
 	Common::String _sentence;
 
 	// Unknown fields
-	int16 _v86F3A;
-	int16 _v86F42;
+	int16 _secondObject;
+	int16 _secondObjectSource;
 	int16 _recentCommandSource;
 	bool _v86F4A;
 	int16 _recentCommand;
 	InterAwaiting _interAwaiting;
 	bool _inProgress;
-	int _v8453A;
 	int _pickedWord;
 
 public:
@@ -120,7 +121,14 @@ public:
 	void set();
 	const Common::String &statusText() const { return _statusText; }
 	void refresh();
+
+	/**
+	 * Accepts the currently defined sentence from the ScreenObjects parser.
+	 * Copies the data, and checks to see if the action requires the player
+	 * to walk to the given hotspot.
+	 */
 	void startAction();
+
 	void checkAction();
 	bool isAction(int verbId, int objectNameId = 0, int indirectObjectId = 0);
 	
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 2736e77..090ddd0 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -172,7 +172,7 @@ void Game::sectionLoop() {
 
 		// Reset the user interface
 		_screenObjects._v8333C = true;
-		_screenObjects._v832EC = 0;
+		_screenObjects._inputMode = kInputBuildingSentences;
 		_scene._userInterface._scrollerY = 0;
 		
 		_player._loadsFirst = true;
diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
index 22e4feb..fec1f6e 100644
--- a/engines/mads/hotspots.cpp
+++ b/engines/mads/hotspots.cpp
@@ -131,9 +131,9 @@ void DynamicHotspots::refresh() {
 		DynamicHotspot &dh = (*this)[i];
 
 		if ((*this)[i]._active) {
-			switch (scrObjects._v832EC) {
-			case 0:
-			case 2:
+			switch (scrObjects._inputMode) {
+			case kInputBuildingSentences:
+			case kInputLimitedSentences:
 				scrObjects.add(dh._bounds, _vm->_game->_scene._layer, CAT_12, dh._descId);
 				scrObjects._v8333C = true;
 				break;
diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index a8e50e6..43b7b6e 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -116,7 +116,8 @@ void InventoryObjects::addToInventory(int objectId) {
 
 		(*this)[objectId]._roomNumber = PLAYER_INVENTORY;
 
-		if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE && !_vm->_game->_screenObjects._v832EC) {
+		if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE && 
+				_vm->_game->_screenObjects._inputMode == kInputBuildingSentences) {
 			userInterface.categoryChanged();
 			userInterface.selectObject(userInterface._selectedInvIndex);
 		}
@@ -137,7 +138,8 @@ void InventoryObjects::removeFromInventory(int objectId, int newScene) {
 	int selectedIndex = userInterface._selectedInvIndex;
 	bool noSelection = selectedIndex < 0;
 
-	if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE && !_vm->_game->_screenObjects._v832EC)
+	if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE && 
+			_vm->_game->_screenObjects._inputMode == kInputBuildingSentences)
 		userInterface.selectObject(-1);
 
 	// Remove the item from the inventory list
@@ -158,7 +160,8 @@ void InventoryObjects::removeFromInventory(int objectId, int newScene) {
 			newIndex = 0;
 	}
 
-	if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE && !_vm->_game->_screenObjects._v832EC) {
+	if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE && 
+			_vm->_game->_screenObjects._inputMode == kInputBuildingSentences) {
 		userInterface.categoryChanged();
 		userInterface.selectObject(newIndex);
 	}
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index e8d8a28..b91384d 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -760,7 +760,7 @@ void Scene202::actions() {
 			}
 			_scene->_nextSceneId = 201;
 		} else if (action->isAction(VERB_TAKE, 0x2C)) {
-			if (action->_actionMode2 == 4) {
+			if (action->_mainObjectSource == 4) {
 				if (_game._trigger == 0) {
 					if (_game._objects.isInInventory(OBJ_BONES)) {
 						_vm->_dialogs->show(0x4EFB);
@@ -952,7 +952,7 @@ void Scene202::actions() {
 		} else if (action->isAction(VERB_TAKE, 0x140)) {
 			_vm->_dialogs->show(0x4EF8);
 		} else if (action->isAction(VERB_LOOK, 0x2D)) {
-			if (action->_actionMode == 4)
+			if (action->_commandSource == 4)
 				_vm->_dialogs->show(0x4EF9);
 			else
 				return;
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index cb761ca..f8eeb37 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -138,7 +138,7 @@ void Scene804::enter() {
 	Scene8xx::enter1();
 
 	if (_globals[kInSpace] && !_globals[kWindowFixed]) {
-		_scene->_userInterface.setup(2);
+		_scene->_userInterface.setup(kInputLimitedSentences);
 		_vm->_sound->command(19);
 	}
 }
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 9e27f27..a71eade 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -160,7 +160,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	_interfaceY = MADS_SCENE_HEIGHT;
 	_spritesCount = _sprites.size();
 
-	_userInterface.setup(_vm->_game->_screenObjects._v832EC);
+	_userInterface.setup(_vm->_game->_screenObjects._inputMode);
 
 	warning("TODO: showMouse");
 
@@ -299,7 +299,7 @@ void Scene::doFrame() {
 		_action.startAction();
 		if (_action._activeAction._verbId == Nebular::NOUN_LOOK_AT) {
 			_action._activeAction._verbId = VERB_LOOK;
-			_action._savedFields._selectedRow = false;
+			_action._savedFields._command = false;
 		}
 
 		flag = true;
@@ -438,7 +438,8 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
 }
 
 void Scene::doPreactions() {
-	if (_vm->_game->_screenObjects._v832EC == 0 || _vm->_game->_screenObjects._v832EC == 2) {
+	if (_vm->_game->_screenObjects._inputMode == kInputBuildingSentences || 
+			_vm->_game->_screenObjects._inputMode == kInputLimitedSentences) {
 		_vm->_game->_triggerSetupMode = KERNEL_TRIGGER_PREPARE;
 		_action.checkAction();
 		_sceneLogic->preActions();
@@ -449,37 +450,38 @@ void Scene::doPreactions() {
 }
 
 void Scene::doAction() {
-	int flag = 0;
+	bool flag = false;
 
 	_vm->_game->_triggerSetupMode = KERNEL_TRIGGER_PARSER;
-	if ((_action._inProgress || _vm->_game->_trigger) && !_action._v8453A) {
+	if ((_action._inProgress || _vm->_game->_trigger) && !_action._savedFields._commandError) {
 		_sceneLogic->actions();
 		_action._inProgress = true;
-		flag = -1;
+		flag = true;
 	}
 
-	if (_vm->_game->_screenObjects._v832EC == 1) {
+	if (_vm->_game->_screenObjects._inputMode == kInputConversation) {
 		_action._inProgress = false;
 	} else {
 		if ((_action._inProgress || _vm->_game->_trigger) ||
-				(!flag && _action._v8453A == flag)) {
+			(!flag && _action._savedFields._commandError == flag)) {
 			_vm->_game->_sectionHandler->sectionPtr2();
 			_action._inProgress = true;
-			flag = -1;
+			flag = true;
 		}
 
-		if ((_action._inProgress || _vm->_game->_trigger) && (!flag || _action._v8453A == flag)) {
+		if ((_action._inProgress || _vm->_game->_trigger) && 
+				(!flag || _action._savedFields._commandError == flag)) {
 			_vm->_game->doObjectAction();
 		}
 
 		if (!_action._savedFields._lookFlag) {
 			if (!_action._inProgress) {
-				_action._v8453A = -1;
+				_action._savedFields._commandError = true;
 				_sceneLogic->postActions();
 			}
 
 			if (!_action._inProgress) {
-				_action._v8453A = -1;
+				_action._savedFields._commandError = true;
 				warning("TODO: PtrUnk4");
 			}
 
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index b55d80c9..44f0907 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -253,7 +253,7 @@ ScreenObject::ScreenObject() {
 ScreenObjects::ScreenObjects(MADSEngine *vm) : _vm(vm) {
 	_objectY = -1;
 	_v8333C = false;
-	_v832EC = 0;
+	_inputMode = kInputBuildingSentences;
 	_v7FED6 = 0;
 	_v8332A = 0;
 	_category = CAT_NONE;
@@ -285,7 +285,7 @@ void ScreenObjects::check(bool scanFlag) {
 	Scene &scene = _vm->_game->_scene;
 	UserInterface &userInterface = scene._userInterface;
 
-	if (!_vm->_events->_mouseButtons || _v832EC)
+	if (!_vm->_events->_mouseButtons || _inputMode != kInputBuildingSentences)
 		_vm->_events->_anyStroke = false;
 
 	if ((_vm->_events->_mouseMoved || _vm->_game->_scene._userInterface._scrollerY 
@@ -380,7 +380,7 @@ void ScreenObjects::checkScroller() {
 	UserInterface &userInterface = _vm->_game->_scene._userInterface;
 	Common::Array<int> &inventoryList = _vm->_game->_objects._inventoryList;
 
-	if (_v832EC)
+	if (_inputMode != kInputBuildingSentences)
 		return;
 
 	userInterface._scrollerY = 0;
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index 31fdd2a..3595907 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -55,6 +55,12 @@ enum ScreenTransition {
 	kVertTransition7, kCenterVertTransition
 };
 
+enum InputMode {
+	kInputBuildingSentences = 0,		// Normal sentence building
+	kInputConversation = 1,			// Conversation mode
+	kInputLimitedSentences = 2		// Use only scene hotspots
+};
+
 class SpriteSlot;
 class TextDisplay;
 class UISlot;
@@ -148,7 +154,7 @@ private:
 	 */
 	void checkScroller();
 public:
-	int _v832EC;
+	InputMode _inputMode;
 	int _v7FED6;
 	int _v8332A;
 	int _v8333C;
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 7ed1884..4b174e8 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -239,10 +239,10 @@ void UserInterface::load(const Common::String &resName) {
 	delete pixelsStream;
 }
 
-void UserInterface::setup(int id) {
+void UserInterface::setup(InputMode inputMode) {
 	Scene &scene = _vm->_game->_scene;
 
-	if (_vm->_game->_screenObjects._v832EC != id) {
+	if (_vm->_game->_screenObjects._inputMode != inputMode) {
 		Common::String resName = _vm->_game->_aaName;
 
 		// Strip off any extension
@@ -252,7 +252,7 @@ void UserInterface::setup(int id) {
 		}
 
 		// Add on suffix if necessary
-		if (id)
+		if (inputMode != kInputBuildingSentences)
 			resName += "A";
 
 		resName += ".INT";
@@ -260,7 +260,7 @@ void UserInterface::setup(int id) {
 		load(resName);
 		_surface.copyTo(this);
 	}
-	_vm->_game->_screenObjects._v832EC = id;
+	_vm->_game->_screenObjects._inputMode = inputMode;
 
 	scene._userInterface._uiSlots.clear();
 	scene._userInterface._uiSlots.fullRefresh();
@@ -279,7 +279,7 @@ void UserInterface::setup(int id) {
 }
 
 void UserInterface::drawTextElements() {
-	if (_vm->_game->_screenObjects._v832EC) {
+	if (_vm->_game->_screenObjects._inputMode) {
 		drawTalkList();
 	} else {
 		// Draw the actions
@@ -408,7 +408,7 @@ void UserInterface::loadElements() {
 	Common::Rect bounds;
 	_vm->_game->_screenObjects.clear();
 
-	if (!_vm->_game->_screenObjects._v832EC) {
+	if (_vm->_game->_screenObjects._inputMode == kInputBuildingSentences) {
 		// Set up screen objects for the inventory scroller
 		for (int idx = 1; idx <= 3; ++idx) {
 			getBounds(CAT_INV_SCROLLER, idx, bounds);
@@ -450,7 +450,8 @@ void UserInterface::loadElements() {
 			CAT_INV_ANIM, 0);
 	}
 
-	if (!_vm->_game->_screenObjects._v832EC || _vm->_game->_screenObjects._v832EC == 2) {
+	if (!_vm->_game->_screenObjects._inputMode == kInputBuildingSentences || 
+			_vm->_game->_screenObjects._inputMode == kInputLimitedSentences) {
 		_categoryIndexes[CAT_HOTSPOT - 1] = _vm->_game->_screenObjects.size() + 1;
 		for (int hotspotIdx = scene._hotspots.size() - 1; hotspotIdx >= 0; --hotspotIdx) {
 			Hotspot &hs = scene._hotspots[hotspotIdx];
@@ -458,7 +459,7 @@ void UserInterface::loadElements() {
 		}
 	}
 
-	if (_vm->_game->_screenObjects._v832EC == 1) {
+	if (_vm->_game->_screenObjects._inputMode == kInputConversation) {
 		// setup areas for talk entries
 		_categoryIndexes[CAT_TALK_ENTRY - 1] = _vm->_game->_screenObjects.size() + 1;
 		for (int idx = 0; idx < 5; ++idx) {
@@ -594,7 +595,7 @@ void UserInterface::noInventoryAnim() {
 		_invSpritesIndex = -1;
 	}
 
-	if (!_vm->_game->_screenObjects._v832EC)
+	if (_vm->_game->_screenObjects._inputMode == kInputBuildingSentences)
 		refresh();
 }
 
@@ -608,8 +609,9 @@ void UserInterface::refresh() {
 
 void UserInterface::inventoryAnim() {
 	Scene &scene = _vm->_game->_scene;
-	if (_vm->_game->_screenObjects._v832EC == 1 || _vm->_game->_screenObjects._v832EC == 2
-			|| _invSpritesIndex < 0)
+	if (_vm->_game->_screenObjects._inputMode == kInputConversation || 
+			_vm->_game->_screenObjects._inputMode == kInputLimitedSentences ||
+			_invSpritesIndex < 0)
 		return;
 
 	// Move to the next frame number in the sequence, resetting if at the end
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 53c1e10..445cd1e 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -166,7 +166,7 @@ public:
 	/**
 	* Set up the interface
 	*/
-	void setup(int id);
+	void setup(InputMode inputMode);
 
 	void drawTextElements();
 


Commit: 25b93a11ee28256331bb52ccdf5441e357c367c1
    https://github.com/scummvm/scummvm/commit/25b93a11ee28256331bb52ccdf5441e357c367c1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-03T22:36:36-04:00

Commit Message:
MADS: Fix hotspot loading, and a couple of other warnings

Changed paths:
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/user_interface.cpp



diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index fea5fa5..bfc225e 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -124,7 +124,7 @@ bool DialogsNebular::show(int msgId) {
 	Common::String valStr;
 	Common::String dialogText;
 	bool result = true;
-	bool centerFlag;
+	bool centerFlag = false;
 	bool underlineFlag;
 	bool commandFlag;
 	bool crFlag;
@@ -268,7 +268,7 @@ bool DialogsNebular::textNoun(Common::String &dialogText, int nounNum,
 
 bool DialogsNebular::commandCheck(const char *idStr, Common::String &valStr,
 		const Common::String &command) {
-	int idLen = strlen(idStr);
+	uint idLen = strlen(idStr);
 	
 	valStr = (command.size() <= idLen) ? "" : Common::String(command.c_str() + idLen);
 
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 4b174e8..d229c39 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -450,7 +450,7 @@ void UserInterface::loadElements() {
 			CAT_INV_ANIM, 0);
 	}
 
-	if (!_vm->_game->_screenObjects._inputMode == kInputBuildingSentences || 
+	if (_vm->_game->_screenObjects._inputMode == kInputBuildingSentences || 
 			_vm->_game->_screenObjects._inputMode == kInputLimitedSentences) {
 		_categoryIndexes[CAT_HOTSPOT - 1] = _vm->_game->_screenObjects.size() + 1;
 		for (int hotspotIdx = scene._hotspots.size() - 1; hotspotIdx >= 0; --hotspotIdx) {


Commit: 19a814f38ccb6c3758e6dacd3d3e1747e2aa6947
    https://github.com/scummvm/scummvm/commit/19a814f38ccb6c3758e6dacd3d3e1747e2aa6947
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-03T22:50:47-04:00

Commit Message:
MADS: Fix setting _commandError in MADSAction::startAction

Changed paths:
    engines/mads/action.cpp
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 8ee46e2..0050580 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -289,7 +289,7 @@ void MADSAction::startAction() {
 	_activeAction = _action;
 	_sentence = _statusText;
 
-	if ((_mainObjectSource == ACTIONMODE2_4) && (_secondObjectSource == 0))
+	if ((_mainObjectSource == ACTIONMODE2_4) && (_secondObjectSource == 4))
 		_savedFields._commandError = true;
 
 	player._needToWalk = false;
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 51a2d95..b429aa0 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -278,8 +278,7 @@ void Scene103::actions() {
 		default:
 			break;
 		}
-	}
-	else if (_action.isAction(VERB_TAKE, 371) && _game._objects.isInRoom(OBJ_TIMER_MODULE)) {
+	} else if (_action.isAction(VERB_TAKE, 371) && _game._objects.isInRoom(OBJ_TIMER_MODULE)) {
 		switch (_vm->_game->_trigger) {
 		case 0:
 			_scene->changeDepthSurface(1);
@@ -370,8 +369,7 @@ void Scene103::actions() {
 		}
 	} else if (_action.isAction(VERB_LOOK, 250)) {
 		_vm->_dialogs->show(!_globals[kTurkeyExploded] ? 10323 : 10303);
-	}
-	else if (_action.isAction(VERB_TALKTO, 27)) {
+	} else if (_action.isAction(VERB_TALKTO, 27)) {
 		switch (_vm->_game->_trigger) {
 		case 0: {
 			_game._player._stepEnabled = false;


Commit: 7f15c6d5fd0f2c1bfef1d69d0556233543a6cd8a
    https://github.com/scummvm/scummvm/commit/7f15c6d5fd0f2c1bfef1d69d0556233543a6cd8a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-04T08:19:37-04:00

Commit Message:
MADS: Beginnings of proper look dialog display

Changed paths:
    engines/mads/dialogs.cpp
    engines/mads/dialogs.h
    engines/mads/nebular/dialogs_nebular.cpp



diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index 1215df3..13342f1 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -59,8 +59,8 @@ void Dialog::draw() {
 
 	// Draw the dialog
 	// Fill entire content of dialog
-	_vm->_screen.fillRect(Common::Rect(_position.x, _position.y,
-		_position.x + _width, _position.y + _height), TEXTDIALOG_BACKGROUND);
+	Common::Rect bounds = getBounds();
+	_vm->_screen.fillRect(bounds, TEXTDIALOG_BACKGROUND);
 
 	// Draw the outer edge lines
 	_vm->_screen.hLine(_position.x + 1, _position.y + _height - 2,
@@ -76,6 +76,8 @@ void Dialog::draw() {
 	drawContent(Common::Rect(_position.x + 2, _position.y + 2,
 		_position.x + _width - 2, _position.y + _height - 2), 0,
 		TEXTDIALOG_CONTENT1, TEXTDIALOG_CONTENT2);
+
+	_vm->_screen.copyRectToScreen(bounds);
 }
 
 void Dialog::drawContent(const Common::Rect &r, int seed, byte color1, byte color2) {
@@ -103,12 +105,12 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName,
 		const Common::Point &pos, int maxChars):
 		Dialog(vm) {
 	_vm = vm;
-	_fontName = fontName;
+	_font = _vm->_font->getFont(fontName);
 	_position = pos;
 	
 	_vm->_font->setColors(TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK);
 
-	_innerWidth = (_vm->_font->maxWidth() + 1) * maxChars;
+	_innerWidth = (_font->maxWidth() + 1) * maxChars;
 	_width = _innerWidth + 10;
 	_lineSize = maxChars * 2;
 	_lineWidth = 0;
@@ -139,7 +141,7 @@ void TextDialog::addLine(const Common::String &line, bool underline) {
 	if (_lineWidth > 0 || _currentX > 0)
 		incNumLines();
 
-	int stringWidth = _vm->_font->getWidth(line, 1);
+	int stringWidth = _font->getWidth(line, 1);
 	if (stringWidth >= _innerWidth || (int)line.size() >= _lineSize) {
 		wordWrap(line);
 	} else {
@@ -211,7 +213,7 @@ void TextDialog::wordWrap(const Common::String &line) {
 				tempLine2 += ' ';
 			tempLine2 += tempLine;
 
-			int lineWidth = _vm->_font->getWidth(tempLine2, 1);
+			int lineWidth = _font->getWidth(tempLine2, 1);
 			if (((_currentX + (int)tempLine2.size()) > _lineSize) ||
 					((_lineWidth + lineWidth) > _innerWidth)) {
 				incNumLines();
@@ -228,7 +230,7 @@ void TextDialog::wordWrap(const Common::String &line) {
 
 void TextDialog::appendLine(const Common::String &line) {
 	_currentX += line.size();
-	_lineWidth += _vm->_font->getWidth(line, 1);
+	_lineWidth += _font->getWidth(line, 1);
 	_lines[_numLines] += line;
 }
 
@@ -255,7 +257,7 @@ void TextDialog::draw() {
 		--_numLines;
 
 	// Figure out the size and position for the dialog
-	_height = (_vm->_font->getHeight() + 1) * (_numLines + 1) + 10;
+	_height = (_font->getHeight() + 1) * (_numLines + 1) + 10;
 	if (_position.x == -1)
 		_position.x = 160 - (_width / 2);
 	if (_position.y == -1)
@@ -275,7 +277,7 @@ void TextDialog::draw() {
 		if (_lineXp[lineNum] == -1) {
 			// Draw a line across the entire dialog
 			_vm->_screen.hLine(_position.x + 2, 
-				lineYp + (_vm->_font->getHeight() + 1)  / 2,
+				lineYp + (_font->getHeight() + 1)  / 2,
 				_position.x + _width - 4, TEXTDIALOG_BLACK);
 		} else {
 			// Draw a text line
@@ -284,24 +286,26 @@ void TextDialog::draw() {
 			if (_lineXp[lineNum] & 0x40)
 				++yp;
 
-			_vm->_font->writeString(&_vm->_screen, _lines[lineNum], 
+			_font->writeString(&_vm->_screen, _lines[lineNum], 
 				Common::Point(xp, yp), 1);
 
 			if (_lineXp[lineNum] & 0x80) {
 				// Draw an underline under the text
-				int lineWidth = _vm->_font->getWidth(_lines[lineNum], 1);
-				_vm->_screen.hLine(xp, yp + _vm->_font->getHeight(), xp + lineWidth,
+				int lineWidth = _font->getWidth(_lines[lineNum], 1);
+				_vm->_screen.hLine(xp, yp + _font->getHeight(), xp + lineWidth,
 					TEXTDIALOG_BLACK);
 			}
 		}
 
-		lineYp += _vm->_font->getHeight() + 1;
+		lineYp += _font->getHeight() + 1;
 	}
+
+	_vm->_screen.copyRectToScreen(getBounds());
 }
 
 void TextDialog::drawWithInput() {
 	//int innerWidth = _innerWidth;
-	//int lineHeight = _vm->_font->getHeight() + 1;
+	//int lineHeight = _font->getHeight() + 1;
 	//int xp = _position.x + 5;
 
 	// Draw the content of the dialog
@@ -322,10 +326,9 @@ void TextDialog::show() {
 	draw();
 	_vm->_events->showCursor();
 
-	while (!_vm->shouldQuit() && !_vm->_events->_keyPressed &&
-		!_vm->_events->_mouseClicked) {
-		_vm->_events->delay(1);
-	}
+	do {
+		_vm->_events->waitForNextFrame();
+	} while (!_vm->shouldQuit() && !_vm->_events->_mouseReleased);
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index fe6041e..2c7c342 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "mads/game.h"
+#include "mads/font.h"
 #include "mads/msurface.h"
 
 namespace MADS {
@@ -68,6 +69,14 @@ public:
 	 * Destructor
 	 */
 	virtual ~Dialog();
+
+	/**
+	 * Return the bounds of the dialog.
+	 */
+	Common::Rect getBounds() const {
+		return Common::Rect(_position.x, _position.y,
+			_position.x + _width, _position.y + _height);
+	}
 };
 
 enum {
@@ -95,7 +104,7 @@ private:
 	 */
 	void restorePalette();
 protected:
-	Common::String _fontName;
+	Font *_font;
 	int _innerWidth;
 	int _lineWidth;
 	int _currentX;
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index bfc225e..3be3db3 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -135,8 +135,8 @@ bool DialogsNebular::show(int msgId) {
 	// Loop through the lines of the returned text
 	for (uint idx = 0; idx < msg.size(); ++idx) {
 		Common::String srcLine = msg[idx];
-
 		const char *srcP = srcLine.c_str();
+		dialogText = "";
 		commandFlag = false;
 		underlineFlag = false;
 		centerFlag = false;


Commit: 366e6ae38f9916277096f93bed393edd0cd83e45
    https://github.com/scummvm/scummvm/commit/366e6ae38f9916277096f93bed393edd0cd83e45
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-04T09:07:40-04:00

Commit Message:
MADS: Fix action checks in scene 103 actions code

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index b429aa0..cda8f89 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -398,29 +398,29 @@ void Scene103::actions() {
 		default:
 			break;
 		}
-	} else if (!_action.isAction(VERB_LOOK, 27)) {
+	} else if (_action.isAction(VERB_LOOK, 27)) {
 		_vm->_dialogs->show(10304);
-	} else if (!_action.isAction(VERB_LOOK, 36)) {
+	} else if (_action.isAction(VERB_LOOK, 36)) {
 		_vm->_dialogs->show(10307);
-	} else if (!_action.isAction(VERB_LOOK, 55)) {
+	} else if (_action.isAction(VERB_LOOK, 55)) {
 		_vm->_dialogs->show(10308);
-	} else if (!_action.isAction(VERB_TAKE, 315)) {
+	} else if (_action.isAction(VERB_TAKE, 315)) {
 		_vm->_dialogs->show(10309);
-	} else if (!_action.isAction(VERB_TAKE, 85)) {
+	} else if (_action.isAction(VERB_TAKE, 85)) {
 		_vm->_dialogs->show(10310);
-	} else if (!_action.isAction(VERB_LOOK, 144)) {
+	} else if (_action.isAction(VERB_LOOK, 144)) {
 		_vm->_dialogs->show(10312);
-	} else if (!_action.isAction(VERB_OPEN, 144)) {
+	} else if (_action.isAction(VERB_OPEN, 144)) {
 		_vm->_dialogs->show(10313);
-	} else if (!_action.isAction(VERB_CLOSE, 27)) {
+	} else if (_action.isAction(VERB_CLOSE, 27)) {
 		_vm->_dialogs->show(10314);
-	} else if (!_action.isAction(VERB_LOOK, 310)) {
+	} else if (_action.isAction(VERB_LOOK, 310)) {
 		_vm->_dialogs->show(10315);
-	} else if (!_action.isAction(VERB_LOOK, 178)) {
+	} else if (_action.isAction(VERB_LOOK, 178)) {
 		_vm->_dialogs->show(10316);
-	} else if (!_action.isAction(VERB_LOOK, 283)) {
+	} else if (_action.isAction(VERB_LOOK, 283)) {
 		_vm->_dialogs->show(10317);
-	} else if (!_action.isAction(VERB_LOOK, 120)) {
+	} else if (_action.isAction(VERB_LOOK, 120)) {
 		_vm->_dialogs->show(10318);
 	} else if (_action.isAction(VERB_LOOK, 289) &&
 			_game._objects.isInInventory(OBJ_REBREATHER)) {
@@ -428,7 +428,7 @@ void Scene103::actions() {
 	} else if (_action.isAction(VERB_LOOK, 371) &&
 			_game._objects.isInInventory(OBJ_TIMER_MODULE)) {
 		_vm->_dialogs->show(10320);
-	} else if (!_action.isAction(VERB_LOOK, 137)) {
+	} else if (_action.isAction(VERB_LOOK, 137)) {
 		_vm->_dialogs->show(10321);
 	} else if (_action.isAction(VERB_LOOK, 409)) {
 		_vm->_dialogs->show(_game._objects.isInInventory(OBJ_TIMER_MODULE) ? 10324 : 10325);


Commit: 4639d37609f62bae8d0bcffc5a2e64c79f2659a7
    https://github.com/scummvm/scummvm/commit/4639d37609f62bae8d0bcffc5a2e64c79f2659a7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-04T09:35:18-04:00

Commit Message:
MADS: Fixes for properly displaying the text of a message dialog

Changed paths:
    engines/mads/dialogs.cpp
    engines/mads/font.cpp
    engines/mads/nebular/dialogs_nebular.cpp



diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index 13342f1..d5e8ad5 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -43,6 +43,8 @@ void Dialog::save(MSurface *s) {
 	s->copyTo(_savedSurface, 
 		Common::Rect(_position.x, _position.y, _position.x + _width, _position.y + _height),
 		Common::Point());
+
+	_vm->_screen.copyRectToScreen(getBounds());
 }
 
 void Dialog::restore(MSurface *s) {
@@ -50,6 +52,8 @@ void Dialog::restore(MSurface *s) {
 		_savedSurface->copyTo(s, _position);
 		delete _savedSurface;
 		_savedSurface = nullptr;
+
+		_vm->_screen.copyRectToScreen(getBounds());
 	}
 }
 
@@ -76,8 +80,6 @@ void Dialog::draw() {
 	drawContent(Common::Rect(_position.x + 2, _position.y + 2,
 		_position.x + _width - 2, _position.y + _height - 2), 0,
 		TEXTDIALOG_CONTENT1, TEXTDIALOG_CONTENT2);
-
-	_vm->_screen.copyRectToScreen(bounds);
 }
 
 void Dialog::drawContent(const Common::Rect &r, int seed, byte color1, byte color2) {
@@ -273,7 +275,7 @@ void TextDialog::draw() {
 
 	// Draw the text lines
 	int lineYp = _position.y + 5; 
-	for (int lineNum = 0; lineNum < _numLines; ++lineNum) {
+	for (int lineNum = 0; lineNum <= _numLines; ++lineNum) {
 		if (_lineXp[lineNum] == -1) {
 			// Draw a line across the entire dialog
 			_vm->_screen.hLine(_position.x + 2, 
@@ -326,9 +328,14 @@ void TextDialog::show() {
 	draw();
 	_vm->_events->showCursor();
 
+	// Wait for mouse click
 	do {
 		_vm->_events->waitForNextFrame();
 	} while (!_vm->shouldQuit() && !_vm->_events->_mouseReleased);
+
+	// Allow the mouse release to be gobbled up
+	if (!_vm->shouldQuit())
+		_vm->_events->waitForNextFrame();
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/font.cpp b/engines/mads/font.cpp
index 294139c..ba10099 100644
--- a/engines/mads/font.cpp
+++ b/engines/mads/font.cpp
@@ -141,7 +141,7 @@ int Font::writeString(MSurface *surface, const Common::String &msg, const Common
 	if (width > 0)
 		xEnd = MIN((int)surface->w, pt.x + width);
 	else
-		xEnd = surface->w - pt.x;
+		xEnd = surface->w;
 
 	int x = pt.x;
 	int y = pt.y;
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 3be3db3..ff25696 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -125,9 +125,9 @@ bool DialogsNebular::show(int msgId) {
 	Common::String dialogText;
 	bool result = true;
 	bool centerFlag = false;
-	bool underlineFlag;
-	bool commandFlag;
-	bool crFlag;
+	bool underlineFlag = false;
+	bool commandFlag = false;
+	bool crFlag = false;
 	TextDialog *dialog = nullptr;
 	_dialogWidth = 17; 
 	_capitalizationMode = kUppercase;
@@ -136,11 +136,6 @@ bool DialogsNebular::show(int msgId) {
 	for (uint idx = 0; idx < msg.size(); ++idx) {
 		Common::String srcLine = msg[idx];
 		const char *srcP = srcLine.c_str();
-		dialogText = "";
-		commandFlag = false;
-		underlineFlag = false;
-		centerFlag = false;
-		crFlag = false;
 
 		// Loop through the text of the line
 		while (srcP < srcLine.c_str() + srcLine.size()) {
@@ -226,6 +221,13 @@ bool DialogsNebular::show(int msgId) {
 		} else {
 			dialog->wordWrap(dialogText);
 		}
+
+		// Reset line processing flags in preparation for next line
+		dialogText = "";
+		commandFlag = false;
+		underlineFlag = false;
+		centerFlag = false;
+		crFlag = false;
 	}
 
 	if (!centerFlag)


Commit: b778217d8eea64d385947a96a94cdea7c686c605
    https://github.com/scummvm/scummvm/commit/b778217d8eea64d385947a96a94cdea7c686c605
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-04T20:57:09-04:00

Commit Message:
MADS: Fix for actions get repeated endlessly

Changed paths:
    engines/mads/scene.cpp



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index a71eade..64260a6 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -455,8 +455,7 @@ void Scene::doAction() {
 	_vm->_game->_triggerSetupMode = KERNEL_TRIGGER_PARSER;
 	if ((_action._inProgress || _vm->_game->_trigger) && !_action._savedFields._commandError) {
 		_sceneLogic->actions();
-		_action._inProgress = true;
-		flag = true;
+		flag = !_action._inProgress;
 	}
 
 	if (_vm->_game->_screenObjects._inputMode == kInputConversation) {
@@ -465,8 +464,7 @@ void Scene::doAction() {
 		if ((_action._inProgress || _vm->_game->_trigger) ||
 			(!flag && _action._savedFields._commandError == flag)) {
 			_vm->_game->_sectionHandler->sectionPtr2();
-			_action._inProgress = true;
-			flag = true;
+			flag = !_action._inProgress;
 		}
 
 		if ((_action._inProgress || _vm->_game->_trigger) && 


Commit: ebe4d369a54d852b7d789ac247a872799e68e495
    https://github.com/scummvm/scummvm/commit/ebe4d369a54d852b7d789ac247a872799e68e495
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-05T12:43:50-04:00

Commit Message:
MADS: Fixes for actions triggering prematurely

Changed paths:
    engines/mads/action.cpp
    engines/mads/events.cpp
    engines/mads/game.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/scene.cpp
    engines/mads/sequence.cpp
    engines/mads/sequence.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 0050580..ccfd13b 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -320,7 +320,7 @@ void MADSAction::startAction() {
 	if (hotspotId >= 0 && hotspotId < (int)hotspots.size()) {
 		Hotspot &hs = hotspots[hotspotId];
 
-		if (hs._feetPos.x == -1 || hs._feetPos.x != -3) {
+		if (hs._feetPos.x == -1 || hs._feetPos.x == -3) {
 			checkCustomDest(hs._feetPos.x);
 		} else if (hs._feetPos.x >= 0) {
 			if (_savedFields._commandSource == ACTIONMODE_NONE || hs._cursor < CURSOR_WAIT) {
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 29ea927..244ae72 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -130,20 +130,20 @@ void EventsManager::pollEvents() {
 			_mouseClicked = true;
 			_mouseButtons = 1;
 			_mouseMoved = true;
-			_anyStroke = true;
+			//_anyStroke = true;
 			return;
 		case Common::EVENT_LBUTTONUP:
 		case Common::EVENT_RBUTTONUP:
 			_mouseClicked = false;
 			_mouseReleased = true;
 			_mouseMoved = true;
-			_anyStroke = true;
+			//_anyStroke = true;
 			return;
 		case Common::EVENT_MOUSEMOVE:
 			_mousePos = event.mouse;
 			_currentPos = event.mouse;
 			_mouseMoved = true;
-			_anyStroke = true;
+			//_anyStroke = true;
 			break;
 		default:
  			break;
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 090ddd0..d0d3b27 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -59,7 +59,7 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 	_priorFrameTimer = 0;
 	_anyEmergency = false;
 	_triggerMode = KERNEL_TRIGGER_PARSER;
-	_triggerSetupMode = KERNEL_TRIGGER_PARSER;
+	_triggerSetupMode = KERNEL_TRIGGER_DAEMON;
 	_winStatus = 0;
 
 	// Load the inventory object list
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index cda8f89..c12e721 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -432,6 +432,8 @@ void Scene103::actions() {
 		_vm->_dialogs->show(10321);
 	} else if (_action.isAction(VERB_LOOK, 409)) {
 		_vm->_dialogs->show(_game._objects.isInInventory(OBJ_TIMER_MODULE) ? 10324 : 10325);
+	} else {
+		return;
 	}
 
 	_action._inProgress = false;
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 64260a6..02877aa 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -313,9 +313,10 @@ void Scene::doFrame() {
 	if (!_vm->_game->_fx)
 		_frameStartTime = _vm->_events->getFrameCounter();
 
-	if ((_action._inProgress && !player._moving && !player._needToWalk &&
-			player._turnToFacing == player._facing) ||
-			(_vm->_game->_trigger && _vm->_game->_triggerMode == KERNEL_TRIGGER_PARSER)) {
+	// Handle parser actions as well as game triggers
+	if ((_action._inProgress && !player._moving && !player._needToWalk && 
+			(player._facing == player._turnToFacing) && !_vm->_game->_trigger) ||
+			(_vm->_game->_trigger && (_vm->_game->_triggerMode == KERNEL_TRIGGER_PARSER))) {
 		doAction();
 	}
 
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 01ca696..5150b75 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -47,7 +47,7 @@ SequenceEntry::SequenceEntry() {
 	_field22 = 0;
 	_triggerCountdown = 0;
 	_doneFlag = 0;
-	_abortMode = KERNEL_TRIGGER_PARSER;
+	_triggerMode = KERNEL_TRIGGER_DAEMON;
 	_numTicks = 0;
 	_extraTicks = 0;
 	_timeout = 0;
@@ -135,7 +135,7 @@ int SequenceList::add(int spriteListIndex, bool flipped, int frameIndex, int tri
 	_entries[seqIndex]._flags = 0;
 	_entries[seqIndex]._dynamicHotspotIndex = -1;
 	_entries[seqIndex]._entries._count = 0;
-	_entries[seqIndex]._abortMode = _vm->_game->_triggerSetupMode;
+	_entries[seqIndex]._triggerMode = _vm->_game->_triggerSetupMode;
 
 	_entries[seqIndex]._actionNouns = _vm->_game->_scene._action._activeAction;
 
@@ -160,7 +160,7 @@ int SequenceList::addTimer(int time, int abortVal) {
 	se._triggerCountdown = true;
 	se._doneFlag = false;
 	se._entries._count = 0;
-	se._abortMode = _vm->_game->_triggerSetupMode;
+	se._triggerMode = _vm->_game->_triggerSetupMode;
 	se._actionNouns = _vm->_game->_scene._action._activeAction;
 	addSubEntry(seqIndex, SM_0, 0, abortVal);
 
@@ -328,9 +328,9 @@ bool SequenceList::loadSprites(int seqIndex) {
 
 	if (idx >= 0) {
 		_vm->_game->_trigger = seqEntry._entries._abortVal[idx];
-		_vm->_game->_triggerMode = seqEntry._abortMode;
+		_vm->_game->_triggerMode = seqEntry._triggerMode;
 
-		if (seqEntry._abortMode == KERNEL_TRIGGER_DAEMON)
+		if (seqEntry._triggerMode == KERNEL_TRIGGER_DAEMON)
 			scene._action._activeAction = seqEntry._actionNouns;
 	}
 
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index 5dfdbce..8db06d5 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -74,7 +74,7 @@ struct SequenceEntry {
 	int _triggerCountdown;
 	bool _doneFlag;
 	SequenceSubEntries _entries;
-	TriggerMode _abortMode;
+	TriggerMode _triggerMode;
 
 	ActionDetails _actionNouns;
 	int _numTicks;


Commit: 2a105149fe734f9cec759b08e8a545bcd0b97078
    https://github.com/scummvm/scummvm/commit/2a105149fe734f9cec759b08e8a545bcd0b97078
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-05T14:27:14-04:00

Commit Message:
MADS: Fix pathfinding when dest pos is exactly the same as source pos

Changed paths:
    engines/mads/player.cpp



diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index a98fdb1..3eb6b11 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -388,8 +388,8 @@ void Player::move() {
 	bool newFacing = false;
 
 	if (_moving) {
-		bool isRouteEmpty = rails.empty();
 		while (!_walkOffScreen && _playerPos == _targetPos) {
+			bool isRouteEmpty = rails.empty();
 			if (!isRouteEmpty) {
 				const WalkNode &node = rails.popNode();
 


Commit: 06aeba275acb80df86ff103880c07ccc0e9738b1
    https://github.com/scummvm/scummvm/commit/06aeba275acb80df86ff103880c07ccc0e9738b1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-05T14:27:33-04:00

Commit Message:
MADS: Fix right mouse button handling

Changed paths:
    engines/mads/action.cpp
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/scene.cpp
    engines/mads/screen.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index ccfd13b..e227d7c 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -366,7 +366,7 @@ void MADSAction::checkActionAtMousePos() {
 			scene._lookFlag = true;
 	}
 
-	if (_vm->_events->_anyStroke && _vm->_events->_mouseButtons) {
+	if (_vm->_events->_rightMousePressed && _vm->_events->_mouseButtons) {
 		switch (userInterface._category) {
 		case CAT_COMMAND:
 		case CAT_INV_VOCAB:
@@ -507,7 +507,7 @@ void MADSAction::leftClick() {
 		}
 	}
 
-	if (abortFlag || (_vm->_events->_anyStroke && (userInterface._category == CAT_COMMAND ||
+	if (abortFlag || (_vm->_events->_rightMousePressed && (userInterface._category == CAT_COMMAND ||
 			userInterface._category == CAT_INV_VOCAB)))
 		return;
 
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 244ae72..ecc7a52 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -46,7 +46,7 @@ EventsManager::EventsManager(MADSEngine *vm) {
 	_vD4 = 0;
 	_mouseMoved = false;
 	_vD8 = 0;
-	_anyStroke = false;
+	_rightMousePressed = false;
 }
 
 EventsManager::~EventsManager() {
@@ -129,21 +129,20 @@ void EventsManager::pollEvents() {
 		case Common::EVENT_RBUTTONDOWN:
 			_mouseClicked = true;
 			_mouseButtons = 1;
+			_rightMousePressed = event.type == Common::EVENT_RBUTTONDOWN;
 			_mouseMoved = true;
-			//_anyStroke = true;
 			return;
 		case Common::EVENT_LBUTTONUP:
 		case Common::EVENT_RBUTTONUP:
 			_mouseClicked = false;
 			_mouseReleased = true;
 			_mouseMoved = true;
-			//_anyStroke = true;
+			_rightMousePressed = false;
 			return;
 		case Common::EVENT_MOUSEMOVE:
 			_mousePos = event.mouse;
 			_currentPos = event.mouse;
 			_mouseMoved = true;
-			//_anyStroke = true;
 			break;
 		default:
  			break;
diff --git a/engines/mads/events.h b/engines/mads/events.h
index 8537605..3b5820a 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -58,7 +58,7 @@ public:
 	bool _mouseClicked;
 	bool _mouseReleased;
 	byte _mouseButtons;
-	bool _anyStroke;
+	bool _rightMousePressed;
 	bool _keyPressed;
 	int _vCC;
 	int _vD2;
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 02877aa..2d95f86 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -523,7 +523,7 @@ void Scene::updateCursor() {
 	Player &player = _vm->_game->_player;
 
 	CursorType cursorId = CURSOR_ARROW;
-	if (_action._interAwaiting == 1 && !_vm->_events->_anyStroke &&
+	if (_action._interAwaiting == 1 && !_vm->_events->_rightMousePressed &&
 		_vm->_game->_screenObjects._category == CAT_HOTSPOT) {
 		int idx = _vm->_game->_screenObjects._selectedObject -
 			_userInterface._categoryIndexes[CAT_HOTSPOT - 1];
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 44f0907..f03f891 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -286,7 +286,7 @@ void ScreenObjects::check(bool scanFlag) {
 	UserInterface &userInterface = scene._userInterface;
 
 	if (!_vm->_events->_mouseButtons || _inputMode != kInputBuildingSentences)
-		_vm->_events->_anyStroke = false;
+		_vm->_events->_rightMousePressed = false;
 
 	if ((_vm->_events->_mouseMoved || _vm->_game->_scene._userInterface._scrollerY 
 			|| _v8332A || _v8333C) && scanFlag) {
@@ -473,13 +473,13 @@ void ScreenObjects::elementHighlighted() {
 		indexEnd = 9;
 		varA = 5;
 		topIndex = 0;
-		idxP = !_vm->_events->_anyStroke ? &userInterface._highlightedCommandIndex : 
+		idxP = !_vm->_events->_rightMousePressed ? &userInterface._highlightedCommandIndex : 
 			&userInterface._selectedActionIndex;
 
-		if (_vm->_events->_anyStroke && userInterface._selectedItemVocabIdx >= 0)
+		if (_vm->_events->_rightMousePressed && userInterface._selectedItemVocabIdx >= 0)
 			userInterface.updateSelection(CAT_INV_VOCAB, -1, &userInterface._selectedItemVocabIdx);
 
-		var4 = _released && !_vm->_events->_anyStroke ? 1 : 0;
+		var4 = _released && !_vm->_events->_rightMousePressed ? 1 : 0;
 		break;
 
 	case CAT_INV_LIST:
@@ -505,12 +505,12 @@ void ScreenObjects::elementHighlighted() {
 
 		varA = 0;
 		topIndex = 0;
-		idxP = _vm->_events->_anyStroke ? &userInterface._selectedItemVocabIdx : &userInterface._highlightedActionIndex;
+		idxP = _vm->_events->_rightMousePressed ? &userInterface._selectedItemVocabIdx : &userInterface._highlightedActionIndex;
 
-		if (_vm->_events->_anyStroke && userInterface._selectedActionIndex >= 0)
+		if (_vm->_events->_rightMousePressed && userInterface._selectedActionIndex >= 0)
 			userInterface.updateSelection(CAT_COMMAND, -1, &userInterface._selectedActionIndex);
 
-		var4 = _released && !_vm->_events->_anyStroke ? 1 : 0;
+		var4 = _released && !_vm->_events->_rightMousePressed ? 1 : 0;
 		break;
 
 	case CAT_INV_ANIM:
@@ -605,7 +605,7 @@ void ScreenObjects::elementHighlighted() {
 			newIndex = -1;
 	}
 
-	if (_released && !_vm->_events->_anyStroke &&
+	if (_released && !_vm->_events->_rightMousePressed &&
 			(_vm->_events->_mouseReleased || !_vm->_easyMouse))
 		newIndex = -1;
 


Commit: ecdaf23344725c4bddf5e3dddf80d56140374013
    https://github.com/scummvm/scummvm/commit/ecdaf23344725c4bddf5e3dddf80d56140374013
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-05T15:56:24-04:00

Commit Message:
MADS: Fix to stop daemon actions overwriting currently active player actions

Changed paths:
    engines/mads/sequence.cpp



diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 5150b75..92cba84 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -330,7 +330,7 @@ bool SequenceList::loadSprites(int seqIndex) {
 		_vm->_game->_trigger = seqEntry._entries._abortVal[idx];
 		_vm->_game->_triggerMode = seqEntry._triggerMode;
 
-		if (seqEntry._triggerMode == KERNEL_TRIGGER_DAEMON)
+		if (seqEntry._triggerMode != KERNEL_TRIGGER_DAEMON)
 			scene._action._activeAction = seqEntry._actionNouns;
 	}
 


Commit: 0b9c802bf0095568d71db5d10b3b6dbe075934fb
    https://github.com/scummvm/scummvm/commit/0b9c802bf0095568d71db5d10b3b6dbe075934fb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-05T17:19:51-04:00

Commit Message:
MADS: Fix for actions getting aborted due to _commandError being set

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/scene.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index c12e721..6d63a56 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -343,6 +343,7 @@ void Scene103::actions() {
 	} else if (_action.isAction(VERB_LOOK, 362)) {
 		_vm->_dialogs->show(10301);
 	} else if (_action.isAction(VERB_TAKE, 362)) {
+		// Take Turkey
 		if (!_vm->_game->_trigger)
 			_vm->_sound->command(31);
 
@@ -356,8 +357,7 @@ void Scene103::actions() {
 				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 18, 0, 60, msg);
 				_scene->_sequences.addTimer(120, _vm->_game->_trigger);
 			} else {
-				_scene->_sequences.addSubEntry(_globals._spriteIndexes[24],
-					SM_0, 0, 1);
+				_scene->_sequences.addSubEntry(_globals._spriteIndexes[24], SM_0, 0, 1);
 			}
 
 			_game._player._stepEnabled = _game._trigger == 2;
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 2d95f86..1400774 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -474,12 +474,12 @@ void Scene::doAction() {
 		}
 
 		if (!_action._savedFields._lookFlag) {
-			if (!_action._inProgress) {
+			if (_action._inProgress) {
 				_action._savedFields._commandError = true;
 				_sceneLogic->postActions();
 			}
 
-			if (!_action._inProgress) {
+			if (_action._inProgress) {
 				_action._savedFields._commandError = true;
 				warning("TODO: PtrUnk4");
 			}


Commit: 88dcc7e0d64d3cc1c0963d90dcaad7ea112420df
    https://github.com/scummvm/scummvm/commit/88dcc7e0d64d3cc1c0963d90dcaad7ea112420df
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-05T23:36:10+02:00

Commit Message:
MADS: Add debugger command to display quotes

Changed paths:
    engines/mads/debugger.cpp
    engines/mads/debugger.h



diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp
index 58bf838..276340f 100644
--- a/engines/mads/debugger.cpp
+++ b/engines/mads/debugger.cpp
@@ -37,6 +37,7 @@ Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) {
 	DCmd_Register("play_sound", WRAP_METHOD(Debugger, Cmd_PlaySound));
 	DCmd_Register("show_codes", WRAP_METHOD(Debugger, Cmd_ShowCodes));
 	DCmd_Register("dump_file", WRAP_METHOD(Debugger, Cmd_DumpFile));
+	DCmd_Register("show_quote", WRAP_METHOD(Debugger, Cmd_ShowQuote));
 }
 
 static int strToInt(const char *s) {
@@ -168,4 +169,13 @@ bool Debugger::Cmd_DumpFile(int argc, const char **argv) {
 	return true;
 }
 
+bool Debugger::Cmd_ShowQuote(int argc, const char **argv) {
+	if (argc != 2)
+		DebugPrintf("Usage: %s <quote number>\n", argv[0]);
+	else
+		DebugPrintf("%s", _vm->_game->getQuote(strToInt(argv[1])).c_str());
+
+	return true;
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/debugger.h b/engines/mads/debugger.h
index de450b1..b2b0949 100644
--- a/engines/mads/debugger.h
+++ b/engines/mads/debugger.h
@@ -41,6 +41,7 @@ protected:
 	bool Cmd_PlaySound(int argc, const char **argv);
 	bool Cmd_ShowCodes(int argc, const char **argv);
 	bool Cmd_DumpFile(int argc, const char **argv);
+	bool Cmd_ShowQuote(int argc, const char **argv);
 public:
 	bool _showMousePos;
 public:


Commit: c117e59009890d15e3bec65564ad0ac1f728dc79
    https://github.com/scummvm/scummvm/commit/c117e59009890d15e3bec65564ad0ac1f728dc79
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-05T23:37:10+02:00

Commit Message:
MADS: Implement scene 209

Changed paths:
    engines/mads/inventory.cpp
    engines/mads/inventory.h
    engines/mads/nebular/game_nebular.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index 43b7b6e..ec5670b 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -167,4 +167,9 @@ void InventoryObjects::removeFromInventory(int objectId, int newScene) {
 	}
 }
 
+int InventoryObjects::getIdFromDesc(int objectId) {
+	warning("TODO: InventoryObjects::getIdFromDesc()");
+	return objectId;
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/inventory.h b/engines/mads/inventory.h
index eec272b..13b8109 100644
--- a/engines/mads/inventory.h
+++ b/engines/mads/inventory.h
@@ -109,6 +109,8 @@ public:
 	 * @param newScene	Specifies the new scene to set the item to
 	 */
 	void removeFromInventory(int objectId, int newScene);
+
+	int getIdFromDesc(int objectId);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index 5b88f63..e4f4efc 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -33,7 +33,7 @@ namespace Nebular {
 
 enum StoryMode { STORYMODE_NAUGHTY = 1, STORYMODE_NICE = 2 };
 
-enum InventoryObject { OBJ_NONE = 0,
+enum InventoryObject { OBJ_NONE = -1, OBJ_BINOCULARS = 0,
 	OBJ_BURGER = 1, OBJ_DEAD_FISH = 2, OBJ_STUFFED_FISH = 3, OBJ_REBREATHER = 4,
 	OBJ_TIMER_MODULE = 5, OBJ_BIG_LEAVES = 6, OBJ_POISON_DARTS = 7, OBJ_PLANT_STALK = 8,
 	OBJ_BLOWGUN = 9, OBJ_TWINKIFRUIT = 10, OBJ_BONE = 11, OBJ_CHICKEN = 12,
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index b91384d..0bf5c21 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -57,7 +57,7 @@ void Scene2xx::setPlayerSpritesPrefix() {
 
 	if (oldName != _game._player._spritesPrefix)
 		_game._player._spritesChanged = true;
-	
+
 	if ((_scene->_nextSceneId == 203 || _scene->_nextSceneId == 204) && _globals[kRhotundaStatus])
 		_game._player._loadsFirst = false;
 
@@ -156,7 +156,7 @@ void Scene201::enter() {
 		int sepChar = (_globals[kSexOfRex] == SEX_UNKNOWN) ? 't' : 'u';
 		// Guess values. What is the default value used by the compiler?
 		int suffixNum = -1;
-		int abortTimers = -1; 
+		int abortTimers = -1;
 		switch(_globals[kTeleporterCommand]) {
 		case 1:
 			suffixNum = 3;
@@ -181,7 +181,7 @@ void Scene201::enter() {
 		if (suffixNum >= 0)
 			_scene->loadAnimation(formAnimName(sepChar, suffixNum), abortTimers);
 	}
-	
+
 	if ((_scene->_priorSceneId == 202) && (_globals[kMeteorologistStatus] == 1) && !_scene->_roomChanged) {
 		_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('a', 0), 0);
 		_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('a', 1), 0);
@@ -282,10 +282,10 @@ void Scene201::step() {
 void Scene201::actions() {
 	MADSAction *action = _game._player._action;
 	if (action->_lookFlag == false) {
-		if (action->isAction(0x18C, 0x83))
+		if (_action.isAction(0x18C, 0x83))
 			_scene->_nextSceneId = 202;
-		else if ((action->isAction(0x50, 0x156)) || (action->isAction(0x188, 0x16C)) || (action->isAction(0x188, 0x1B6))) {
-			if (_game._trigger == 0) { 
+		else if ((_action.isAction(0x50, 0x156)) || (_action.isAction(0x188, 0x16C)) || (_action.isAction(0x188, 0x1B6))) {
+			if (_game._trigger == 0) {
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
 				int sepChar = (_globals[kSexOfRex] == SEX_UNKNOWN) ? 't' : 'u';
@@ -293,30 +293,30 @@ void Scene201::actions() {
 			} else if (_game._trigger == 1) {
 				_scene->_nextSceneId = 213;
 			}
-		} else if (action->isAction(VERB_LOOK, 0x1A6)) {
+		} else if (_action.isAction(VERB_LOOK, 0x1A6)) {
 			_vm->_dialogs->show(0x4E85);
-		} else if (action->isAction(VERB_LOOK, 0x129)) {
+		} else if (_action.isAction(VERB_LOOK, 0x129)) {
 			_vm->_dialogs->show(0x4E86);
-		} else if (action->isAction(VERB_LOOK, 0x16F)) {
+		} else if (_action.isAction(VERB_LOOK, 0x16F)) {
 			_vm->_dialogs->show(0x4E87);
-		} else if (action->isAction(VERB_LOOK, 0x142)) {
+		} else if (_action.isAction(VERB_LOOK, 0x142)) {
 			_vm->_dialogs->show(0x4E88);
-		} else if (action->isAction(VERB_LOOK, 0x18F)) {
+		} else if (_action.isAction(VERB_LOOK, 0x18F)) {
 			_vm->_dialogs->show(0x4E89);
-		} else if (action->isAction(VERB_LOOK, 0x1B9)) {
+		} else if (_action.isAction(VERB_LOOK, 0x1B9)) {
 			_vm->_dialogs->show(0x4E8A);
-		} else if (action->isAction(VERB_LOOK, 0x192)) {
+		} else if (_action.isAction(VERB_LOOK, 0x192)) {
 			_vm->_dialogs->show(0x4E8B);
-		} else if (action->isAction(VERB_LOOK, 0x1BA)) {
+		} else if (_action.isAction(VERB_LOOK, 0x1BA)) {
 			_vm->_dialogs->show(0x4E8C);
-		} else if (action->isAction(VERB_LOOK, 0x83)) {
+		} else if (_action.isAction(VERB_LOOK, 0x83)) {
 			_vm->_dialogs->show(0x4E8E);
-		} else if (action->isAction(VERB_LOOK, 0x1B6)) {
+		} else if (_action.isAction(VERB_LOOK, 0x1B6)) {
 			if (_globals[kMeteorologistEverSeen])
 				_vm->_dialogs->show(0x4E90);
 			else
 				_vm->_dialogs->show(0x4E8D);
-		} else if (action->isAction(VERB_LOOK, 0x16C)) {
+		} else if (_action.isAction(VERB_LOOK, 0x16C)) {
 			_vm->_dialogs->show(0x4E91);
 		} else
 			return;
@@ -415,8 +415,8 @@ void Scene202::enter() {
 	_meteoClock1 = _meteoClock2 = _scene->_frameStartTime;
 
 	if (_scene->_roomChanged)
-		_game._objects.addToInventory(OBJ_NONE);
-	
+		_game._objects.addToInventory(OBJ_BINOCULARS);
+
 	if (_globals[kMeteorologistWatch]) {
 		_game._player._visible = false;
 		_game._player._stepEnabled = false;
@@ -489,7 +489,7 @@ void Scene202::step() {
 		}
 		int msgIndex = _scene->_kernelMessages.add(msgPos, 0x1110, msgFlag | 32, 0, 120, _game.getQuote(102));
 		_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
-		
+
 		if (_globals[kMeteorologistWatch] == 1) {
 			MADSAction *action = _game._player._action;
 			action->_activeAction._verbId = VERB_LOOK;
@@ -508,7 +508,7 @@ void Scene202::step() {
 	case 90:
 		_vm->_sound->command(41);
 		_scene->_sequences.remove(_globals._spriteIndexes[25]);
-		_globals._spriteIndexes[24] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0); 
+		_globals._spriteIndexes[24] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0);
 		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
 		_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
 		_scene->_sequences.addSubEntry(_globals._spriteIndexes[24], SM_0, 0, 91);
@@ -547,7 +547,7 @@ void Scene202::step() {
 	default:
 		break;
 	}
-	
+
 	if (!_scene->_activeAnimation && (_globals[kMeteorologistStatus] != 2) && (_meteoClock2 <= _scene->_frameStartTime) && (_meteoClock1 <= _scene->_frameStartTime)) {
 		int randVal = _vm->getRandomNumber(1, 500);
 		int threshold = 1;
@@ -566,7 +566,7 @@ void Scene202::step() {
 			_meteoClock2 = _scene->_frameStartTime + 2;
 		}
 	}
-	
+
 	if (!_scene->_activeAnimation)
 		return;
 
@@ -602,11 +602,11 @@ void Scene202::step() {
 	if (_scene->_activeAnimation->getCurrentFrame() == _meteoFrame) {
 		return;
 	}
-	
+
 	_meteoFrame = _scene->_activeAnimation->getCurrentFrame();
 	int randVal = _vm->getRandomNumber(1, 1000);
 	int frameStep = -1;
-	
+
 	switch (_scene->_activeAnimation->getCurrentFrame()) {
 	case 42:
 	case 77:
@@ -703,7 +703,7 @@ int Scene202::subStep4(int randVal) {
 	if (randVal <= 200)
 		return 19;
 
-	return 166;	
+	return 166;
 }
 
 void Scene202::preActions() {
@@ -713,7 +713,7 @@ void Scene202::preActions() {
 	if (player._readyToWalk)
 		_scene->_kernelMessages.reset();
 
-	if (!_ladderTopFl && (action->isAction(0x4E, 0xC7) || !player._readyToWalk)) {
+	if (!_ladderTopFl && (_action.isAction(0x4E, 0xC7) || !player._readyToWalk)) {
 		if (_game._trigger == 0) {
 			_vm->_sound->command(29);
 			player._readyToWalk = false;
@@ -729,10 +729,10 @@ void Scene202::preActions() {
 			player._readyToWalk = true;
 			_game._player._stepEnabled = true;
 			_ladderTopFl = false;
-		}		
+		}
 	}
 
-	if (action->isAction(VERB_LOOK, 0x27) && action->_activeAction._indirectObjectId > 0) {
+	if (_action.isAction(VERB_LOOK, 0x27) && (action->_activeAction._indirectObjectId > 0)) {
 		if (!player._readyToWalk || _ladderTopFl)
 			_game._player._needToWalk = false;
 		else
@@ -746,12 +746,12 @@ void Scene202::preActions() {
 void Scene202::actions() {
 	MADSAction *action = _game._player._action;
 	if (action->_lookFlag == false) {
-		if (action->isAction(0x4E, 0xC7)) {
+		if (_action.isAction(0x4E, 0xC7)) {
 			action->_inProgress = false;
 			return;
-		} else if (action->isAction(0x18C, 0x83)) {
+		} else if (_action.isAction(0x18C, 0x83)) {
 			_scene->_nextSceneId = 203;
-		} else if (action->isAction(0x18C, 0x82)) {
+		} else if (_action.isAction(0x18C, 0x82)) {
 			if (_globals[kMeteorologistStatus] != 2) {
 				if (_scene->_activeAnimation)
 					_globals[kMeteorologistStatus] = 1;
@@ -759,7 +759,7 @@ void Scene202::actions() {
 					_globals[kMeteorologistStatus] = 0;
 			}
 			_scene->_nextSceneId = 201;
-		} else if (action->isAction(VERB_TAKE, 0x2C)) {
+		} else if (_action.isAction(VERB_TAKE, 0x2C)) {
 			if (action->_mainObjectSource == 4) {
 				if (_game._trigger == 0) {
 					if (_game._objects.isInInventory(OBJ_BONES)) {
@@ -797,7 +797,7 @@ void Scene202::actions() {
 					return;
 				}
 			}
-		} else if ((action->isAction(0x50, 0xC7)) && (_globals[kLadderBroken] == 0)) {
+		} else if ((_action.isAction(0x50, 0xC7)) && (_globals[kLadderBroken] == 0)) {
 			if (_game._trigger == 0) {
 				_vm->_sound->command(29);
 				_meteoClock1 = _scene->_frameStartTime;
@@ -822,7 +822,7 @@ void Scene202::actions() {
 				action->_inProgress = false;
 				return;
 			}
-		} else if (((action->isAction(VERB_LOOK, 0x27, 0x82)) || (action->isAction(VERB_LOOK, 0x27, 0x1B6))) && (_globals[kSexOfRex] == SEX_MALE)) {
+		} else if (((_action.isAction(VERB_LOOK, 0x27, 0x82)) || (_action.isAction(VERB_LOOK, 0x27, 0x1B6))) && (_globals[kSexOfRex] == SEX_MALE)) {
 			if (!_ladderTopFl) {
 				if (_game._trigger == 0) {
 					_game._player._stepEnabled = false;
@@ -911,15 +911,15 @@ void Scene202::actions() {
 					return;
 				}
 			}
-		} else if (action->isAction(0x188, 0xAA)) {
+		} else if (_action.isAction(0x188, 0xAA)) {
 			setRandomKernelMessage();
-		} else if (action->isAction(VERB_LOOK, 0x129)) {
+		} else if (_action.isAction(VERB_LOOK, 0x129)) {
 			_vm->_dialogs->show(0x4EEA);
-		} else if (action->isAction(VERB_LOOK, 0x86)) {
+		} else if (_action.isAction(VERB_LOOK, 0x86)) {
 			_vm->_dialogs->show(0x4EEB);
-		} else if (action->isAction(VERB_LOOK, 0x19C)) {
+		} else if (_action.isAction(VERB_LOOK, 0x19C)) {
 			_vm->_dialogs->show(0x4EEC);
-		} else if (action->isAction(VERB_LOOK, 0x82)) {
+		} else if (_action.isAction(VERB_LOOK, 0x82)) {
 			if ((_globals[kMeteorologistStatus] == 0) || (_globals[kMeteorologistStatus] == 2)) {
 				_vm->_dialogs->show(0x4EED);
 			} else if (_globals[kMeteorologistStatus] == 1) {
@@ -927,37 +927,37 @@ void Scene202::actions() {
 			} else {
 				action->_inProgress = false;
 				return;
-			} 
-		} else if (action->isAction(VERB_LOOK, 0x18E)) {
+			}
+		} else if (_action.isAction(VERB_LOOK, 0x18E)) {
 			_vm->_dialogs->show(0x4EEE);
-		} else if (action->isAction(VERB_LOOK, 0x164)) {
+		} else if (_action.isAction(VERB_LOOK, 0x164)) {
 			_vm->_dialogs->show(0x4EEF);
-		} else if (action->isAction(VERB_LOOK, 0x175)) {
+		} else if (_action.isAction(VERB_LOOK, 0x175)) {
 			_vm->_dialogs->show(0x4EF0);
-		} else if (action->isAction(VERB_LOOK, 0x174)) {
+		} else if (_action.isAction(VERB_LOOK, 0x174)) {
 			_vm->_dialogs->show(0x4EF1);
-		} else if (action->isAction(VERB_LOOK, 0x142)) {
+		} else if (_action.isAction(VERB_LOOK, 0x142)) {
 			_vm->_dialogs->show(0x4EF2);
-		} else if (action->isAction(VERB_LOOK, 0xAA)) {
+		} else if (_action.isAction(VERB_LOOK, 0xAA)) {
 			if ((_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == FACING_NORTH))
 				_vm->_dialogs->show(0x4EF4);
 			else
 				_vm->_dialogs->show(0x4EF3);
-		} else if (action->isAction(VERB_LOOK, 0x186)) {
+		} else if (_action.isAction(VERB_LOOK, 0x186)) {
 			_vm->_dialogs->show(0x4EF5);
-		} else if (action->isAction(VERB_LOOK, 0x1B5)) {
+		} else if (_action.isAction(VERB_LOOK, 0x1B5)) {
 			_vm->_dialogs->show(0x4EF6);
-		} else if (action->isAction(VERB_LOOK, 0x140)) {
+		} else if (_action.isAction(VERB_LOOK, 0x140)) {
 			_vm->_dialogs->show(0x4EF7);
-		} else if (action->isAction(VERB_TAKE, 0x140)) {
+		} else if (_action.isAction(VERB_TAKE, 0x140)) {
 			_vm->_dialogs->show(0x4EF8);
-		} else if (action->isAction(VERB_LOOK, 0x2D)) {
+		} else if (_action.isAction(VERB_LOOK, 0x2D)) {
 			if (action->_commandSource == 4)
 				_vm->_dialogs->show(0x4EF9);
 			else
 				return;
 		} else {
-			return;			
+			return;
 		}
 	} else {
 		_vm->_dialogs->show(0x4EFB);
@@ -1038,7 +1038,7 @@ void Scene203::step() {
 	} else if (_game._trigger == 81) {
 		_scene->_nextSceneId = 208;
 		_scene->_reloadSceneFlag = true;
-	} 
+	}
 }
 
 void Scene203::preActions() {
@@ -1094,7 +1094,7 @@ void Scene205::enter() {
 	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('f', -1), 0);
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('c', -1), 0);
 	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('p', -1), 0);
-	
+
 	if (_globals[kSexOfRex] == SEX_MALE)
 		_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('a', 1), 0);
 
@@ -1144,7 +1144,7 @@ void Scene205::enter() {
 		warning("sub71704(0x3, 0xC3, 0x108, 0x63, 0x86, 0xD, 2, 0xFDFC, 0x3C, 0x6C, 0x6C, 0x6D, 0x6D, 0x6E, 0x6E, 0x6F, 0x6C, 0);");
 
 	if (_scene->_priorSceneId != -2)
-		_game._player._playerPos = Common::Point(99, 152);	
+		_game._player._playerPos = Common::Point(99, 152);
 
 	if (_globals[kSexOfRex] != SEX_MALE) {
 		_scene->loadAnimation(formAnimName('a', -1), 0);
@@ -1246,7 +1246,7 @@ void Scene207::enter() {
 		_vultureFl = true;
 
 	_spiderFl = (var2 & 1);
-	
+
 	if (_vultureFl) {
 		_globals._spriteIndexes[16] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 30, 0, 0, 400);
 		_vultureTime = _game._player._priorTimer;
@@ -1479,7 +1479,7 @@ void Scene208::enter() {
 }
 
 void Scene208::step() {
-	if (_boundingFl  && (_rhotundaTime <= _scene->_activeAnimation->getCurrentFrame())) {
+	if (_boundingFl && (_rhotundaTime <= _scene->_activeAnimation->getCurrentFrame())) {
 		_rhotundaTime = _scene->_activeAnimation->getCurrentFrame();
 
 		if (_rhotundaTime == 125)
@@ -1494,9 +1494,9 @@ void Scene208::step() {
 
 	if ((_game._trigger == 0) && _boundingFl)
 		return;
-	
+
 	_boundingFl = true;
-	
+
 	switch (_game._trigger) {
 	case 0:
 		_scene->loadAnimation(formAnimName('A', -1), 81);
@@ -1532,7 +1532,7 @@ void Scene208::subAction(int mode) {
 	switch (_game._trigger) {
 	case 0: {
 		_game._player._stepEnabled = false;
-		_game._player._visible   = false;
+		_game._player._visible = false;
 		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 1, 0, 0);
 		_scene->_sequences.setMsgLayout(_globals._spriteIndexes[20]);
 
@@ -1686,16 +1686,1587 @@ void Scene209::setup() {
 	_scene->addActiveVocab(0x10F);
 }
 
-void Scene209::enter() {
+void Scene209::handlePause() {
+	switch (_game._trigger) {
+	case 124:
+		if (++_pauseCounter <= _pauseCounterThreshold)
+			_scene->_sequences.addTimer(60, 124);
+		else
+			_pauseMode = 0;
+		break;
+	}
 }
 
-void Scene209::step() {
+void Scene209::initPauseCounterThreshold() {
+	switch (_game._trigger) {
+	case 226:
+		_scene->_sequences.addTimer(1, 124);
+		_pauseCounterThreshold = _vm->getRandomNumber(7,12);
+		_pauseMode = 2;
+		_pauseCounter = 0;
+		break;
+	}
 }
 
-void Scene209::preActions() {
+void Scene209::handlePeek() {
+	switch (_game._trigger) {
+	case 133:
+		_vm->_sound->command(18);
+		_globals._spriteIndexes[18] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 51, 52);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 134);
+		break;
+
+	case 134: {
+		int oldIdx = _globals._spriteIndexes[18];
+		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addTimer(60, 135);
+		}
+		break;
+
+	case 135:
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 7);
+		_scene->_sequences.addTimer(10, 136);
+		break;
+
+	case 136:
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+		_scene->_sequences.addTimer(50, 137);
+		break;
+
+	case 137:
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 51, 52);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 138);
+		break;
+
+	case 138:
+		_pauseMode = 1;
+		_scene->_hotspots.activate(227, false);
+		_playingAnimFl = false;
+		break;
+	}
 }
 
-void Scene209::actions() {
+void Scene209::handleVerticalMove() {
+	switch (_game._trigger) {
+	case 140:
+		_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 8, 0, 1);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 1, 5);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 141);
+		break;
+
+	case 141: {
+		_vm->_sound->command(18);
+		int oldIdx = _globals._spriteIndexes[18];
+		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 5);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addTimer(60, 142);
+		}
+		break;
+
+	case 142:
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[18] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 1, 5);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 143);
+		break;
+
+	case 143:
+		_pauseMode = 1;
+		_playingAnimFl = false;
+		_scene->_hotspots.activate(227, false);
+		break;
+	}
+}
+
+void Scene209::handleLookStay() {
+	switch (_game._trigger) {
+	case 145:
+		_vm->_sound->command(18);
+		_monkeyPosition = 2;
+		_globals._spriteIndexes[18] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 51, 52);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 146);
+		break;
+
+	case 146: {
+		int oldIdx = _globals._spriteIndexes[18];
+		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addTimer(15, 147);
+		}
+		break;
+
+	case 147:
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 7);
+		_scene->_sequences.addTimer(8, 148);
+		break;
+
+	case 148:
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+
+		if (!_dodgeFl)
+			_scene->_sequences.addTimer(90, 149);
+		else {
+			_scene->_sequences.addTimer(1, 149);
+			_shouldDodgeFl = true;
+		}
+		break;
+
+	case 149:
+		_playingAnimFl = false;
+		break;
+	}
+}
+
+void Scene209::handleLookRight() {
+	switch (_game._trigger) {
+	case 151:
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 8, 2, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 8, 14);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 152);
+		break;
+
+	case 152: {
+		int oldIdx = _globals._spriteIndexes[18];
+		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addTimer(60, 153);
+		}
+		break;
+
+	case 153:
+		_playingAnimFl = false;
+		if (_dodgeFl)
+			_shouldDodgeFl = true;
+		break;
+	}
+}
+
+void Scene209::handleBlink() {
+	switch (_game._trigger) {
+	case 155:
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+		_scene->_sequences.addTimer(50, 156);
+		break;
+
+	case 156:
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 7);
+		_scene->_sequences.addTimer(10, 157);
+		break;
+
+	case 157:
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+		_scene->_sequences.addTimer(50, 158);
+		break;
+
+	case 158:
+		_playingAnimFl = false;
+		if (_dodgeFl)
+			_shouldDodgeFl = true;
+		break;
+	}
+}
+
+void Scene209::handleGetBinoculars() {
+	switch (_game._trigger) {
+	case 161:
+		_vm->_sound->command(18);
+		_monkeyPosition = 3;
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 8, 24);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_FRAME_INDEX, 20, 165);
+		if (!_fallFl && !_dodgeFl) {
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 162);
+		} else {
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 163);
+		}
+		break;
+
+	case 162: {
+		int oldIdx = _globals._spriteIndexes[18];
+		_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 8, 6, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 23, 25);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 163);
+		}
+		break;
+
+	case 163: {
+		int oldIdx = _globals._spriteIndexes[18];
+		_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 8, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 23, 24);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addTimer(8, 164);
+		}
+		break;
+
+	case 164:
+		_playingAnimFl = false;
+		if (_fallFl)
+			_shouldFallFl = true;
+		break;
+
+	case 165:
+		_vm->_sound->command(18);
+		break;
+	}
+}
+
+void Scene209::handleBinocularBlink() {
+	switch (_game._trigger) {
+	case 167: {
+		int oldIdx = _globals._spriteIndexes[18];
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 8, 2, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 23, 25);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 168);
+		}
+		break;
+
+	case 168: {
+		int oldIdx = _globals._spriteIndexes[18];
+		_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 8, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 23, 24);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addTimer(30, 169);
+		}
+		break;
+
+	case 169:
+		_playingAnimFl = false;
+		if (_fallFl)
+			_shouldFallFl = true;
+		break;
+	}
+}
+
+void Scene209::handleBinocularScan() {
+	switch (_game._trigger) {
+	case 171: {
+		int oldIdx = _globals._spriteIndexes[18];
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 2, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 43, 45);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 172);
+		}
+		break;
+
+	case 172: {
+		int oldIdx = _globals._spriteIndexes[18];
+		int randAction = _vm->getRandomNumber(1,2);
+		switch (randAction) {
+		case 1:
+			_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 2, 0, 0);
+			break;
+		case 2:
+			_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 4, 0, 0);
+			break;
+		}
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 23, 25);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 173);
+		}
+		break;
+
+	case 173: {
+		int oldIdx = _globals._spriteIndexes[18];
+		_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 2, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 26, 30);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 174);
+		}
+		break;
+
+	case 174: {
+		int oldIdx = _globals._spriteIndexes[18];
+		_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 23, 24);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addTimer(60, 175);
+		}
+		break;
+
+	case 175:
+		_playingAnimFl = false;
+		if (_fallFl)
+			_shouldFallFl = true;
+		break;
+	}
+}
+
+void Scene209::handleJumpInTree() {
+	switch (_game._trigger) {
+	case 178: {
+		int oldIdx = 0;
+		_monkeyPosition = 1;
+		if (_removeMonkeyFl)
+			_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		else
+			oldIdx = _globals._spriteIndexes[18];
+
+		_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 46, 49);
+		if (!_removeMonkeyFl)
+			_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 179);
+		}
+		break;
+
+	case 179: {
+		_vm->_sound->command(18);
+		int oldIdx = _globals._spriteIndexes[18];
+		_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 53, 61);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 180);
+		}
+		break;
+
+	case 180:
+		_removeMonkeyFl = true;
+		_pauseMode = 1;
+		_playingAnimFl = false;
+		_scene->_hotspots.activate(227, false);
+		break;
+	}
+}
+
+void Scene209::handleTongue() {
+	switch (_game._trigger) {
+	case 182: {
+		int oldIdx = _globals._spriteIndexes[18];
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 26, 30);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 183);
+		}
+		break;
+
+	case 183: {
+		int oldIdx = _globals._spriteIndexes[18];
+		_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 31, 33);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 184);
+		}
+		break;
+
+	case 184: {
+		int oldIdx = _globals._spriteIndexes[18];
+		_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 36, 37);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 185);
+		}
+		break;
+
+	case 185: {
+		_vm->_sound->command(18);
+		int oldIdx = _globals._spriteIndexes[18];
+		_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 6, 20, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 38, 39);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 186);
+		}
+		break;
+
+	case 186: {
+		int oldIdx = _globals._spriteIndexes[18];
+		_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 40, 41);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 178);
+		_removeMonkeyFl = false;
+		}
+		break;
+	}
+}
+
+void Scene209::handleStandFromPeek() {
+	switch (_game._trigger) {
+	case 189:
+		_monkeyPosition = 4;
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 50);
+		_scene->_sequences.addTimer(8, 190);
+		break;
+
+	case 190:
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+		_scene->_sequences.addTimer(8, 191);
+		break;
+
+	case 191:
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[21], 1, 5);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 192);
+		break;
+
+	case 192: {
+		_vm->_sound->command(18);
+		int oldIdx = _globals._spriteIndexes[21];
+		_globals._spriteIndexes[20] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[20], oldIdx);
+		_scene->_sequences.addTimer(8, 193);
+		}
+		break;
+
+	case 193:
+		_scene->_sequences.remove(_globals._spriteIndexes[20]);
+		_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 22);
+		_scene->_sequences.addTimer(5, 194);
+		break;
+
+	case 194:
+		_playingAnimFl = false;
+		_counter = 0;
+		break;
+	}
+}
+
+void Scene209::handleStandBlink() {
+	switch (_game._trigger) {
+	case 246:
+		_scene->_sequences.remove(_globals._spriteIndexes[19]);
+		_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 22);
+		_scene->_sequences.addTimer(10, 247);
+		break;
+
+	case 247:
+		_scene->_sequences.remove(_globals._spriteIndexes[19]);
+		_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 23);
+		_scene->_sequences.addTimer(8, 248);
+		break;
+
+	case 248:
+		_scene->_sequences.remove(_globals._spriteIndexes[19]);
+		_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 22);
+		_scene->_sequences.addTimer(10, 249);
+		break;
+
+	case 249:
+		_playingAnimFl = false;
+		break;
+	}
+}
+
+void Scene209::handleJumpAndHide() {
+	switch (_game._trigger) {
+	case 196:
+		_vm->_sound->command(18);
+		_monkeyPosition = 1;
+		_scene->_sequences.remove(_globals._spriteIndexes[19]);
+		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[20], 1, 16);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[20], SM_0, 0, 197);
+		break;
+
+	case 197:
+		_pauseMode = 1;
+		_scene->_hotspots.activate(227, false);
+		_playingAnimFl = false;
+		break;
+	}
+}
+
+void Scene209::handleMonkeyEating() {
+	switch (_game._trigger) {
+	case 199:
+		_vm->_sound->command(18);
+		_scene->_sequences.remove(_globals._spriteIndexes[19]);
+		_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], 1, 14);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[19], SM_0, 0, 200);
+		break;
+
+	case 200: {
+		int oldIdx = _globals._spriteIndexes[19];
+		_globals._spriteIndexes[19] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 10, 10, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], 15, 16);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[19], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[19], SM_0, 0, 201);
+		}
+		break;
+
+	case 201: {
+		int oldIdx = _globals._spriteIndexes[19];
+		_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 12);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[19], oldIdx);
+		_scene->_sequences.addTimer(20, 202);
+		}
+		break;
+
+	case 202:
+		_scene->_sequences.remove(_globals._spriteIndexes[19]);
+		_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 19);
+		_scene->_sequences.addTimer(20, 203);
+		break;
+
+	case 203:
+		_scene->_sequences.remove(_globals._spriteIndexes[19]);
+		_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 17);
+		_scene->_sequences.addTimer(20, 204);
+		break;
+
+	case 204:
+		_scene->_sequences.remove(_globals._spriteIndexes[19]);
+		_globals._spriteIndexes[19] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 10, 8, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], 18, 19);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[19], SM_0, 0, 205);
+		break;
+
+	case 205: {
+		int oldIdx = _globals._spriteIndexes[19];
+		_globals._spriteIndexes[19] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 10, 8, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], 20, 21);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[19], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[19], SM_0, 0, 206);
+		}
+		break;
+
+	case 206: {
+		int oldIdx = _globals._spriteIndexes[19];
+		_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], 22, 25);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[19], oldIdx);
+		if (!_dodgeFl && !_fallFl)
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[19], SM_0, 0, 207);
+		else
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[19], SM_0, 0, 209);
+		}
+		break;
+
+	case 207: {
+		_vm->_sound->command(18);
+		 int msgIndex = _scene->_kernelMessages.add(Common::Point(180, 25), 0xFDFC, 0, 0, 90, _game.getQuote(130));
+		 _scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+
+		 int oldIdx = _globals._spriteIndexes[19];
+		_globals._spriteIndexes[19] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 15, 4, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], 26, 27);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[19], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[19], SM_0, 0, 208);
+		}
+		break;
+
+	case 208: {
+		_scene->_kernelMessages.add(Common::Point(180, 39), 0xFDFC, 0, 0, 90, _game.getQuote(131));
+		int oldIdx = _globals._spriteIndexes[19];
+		_globals._spriteIndexes[19] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 10, 4, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], 28, 29);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[19], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[19], SM_0, 0, 209);
+		}
+		break;
+
+	case 209: {
+		int oldIdx = _globals._spriteIndexes[19];
+		_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 22);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[19], oldIdx);
+		_scene->_sequences.addTimer(1, 210);
+		}
+		break;
+
+	case 210:
+		_playingAnimFl = false;
+		break;
+	}
+}
+
+void Scene209::handleMonkeyFall() {
+	switch (_game._trigger) {
+	case 219: {
+		_vm->_sound->command(25);
+		_scene->_sprites.remove(_globals._spriteIndexes[7]);
+		_scene->_sprites.remove(_globals._spriteIndexes[6]);
+		_scene->_sprites.remove(_globals._spriteIndexes[5]);
+		_scene->_sprites.remove(_globals._spriteIndexes[4]);
+
+		_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('m', 4), 0);
+		_scene->_kernelMessages.add(Common::Point(180, 26), 0xFDFC, 0, 0, 90, _game.getQuote(151));
+		_scene->_sequences.addTimer(40, 100);
+		_scene->_hotspots.activate(227, false);
+		int oldIdx = _globals._spriteIndexes[18];
+		_monkeyPosition = 1;
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[23], 1, 35);
+		_scene->_sequences.setDepth (_globals._spriteIndexes[23], 6);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 220);
+		}
+		break;
+
+	case 220: {
+		_vm->_sound->command(18);
+		_scene->_kernelMessages.add(Common::Point(182, 109), 0xFDFC, 0, 0, 90, _game.getQuote(159));
+		_scene->_hotspots.activate(227, false);
+		int oldIdx = _globals._spriteIndexes[18];
+		_monkeyPosition = 1;
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[23], 36, 42);
+		_scene->_sequences.setDepth (_globals._spriteIndexes[23], 6);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 221);
+		}
+		break;
+
+	case 221: {
+		_game._objects.setRoom(OBJ_BINOCULARS, 209);
+		_binocularsDroppedFl = true;
+		int oldIdx = _globals._spriteIndexes[23];
+		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
+		_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[24], oldIdx);
+		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(201, 131));
+		_scene->_sequences.setDepth(_globals._spriteIndexes[24], 8);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[23], oldIdx);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[23], 43, 72);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 222);
+		_scene->_dynamicHotspots.setPosition(_scene->_dynamicHotspots.add(39, 13, _globals._spriteIndexes[24], Common::Rect(0, 0, 0, 0)), 200, 133, FACING_NORTH);
+		}
+		break;
+
+	case 222: {
+		_scene->_kernelMessages.add(Common::Point(182, 109), 0xFDFC, 0, 0, 70, _game.getQuote(160));
+		int oldIdx = _globals._spriteIndexes[23];
+		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[23], 73, 78);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[23], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 223);
+		}
+		break;
+
+	case 223:
+		_scene->loadAnimation(Resources::formatName(209, 'e', -1, EXT_AA, ""), 224);
+		_vm->_sound->command(38);
+		break;
+
+	case 224:
+		_playingAnimFl = false;
+		_fallFl = false;
+		_counter = 0;
+		_pauseMode = 0;
+		_vm->_dialogs->show(0x51AE);
+		_game._player._stepEnabled = true;
+		break;
+	}
+}
+
+void Scene209::handleMonkey1() {
+	switch (_game._trigger) {
+	case 212:
+		_scene->_sequences.remove(_globals._spriteIndexes[19]);
+		_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 9, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], 1, 13);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[19], SM_0, 0, 213);
+		break;
+
+	case 213: {
+		int oldIdx = _globals._spriteIndexes[19];
+		_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 7, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[22], 1, 22);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[22], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 214);
+		}
+		break;
+
+	case 214: {
+		int oldIdx = _globals._spriteIndexes[22];
+		_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 7, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[22], 23, 26);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[22], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 215);
+		int msgIndex = _scene->_kernelMessages.add(Common::Point(170, 21), 0xFDFC, 0, 0, 90, _game.getQuote(156));
+		_scene->_kernelMessages.setQuoted(msgIndex, 3, true);
+		}
+		break;
+
+	case 215: {
+		_vm->_sound->command(18);
+		_scene->loadAnimation(Resources::formatName(209, 'a', -1, EXT_AA, ""), 251);
+		int oldIdx = _globals._spriteIndexes[22];
+		_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 7, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[22], 27, 35);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[22], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 216);
+		}
+		break;
+
+	case 216: {
+		int oldIdx = _globals._spriteIndexes[22];
+		_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 22);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[19], oldIdx);
+		_scene->_sequences.addTimer(25, 217);
+		}
+		break;
+
+	case 217:
+		_pitchFl = false;
+		_counter = 0;
+		_pauseMode = 0;
+		_scene->_sequences.addTimer(1, 196);
+		break;
+	}
+}
+
+void Scene209::handleMonkey2() {
+	switch (_game._trigger) {
+	case 251:
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 60, _game.getQuote(137));
+		_vm->_sound->command(22);
+		_globals._spriteIndexes[27] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[12], false, 11, 1, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[27], Common::Point(111, 133));
+		_scene->_sequences.setScale(_globals._spriteIndexes[27], 79);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[27], 1, 6);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[27], SM_0, 0, 252);
+		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+		_game._player._visible = false;
+		break;
+
+	case 252: {
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(132));
+		int oldIdx = _globals._spriteIndexes[27];
+		_globals._spriteIndexes[27] = _scene->_sequences.startCycle(_globals._spriteIndexes[12], false, 7);
+		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[27], Common::Point(111, 133));
+		_scene->_sequences.setScale(_globals._spriteIndexes[27], 79);
+		_scene->_sequences.updateTimeout(_globals._spriteIndexes[27], oldIdx);
+		_scene->_sequences.addTimer(120, 253);
+		}
+		break;
+
+	case 253:
+		_scene->_sequences.remove(_globals._spriteIndexes[27]);
+		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+		_game._player._visible = true;
+		_game._player._stepEnabled = true;
+		break;
+	}
+}
+
+void Scene209::handleDodge() {
+	switch (_game._trigger) {
+	case 241:
+		_scene->_hotspots.activate(227, true);
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 7);
+		_scene->_sequences.addTimer(6, 242);
+		break;
+
+	case 242:
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 5);
+		_scene->_sequences.addTimer(25, 243);
+		_vm->_sound->command(24);
+		break;
+
+	case 243:
+		_vm->_sound->command(18);
+		_scene->_sequences.remove(_globals._spriteIndexes[18]);
+		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+		_playingAnimFl = false;
+		_pauseMode = 0;
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(180, 21), 0xFDFC, 0, 0, 90, _game.getQuote(155));
+		if (!_shootMissedLastFl) {
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(135));
+			_shootMissedLastFl = true;
+		} else {
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(136));
+		}
+		break;
+	}
+}
+
+void Scene209::enter() {
+	_globals._spriteIndexes[12] = _scene->_sprites.addSprites(formAnimName('a', 1), 0);
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('e', -1), 0);
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 0), 0);
+	_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('b', 1), 0);
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('m', 0), 0);
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('m', 1), 0);
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('m', 3), 0);
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('m', 6), 0);
+	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('m', 8), 0);
+
+	_game.loadQuoteSet(0x82, 0x83, 0x84, 0x9C, 0x97, 0x95, 0x99, 0x9E, 0x98, 0x9B, 0xA0, 0x96, 0x9F,
+		0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x91, 0x92, 0x93, 0x94, 0x89, 0x85, 0x8A, 0x86, 0x87, 0x88, 0);
+
+	_vm->_palette->setEntry(252, 63, 44, 30);
+	_vm->_palette->setEntry(253, 63, 20, 22);
+
+	if (_game._objects.isInRoom(OBJ_PLANT_STALK)) {
+		_globals._spriteIndexes[16] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+		int idx = _scene->_dynamicHotspots.add(271, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, 263, 129, FACING_SOUTH);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[16], 13);
+	}
+
+	if (_scene->_priorSceneId == 208) {
+		_game._player._playerPos = Common::Point(11, 121);
+		_game._player._facing = FACING_EAST;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(28, 121);
+		_game._player._facing = FACING_SOUTH;
+	}
+
+	if (_game._objects.isInRoom(OBJ_BINOCULARS)) {
+		_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
+		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(201, 131));
+		_scene->_sequences.setDepth(_globals._spriteIndexes[24], 8);
+		int idx = _scene->_dynamicHotspots.add(39, 13, _globals._spriteIndexes[24], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, 200, 133, FACING_NORTH);
+	}
+
+	if (_scene->_roomChanged) {
+		_game._objects.addToInventory(OBJ_POISON_DARTS);
+		_game._objects.addToInventory(OBJ_BLOWGUN);
+		_globals[36] = 1;
+	}
+
+	_pitchFl = false;
+	_fallFl = false;
+	_dodgeFl = false;
+	_playingAnimFl = false;
+	_monkeyPosition = 1;
+	_counter = 0;
+	_pauseMode = 0;
+	_forceFallFl = false;
+	_shouldFallFl = false;
+	_forceDodgeFl = false;
+	_binocularsDroppedFl = false;
+	_shouldDodgeFl = false;
+	_startShootingInTimerFl = false;
+	_dialogAbortVal = 5;
+	_playingDialogFl = false;
+	_shootMissedLastFl = false;
+	_removeMonkeyFl = true;
+	_shootReadyFl = false;
+
+	_scene->_hotspots.activate(227, false);
+
+	sceneEntrySound();
+}
+
+void Scene209::step() {
+	if (!_playingAnimFl && !_pitchFl && !_fallFl && !_dodgeFl && (_pauseMode == 0) && (_globals[36] == 1)) {
+		int randAction = _vm->getRandomNumber(1,50);
+		switch (randAction) {
+		case 1:
+			if ((_monkeyPosition == 1) && (_counter < 2)) {
+				_scene->_sequences.addTimer(1, 133);
+				_playingAnimFl = true;
+				_scene->_hotspots.activate(227, true);
+				++_counter;
+			}
+			break;
+	
+		case 2:
+			if ((_monkeyPosition == 1) && (_counter < 2)) {
+				_scene->_sequences.addTimer(1, 140);
+				_scene->_hotspots.activate(227, true);
+				_playingAnimFl = true;
+				++_counter;
+			}
+			break;
+	
+		case 3:
+			if (_monkeyPosition == 1) {
+				_scene->_sequences.addTimer(1, 145);
+				_scene->_hotspots.activate(227, true);
+				_playingAnimFl = true;
+				_counter = 0;
+			}
+			break;
+	
+		case 4:
+			if ((_monkeyPosition == 2) && (_counter < 2)) {
+				_scene->_sequences.addTimer(1, 151);
+				_scene->_hotspots.activate(227, true);
+				++_counter;
+				_playingAnimFl = true;
+			}
+			break;
+	
+		case 5:
+			if (_monkeyPosition == 2) {
+				_scene->_sequences.addTimer(1, 161);
+				_scene->_hotspots.activate(227, true);
+				_counter = 0;
+				_playingAnimFl = true;
+			}
+			break;
+	
+		case 6:
+			if (_monkeyPosition == 2) {
+				_scene->_sequences.addTimer(1, 189);
+				_scene->_hotspots.activate(227, true);
+				_counter = 0;
+				_playingAnimFl = true;
+			}
+			break;
+		case 7:
+			if (_monkeyPosition == 3) {
+				_scene->_hotspots.activate(227, true);
+				_scene->_sequences.addTimer(1, 167);
+				_playingAnimFl = true;
+			}
+			break;
+	
+		case 8:
+			if (_monkeyPosition == 3) {
+				_scene->_sequences.addTimer(1, 178);
+				_playingAnimFl = true;
+				_scene->_hotspots.activate(227, true);
+				_counter = 0;
+			}
+			break;
+	
+		case 9:
+			if ((_monkeyPosition == 3) && (_game._player._playerPos.x<120)) {
+				_scene->_sequences.addTimer(1, 182);
+				_scene->_hotspots.activate(227, true);
+				_counter = 0;
+				_playingAnimFl = true;
+			}
+			break;
+	
+		case 10:
+			if (_monkeyPosition == 4) {
+				_scene->_sequences.addTimer(1, 196);
+				_scene->_hotspots.activate(227, true);
+				_playingAnimFl = true;
+				_counter = 0;
+			}
+			break;
+	
+		case 11:
+			if ((_monkeyPosition == 4) && (_counter < 3)) {
+				_scene->_sequences.addTimer(1, 199);
+				_scene->_hotspots.activate(227, true);
+				++_counter;
+				_playingAnimFl = true;
+			}
+			break;
+	
+		case 30:
+			if (_monkeyPosition == 4) {
+				_scene->_sequences.addTimer(1, 246);
+				_scene->_hotspots.activate(227, true);
+				_counter = 0;
+				_playingAnimFl = true;
+			}
+			break;
+	
+		default:
+			if ((randAction >= 12) && (randAction <= 20) && (_monkeyPosition == 2) && (_counter < 5)) {
+				_scene->_sequences.addTimer(1, 155);
+				++_counter;
+				_playingAnimFl = true;
+			}
+		
+			if ((randAction >= 21) && (randAction <= 29) && (_monkeyPosition == 3) && (_counter < 3)) {
+				_scene->_sequences.addTimer(1, 171);
+				_playingAnimFl = true;
+				++_counter;
+			}
+			break;
+		}
+	}
+
+	if (!_dodgeFl && !_pitchFl && !_fallFl && (_pauseMode == 1))
+		_scene->_sequences.addTimer(1, 226);
+
+	if (!_dodgeFl && !_pitchFl && !_fallFl && (_pauseMode == 2))
+		handlePause();
+
+	if (!_dodgeFl && !_pitchFl && !_fallFl && (_pauseMode == 1))
+		initPauseCounterThreshold();
+
+	handlePeek();
+	handleVerticalMove();
+	handleLookStay();
+	handleLookRight();
+	handleBlink();
+	handleGetBinoculars();
+	handleStandFromPeek();
+	handleDodge();
+	handleBinocularBlink();
+	handleBinocularScan();
+	handleJumpInTree();
+	handleTongue();
+	handleMonkeyFall();
+	handleJumpAndHide();
+	handleMonkeyEating();
+	handleMonkey1();
+	handleStandBlink();
+	handleMonkey2();
+
+	if ((_monkeyPosition == 1) && !_playingAnimFl && _fallFl) {
+		_scene->_sequences.addTimer(1, 145);
+		_playingAnimFl = true;
+	}
+
+	if ((_monkeyPosition == 2) && !_playingAnimFl && _fallFl) {
+		_scene->_sequences.addTimer(1, 161);
+		_playingAnimFl = true;
+	}
+
+	if ((_monkeyPosition == 4) && !_playingAnimFl && _fallFl) {
+		_scene->_sequences.addTimer(1, 196);
+		_playingAnimFl = true;
+	}
+
+	if ((_monkeyPosition == 3) && !_playingAnimFl && _fallFl && _forceFallFl) {
+		_scene->_sequences.addTimer(1, 219);
+		_playingAnimFl = true;
+	}
+
+	if ((_monkeyPosition == 1) && !_playingAnimFl && _pitchFl) {
+		_scene->_sequences.addTimer(1, 145);
+		_playingAnimFl = true;
+	}
+
+	if ((_monkeyPosition == 2) && !_playingAnimFl && _pitchFl) {
+		_scene->_sequences.addTimer(1, 189);
+		_playingAnimFl = true;
+	}
+
+	if ((_monkeyPosition == 4) && !_playingAnimFl && _pitchFl) {
+		_scene->_sequences.addTimer(1, 212);
+		_playingAnimFl = true;
+	}
+
+	if ((_monkeyPosition == 3) && !_playingAnimFl && _pitchFl) {
+		_scene->_sequences.addTimer(1, 178);
+		_playingAnimFl = true;
+	}
+
+	if ((_monkeyPosition == 1) && !_playingAnimFl && _dodgeFl) {
+		_scene->_sequences.addTimer(1, 145);
+		_playingAnimFl = true;
+	}
+
+	if ((_monkeyPosition == 4) && !_playingAnimFl && _dodgeFl) {
+		_scene->_sequences.addTimer(1, 196);
+		_playingAnimFl = true;
+	}
+
+	if ((_monkeyPosition == 3) && !_playingAnimFl && _dodgeFl) {
+		_scene->_sequences.addTimer(1, 178);
+		_playingAnimFl = true;
+	}
+
+	if ((_monkeyPosition == 2) && !_playingAnimFl && _dodgeFl && _forceDodgeFl) {
+		_scene->_sequences.addTimer(1, 241);
+		_playingAnimFl = true;
+	}
+
+	if (_dodgeFl || _fallFl) { /* if want to dodge or fall */
+		if (!_playingAnimFl && (_monkeyPosition == 2))
+			_shouldDodgeFl = true;
+
+		if (!_playingAnimFl && (_monkeyPosition == 3))
+			_shouldFallFl = true;
+
+		switch (_game._trigger) {
+		case 228:
+			_game._player._visible = false;
+			_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._spriteIndexes[17], 1, 7);
+			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(116, 131));
+			_scene->_sequences.setDepth(_globals._spriteIndexes[17], 4);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], SM_0, 0, 228);
+			break;
+
+		case 229: {
+			int oldIdx = _globals._spriteIndexes[17];
+			_globals._spriteIndexes[17] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 7);
+			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(116, 131));
+			_scene->_sequences.setDepth(_globals._spriteIndexes[17], 4);
+			_scene->_sequences.updateTimeout(_globals._spriteIndexes[17], oldIdx);
+			_scene->_sequences.addTimer(35, 230);
+			}
+			break;
+
+		case 230:
+			_scene->_sequences.remove(_globals._spriteIndexes[17]);
+			_globals._spriteIndexes[17] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._spriteIndexes[17], 1, 7);
+			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(116, 131));
+			_scene->_sequences.setDepth(_globals._spriteIndexes[17], 4);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], SM_0, 0, 231);
+			break;
+
+		case 231: {
+			int oldIdx = _globals._spriteIndexes[17];
+			_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._spriteIndexes[17], 8, 10);
+			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(116, 131));
+			_scene->_sequences.setDepth(_globals._spriteIndexes[17], 4);
+			_scene->_sequences.updateTimeout(_globals._spriteIndexes[17], oldIdx);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], SM_0, 0, 232);
+			_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+			_scene->_sequences.updateTimeout(_globals._spriteIndexes[17], -1);
+			_game._player._visible = false;
+			}
+			break;
+
+		case 232: {
+			int oldIdx = _globals._spriteIndexes[17];
+			_globals._spriteIndexes[17] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 10);
+			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(116, 131));
+			_scene->_sequences.setDepth(_globals._spriteIndexes[17], 4);
+			_scene->_sequences.updateTimeout(_globals._spriteIndexes[17], oldIdx);
+			_scene->_sequences.addTimer(2, 233);
+			_scene->_kernelMessages.reset();
+			if (_dodgeFl && (_monkeyPosition != 1) && (_monkeyPosition != 2))
+				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 34463, _game.getQuote(138));
+			if (_fallFl && (_monkeyPosition != 3))
+				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 34463, _game.getQuote(138));
+			}
+			break;
+
+		case 233:
+			_shootReadyFl = true;
+			break;
+
+		case 234:
+			_scene->_sequences.remove(_globals._spriteIndexes[17]);
+			_scene->_kernelMessages.reset();
+			if (_action.isAction(NOUN_HOSE_DOWN, NOUN_BLOWGUN, NOUN_MONKEY)) {
+				_globals._spriteIndexes[17] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[2], false, 7, 16, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._spriteIndexes[17], 11, 12);
+				_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(116, 131));
+				_scene->_sequences.setDepth(_globals._spriteIndexes[17], 4);
+				_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], SM_FRAME_INDEX, 12, 239);
+				_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], SM_0, 0, 235);
+			} else if (_action.isAction(NOUN_SHOOT, NOUN_BLOWGUN, NOUN_MONKEY)) {
+				_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._spriteIndexes[17], 11, 12);
+				_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(116, 131));
+				_scene->_sequences.setDepth(_globals._spriteIndexes[17], 4);
+				_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], SM_0, 0, 235);
+				_vm->_sound->command(23);
+			}
+			break;
+
+		case 235: {
+			int oldIdx = _globals._spriteIndexes[17];
+			_globals._spriteIndexes[17] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 13);
+			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(116, 131));
+			_scene->_sequences.setDepth(_globals._spriteIndexes[17], 4);
+			_scene->_sequences.updateTimeout(_globals._spriteIndexes[17], oldIdx);
+			_scene->_sequences.addTimer(12, 236);
+			_forceFallFl = true;
+			_forceDodgeFl = true;
+			}
+			break;
+
+		case 236:
+			_scene->_sequences.remove(_globals._spriteIndexes[17]);
+			_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._spriteIndexes[17], 14, 16);
+			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(116, 131));
+			_scene->_sequences.setDepth(_globals._spriteIndexes[17], 4);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], SM_0, 0, 237);
+			break;
+
+		case 237:
+			_game._player._visible = true;
+			_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+			_scene->_sequences.addTimer(1, 238);
+			break;
+
+		case 238:
+			_scene->_sequences.remove(_globals._spriteIndexes[17]);
+			if (_dodgeFl)
+				_game._player._stepEnabled = true;
+
+			_startShootingInTimerFl = false;
+
+			if (_fallFl) {
+				_globals[36] = MONKEY_IS_GONE;
+				_game._objects.setRoom(OBJ_POISON_DARTS, NOWHERE);
+			}
+			_dodgeFl = false;
+			_fallFl = false;
+			_forceFallFl = false;
+			_forceDodgeFl = false;
+			_shouldFallFl = false;
+			_shouldDodgeFl = false;
+			break;
+
+		case 239:
+			_vm->_sound->command(23);
+			break;
+		}
+	}
+
+	if (_game._trigger == 100)
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(134));
+
+	if (_shootReadyFl && (_shouldFallFl || _shouldDodgeFl)) {
+		_scene->_sequences.addTimer(4, 234);
+		_shootReadyFl = false;
+	}
+}
+
+void Scene209::preActions() {
+	if (_action.isAction(0x18C, 0x84))
+		_game._player._walkOffScreenSceneId = 208;
+
+	if (_globals[36] == 1) {
+		if ((_action.isAction(NOUN_SHOOT) || _action.isAction(NOUN_HOSE_DOWN)) && _action.isAction(NOUN_MONKEY) 
+			&& _action.isAction(NOUN_BLOWGUN) && _game._objects.isInInventory(OBJ_BLOWGUN) && _game._objects.isInInventory(OBJ_POISON_DARTS)) {
+			_game._player._prepareWalkPos = Common::Point(111, 129);
+			_game._player._prepareWalkFacing = FACING_NORTHEAST;
+			_game._player._needToWalk = true;
+			_game._player._readyToWalk = true;
+		}
+
+		if (_action.isAction(VERB_LOOK, NOUN_MONKEY) || _action.isAction(VERB_TALKTO, NOUN_MONKEY)) {
+			_game._player._prepareWalkPos = Common::Point(111, 129);
+			_game._player._prepareWalkFacing = FACING_NORTHEAST;
+			_game._player._needToWalk = true;
+			_game._player._readyToWalk = true;
+		}
+	}
+}
+
+void Scene209::actions() {
+	if (_action._lookFlag) {
+		_vm->_dialogs->show(0x51B0);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(0x18C, 0x1A2)) {
+		_scene->_nextSceneId = 203;
+		_action._inProgress = false;
+		return;
+	}
+
+	if ((_action.isAction(VERB_TALKTO, NOUN_MONKEY)) && !_pitchFl && !_playingDialogFl) {
+		_scene->_sequences.addTimer(1, _dialogAbortVal);
+		_playingDialogFl = true;
+		_game._player._stepEnabled = false;
+		_action._inProgress = false;
+		return;
+	}
+
+	switch (_game._trigger) {
+	case 130:
+		_game._player._stepEnabled = true;
+		_playingDialogFl = false;
+		_action._inProgress = false;
+		return;
+
+	case 5:
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 6, 180, _game.getQuote(139));
+		_action._inProgress = false;
+		return;
+
+	case 6:
+		_scene->_kernelMessages.add(Common::Point(180, 21), 0xFDFC, 0, 0, 60, _game.getQuote(151));
+		_scene->_sequences.addTimer(60, 130);
+		_dialogAbortVal = 7;
+		_action._inProgress = false;
+		return;
+
+	case 7:
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 8, 180, _game.getQuote(140));
+		_action._inProgress = false;
+		return;
+
+	case 8:
+		_scene->_kernelMessages.add(Common::Point(180, 21), 0xFDFC, 0, 0, 60, _game.getQuote(149));
+		_scene->_sequences.addTimer(60, 130);
+		_dialogAbortVal = 9;
+		_action._inProgress = false;
+		return;
+
+	case 9:
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 180, _game.getQuote(141));
+		_scene->_sequences.addTimer(200, 10);
+		_action._inProgress = false;
+		return;
+
+	case 10:
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 11, 180, _game.getQuote(142));
+		_action._inProgress = false;
+		return;
+
+	case 11:
+		_scene->_kernelMessages.add(Common::Point(180, 21), 0xFDFC, 0, 0, 60, _game.getQuote(152));
+		_scene->_sequences.addTimer(60, 130);
+		_dialogAbortVal = 12;
+		_action._inProgress = false;
+		return;
+
+	case 12:
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 130, _game.getQuote(143));
+		_scene->_sequences.addTimer(150, 13);
+		_action._inProgress = false;
+		return;
+
+	case 13:
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 14, 180, _game.getQuote(145));
+		_action._inProgress = false;
+		return;
+
+	case 14:
+		_scene->_kernelMessages.add(Common::Point(180, 21), 0xFDFC, 0, 0, 60, _game.getQuote(151));
+		_scene->_sequences.addTimer(60, 130);
+		_dialogAbortVal = 15;
+		_action._inProgress = false;
+		return;
+
+	case 15:
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 16, 180, _game.getQuote(146));
+		_action._inProgress = false;
+		return;
+
+	case 16:
+		_scene->_kernelMessages.add(Common::Point(180, 21), 0xFDFC, 0, 17, 60, _game.getQuote(154));
+		_action._inProgress = false;
+		return;
+
+	case 17:
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 130, 60, _game.getQuote(147));
+		_dialogAbortVal = 18;
+		_action._inProgress = false;
+		return;
+
+	case 18:
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 180, _game.getQuote(148));
+		_pitchFl = true;
+		_playingDialogFl = false;
+		_dialogAbortVal = 5;
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_globals[36] == 1) {
+		if ((_action.isAction(NOUN_SHOOT) || _action.isAction(NOUN_HOSE_DOWN)) && _action.isAction(NOUN_MONKEY)
+			&& _action.isAction(NOUN_BLOWGUN) && _game._objects.isInInventory(OBJ_BLOWGUN) && _game._objects.isInInventory(OBJ_POISON_DARTS)) {
+			if (_action.isAction(NOUN_SHOOT, NOUN_BLOWGUN, NOUN_MONKEY) && !_startShootingInTimerFl) {
+				_game._triggerSetupMode = KERNEL_TRIGGER_DAEMON;
+				_scene->_sequences.addTimer(1, 231);
+				_startShootingInTimerFl = true;
+				_game._player._stepEnabled = false;
+				_dodgeFl = true;
+				_action._inProgress = false;
+				return;
+			} 
+			
+			if (_action.isAction(NOUN_HOSE_DOWN, NOUN_BLOWGUN, NOUN_MONKEY) && !_startShootingInTimerFl) {
+				_game._triggerSetupMode = KERNEL_TRIGGER_DAEMON;
+				_scene->_sequences.addTimer(1, 228);
+				_game._player._stepEnabled = false;
+				_fallFl = true;
+				_startShootingInTimerFl = true;
+				_action._inProgress = false;
+				return;
+			}
+		}
+
+		if (_action.isAction(VERB_LOOK, NOUN_MONKEY)) {
+			_pitchFl = true;
+			_game._player._stepEnabled = false;
+			_vm->_dialogs->show(0x51B2);
+			_action._inProgress = false;
+			return;
+		}
+	}
+
+	if (_action.isAction(VERB_TAKE, NOUN_PLANT_STALK) && (_game._trigger || _game._objects.isInRoom(OBJ_PLANT_STALK))) {
+		switch (_game._trigger) {
+		case 0:
+			_globals._spriteIndexes[11] = _scene->_sprites.addSprites("*RXMBD_2", 0);
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_globals._spriteIndexes[26] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[11], false, 3, 2, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._spriteIndexes[26]);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_FRAME_INDEX, 4, 1);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_0, 0, 2);
+			break;
+
+		case 1:
+			_scene->_sequences.remove(_globals._spriteIndexes[16]);
+			_game._objects.addToInventory(OBJ_PLANT_STALK);
+			break;
+
+		case 2:
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			_scene->_sequences.addTimer(4, 3);
+			_vm->_dialogs->showPicture(OBJ_PLANT_STALK, 0x328);
+			break;
+
+		case 3:
+			_scene->_sprites.remove(_globals._spriteIndexes[11]);
+			break;
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_TAKE, 0x27) && (_game._trigger || _game._objects.isInRoom(OBJ_BINOCULARS))) {
+		switch (_game._trigger) {
+		case 0:
+			_globals._spriteIndexes[10] = _scene->_sprites.addSprites("*RXMBD_8", false);
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_globals._spriteIndexes[25] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[10], false, 3, 2, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._spriteIndexes[25]);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[25], SM_FRAME_INDEX, 4, 1);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[25], SM_0, 0, 2);
+			break;
+
+		case 1:
+			_scene->_sequences.remove(_globals._spriteIndexes[24]);
+			_game._objects.addToInventory(OBJ_BINOCULARS);
+			break;
+
+		case 2:
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			_binocularsDroppedFl = false;
+			_scene->_sequences.addTimer(4, 3);
+			break;
+
+		case 3:
+			_vm->_dialogs->showPicture (OBJ_BINOCULARS, 0x51AF);
+			_scene->_sprites.remove(_globals._spriteIndexes[10]);
+			break;
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x142)) {
+		_vm->_dialogs->show(0x51A5);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x1A3)) {
+		_vm->_dialogs->show(0x51A6);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x1A4)) {
+		_vm->_dialogs->show(0x51A7);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x1A6)) {
+		_vm->_dialogs->show(0x51A8);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x84)) {
+		_vm->_dialogs->show(0x51A9);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x1A2)) {
+		_vm->_dialogs->show(0x51AA);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x10F) && (_action._savedFields._mainObjectSource == 4)) {
+		_vm->_dialogs->show(0x51AB);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_GIVE, 0x17A, 0xE3) || _action.isAction(VERB_THROW, 0x17A, 0xE3)) {
+		_vm->_dialogs->show(0x51AD);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x175)) {
+		_vm->_dialogs->show(0x51B1);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_THROW, 0xE3) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
+		if (!_action.isAction(0x114)) {
+			_vm->_dialogs->show(0x51B3);
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_THROW, 0x114, 0xE3)) {
+		_vm->_dialogs->show(0x51B4);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x100)) {
+		if (_globals[36] == 1) {
+			if (_monkeyPosition == 1)
+				_vm->_dialogs->show(0x51B5);
+			else
+				_vm->_dialogs->show(0x51B6);
+		} else {
+			if (_globals[36] == 0)
+				_vm->_dialogs->show(0x51B5);
+			else
+				_vm->_dialogs->show(0x51B7);
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x3A4)) {
+		_vm->_dialogs->show(0x51B8);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_TAKE, 0x3A4)) {
+		_vm->_dialogs->show(0x51B9);
+		_action._inProgress = false;
+		return;
+	}
 }
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index a749e8a..d29b94e 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -155,8 +155,45 @@ public:
 };
 
 class Scene209: public Scene2xx {
+private:
+	bool _dodgeFl, _forceDodgeFl, _shouldDodgeFl;
+	bool _pitchFl;
+	bool _fallFl, _forceFallFl, _shouldFallFl;
+	bool _playingAnimFl, _playingDialogFl;
+	int _pauseMode, _pauseCounterThreshold, _pauseCounter;
+	bool _removeMonkeyFl;
+	int _monkeyPosition;
+	bool _shootReadyFl, _startShootingInTimerFl, _shootMissedLastFl;
+	bool _binocularsDroppedFl;
+	int _dialogAbortVal;
+	int _counter;
+
+	void handlePause();
+	void initPauseCounterThreshold();
+	void handlePeek();
+	void handleVerticalMove();
+	void handleLookStay();
+	void handleLookRight();
+	void handleBlink();
+	void handleGetBinoculars();
+	void handleStandFromPeek();
+	void handleDodge();
+	void handleBinocularBlink();
+	void handleBinocularScan();
+	void handleJumpInTree();
+	void handleTongue();
+	void handleMonkeyFall();
+	void handleJumpAndHide();
+	void handleMonkeyEating();
+	void handleMonkey1();
+	void handleStandBlink();
+	void handleMonkey2();
+
 public:
-	Scene209(MADSEngine *vm) : Scene2xx(vm) {}
+	Scene209(MADSEngine *vm) : Scene2xx(vm), _dodgeFl(false), _forceDodgeFl(false), _pitchFl(false), _fallFl(false), _forceFallFl(false),
+	   _playingAnimFl(false), _shouldFallFl(false), _shouldDodgeFl(false), _monkeyPosition(0), _counter(0), _pauseMode(0),
+	   _binocularsDroppedFl(false), _startShootingInTimerFl(false), _dialogAbortVal(0), _playingDialogFl(false),_shootMissedLastFl(false),
+	   _removeMonkeyFl(false), _shootReadyFl(false), _pauseCounterThreshold(0), _pauseCounter(0) {}
 	virtual void setup();
 	virtual void enter();
 	virtual void step();


Commit: ae6e19d7fc5b68611b33cdc6aabfce9379a561a2
    https://github.com/scummvm/scummvm/commit/ae6e19d7fc5b68611b33cdc6aabfce9379a561a2
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-05T23:37:48+02:00

Commit Message:
MADS: Some rework in scene group 1 and 8

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes8.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 6d63a56..7cc4fb3 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -140,56 +140,43 @@ void Scene103::enter() {
 
 	_globals._spriteIndexes[12] = _scene->_sprites.addSprites("*RXMBD_2");
 	_globals._spriteIndexes[13] = _scene->_sprites.addSprites("*RXMRD_3");
-	_globals._spriteIndexes[15] = _scene->_sequences.addSpriteCycle(
-		_globals._spriteIndexes[0], false, 7, 0, 1, 0);
-	_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(
-		_globals._spriteIndexes[1], false, 6, 0, 2, 0);
+	_globals._spriteIndexes[15] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 7, 0, 1, 0);
+	_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 2, 0);
 	_scene->_sequences.setDepth(_globals._spriteIndexes[16], 0);
 
-	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(
-		_globals._spriteIndexes[2], false, 6, 0, 0, 25);	
+	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 25);	
 	_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], SM_FRAME_INDEX, 2, 72);
-	_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(
-		_globals._spriteIndexes[3], false, 6, 0, 1, 37);
+	_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 1, 37);
 	_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_FRAME_INDEX, 2, 73);
 
-	_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(
-		_globals._spriteIndexes[8], false, 8);
-	_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(
-		_globals._spriteIndexes[7], false, 6);
-	_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(
-		_globals._spriteIndexes[4], false, 6);
-	_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(
-		_globals._spriteIndexes[5], false, 6);
+	_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8);
+	_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 6);
+	_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6);
+	_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6);
 
-	if (_game._objects.isInRoom(OBJ_TIMER_MODULE)) {
+	if (_game._objects.isInRoom(OBJ_TIMER_MODULE))
 		_vm->_game->_scene._hotspots.activate(371, false);
-	} else {
-		_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(
-			_globals._spriteIndexes[11], false, 6);
-	}
+	else
+		_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 6);
 
-	if (_game._objects.isInRoom(OBJ_REBREATHER)) {
+	if (_game._objects.isInRoom(OBJ_REBREATHER))
 		_vm->_game->_scene._hotspots.activate(289, false);
-	} else {
-		_globals._spriteIndexes[25] = _scene->_sequences.addSpriteCycle(
-			_globals._spriteIndexes[10], false, 6);
-	}
+	else
+		_globals._spriteIndexes[25] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[10], false, 6);
 	
 	if (_globals[kTurkeyExploded]) {
-		_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(
-			_globals._spriteIndexes[9], false, 6);
+		_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6);
 		_scene->_sequences.setAnimRange(_globals._spriteIndexes[24], -2, -2);
 		_scene->_hotspots.activate(362, false);
 	}
 
 	if (_scene->_priorSceneId != -2)
 		_game._player._playerPos = Common::Point(237, 74);
+
 	if (_scene->_priorSceneId == 102) {
 		_game._player._stepEnabled = false;
 
-		_globals._spriteIndexes[21] = _scene->_sequences.addReverseSpriteCycle(
-			_globals._spriteIndexes[6], false, 6, 1, 0, 0);
+		_globals._spriteIndexes[21] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[6], false, 6, 1, 0, 0);
 		_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 70);
 	}
 
@@ -197,8 +184,7 @@ void Scene103::enter() {
 	_vm->_game->loadQuoteSet(70, 51, 71, 7, 73, 0);
 
 	if (!_game._visitedScenes._sceneRevisited) {
-		int msgIndex = _scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 
-			34, 0, 120, _game.getQuote(70));
+		int msgIndex = _scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(70));
 		_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
 	}
 
@@ -262,8 +248,7 @@ void Scene103::actions() {
 	} else if (_action.isAction(395, 110)) {
 		switch (_vm->_game->_trigger) {
 		case 0:
-			_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(
-				_globals._spriteIndexes[6], false, 6, 1);
+			_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 1);
 			_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 1);
 			_game._player._stepEnabled = false;
 			_vm->_sound->command(20);
@@ -348,9 +333,7 @@ void Scene103::actions() {
 			_vm->_sound->command(31);
 
 		if (_vm->_game->_fx < 2) {
-			_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(
-				_globals._spriteIndexes[9], false, 6,
-				_vm->_game->_trigger < 1 ? 1 : 0);
+			_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, _vm->_game->_trigger < 1 ? 1 : 0);
 			if (_vm->_game->_trigger) {
 				_scene->_sequences.setAnimRange(_globals._spriteIndexes[24], -1, 0);
 				Common::String msg = _game.getQuote(51);
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index f8eeb37..6fee0cb 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -105,30 +105,22 @@ void Scene804::enter() {
 
 	if (_globals[kInSpace]) {
 		if (_globals[kWindowFixed]) {
-			_globals._spriteIndexes[20] = _scene->_sequences.startCycle(
-				_globals._spriteIndexes[5], 0, 1);
+			_globals._spriteIndexes[20] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], 0, 1);
 			_scene->_sequences.addTimer(60, 100);
 		} else {
-			_globals._spriteIndexes[21] = _scene->_sequences.startCycle(
-				_globals._spriteIndexes[6], false, 1);
-			_globals._spriteIndexes[22] = _scene->_sequences.startReverseCycle(
-				_globals._spriteIndexes[7], false, 4, 0, 0, 0);
+			_globals._spriteIndexes[21] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 1);
+			_globals._spriteIndexes[22] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[7], false, 4, 0, 0, 0);
 			_scene->_sequences.addTimer(160, 70);
 			_game._player._stepEnabled = false;
 		}
 	} else {
-		if (_globals[kBeamIsUp] == 0) {
-			_globals._spriteIndexes[23] = _scene->_sequences.startCycle(
-				_globals._spriteIndexes[8], false, 1);
-		}
+		if (_globals[kBeamIsUp] == 0)
+			_globals._spriteIndexes[23] = _scene->_sequences.startCycle(_globals._spriteIndexes[8], false, 1);
 
-		if (_globals[kWindowFixed] == 0) {
-			_globals._spriteIndexes[23] = _scene->_sequences.startCycle(
-				_globals._spriteIndexes[19], false, 1);
-		}
+		if (_globals[kWindowFixed] == 0)
+			_globals._spriteIndexes[23] = _scene->_sequences.startCycle(_globals._spriteIndexes[19], false, 1);
 
-		_globals._spriteIndexes[1] = _scene->_sequences.startCycle(
-			_globals._spriteIndexes[1], false, 1);
+		_globals._spriteIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
 		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[16], Common::Point(133, 139));
 		_scene->_sequences.setDepth(_globals._spriteIndexes[16], 8);
 	}
@@ -168,10 +160,8 @@ void Scene804::step() {
 		}
 	} else {
 		if (_globals._v3 && _globals._v2 && _scene->_activeAnimation->getCurrentFrame() == 39) {
-			_globals._spriteIndexes[16] = _scene->_sequences.startCycle(
-				_globals._spriteIndexes[1], false, 1);
-			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[16],
-				Common::Point(133, 139));
+			_globals._spriteIndexes[16] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[16], Common::Point(133, 139));
 			_scene->_sequences.setDepth(_globals._spriteIndexes[16], 8);
 			_globals._v3 = 0;
 		}
@@ -183,6 +173,7 @@ void Scene804::step() {
 
 		if (_game._trigger == 70)
 			_globals._v5 = 42;
+
 		if (_scene->_activeAnimation->getCurrentFrame() == 65)
 			_scene->_sequences.remove(_globals._spriteIndexes[22]);
 


Commit: 3b27d99c397d6dca2485d50064c7529be1a44f19
    https://github.com/scummvm/scummvm/commit/3b27d99c397d6dca2485d50064c7529be1a44f19
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-05T23:38:09+02:00

Commit Message:
MADS: Remove useless global variable

Changed paths:
    engines/mads/nebular/globals_nebular.cpp
    engines/mads/nebular/globals_nebular.h



diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp
index 80e8ded..382a31e 100644
--- a/engines/mads/nebular/globals_nebular.cpp
+++ b/engines/mads/nebular/globals_nebular.cpp
@@ -46,7 +46,6 @@ Globals::Globals() {
 	_v7 = 0;
 	_v8 = 0;
 	_abortVal = 0;
-	_v8425C = 0;
 	_v84262 = 0;
 	_v84264 = 0;
 	_v84266 = 0;
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index 14bb2fb..51e18ee 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -296,7 +296,6 @@ public:
 	uint32 _v7;
 	int _v8;
 	int _abortVal;
-	uint32 _v8425C;
 	int _v84262, _v84264, _v84266, _v84268;
 public:
 	/**


Commit: d3bc036a46ea83a0bd5a4d16577740b25e8eaec4
    https://github.com/scummvm/scummvm/commit/d3bc036a46ea83a0bd5a4d16577740b25e8eaec4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-05T17:50:58-04:00

Commit Message:
MADS: Fix display of dialog at end of taking turkey explosion sequence

Changed paths:
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index ff25696..871e104 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -234,6 +234,7 @@ bool DialogsNebular::show(int msgId) {
 		dialog->incNumLines();
 	
 	// Show the dialog
+	_vm->_events->setCursor(CURSOR_ARROW);
 	dialog->show();
 
 	delete dialog;
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 7cc4fb3..5e4d169 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -335,18 +335,21 @@ void Scene103::actions() {
 		if (_vm->_game->_fx < 2) {
 			_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, _vm->_game->_trigger < 1 ? 1 : 0);
 			if (_vm->_game->_trigger) {
+				// Rex says "Gads.."
 				_scene->_sequences.setAnimRange(_globals._spriteIndexes[24], -1, 0);
 				Common::String msg = _game.getQuote(51);
 				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 18, 0, 60, msg);
-				_scene->_sequences.addTimer(120, _vm->_game->_trigger);
+				_scene->_sequences.addTimer(120, _vm->_game->_trigger + 1);
 			} else {
+				// Start initial explosion
 				_scene->_sequences.addSubEntry(_globals._spriteIndexes[24], SM_0, 0, 1);
 			}
 
 			_game._player._stepEnabled = _game._trigger == 2;
 			_globals[kTurkeyExploded] = -1;
 			if (_game._trigger == 2) {
-				_vm->_dialogs->show(1030);
+				// Show exposition dialog
+				_vm->_dialogs->show(10302);
 				_scene->_hotspots.activate(362, false);
 			}
 		}


Commit: 41e527bb73c6166ce4ed49502de1d8bbee6e4bf6
    https://github.com/scummvm/scummvm/commit/41e527bb73c6166ce4ed49502de1d8bbee6e4bf6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-05T18:48:23-04:00

Commit Message:
MADS: Fix incorrect parameter in turky explosion sequence

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 5e4d169..f7a2a60 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -332,26 +332,30 @@ void Scene103::actions() {
 		if (!_vm->_game->_trigger)
 			_vm->_sound->command(31);
 
-		if (_vm->_game->_fx < 2) {
+		if (_vm->_game->_trigger < 2) {
 			_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, _vm->_game->_trigger < 1 ? 1 : 0);
 			if (_vm->_game->_trigger) {
+				// Lock the turkey into a permanent "exploded" frame
+				_scene->_sequences.setAnimRange(_globals._spriteIndexes[24], -1, -1);
+
 				// Rex says "Gads.."
-				_scene->_sequences.setAnimRange(_globals._spriteIndexes[24], -1, 0);
 				Common::String msg = _game.getQuote(51);
 				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 18, 0, 60, msg);
 				_scene->_sequences.addTimer(120, _vm->_game->_trigger + 1);
 			} else {
-				// Start initial explosion
+				// Initial turky explosion
 				_scene->_sequences.addSubEntry(_globals._spriteIndexes[24], SM_0, 0, 1);
 			}
+		}
 
-			_game._player._stepEnabled = _game._trigger == 2;
-			_globals[kTurkeyExploded] = -1;
-			if (_game._trigger == 2) {
-				// Show exposition dialog
-				_vm->_dialogs->show(10302);
-				_scene->_hotspots.activate(362, false);
-			}
+		// Re-enable player if sequence is ended, and set global flag
+		_game._player._stepEnabled = _game._trigger == 2;
+		_globals[kTurkeyExploded] = -1;
+
+		if (_game._trigger == 2) {
+			// Show exposition dialog at end of sequence
+			_vm->_dialogs->show(10302);
+			_scene->_hotspots.activate(362, false);
 		}
 	} else if (_action.isAction(VERB_LOOK, 250)) {
 		_vm->_dialogs->show(!_globals[kTurkeyExploded] ? 10323 : 10303);


Commit: 0f1b1e3b8c3e7d5463e722ca608b6f4b942a4dd7
    https://github.com/scummvm/scummvm/commit/0f1b1e3b8c3e7d5463e722ca608b6f4b942a4dd7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-05T18:48:46-04:00

Commit Message:
MADS: Remove redundant if block around sequence sub-entries loop

Changed paths:
    engines/mads/sequence.cpp



diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 92cba84..fa6d745 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -303,26 +303,24 @@ bool SequenceList::loadSprites(int seqIndex) {
 		seqEntry._doneFlag = true;
 	}
 
-	if (seqEntry._entries._count > 0) {
-		for (int i = 0; i < seqEntry._entries._count; ++i) {
-			switch (seqEntry._entries._mode[i]) {
-			case SM_0:
-			case SM_1:
-				if (((seqEntry._entries._mode[i] == SM_0) && seqEntry._doneFlag) ||
-					((seqEntry._entries._mode[i] == SM_1) && result))
-					idx = i;
-				break;
-
-			case SM_FRAME_INDEX: {
-				int v = seqEntry._entries._frameIndex[i];
-				if ((v == seqEntry._frameIndex) || (v == 0))
-					idx = i;
-				break;
-			}
+	for (int i = 0; i < seqEntry._entries._count; ++i) {
+		switch (seqEntry._entries._mode[i]) {
+		case SM_0:
+		case SM_1:
+			if (((seqEntry._entries._mode[i] == SM_0) && seqEntry._doneFlag) ||
+				((seqEntry._entries._mode[i] == SM_1) && result))
+				idx = i;
+			break;
 
-			default:
-				break;
-			}
+		case SM_FRAME_INDEX: {
+			int v = seqEntry._entries._frameIndex[i];
+			if ((v == seqEntry._frameIndex) || (v == 0))
+				idx = i;
+			break;
+		}
+
+		default:
+			break;
 		}
 	}
 


Commit: e37d1b72808e3179985bb0d6fe320e105c822688
    https://github.com/scummvm/scummvm/commit/e37d1b72808e3179985bb0d6fe320e105c822688
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-05T21:01:41-04:00

Commit Message:
MADS: Cleanup of the MADSAction class

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index e227d7c..a84c329 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -53,7 +53,7 @@ void MADSAction::clear() {
 	_recentCommandSource = 0;
 	_articleNumber = 0;
 	_lookFlag = false;
-	_v86F4A = 0;
+	_pointEstablished = 0;
 	_selectedRow = -1;
 	_hotspotId = -1;
 	_secondObject = -1;
@@ -74,11 +74,11 @@ void MADSAction::appendVocab(int vocabId, bool capitalise) {
 	_statusText += " ";
 }
 
-void MADSAction::checkCustomDest(int v) {
+void MADSAction::startWalkingDirectly(int walkType) {
 	Scene &scene = _vm->_game->_scene;
 	Player &player = _vm->_game->_player;
 
-	if (_v86F4A && (v == -3 || _savedFields._command < 0)) {
+	if (_pointEstablished && (walkType == -3 || _savedFields._command < 0)) {
 		player._needToWalk = true;
 		player._prepareWalkPos = scene._customDest;
 	}
@@ -304,7 +304,7 @@ void MADSAction::startAction() {
 		if (hotspotId >= (int)hotspots.size()) {
 			DynamicHotspot &hs = dynHotspots[hotspotId - hotspots.size()];
 			if ((hs._feetPos.x == -1) || (hs._feetPos.x == -3)) {
-				checkCustomDest(hs._feetPos.x);
+				startWalkingDirectly(hs._feetPos.x);
 			} else if (hs._feetPos.x == 0) {
 				player._prepareWalkFacing = hs._facing;
 			} else if (_savedFields._commandSource == ACTIONMODE_NONE || hs._cursor >= CURSOR_WAIT) {
@@ -321,7 +321,7 @@ void MADSAction::startAction() {
 		Hotspot &hs = hotspots[hotspotId];
 
 		if (hs._feetPos.x == -1 || hs._feetPos.x == -3) {
-			checkCustomDest(hs._feetPos.x);
+			startWalkingDirectly(hs._feetPos.x);
 		} else if (hs._feetPos.x >= 0) {
 			if (_savedFields._commandSource == ACTIONMODE_NONE || hs._cursor < CURSOR_WAIT) {
 				player._needToWalk = true;
@@ -561,7 +561,7 @@ void MADSAction::leftClick() {
 			if (_vm->_events->currentPos().y < MADS_SCENE_HEIGHT) {
 				scene._customDest = _vm->_events->currentPos() + scene._posAdjust;
 				_selectedAction = -1;
-				_v86F4A = true;
+				_pointEstablished = true;
 			}
 			break;
 
@@ -591,7 +591,7 @@ void MADSAction::leftClick() {
 
 				if (userInterface._category == CAT_HOTSPOT) {
 					scene._customDest = _vm->_events->mousePos() + scene._posAdjust;
-					_v86F4A = true;
+					_pointEstablished = true;
 				}
 			}
 			break;
@@ -609,9 +609,9 @@ void MADSAction::leftClick() {
 				_selectedAction = -1;
 
 				if (userInterface._category == CAT_HOTSPOT) {
-					if (!_v86F4A) {
+					if (!_pointEstablished) {
 						scene._customDest = _vm->_events->mousePos() + scene._posAdjust;
-						_v86F4A = true;
+						_pointEstablished = true;
 					}
 				}
 			}
diff --git a/engines/mads/action.h b/engines/mads/action.h
index 4b51ec9..343f915 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -88,7 +88,7 @@ private:
 
 	void appendVocab(int vocabId, bool capitalise = false);
 
-	void checkCustomDest(int v);
+	void startWalkingDirectly(int v);
 public:
 	ActionDetails _action, _activeAction;
 	int8 _flags1, _flags2;
@@ -108,7 +108,7 @@ public:
 	int16 _secondObject;
 	int16 _secondObjectSource;
 	int16 _recentCommandSource;
-	bool _v86F4A;
+	bool _pointEstablished;
 	int16 _recentCommand;
 	InterAwaiting _interAwaiting;
 	bool _inProgress;


Commit: 11403c5db6eac282e0e1f28623ac25ab95517792
    https://github.com/scummvm/scummvm/commit/11403c5db6eac282e0e1f28623ac25ab95517792
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-05T21:30:42-04:00

Commit Message:
MADS: Further cleanup of previously anonymous fields

Changed paths:
    engines/mads/action.h
    engines/mads/game.cpp
    engines/mads/hotspots.cpp
    engines/mads/screen.cpp
    engines/mads/screen.h



diff --git a/engines/mads/action.h b/engines/mads/action.h
index 343f915..b38e9c2 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -88,7 +88,7 @@ private:
 
 	void appendVocab(int vocabId, bool capitalise = false);
 
-	void startWalkingDirectly(int v);
+	void startWalkingDirectly(int walkType);
 public:
 	ActionDetails _action, _activeAction;
 	int8 _flags1, _flags2;
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index d0d3b27..d964c14 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -171,7 +171,7 @@ void Game::sectionLoop() {
 		_visitedScenes.add(_scene._nextSceneId);
 
 		// Reset the user interface
-		_screenObjects._v8333C = true;
+		_screenObjects._forceRescan = true;
 		_screenObjects._inputMode = kInputBuildingSentences;
 		_scene._userInterface._scrollerY = 0;
 		
diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
index fec1f6e..24ff172 100644
--- a/engines/mads/hotspots.cpp
+++ b/engines/mads/hotspots.cpp
@@ -135,7 +135,7 @@ void DynamicHotspots::refresh() {
 			case kInputBuildingSentences:
 			case kInputLimitedSentences:
 				scrObjects.add(dh._bounds, _vm->_game->_scene._layer, CAT_12, dh._descId);
-				scrObjects._v8333C = true;
+				scrObjects._forceRescan = true;
 				break;
 			default:
 				break;
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index f03f891..25623bc 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -252,7 +252,7 @@ ScreenObject::ScreenObject() {
 
 ScreenObjects::ScreenObjects(MADSEngine *vm) : _vm(vm) {
 	_objectY = -1;
-	_v8333C = false;
+	_forceRescan = false;
 	_inputMode = kInputBuildingSentences;
 	_v7FED6 = 0;
 	_v8332A = 0;
@@ -289,7 +289,7 @@ void ScreenObjects::check(bool scanFlag) {
 		_vm->_events->_rightMousePressed = false;
 
 	if ((_vm->_events->_mouseMoved || _vm->_game->_scene._userInterface._scrollerY 
-			|| _v8332A || _v8333C) && scanFlag) {
+			|| _v8332A || _forceRescan) && scanFlag) {
 		_category = CAT_NONE;
 		_selectedObject = scanBackwards(_vm->_events->currentPos(), LAYER_GUI);
 		if (_selectedObject > 0) {
@@ -320,7 +320,7 @@ void ScreenObjects::check(bool scanFlag) {
 			}
 		}
 
-		if (_vm->_events->_mouseButtons || (_vm->_easyMouse && scene._action._interAwaiting > 1
+		if (_vm->_events->_mouseButtons || (_vm->_easyMouse && scene._action._interAwaiting > AWAITING_COMMAND
 			&& scene._userInterface._category == CAT_INV_LIST) ||
 			(_vm->_easyMouse && scene._userInterface._category == CAT_HOTSPOT)) {
 			scene._action.checkActionAtMousePos();
@@ -337,7 +337,7 @@ void ScreenObjects::check(bool scanFlag) {
 		if (_vm->_events->_mouseButtons || _vm->_easyMouse)
 			scene._action.set();
 
-		_v8333C = 0;
+		_forceRescan = 0;
 	}
 
 	scene._action.refresh();
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index 3595907..ed3de80 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -157,7 +157,7 @@ public:
 	InputMode _inputMode;
 	int _v7FED6;
 	int _v8332A;
-	int _v8333C;
+	int _forceRescan;
 	int _selectedObject;
 	ScrCategory _category;
 	int _newDescId;


Commit: ff7d2e2dbf60202cc24b26b1ac61c0e76e802191
    https://github.com/scummvm/scummvm/commit/ff7d2e2dbf60202cc24b26b1ac61c0e76e802191
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-05T22:41:25-04:00

Commit Message:
MADS: Add missing scene codes variant handling

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 3a6e6a6..0538f1b 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -90,10 +90,10 @@ Common::String NebularScene::formAnimName(char sepChar, int suffixNum) {
 
 /*------------------------------------------------------------------------*/
 
-void SceneInfoNebular::loadCodes(MSurface &depthSurface) {
+void SceneInfoNebular::loadCodes(MSurface &depthSurface, int variant) {
 	File f(Resources::formatName(RESPREFIX_RM, _sceneId, ".DAT"));
 	MadsPack codesPack(&f);
-	Common::SeekableReadStream *stream = codesPack.getItemStream(0);
+	Common::SeekableReadStream *stream = codesPack.getItemStream(variant + 1);
 
 	loadCodes(depthSurface, stream);
 
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 895ee51..8e5bc05 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -131,7 +131,7 @@ public:
 class SceneInfoNebular : public SceneInfo {
 	friend class SceneInfo;
 protected:
-	virtual void loadCodes(MSurface &depthSurface);
+	virtual void loadCodes(MSurface &depthSurface, int variant);
 
 	virtual void loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream);
 
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index f7a2a60..2a9b3c6 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -266,7 +266,7 @@ void Scene103::actions() {
 	} else if (_action.isAction(VERB_TAKE, 371) && _game._objects.isInRoom(OBJ_TIMER_MODULE)) {
 		switch (_vm->_game->_trigger) {
 		case 0:
-			_scene->changeDepthSurface(1);
+			_scene->changeVariant(1);
 			_globals._spriteIndexes[28] = _scene->_sequences.startReverseCycle(
 				_globals._spriteIndexes[13], false, 3, 2);
 			_scene->_sequences.setMsgLayout(_globals._spriteIndexes[28]);
@@ -284,7 +284,7 @@ void Scene103::actions() {
 		case 2:
 			_vm->_sound->command(22);
 			_game._objects.addToInventory(OBJ_TIMER_MODULE);
-			_scene->changeDepthSurface(0);
+			_scene->changeVariant(0);
 			_scene->drawElements(kTransitionNone, false);
 			_scene->_hotspots.activate(371, false);
 			_vm->_game->_player._visible = true;
@@ -298,7 +298,7 @@ void Scene103::actions() {
 	} else if (_action.isAction(VERB_TAKE, 289, 0) && _game._objects.isInRoom(OBJ_REBREATHER)) {
 		switch (_vm->_game->_trigger) {
 		case 0:
-			_scene->changeDepthSurface(1);
+			_scene->changeVariant(1);
 			_globals._spriteIndexes[27] = _scene->_sequences.startReverseCycle(
 				_globals._spriteIndexes[12], false, 3, 2);
 			_scene->_sequences.setMsgLayout(_globals._spriteIndexes[27]);
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 0bf5c21..9e4edc0 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -381,7 +381,7 @@ void Scene202::enter() {
 	}
 
 	if (_globals[kBone202Status])
-		_scene->changeDepthSurface(_globals[kBone202Status]);
+		_scene->changeVariant(_globals[kBone202Status]);
 
 	if (_scene->_priorSceneId == 201) {
 		_game._player._playerPos = Common::Point(190, 91);
@@ -789,7 +789,7 @@ void Scene202::actions() {
 						_game._objects.addToInventory(OBJ_BONE);
 						_vm->_dialogs->showPicture(OBJ_BONE, 0x4EFA, 0);
 					}
-					_scene->changeDepthSurface(_globals[kBone202Status]);
+					_scene->changeVariant(_globals[kBone202Status]);
 					_game._player._stepEnabled = true;
 					_game._player._visible = true;
 				} else {
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 1400774..9ef7d0b 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -114,7 +114,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	_priorSceneId = _currentSceneId;
 	_currentSceneId = sceneId;
 
-	_v1 = 0;
+	_variant = 0;
 	if (palFlag)
 		_vm->_palette->resetGamePalette(18, 10);
 
@@ -124,7 +124,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 
 	// TODO: palletteUsage reset?  setPalette(_nullPalette);
 	_sceneInfo = SceneInfo::init(_vm);
-	_sceneInfo->load(_currentSceneId, _v1, Common::String(), _vm->_game->_v2 ? 17 : 16,
+	_sceneInfo->load(_currentSceneId, _variant, Common::String(), _vm->_game->_v2 ? 17 : 16,
 		_depthSurface, _backgroundSurface);
 
 	// Initialise palette animation for the scene
@@ -570,9 +570,9 @@ void Scene::free() {
 	_sceneInfo = nullptr;
 }
 
-void Scene::changeDepthSurface(int arg1) {
-	_v1 = arg1;
-	_sceneInfo->loadCodes(_depthSurface, nullptr);
+void Scene::changeVariant(int variant) {
+	_variant = variant;
+	_sceneInfo->loadCodes(_depthSurface, variant);
 	_spriteSlots.fullRefresh();
 }
 
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 4e3829b..dbb2188 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -98,7 +98,7 @@ public:
 	int _textSpacing;
 	Hotspots _hotspots;
 	DirtyAreas _dirtyAreas;
-	int _v1;
+	int _variant;
 	SceneInfo *_sceneInfo;
 	MSurface _backgroundSurface;
 	DepthSurface _depthSurface;
@@ -206,7 +206,10 @@ public:
 	 */
 	void free();
 
-	void changeDepthSurface(int arg1);
+	/**
+	 * Set the walk surface for a scene to a different variant
+	 */
+	void changeVariant(int variant);
 
 	void resetScene();
 
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 4c19202..f92ff86 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -98,7 +98,7 @@ SceneInfo *SceneInfo::init(MADSEngine *vm) {
 	}
 }
 
-void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
+void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 		int flags, MSurface &depthSurface, MSurface &bgSurface) {
 	bool sceneFlag = sceneId >= 0;
 	
@@ -180,7 +180,7 @@ void SceneInfo::load(int sceneId, int v1, const Common::String &resName,
 	}
 
 	// Load the depth surface with the scene codes
-	Common::SeekableReadStream *depthStream = infoPack.getItemStream(1);
+	Common::SeekableReadStream *depthStream = infoPack.getItemStream(variant + 1);
 	loadCodes(depthSurface, depthStream);
 	delete depthStream;
 
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 81c24ed..2a6032a 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -137,11 +137,6 @@ protected:
 	 * Constructor
 	 */
 	SceneInfo(MADSEngine *vm) : _vm(vm) {}
-	
-	/**
-	 * Loads the given surface with depth information of a given scene
-	 */
-	virtual void loadCodes(MSurface &depthSurface) = 0;
 public:
 	int _sceneId;
 	int _artFileNum;
@@ -173,11 +168,20 @@ public:
 	/**
 	 loads the data
 	 */
-	void load(int sceneId, int flags, const Common::String &resName, int v3, 
+	void load(int sceneId, int variant, const Common::String &resName, int flags, 
 		MSurface &depthSurface, MSurface &bgSurface);
 
 	/**
 	* Loads the given surface with depth information of a given scene
+	* @param depthSurface	Depth/walk surface
+	* @param variant		Variant number to load
+	*/
+	virtual void loadCodes(MSurface &depthSurface, int variant) = 0;
+
+	/**
+	* Loads the given surface with depth information of a given scene
+	* @param depthSurface	Depth/walk surface
+	* @param stream			Stream to load the data from
 	*/
 	virtual void loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream) = 0;
 };


Commit: 962d41e8ca6c0495209ffc1832c59606428d3a35
    https://github.com/scummvm/scummvm/commit/962d41e8ca6c0495209ffc1832c59606428d3a35
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-05T23:24:38-04:00

Commit Message:
MADS: Fix calculating player depth in the scene

Changed paths:
    engines/mads/player.cpp



diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 3eb6b11..b337f8a 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -263,7 +263,7 @@ void Player::update() {
 			scene._spriteSlots[slotIndex]._flags = IMG_ERASE;
 
 		int newDepth = 1;
-		int yp = MAX(_playerPos.y, (int16)(MADS_SCENE_HEIGHT - 1));
+		int yp = MIN(_playerPos.y, (int16)(MADS_SCENE_HEIGHT - 1));
 		
 		for (int idx = 1; idx < 15; ++idx) {
 			if (scene._sceneInfo->_depthList[newDepth] >= yp)


Commit: a2871fb1b0eb96755404f584e94e267d8a629263
    https://github.com/scummvm/scummvm/commit/a2871fb1b0eb96755404f584e94e267d8a629263
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-06T00:24:42-04:00

Commit Message:
MADS: Fix display of scene inventory items

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 2a9b3c6..775f814 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -155,14 +155,14 @@ void Scene103::enter() {
 	_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6);
 
 	if (_game._objects.isInRoom(OBJ_TIMER_MODULE))
-		_vm->_game->_scene._hotspots.activate(371, false);
-	else
 		_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 6);
+	else
+		_vm->_game->_scene._hotspots.activate(371, false);
 
 	if (_game._objects.isInRoom(OBJ_REBREATHER))
-		_vm->_game->_scene._hotspots.activate(289, false);
-	else
 		_globals._spriteIndexes[25] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[10], false, 6);
+	else
+		_vm->_game->_scene._hotspots.activate(289, false);
 	
 	if (_globals[kTurkeyExploded]) {
 		_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6);


Commit: 0c55beb40ca9f0254c4228e26ae8152fca78957f
    https://github.com/scummvm/scummvm/commit/0c55beb40ca9f0254c4228e26ae8152fca78957f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-06T15:20:48-04:00

Commit Message:
MADS: In progress doObjectScene implementation

Changed paths:
    engines/mads/nebular/game_nebular.cpp



diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 638432a..bc61fa4 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -29,6 +29,7 @@
 #include "mads/nebular/game_nebular.h"
 #include "mads/nebular/dialogs_nebular.h"
 #include "mads/nebular/globals_nebular.h"
+#include "mads/nebular/nebular_scenes.h"
 
 namespace MADS {
 
@@ -277,7 +278,149 @@ void GameNebular::checkShowDialog() {
 }
 
 void GameNebular::doObjectAction() {
-	warning("TODO: GameNebular::doObjectAction");
+	Scene &scene = _scene;
+	MADSAction &action = _scene._action;
+	Dialogs &dialogs = *_vm->_dialogs;
+	int id;
+
+	if (action.isAction(NOUN_SMELL) && scene._currentSceneId > 103 && scene._currentSceneId < 111) {
+		dialogs.show(440);
+	} else if (action.isAction(NOUN_EAT) && scene._currentSceneId > 103 && scene._currentSceneId < 111) {
+		dialogs.show(441);
+	} else if (action.isAction(NOUN_SMELL, NOUN_BURGER)) {
+		dialogs.show(442);
+	} else if (action.isAction(NOUN_EAT, NOUN_BURGER)) {
+		dialogs.show(443);
+	} else if (action.isAction(NOUN_SMELL, NOUN_STUFFED_FISH)) {
+		dialogs.show(444);
+	} else if (action.isAction(NOUN_EAT, NOUN_STUFFED_FISH)) {
+		dialogs.show(445);
+	} else if (action.isAction(401, 289)) {
+		dialogs.show(scene._currentSceneId > 103 && scene._currentSceneId < 111 ? 447 : 446);
+	} else if (action.isAction(306, 371)) {
+		dialogs.show(448);
+	} else if (action.isAction(951, 35)) {
+		dialogs.show(449);
+	} else if (action.isAction(203, 276)) {
+		dialogs.show(450);
+	} else if (action.isAction(NOUN_EAT, 378)) {
+		_objects.setRoom(OBJ_TWINKIFRUIT, PLAYER_INVENTORY);
+		dialogs.show(451);
+	} else if (action.isAction(153, 378)) {
+		_objects.setRoom(OBJ_TWINKIFRUIT, PLAYER_INVENTORY);
+		dialogs.show(452);
+	} else if (action.isAction(152)) {
+		dialogs.show(453);
+	} else if (action.isAction(1187, OBJ_PHONE_CELLS)) {
+		dialogs.show(454);
+	} else if (action.isAction(1188, 92)) {
+		dialogs.show(455);
+	} else if (action.isAction(140, 72)) {
+		dialogs.show(456);
+	} else if (action.isAction(1189, OBJ_VASE)) {
+		dialogs.show(457);
+	} else if (action.isAction(306, 369)) {
+		dialogs.show(458);
+	} else if (action.isAction(1192, 774)) {
+		dialogs.show(459);
+	} else if (action.isAction(1191, 359)) {
+		dialogs.show(460);
+	} else if (action.isAction(1190)) {
+		dialogs.show(461);
+	} else if (action.isAction(934, 277)) {
+		dialogs.show(462);
+	} else if (action.isAction(329, 277)) {
+		dialogs.show(465);
+	} else if (action.isAction(368, 135)) {
+		dialogs.show(463);
+	} else if (action.isAction(25, 135)) {
+		dialogs.show(463);
+	} else if (action.isAction(379)) {
+		dialogs.show(464);
+	} else if (action.isAction(869)) {
+		dialogs.show(466);
+	} 	else if (action.isAction(530, 288)) {
+		dialogs.show(467);
+	} else if (action.isAction(NOUN_EAT, 74)) {
+		dialogs.show(469);
+	} else if (action.isAction(50, 381)) {
+		dialogs.show(471);
+	} else if (action.isAction(307, 950)) {
+		dialogs.show(472);
+	} else if (action.isAction(NOUN_READ, NOUN_LOG)) {
+		dialogs.show(473);
+	} else if (action.isAction(1189, 43)) {
+		dialogs.show(474);
+	} else if (action.isAction(114, 726)) {
+		dialogs.show(475);
+	} else if (action.isAction(114, 727)) {
+		dialogs.show(476);
+	} else if (action.isAction(114, 937)) {
+		dialogs.show(477);
+	} else if (action.isAction(VERB_PUT, 276, NOUN_PLANT_STALK) && _objects.isInRoom(OBJ_POISON_DARTS)
+			&& _objects.isInRoom(OBJ_PLANT_STALK)) {
+		_objects.addToInventory(OBJ_BLOWGUN);
+		_objects.setRoom(OBJ_PLANT_STALK, PLAYER_INVENTORY);
+		_globals[kBlowgunStatus] = 0;
+		dialogs.showPicture(OBJ_BLOWGUN, 809);
+	} else if (action.isAction(VERB_PUT, 276, NOUN_BLOWGUN) && _objects.isInInventory(OBJ_POISON_DARTS)
+			&& _objects.isInInventory(OBJ_BLOWGUN)) {
+		dialogs.show(433);
+	} else if (action.isAction(1161) && action.isAction(1195) && action.isAction(1197)) {
+		dialogs.show(434);
+	} else if (action.isAction(1196)) {
+		dialogs.show(479);
+	} else if ((action.isAction(287) || action.isAction(NOUN_LOOK_AT) || action.isAction(VERB_LOOK)) &&
+			action.isAction(936) && _objects.isInInventory(OBJ_NOTE)) {
+		_objects.setRoom(OBJ_NOTE, PLAYER_INVENTORY);
+		_objects.addToInventory(OBJ_COMBINATION);
+		dialogs.showPicture(OBJ_COMBINATION, 851);
+	} else if ((action.isAction(VERB_LOOK) || action.isAction(NOUN_READ)) &&
+			((id = _objects.getIdFromDesc(action._activeAction._objectNameId)) != 0 ||
+			(action._activeAction._indirectObjectId > 0 &&
+			(id = _objects.getIdFromDesc(action._activeAction._indirectObjectId))))) {
+		if (id == 21) {
+			dialogs._indexList[0] = _globals[kTeleporterCode + 7];
+			dialogs._indexList[1] = _globals[kTeleporterCode + 8];
+			dialogs._indexList[2] = _globals[kTeleporterCode + 6];
+			dialogs._indexList[3] = _globals[kTeleporterCode + 9];
+			dialogs._indexList[4] = _globals[kTeleporterCode + 0];
+			dialogs._indexList[5] = _globals[kTeleporterCode + 1];
+			dialogs._indexList[6] = _globals[kTeleporterCode + 4];
+			dialogs._indexList[7] = _globals[kTeleporterCode + 5];
+			dialogs._indexList[8] = _globals[kTeleporterCode + 2];
+
+			dialogs.showPicture(id, 402);
+		} else {
+			error("TODO: Implement. See loc_29B48");
+		}
+	} else if (action.isAction(VERB_PUT, NOUN_BURGER, NOUN_DEAD_FISH)) {
+		if (_objects.isInInventory(OBJ_BURGER) || _objects.isInInventory(OBJ_DEAD_FISH)) {
+			_objects.removeFromInventory(OBJ_DEAD_FISH, PLAYER_INVENTORY);
+			_objects.removeFromInventory(OBJ_BURGER, PLAYER_INVENTORY);
+			_objects.addToInventory(OBJ_STUFFED_FISH);
+			dialogs.showPicture(OBJ_STUFFED_FISH, 803);
+		}
+	} else if (action.isAction(VERB_PUT, 26, 357) && _objects.isInInventory(OBJ_AUDIO_TAPE) &&
+			_objects.isInInventory(OBJ_TAPE_PLAYER)) {
+		_objects.setRoom(OBJ_AUDIO_TAPE, 25);
+	} else if (action.isAction(118, 357) && _objects.isInInventory(OBJ_TAPE_PLAYER)) {
+		if (_objects[OBJ_AUDIO_TAPE]._roomNumber == 25) {
+			_objects.addToInventory(OBJ_AUDIO_TAPE);
+		} else {
+			dialogs.show(407);
+		}
+	} else if (action.isAction(108, 357)) {
+		dialogs.show(408);
+	} else if (action.isAction(14, 291)) {
+		dialogs.show(_globals[kTopButtonPushed] ? 502 : 501);
+	} else if ((action.isAction(25, 106, 72) || action.isAction(VERB_PUT, 106, 72)) &&
+			_objects.isInInventory(OBJ_DETONATORS) && _objects.isInInventory(OBJ_CHARGE_CASES)) {
+		error("TODO: loc_29DBA");
+	} else if (action.isAction(25, 106)) {
+		dialogs.show(470);
+	}
+		
 }
 
 void GameNebular::step() {


Commit: 783f9a0b6ee002512cf8c6d03c4db46bbfc92d8c
    https://github.com/scummvm/scummvm/commit/783f9a0b6ee002512cf8c6d03c4db46bbfc92d8c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-06T16:12:24-04:00

Commit Message:
MADS: Completed doObjectScene implementation

Changed paths:
    engines/mads/nebular/game_nebular.cpp



diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index bc61fa4..6994e54 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -419,8 +419,132 @@ void GameNebular::doObjectAction() {
 		error("TODO: loc_29DBA");
 	} else if (action.isAction(25, 106)) {
 		dialogs.show(470);
+	} else if ((action.isAction(25, 371, 43) || action.isAction(7, 371, 43) || action.isAction(25, 371, 42)
+			|| action.isAction(VERB_PUT, 371, 42)) && _objects.isInInventory(OBJ_TIMER_MODULE) && (
+			_objects.isInInventory(OBJ_BOMBS) || _objects.isInInventory(OBJ_BOMB))) {
+		if (_objects.isInInventory(OBJ_BOMBS)) {
+			_objects.setRoom(OBJ_BOMBS, PLAYER_INVENTORY);
+			_objects.addToInventory(OBJ_BOMB);
+		} else {
+			_objects.setRoom(OBJ_BOMB, PLAYER_INVENTORY);
+		}
+
+		_objects.setRoom(OBJ_TIMER_MODULE, PLAYER_INVENTORY);
+		_objects.addToInventory(OBJ_TIMEBOMB);
+		dialogs.showPicture(OBJ_TIMEBOMB, 404);
+	} else if (action.isAction(140, 271)) {
+		dialogs.show(410);
+	} else if (action.isAction(119, 46)) {
+		_globals[kBottleStatus] = 0;
+		dialogs.show(432);
+	} else if (action.isAction(108, 136)) {
+		if (_objects[OBJ_FISHING_LINE]._roomNumber == 3) {
+			_objects.addToInventory(OBJ_FISHING_LINE);
+			dialogs.showPicture(OBJ_FISHING_LINE, 409);
+		} else {
+			dialogs.show(428);
+		}
+	} else if (action.isAction(108, 262)) {
+		switch (_globals[kPenlightCellStatus]) {
+		case 1:
+		case 2:
+			_objects.addToInventory(OBJ_DURAFAIL_CELLS);
+			dialogs.showPicture(OBJ_DURAFAIL_CELLS, 412);
+			break;
+		case 3:
+			_objects.addToInventory(OBJ_PHONE_CELLS);
+			dialogs.showPicture(OBJ_DURAFAIL_CELLS, 413);
+			break;
+		case 5:
+			_objects.addToInventory(OBJ_DURAFAIL_CELLS);
+			dialogs.showPicture(OBJ_DURAFAIL_CELLS, 411);
+			break;
+		case 6:
+			_objects.addToInventory(OBJ_DURAFAIL_CELLS);
+			dialogs.showPicture(OBJ_DURAFAIL_CELLS, 429);
+			break;
+		default:
+			dialogs.show(478);
+			break;
+		}
+	} else if (action.isAction(108, 264)) {
+		switch (_globals[kHandsetCellStatus]) {
+		case 1:
+			_objects.addToInventory(OBJ_DURAFAIL_CELLS);
+			dialogs.showPicture(OBJ_DURAFAIL_CELLS,
+				_difficulty != 1 || _globals[kDurafailRecharged] ? 415 : 414);
+			break;
+		case 2:
+			_objects.addToInventory(OBJ_DURAFAIL_CELLS);
+			if (_difficulty == 1) {
+				dialogs.showPicture(OBJ_DURAFAIL_CELLS, 416);
+			} else {
+				_globals[kHandsetCellStatus] = 0;
+			}
+			break;
+		case 3:
+			_objects.addToInventory(OBJ_PHONE_CELLS);
+			dialogs.showPicture(OBJ_PHONE_CELLS, 418);
+			break;
+		case 4:
+			_objects.addToInventory(OBJ_PHONE_CELLS);
+			dialogs.showPicture(OBJ_PHONE_CELLS, 417);
+			break;
+		default:
+			dialogs.show(478);
+			break;
+		}
+	} else if (action.isAction(VERB_PUT, 263, 262)) {
+		if (_globals[kPenlightCellStatus] == 0) {
+			_globals[kPenlightCellStatus] = 3;
+			_objects.setRoom(OBJ_PHONE_CELLS, PLAYER_INVENTORY);
+			dialogs.show(419);
+		} else {
+			dialogs.show(420);
+		}
+	} else if (action.isAction(VERB_PUT, 263, 264)) {
+		if (_globals[kHandsetCellStatus] == 0) {
+			_globals[kHandsetCellStatus] = 3;
+			_objects.setRoom(OBJ_PHONE_CELLS, PLAYER_INVENTORY);
+			dialogs.show(421);
+		}
+		else {
+			dialogs.show(422);
+		}
+	} else if (action.isAction(VERB_PUT, 115, 262)) {
+		if (_globals[kPenlightCellStatus]) {
+			dialogs.show(424);
+		} else {
+			_objects.setRoom(OBJ_DURAFAIL_CELLS, PLAYER_INVENTORY);
+			_globals[kPenlightCellStatus] = _difficulty != 1 || _globals[kDurafailRecharged] ? 1 : 2;
+			dialogs.show(423);
+		}
+	} else if (action.isAction(VERB_PUT, 115, 264)) {
+		if (_globals[kHandsetCellStatus]) {
+			dialogs.show(424);
+		} else {
+			_objects.setRoom(OBJ_DURAFAIL_CELLS, PLAYER_INVENTORY);
+			_globals[kDurafailRecharged] = _difficulty != 1 || _globals[kHandsetCellStatus] ? 1 : 2;
+			dialogs.show(425);
+		}
+	} else if (action.isAction(306, 369)) {
+		dialogs.show(427);
+	} else if (action.isAction(VERB_PUT, 42, 73) || action.isAction(VERB_PUT, 43, 73)) {
+		_objects.setRoom(OBJ_CHICKEN, PLAYER_INVENTORY);
+		if (_objects.isInInventory(OBJ_BOMBS)) {
+			_objects.setRoom(OBJ_BOMBS, PLAYER_INVENTORY);
+			_objects.addToInventory(OBJ_BOMB);
+		} else {
+			_objects.setRoom(OBJ_BOMB, PLAYER_INVENTORY);
+		}
+
+		_objects.addToInventory(OBJ_CHICKEN_BOMB);
+		dialogs.showPicture(OBJ_CHICKEN_BOMB, 430);
+	} else {
+		return;
 	}
-		
+
+	action._inProgress = false;
 }
 
 void GameNebular::step() {


Commit: 29789847a86a83cff14a57b12479229ce6ba7ac9
    https://github.com/scummvm/scummvm/commit/29789847a86a83cff14a57b12479229ce6ba7ac9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-06T16:32:18-04:00

Commit Message:
MADS: More implementation for looking at inventory items

Changed paths:
    engines/mads/inventory.cpp
    engines/mads/nebular/game_nebular.cpp



diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index ec5670b..89ca9f8 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -167,9 +167,14 @@ void InventoryObjects::removeFromInventory(int objectId, int newScene) {
 	}
 }
 
-int InventoryObjects::getIdFromDesc(int objectId) {
-	warning("TODO: InventoryObjects::getIdFromDesc()");
-	return objectId;
+int InventoryObjects::getIdFromDesc(int descId) {
+	for (int i = 0; i < (int)size(); ++i) {
+		InventoryObject &obj = (*this)[i];
+		if (obj._descId == descId)
+			return i;
+	}
+
+	return -1;
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 6994e54..69c896a 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -379,7 +379,7 @@ void GameNebular::doObjectAction() {
 			((id = _objects.getIdFromDesc(action._activeAction._objectNameId)) != 0 ||
 			(action._activeAction._indirectObjectId > 0 &&
 			(id = _objects.getIdFromDesc(action._activeAction._indirectObjectId))))) {
-		if (id == 21) {
+		if (id == OBJ_REPAIR_LIST) {
 			dialogs._indexList[0] = _globals[kTeleporterCode + 7];
 			dialogs._indexList[1] = _globals[kTeleporterCode + 8];
 			dialogs._indexList[2] = _globals[kTeleporterCode + 6];
@@ -392,7 +392,25 @@ void GameNebular::doObjectAction() {
 
 			dialogs.showPicture(id, 402);
 		} else {
-			error("TODO: Implement. See loc_29B48");
+			int messageId = 800 + id;
+			if (id == OBJ_CHARGE_CASES) {
+				error("TODO: object_get_folder - loc_29B48");
+				messageId = 860;
+			}
+			
+			if (id == OBJ_TAPE_PLAYER && _objects[OBJ_AUDIO_TAPE]._roomNumber == OBJ_TAPE_PLAYER)
+				messageId = 867;
+
+			if (id == 32 && _objects[OBJ_FISHING_LINE]._roomNumber == 3)
+				messageId = 862;
+
+			if (id == OBJ_BOTTLE && _globals[kBottleStatus] != 0)
+				messageId = 862 + _globals[kBottleStatus];
+
+			if (id == OBJ_PHONE_HANDSET && _globals[kHandsetCellStatus])
+				messageId = 861;
+
+			dialogs.showPicture(id, messageId);
 		}
 	} else if (action.isAction(VERB_PUT, NOUN_BURGER, NOUN_DEAD_FISH)) {
 		if (_objects.isInInventory(OBJ_BURGER) || _objects.isInInventory(OBJ_DEAD_FISH)) {


Commit: 166a549cd594ada54d58882732ce7d3369e67c54
    https://github.com/scummvm/scummvm/commit/166a549cd594ada54d58882732ce7d3369e67c54
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-06T16:41:24-04:00

Commit Message:
MADS: Temporarily hook showPicture method to use standard show method

Changed paths:
    engines/mads/nebular/dialogs_nebular.h



diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index 84bbaed..e123efd 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -51,6 +51,7 @@ public:
 		warning("TODO: showDialog");
 	}
 	virtual void showPicture(int objId, int msgId, int arg3) {
+		show(msgId);
 		warning("TODO: showPicture");
 	}
 	virtual bool show(int id);


Commit: 4e13e74f2774a182b82abe6aa9400c5098bac4d9
    https://github.com/scummvm/scummvm/commit/4e13e74f2774a182b82abe6aa9400c5098bac4d9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-06T17:50:07-04:00

Commit Message:
MADS: Fix to correctly wrap lines in text dialogs

Changed paths:
    engines/mads/dialogs.cpp



diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index d5e8ad5..2301541 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -232,7 +232,7 @@ void TextDialog::wordWrap(const Common::String &line) {
 
 void TextDialog::appendLine(const Common::String &line) {
 	_currentX += line.size();
-	_lineWidth += _font->getWidth(line, 1);
+	_lineWidth += _font->getWidth(line, 1) + 1;
 	_lines[_numLines] += line;
 }
 


Commit: bd11534499ef169700b0ddb450cc93cff434be6b
    https://github.com/scummvm/scummvm/commit/bd11534499ef169700b0ddb450cc93cff434be6b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-06T17:50:56-04:00

Commit Message:
MADS: Fix incorrect look description in scene 103

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 775f814..f56f5d3 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -289,7 +289,7 @@ void Scene103::actions() {
 			_scene->_hotspots.activate(371, false);
 			_vm->_game->_player._visible = true;
 			_vm->_game->_player._stepEnabled = true;
-			_vm->_dialogs->showPicture(OBJ_REBREATHER, 804);
+			_vm->_dialogs->showPicture(OBJ_REBREATHER, 805);
 			break;
 
 		default:


Commit: 2457905ed42820d27264a4beccc9ae45da746c18
    https://github.com/scummvm/scummvm/commit/2457905ed42820d27264a4beccc9ae45da746c18
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-06T21:24:35-04:00

Commit Message:
MADS: Fixes for switching between scenes

Changed paths:
    engines/mads/game.cpp
    engines/mads/player.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/sprites.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index d964c14..90ea105 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -143,6 +143,8 @@ void Game::gameLoop() {
 		}
 
 		_player.releasePlayerSprites();
+		assert(_scene._sprites.size() == 0);
+
 		_vm->_palette->unlock();
 		_vm->_events->waitCursor();
 		_vm->_events->freeCursors();
@@ -271,7 +273,8 @@ void Game::sectionLoop() {
 
 		_scene._reloadSceneFlag = false;
 
-		warning("TODO: sub_1DD8C, sub_1DD7E");
+		_scene._userInterface.noInventoryAnim();
+		_scene.removeSprites();
 
 		if (!_player._loadedFirst) {
 			_player._spritesLoaded = false;
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index b337f8a..10d8b3e 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -675,6 +675,9 @@ void Player::releasePlayerSprites() {
 			scene._sprites.remove(spriteEnd);
 		} while (--spriteEnd >= _spritesStart);
 	}
+
+	_spritesLoaded = false;
+	_spritesChanged = true;
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 9ef7d0b..d297cb7 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -389,7 +389,7 @@ void Scene::doFrame() {
 		_animFlag = true;
 	_vm->_game->_fx = kTransitionNone;
 
-	if (_freeAnimationFlag) {
+	if (_freeAnimationFlag && _activeAnimation) {
 		_activeAnimation->free();
 		_activeAnimation = nullptr;
 	}
@@ -570,6 +570,11 @@ void Scene::free() {
 	_sceneInfo = nullptr;
 }
 
+void Scene::removeSprites() {
+	for (int idx = _sprites.size() - 1; idx >= _spritesCount; --idx)
+		_sprites.remove(idx);
+}
+
 void Scene::changeVariant(int variant) {
 	_variant = variant;
 	_sceneInfo->loadCodes(_depthSurface, variant);
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index dbb2188..b0ecf11 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -214,6 +214,12 @@ public:
 	void resetScene();
 
 	void backgroundAnimation();
+
+	/**
+	* Removes all the scene specific sprites fromt the sprites list, 
+	* leaving any player sprites list in place at the start of the list.
+	*/
+	void removeSprites();
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 442125e..0dd640b 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -372,14 +372,18 @@ int SpriteSets::add(SpriteAsset *asset, int idx) {
 
 	if (idx >= (int)size())
 		resize(idx + 1);
-	delete (*this)[idx];
-	(*this)[idx] = asset;
 
+	if ((*this)[idx]) {
+		delete (*this)[idx];
+	} else {
+		++_assetCount;
+	}
+
+	(*this)[idx] = asset;
 	return idx;
 }
 
 int SpriteSets::addSprites(const Common::String &resName, int flags) {
-	++_assetCount;
 	return add(new SpriteAsset(_vm, resName, flags));
 }
 
@@ -394,7 +398,14 @@ void SpriteSets::clear() {
 void SpriteSets::remove(int idx) {
 	if (idx >= 0) {
 		delete (*this)[idx];
-		(*this)[idx] = nullptr;
+
+		if (idx < ((int)size() - 1))
+			(*this)[idx] = nullptr;
+		else {
+			do {
+				remove_at(size() - 1);
+			} while (size() > 0 && (*this)[size() - 1] == nullptr);
+		}
 
 		--_assetCount;
 	}


Commit: b435c76b2578ad0650606ba6ad59f56eeb94ee01
    https://github.com/scummvm/scummvm/commit/b435c76b2578ad0650606ba6ad59f56eeb94ee01
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-06T22:05:18-04:00

Commit Message:
MADS: Fix loading of scene sprite set names

Changed paths:
    engines/mads/animation.cpp



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index f4fee20..f581bf4 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -51,7 +51,7 @@ void AAHeader::load(Common::SeekableReadStream *f) {
 	buffer[FILENAME_SIZE - 1] = '\0';
 	_interfaceFile = Common::String(buffer);
 
-	for (int i = 0; i < 10; ++i) {
+	for (int i = 0; i < _spriteSetsCount; ++i) {
 		f->read(buffer, FILENAME_SIZE);
 		buffer[FILENAME_SIZE - 1] = '\0';
 		_spriteSetNames.push_back(Common::String(buffer));


Commit: 54bcb822fbd4e5d573ae5cd00ce3b813fbc7faa6
    https://github.com/scummvm/scummvm/commit/54bcb822fbd4e5d573ae5cd00ce3b813fbc7faa6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-06T22:28:14-04:00

Commit Message:
MADS: Properly free scene-specific sprite sets when leaving scene

Changed paths:
    engines/mads/animation.cpp



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index f581bf4..769bd39 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -144,7 +144,15 @@ Animation::Animation(MADSEngine *vm, Scene *scene) : _vm(vm), _scene(scene) {
 }
 
 Animation::~Animation() {
-	delete _font;
+	Scene &scene = _vm->_game->_scene;
+
+	if (_header._manualFlag)
+		scene._sprites.remove(_spriteListIndexes[_header._spritesIndex]);
+
+	for (uint idx = 0; idx < _header._spriteSetsCount; ++idx) {
+		if (!_header._manualFlag || _header._spritesIndex != idx)
+			scene._sprites.remove(_spriteListIndexes[idx]);
+	}
 }
 
 void Animation::free() {


Commit: 1c50c69ba69d255e3ba9ed5a88ea0985417b9357
    https://github.com/scummvm/scummvm/commit/1c50c69ba69d255e3ba9ed5a88ea0985417b9357
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-06T23:53:07-04:00

Commit Message:
MADS: Added stubbed Animation::preLoad method

Changed paths:
    engines/mads/animation.cpp
    engines/mads/animation.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 769bd39..b557a59 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -307,6 +307,11 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
 	f.close();
 }
 
+void Animation::preLoad(const Common::String &resName, int level) {
+	// No implementation in ScummVM, since access is fast enough that data
+	// doesn't need to be preloaded
+}
+
 void Animation::startAnimation(int abortTimers) {
 	_messageCtr = 0;
 	_skipLoad = true;
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 63f77d1..8095bec 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -173,6 +173,11 @@ public:
 		int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo);
 
 	/**
+	 * Preload animation data for the scene
+	 */
+	void preLoad(const Common::String &resName, int level);
+
+	/**
 	 * Setups up a loaded animation for playback
 	 */
 	void startAnimation(int abortTimers);


Commit: 66b7419f30eb4fb0f9df899eea664f529cfb84fd
    https://github.com/scummvm/scummvm/commit/66b7419f30eb4fb0f9df899eea664f529cfb84fd
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-07T08:29:27-04:00

Commit Message:
MADS: Remove stubbed methods that were undeed mouse handler calls

Changed paths:
    engines/mads/scene.cpp
    engines/mads/user_interface.cpp



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index d297cb7..f5d1ce6 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -358,8 +358,7 @@ void Scene::doFrame() {
 				_kernelMessages.update();
 			}
 
-			_userInterface._uiSlots.draw(_vm->_game->_fx == 0,
-				_vm->_game->_fx != 0);
+			_userInterface._uiSlots.draw(!_vm->_game->_fx, _vm->_game->_fx);
 
 			// Write any text needed by the interface
 			if (_vm->_game->_fx)
@@ -395,7 +394,7 @@ void Scene::doFrame() {
 	}
 }
 
-void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
+void  Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
 	// Draw any sprites
 	_spriteSlots.drawBackground();
 
@@ -433,7 +432,6 @@ void Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
 		_dirtyAreas.copyToScreen(_vm->_screen._offset);
 	}
 
-	warning("TODO: sub_115A2");
 	_spriteSlots.cleanUp();
 	_textDisplay.cleanUp();
 }
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index d229c39..c371f3d 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -149,7 +149,6 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 		_vm->_screen.setPointer(&userInterface);
 		userInterface.setBounds(Common::Rect(0, scene._interfaceY,
 			MADS_SCREEN_WIDTH - 1, userInterface.h + scene._interfaceY - 1));
-		warning("TODO: sub_111C8 / sub_1146C");
 
 		for (uint idx = 0; idx < size(); ++idx) {
 			DirtyArea &dirtyArea = userInterface._dirtyAreas[idx];
@@ -162,8 +161,6 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 				_vm->_screen.copyRectToScreen(r);
 			}
 		}
-
-		warning("TODO: sub 115A2 / sub111D3");
 	}
 
 	// Post-processing to remove slots no longer needed


Commit: f6a6ea974117cd8401a2caecdba9ef553821d41a
    https://github.com/scummvm/scummvm/commit/f6a6ea974117cd8401a2caecdba9ef553821d41a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-07T08:34:13-04:00

Commit Message:
MADS: Remove stub warning for originald debugger code not to be implemented

Changed paths:
    engines/mads/scene.cpp



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index f5d1ce6..b178de5 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -379,8 +379,8 @@ void Scene::doFrame() {
 				// Mouse position display isn't persistent, so remove it
 				_kernelMessages.remove(mouseTextIndex);
 
-
-			warning("TODO: sub_1DA3E");
+			// Original had a debugger check/call here to allow pausing after
+			// drawing each frame. Not implemented under ScummVM
 		}
 	}
 


Commit: 7e13f488abeb6a7530d591bae880fdb185c8fef1
    https://github.com/scummvm/scummvm/commit/7e13f488abeb6a7530d591bae880fdb185c8fef1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-07T22:37:22-04:00

Commit Message:
MADS: Implement loading logic for UI background animations

Changed paths:
    engines/mads/animation.cpp
    engines/mads/animation.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/palette.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.h
    engines/mads/screen.cpp
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index b557a59..40abdbe 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -108,15 +108,24 @@ void AnimMessage::load(Common::SeekableReadStream *f) {
 	f->skip(2);
 }
 
-void AnimFrameEntry::load(Common::SeekableReadStream *f) {
-	_frameNumber = f->readUint16LE();
-	_seqIndex = f->readByte();
-	_spriteSlot._spritesIndex = f->readByte();
-	_spriteSlot._frameNumber = f->readUint16LE();
-	_spriteSlot._position.x = f->readSint16LE();
-	_spriteSlot._position.y = f->readSint16LE();
-	_spriteSlot._depth = f->readSByte();
-	_spriteSlot._scale = (int8)f->readByte();
+void AnimFrameEntry::load(Common::SeekableReadStream *f, bool uiFlag) {
+	if (uiFlag) {
+		f->skip(2);
+		_seqIndex = f->readByte();
+		_spriteSlot._spritesIndex = f->readByte();
+		_spriteSlot._frameNumber = f->readUint16LE();
+		_spriteSlot._position.x = f->readSint16LE();
+		_spriteSlot._position.y = f->readSint16LE();
+	} else {
+		_frameNumber = f->readUint16LE();
+		_seqIndex = f->readByte();
+		_spriteSlot._spritesIndex = f->readByte();
+		_spriteSlot._frameNumber = f->readUint16LE();
+		_spriteSlot._position.x = f->readSint16LE();
+		_spriteSlot._position.y = f->readSint16LE();
+		_spriteSlot._depth = f->readSByte();
+		_spriteSlot._scale = (int8)f->readByte();
+	}
 }
 
 /*------------------------------------------------------------------------*/
@@ -132,6 +141,22 @@ void AnimMiscEntry::load(Common::SeekableReadStream *f) {
 
 /*------------------------------------------------------------------------*/
 
+void AnimUIEntry::load(Common::SeekableReadStream *f) {
+	_probability = f->readUint16LE();
+	_imageCount = f->readUint16LE();
+	_firstImage = f->readUint16LE();
+	_lastImage = f->readUint16LE();
+	_counter = f->readSint16LE();
+	for (int i = 0; i < ANIM_SPAWN_COUNT; ++i)
+		_spawn[i] = f->readByte();
+	for (int i = 0; i < ANIM_SPAWN_COUNT; ++i)
+		_spawnFrame[i] = f->readUint16LE();
+	_sound = f->readUint16LE() & 0xFF;
+	_soundFrame = f->readUint16LE();
+}
+
+/*------------------------------------------------------------------------*/
+
 Animation *Animation::init(MADSEngine *vm, Scene *scene) {
 	return new Animation(vm, scene);
 }
@@ -149,7 +174,7 @@ Animation::~Animation() {
 	if (_header._manualFlag)
 		scene._sprites.remove(_spriteListIndexes[_header._spritesIndex]);
 
-	for (uint idx = 0; idx < _header._spriteSetsCount; ++idx) {
+	for (int idx = 0; idx < _header._spriteSetsCount; ++idx) {
 		if (!_header._manualFlag || _header._spritesIndex != idx)
 			scene._sprites.remove(_spriteListIndexes[idx]);
 	}
@@ -195,12 +220,12 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
 	delete stream;
 
 	if (_header._animMode == 4)
-		flags |= 0x4000;
+		flags |= PALFLAG_RESERVED;
 
-	if (flags & 0x100) {
+	if (flags & ANIMFLAG_LOAD_BACKGROUND) {
 		loadInterface(interfaceSurface, depthSurface, _header, flags, palAnimData, sceneInfo);
 	}
-	if (flags & 0x200) {
+	if (flags & ANIMFLAG_LOAD_BACKGROUND_ONLY) {
 		// No data
 		_header._messagesCount = 0;
 		_header._frameEntriesCount = 0;
@@ -234,7 +259,7 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
 
 		for (int i = 0; i < _header._frameEntriesCount; i++) {
 			AnimFrameEntry rec;
-			rec.load(frameStream);
+			rec.load(frameStream, flags & ANIMFLAG_LOAD_BACKGROUND);
 			_frameEntries.push_back(rec);
 		}
 
@@ -242,14 +267,23 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
 	}
 	
 	_miscEntries.clear();
+	_uiEntries.clear();
 	if (_header._miscEntriesCount > 0) {
 		// Chunk 4: Misc Data
 		Common::SeekableReadStream *miscStream = madsPack.getItemStream(streamIndex++);
 
-		for (int i = 0; i < _header._miscEntriesCount; ++i) {
-			AnimMiscEntry rec;
-			rec.load(miscStream);
-			_miscEntries.push_back(rec);
+		if (flags & ANIMFLAG_LOAD_BACKGROUND) {
+			for (int i = 0; i < _header._miscEntriesCount; ++i) {
+				AnimUIEntry rec;
+				rec.load(miscStream);
+				_uiEntries.push_back(rec);
+			}
+		} else {
+			for (int i = 0; i < _header._miscEntriesCount; ++i) {
+				AnimMiscEntry rec;
+				rec.load(miscStream);
+				_miscEntries.push_back(rec);
+			}
 		}
 
 		delete miscStream;
@@ -257,7 +291,7 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
 	
 	// If the animation specifies a font, then load it for access
 	delete _font;
-	if (_header._flags & ANIM_CUSTOM_FONT) {
+	if (_header._flags & ANIMFLAG_CUSTOM_FONT) {
 		Common::String fontName = "*" + _header._fontResource;
 		_font = _vm->_font->getFont(fontName.c_str());
 	} else {
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 8095bec..75f14a5 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -33,7 +33,12 @@
 
 namespace MADS {
 
-enum AnimFlag { ANIM_CUSTOM_FONT = 0x20 };
+enum AnimFlag { 
+	ANIMFLAG_DITHER				= 0x0001,	// Dither to 16 colors
+	ANIMFLAG_CUSTOM_FONT		= 0x0020,	// Load ccustom font 
+	ANIMFLAG_LOAD_BACKGROUND	= 0x0100,	// Load background
+	ANIMFLAG_LOAD_BACKGROUND_ONLY = 0x0200	// Load background only
+};
 
 class MADSEngine;
 class Scene;
@@ -63,7 +68,7 @@ public:
 	/**
 	 * Loads data for the record
 	 */
-	void load(Common::SeekableReadStream *f);
+	void load(Common::SeekableReadStream *f, bool uiFlag);
 };
 
 class AnimMiscEntry {
@@ -80,6 +85,26 @@ public:
 	void load(Common::SeekableReadStream *f);
 };
 
+#define ANIM_SPAWN_COUNT 2
+
+class AnimUIEntry {
+public:
+	int _probability;
+	int _imageCount;
+	int _firstImage;
+	int _lastImage;
+	int _counter;
+	int _spawn[ANIM_SPAWN_COUNT];
+	int _spawnFrame[ANIM_SPAWN_COUNT];
+	int _sound;
+	int _soundFrame;
+
+	/**
+	 * Loads the data for the record
+	 */
+	void load(Common::SeekableReadStream *f);
+};
+
 class AAHeader {
 public:
 	int _spriteSetsCount;
@@ -115,7 +140,6 @@ private:
 
 	Common::Array<int> _spriteListIndexes;
 	Common::Array<AnimMessage> _messages;
-	Common::Array<AnimFrameEntry> _frameEntries;
 	Common::Array<AnimMiscEntry> _miscEntries;
 	Common::Array<SpriteAsset *> _spriteSets;
 	Font *_font;
@@ -153,6 +177,8 @@ private:
 protected:
 	Animation(MADSEngine *vm, Scene *scene);
 public:
+	Common::Array<AnimFrameEntry> _frameEntries;
+	Common::Array<AnimUIEntry> _uiEntries;
 	bool _resetFlag;
 
 	static Animation *init(MADSEngine *vm, Scene *scene);
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 90ea105..fd02941 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -52,7 +52,6 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 	_priorSectionNumber = 0;
 	_currentSectionNumber = -1;
 	_kernelMode = KERNEL_GAME_LOAD;
-	_v2 = 0;
 	_quoteEmergency = false;
 	_vocabEmergency = false;
 	_aaName = "*I0.AA";
diff --git a/engines/mads/game.h b/engines/mads/game.h
index f41e7d2..e488009 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -131,7 +131,6 @@ public:
 	VisitedScenes _visitedScenes;
 	Scene _scene;
 	KernelMode _kernelMode;
-	int _v2;
 	int _trigger;
 	ScreenTransition _fx;
 	TriggerMode _triggerMode;
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 68d8579..229d3fc 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -43,6 +43,7 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :
 	_textWindowStill = false;
 	_screenFade = SCREEN_FADE_SMOOTH;
 	_musicFlag = false;
+	_dithering = false;
 
 	_debugger = nullptr;
 	_dialogs = nullptr;
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index cf8046f..4ea0758 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -104,6 +104,7 @@ public:
 	bool _textWindowStill;
 	ScreenFade _screenFade;
 	bool _musicFlag;
+	bool _dithering;
 public:
 	MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc);
 	virtual ~MADSEngine();
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index dd5eaf6..cceef09 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -32,6 +32,19 @@ class MADSEngine;
 
 #define PALETTE_USAGE_COUNT 4
 
+/**
+ * Palette mapping options
+ */
+enum {
+	PALFLAG_BACKGROUND		= 0x8000,  // Loading initial background       
+	PALFLAG_RESERVED		= 0x4000,  // Enable mapping reserved colors 
+	PALFLAG_ANY_TO_CLOSEST	= 0x2000,  // Any color can map to closest     
+	PALFLAG_ALL_TO_CLOSEST	= 0x1000,  // Any colors that can map must map 
+	PALFLAG_TOP_COLORS		= 0x0800,  // Allow mapping to high four colors 
+	PALFLAG_DEFINE_RESERVED	= 0x0400,  // Define initial reserved color    
+	PALFLAG_MASK			= 0xfc00   // Mask for all the palette flags   
+};
+
 struct RGB4 {
 	byte r;
 	byte g;
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index b178de5..ac57e0b 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -123,8 +123,12 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	_kernelMessages.clear();
 
 	// TODO: palletteUsage reset?  setPalette(_nullPalette);
+	int flags = SCENEFLAG_LOAD_SHADOW;
+	if (_vm->_dithering)
+		flags |= SCENEFLAG_DITHER;
+
 	_sceneInfo = SceneInfo::init(_vm);
-	_sceneInfo->load(_currentSceneId, _variant, Common::String(), _vm->_game->_v2 ? 17 : 16,
+	_sceneInfo->load(_currentSceneId, _variant, Common::String(), flags,
 		_depthSurface, _backgroundSurface);
 
 	// Initialise palette animation for the scene
@@ -143,10 +147,12 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	_vm->_palette->_paletteUsage.load(1, 0xF);
 
 	// Load interface
-	int flags = _vm->_game->_v2 ? 0x4101 : 0x4100;
-	if (!_vm->_textWindowStill)
-		flags |= 0x200;
-
+	flags = PALFLAG_RESERVED | ANIMFLAG_LOAD_BACKGROUND;
+	if (_vm->_dithering)
+		flags |= ANIMFLAG_DITHER;
+	if (_vm->_textWindowStill)
+		flags |= ANIMFLAG_LOAD_BACKGROUND_ONLY;
+		
 	_animationData = Animation::init(_vm, this);
 	MSurface depthSurface;
 	_animationData->load(_userInterface, depthSurface, prefix, flags, nullptr, nullptr);
@@ -513,7 +519,7 @@ void Scene::loadAnimation(const Common::String &resName, int abortTimers) {
 
 	_activeAnimation = Animation::init(_vm, this);
 	_activeAnimation->load(interfaceSurface, depthSurface, resName, 
-		_vm->_game->_v2 ? 1 : 0, nullptr, nullptr);
+		_vm->_dithering ? ANIMFLAG_DITHER : 0, nullptr, nullptr);
 	_activeAnimation->startAnimation(abortTimers);
 }
 
@@ -585,8 +591,4 @@ void Scene::resetScene() {
 	_sequences.clear();
 }
 
-void Scene::backgroundAnimation() {
-	warning("TODO: Scene::backgroundAnimation");
-}
-
 } // End of namespace MADS
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index b0ecf11..f449ede 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -213,8 +213,6 @@ public:
 
 	void resetScene();
 
-	void backgroundAnimation();
-
 	/**
 	* Removes all the scene specific sprites fromt the sprites list, 
 	* leaving any player sprites list in place at the start of the list.
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 2a6032a..73ca21d 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -52,6 +52,11 @@ class SpriteSlot;
 #define TEXT_DISPLAY_MAX_SIZE 40
 #define DIRTY_AREAS_SIZE (SPRITE_SLOTS_MAX_SIZE + TEXT_DISPLAY_MAX_SIZE)
 
+enum { 
+	SCENEFLAG_DITHER		= 0x01,     // Dither to 16 colors
+	SCENEFLAG_LOAD_SHADOW	= 0x10		// Load hard shadows
+};
+
 class VerbInit {
 public:
 	int _id;
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 25623bc..683a567 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -354,10 +354,10 @@ void ScreenObjects::check(bool scanFlag) {
 					slot._flags = IMG_ERASE;
 		}
 
-		// Any background animation
-		scene.backgroundAnimation();
+		// Any background animation in the user interface
+		userInterface.doBackgroundAnimation();
 
-		// Handle animating the selected inventory animation
+		// Handle animating the selected inventory item
 		userInterface.inventoryAnim();
 
 		// Set the base time
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index c371f3d..d7f198f 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -48,7 +48,7 @@ void UISlots::add(const Common::Point &pt, int frameNumber, int spritesIndex) {
 	assert(size() < 50);
 
 	UISlot ie;
-	ie._flags = -3;
+	ie._flags = IMG_OVERPRINT;
 	ie._segmentId = IMG_TEXT_UPDATE;
 	ie._position = pt;
 	ie._frameNumber = frameNumber;
@@ -57,6 +57,20 @@ void UISlots::add(const Common::Point &pt, int frameNumber, int spritesIndex) {
 	push_back(ie);
 }
 
+void UISlots::add(const AnimFrameEntry &frameEntry) {
+	assert(size() < 50);
+
+	UISlot ie;
+	ie._flags = IMG_UPDATE;
+	ie._segmentId = frameEntry._seqIndex;
+	ie._spritesIndex = frameEntry._spriteSlot._spritesIndex;
+	ie._frameNumber = frameEntry._frameNumber;
+	ie._position = frameEntry._spriteSlot._position;
+
+	push_back(ie);
+}
+
+
 void UISlots::draw(bool updateFlag, bool delFlag) {
 	Scene &scene = _vm->_game->_scene;
 	UserInterface &userInterface = scene._userInterface;
@@ -633,6 +647,66 @@ void UserInterface::inventoryAnim() {
 	_uiSlots.push_back(slot);
 }
 
+void UserInterface::doBackgroundAnimation() {
+	Scene &scene = _vm->_game->_scene;
+	Common::Array<AnimUIEntry> &uiEntries = scene._animationData->_uiEntries;
+	Common::Array<AnimFrameEntry> &frameEntries = scene._animationData->_frameEntries;
+
+	_noSegmentsActive = !_someSegmentsActive;
+	_someSegmentsActive = false;
+
+	for (int idx = 0; idx < uiEntries.size(); ++idx) {
+		AnimUIEntry &uiEntry = uiEntries[idx];
+
+		if (uiEntry._counter < 0) {
+			if (uiEntry._counter == -1) {
+				int probabilityRandom = _vm->getRandomNumber(1, 30000);
+				int probability = uiEntry._probability;
+				if (uiEntry._probability > 30000) {
+					if (_noSegmentsActive) {
+						probability -= 30000;
+					} else {
+						probability = -1;
+					}
+				}
+				if (probabilityRandom <= probability) {
+					uiEntry._counter = uiEntry._firstImage;
+					_someSegmentsActive = true;
+				}
+			} else {
+				uiEntry._counter = uiEntry._firstImage;
+				_someSegmentsActive = true;
+			}
+		} else {
+			for (int idx2 = 0; idx2 < ANIM_SPAWN_COUNT; idx2++) {
+				if (uiEntry._spawnFrame[idx2] == (uiEntry._counter - uiEntry._firstImage)) {
+					int tempIndex = uiEntry._spawn[idx2];
+					if (idx >= tempIndex) {
+						uiEntries[tempIndex]._counter = uiEntries[tempIndex]._firstImage;
+					} else {
+						uiEntries[tempIndex]._counter = -2;
+					}
+					_someSegmentsActive = true;
+				}
+			}
+
+			++uiEntry._counter;
+			if (uiEntry._counter > uiEntry._lastImage) {
+				uiEntry._counter = -1;
+			} else {
+				_someSegmentsActive = true;
+			}
+		}
+	}
+
+	for (int idx = 0; idx < uiEntries.size(); ++idx) {
+		int imgScan = uiEntries[idx]._counter;
+		if (imgScan >= 0) {
+			_uiSlots.add(frameEntries[imgScan]);
+		}
+	}
+}
+
 void UserInterface::categoryChanged() {
 	_highlightedItemIndex = -1;
 	_vm->_events->initVars();
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 445cd1e..86b5622 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -33,6 +33,8 @@ namespace MADS {
 
 enum { IMG_SPINNING_OBJECT = 200, IMG_TEXT_UPDATE = 201 };
 
+class AnimFrameEntry;
+
 class UISlot {
 public:
 	int _flags;
@@ -62,6 +64,11 @@ public:
 	void add(const Common::Point &pt, int frameNumber, int spritesIndex);
 
 	/**
+	 * Loads the data from an aimation frame entry
+	 */
+	void add(const AnimFrameEntry &frameEntry);
+
+	/**
 	 * Adds a special entry for full refresh of the user interface
 	 */
 	void fullRefresh();
@@ -83,6 +90,8 @@ private:
 	int _invFrameNumber;
 	uint32 _scrollMilli;
 	bool _scrollFlag;
+	int _noSegmentsActive;
+	int _someSegmentsActive;
 
 	/**
 	 * Loads the elements of the user interface
@@ -183,6 +192,11 @@ public:
 	void noInventoryAnim();
 
 	/**
+	 * Handles any animation that occurs in the background of the user interface
+	 */
+	void doBackgroundAnimation();
+
+	/**
 	* Handles queuing a new frame of an inventory animation for drawing
 	*/
 	void inventoryAnim();


Commit: f6cfd1d53b3ac47744c8393c49ecf51a99633fc4
    https://github.com/scummvm/scummvm/commit/f6cfd1d53b3ac47744c8393c49ecf51a99633fc4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-07T23:48:43-04:00

Commit Message:
MADS: Implement missing dirty rect merged area pointer

Changed paths:
    engines/mads/screen.cpp
    engines/mads/screen.h
    engines/mads/user_interface.cpp



diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 683a567..78980fe 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -34,6 +34,7 @@ MADSEngine *DirtyArea::_vm = nullptr;
 DirtyArea::DirtyArea() {
 	_active = false;
 	_textActive = false;
+	_mergedArea = nullptr;
 }
 
 void DirtyArea::setArea(int width, int height, int maxWidth, int maxHeight) {
@@ -206,6 +207,7 @@ void DirtyAreas::mergeAreas(int idx1, int idx2) {
 	da1._bounds2.bottom = da1._bounds.top + (da1._bounds.height() + 1) / 2 - 1;
 
 	da2._active = false;
+	da2._mergedArea = &da1;
 	da1._textActive = true;
 }
 
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index ed3de80..57b53df 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -74,6 +74,7 @@ public:
 	Common::Rect _bounds2;
 	bool _textActive;
 	bool _active;
+	DirtyArea *_mergedArea;
 
 	DirtyArea();
 
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index d7f198f..f51372e 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -134,15 +134,17 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 	userInterface._dirtyAreas.merge(1, userInterface._uiSlots.size());
 
 	for (uint idx = 0; idx < size(); ++idx) {
-		DirtyArea &dirtyArea = userInterface._dirtyAreas[idx];
+		DirtyArea *dirtyArea = &userInterface._dirtyAreas[idx];
 		UISlot &slot = (*this)[idx];
 
 		if (slot._flags >= IMG_STATIC && !(slot._flags & 0x40)) {
-			if (!dirtyArea._active) {
-				error("Should never reach this point, even in original");
+			if (!dirtyArea->_active) {
+				do {
+					dirtyArea = dirtyArea->_mergedArea;
+				} while (!dirtyArea->_active);
 			}
 
-			if (dirtyArea._textActive) {
+			if (dirtyArea->_textActive) {
 				SpriteAsset *asset = scene._sprites[slot._spritesIndex];
 				
 				if (slot._segmentId == IMG_SPINNING_OBJECT) {
@@ -655,7 +657,7 @@ void UserInterface::doBackgroundAnimation() {
 	_noSegmentsActive = !_someSegmentsActive;
 	_someSegmentsActive = false;
 
-	for (int idx = 0; idx < uiEntries.size(); ++idx) {
+	for (int idx = 0; idx < (int)uiEntries.size(); ++idx) {
 		AnimUIEntry &uiEntry = uiEntries[idx];
 
 		if (uiEntry._counter < 0) {
@@ -699,7 +701,7 @@ void UserInterface::doBackgroundAnimation() {
 		}
 	}
 
-	for (int idx = 0; idx < uiEntries.size(); ++idx) {
+	for (uint idx = 0; idx < uiEntries.size(); ++idx) {
 		int imgScan = uiEntries[idx]._counter;
 		if (imgScan >= 0) {
 			_uiSlots.add(frameEntries[imgScan]);


Commit: 0f476c31ef6edccc218286997a221bcf2e94a990
    https://github.com/scummvm/scummvm/commit/0f476c31ef6edccc218286997a221bcf2e94a990
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-08T10:26:43+02:00

Commit Message:
MADS: Implement scene 210, some cleanup of some other 2xx scenes, add some stubs

Changed paths:
    engines/mads/game.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h
    engines/mads/rails.h
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/game.h b/engines/mads/game.h
index e488009..3216da3 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -148,6 +148,7 @@ public:
 
 	uint32 getQuotesSize() { return _quotes.size(); }
 	const Common::String &getQuote(uint32 index) { return _quotes[index - 1]; }
+	void splitQuote(Common::String quote, Common::String part1, Common::String part2) {warning("TODO: splitQuote()");}
 	Common::StringArray getMessage(uint32 id);
 
 	/**
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 9e4edc0..97c6581 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -280,8 +280,7 @@ void Scene201::step() {
 }
 
 void Scene201::actions() {
-	MADSAction *action = _game._player._action;
-	if (action->_lookFlag == false) {
+	if (_action._lookFlag == false) {
 		if (_action.isAction(0x18C, 0x83))
 			_scene->_nextSceneId = 202;
 		else if ((_action.isAction(0x50, 0x156)) || (_action.isAction(0x188, 0x16C)) || (_action.isAction(0x188, 0x1B6))) {
@@ -323,7 +322,7 @@ void Scene201::actions() {
 	} else {
 		_vm->_dialogs->show(0x4E8F);
 	}
-	action->_inProgress = false;
+	_action._inProgress = false;
 }
 
 /*------------------------------------------------------------------------*/
@@ -491,10 +490,9 @@ void Scene202::step() {
 		_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
 
 		if (_globals[kMeteorologistWatch] == 1) {
-			MADSAction *action = _game._player._action;
-			action->_activeAction._verbId = VERB_LOOK;
-			action->_activeAction._objectNameId = 39;
-			action->_activeAction._indirectObjectId = 438;
+			_action._activeAction._verbId = VERB_LOOK;
+			_action._activeAction._objectNameId = 39;
+			_action._activeAction._indirectObjectId = 438;
 			_game._triggerSetupMode = KERNEL_TRIGGER_PARSER;
 			_scene->_sequences.addTimer(120, 2);
 			_globals._abortVal = -1;
@@ -708,7 +706,6 @@ int Scene202::subStep4(int randVal) {
 
 void Scene202::preActions() {
 	Player &player = _vm->_game->_player;
-	MADSAction *action = player._action;
 
 	if (player._readyToWalk)
 		_scene->_kernelMessages.reset();
@@ -732,7 +729,7 @@ void Scene202::preActions() {
 		}
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x27) && (action->_activeAction._indirectObjectId > 0)) {
+	if (_action.isAction(VERB_LOOK, 0x27) && (_action._activeAction._indirectObjectId > 0)) {
 		if (!player._readyToWalk || _ladderTopFl)
 			_game._player._needToWalk = false;
 		else
@@ -744,10 +741,9 @@ void Scene202::preActions() {
 }
 
 void Scene202::actions() {
-	MADSAction *action = _game._player._action;
-	if (action->_lookFlag == false) {
+	if (_action._lookFlag == false) {
 		if (_action.isAction(0x4E, 0xC7)) {
-			action->_inProgress = false;
+			_action._inProgress = false;
 			return;
 		} else if (_action.isAction(0x18C, 0x83)) {
 			_scene->_nextSceneId = 203;
@@ -760,8 +756,9 @@ void Scene202::actions() {
 			}
 			_scene->_nextSceneId = 201;
 		} else if (_action.isAction(VERB_TAKE, 0x2C)) {
-			if (action->_mainObjectSource == 4) {
-				if (_game._trigger == 0) {
+			if (_action._mainObjectSource == 4) {
+				switch (_game._trigger) {
+				case 0:
 					if (_game._objects.isInInventory(OBJ_BONES)) {
 						_vm->_dialogs->show(0x4EFB);
 					} else {
@@ -772,15 +769,17 @@ void Scene202::actions() {
 						_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_FRAME_INDEX, 6, 1);
 						_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 2);
 					}
-				} else if (_game._trigger == 1) {
-					if ((_game._player._playerPos.x == 132) && (_game._player._playerPos.y == 97)) {
+					break;
+				case 1:
+					if (_game._player._playerPos == Common::Point(132,97)) {
 						_scene->_sequences.remove(_globals._spriteIndexes[16]);
 						_globals[kBone202Status] |= 1;
 					} else {
 						_scene->_sequences.remove(_globals._spriteIndexes[21]);
 						_globals[kBone202Status] |= 2;
 					}
-				} else if (_game._trigger == 2) {
+					break;
+				case 2:
 					if (_game._objects.isInInventory(OBJ_BONE)) {
 						_game._objects.removeFromInventory(OBJ_BONE, 1);
 						_game._objects.addToInventory(OBJ_BONES);
@@ -792,13 +791,15 @@ void Scene202::actions() {
 					_scene->changeVariant(_globals[kBone202Status]);
 					_game._player._stepEnabled = true;
 					_game._player._visible = true;
-				} else {
-					action->_inProgress = false;
+					break;
+				default:
+					_action._inProgress = false;
 					return;
 				}
 			}
 		} else if ((_action.isAction(0x50, 0xC7)) && (_globals[kLadderBroken] == 0)) {
-			if (_game._trigger == 0) {
+			switch (_game._trigger) {
+			case 0:
 				_vm->_sound->command(29);
 				_meteoClock1 = _scene->_frameStartTime;
 				_game._player._visible = false;
@@ -809,7 +810,8 @@ void Scene202::actions() {
 				_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
 				_scene->_sequences.setDepth(_globals._spriteIndexes[23], 1);
 				_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 1);
-			} else if (_game._trigger == 1) {
+				break;
+			case 1: {
 				_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
 				_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
 				_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
@@ -818,13 +820,16 @@ void Scene202::actions() {
 				_game._player._stepEnabled = true;
 				int msgIndex = _scene->_kernelMessages.add(Common::Point(248, 15), 0x1110, 32, 0, 60, _game.getQuote(97));
 				_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
-			} else {
-				action->_inProgress = false;
+				}
+				break;
+			default:
+				_action._inProgress = false;
 				return;
 			}
 		} else if (((_action.isAction(VERB_LOOK, 0x27, 0x82)) || (_action.isAction(VERB_LOOK, 0x27, 0x1B6))) && (_globals[kSexOfRex] == SEX_MALE)) {
 			if (!_ladderTopFl) {
-				if (_game._trigger == 0) {
+				switch (_game._trigger) {
+				case 0:
 					_game._player._stepEnabled = false;
 					_game._player._visible= false;
 					_globals._spriteIndexes[25] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
@@ -833,7 +838,8 @@ void Scene202::actions() {
 					_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
 					_scene->_sequences.updateTimeout(-1, _globals._spriteIndexes[25]);
 					_scene->_sequences.addSubEntry(_globals._spriteIndexes[25], SM_0, 0, 1);
-				} else if (_game._trigger == 1) {
+					break;
+				case 1:
 					_globals._spriteIndexes[25] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
 					_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
 					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
@@ -843,7 +849,8 @@ void Scene202::actions() {
 					} else {
 						_scene->_sequences.addTimer(120, 2);
 					}
-				} else if (_game._trigger == 2) {
+					break;
+				case 2:
 					if (!_scene->_activeAnimation && (_globals._abortVal == 0)) {
 						_vm->_dialogs->show(0x4EFE);
 					}
@@ -853,16 +860,19 @@ void Scene202::actions() {
 					_scene->_sequences.setAnimRange(_globals._spriteIndexes[25], 1, 6);
 					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
 					_scene->_sequences.addSubEntry(_globals._spriteIndexes[25], SM_0, 0, 3);
-				} else if (_game._trigger == 3) {
+					break;
+				case 3:
 					_scene->_sequences.updateTimeout(-1, _globals._spriteIndexes[25]);
 					_game._player._stepEnabled = true;
 					_game._player._visible = true;
-				} else {
-					action->_inProgress = false;
+					break;
+				default:
+					_action._inProgress = false;
 					return;
 				}
 			} else {
-				if (_game._trigger == 0) {
+				switch (_game._trigger) {
+				case 0:
 					_toTeleportFl = true;
 					_game._player._stepEnabled = false;
 					_scene->_sequences.remove(_globals._spriteIndexes[24]);
@@ -870,7 +880,8 @@ void Scene202::actions() {
 					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
 					_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
 					_scene->_sequences.addSubEntry(_globals._spriteIndexes[24], SM_0, 0, 1);
-				} else if (_game._trigger == 1) {
+					break;
+				case 1:
 					_globals._spriteIndexes[25] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, -2);
 					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(247, 82));
 					_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
@@ -885,14 +896,15 @@ void Scene202::actions() {
 								int msgIndex = _scene->_kernelMessages.add(Common::Point(248, 15), 0x1110, 32, 0, 60, _game.getQuote(100));
 								_scene->_kernelMessages.setQuoted(msgIndex, 4, false);
 							} else {
-								action->_inProgress = false;
+								_action._inProgress = false;
 								return;
 							}
 						}
 					} else {
 						_scene->_sequences.addTimer(120, 2);
 					}
-				} else if (_game._trigger == 2) {
+					break;
+				case 2:
 					if (!_scene->_activeAnimation)
 						_vm->_dialogs->show(0x4EFE);
 					_globals._abortVal = 0;
@@ -901,13 +913,15 @@ void Scene202::actions() {
 					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
 					_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
 					_scene->_sequences.addSubEntry(_globals._spriteIndexes[24], SM_0, 0, 3);
-				} else if (_game._trigger == 3) {
+					break;
+				case 3:
 					_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
 					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
 					_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
 					_game._player._stepEnabled = true;
-				} else {
-					action->_inProgress = false;
+					break;
+				default:
+					_action._inProgress = false;
 					return;
 				}
 			}
@@ -925,7 +939,7 @@ void Scene202::actions() {
 			} else if (_globals[kMeteorologistStatus] == 1) {
 				_vm->_dialogs->show(0x4EFC);
 			} else {
-				action->_inProgress = false;
+				_action._inProgress = false;
 				return;
 			}
 		} else if (_action.isAction(VERB_LOOK, 0x18E)) {
@@ -952,7 +966,7 @@ void Scene202::actions() {
 		} else if (_action.isAction(VERB_TAKE, 0x140)) {
 			_vm->_dialogs->show(0x4EF8);
 		} else if (_action.isAction(VERB_LOOK, 0x2D)) {
-			if (action->_commandSource == 4)
+			if (_action._commandSource == 4)
 				_vm->_dialogs->show(0x4EF9);
 			else
 				return;
@@ -962,7 +976,7 @@ void Scene202::actions() {
 	} else {
 		_vm->_dialogs->show(0x4EFB);
 	}
-	action->_inProgress = false;
+	_action._inProgress = false;
 }
 
 /*****************************************************************************/
@@ -1127,10 +1141,10 @@ void Scene205::enter() {
 	_globals._frameTime &= 0xFFFF;
 	_game.loadQuoteSet(0x6B, 0x70, 0x71, 0x72, 0x5A, 0x74, 0x75, 0x76, 0x77, 0x78, 0x73, 0x79, 0x7A, 0x7B, 0x7C,
 		0x7D, 0x7E, 0x7F, 0x80, 0xAC, 0xAD, 0xAE, 0x6C, 0x6D, 0x6E, 0x6F, 0x2, 0);
-	warning("TODO: sub71A50(_globals._v4, 0x5A, 0x78, 0x74, 0x75, 0x76, 0x77, 0);");
+	warning("TODO: sub71A50(&dialog1, 0x5A, 0x78, 0x74, 0x75, 0x76, 0x77, 0);");
 
 	if (!_game._visitedScenes._sceneRevisited)
-		warning("TODO: sub71B18(_globals._v4, 0x5A, 0x74, 0x75, 0x77, 0);");
+		warning("TODO: sub71B18(&dialog1, 0x5A, 0x74, 0x75, 0x77, 0);");
 
 
 	_vm->_palette->setEntry(250, 63, 50, 20);
@@ -2310,7 +2324,7 @@ void Scene209::handleMonkeyFall() {
 		_scene->_sequences.remove(_globals._spriteIndexes[18]);
 		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._spriteIndexes[23], 1, 35);
-		_scene->_sequences.setDepth (_globals._spriteIndexes[23], 6);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[23], 6);
 		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
 		_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 220);
 		}
@@ -2325,7 +2339,7 @@ void Scene209::handleMonkeyFall() {
 		_scene->_sequences.remove(_globals._spriteIndexes[18]);
 		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._spriteIndexes[23], 36, 42);
-		_scene->_sequences.setDepth (_globals._spriteIndexes[23], 6);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[23], 6);
 		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
 		_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 221);
 		}
@@ -3269,5 +3283,1053 @@ void Scene209::actions() {
 	}
 }
 
+/*****************************************************************************/
+
+void Scene210::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x70);
+	_scene->addActiveVocab(0x18B);
+}
+
+void Scene210::handleDialogs() {
+	if (_game._trigger == 0) {
+		_scene->_kernelMessages.reset();
+		_game._player._stepEnabled = false;
+		Common::String curQuote = _game.getQuote(_action._activeAction._verbId);
+		if (_vm->_font->getWidth(curQuote, _scene->_textSpacing) > 200) {
+			Common::String subQuote1;
+			_game.splitQuote(curQuote, subQuote1, _subQuote2);
+			_scene->_kernelMessages.add(Common::Point(0, -14), 0x1110, 34, 0, 240, subQuote1);
+			_scene->_sequences.addTimer(60, 50);
+		} else {
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 1, 12, curQuote);
+		}
+	} else if (_game._trigger == 50) {
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 240, _subQuote2);
+		_scene->_sequences.addTimer(180, 1);
+	} else {
+		if (_game._trigger == 1)
+			_scene->_kernelMessages.reset();
+
+		switch (_curDialogNode) {
+		case 1:
+			handleSubDialog1();
+			break;
+
+		case 2:
+			handleSubDialog2();
+			break;
+
+		case 3:
+			handleSubDialog3();
+			break;
+
+		case 5:
+			handleSubDialog5();
+			break;
+
+		case 6:
+			handleSubDialog6();
+			break;
+
+		case 7:
+			handleSubDialog7();
+			break;
+
+		case 8:
+			handleSubDialog8();
+			break;
+		}
+	}
+}
+
+void Scene210::handleSubDialog1() {
+	switch (_action._activeAction._verbId) {
+	case 180:
+		setDialogNode(2);
+		break;
+
+	case 181:
+		setDialogNode(6);
+		break;
+
+	case 182:
+		setDialogNode(4);
+		break;
+
+	case 183:
+		setDialogNode(9);
+		break;
+
+	case 184:
+		setDialogNode(0);
+		break;
+	}
+}
+
+void Scene210::handleSubDialog2() {
+	switch (_action._activeAction._verbId) {
+	case 187:
+		setDialogNode(3);
+		break;
+
+	case 188:
+		setDialogNode(4);
+		break;
+
+	case 189:
+		setDialogNode(0);
+		break;
+	}
+}
+
+void Scene210::handleSubDialog3() {
+	switch (_action._activeAction._verbId) {
+	case 193:
+		setDialogNode(6);
+		break;
+
+	case 194:
+		setDialogNode(5);
+		break;
+
+	case 195:
+		setDialogNode(4);
+		break;
+
+	case 196:
+		setDialogNode(0);
+		break;
+	}
+}
+
+void Scene210::handleSubDialog5() {
+	switch (_action._activeAction._verbId) {
+	case 204:
+		setDialogNode(6);
+		break;
+
+	case 205:
+	case 206:
+		setDialogNode(4);
+		break;
+
+	case 207:
+		setDialogNode(0);
+		break;
+	}
+}
+
+void Scene210::handleSubDialog6() {
+	switch (_action._activeAction._verbId) {
+	case 211:
+		setDialogNode(7);
+		break;
+
+	case 212:
+		setDialogNode(4);
+		break;
+
+	case 213:
+		setDialogNode(0);
+		break;
+	}
+}
+
+void Scene210::handleSubDialog7() {
+	switch (_action._activeAction._verbId) {
+	case 216:
+	case 217:
+	case 219:
+		setDialogNode(4);
+		break;
+
+	case 218:
+		setDialogNode(8);
+		break;
+
+	case 220:
+		setDialogNode(0);
+		break;
+	}
+}
+
+void Scene210::handleSubDialog8() {
+	switch (_action._activeAction._verbId) {
+	case 223:
+	case 224:
+		setDialogNode(4);
+		break;
+
+	case 225:
+	case 226:
+		setDialogNode(9);
+		break;
+
+	case 227:
+		setDialogNode(0);
+		break;
+	}
+}
+
+void Scene210::setDialogNode(int node) {
+	switch (node) {
+	case 0:
+		_scene->_userInterface.setup(kInputBuildingSentences);
+		_shouldFaceRex = false;
+		_shouldTalk = false;
+		_game._player._stepEnabled = true;
+		_curDialogNode = 0;
+		break;
+
+	case 2:
+		switch (_game._trigger) {
+		case 1:
+			_nextHandsPlace = 1;
+			_shouldTalk = true;
+			_game._player._stepEnabled = false;
+			if (_twinklesTalking) {
+				handleTwinklesSpeech(0xB9, -1, 0);
+				_scene->_sequences.addTimer(180, 2);
+			} else {
+				_scene->_sequences.addTimer(6, 1);
+			}
+			break;
+
+		case 2:
+			_nextHandsPlace = 0;
+			handleTwinklesSpeech(186, 0, 0);
+			_scene->_sequences.addTimer(180, 3);
+			break;
+
+		default:
+			_nextHandsPlace = 0;
+			_shouldTalk = false;
+			_game._player._stepEnabled = true;
+			initNode(2);
+			break;
+		}
+		break;
+
+	case 3:
+		switch (_game._trigger) {
+		case 1:
+			_nextHandsPlace = 0;
+			_shouldTalk = true;
+			_game._player._stepEnabled = false;
+			if (_twinklesTalking) {
+				handleTwinklesSpeech(0xBE, -2, 0);
+				_scene->_sequences.addTimer(180, 2);
+			} else {
+				_scene->_sequences.addTimer(6, 1);
+			}
+			break;
+		case 2:
+			_nextHandsPlace = 2;
+			handleTwinklesSpeech(191, -1, 0);
+			_scene->_sequences.addTimer(180, 3);
+			break;
+		case 3:
+			_nextHandsPlace = 0;
+			handleTwinklesSpeech(192, 0, 0);
+			_scene->_sequences.addTimer(180, 4);
+			break;
+		default:
+			_shouldTalk = false;
+			_game._player._stepEnabled = true;
+			initNode(3);
+			break;
+		}
+		break;
+
+	case 4:
+		if (_game._trigger == 1) {
+			_nextHandsPlace = 1;
+			_shouldTalk = true;
+			_game._player._stepEnabled = false;
+
+			int quote;
+			if (_game._storyMode == STORYMODE_NAUGHTY)
+				quote = _vm->getRandomNumber(199, 201);
+			else
+				quote = _vm->getRandomNumber(197, 198);
+
+			if (_twinklesTalking) {
+				handleTwinklesSpeech(quote, 0, 360);
+				_scene->_sequences.addTimer(120, 2);
+			} else {
+				_scene->_sequences.addTimer(6, 1);
+			}
+		} else {
+			_scene->_userInterface.setup(kInputBuildingSentences);
+			_shouldFaceRex = false;
+			_shouldTalk = false;
+			_game._player._stepEnabled = true;
+		}
+		break;
+
+	case 5:
+		switch (_game._trigger) {
+		case 1:
+			_nextHandsPlace = 2;
+			_shouldTalk = true;
+			_game._player._stepEnabled = false;
+			if (_twinklesTalking) {
+				handleTwinklesSpeech(0xCA, -1, 0);
+				_scene->_sequences.addTimer(180, 2);
+			} else {
+				_scene->_sequences.addTimer(6, 1);
+			}
+			break;
+
+		case 2:
+			_nextHandsPlace = 1;
+			handleTwinklesSpeech(0xCB, 0, 0);
+			_scene->_sequences.addTimer(180, 3);
+			break;
+
+		default:
+			_nextHandsPlace = 2;
+			_shouldTalk = false;
+			_game._player._stepEnabled = true;
+			initNode(5);
+			break;
+		}
+		break;
+
+	case 6:
+		switch (_game._trigger) {
+		case 1:
+			_nextHandsPlace = 1;
+			_shouldTalk = true;
+			_game._player._stepEnabled = false;
+			if (_twinklesTalking) {
+				handleTwinklesSpeech(0xD0, -2, 0);
+				_scene->_sequences.addTimer(180, 2);
+			} else {
+				_scene->_sequences.addTimer(6, 1);
+			}
+			break;
+
+		case 2:
+			handleTwinklesSpeech(0xD1, -1, 0);
+			_scene->_sequences.addTimer(180, 3);
+			break;
+
+		case 3:
+			_nextHandsPlace = 1;
+			handleTwinklesSpeech(0xD2, 0, 0);
+			_scene->_sequences.addTimer(180, 4);
+			break;
+
+		default:
+			_nextHandsPlace = 0;
+			_shouldTalk = false;
+			_game._player._stepEnabled = true;
+			initNode(6);
+			break;
+		}
+		break;
+
+	case 7:
+		switch (_game._trigger) {
+		case 1:
+			_nextHandsPlace = 2;
+			_shouldTalk = true;
+			_game._player._stepEnabled = false;
+			if (_twinklesTalking) {
+				handleTwinklesSpeech(0xD6, -1, 0);
+				_scene->_sequences.addTimer(180, 2);
+			} else {
+				_scene->_sequences.addTimer(6, 1);
+			}
+			break;
+
+		case 2:
+			handleTwinklesSpeech(0xD7, 0, 0);
+			_scene->_sequences.addTimer(180, 3);
+			break;
+
+		default:
+			_shouldTalk = false;
+			_game._player._stepEnabled = true;
+			initNode(7);
+			break;
+		}
+		break;
+
+	case 8:
+		switch (_game._trigger) {
+		case 1:
+			_nextHandsPlace = 2;
+			_shouldTalk = true;
+			_game._player._stepEnabled = false;
+			if (_twinklesTalking) {
+				handleTwinklesSpeech(0xDD, -1, 0);
+				_scene->_sequences.addTimer(180, 2);
+			} else {
+				_scene->_sequences.addTimer(6, 1);
+			}
+			break;
+
+		case 2:
+			handleTwinklesSpeech(0xDE, 0, 0);
+			_scene->_sequences.addTimer(180, 3);
+			break;
+
+		default:
+			_shouldTalk = false;
+			_game._player._stepEnabled = true;
+			initNode(8);
+			break;
+		}
+		break;
+
+
+	case 9:
+		switch (_game._trigger) {
+		case 1:
+			_nextHandsPlace = 0;
+			_shouldTalk = true;
+			_game._player._stepEnabled = false;
+			if (_twinklesTalking) {
+				_scene->_userInterface.emptyTalkList();
+				_scene->_userInterface.setup(kInputConversation);
+				handleTwinklesSpeech(0xE4, -1, 0);
+				_scene->_sequences.addTimer(180, 2);
+			} else {
+				_scene->_sequences.addTimer(6, 1);
+			}
+			break;
+
+		case 2:
+			handleTwinklesSpeech(0xE5, 0, 0);
+			_scene->_sequences.addTimer(180, 3);
+			break;
+
+		case 3:
+			_twinkleAnimationType = 2;
+			_globals[kCurtainOpen] = true;
+			_game._player._visible = false;
+			_vm->_palette->lock();
+			_scene->_kernelMessages.reset();
+			_scene->_activeAnimation->free();
+			_scene->_activeAnimation = nullptr;
+			_scene->resetScene();
+
+			_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', -1), 0);
+			_game.loadQuoteSet(0xE6, 0xE9, 0xEA, 0xE7, 0xE8, 0);
+			_scene->loadAnimation(formAnimName('B', -1), 4);
+			break;
+
+		case 4: {
+			_globals._spriteIndexes[8] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 5);
+			_scene->_sequences.setDepth(_globals._spriteIndexes[8], 1);
+
+			int msgIndex = _scene->_kernelMessages.add(Common::Point(160, 20), 0x1110, 32, 5, 180, _game.getQuote(231));
+			_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+			}
+			break;
+
+		case 5: {
+			int msgIndex = _scene->_kernelMessages.add(Common::Point(160, 40), 0xFDFC, 32, 6, 180, _game.getQuote(233));
+			_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+			}
+			break;
+
+		case 6: {
+			int msgIndex = _scene->_kernelMessages.add(Common::Point(160, 60), 0x1110, 32, 7, 180, _game.getQuote(232));
+			_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+			}
+			break;
+
+		case 7: {
+			int msgIndex = _scene->_kernelMessages.add(Common::Point(160, 80), 0xFDFC, 32, 8, 180, _game.getQuote(234));
+			_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+			}
+			break;
+
+		case 8:
+			_globals[kTwinklesStatus] = TWINKLES_GONE;
+			_scene->_nextSceneId = 216;
+			break;
+		}
+		break;
+	}
+}
+
+void Scene210::handleTwinklesSpeech(int quoteId, int shiftX, uint32 delay) {
+	_scene->_kernelMessages.add(Common::Point(10, 70 + (shiftX * 14)), 0xFDFC, 0, 0, (delay == 0) ? 9999999 : delay, _game.getQuote(quoteId));
+}
+
+void Scene210::initNode(int node) {
+	_curDialogNode = node;
+
+	switch (_curDialogNode) {
+	case 1:
+		warning("TODO: talk_init(&dialog1);");
+		break;
+
+	case 2:
+		warning("TODO: talk_init(&dialog2);");
+		break;
+
+	case 3:
+		warning("TODO: talk_init(&dialog3);");
+		break;
+
+	case 5:
+		warning("TODO: talk_init(&dialog5);");
+		break;
+
+	case 6:
+		warning("TODO: talk_init(&dialog6);");
+		break;
+
+	case 7:
+		warning("TODO: talk_init(&dialog7);");
+		break;
+
+	case 8:
+		warning("TODO: talk_init(&dialog8);");
+		break;
+	}
+}
+
+void Scene210::restoreDialogNode(int node, int msgId, int posY) {
+	int curQuoteId = msgId;
+	int curY = 1 - posY;
+	for (int count = 0; count < posY; count++) {
+		handleTwinklesSpeech(curQuoteId, curY, 0);
+		curY++;
+		curQuoteId++;
+	}
+
+	initNode(node);
+}
+
+void Scene210::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', -1), 0);
+
+	if (!_game._visitedScenes._sceneRevisited)
+		_globals[kCurtainOpen] = 0;
+
+	if (_scene->_priorSceneId == 205)
+		_game._player._playerPos = Common::Point(277, 56);
+	else if (_scene->_priorSceneId == 215) {
+		_game._player._playerPos = Common::Point(168, 128);
+		_game._player._facing = FACING_SOUTH;
+		_globals[kCurtainOpen] = true;
+	} else if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(308, 132);
+
+	if (!_globals[kCurtainOpen]) {
+		_globals._spriteIndexes[8] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 5);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[8], 5);
+	} else {
+		int idx = _scene->_dynamicHotspots.add(112, 395, -1, Common::Rect(163, 87, 19, 36)); 
+		_doorway = _scene->_dynamicHotspots.setPosition(idx, 168, 127, FACING_NORTH);
+		_scene->_dynamicHotspots.setCursor(_doorway, CURSOR_GO_UP);
+	}
+
+	_game.loadQuoteSet(0x5A, 0x73, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB8, 0xB7,
+		0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA,
+		0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC,
+		0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0);
+	warning("TODO: sub71A50(&dialog1, 0x2E, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0);");
+
+	if (!_game._visitedScenes._sceneRevisited) {
+		warning("TODO: sub71B18(0x2E, 0xB4, 0xB5, 0xB6, 0xB8, 0);");
+
+		warning("TODO: if (Debugger_widepipe_ctr >= 2)");
+		warning("TODO: \tsub71B9E(&dialog1, 0xB7, -1);");
+	}
+
+	warning("TODO: sub71A50(&dialog2, 0x2F, 0xBC, 0xBB, 0xBD, _game._visitedScenes._sceneRevisited ? 0, -1);");
+	warning("TODO: sub71A50(&dialog3, 0x30, 0xC3, 0xC2, 0xC1, 0xC4, _game._visitedScenes._sceneRevisited ? 0, -1);");
+	warning("TODO: sub71A50(&dialog5, 0x31, 0xCD, 0xCC, 0xCE, 0xCF, _game._visitedScenes._sceneRevisited ? 0, -1);");
+	warning("TODO: sub71A50(&dialog6, 0x32, 0xD3, 0xD4, 0xD5, _game._visitedScenes._sceneRevisited ? 0, -1);");
+	warning("TODO: sub71A50(&dialog7, 0x33, 0xD8, 0xDA, 0xD9, 0xDB, 0xDC, _game._visitedScenes._sceneRevisited ? 0, -1);");
+	warning("TODO: sub71A50(&dialog8, 0x34, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, _game._visitedScenes._sceneRevisited ? 0, -1);");
+
+	_twinkleAnimationType = 0;
+	_twinklesCurrentFrame = 0;
+
+	if (_scene->_priorSceneId != -2) {
+		_shouldMoveHead = false;
+		_shouldFaceRex = false;
+		_shouldTalk = false;
+		_nextHandsPlace = 0;
+		_twinklesTalking = false;
+		_curDialogNode = 0;
+		_stopWalking = false;
+		_twinklesTalk2 = (_globals[kTwinklesApproached] > 0);
+	}
+
+	if (_globals[kTwinklesStatus] == 0) {
+		_scene->loadAnimation(formAnimName('A', -1), 0);
+		_twinkleAnimationType = 1;
+	} else
+		_scene->_hotspots.activate(476, false);
+
+	if (_curDialogNode) {
+		int quote = 0;
+		int number = 0;
+
+		switch (_curDialogNode) {
+		case 1:
+			quote = 0xB3;
+			number = 1;
+			break;
+		case 2:
+			quote = 0xB9;
+			number = 2;
+			break;
+		case 3:
+			quote = 0xBE;
+			number = 3;
+			break;
+		case 5:
+			quote = 0xCA;
+			number = 2;
+			break;
+		case 6:
+			quote = 0xD0;
+			number = 3;
+			break;
+		case 7:
+			quote = 0xD6;
+			number = 2;
+			break;
+		case 8:
+			quote = 0xDD;
+			number = 2;
+			break;
+		}
+
+		restoreDialogNode(_curDialogNode, quote, number);
+		_scene->_activeAnimation->setCurrentFrame(131);
+	}
+
+	_vm->_palette->setEntry(252, 63, 63, 10);
+	_vm->_palette->setEntry(253, 45, 45, 5);
+
+	sceneEntrySound();
+}
+
+void Scene210::step() {
+	if ((_twinkleAnimationType == 1) && _scene->_activeAnimation) {
+		if (_twinklesCurrentFrame != _scene->_activeAnimation->getCurrentFrame()) {
+			_twinklesCurrentFrame = _scene->_activeAnimation->getCurrentFrame();
+			int reset_frame = -1;
+			int random = _vm->getRandomNumber(1, 1000);
+
+			switch (_twinklesCurrentFrame) {
+			case 31:
+			case 58:
+			case 74:
+			case 108:
+			case 190:
+				if (_shouldFaceRex)
+					reset_frame = 108;
+				else if ((random <= 100) || _shouldMoveHead)
+					reset_frame = 74;
+				else if (random <= 300)
+					reset_frame = 58;
+				else if (random <= 500)
+					reset_frame = 31;
+				else
+					reset_frame = 0;
+				break;
+
+			case 80:
+			case 90:
+				_twinklesTalking = false;
+				if (_shouldMoveHead) {
+					reset_frame = 90;
+				} else if (_twinklesCurrentFrame == 90) {
+					if ((random <= 400) || _shouldFaceRex)
+						reset_frame = 99;
+					else
+						reset_frame = 79;
+				}
+				break;
+
+			case 98:
+				if (_shouldMoveHead)
+					reset_frame = 91;
+				break;
+
+			case 99:
+				if ((random <= 400) && !_shouldFaceRex)
+					reset_frame = 79;
+				break;
+
+			case 124:
+			case 136:
+			case 174:
+			case 143:
+			case 152:
+				if (_nextHandsPlace == 3)
+					reset_frame = 174;
+				else if (!_shouldFaceRex)
+					reset_frame = 174;
+				else if (_nextHandsPlace == 1)
+					reset_frame = 136;
+				else if (_nextHandsPlace == 2)
+					reset_frame = 152;
+				else if (_shouldTalk)
+					reset_frame = 124;
+				else
+					reset_frame = (random <= 200) ? 131 : 143;
+				break;
+
+			case 131:
+				if (_shouldTalk) {
+					switch (_nextHandsPlace) {
+					case 1:
+						reset_frame = 136;
+						break;
+					case 2:
+						reset_frame = 152;
+						break;
+					default:
+						reset_frame = 124;
+						break;
+					}
+				}
+				break;
+
+			case 138:
+			case 141:
+				if ((_nextHandsPlace == 0) || !_shouldFaceRex)
+					reset_frame = 141;
+				else if (_nextHandsPlace == 2)
+					reset_frame = 152;
+				else if (!_shouldTalk || (_twinklesCurrentFrame == 141))
+					reset_frame = 137;
+				break;
+
+			case 153:
+			case 169:
+				if ((_nextHandsPlace == 0) || !_shouldFaceRex)
+					reset_frame = 169;
+				else if (_nextHandsPlace == 1)
+					reset_frame = 136;
+				else if (_shouldTalk)
+					reset_frame = 153;
+				else
+					reset_frame = 162;
+				break;
+
+			case 162:
+				if (_shouldTalk) {
+					switch (_nextHandsPlace) {
+					case 0:
+						reset_frame = 124;
+						break;
+					case 1:
+						reset_frame = 136;
+						break;
+					default:
+						reset_frame = 153;
+						break;
+					}
+				}
+				break;
+			}
+
+			if (reset_frame >= 0) {
+				if (reset_frame != _scene->_activeAnimation->getCurrentFrame()) {
+					_scene->_activeAnimation->setCurrentFrame(reset_frame);
+					_twinklesCurrentFrame = reset_frame;
+				}
+
+				if ((reset_frame == 90) || (reset_frame == 91) || (reset_frame == 124) || (reset_frame == 153)
+					|| ((reset_frame == 137) && _shouldTalk)) {
+					_twinklesTalking = true;
+				} else {
+					_twinklesTalking = false;
+				}
+			}
+		}
+	}
+
+	if ((_twinkleAnimationType == 2) && _scene->_activeAnimation) {
+		if (_twinklesCurrentFrame != _scene->_activeAnimation->getCurrentFrame()) {
+			_twinklesCurrentFrame = _scene->_activeAnimation->getCurrentFrame();
+			int reset_frame = -1;
+
+			if (_twinklesCurrentFrame == 53) {
+				_scene->_kernelMessages.add(Common::Point(151, 61), 0xFDFC, 32, 70, 180, _game.getQuote(230));
+				_shouldTalk = true;
+			} else if ((_twinklesCurrentFrame == 75) && _shouldTalk)
+				reset_frame = 60;
+	
+			if ((reset_frame >= 0) && (reset_frame != _scene->_activeAnimation->getCurrentFrame())) {
+				_scene->_activeAnimation->setCurrentFrame(reset_frame);
+				_twinklesCurrentFrame = reset_frame;
+			}
+		}
+
+		if (_game._trigger == 70)
+			_shouldTalk = false;
+	}
+
+	if ((_twinkleAnimationType == 1) && (_scene->_rails.getNext() > 0)) {
+		_game._player.walk(Common::Point(214, 150), FACING_NORTHWEST);
+		_scene->_rails.resetNext();
+		_stopWalking = true;
+	}
+}
+
+void Scene210::preActions() {
+	_stopWalking = false;
+
+	if (_action.isAction(0x1AD, 0x1C1))
+		_game._player._walkOffScreenSceneId = 211;
+}
+
+void Scene210::actions() {
+	if (_action.isAction(VERB_LOOK, 0x27, 0x1C0)) {
+		_vm->_dialogs->show(0x5219);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_game._screenObjects._inputMode == 1) {
+		handleDialogs();
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_TALKTO, 0x1DC) || 
+		((_game._player._playerPos == Common::Point(214, 150)) && (_game._player._facing == FACING_NORTHWEST) && (_twinkleAnimationType == 1) && _stopWalking)) {
+		switch (_game._trigger) {
+		case 0: {
+			_game._player._stepEnabled = false;
+			int quote;
+			if (_globals[kTwinklesApproached] == 0)
+				quote = 90;
+			else if (_globals[kTwinklesApproached] == 1)
+				quote = 115;
+			else
+				quote = 171;
+
+			_shouldFaceRex = true;
+			_nextHandsPlace = 0;
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.addQuote(quote, 1, 120);
+			}
+			break;
+
+		case 1:
+			_shouldTalk = true;
+			if (!_twinklesTalking) {
+				_scene->_sequences.addTimer(6, 1);
+			} else {
+				if (_globals[kTwinklesApproached] == 0) {
+					handleTwinklesSpeech(0xAF, -1, 0);
+					handleTwinklesSpeech(0xB0, 0, 0);
+				} else if (_globals[kTwinklesApproached] == 1) {
+					handleTwinklesSpeech(0xB1, 0, 0);
+				} else {
+					int quote = _twinklesTalk2 ? 0xB3 : 0xB2;
+					_twinklesTalk2 = true;
+					handleTwinklesSpeech(quote, 0, 0);
+				}
+				_scene->_sequences.addTimer(60, 3);
+			}
+			break;
+
+		case 3:
+			_game._player._stepEnabled = true;
+			_shouldMoveHead = false;
+			_shouldTalk = false;
+
+			if (_globals[kTwinklesApproached] < 2)
+				_globals[kTwinklesApproached]++;
+
+			warning("TODO: talk_init(&dialog1);");
+			_curDialogNode = 1;
+			break;
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_GIVE, 0x1DC) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
+		switch (_game._trigger) {
+		case 0: {
+			int quote = _vm->getRandomNumber(172, 174);
+			_shouldMoveHead = true;
+			_game._player._stepEnabled = false;
+			handleTwinklesSpeech(quote, 0, 120);
+			_scene->_sequences.addTimer(120, 1);
+			}
+			break;
+
+		case 1:
+			_game._player._stepEnabled = true;
+			_shouldMoveHead = false;
+			break;
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(0x1AD, 0x1BF) || _action.isAction(0x18C, 0x1C0)) {
+		_scene->_nextSceneId = 205;
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(0x18B, 0x70)) {
+		_scene->_nextSceneId = 215;
+		_action._inProgress = false;
+		return;
+	}
+
+	if ((_action.isAction(VERB_PULL, 0x5F) || _action.isAction(VERB_OPEN, 0x5F)) && !_globals[kCurtainOpen]) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_scene->_sequences.remove(_globals._spriteIndexes[8]);
+			_globals._spriteIndexes[8] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[1], false, 12, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._spriteIndexes[8], 5);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[8], SM_0, 0, 1);
+			break;
+
+		case 1:
+			_game._player._stepEnabled = true;
+			_globals[kCurtainOpen] = true;
+			_doorway = _scene->_dynamicHotspots.add(112, 395, -1, Common::Rect(163, 87, 19, 36));
+			_scene->_dynamicHotspots.setPosition(_doorway, 168, 127, FACING_NORTH);
+			_scene->_dynamicHotspots.setCursor(_doorway, CURSOR_GO_UP);
+			break;
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if ((_action.isAction(VERB_PULL, 0x5F) || _action.isAction(VERB_CLOSE, 0x5F)) && _globals[kCurtainOpen]) {
+		switch (_game._trigger) {
+		case 0:
+			_scene->_sequences.remove(_globals._spriteIndexes[8]);
+			_game._player._stepEnabled = false;
+			_game._player._facing = FACING_NORTH;
+			_globals._spriteIndexes[8] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[1], false, 12, 0, 0, 1);
+			_scene->_sequences.setDepth(_globals._spriteIndexes[8], 5);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[8], SM_0, 0, 1);
+			_game._player._stepEnabled = false;
+			break;
+		case 1:
+			_globals._spriteIndexes[8] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 5);
+			_scene->_sequences.setDepth(_globals._spriteIndexes[8], 5);
+			_scene->_sequences.addTimer(48, 2);
+			break;
+		case 2:
+			_scene->_dynamicHotspots.remove(_doorway);
+			_game._player._stepEnabled = true;
+			_globals[kCurtainOpen] = false;
+			break;
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0xAA)) {
+		if (_globals[kTwinklesStatus] == TWINKLES_GONE) {
+			if (_game._storyMode == STORYMODE_NAUGHTY)
+				_vm->_dialogs->show(0x520B);
+			else
+				_vm->_dialogs->show(0x520A);
+		} else {
+			_vm->_dialogs->show(0x5209);
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x31)) {
+		_vm->_dialogs->show(0x520C);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0xA7)) {
+		_vm->_dialogs->show(0x520D);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_TAKE, 0xA7) || _action.isAction(VERB_TAKE, 0x31)) {
+		_vm->_dialogs->show(0x520E);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x1C5)) {
+		_vm->_dialogs->show(0x520F);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x3A)) {
+		_vm->_dialogs->show(0x5210);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x1B0)) {
+		_vm->_dialogs->show(0x5211);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x1DC)) {
+		_vm->_dialogs->show(0x5212);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(0x13A, 0x1DC) || _action.isAction(0xA6, 0x1DC)) {
+		_vm->_dialogs->show(0x5213);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x1BF)) {
+		_vm->_dialogs->show(0x5214);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x5F)) {
+		_vm->_dialogs->show(0x5215);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x53)) {
+		_vm->_dialogs->show(0x5216);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_TAKE, 0x53)) {
+		_vm->_dialogs->show(0x5217);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x1C0)) {
+		_vm->_dialogs->show(0x5218);
+		_action._inProgress = false;
+		return;
+	}
+}
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index d29b94e..fb09735 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -202,6 +202,40 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene210: public Scene2xx {
+private:
+	int _curDialogNode;
+	int _nextHandsPlace;
+	int _twinkleAnimationType;
+	int _twinklesCurrentFrame;
+	bool _shouldTalk, _shouldFaceRex, _shouldMoveHead;
+	bool _stopWalking;
+	bool _twinklesTalking;
+	bool _twinklesTalk2;
+	int _doorway;
+	Common::String _subQuote2;
+
+	void handleDialogs();
+	void handleSubDialog1();
+	void handleSubDialog2();
+	void handleSubDialog3();
+	void handleSubDialog5();
+	void handleSubDialog6();
+	void handleSubDialog7();
+	void handleSubDialog8();
+	void setDialogNode(int node);
+	void handleTwinklesSpeech(int quoteId, int shiftX, uint32 delay);
+	void initNode(int node);
+	void restoreDialogNode(int node, int msgId, int posY);
+public:
+	Scene210(MADSEngine *vm) : Scene2xx(vm) {}
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 
diff --git a/engines/mads/rails.h b/engines/mads/rails.h
index 55f6f8b..6338aea 100644
--- a/engines/mads/rails.h
+++ b/engines/mads/rails.h
@@ -121,6 +121,7 @@ public:
 	const WalkNode &popNode();
 
 	void resetNext() { _next = 0; }
+	int  getNext() { return _next; }
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index f51372e..8d05402 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -579,6 +579,10 @@ void UserInterface::drawTalkList() {
 	warning("TODO: drawTalkList");
 }
 
+void UserInterface::emptyTalkList() {
+	warning("TODO: emptyTalkList");
+}
+
 void UserInterface::loadInventoryAnim(int objectId) {
 	Scene &scene = _vm->_game->_scene;
 	noInventoryAnim();
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 86b5622..6b3abf0 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -214,6 +214,8 @@ public:
 	void scrollerChanged();
 
 	void scrollInventory();
+
+	void emptyTalkList();
 };
 
 } // End of namespace MADS


Commit: 04cfa85d74aa1ed143475f6d66039b3d51d2506d
    https://github.com/scummvm/scummvm/commit/04cfa85d74aa1ed143475f6d66039b3d51d2506d
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-08T10:36:12+02:00

Commit Message:
MADS: Use Common::Point in DynamicHotspot::setPosition()

Changed paths:
    engines/mads/hotspots.cpp
    engines/mads/hotspots.h
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
index 24ff172..baae4a9 100644
--- a/engines/mads/hotspots.cpp
+++ b/engines/mads/hotspots.cpp
@@ -75,10 +75,9 @@ int DynamicHotspots::add(int descId, int vocabId, int seqIndex, const Common::Re
 	return idx;
 }
 
-int DynamicHotspots::setPosition(int index, int xp, int yp, Facing facing) {
+int DynamicHotspots::setPosition(int index, const Common::Point &pos, Facing facing) {
 	if (index >= 0) {
-		_entries[index]._feetPos.x = xp;
-		_entries[index]._feetPos.y = yp;
+		_entries[index]._feetPos = pos;
 		_entries[index]._facing = facing;
 	}
 
diff --git a/engines/mads/hotspots.h b/engines/mads/hotspots.h
index a36993f..bd803e8 100644
--- a/engines/mads/hotspots.h
+++ b/engines/mads/hotspots.h
@@ -61,7 +61,7 @@ public:
 	Common::Array<MADS::DynamicHotspot>::size_type size() const { return _entries.size(); }
 	DynamicHotspot &operator[](uint idx) { return _entries[idx]; }
 	int add(int descId, int vocabId, int seqIndex, const Common::Rect &bounds);
-	int setPosition(int index, int xp, int yp, Facing facing);
+	int setPosition(int index, const Common::Point &pos, Facing facing);
 	int setCursor(int index, CursorType cursor);
 	void remove(int index);
 	void clear();
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 97c6581..b7b2b80 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -141,7 +141,7 @@ void Scene201::enter() {
 	_scene->_sequences.setMsgPosition(_globals._spriteIndexes[19], Common::Point(185, 46));
 
 	int idx = _scene->_dynamicHotspots.add(1159, 209, _globals._spriteIndexes[19], Common::Rect(0, 0, 0, 0));
-	_scene->_dynamicHotspots.setPosition(idx, 186, 81, FACING_NORTH);
+	_scene->_dynamicHotspots.setPosition(idx, Common::Point(186, 81), FACING_NORTH);
 
 	if ((_scene->_priorSceneId == 202) || (_scene->_priorSceneId == -1)) {
 		_game._player._playerPos = Common::Point(165, 152);
@@ -209,7 +209,7 @@ void Scene201::step() {
 	if (_pterodactylFlag && (_vm->getRandomNumber(5000) == 9)) {
 		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 5, 1, 6, 0);
 		int idx = _scene->_dynamicHotspots.add(351, 13, _globals._spriteIndexes[20], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 270, 80, FACING_EAST);
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(270, 80), FACING_EAST);
 		_scene->_sequences.setDepth(_globals._spriteIndexes[20], 8);
 		_vm->_sound->command(14);
 		_pterodactylFlag = false;
@@ -361,14 +361,14 @@ void Scene202::enter() {
 	_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(149, 113));
 	_scene->_sequences.setDepth(_globals._spriteIndexes[17], 10);
 	int idx = _scene->_dynamicHotspots.add(320, 13, _globals._spriteIndexes[17], Common::Rect(0, 0, 0, 0));
-	_scene->_dynamicHotspots.setPosition(idx, 153, 97, FACING_SOUTH);
+	_scene->_dynamicHotspots.setPosition(idx, Common::Point(153, 97), FACING_SOUTH);
 
 	if (!(_globals[kBone202Status] & 1)) {
 		_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
 		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[16], Common::Point(130, 108));
 		_scene->_sequences.setDepth(_globals._spriteIndexes[16], 10);
 		idx = _scene->_dynamicHotspots.add(44, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 132, 97, FACING_SOUTH);
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(132, 97), FACING_SOUTH);
 	}
 
 	if (!(_globals[kBone202Status] & 2)) {
@@ -376,7 +376,7 @@ void Scene202::enter() {
 		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[21], Common::Point(166, 110));
 		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 10);
 		idx = _scene->_dynamicHotspots.add(44, 13, _globals._spriteIndexes[21], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 165, 99, FACING_SOUTH);
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(165, 99), FACING_SOUTH);
 	}
 
 	if (_globals[kBone202Status])
@@ -395,7 +395,7 @@ void Scene202::enter() {
 		_scene->_sequences.setDepth(_globals._spriteIndexes[20], 6);
 		_scene->_hotspots.activate(199, false);
 		idx = _scene->_dynamicHotspots.add(457, 13, _globals._spriteIndexes[20], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 246, 124, FACING_NORTH);
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(246, 124), FACING_NORTH);
 	}
 
 	_game.loadQuoteSet(0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x62, 0x63, 0x64, 0x65, 0x66, 0x61, 0);
@@ -532,7 +532,7 @@ void Scene202::step() {
 		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 0, 0, 0);
 		_scene->_hotspots.activate(199, false);
 		int idx = _scene->_dynamicHotspots.add(457, 13, _globals._spriteIndexes[20], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 246, 124, FACING_NORTH);
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(246, 124), FACING_NORTH);
 		_scene->_sequences.updateTimeout(_globals._spriteIndexes[26], _globals._spriteIndexes[20]);
 		_scene->_sequences.updateTimeout(-1, _globals._spriteIndexes[26]);
 		_game._player._stepEnabled = true;
@@ -806,7 +806,7 @@ void Scene202::actions() {
 				_game._player._stepEnabled = false;
 
 				_ladderHotspotId = _scene->_dynamicHotspots.add(199, 79, -1, Common::Rect(241, 68, 12, 54));
-				_scene->_dynamicHotspots.setPosition(_ladderHotspotId, 246, 124, FACING_NORTH);
+				_scene->_dynamicHotspots.setPosition(_ladderHotspotId, Common::Point(246, 124), FACING_NORTH);
 				_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
 				_scene->_sequences.setDepth(_globals._spriteIndexes[23], 1);
 				_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 1);
@@ -1006,7 +1006,7 @@ void Scene203::enter() {
 		_rhotundaEatFl = true;
 		_game._player.walk(Common::Point(158, 135), FACING_SOUTH);
 		int idx = _scene->_dynamicHotspots.add(131, 396, 0, Common::Rect(0, 0, 320, 156));
-		_scene->_dynamicHotspots.setPosition(idx, 155, 152, FACING_SOUTH);
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(155, 152), FACING_SOUTH);
 		_scene->_dynamicHotspots.setCursor(idx, CURSOR_GO_DOWN);
 	}
 
@@ -1015,7 +1015,7 @@ void Scene203::enter() {
 		if (_vm->getRandomNumber(1, 3) == 2) {
 			_globals._spriteIndexes[15] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 9, 1, 0, 0);
 			int idx = _scene->_dynamicHotspots.add(477, 209, _globals._spriteIndexes[15], Common::Rect(0, 0, 0, 0));
-			_scene->_dynamicHotspots.setPosition(idx, -2, 0, FACING_NONE);
+			_scene->_dynamicHotspots.setPosition(idx, Common::Point(-2, 0), FACING_NONE);
 			_vm->_sound->command(14);
 		}
 	}
@@ -1114,11 +1114,11 @@ void Scene205::enter() {
 
 	_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 10, 0, 0, 3);
 	int idx = _scene->_dynamicHotspots.add(73, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
-	_scene->_dynamicHotspots.setPosition(idx, 162, 120, FACING_NORTHEAST);
+	_scene->_dynamicHotspots.setPosition(idx, Common::Point(162, 120), FACING_NORTHEAST);
 
 	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 15, 0, 0, 0);
 	idx = _scene->_dynamicHotspots.add(73, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
-	_scene->_dynamicHotspots.setPosition(idx, 162, 120, FACING_NORTHEAST);
+	_scene->_dynamicHotspots.setPosition(idx, Common::Point(162, 120), FACING_NORTHEAST);
 
 	_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 9, 0, 0, 0);
 	_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 0, 0, 0);
@@ -1128,7 +1128,7 @@ void Scene205::enter() {
 		_lastFishTime = _scene->_frameStartTime;
 		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 7, 1, 0, 0);
 		idx = _scene->_dynamicHotspots.add(269, 13, _globals._spriteIndexes[21], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 49, 86, FACING_NORTH);
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(49, 86), FACING_NORTH);
 	}
 
 	if (_game._objects[12]._roomNumber == 205) {
@@ -1195,7 +1195,7 @@ void Scene205::step() {
 	if (_globals._frameTime - _lastFishTime > 1300) {
 		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 5, 1, 0, 0);
 		int idx = _scene->_dynamicHotspots.add(269, 13, _globals._spriteIndexes[21], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 49, 86, FACING_NORTH);
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(49, 86), FACING_NORTH);
 		_lastFishTime = _globals._frameTime;
 	}
 
@@ -1265,7 +1265,7 @@ void Scene207::enter() {
 		_globals._spriteIndexes[16] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 30, 0, 0, 400);
 		_vultureTime = _game._player._priorTimer;
 		_vultureHotspotId = _scene->_dynamicHotspots.add(389, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(_vultureHotspotId, 254, 94, FACING_WEST);
+		_scene->_dynamicHotspots.setPosition(_vultureHotspotId, Common::Point(254, 94), FACING_WEST);
 	}
 
 	if (_spiderFl) {
@@ -1273,7 +1273,7 @@ void Scene207::enter() {
 		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], -1, -1);
 		_spiderTime = _game._player._priorTimer;
 		_spiderHotspotId = _scene->_dynamicHotspots.add(333, 13, _globals._spriteIndexes[19], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(_spiderHotspotId, 59, 132, FACING_SOUTH);
+		_scene->_dynamicHotspots.setPosition(_spiderHotspotId, Common::Point(59, 132), FACING_SOUTH);
 	}
 
 	_eyeFl = false;
@@ -1427,7 +1427,7 @@ void Scene208::updateTrap() {
 		_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 0, 0, 24);
 		_scene->_sequences.setDepth(_globals._spriteIndexes[16], 5);
 		int idx = _scene->_dynamicHotspots.add(424, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 100, 146, FACING_NORTH);
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(100, 146), FACING_NORTH);
 		_scene->_hotspots.activate(414, false);
 		return;
 	}
@@ -1437,7 +1437,7 @@ void Scene208::updateTrap() {
 		_globals._spriteIndexes[17] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
 		_scene->_sequences.setDepth(_globals._spriteIndexes[17], 15);
 		int idx = _scene->_dynamicHotspots.add(426, 13, _globals._spriteIndexes[17], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 60, 152, FACING_NORTH);
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(60, 152), FACING_NORTH);
 		}
 		break;
 	case 2: {
@@ -1445,7 +1445,7 @@ void Scene208::updateTrap() {
 		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
 		_scene->_hotspots.activate(414, false);
 		int idx = _scene->_dynamicHotspots.add(425, 13, _globals._spriteIndexes[17], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 100, 146, FACING_NORTH);
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(100, 146), FACING_NORTH);
 		_scene->_dynamicHotspots[idx]._articleNumber = 5;
 		}
 		break;
@@ -2357,7 +2357,8 @@ void Scene209::handleMonkeyFall() {
 		_scene->_sequences.updateTimeout(_globals._spriteIndexes[23], oldIdx);
 		_scene->_sequences.setAnimRange(_globals._spriteIndexes[23], 43, 72);
 		_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 222);
-		_scene->_dynamicHotspots.setPosition(_scene->_dynamicHotspots.add(39, 13, _globals._spriteIndexes[24], Common::Rect(0, 0, 0, 0)), 200, 133, FACING_NORTH);
+		int idx = _scene->_dynamicHotspots.add(39, 13, _globals._spriteIndexes[24], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(200, 133), FACING_NORTH);
 		}
 		break;
 
@@ -2533,7 +2534,7 @@ void Scene209::enter() {
 	if (_game._objects.isInRoom(OBJ_PLANT_STALK)) {
 		_globals._spriteIndexes[16] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
 		int idx = _scene->_dynamicHotspots.add(271, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 263, 129, FACING_SOUTH);
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(263, 129), FACING_SOUTH);
 		_scene->_sequences.setDepth(_globals._spriteIndexes[16], 13);
 	}
 
@@ -2550,7 +2551,7 @@ void Scene209::enter() {
 		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(201, 131));
 		_scene->_sequences.setDepth(_globals._spriteIndexes[24], 8);
 		int idx = _scene->_dynamicHotspots.add(39, 13, _globals._spriteIndexes[24], Common::Rect(0, 0, 0, 0));
-		_scene->_dynamicHotspots.setPosition(idx, 200, 133, FACING_NORTH);
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(200, 133), FACING_NORTH);
 	}
 
 	if (_scene->_roomChanged) {
@@ -3829,7 +3830,7 @@ void Scene210::enter() {
 		_scene->_sequences.setDepth(_globals._spriteIndexes[8], 5);
 	} else {
 		int idx = _scene->_dynamicHotspots.add(112, 395, -1, Common::Rect(163, 87, 19, 36)); 
-		_doorway = _scene->_dynamicHotspots.setPosition(idx, 168, 127, FACING_NORTH);
+		_doorway = _scene->_dynamicHotspots.setPosition(idx, Common::Point(168, 127), FACING_NORTH);
 		_scene->_dynamicHotspots.setCursor(_doorway, CURSOR_GO_UP);
 	}
 
@@ -4205,7 +4206,7 @@ void Scene210::actions() {
 			_game._player._stepEnabled = true;
 			_globals[kCurtainOpen] = true;
 			_doorway = _scene->_dynamicHotspots.add(112, 395, -1, Common::Rect(163, 87, 19, 36));
-			_scene->_dynamicHotspots.setPosition(_doorway, 168, 127, FACING_NORTH);
+			_scene->_dynamicHotspots.setPosition(_doorway, Common::Point(168, 127), FACING_NORTH);
 			_scene->_dynamicHotspots.setCursor(_doorway, CURSOR_GO_UP);
 			break;
 		}


Commit: 3e2cba4cdac011372882336a5572219aa08380f2
    https://github.com/scummvm/scummvm/commit/3e2cba4cdac011372882336a5572219aa08380f2
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-08T11:20:15+02:00

Commit Message:
MADS: Hook scene 210 in hardcoded logic

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 0538f1b..67a75c3 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -65,6 +65,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene208(vm);
 	case 209:
 		return new Scene209(vm);
+	case 210:
+		return new Scene210(vm);
 
 	// Scene group #8
 	case 804:


Commit: cd77110093c32f07b84325684ada9a425bdf6c93
    https://github.com/scummvm/scummvm/commit/cd77110093c32f07b84325684ada9a425bdf6c93
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-08T20:34:39-04:00

Commit Message:
MADS: Fixes for movement issues in the grasslands

Changed paths:
    engines/mads/player.cpp



diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 10d8b3e..bf5e59e 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -426,27 +426,29 @@ void Player::move() {
 	if (_scalingVelocity && (_totalDistance > 0)) {
 		int angleRange = 100 - _currentScale;
 		int angleScale = angleRange * (_posDiff.x - 1) / _totalDistance + _currentScale;
-		velocity = MAX(1, 10000 / (angleScale * _currentScale * velocity));
+		velocity = MAX(1L, (angleScale * _currentScale * velocity) / 10000L);
 	}
 
 	if (!_moving || (_facing != _turnToFacing))
 		return;
 
 	Common::Point newPos = _playerPos;
+	newFacing = false;
+	_special = 0;
 
 	if (_distAccum < velocity) {
 		do {
 			if (_pixelAccum < _posDiff.x)
 				_pixelAccum += _posDiff.y;
 			if (_pixelAccum >= _posDiff.x) {
-				if ((_posChange.y > 0) || (_walkOffScreen != 0))
+				if ((_posChange.y > 0) || _walkOffScreen)
 					newPos.y += _yDirection;
 				--_posChange.y;
 				_pixelAccum -= _posDiff.x;
 			}
 
 			if (_pixelAccum < _posDiff.x) {
-				if ((_posChange.x > 0) || (_walkOffScreen != 0))
+				if ((_posChange.x > 0) || _walkOffScreen)
 					newPos.x += _xDirection;
 				--_posChange.x;
 			}


Commit: 531ebab4da814aac23a9b084772a6156bfb3b9b8
    https://github.com/scummvm/scummvm/commit/531ebab4da814aac23a9b084772a6156bfb3b9b8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-08T22:04:43-04:00

Commit Message:
MADS: Added preliminary keyboard handling and keypress process stub

Changed paths:
    engines/mads/dialogs.cpp
    engines/mads/dialogs.h
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/screen.cpp



diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index 2301541..8bc73e5 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -331,11 +331,13 @@ void TextDialog::show() {
 	// Wait for mouse click
 	do {
 		_vm->_events->waitForNextFrame();
-	} while (!_vm->shouldQuit() && !_vm->_events->_mouseReleased);
+	} while (!_vm->shouldQuit() && !_vm->_events->isKeyPressed() && !_vm->_events->_mouseReleased);
 
-	// Allow the mouse release to be gobbled up
-	if (!_vm->shouldQuit())
+	// Allow the mouse release or keypress to be gobbled up
+	if (!_vm->shouldQuit()) {
 		_vm->_events->waitForNextFrame();
+		_vm->_events->_pendingKeys.clear();
+	}
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index 2c7c342..00b714d 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -184,7 +184,7 @@ public:
 	void show();
 };
 
-class MessageDialog: protected TextDialog {
+class MessageDialog: public TextDialog {
 public:
 	MessageDialog(MADSEngine *vm, int lines, ...);
 
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index ecc7a52..85c62e3 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -37,13 +37,12 @@ EventsManager::EventsManager(MADSEngine *vm) {
 	_cursorSprites = nullptr;
 	_frameCounter = 10;
 	_priorFrameTime = 0;
-	_keyPressed = false;
 	_mouseClicked = false;
 	_mouseReleased = false;
 	_mouseButtons = 0;
-	_vCC = 0;
+	_mouseStatus = 0;
 	_vD2 = 0;
-	_vD4 = 0;
+	_mouseStatusCopy = 0;
 	_mouseMoved = false;
 	_vD8 = 0;
 	_rightMousePressed = false;
@@ -119,18 +118,22 @@ void EventsManager::pollEvents() {
 				_vm->_debugger->attach();
 				_vm->_debugger->onFrame();
 			} else {
-				_keyPressed = true;
+				_pendingKeys.push(event);
 			}
 			return;
 		case Common::EVENT_KEYUP:
-			_keyPressed = false;
 			return;
 		case Common::EVENT_LBUTTONDOWN:
 		case Common::EVENT_RBUTTONDOWN:
 			_mouseClicked = true;
 			_mouseButtons = 1;
-			_rightMousePressed = event.type == Common::EVENT_RBUTTONDOWN;
 			_mouseMoved = true;
+			if (event.type == Common::EVENT_RBUTTONDOWN) {
+				_rightMousePressed = true;
+				_mouseStatus |= 2;
+			} else {
+				_mouseStatus |= 1;
+			}
 			return;
 		case Common::EVENT_LBUTTONUP:
 		case Common::EVENT_RBUTTONUP:
@@ -138,6 +141,11 @@ void EventsManager::pollEvents() {
 			_mouseReleased = true;
 			_mouseMoved = true;
 			_rightMousePressed = false;
+			if (event.type == Common::EVENT_RBUTTONUP) {
+				_mouseStatus &= ~2;
+			} else {
+				_mouseStatus &= ~1;
+			}
 			return;
 		case Common::EVENT_MOUSEMOVE:
 			_mousePos = event.mouse;
@@ -205,7 +213,7 @@ void EventsManager::waitForNextFrame() {
 
 void EventsManager::initVars() {
 	_mousePos = Common::Point(-1, -1);
-	_vD4 = _vCC;
+	_mouseStatusCopy = _mouseStatus;
 	_vD2 = _vD8 = 0;
 }
 
diff --git a/engines/mads/events.h b/engines/mads/events.h
index 3b5820a..529581c 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -24,6 +24,8 @@
 #define MADS_EVENTS_H
 
 #include "common/scummsys.h"
+#include "common/events.h"
+#include "common/stack.h"
 #include "mads/assets.h"
 #include "mads/sprites.h"
 
@@ -59,12 +61,12 @@ public:
 	bool _mouseReleased;
 	byte _mouseButtons;
 	bool _rightMousePressed;
-	bool _keyPressed;
-	int _vCC;
+	int _mouseStatus;
 	int _vD2;
-	int _vD4;
+	int _mouseStatusCopy;
 	bool _mouseMoved;
 	int _vD8;
+	Common::Stack<Common::Event> _pendingKeys;
 public:
 	/**
 	 * Constructor
@@ -142,6 +144,11 @@ public:
 	uint32 getFrameCounter() const { return _frameCounter; }
 
 	void initVars();
+
+	/**
+	 * Returns true if there's any pending keys to be processed 
+	 */
+	bool isKeyPressed() const { return !_pendingKeys.empty(); }
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index fd02941..f790341 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -60,6 +60,7 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 	_triggerMode = KERNEL_TRIGGER_PARSER;
 	_triggerSetupMode = KERNEL_TRIGGER_DAEMON;
 	_winStatus = 0;
+	_widepipeCtr = 0;
 
 	// Load the inventory object list
 	_objects.load();
@@ -379,4 +380,26 @@ Common::StringArray Game::getMessage(uint32 id) {
 	error("Invalid message Id specified");
 }
 
+static const char *const DEBUG_STRING = "WIDEPIPE";
+
+void Game::handleKeypress(const Common::Event &event) {
+	if (event.kbd.flags & Common::KBD_CTRL) {
+		if (_widepipeCtr == 8) {
+			// Implement original game cheating keys here someday
+		} else {
+			if (event.kbd.keycode == (Common::KEYCODE_a +
+					(DEBUG_STRING[_widepipeCtr] - 'a'))) {
+				if (++_widepipeCtr == 8) {
+					MessageDialog *dlg = new MessageDialog(_vm, 2,
+						"CHEATING ENABLED", "(for your convenience).");
+					dlg->show();
+					delete dlg;
+				}
+			}
+		}
+	}
+
+	warning("TODO: handleKeypress - %d", (int)event.kbd.keycode);
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 3216da3..296bbcd 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -78,6 +78,7 @@ protected:
 	bool _quoteEmergency;
 	bool _vocabEmergency;
 	bool _anyEmergency;
+	int _widepipeCtr;
 
 	/**
 	 * Constructor
@@ -166,6 +167,11 @@ public:
 	void loadQuoteRange(int startNum, int endNum) {}
 	void loadQuoteSet(...) {}
 	void loadQuote(int quoteNum) {}
+
+	/**
+	* Handle a keyboard event
+	*/
+	void handleKeypress(const Common::Event &event);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 871e104..13019d5 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -78,11 +78,12 @@ bool CopyProtectionDialog::show() {
 	_vm->_events->showCursor();
 
 	// TODO: Replace with text input
-	while (!_vm->shouldQuit() && !_vm->_events->_keyPressed &&
+	while (!_vm->shouldQuit() && !_vm->_events->isKeyPressed() &&
 			!_vm->_events->_mouseClicked) {
 		_vm->_events->delay(1);
 	}
 
+	_vm->_events->_pendingKeys.clear();
 	return true;
 }
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index ac57e0b..8cb5fbc 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -509,7 +509,17 @@ void Scene::doSceneStep() {
 }
 
 void Scene::checkKeyboard() {
-	warning("TODO: Scene::checkKeyboard");
+	if (_vm->_events->isKeyPressed()) {
+		Common::Event evt = _vm->_events->_pendingKeys.pop();
+		_vm->_game->handleKeypress(evt);
+	}
+
+	if ((_vm->_events->_mouseStatus & 3) == 3 && _vm->_game->_player._stepEnabled) {
+		_reloadSceneFlag = true;
+		_vm->_dialogs->_pendingDialog = DIALOG_GAME_MENU;
+		_action.clear();
+		_action._selectedAction = 0;
+	}
 }
 
 void Scene::loadAnimation(const Common::String &resName, int abortTimers) {
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index f449ede..a49692d 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -71,6 +71,9 @@ private:
 	 */
 	void doSceneStep();
 
+	/**
+	 * Checks whether there's a pending keypress, and if so handles it.
+	 */
 	void checkKeyboard();
 
 	/**
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 78980fe..5553f61 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -313,7 +313,7 @@ void ScreenObjects::check(bool scanFlag) {
 		}
 
 		//_released = _vm->_events->_mouseReleased;
-		if (_vm->_events->_vD2 || (_vm->_easyMouse && !_vm->_events->_vD4))
+		if (_vm->_events->_vD2 || (_vm->_easyMouse && !_vm->_events->_mouseStatusCopy))
 			scene._userInterface._category = _category;
 
 		if (!_vm->_events->_mouseButtons || _vm->_easyMouse) {
@@ -387,9 +387,9 @@ void ScreenObjects::checkScroller() {
 
 	userInterface._scrollerY = 0;
 	
-	if ((_category == CAT_INV_SCROLLER || (_scrollerY == 3 && _vm->_events->_vD4))
-			&& (_vm->_events->_vD4 || _vm->_easyMouse)) {
-		if ((_vm->_events->_vD2 || (_vm->_easyMouse && !_vm->_events->_vD4))
+	if ((_category == CAT_INV_SCROLLER || (_scrollerY == 3 && _vm->_events->_mouseStatusCopy))
+			&& (_vm->_events->_mouseStatusCopy || _vm->_easyMouse)) {
+		if ((_vm->_events->_vD2 || (_vm->_easyMouse && !_vm->_events->_mouseStatusCopy))
 				&& _category == CAT_INV_SCROLLER) {
 			_currentDescId = _newDescId;
 		}


Commit: 21a0e38f34324423e0f571ccb37a800737cd78d2
    https://github.com/scummvm/scummvm/commit/21a0e38f34324423e0f571ccb37a800737cd78d2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-08T22:21:45-04:00

Commit Message:
MADS: Resolve some old TODOs

Changed paths:
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/player.h
    engines/mads/scene.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index f790341..eb7ba62 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -309,10 +309,6 @@ void Game::initSection(int sectionNumber) {
 		CURSOR_ARROW : CURSOR_WAIT);
 }
 
-void Game::loadResourceSequence(const Common::String prefix, int v) {
-	warning("TODO: loadResourceSequence");
-}
-
 void Game::loadQuotes() {
 	File f("*QUOTES.DAT");
 
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 296bbcd..5659366 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -90,8 +90,6 @@ protected:
 	 */
 	void initSection(int sectionNumber);
 
-	void loadResourceSequence(const Common::String prefix, int v);
-
 	//@{
 	/** @name Virtual Method list */
 
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 69c896a..d8b00bc 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -232,8 +232,8 @@ void GameNebular::initialiseGlobals() {
 	_player._facing = FACING_NORTH;
 	_player._turnToFacing = FACING_NORTH;
 
-	loadResourceSequence("RXM", 1);
-	loadResourceSequence("ROX", 1);
+	Player::preloadSequences("RXM", 1);
+	Player::preloadSequences("ROX", 1);
 }
 
 void GameNebular::setSectionHandler() {
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 8315206..6df1159 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -210,6 +210,10 @@ public:
 	* Delete any sprites used by the player
 	*/
 	void releasePlayerSprites();
+
+	static void preloadSequences(const Common::String &prefix, int level) {
+		// No implementation in ScummVM
+	}
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 8cb5fbc..76263bd 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -168,7 +168,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 
 	_userInterface.setup(_vm->_game->_screenObjects._inputMode);
 
-	warning("TODO: showMouse");
+	_vm->_events->showCursor();
 
 	warning("TODO: inventory_anim_allocate");
 }


Commit: 09adb571d35c45941246bdce5db895d9d81fd59c
    https://github.com/scummvm/scummvm/commit/09adb571d35c45941246bdce5db895d9d81fd59c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-08T23:01:46-04:00

Commit Message:
MADS: Cleanup of verb/preposition flags handling

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h
    engines/mads/inventory.cpp
    engines/mads/inventory.h
    engines/mads/scene.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index a84c329..8cbc404 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -105,7 +105,8 @@ void MADSAction::set() {
 		// Two 'look' actions in succession, so the action becomes 'Look around'
 		_statusText = kLookAroundStr;
 	} else {
-		if ((_commandSource == ACTIONMODE_OBJECT) && (_selectedRow >= 0) && (_flags1 == 2) && (_flags2 == 0)) {
+		if ((_commandSource == ACTIONMODE_OBJECT) && (_selectedRow >= 0) 
+				&& (_verbType == VERB_THAT) && (_prepType == PREP_NONE)) {
 			// Use/to action
 			int invIndex = userInterface._selectedInvIndex;
 			InventoryObject &objEntry = _vm->_game->_objects.getItem(invIndex);
@@ -142,7 +143,7 @@ void MADSAction::set() {
 			}
 
 			// Handling for if a hotspot has been selected/highlighted
-			if ((_hotspotId >= 0) && (_selectedRow >= 0) && (_articleNumber > 0) && (_flags1 == 2)) {
+			if ((_hotspotId >= 0) && (_selectedRow >= 0) && (_articleNumber > 0) && (_verbType == VERB_THAT)) {
 				flag = true;
 
 				_statusText += kArticleList[_articleNumber];
@@ -379,8 +380,8 @@ void MADSAction::checkActionAtMousePos() {
 				if (userInterface._selectedActionIndex >= 0) {
 					_commandSource = ACTIONMODE_VERB;
 					_selectedRow = userInterface._selectedActionIndex;
-					_flags1 = scene._verbList[_selectedRow]._action1;
-					_flags2 = scene._verbList[_selectedRow]._action2;
+					_verbType = scene._verbList[_selectedRow]._verbType;
+					_prepType = scene._verbList[_selectedRow]._prepType;
 					_interAwaiting = AWAITING_THIS;
 				} else if (userInterface._selectedItemVocabIdx >= 0) {
 					_commandSource = ACTIONMODE_OBJECT;
@@ -388,13 +389,14 @@ void MADSAction::checkActionAtMousePos() {
 					int objectId = _vm->_game->_objects._inventoryList[_selectedRow];
 					InventoryObject &invObject = _vm->_game->_objects[objectId];
 
-					_flags1 = invObject._vocabList[_selectedRow - 1]._actionFlags1;
-					_flags2 = invObject._vocabList[_selectedRow - 1]._actionFlags2;
+					_verbType = invObject._vocabList[_selectedRow - 1]._verbType;
+					_prepType = invObject._vocabList[_selectedRow - 1]._prepType;
 					_mainObjectSource = ACTIONMODE2_2;
 					_hotspotId = userInterface._selectedInvIndex;
-					_articleNumber = _flags2;
+					_articleNumber = _prepType;
 
-					if ((_flags1 == 1 && _flags2 == 0) || (_flags1 == 2 && _flags2 != 0))
+					if ((_verbType == VERB_THIS && _prepType == PREP_NONE) || 
+							(_verbType == VERB_THAT && _prepType != PREP_NONE))
 						_interAwaiting = AWAITING_RIGHT_MOUSE;
 					else
 						_interAwaiting = AWAITING_THAT;
@@ -412,8 +414,8 @@ void MADSAction::checkActionAtMousePos() {
 			_commandSource = ACTIONMODE_VERB;
 			_selectedRow = _pickedWord;
 			if (_selectedRow >= 0) {
-				_flags1 = scene._verbList[_selectedRow]._action1;
-				_flags2 = scene._verbList[_selectedRow]._action2;
+				_verbType = scene._verbList[_selectedRow]._verbType;
+				_prepType = scene._verbList[_selectedRow]._prepType;
 			}
 			break;
 
@@ -427,13 +429,13 @@ void MADSAction::checkActionAtMousePos() {
 				int objectId = _vm->_game->_objects._inventoryList[_selectedRow];
 				InventoryObject &invObject = _vm->_game->_objects[objectId];
 
-				_flags1 = invObject._vocabList[_selectedRow - 2]._actionFlags1;
-				_flags2 = invObject._vocabList[_selectedRow - 2]._actionFlags2;
+				_verbType = invObject._vocabList[_selectedRow - 2]._verbType;
+				_prepType = invObject._vocabList[_selectedRow - 2]._prepType;
 				_hotspotId = userInterface._selectedInvIndex;
 				_mainObjectSource = ACTIONMODE2_2;
 
-				if (_flags1 == 2)
-					_articleNumber = _flags2;
+				if (_verbType == VERB_THAT)
+					_articleNumber = _prepType;
 			}
 			break;
 
@@ -516,7 +518,7 @@ void MADSAction::leftClick() {
 		switch (userInterface._category) {
 		case CAT_COMMAND:
 			if (_selectedRow >= 0) {
-				if (!_flags1) {
+				if (_verbType == VERB_ONLY) {
 					_selectedAction = -1;
 				}
 				else {
@@ -535,17 +537,15 @@ void MADSAction::leftClick() {
 
 		case CAT_INV_VOCAB:
 			if (_selectedRow >= 0) {
-				if (_flags1 != 1 || _flags2 != 0) {
-					if (_flags1 != 2 || _flags2 == 0) {
+				if (_verbType != VERB_THIS || _prepType != PREP_NONE) {
+					if (_verbType != VERB_THAT || _prepType == PREP_NONE) {
 						_interAwaiting = AWAITING_THAT;
-						_articleNumber = _flags2;
-					}
-					else {
-						_articleNumber = _flags2;
+						_articleNumber = _prepType;
+					} else {
+						_articleNumber = _prepType;
 						_selectedAction = -1;
 					}
-				}
-				else {
+				} else {
 					_selectedAction = -1;
 				}
 
@@ -581,8 +581,8 @@ void MADSAction::leftClick() {
 		case CAT_HOTSPOT:
 		case CAT_INV_ANIM:
 			if (_hotspotId >= 0) {
-				if (_flags2) {
-					_articleNumber = _flags2;
+				if (_prepType) {
+					_articleNumber = _prepType;
 					_interAwaiting = AWAITING_THAT;
 				}
 				else {
diff --git a/engines/mads/action.h b/engines/mads/action.h
index b38e9c2..3b238c9 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -60,6 +60,12 @@ enum {
 	VERB_WALKTO = 13
 };
 
+enum VerbType { VERB_ONLY, VERB_THIS, VERB_THAT };
+
+enum PrepType {
+	PREP_NONE, PREP_WITH, PREP_TO, PREP_AT, PREP_FROM, PREP_ON, PREP_IN, 
+	PREP_UNDER, PREP_BEHIND, PREP_RELATIONAL = -1
+};
 
 class MADSEngine;
 
@@ -91,7 +97,8 @@ private:
 	void startWalkingDirectly(int walkType);
 public:
 	ActionDetails _action, _activeAction;
-	int8 _flags1, _flags2;
+	VerbType _verbType;
+	PrepType _prepType;
 	int _commandSource;
 	int _mainObjectSource;
 	int _articleNumber;
diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index 89ca9f8..607179a 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -33,8 +33,8 @@ void InventoryObject::load(Common::SeekableReadStream &f) {
 	_vocabCount = f.readByte();
 	
 	for (int i = 0; i < 3; ++i) {
-		_vocabList[i]._actionFlags1 = f.readByte();
-		_vocabList[i]._actionFlags2 = f.readByte();
+		_vocabList[i]._verbType = (VerbType)f.readByte();
+		_vocabList[i]._prepType = (PrepType)f.readByte();
 		_vocabList[i]._vocabId = f.readUint16LE();
 	}
 
@@ -71,7 +71,7 @@ void InventoryObjects::setQuality(int objIndex, int id, const byte *p) {
 	// more of the engine is implemented
 	for (int i = 0; i < (int)size(); ++i) {
 		InventoryObject &obj = (*this)[i];
-		if (obj._vocabList[0]._actionFlags1 <= i)
+		if (obj._vocabList[0]._verbType <= i)
 			break;
 
 		if (obj._mutilateString[6 + i] == id) {
diff --git a/engines/mads/inventory.h b/engines/mads/inventory.h
index 13b8109..5c2f925 100644
--- a/engines/mads/inventory.h
+++ b/engines/mads/inventory.h
@@ -41,8 +41,8 @@ public:
 	int _article;
 	int _vocabCount;
 	struct {
-		int _actionFlags1;
-		int _actionFlags2;
+		VerbType _verbType;
+		PrepType _prepType;
 		int _vocabId;
 	} _vocabList[3];
 	char _mutilateString[10];	// ???
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 76263bd..02a066a 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -50,16 +50,16 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 	_layer = LAYER_GUI;
 	_lookFlag = false;
 
-	_verbList.push_back(VerbInit(VERB_LOOK, 2, 0));
-	_verbList.push_back(VerbInit(VERB_TAKE, 2, 0));
-	_verbList.push_back(VerbInit(VERB_PUSH, 2, 0));
-	_verbList.push_back(VerbInit(VERB_OPEN, 2, 0));
-	_verbList.push_back(VerbInit(VERB_PUT, 1, -1));
-	_verbList.push_back(VerbInit(VERB_TALKTO, 2, 0));
-	_verbList.push_back(VerbInit(VERB_GIVE, 1, 2));
-	_verbList.push_back(VerbInit(VERB_PULL, 2, 0));
-	_verbList.push_back(VerbInit(VERB_CLOSE, 2, 0));
-	_verbList.push_back(VerbInit(VERB_THROW, 1, 2));
+	_verbList.push_back(VerbInit(VERB_LOOK, VERB_THAT, PREP_NONE));
+	_verbList.push_back(VerbInit(VERB_TAKE, VERB_THAT, PREP_NONE));
+	_verbList.push_back(VerbInit(VERB_PUSH, VERB_THAT, PREP_NONE));
+	_verbList.push_back(VerbInit(VERB_OPEN, VERB_THAT, PREP_NONE));
+	_verbList.push_back(VerbInit(VERB_PUT, VERB_THIS, PREP_RELATIONAL));
+	_verbList.push_back(VerbInit(VERB_TALKTO, VERB_THAT, PREP_NONE));
+	_verbList.push_back(VerbInit(VERB_GIVE, VERB_THIS, PREP_TO));
+	_verbList.push_back(VerbInit(VERB_PULL, VERB_THAT, PREP_NONE));
+	_verbList.push_back(VerbInit(VERB_CLOSE, VERB_THAT, PREP_NONE));
+	_verbList.push_back(VerbInit(VERB_THROW, VERB_THIS, PREP_TO));
 }
 
 Scene::~Scene() {
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 73ca21d..e37aa43 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -60,11 +60,12 @@ enum {
 class VerbInit {
 public:
 	int _id;
-	int _action1;
-	int _action2;
+	VerbType _verbType;
+	PrepType _prepType;
 
 	VerbInit() {}
-	VerbInit(int id, int action1, int action2): _id(id), _action1(action1), _action2(action2) {}
+	VerbInit(int id, VerbType verbType, PrepType prepType): _id(id), 
+		_verbType(verbType), _prepType(prepType) {}
 };
 
 class SceneLogic {


Commit: e144e9810f7aad29575b98faad9fcc64a82d785d
    https://github.com/scummvm/scummvm/commit/e144e9810f7aad29575b98faad9fcc64a82d785d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-08T23:25:11-04:00

Commit Message:
MADS: Dropped old ActionMode enums in favour of ScrCategory

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h
    engines/mads/screen.h
    engines/mads/staticres.cpp
    engines/mads/staticres.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 8cbc404..b646ca5 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -47,10 +47,10 @@ MADSAction::MADSAction(MADSEngine *vm) : _vm(vm) {
 
 void MADSAction::clear() {
 	_interAwaiting = AWAITING_COMMAND;
-	_commandSource = ACTIONMODE_NONE;
-	_mainObjectSource = ACTIONMODE2_0;
-	_secondObjectSource = 0;
-	_recentCommandSource = 0;
+	_commandSource = CAT_NONE;
+	_mainObjectSource = CAT_NONE;
+	_secondObjectSource = CAT_NONE;
+	_recentCommandSource = CAT_NONE;
 	_articleNumber = 0;
 	_lookFlag = false;
 	_pointEstablished = 0;
@@ -94,7 +94,7 @@ void MADSAction::set() {
 	_action._objectNameId = -1;
 	_action._indirectObjectId = -1;
 
-	if (_commandSource == ACTIONMODE_TALK) {
+	if (_commandSource == CAT_TALK_ENTRY) {
 		// Handle showing the conversation selection. Rex at least doesn't actually seem to use this
 		if (_selectedRow >= 0) {
 			Common::String desc = userInterface._talkStrings[userInterface._talkIds[_selectedRow]];
@@ -105,7 +105,7 @@ void MADSAction::set() {
 		// Two 'look' actions in succession, so the action becomes 'Look around'
 		_statusText = kLookAroundStr;
 	} else {
-		if ((_commandSource == ACTIONMODE_OBJECT) && (_selectedRow >= 0) 
+		if ((_commandSource == CAT_INV_VOCAB) && (_selectedRow >= 0) 
 				&& (_verbType == VERB_THAT) && (_prepType == PREP_NONE)) {
 			// Use/to action
 			int invIndex = userInterface._selectedInvIndex;
@@ -122,7 +122,7 @@ void MADSAction::set() {
 		} else {
 			// Handling for if an action has been selected
 			if (_selectedRow >= 0) {
-				if (_commandSource == ACTIONMODE_VERB) {
+				if (_commandSource == CAT_COMMAND) {
 					// Standard verb action
 					_action._verbId = scene._verbList[_selectedRow]._id;
 				} else {
@@ -137,7 +137,7 @@ void MADSAction::set() {
 
 				if (_action._verbId == VERB_LOOK) {
 					// Add in the word 'add'
-					_statusText += kAtStr;
+					_statusText += kArticleList[PREP_AT];
 					_statusText += " ";
 				}
 			}
@@ -173,7 +173,7 @@ void MADSAction::set() {
 					}
 				}
 
-				if ((_mainObjectSource == ACTIONMODE2_2) || (_mainObjectSource == ACTIONMODE2_5)) {
+				if ((_mainObjectSource == CAT_INV_LIST) || (_mainObjectSource == CAT_INV_ANIM)) {
 					// Get name from given inventory object
 					InventoryObject &invObject = _vm->_game->_objects.getItem(_hotspotId);
 					_action._objectNameId = invObject._descId;
@@ -290,14 +290,14 @@ void MADSAction::startAction() {
 	_activeAction = _action;
 	_sentence = _statusText;
 
-	if ((_mainObjectSource == ACTIONMODE2_4) && (_secondObjectSource == 4))
+	if ((_mainObjectSource == CAT_HOTSPOT) && (_secondObjectSource == 4))
 		_savedFields._commandError = true;
 
 	player._needToWalk = false;
 	int hotspotId = -1;
 
 	if (!_savedFields._lookFlag && (_vm->_game->_screenObjects._inputMode != kInputConversation)) {
-		if (_savedFields._mainObjectSource == ACTIONMODE2_4)
+		if (_savedFields._mainObjectSource == CAT_HOTSPOT)
 			hotspotId = _savedFields._mainObject;
 		else if (_secondObjectSource == 4)
 			hotspotId = _savedFields._secondObject;
@@ -308,7 +308,7 @@ void MADSAction::startAction() {
 				startWalkingDirectly(hs._feetPos.x);
 			} else if (hs._feetPos.x == 0) {
 				player._prepareWalkFacing = hs._facing;
-			} else if (_savedFields._commandSource == ACTIONMODE_NONE || hs._cursor >= CURSOR_WAIT) {
+			} else if (_savedFields._commandSource == CAT_NONE || hs._cursor >= CURSOR_WAIT) {
 				player._needToWalk = true;
 				player._prepareWalkPos = hs._feetPos;
 			}
@@ -324,7 +324,7 @@ void MADSAction::startAction() {
 		if (hs._feetPos.x == -1 || hs._feetPos.x == -3) {
 			startWalkingDirectly(hs._feetPos.x);
 		} else if (hs._feetPos.x >= 0) {
-			if (_savedFields._commandSource == ACTIONMODE_NONE || hs._cursor < CURSOR_WAIT) {
+			if (_savedFields._commandSource == CAT_NONE || hs._cursor < CURSOR_WAIT) {
 				player._needToWalk = true;
 				player._prepareWalkPos = hs._feetPos;
 			}
@@ -378,20 +378,20 @@ void MADSAction::checkActionAtMousePos() {
 		case CAT_INV_ANIM:
 			if (_interAwaiting != AWAITING_THAT) {
 				if (userInterface._selectedActionIndex >= 0) {
-					_commandSource = ACTIONMODE_VERB;
+					_commandSource = CAT_COMMAND;
 					_selectedRow = userInterface._selectedActionIndex;
 					_verbType = scene._verbList[_selectedRow]._verbType;
 					_prepType = scene._verbList[_selectedRow]._prepType;
 					_interAwaiting = AWAITING_THIS;
 				} else if (userInterface._selectedItemVocabIdx >= 0) {
-					_commandSource = ACTIONMODE_OBJECT;
+					_commandSource = CAT_INV_VOCAB;
 					_selectedRow = userInterface._selectedItemVocabIdx;
 					int objectId = _vm->_game->_objects._inventoryList[_selectedRow];
 					InventoryObject &invObject = _vm->_game->_objects[objectId];
 
 					_verbType = invObject._vocabList[_selectedRow - 1]._verbType;
 					_prepType = invObject._vocabList[_selectedRow - 1]._prepType;
-					_mainObjectSource = ACTIONMODE2_2;
+					_mainObjectSource = CAT_INV_LIST;
 					_hotspotId = userInterface._selectedInvIndex;
 					_articleNumber = _prepType;
 
@@ -411,7 +411,7 @@ void MADSAction::checkActionAtMousePos() {
 		_articleNumber = 0;
 		switch (userInterface._category) {
 		case CAT_COMMAND:
-			_commandSource = ACTIONMODE_VERB;
+			_commandSource = CAT_COMMAND;
 			_selectedRow = _pickedWord;
 			if (_selectedRow >= 0) {
 				_verbType = scene._verbList[_selectedRow]._verbType;
@@ -420,11 +420,11 @@ void MADSAction::checkActionAtMousePos() {
 			break;
 
 		case CAT_INV_VOCAB:
-			_commandSource = ACTIONMODE_OBJECT;
+			_commandSource = CAT_INV_VOCAB;
 			_selectedRow = _pickedWord;
 			if (_selectedRow < 0) {
 				_hotspotId = -1;
-				_mainObjectSource = ACTIONMODE2_0;
+				_mainObjectSource = CAT_NONE;
 			} else {
 				int objectId = _vm->_game->_objects._inventoryList[_selectedRow];
 				InventoryObject &invObject = _vm->_game->_objects[objectId];
@@ -432,7 +432,7 @@ void MADSAction::checkActionAtMousePos() {
 				_verbType = invObject._vocabList[_selectedRow - 2]._verbType;
 				_prepType = invObject._vocabList[_selectedRow - 2]._prepType;
 				_hotspotId = userInterface._selectedInvIndex;
-				_mainObjectSource = ACTIONMODE2_2;
+				_mainObjectSource = CAT_INV_LIST;
 
 				if (_verbType == VERB_THAT)
 					_articleNumber = _prepType;
@@ -441,13 +441,13 @@ void MADSAction::checkActionAtMousePos() {
 
 		case CAT_HOTSPOT:
 			_selectedRow = -1;
-			_commandSource = ACTIONMODE_NONE;
-			_mainObjectSource = ACTIONMODE2_4;
+			_commandSource = CAT_NONE;
+			_mainObjectSource = CAT_HOTSPOT;
 			_hotspotId = _pickedWord;
 			break;
 
 		case CAT_TALK_ENTRY:
-			_commandSource = ACTIONMODE_TALK;
+			_commandSource = CAT_TALK_ENTRY;
 			_selectedRow = _pickedWord;
 			break;
 
@@ -556,7 +556,7 @@ void MADSAction::leftClick() {
 
 		case CAT_HOTSPOT:
 			_recentCommand = -1;
-			_recentCommandSource = 0;
+			_recentCommandSource = CAT_NONE;
 
 			if (_vm->_events->currentPos().y < MADS_SCENE_HEIGHT) {
 				scene._customDest = _vm->_events->currentPos() + scene._posAdjust;
diff --git a/engines/mads/action.h b/engines/mads/action.h
index 3b238c9..6b3f1ca 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -28,9 +28,6 @@
 
 namespace MADS {
 
-enum { ACTIONMODE_NONE = 0, ACTIONMODE_VERB = 1, ACTIONMODE_OBJECT = 3, ACTIONMODE_TALK = 6 };
-enum { ACTIONMODE2_0 = 0, ACTIONMODE2_2 = 2, ACTIONMODE2_4 = 4, ACTIONMODE2_5 = 5 };
-
 enum TriggerMode { 
 	KERNEL_TRIGGER_PARSER = 0,		// Triggers parser
 	KERNEL_TRIGGER_DAEMON = 1,		// Triggers step/daemon code
@@ -67,6 +64,12 @@ enum PrepType {
 	PREP_UNDER, PREP_BEHIND, PREP_RELATIONAL = -1
 };
 
+enum ScrCategory {
+	CAT_NONE = 0, CAT_COMMAND = 1, CAT_INV_LIST = 2, CAT_INV_VOCAB = 3,
+	CAT_HOTSPOT = 4, CAT_INV_ANIM = 5, CAT_TALK_ENTRY = 6, CAT_INV_SCROLLER = 7,
+	CAT_12 = 12
+};
+
 class MADSEngine;
 
 struct ActionDetails {
@@ -97,10 +100,6 @@ private:
 	void startWalkingDirectly(int walkType);
 public:
 	ActionDetails _action, _activeAction;
-	VerbType _verbType;
-	PrepType _prepType;
-	int _commandSource;
-	int _mainObjectSource;
 	int _articleNumber;
 	bool _lookFlag;
 	int _selectedRow;
@@ -111,10 +110,13 @@ public:
 	ActionSavedFields _savedFields;
 	Common::String _sentence;
 
-	// Unknown fields
+	VerbType _verbType;
+	PrepType _prepType;
+	ScrCategory _commandSource;
+	ScrCategory _mainObjectSource;
 	int16 _secondObject;
-	int16 _secondObjectSource;
-	int16 _recentCommandSource;
+	ScrCategory _secondObjectSource;
+	ScrCategory _recentCommandSource;
 	bool _pointEstablished;
 	int16 _recentCommand;
 	InterAwaiting _interAwaiting;
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index 57b53df..11b8134 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -26,18 +26,13 @@
 #include "common/scummsys.h"
 #include "common/array.h"
 #include "mads/msurface.h"
+#include "mads/action.h"
 
 namespace MADS {
 
 #define MADS_SCREEN_WIDTH 320
 #define MADS_SCREEN_HEIGHT 200
 
-enum ScrCategory {
-	CAT_NONE = 0, CAT_COMMAND = 1, CAT_INV_LIST = 2, CAT_INV_VOCAB = 3,
-	CAT_HOTSPOT = 4, CAT_INV_ANIM = 5, CAT_TALK_ENTRY = 6, CAT_INV_SCROLLER = 7,
-	CAT_12 = 12
-};
-
 enum Layer {
 	LAYER_GUI = 19
 };
diff --git a/engines/mads/staticres.cpp b/engines/mads/staticres.cpp
index 92d2740..396e5a1 100644
--- a/engines/mads/staticres.cpp
+++ b/engines/mads/staticres.cpp
@@ -35,7 +35,6 @@ const char *const kCheatingEnabledDesc[3] = {
 	nullptr
 };
 
-const char *const kAtStr = "at";
 const char *const kLookAroundStr = "Look around";
 const char *const kToStr = "to ";
 const char *const kUseStr = "Use ";
diff --git a/engines/mads/staticres.h b/engines/mads/staticres.h
index b4132c8..0680455 100644
--- a/engines/mads/staticres.h
+++ b/engines/mads/staticres.h
@@ -29,7 +29,6 @@ extern const char *const kArticleList[9];
 
 extern const char *const kCheatingEnabledDesc[3];
 
-extern const char *const kAtStr;
 extern const char *const kLookAroundStr;
 extern const char *const kToStr;
 extern const char *const kUseStr;


Commit: 6c2c752d055a448dff4cc42e3504be8550f4e72f
    https://github.com/scummvm/scummvm/commit/6c2c752d055a448dff4cc42e3504be8550f4e72f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-08T23:37:16-04:00

Commit Message:
MADS: Fix selecting inventory vocab actions in the user interface

Changed paths:
    engines/mads/action.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index b646ca5..f3e1d2d 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -426,11 +426,9 @@ void MADSAction::checkActionAtMousePos() {
 				_hotspotId = -1;
 				_mainObjectSource = CAT_NONE;
 			} else {
-				int objectId = _vm->_game->_objects._inventoryList[_selectedRow];
-				InventoryObject &invObject = _vm->_game->_objects[objectId];
-
-				_verbType = invObject._vocabList[_selectedRow - 2]._verbType;
-				_prepType = invObject._vocabList[_selectedRow - 2]._prepType;
+				InventoryObject &invObject = _vm->_game->_objects.getItem(userInterface._selectedInvIndex);
+				_verbType = invObject._vocabList[_selectedRow + 1]._verbType;
+				_prepType = invObject._vocabList[_selectedRow + 1]._prepType;
 				_hotspotId = userInterface._selectedInvIndex;
 				_mainObjectSource = CAT_INV_LIST;
 


Commit: 57bd5e0683638869e485b1855345b3a95f40c2da
    https://github.com/scummvm/scummvm/commit/57bd5e0683638869e485b1855345b3a95f40c2da
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-09T10:41:33+02:00

Commit Message:
MADS: Some refactoring, implement Scene 211

Changed paths:
    engines/mads/hotspots.cpp
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h
    engines/mads/sequence.h



diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
index baae4a9..a5b56ee 100644
--- a/engines/mads/hotspots.cpp
+++ b/engines/mads/hotspots.cpp
@@ -59,8 +59,7 @@ int DynamicHotspots::add(int descId, int vocabId, int seqIndex, const Common::Re
 	_entries[idx]._descId = descId;
 	_entries[idx]._seqIndex = seqIndex;
 	_entries[idx]._bounds = bounds;
-	_entries[idx]._feetPos.x = -3;
-	_entries[idx]._feetPos.y = 0;
+	_entries[idx]._feetPos = Common::Point(-3, 0);
 	_entries[idx]._facing = FACING_NONE;
 	_entries[idx]._vocabId = vocabId;
 	_entries[idx]._articleNumber = 6;
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 67a75c3..a3a1433 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -67,6 +67,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene209(vm);
 	case 210:
 		return new Scene210(vm);
+	case 211:
+		return new Scene211(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index b7b2b80..5c966cf 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -121,10 +121,9 @@ void Scene201::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 
-	Scene &scene = _vm->_game->_scene;
-	scene.addActiveVocab(NOUN_15F);
-	scene.addActiveVocab(NOUN_487);
-	scene.addActiveVocab(NOUN_D);
+	_scene->addActiveVocab(NOUN_15F);
+	_scene->addActiveVocab(NOUN_487);
+	_scene->addActiveVocab(NOUN_D);
 }
 
 void Scene201::enter() {
@@ -331,13 +330,12 @@ void Scene202::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 
-	Scene &scene = _vm->_game->_scene;
-	scene.addActiveVocab(NOUN_C7);
-	scene.addActiveVocab(NOUN_4E);
-	scene.addActiveVocab(NOUN_D);
-	scene.addActiveVocab(NOUN_2C);
-	scene.addActiveVocab(NOUN_140);
-	scene.addActiveVocab(NOUN_1C9);
+	_scene->addActiveVocab(NOUN_C7);
+	_scene->addActiveVocab(NOUN_4E);
+	_scene->addActiveVocab(NOUN_D);
+	_scene->addActiveVocab(NOUN_2C);
+	_scene->addActiveVocab(NOUN_140);
+	_scene->addActiveVocab(NOUN_1C9);
 }
 
 void Scene202::enter() {
@@ -1181,11 +1179,7 @@ void Scene205::step() {
 		warning("TODO: sub7178C()");
 
 		if (_globals._frameTime >= _chickenTime) {
-			warning("minVal = 1 + sub7176C();");
-			int minVal = 1;
-
-			warning("TODO: sub717B2(100, minVal);");
-//			if (sub717B2(100, minVal)) {
+			warning("TODO: if (sub717B2(100, 1 + sub7176C()))");
 				_vm->_sound->command(28);
 //			}
 			_chickenTime = _globals._frameTime + 2;
@@ -2808,7 +2802,7 @@ void Scene209::step() {
 		switch (_game._trigger) {
 		case 228:
 			_game._player._visible = false;
-			_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+			_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._spriteIndexes[17], 1, 7);
 			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(116, 131));
 			_scene->_sequences.setDepth(_globals._spriteIndexes[17], 4);
@@ -4220,7 +4214,7 @@ void Scene210::actions() {
 			_scene->_sequences.remove(_globals._spriteIndexes[8]);
 			_game._player._stepEnabled = false;
 			_game._player._facing = FACING_NORTH;
-			_globals._spriteIndexes[8] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[1], false, 12, 0, 0, 1);
+			_globals._spriteIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 12, 0, 0, 1);
 			_scene->_sequences.setDepth(_globals._spriteIndexes[8], 5);
 			_scene->_sequences.addSubEntry(_globals._spriteIndexes[8], SM_0, 0, 1);
 			_game._player._stepEnabled = false;
@@ -4332,5 +4326,271 @@ void Scene210::actions() {
 	}
 }
 
+/*------------------------------------------------------------------------*/
+
+void Scene211::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+
+	_scene->addActiveVocab(0x144);
+}
+
+void Scene211::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites("*SC002Z2", false);
+	_wakeFl = false;
+
+	if (_scene->_priorSceneId == 210)
+		_game._player._playerPos = Common::Point(25, 148);
+	else if (_scene->_priorSceneId == 205) {
+		_game._player._playerPos = Common::Point(49, 133);
+		_game._player._facing = FACING_WEST;
+		_wakeFl = true;
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_scene->loadAnimation(formAnimName('A', -1), 100);
+		_scene->_activeAnimation->setCurrentFrame(169);
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(310, 31);
+		_game._player._facing = FACING_SOUTHWEST;
+	}
+
+	if (_vm->getRandomNumber(1, 8) == 1) {
+		_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(202, 126));
+		_scene->_sequences.setDepth(_globals._spriteIndexes[17], 8);
+		_scene->_sequences.sub70C52(_globals._spriteIndexes[17], SM_FRAME_INDEX, -200, 0);
+		_scene->_dynamicHotspots.add(324, 13, _globals._spriteIndexes[17], Common::Rect(1, 1, 41, 10));
+	}
+
+	if (_scene->_roomChanged)
+		_game._objects.addToInventory(OBJ_BINOCULARS);
+
+	_vm->_palette->setEntry(252, 63, 44, 30);
+	_vm->_palette->setEntry(253, 63, 20, 22);
+	_game.loadQuoteSet(0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 1, 0);
+
+	if (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY)
+		warning("sub71704(0x2, 0x0, 0x36, 0x0, 0x1E, 0xD, 2, 0xFDFC, 0x3C, 0x97, 0x98, 0x99, 0x9A, 0);");
+
+	_monkeyTime = _globals._frameTime;
+	_scrollY = 30;
+
+	_ambushFl = false;
+	_monkeyFrame = 0;
+
+	sceneEntrySound();
+}
+
+void Scene211::step() {
+	if (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY) {
+		warning("TODO: sub7178C()");
+
+		if (!_ambushFl && !_wakeFl && (_globals._frameTime >= _monkeyTime)) {
+			warning("if (sub717B2(80, 1 + sub7176C())) {");
+				_vm->_sound->command(18);
+			// }
+			_monkeyTime = _globals._frameTime + 2;
+		}
+
+		if ((_game._player._playerPos == Common::Point(52, 132)) && (_game._player._facing == FACING_WEST) && !_game._player._moving && 
+			(_game._trigger || !_ambushFl)) {
+			switch (_game._trigger) {
+			case 0:
+				if (_game._objects.isInInventory(OBJ_BINOCULARS)) {
+					_ambushFl = true;
+					_monkeyFrame = 0;
+					_game._player._stepEnabled = false;
+					_game._player._visible = false;
+					_scene->_kernelMessages.reset();
+					_scene->loadAnimation(formAnimName('A', -1), 90);
+					_vm->_sound->command(19);
+					int count = (int)_game._objects._inventoryList.size();
+					for (int idx = 0; idx < count; idx++) {
+						if ((_game._objects._inventoryList[idx] == OBJ_BINOCULARS) && (_scene->_userInterface._selectedInvIndex != idx))
+							_scene->_userInterface.selectObject(idx);
+					}
+				}
+				break;
+
+			case 90:
+				_vm->_sound->command(10);
+				_game._player._stepEnabled = true;
+				_game._player._visible = true;
+				_game._player._playerPos = Common::Point(49, 133);
+				_ambushFl = false;
+				_globals[kMonkeyStatus] = MONKEY_HAS_BINOCULARS;
+				break;
+			}
+		}
+	}
+
+	if (_ambushFl && (_scene->_activeAnimation->getCurrentFrame() > _monkeyFrame)) {
+		_monkeyFrame = _scene->_activeAnimation->getCurrentFrame();
+		switch (_monkeyFrame) {
+		case 2: {
+			int msgIndex = _scene->_kernelMessages.add(Common::Point(12, 4), 0xFDFC, 0, 0, 60, _game.getQuote(157));
+			_scene->_kernelMessages.setQuoted(msgIndex, 2, true);
+			}
+			break;
+
+		case 12: {
+			int msgIndex = _scene->_kernelMessages.add(Common::Point(35, 20), 0xFDFC, 0, 0, 60, _game.getQuote(155));
+			_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+			}
+			break;
+
+		case 42: {
+			int msgIndex = _scene->_kernelMessages.add(Common::Point(60, 45), 0xFDFC, 0, 0, 60, _game.getQuote(156));
+			_scene->_kernelMessages.setQuoted(msgIndex, 6, true);
+			}
+			break;
+
+		case 73:
+			_scene->_kernelMessages.add(Common::Point(102, 95), 0xFDFC, 32, 0, 75, _game.getQuote(157));
+			break;
+
+		case 90: {
+			int msgIndex = _scene->_kernelMessages.add(Common::Point(102, 95), 0xFDFC, 32, 0, 60, _game.getQuote(158));
+			_scene->_kernelMessages.setQuoted(msgIndex, 6, true);
+			}
+			break;
+
+		case 97:
+			_scene->_userInterface.selectObject(-1);
+			_game._objects.removeFromInventory(OBJ_BINOCULARS, 1);
+			break;
+
+		case 177: {
+			int msgIndex = _scene->_kernelMessages.add(Common::Point(63, _scrollY), 0x1110, 0, 0, 180, _game.getQuote(161));
+			_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+			_scrollY += 14;
+			}
+			break;
+
+		case 181: {
+			int msgIndex = _scene->_kernelMessages.add(Common::Point(63, _scrollY), 0x1110, 0, 0, 180, _game.getQuote(162));
+			_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+			_scrollY += 14;
+			}
+			break;
+
+		case 188: {
+			int msgIndex = _scene->_kernelMessages.add(Common::Point(63, _scrollY), 0x1110, 0, 0, 180, _game.getQuote(163));
+			_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+			_scrollY += 14;
+			}
+			break;
+
+		case 200: {
+			int msgIndex = _scene->_kernelMessages.add(Common::Point(63, _scrollY), 0x1110, 0, 0, 180, _game.getQuote(164));
+			_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+			_scrollY += 14;
+			}
+			break;
+		}
+	}
+
+	if (_wakeFl) {
+		if (_game._trigger == 100) {
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			_wakeFl = false;
+		}
+
+		if (_scene->_activeAnimation->getCurrentFrame() > _monkeyFrame) {
+			_monkeyFrame = _scene->_activeAnimation->getCurrentFrame();
+			switch (_scene->_activeAnimation->getCurrentFrame()) {
+			case 177: {
+				int msgIndex = _scene->_kernelMessages.add(Common::Point(63, _scrollY), 0x1110, 0, 0, 180, _game.getQuote(165));
+				_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+				_scrollY += 14;
+				}
+				break;
+
+			case 181: {
+				int msgIndex = _scene->_kernelMessages.add(Common::Point(63, _scrollY), 0x1110, 0, 0, 180, _game.getQuote(166));
+				_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+				_scrollY += 14;
+				}
+				break;
+
+			case 188: {
+				int msgIndex = _scene->_kernelMessages.add(Common::Point(63, _scrollY), 0x1110, 0, 0, 180, _game.getQuote(167));
+				_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+				_scrollY += 14;
+				}
+				break;
+
+			case 200: {
+				int msgIndex = _scene->_kernelMessages.add(Common::Point(63, _scrollY), 0x1110, 0, 0, 180, _game.getQuote(168));
+				_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+				_scrollY += 14;
+				}
+				break;
+			}
+		}
+	}
+}
+
+void Scene211::preActions() {
+	if (_action.isAction(0x1AD, 0x1B2) && _game._objects.isInInventory(OBJ_BINOCULARS) && (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY)
+	&& (_scene->_customDest.x <= 52) && (_scene->_customDest.y >= 132))
+		_game._player.walk(Common::Point(52, 132), FACING_WEST);
+
+	if (_action.isAction(0x1AD, 0x1AE))  {
+		if (_game._objects.isInInventory(OBJ_BINOCULARS) && (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY) )  {
+			_game._player.walk(Common::Point(52, 132), FACING_WEST);
+		} else {
+			_game._player._walkOffScreenSceneId = 210;
+		}
+	}
+
+	if (_action.isAction(0x1AD, 0x1B1))
+		_game._player._walkOffScreenSceneId = 207;
+}
+
+void Scene211::actions() {
+	if (_action._lookFlag && (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY))  {
+		_vm->_dialogs->show(0x5277);
+	} else if (_action.isAction(VERB_LOOK, 0x27, 0x100)) {
+		_vm->_dialogs->show(0x527C);
+	} else if (_action.isAction(VERB_LOOK, 0x3A)) {
+		_vm->_dialogs->show(0x526D);
+	} else if (_action.isAction(VERB_LOOK, 0x1B2)) {
+		_vm->_dialogs->show(0x526E);
+	} else if (_action.isAction(VERB_LOOK, 0x100)) {
+		if (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY)  {
+			if (_game._storyMode == STORYMODE_NAUGHTY)
+				_vm->_dialogs->show(0x526F);
+			else
+				_vm->_dialogs->show(0x5270);
+		} else {
+			_vm->_dialogs->show(0x5271);
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x1B3)) {
+		if (_game._storyMode == STORYMODE_NAUGHTY)
+			_vm->_dialogs->show(0x5272);
+		else
+			_vm->_dialogs->show(0x5273);
+	} else if (_action.isAction(VERB_LOOK, 0xB8)) {
+		_vm->_dialogs->show(0x5274);
+	} else if (_action.isAction(VERB_LOOK, 0x1B1)) {
+		_vm->_dialogs->show(0x5275);
+	} else if (_action.isAction(VERB_LOOK, 0x1AE)) {
+		_vm->_dialogs->show(0x5276);
+	} else if (_action.isAction(VERB_LOOK, 0x144)) {
+		_vm->_dialogs->show(0x5279);
+	} else if (_action.isAction(VERB_TAKE, 0x144)) {
+		_vm->_dialogs->show(0x527A);
+	} else if (_action.isAction(VERB_LOOK, 0x129)) {
+		_vm->_dialogs->show(0x527B);
+	} else 
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index fb09735..4945563 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -228,7 +228,9 @@ private:
 	void initNode(int node);
 	void restoreDialogNode(int node, int msgId, int posY);
 public:
-	Scene210(MADSEngine *vm) : Scene2xx(vm) {}
+	Scene210(MADSEngine *vm) : Scene2xx(vm), _curDialogNode(-1), _nextHandsPlace(0), _twinkleAnimationType(0), _twinklesCurrentFrame(0),
+		_shouldTalk(false), _shouldFaceRex(false), _shouldMoveHead(false), _stopWalking(false), _twinklesTalking(false),
+		_twinklesTalk2(false), _doorway(0), _subQuote2("") {}
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
@@ -236,6 +238,23 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene211: public Scene2xx {
+private:
+	bool _ambushFl, _wakeFl;
+	int _monkeyFrame, _scrollY;
+	uint32 _monkeyTime;
+
+public:
+	Scene211(MADSEngine *vm) : Scene2xx(vm) {}
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index 8db06d5..6d12367 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -121,6 +121,7 @@ public:
 	void updateTimeout(int spriteIdx, int seqIndex);
 	void setScale(int spriteIdx, int scale);
 	void setMsgLayout(int seqIndex);
+	void sub70C52(int seqIndex, int flags, int deltaX, int deltaY) { warning("TODO: sub70C52()"); }
 };
 
 } // End of namespace MADS


Commit: 2368ab78865f251184908d523edeab34514e08ed
    https://github.com/scummvm/scummvm/commit/2368ab78865f251184908d523edeab34514e08ed
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-09T10:42:55+02:00

Commit Message:
MADS: Initialize variables used by Scene 211

Changed paths:
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 4945563..738c61f 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -246,7 +246,7 @@ private:
 	uint32 _monkeyTime;
 
 public:
-	Scene211(MADSEngine *vm) : Scene2xx(vm) {}
+	Scene211(MADSEngine *vm) : Scene2xx(vm), _ambushFl(false), _wakeFl(false), _monkeyFrame(0), _scrollY(0), _monkeyTime(0) {}
 	virtual void setup();
 	virtual void enter();
 	virtual void step();


Commit: 8df08335462db8fc692f18c9dc5bb4293019d2f6
    https://github.com/scummvm/scummvm/commit/8df08335462db8fc692f18c9dc5bb4293019d2f6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-09T09:32:14-04:00

Commit Message:
MADS: Fixes for correctly displaying inventory list in the user interface

Changed paths:
    engines/mads/game.cpp
    engines/mads/inventory.cpp
    engines/mads/screen.cpp
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index eb7ba62..e2e956e 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -208,8 +208,8 @@ void Game::sectionLoop() {
 
 		_vm->_events->initVars();
 		_scene._userInterface._highlightedCommandIndex = -1;
-		_scene._userInterface._highlightedItemIndex = -1;
-		_scene._userInterface._highlightedActionIndex = -1;
+		_scene._userInterface._highlightedInvIndex = -1;
+		_scene._userInterface._highlightedItemVocabIndex = -1;
 
 		_scene._action.clear();
 		_player.setFinalFacing();
diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index 607179a..0795233 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -110,7 +110,7 @@ void InventoryObjects::addToInventory(int objectId) {
 		userInterface._inventoryTopIndex = CLIP(userInterface._inventoryTopIndex,
 			0, (int)_inventoryList.size() - 1);
 
-		if ((userInterface._inventoryTopIndex + 5) <= ((int) size() - 1))
+		if ((userInterface._inventoryTopIndex + 5) < (int)_inventoryList.size())
 			userInterface._inventoryTopIndex = size() - 5;
 		userInterface._inventoryChanged = true;
 
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 5553f61..519dcab 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -131,11 +131,13 @@ void DirtyArea::setUISlot(const UISlot *slot) {
 		_bounds.top = 0;
 		setArea(intSurface.w, intSurface.h, intSurface.w, intSurface.h);
 		break;
+
 	case IMG_OVERPRINT:
 		_bounds.left = slot->_position.x;
 		_bounds.top = slot->_position.y;
-		// TODO: spritesIndex & frameNumber used as w & h??!
-		error("TODO: Figure out IMG_OVERPRINT. Maybe need a union?");
+		_bounds.setWidth(slot->_width);
+		_bounds.setHeight(slot->_height);
+		setArea(slot->_width, slot->_height, intSurface.w, intSurface.h);
 		break;
 
 	default: {
@@ -491,7 +493,7 @@ void ScreenObjects::elementHighlighted() {
 		indexEnd = invList.size() - 1;
 		varA = 0;
 		topIndex = userInterface._inventoryTopIndex;
-		idxP = &userInterface._highlightedItemIndex;
+		idxP = &userInterface._highlightedInvIndex;
 		var4 = (!_released || (_vm->_events->_mouseButtons && action._interAwaiting == 1)) ? 0 : 1;
 		break;
 
@@ -507,7 +509,7 @@ void ScreenObjects::elementHighlighted() {
 
 		varA = 0;
 		topIndex = 0;
-		idxP = _vm->_events->_rightMousePressed ? &userInterface._selectedItemVocabIdx : &userInterface._highlightedActionIndex;
+		idxP = _vm->_events->_rightMousePressed ? &userInterface._selectedItemVocabIdx : &userInterface._highlightedItemVocabIndex;
 
 		if (_vm->_events->_rightMousePressed && userInterface._selectedActionIndex >= 0)
 			userInterface.updateSelection(CAT_COMMAND, -1, &userInterface._selectedActionIndex);
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 8d05402..9416066 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -32,6 +32,7 @@ UISlot::UISlot() {
 	_segmentId = 0;
 	_spritesIndex = 0;
 	_frameNumber = 0;
+	_width = _height = 0;
 }
 
 /*------------------------------------------------------------------------*/
@@ -44,15 +45,15 @@ void UISlots::fullRefresh() {
 	push_back(slot);
 }
 
-void UISlots::add(const Common::Point &pt, int frameNumber, int spritesIndex) {
+void UISlots::add(const Common::Rect &bounds) {
 	assert(size() < 50);
 
 	UISlot ie;
 	ie._flags = IMG_OVERPRINT;
 	ie._segmentId = IMG_TEXT_UPDATE;
-	ie._position = pt;
-	ie._frameNumber = frameNumber;
-	ie._spritesIndex = spritesIndex;
+	ie._position = Common::Point(bounds.left, bounds.top);
+	ie._width = bounds.width();
+	ie._height = bounds.height();
 
 	push_back(ie);
 }
@@ -213,8 +214,8 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm), _dirtyAreas(vm),
 	_selectedItemVocabIdx = -1;
 	_scrollerY = 0;
 	_highlightedCommandIndex = -1;
-	_highlightedItemIndex = -1;
-	_highlightedActionIndex = -1;
+	_highlightedInvIndex = -1;
+	_highlightedItemVocabIndex = -1;
 	_dirtyAreas.resize(50);
 	_inventoryChanged = false;
 	Common::fill(&_categoryIndexes[0], &_categoryIndexes[7], 0);
@@ -279,8 +280,8 @@ void UserInterface::setup(InputMode inputMode) {
 	scene._userInterface._uiSlots.fullRefresh();
 	_vm->_game->_screenObjects._baseTime = _vm->_events->getFrameCounter();
 	_highlightedCommandIndex = -1;
-	_highlightedActionIndex = -1;
-	_highlightedItemIndex = -1;
+	_highlightedItemVocabIndex = -1;
+	_highlightedInvIndex = -1;
 
 	if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE)
 		scene._userInterface._uiSlots.draw(false, false);
@@ -358,7 +359,7 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
 	case CAT_INV_LIST:
 		font = _vm->_font->getFont(FONT_INTERFACE);
 		vocabId = _vm->_game->_objects.getItem(id)._descId;
-		if (id == _highlightedItemIndex) {
+		if (id == _highlightedInvIndex) {
 			_vm->_font->setColorMode(SELMODE_HIGHLIGHTED);
 		} else {
 			_vm->_font->setColorMode(id == _selectedInvIndex ? SELMODE_SELECTED : SELMODE_UNSELECTED);
@@ -399,7 +400,7 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
 		// Item specific verbs
 		font = _vm->_font->getFont(FONT_INTERFACE);
 		vocabId = _vm->_game->_objects.getItem(_selectedInvIndex)._vocabList[id]._vocabId;
-		if (id == _highlightedActionIndex) {
+		if (id == _highlightedItemVocabIndex) {
 			_vm->_font->setColorMode(SELMODE_HIGHLIGHTED);
 		} else {
 			_vm->_font->setColorMode(id == _selectedInvIndex ? SELMODE_SELECTED : SELMODE_UNSELECTED);
@@ -714,13 +715,40 @@ void UserInterface::doBackgroundAnimation() {
 }
 
 void UserInterface::categoryChanged() {
-	_highlightedItemIndex = -1;
+	_highlightedInvIndex = -1;
 	_vm->_events->initVars();
 	_category = CAT_NONE;
 }
 
 void UserInterface::selectObject(int invIndex) {
-	warning("TODO: selectObject");
+	if (_selectedInvIndex != invIndex || _inventoryChanged) {
+		int oldVocabCount = _selectedInvIndex < 0 ? 0 : _vm->_game->_objects.getItem(_selectedInvIndex)._vocabCount;
+		int newVocabCount = invIndex < 0 ? 0 : _vm->_game->_objects.getItem(invIndex)._vocabCount;
+		int maxVocab = MAX(oldVocabCount, newVocabCount);
+
+		updateSelection(CAT_INV_LIST, invIndex, &_selectedInvIndex);
+		_highlightedItemVocabIndex = -1;
+		_selectedItemVocabIdx = -1;
+
+		if (maxVocab) {
+			assert(_uiSlots.size() < 50);
+			int vocabHeight = maxVocab * 8;
+			
+			Common::Rect bounds(240, 3, 240 + 80, 3 + vocabHeight);
+			_uiSlots.add(bounds);
+			_uiSlots.draw(false, false);
+			drawItemVocabList();
+			updateRect(bounds);
+		}
+	}
+
+	if (invIndex == -1) {
+		noInventoryAnim();
+	} else {
+		loadInventoryAnim(_vm->_game->_objects._inventoryList[invIndex]);
+		_vm->_palette->setPalette(_vm->_palette->_mainPalette, 7, 1);
+		_vm->_palette->setPalette(_vm->_palette->_mainPalette, 246, 2);
+	}
 }
 
 void UserInterface::updateSelection(ScrCategory category, int newIndex, int *idx) {
@@ -730,7 +758,7 @@ void UserInterface::updateSelection(ScrCategory category, int newIndex, int *idx
 	if (category == CAT_INV_LIST && _inventoryChanged) {
 		*idx = newIndex;
 		bounds = Common::Rect(90, 3, 90 + 69, 3 + 40);
-		_uiSlots.add(Common::Point(90, 3), 69, 40);
+		_uiSlots.add(bounds);
 		_uiSlots.draw(false, false);
 		drawInventoryList();
 		updateRect(bounds);
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 6b3abf0..46ba478 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -42,6 +42,10 @@ public:
 	int _spritesIndex;
 	int _frameNumber;
 	Common::Point _position;
+	
+	// Only used for IMG_OVERPRINT
+	int _width;
+	int _height;
 
 	UISlot();
 };
@@ -59,9 +63,9 @@ public:
 	UISlots(MADSEngine *vm) : _vm(vm) {}
 
 	/**
-	 * Add a sprite to the list
+	 * Add an overprint (text) entry to the list
 	 */
-	void add(const Common::Point &pt, int frameNumber, int spritesIndex);
+	void add(const Common::Rect &bounds);
 
 	/**
 	 * Loads the data from an aimation frame entry
@@ -155,8 +159,8 @@ public:
 	int _selectedItemVocabIdx;
 	int _scrollerY;
 	int _highlightedCommandIndex;
-	int _highlightedItemIndex;
-	int _highlightedActionIndex;
+	int _highlightedInvIndex;
+	int _highlightedItemVocabIndex;
 	bool _inventoryChanged;
 	int _categoryIndexes[8];
 	Common::StringArray _talkStrings;


Commit: ee7e7e68343b65ec76eea986075bc0b753386546
    https://github.com/scummvm/scummvm/commit/ee7e7e68343b65ec76eea986075bc0b753386546
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-09T19:39:03+02:00

Commit Message:
MADS: Implement scene 212

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index a3a1433..0077b5f 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -69,6 +69,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene210(vm);
 	case 211:
 		return new Scene211(vm);
+	case 212:
+		return new Scene212(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 5c966cf..77e5234 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -4592,5 +4592,66 @@ void Scene211::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene212::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+
+	_scene->addActiveVocab(0x19D);
+}
+
+void Scene212::enter() {
+	// CHECKME: Some useless variables have been remove here
+
+	if (_scene->_priorSceneId == 208) {
+		_game._player._playerPos = Common::Point(195, 85);
+		_game._player._facing = FACING_SOUTH;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(67, 117);
+		_game._player._facing = FACING_NORTHEAST;
+	}
+
+	sceneEntrySound();
+}
+
+void Scene212::step() {
+// CHECKME: Could we move the dino?
+}
+
+void Scene212::preActions() {
+	if (_action.isAction(0x18B, 0x41))
+		_game._player._walkOffScreenSceneId = 111;
+}
+
+void Scene212::actions() {
+	if (_action._lookFlag)
+		_vm->_dialogs->show(0x52D9);
+	else if (_action.isAction(0x18C) && (_action.isAction(0x82) || _action.isAction(0xE8)))
+		_scene->_nextSceneId = 208;
+	else if (_action.isAction(0x18C, 0x3F))
+		_scene->_nextSceneId = 111;
+	else if (_action.isAction(VERB_LOOK, 0x19C))
+		_vm->_dialogs->show(0x52D1);
+	else if (_action.isAction(VERB_LOOK, 0x129))
+		_vm->_dialogs->show(0x52D2);
+	else if (_action.isAction(VERB_LOOK, 0x41))
+		_vm->_dialogs->show(0x52D3);
+	else if (_action.isAction(VERB_LOOK, 0x142))
+		_vm->_dialogs->show(0x52D4);
+	else if (_action.isAction(VERB_LOOK, 0x82))
+		_vm->_dialogs->show(0x52D5);
+	else if (_action.isAction(VERB_LOOK, 0x175))
+		_vm->_dialogs->show(0x52D6);
+	else if (_action.isAction(VERB_LOOK, 0x110))
+		_vm->_dialogs->show(0x52D7);
+	else if (_action.isAction(VERB_LOOK, 0xE8))
+		_vm->_dialogs->show(0x52D8);
+	else 
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 738c61f..0b446bb 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -255,6 +255,16 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene212: public Scene2xx {
+public:
+	Scene212(MADSEngine *vm) : Scene2xx(vm) {}
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 266c8952508c47bff05d10d0945459c634669f73
    https://github.com/scummvm/scummvm/commit/266c8952508c47bff05d10d0945459c634669f73
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-09T20:38:21-04:00

Commit Message:
MADS: Fix wear response for rebreather

Changed paths:
    engines/mads/nebular/game_nebular.cpp



diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index d8b00bc..467f3c3 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -296,7 +296,7 @@ void GameNebular::doObjectAction() {
 	} else if (action.isAction(NOUN_EAT, NOUN_STUFFED_FISH)) {
 		dialogs.show(445);
 	} else if (action.isAction(401, 289)) {
-		dialogs.show(scene._currentSceneId > 103 && scene._currentSceneId < 111 ? 447 : 446);
+		dialogs.show(scene._currentSceneId > 103 && scene._currentSceneId < 111 ? 446 : 447);
 	} else if (action.isAction(306, 371)) {
 		dialogs.show(448);
 	} else if (action.isAction(951, 35)) {


Commit: 90a030c35279294b28d828d7e4a12cd7b7f6c2da
    https://github.com/scummvm/scummvm/commit/90a030c35279294b28d828d7e4a12cd7b7f6c2da
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-10T09:58:24+02:00

Commit Message:
MADS: Implement Scene 101

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 0077b5f..6528afe 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -47,6 +47,10 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 
 	switch (scene._nextSceneId) {
 	// Scene group #1
+	case 101:
+		return new Scene101(vm);
+	case 102:
+		return new Scene102(vm);
 	case 103:
 		return new Scene103(vm);
 
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index f56f5d3..5064795 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -100,21 +100,528 @@ void Scene1xx::setPlayerSpritesPrefix() {
 /*------------------------------------------------------------------------*/
 
 void Scene101::setup() {
+	_scene->_animationData->preLoad(formAnimName('A', -1), 3);
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene101::sayDang() {
+	_game._triggerSetupMode = KERNEL_TRIGGER_DAEMON;
+	_game._player._stepEnabled = false;
+
+	switch (_game._trigger) {
+	case 0:
+		_scene->_sequences.remove(_globals._spriteIndexes[26]);
+		_globals._spriteIndexes[26] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[11], false, 3, 6, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[26], 17, 21);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_0, 0, 72);
+		_vm->_sound->command(17);
+		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 3, 2, 0, 0);
+		break;
+
+	case 72:
+		_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 6, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[26], 17, 17);
+		_scene->_kernelMessages.add(Common::Point(143, 61), 0x1110, 0, 0, 60, _game.getQuote(57));
+		_scene->_sequences.addTimer(120, 73);
+		break; 
+
+	case 73:
+		_vm->_dialogs->show(0x2785);
+		_game._player._stepEnabled = true;
+		break;
+	}
 }
 
 void Scene101::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 1), false);
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 2), false);
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 3), false);
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 4), false);
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('x', 5), false);
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('x', 6), false);
+	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('x', 7), false);
+	_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('m', -1), false);
+	_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('b', 1), false);
+	_globals._spriteIndexes[10] = _scene->_sprites.addSprites(formAnimName('b', 2), false);
+	_globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('a', 0), false);
+	_globals._spriteIndexes[12] = _scene->_sprites.addSprites(formAnimName('a', 1), false);
+	_globals._spriteIndexes[13] = _scene->_sprites.addSprites(formAnimName('x', 8), false);
+	_globals._spriteIndexes[14] = _scene->_sprites.addSprites(formAnimName('x', 0), false);
+
+	_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 0, 0, 25);
+	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 4, 0, 1, 0);
+	_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 2, 0);
+	_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_FRAME_INDEX, 7, 70);
+	_globals._spriteIndexes[19] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[4], false, 10, 0, 0, 60);
+	_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 5, 0, 1, 0);
+	_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 10, 0, 2, 0);
+	_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 6, 0, 0, 0);
+	_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, 0, 10, 4);
+	_globals._spriteIndexes[25] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[10], false, 6, 0, 32, 47);
+
+	_scene->_hotspots.activate(0x137, false);
+	_panelOpened = false;
+
+	if (_scene->_priorSceneId != -1)
+		_globals[kNeedToStandUp] = false;
+
+	if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(100, 152);
+
+	if ((_scene->_priorSceneId == 112) || ((_scene->_priorSceneId == -2) && _sittingFl )) {
+		_game._player._visible = false;
+		_sittingFl = true;
+		_game._player._playerPos = Common::Point(161, 123);
+		_game._player._facing = FACING_NORTHEAST;
+		_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[26], 17, 17);
+		_scene->_hotspots.activate(0x47, false);
+		_chairHotspotId = _scene->_dynamicHotspots.add(0x47, 0x13F, -1, Common::Rect(159, 84, 33, 36));
+		if (_scene->_priorSceneId == 112)
+			sayDang();
+	} else {
+		_globals._spriteIndexes[27] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[12], false, 6, 0, 0, 0);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[27], 4);
+	}
+
+	_game.loadQuoteSet(0x31, 0x32, 0x39, 0x36, 0x37, 0x38, 0);
+
+	if (_globals[10]) {
+		_scene->loadAnimation(Resources::formatName(101, 'S', -1, EXT_AA, ""), 71);
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+		_game._player._playerPos = Common::Point(68, 140);
+		_game._player._facing = FACING_WEST;
+
+		_messageNum = 0;
+		_posY = 30;
+	}
+
+	_oldSpecial = false;
+
+	sceneEntrySound();
 }
 
 void Scene101::step() {
+	if (_oldSpecial != _game._player._special) {
+		_oldSpecial = _game._player._special;
+		if (_oldSpecial)
+			_vm->_sound->command(39);
+		else
+			_vm->_sound->command(11);
+	}
+
+	switch (_game._trigger) {
+	case 70:
+		_vm->_sound->command(9);
+		break;
+
+	case 71:
+		_globals[10] = false;
+		_game._player._visible = true;
+		_game._player._stepEnabled = true;
+		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+		break;
+
+	case 72:
+	case 73:
+		sayDang();
+		break;
+	}
+
+	if (_scene->_activeAnimation != nullptr) {
+		if ((_scene->_activeAnimation->getCurrentFrame() >= 6) && (_messageNum == 0)) {
+			_messageNum++;
+			_scene->_kernelMessages.add(Common::Point(63, _posY), 0x1110, 0, 0, 240, _game.getQuote(49));
+			_posY += 14;
+		}
+
+		if ((_scene->_activeAnimation->getCurrentFrame() >= 7) && (_messageNum == 1)) {
+			_messageNum++;
+			_scene->_kernelMessages.add(Common::Point(63, _posY), 0x1110, 0, 0, 240, _game.getQuote(54));
+			_posY += 14;
+		}
+
+		if ((_scene->_activeAnimation->getCurrentFrame() >= 10) && (_messageNum == 2)) {
+			_messageNum++;
+			_scene->_kernelMessages.add(Common::Point(63, _posY), 0x1110, 0, 0, 240, _game.getQuote(55));
+			_posY += 14;
+		}
+
+		if ((_scene->_activeAnimation->getCurrentFrame() >= 17) && (_messageNum == 3)) {
+			_messageNum++;
+			_scene->_kernelMessages.add(Common::Point(63, _posY), 0x1110, 0, 0, 240, _game.getQuote(56));
+			_posY += 14;
+		}
+
+		if ((_scene->_activeAnimation->getCurrentFrame() >= 20) && (_messageNum == 4)) {
+			_messageNum++;
+			_scene->_kernelMessages.add(Common::Point(63, _posY), 0x1110, 0, 0, 240, _game.getQuote(50));
+			_posY += 14;
+		}
+	}
 }
 
 void Scene101::preActions() {
+	if (_action.isAction(VERB_LOOK, 0x180))
+		_game._player._needToWalk = true;
+
+	if (_sittingFl) {
+		if (_action.isAction(VERB_LOOK) || _action.isAction(0x47) || _action.isAction(VERB_TALKTO) || _action.isAction(0x103) || _action.isAction(0x7D))
+			_game._player._needToWalk = false;
+
+		if (_game._player._needToWalk) {
+			switch (_game._trigger) {
+			case 0:
+				_game._player._needToWalk = false;	
+				_game._player._stepEnabled = false;
+				_scene->_sequences.remove(_globals._spriteIndexes[26]);
+				_globals._spriteIndexes[26] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[11], false, 3, 1, 0, 0);
+				_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_0, 0, 1);
+				_scene->_sequences.setAnimRange(_globals._spriteIndexes[26], 1, 17);
+				_vm->_sound->command(16);
+				break;
+
+			case 1:
+				_sittingFl = false;
+				_game._player._visible = true;
+				_game._player._stepEnabled = true;
+				_game._player._needToWalk = true;
+				_scene->_hotspots.activate(71, true);
+				_scene->_dynamicHotspots.remove(_chairHotspotId);
+				_globals._spriteIndexes[27] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[12], false, 6, 0, 0, 0);
+				_scene->_sequences.setDepth(_globals._spriteIndexes[27], 4);
+				break;
+			}
+		}
+	}
+
+	if (_panelOpened && !(_action.isAction(0x135) || _action.isAction(0x137))) {
+		switch (_game._trigger) {
+		case 0:
+			if (_game._player._needToWalk) {
+				_scene->_sequences.remove(_globals._spriteIndexes[28]);
+				_shieldSpriteIdx = _game._objects.isInRoom(0x18) ? 13 : 14;
+				_globals._spriteIndexes[28] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[_shieldSpriteIdx], false, 6, 1, 0, 0);
+				_scene->_sequences.addSubEntry(_globals._spriteIndexes[28], SM_0, 0, 1);
+				_game._player._stepEnabled = false;
+				_vm->_sound->command(20);
+			}
+			break;
+
+		case 1:
+			_game._player._stepEnabled = true;
+			_panelOpened = false;
+			_scene->_hotspots.activate(0x137, false);
+			break;
+		}
+	}
 }
 
 void Scene101::actions() {
+	if (_action._lookFlag) {
+		_vm->_dialogs->show(0x278D);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_WALKTO, 0xCC)) {
+		_scene->_nextSceneId = 102;
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(0x13F, 0x47) || (_action.isAction(VERB_LOOK, 0x180) && !_sittingFl)) {
+		if (!_sittingFl) {
+			switch (_game._trigger) {
+			case 0:
+				_scene->_sequences.remove(_globals._spriteIndexes[27]);
+				_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 0, 0, 1);
+				_scene->_sequences.setAnimRange(_globals._spriteIndexes[26], 1, 17);
+				_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_FRAME_INDEX, 10, 1);
+				_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_0, 0, 2);
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				_action._inProgress = false;
+				return;
+
+			case 1:
+				_vm->_sound->command(16);
+				break;
+
+			case 2:
+				_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 0, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._spriteIndexes[26], 17, 17);
+				_game._player._stepEnabled = true;
+				_sittingFl = true;
+				_scene->_hotspots.activate(71, false);
+				_chairHotspotId = _scene->_dynamicHotspots.add(71, 0x13F, -1, Common::Rect(159, 84, 33, 36));
+				if (!_action.isAction(VERB_LOOK, 0x180)) {
+					_action._inProgress = false;
+					return;
+				}
+				_game._trigger = 0;
+				break;
+			}
+		} else {
+			_vm->_dialogs->show(0x2793);
+			_action._inProgress = false;
+			return;
+		}
+	}
+
+	if (((_action.isAction(VERB_WALKTO, 0x135) || _action.isAction(VERB_OPEN, 0x135))) && !_panelOpened) {
+		switch (_game._trigger) {
+		case 0:
+			_shieldSpriteIdx = _game._objects.isInRoom(0x18) ? 13 : 14;
+			_globals._spriteIndexes[28] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[_shieldSpriteIdx], false, 6, 1, 0, 0);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[28], SM_0, 0, 1);
+			_game._player._stepEnabled = false;
+			_vm->_sound->command(20);
+			break;
+
+		case 1:
+			_scene->_sequences.remove(_globals._spriteIndexes[28]);
+			_globals._spriteIndexes[28] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[_shieldSpriteIdx], false, 6, 0, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._spriteIndexes[28], -2, -2);
+			_game._player._stepEnabled = true;
+			_panelOpened = true;
+			if (_game._objects.isInRoom(0x18))
+				_scene->_hotspots.activate(0x137, true);
+			break;
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if ((_action.isAction(VERB_TAKE, 0x137) || _action.isAction(VERB_PULL, 0x137)) && _game._objects.isInRoom(0x18)) {
+		_game._objects.addToInventory(0x18);
+		_scene->_sequences.remove(_globals._spriteIndexes[28]);
+		_globals._spriteIndexes[28] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[14], false, 6, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[28], -2, -2);
+		_scene->_hotspots.activate(0x137, false);
+		_vm->_dialogs->showPicture(0x18, 0x2788);
+		_vm->_sound->command(22);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x135) || (_action.isAction(VERB_LOOK, 0x137) && !_game._objects.isInInventory(OBJ_SHIELD_MODULATOR)) ) {
+		if (_panelOpened) {
+			if (_game._objects.isInRoom(OBJ_SHIELD_MODULATOR))
+				_vm->_dialogs->show(0x2790);
+			else
+				_vm->_dialogs->show(0x2791);
+		} else {
+			_vm->_dialogs->show(0x278F);
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_OPEN, 0x135) && _panelOpened) {
+		_vm->_dialogs->show(0x2792);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x180) && _sittingFl) {
+		if (_globals[kWatchedViewScreen]) {
+			sayDang();
+		} else {
+			switch (_game._trigger) {
+			case 0:
+				_game._player._stepEnabled = false;
+				_scene->_sequences.remove(_globals._spriteIndexes[26]);
+				_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._spriteIndexes[26], 17, 21);
+				_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_0, 0, 1);
+				_vm->_sound->command(17);
+				break;
+
+			case 1:
+				_globals._spriteIndexes[26] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[11], false, 3, 1, 0, 0);
+				_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_0, 0, 2);
+				_scene->_sequences.setAnimRange(_globals._spriteIndexes[26], 17, 21);
+				break;
+
+			case 2:
+				_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 0, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._spriteIndexes[26], 17, 17);
+				_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 3, 1, 0, 0);
+				_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 3);
+				break;
+
+			case 3:
+				_game._player._stepEnabled = true;
+				_globals[kWatchedViewScreen] = true;
+				_sittingFl = true;
+				_scene->_nextSceneId = 112;
+				break;
+			}
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x47)) {
+		_vm->_dialogs->show(0x2775);
+		_action._inProgress = false;
+		return;
+	}
+
+	if ((_action.isAction(VERB_LOOK) || _action.isAction(0x103)) && (_action.isAction(0x8E) || _action.isAction(0xF9))) {
+		_vm->_dialogs->show(0x2776);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0xA8) || _action.isAction(VERB_LOOK, 0xF8) || _action.isAction(0x7D, 0xA8) || _action.isAction(0x7D, 0xF8)) {
+		_vm->_dialogs->show(0x2777);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x91)) {
+		_vm->_dialogs->show(0x2778);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0xE1) || _action.isAction(0xD2, 0xE1)) {
+		_vm->_dialogs->show(0x2779);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x60)) {
+		_vm->_dialogs->show(0x277A);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x111)) {
+		_vm->_dialogs->show(0x277B);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x7B) || (_action.isAction(VERB_OPEN, 0x7B) && !_game._objects.isInInventory(OBJ_REBREATHER))) {
+		_vm->_dialogs->show(0x277D);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_OPEN, 0x7B)) {
+		_vm->_dialogs->show(0x277E);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x166)) {
+		_vm->_dialogs->show(0x277F);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0xCA)) {
+		_vm->_dialogs->show(0x278E);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x63)) {
+		_vm->_dialogs->show(0x2780);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0xEB)) {
+		_vm->_dialogs->show(0x2781);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x78)) {
+		_vm->_dialogs->show(0x2782);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x190)) {
+		_vm->_dialogs->show(0x2783);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x138)) {
+		_vm->_dialogs->show(0x2784);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_TAKE, 0x111)) {
+		_vm->_dialogs->show(0x2786);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_TAKE, 0x91)) {
+		_vm->_dialogs->show(0x2787);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_OPEN, 0x63)) {
+		_vm->_dialogs->show(0x2789);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_OPEN, 0x60)) {
+		_vm->_dialogs->show(0x278A);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_CLOSE, 0x60)) {
+		_vm->_dialogs->show(0x278B);
+		_action._inProgress = false;
+		return;
+	}
+
+	if ((_action.isAction(VERB_LOOK) || _action.isAction(0x112)) && _action.isAction(0x17E)) {
+		_vm->_dialogs->show(0x278C);
+		_action._inProgress = false;
+		return;
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+void Scene102::setup() {
+
 }
 
-void Scene101::postActions() {
+void Scene102::enter() {
+
+}
+
+void Scene102::step() {
+
+}
+
+void Scene102::preActions() {
+
+}
+
+void Scene102::actions() {
+
+}
+
+void Scene102::postActions() {
+
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index 56c70b1..3f69223 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -53,8 +53,32 @@ public:
 };
 
 class Scene101: public Scene1xx {
+private:
+	bool _sittingFl;
+	bool _panelOpened;
+
+	int _messageNum;
+	int _posY;
+	int _shieldSpriteIdx;
+	int _chairHotspotId;
+	int _oldSpecial;
+
+	void sayDang();
+public:
+	Scene101(MADSEngine *vm) : Scene1xx(vm), _sittingFl(false), _panelOpened(false), _messageNum(0), 
+		_posY(0), _shieldSpriteIdx(0), _chairHotspotId(0), _oldSpecial(0) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
+class Scene102 : public Scene1xx {
 public:
-	Scene101(MADSEngine *vm) : Scene1xx(vm) {}
+	Scene102(MADSEngine *vm) : Scene1xx(vm) {}
 
 	virtual void setup();
 	virtual void enter();


Commit: 99f947fbc3fab233afdb1974503222c4b6a28e49
    https://github.com/scummvm/scummvm/commit/99f947fbc3fab233afdb1974503222c4b6a28e49
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-10T13:42:37+02:00

Commit Message:
MADS: Avoid to specify the 2nd parameter of addSprites when it's the default value

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 77e5234..d78b85e 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -127,10 +127,10 @@ void Scene201::setup() {
 }
 
 void Scene201::enter() {
-	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0), 0);
-	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 1), 0);
-	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('m', -1), 0);
-	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('b', -1), 0);
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 1));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('m', -1));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('b', -1));
 	_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*SC002Z1");
 	_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 1, 0);
 	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 15, 0, 0, 50);
@@ -182,8 +182,8 @@ void Scene201::enter() {
 	}
 
 	if ((_scene->_priorSceneId == 202) && (_globals[kMeteorologistStatus] == 1) && !_scene->_roomChanged) {
-		_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('a', 0), 0);
-		_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('a', 1), 0);
+		_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('a', 0));
+		_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('a', 1));
 		_game.loadQuoteSet(90, 91, 0);
 		_game._player._stepEnabled = false;
 		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 7, 1, 0, 0);
@@ -340,19 +340,19 @@ void Scene202::setup() {
 
 void Scene202::enter() {
 	_game._player._visible3 = true;
-	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('b', 0), 0);
-	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('b', 1), 0);
-	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('b', 2), 0);
-	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 0), 0);
-	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('l', -1), 0);
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('b', 0));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('b', 1));
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('b', 2));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('l', -1));
 	if (_globals[kSexOfRex] != SEX_MALE) {
 		_globals._spriteIndexes[7] = _scene->_sprites.addSprites("*ROXBD_2");
 	} else {
 		_globals._spriteIndexes[7] = _scene->_sprites.addSprites("*RXMBD_2");
 	}
-	_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('a', 0), 0);
-	_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('a', 1), 0);
-	_globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('a', 2), 0);
+	_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('a', 0));
+	_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('a', 1));
+	_globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('a', 2));
 
 	_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 0, 0);
 	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 0);
@@ -1009,7 +1009,7 @@ void Scene203::enter() {
 	}
 
 	if (!_rhotundaEatFl) {
-		_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('b', -1), 0);
+		_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('b', -1));
 		if (_vm->getRandomNumber(1, 3) == 2) {
 			_globals._spriteIndexes[15] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 9, 1, 0, 0);
 			int idx = _scene->_dynamicHotspots.add(477, 209, _globals._spriteIndexes[15], Common::Rect(0, 0, 0, 0));
@@ -1100,15 +1100,15 @@ void Scene205::setup() {
 }
 
 void Scene205::enter() {
-	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0), 0);
-	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 1), 0);
-	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 2), 0);
-	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('f', -1), 0);
-	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('c', -1), 0);
-	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('p', -1), 0);
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 1));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 2));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('f', -1));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('c', -1));
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('p', -1));
 
 	if (_globals[kSexOfRex] == SEX_MALE)
-		_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('a', 1), 0);
+		_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('a', 1));
 
 	_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 10, 0, 0, 3);
 	int idx = _scene->_dynamicHotspots.add(73, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
@@ -1231,13 +1231,13 @@ void Scene207::setup() {
 }
 
 void Scene207::enter() {
-	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('h', 0), 0);
-	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('h', 1), 0);
-	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('c', -1), 0);
-	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('e', 0), 0);
-	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('e', 1), 0);
-	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('g', 1), 0);
-	_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('g', 0), 0);
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('h', 0));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('h', 1));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('c', -1));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('e', 0));
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('e', 1));
+	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('g', 1));
+	_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('g', 0));
 	_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 7, 0, 0, 0);
 	_scene->_sequences.setDepth(_globals._spriteIndexes[20], 7);
 
@@ -1447,10 +1447,10 @@ void Scene208::updateTrap() {
 }
 
 void Scene208::enter() {
-	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('a', 1), 0);
-	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 0), 0);
-	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 1), 0);
-	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 2), 0);
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('a', 1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 1));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 2));
 	_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RXMBD_8");
 
 	updateTrap();
@@ -2309,7 +2309,7 @@ void Scene209::handleMonkeyFall() {
 		_scene->_sprites.remove(_globals._spriteIndexes[5]);
 		_scene->_sprites.remove(_globals._spriteIndexes[4]);
 
-		_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('m', 4), 0);
+		_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('m', 4));
 		_scene->_kernelMessages.add(Common::Point(180, 26), 0xFDFC, 0, 0, 90, _game.getQuote(151));
 		_scene->_sequences.addTimer(40, 100);
 		_scene->_hotspots.activate(227, false);
@@ -2509,15 +2509,15 @@ void Scene209::handleDodge() {
 }
 
 void Scene209::enter() {
-	_globals._spriteIndexes[12] = _scene->_sprites.addSprites(formAnimName('a', 1), 0);
-	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('e', -1), 0);
-	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 0), 0);
-	_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('b', 1), 0);
-	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('m', 0), 0);
-	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('m', 1), 0);
-	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('m', 3), 0);
-	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('m', 6), 0);
-	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('m', 8), 0);
+	_globals._spriteIndexes[12] = _scene->_sprites.addSprites(formAnimName('a', 1));
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('e', -1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 0));
+	_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('b', 1));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('m', 0));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('m', 1));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('m', 3));
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('m', 6));
+	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('m', 8));
 
 	_game.loadQuoteSet(0x82, 0x83, 0x84, 0x9C, 0x97, 0x95, 0x99, 0x9E, 0x98, 0x9B, 0xA0, 0x96, 0x9F,
 		0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x91, 0x92, 0x93, 0x94, 0x89, 0x85, 0x8A, 0x86, 0x87, 0x88, 0);
@@ -3119,7 +3119,7 @@ void Scene209::actions() {
 	if (_action.isAction(VERB_TAKE, NOUN_PLANT_STALK) && (_game._trigger || _game._objects.isInRoom(OBJ_PLANT_STALK))) {
 		switch (_game._trigger) {
 		case 0:
-			_globals._spriteIndexes[11] = _scene->_sprites.addSprites("*RXMBD_2", 0);
+			_globals._spriteIndexes[11] = _scene->_sprites.addSprites("*RXMBD_2");
 			_game._player._stepEnabled = false;
 			_game._player._visible = false;
 			_globals._spriteIndexes[26] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[11], false, 3, 2, 0, 0);
@@ -3151,7 +3151,7 @@ void Scene209::actions() {
 	if (_action.isAction(VERB_TAKE, 0x27) && (_game._trigger || _game._objects.isInRoom(OBJ_BINOCULARS))) {
 		switch (_game._trigger) {
 		case 0:
-			_globals._spriteIndexes[10] = _scene->_sprites.addSprites("*RXMBD_8", false);
+			_globals._spriteIndexes[10] = _scene->_sprites.addSprites("*RXMBD_8");
 			_game._player._stepEnabled = false;
 			_game._player._visible = false;
 			_globals._spriteIndexes[25] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[10], false, 3, 2, 0, 0);
@@ -3713,7 +3713,7 @@ void Scene210::setDialogNode(int node) {
 			_scene->_activeAnimation = nullptr;
 			_scene->resetScene();
 
-			_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', -1), 0);
+			_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', -1));
 			_game.loadQuoteSet(0xE6, 0xE9, 0xEA, 0xE7, 0xE8, 0);
 			_scene->loadAnimation(formAnimName('B', -1), 4);
 			break;
@@ -3805,7 +3805,7 @@ void Scene210::restoreDialogNode(int node, int msgId, int posY) {
 }
 
 void Scene210::enter() {
-	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', -1), 0);
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', -1));
 
 	if (!_game._visitedScenes._sceneRevisited)
 		_globals[kCurtainOpen] = 0;
@@ -4336,7 +4336,7 @@ void Scene211::setup() {
 }
 
 void Scene211::enter() {
-	_globals._spriteIndexes[1] = _scene->_sprites.addSprites("*SC002Z2", false);
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites("*SC002Z2");
 	_wakeFl = false;
 
 	if (_scene->_priorSceneId == 210)


Commit: dbbfdeec8fb2d042844cee67c91c7d639f2a8eaa
    https://github.com/scummvm/scummvm/commit/dbbfdeec8fb2d042844cee67c91c7d639f2a8eaa
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-10T20:04:58-04:00

Commit Message:
MADS: Added an item command to the debugger

Changed paths:
    engines/mads/debugger.cpp
    engines/mads/debugger.h



diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp
index 276340f..7d66b56 100644
--- a/engines/mads/debugger.cpp
+++ b/engines/mads/debugger.cpp
@@ -38,6 +38,7 @@ Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) {
 	DCmd_Register("show_codes", WRAP_METHOD(Debugger, Cmd_ShowCodes));
 	DCmd_Register("dump_file", WRAP_METHOD(Debugger, Cmd_DumpFile));
 	DCmd_Register("show_quote", WRAP_METHOD(Debugger, Cmd_ShowQuote));
+	DCmd_Register("item", WRAP_METHOD(Debugger, Cmd_Item));
 }
 
 static int strToInt(const char *s) {
@@ -178,4 +179,21 @@ bool Debugger::Cmd_ShowQuote(int argc, const char **argv) {
 	return true;
 }
 
+bool Debugger::Cmd_Item(int argc, const char **argv) {
+	InventoryObjects &objects = _vm->_game->_objects;
+
+	if (argc != 2) {
+		DebugPrintf("Usage: %s <item number>\n", argv[0]);
+		return true;
+	} else {
+		int objectId = strToInt(argv[1]);
+
+		if (!objects.isInInventory(objectId))
+			objects.addToInventory(objectId);
+
+		DebugPrintf("Item added.\n");
+		return false;
+	}
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/debugger.h b/engines/mads/debugger.h
index b2b0949..c2d66d9 100644
--- a/engines/mads/debugger.h
+++ b/engines/mads/debugger.h
@@ -42,6 +42,7 @@ protected:
 	bool Cmd_ShowCodes(int argc, const char **argv);
 	bool Cmd_DumpFile(int argc, const char **argv);
 	bool Cmd_ShowQuote(int argc, const char **argv);
+	bool Cmd_Item(int argc, const char **argv);
 public:
 	bool _showMousePos;
 public:


Commit: da43f4438d44e2fee8fb8e99fd463e2c702e683e
    https://github.com/scummvm/scummvm/commit/da43f4438d44e2fee8fb8e99fd463e2c702e683e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-10T20:06:02-04:00

Commit Message:
MADS: Minor fix to inentory top index setting

Changed paths:
    engines/mads/inventory.cpp



diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index 0795233..bb65430 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -110,8 +110,8 @@ void InventoryObjects::addToInventory(int objectId) {
 		userInterface._inventoryTopIndex = CLIP(userInterface._inventoryTopIndex,
 			0, (int)_inventoryList.size() - 1);
 
-		if ((userInterface._inventoryTopIndex + 5) < (int)_inventoryList.size())
-			userInterface._inventoryTopIndex = size() - 5;
+		if ((userInterface._inventoryTopIndex + 5) <= (int)_inventoryList.size())
+			userInterface._inventoryTopIndex = size() - 4;
 		userInterface._inventoryChanged = true;
 
 		(*this)[objectId]._roomNumber = PLAYER_INVENTORY;


Commit: 0eb08fdcc075643e03ead21ff4d0366f26c9625a
    https://github.com/scummvm/scummvm/commit/0eb08fdcc075643e03ead21ff4d0366f26c9625a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-10T20:06:37-04:00

Commit Message:
MADS: Fix bounds calculation for inventory scroller

Changed paths:
    engines/mads/user_interface.cpp



diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 9416066..3ae571c 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -522,7 +522,7 @@ bool UserInterface::getBounds(ScrCategory category, int v, Common::Rect &bounds)
 
 	case CAT_INV_SCROLLER:
 		heightMultiplier = 0;
-		widthMultiplier = 73;
+		widthMultiplier = 0;
 		yOffset = 0;
 		widthAmt = 9;
 		leftStart = (v != 73) ? 73 : 75;


Commit: 39c66afe6698faaa5ccac78e6cbb85b11c1118b3
    https://github.com/scummvm/scummvm/commit/39c66afe6698faaa5ccac78e6cbb85b11c1118b3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-10T22:14:57-04:00

Commit Message:
MADS: Fixes for inventory scrollbar display

Changed paths:
    engines/mads/game.cpp
    engines/mads/screen.cpp
    engines/mads/screen.h
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index e2e956e..9296b95 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -175,7 +175,7 @@ void Game::sectionLoop() {
 		// Reset the user interface
 		_screenObjects._forceRescan = true;
 		_screenObjects._inputMode = kInputBuildingSentences;
-		_scene._userInterface._scrollerY = 0;
+		_scene._userInterface._scrollbarActive = SCROLLBAR_NONE;
 		
 		_player._loadsFirst = true;
 
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 519dcab..9824a3e 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -261,13 +261,10 @@ ScreenObjects::ScreenObjects(MADSEngine *vm) : _vm(vm) {
 	_v7FED6 = 0;
 	_v8332A = 0;
 	_category = CAT_NONE;
-	_newDescId = 0;
-	_newDescId = 0;
+	_spotId = 0;
 	_released = false;
 	_uiCount = 0;
 	_selectedObject = -1;
-	_scrollerY = -1;
-	_milliTime = 0;
 	_eventFlag = false;
 	_baseTime = 0;
 }
@@ -292,14 +289,14 @@ void ScreenObjects::check(bool scanFlag) {
 	if (!_vm->_events->_mouseButtons || _inputMode != kInputBuildingSentences)
 		_vm->_events->_rightMousePressed = false;
 
-	if ((_vm->_events->_mouseMoved || _vm->_game->_scene._userInterface._scrollerY 
+	if ((_vm->_events->_mouseMoved || userInterface._scrollbarActive 
 			|| _v8332A || _forceRescan) && scanFlag) {
 		_category = CAT_NONE;
 		_selectedObject = scanBackwards(_vm->_events->currentPos(), LAYER_GUI);
 		if (_selectedObject > 0) {
 			ScreenObject &scrObject = (*this)[_selectedObject];
 			_category = (ScrCategory)(scrObject._category & 7);
-			_newDescId = scrObject._descId;
+			_spotId = scrObject._descId;
 		}
 
 		// Handling for easy mouse
@@ -335,13 +332,13 @@ void ScreenObjects::check(bool scanFlag) {
 			scene._userInterface._category = CAT_NONE;
 		}
 
-		if (_vm->_events->_mouseButtons || _vm->_easyMouse || scene._userInterface._scrollerY)
-			checkScroller();
+		if (_vm->_events->_mouseButtons || _vm->_easyMouse || userInterface._scrollbarActive)
+			scene._userInterface.updateInventoryScroller();
 
 		if (_vm->_events->_mouseButtons || _vm->_easyMouse)
 			scene._action.set();
 
-		_forceRescan = 0;
+		_forceRescan = false;
 	}
 
 	scene._action.refresh();
@@ -380,83 +377,6 @@ int ScreenObjects::scanBackwards(const Common::Point &pt, int layer) {
 	return 0;
 }
 
-void ScreenObjects::checkScroller() {
-	UserInterface &userInterface = _vm->_game->_scene._userInterface;
-	Common::Array<int> &inventoryList = _vm->_game->_objects._inventoryList;
-
-	if (_inputMode != kInputBuildingSentences)
-		return;
-
-	userInterface._scrollerY = 0;
-	
-	if ((_category == CAT_INV_SCROLLER || (_scrollerY == 3 && _vm->_events->_mouseStatusCopy))
-			&& (_vm->_events->_mouseStatusCopy || _vm->_easyMouse)) {
-		if ((_vm->_events->_vD2 || (_vm->_easyMouse && !_vm->_events->_mouseStatusCopy))
-				&& _category == CAT_INV_SCROLLER) {
-			_currentDescId = _newDescId;
-		}
-	}
-
-	if (_newDescId == _currentDescId || _scrollerY == 3) {
-		_vm->_game->_scene._userInterface._scrollerY = _currentDescId;
-		uint32 currentMilli = g_system->getMillis();
-		uint32 timeInc = _eventFlag ? 100 : 380;
-		
-		if (_vm->_events->_vD2 || (_milliTime + timeInc) <= currentMilli) {
-			_eventFlag = _vm->_events->_vD2 < 1;
-			_milliTime = currentMilli;
-
-			switch (_currentDescId) {
-			case 1:
-				// Scroll up
-				if (userInterface._inventoryTopIndex > 0 && inventoryList.size() > 0) {
-					--userInterface._inventoryTopIndex;
-					userInterface._inventoryChanged = true;
-				}
-				break;
-
-			case 2:
-				// Scroll down
-				if (userInterface._inventoryTopIndex < (int)inventoryList.size() &&
-						inventoryList.size() > 0) {
-					++userInterface._inventoryTopIndex;
-					userInterface._inventoryChanged = true;
-				}
-				break;
-
-			case 3: {
-				// Inventory slider
-				int newIndex = CLIP((int)_vm->_events->currentPos().y - 170, 0, 17)
-					* inventoryList.size() / 10;
-				if (newIndex >= (int)inventoryList.size())
-					newIndex = inventoryList.size() - 1;
-
-				if (inventoryList.size() > 0) {
-					userInterface._inventoryChanged = newIndex != userInterface._inventoryTopIndex;
-					userInterface._inventoryTopIndex = newIndex;
-				}
-				break;
-			}
-
-			default:
-				break;
-			}
-
-			if (userInterface._inventoryChanged) {
-				int dummy;
-				userInterface.updateSelection(CAT_INV_LIST, 0, &dummy);
-			}
-		}
-	}
-
-	if (userInterface._scrollerY != _scrollerY ||
-			userInterface._objectY != _objectY)
-		userInterface.scrollerChanged();
-
-	_scrollerY = userInterface._scrollerY;
-	_objectY = userInterface._objectY;
-}
-
 void ScreenObjects::elementHighlighted() {
 	Scene &scene = _vm->_game->_scene;
 	UserInterface &userInterface = scene._userInterface;
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index 11b8134..5be627a 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -140,15 +140,8 @@ class ScreenObjects : public Common::Array<ScreenObject> {
 private:
 	MADSEngine *_vm;
 	int _objectY;
-	int _scrollerY;
 
 	int scanBackwards(const Common::Point &pt, int layer);
-
-	/**
-	 * Checks for the mouse being on the user interface inventory scroller,
-	 * and update the scroller and selected inventory object as necessary
-	 */
-	void checkScroller();
 public:
 	InputMode _inputMode;
 	int _v7FED6;
@@ -156,13 +149,11 @@ public:
 	int _forceRescan;
 	int _selectedObject;
 	ScrCategory _category;
-	int _newDescId;
-	int _currentDescId;
 	bool _released;
 	int _uiCount;
-	uint32 _milliTime;
 	bool _eventFlag;
 	uint32 _baseTime;
+	int _spotId;
 
 	/*
 	* Constructor
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 3ae571c..a850c9a 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -208,11 +208,15 @@ UserInterface::UserInterface(MADSEngine *vm) : _vm(vm), _dirtyAreas(vm),
 	_scrollFlag = false;
 	_category = CAT_NONE;
 	_inventoryTopIndex = 0;
-	_objectY = 0;
 	_selectedInvIndex = -1;
 	_selectedActionIndex = 0;
 	_selectedItemVocabIdx = -1;
-	_scrollerY = 0;
+	_scrollbarActive = SCROLLBAR_NONE;
+	_scrollbarOldActive = SCROLLBAR_NONE;
+	_scrollbarStrokeType = SCROLLBAR_NONE;
+	_scrollbarQuickly = false;
+	_scrollbarMilliTime = 0;
+	_scrollbarElevator = _scrollbarOldElevator = 0;
 	_highlightedCommandIndex = -1;
 	_highlightedInvIndex = -1;
 	_highlightedItemVocabIndex = -1;
@@ -327,11 +331,95 @@ void UserInterface::drawItemVocabList() {
 }
 
 void UserInterface::drawScrolller() {
-	if (_scrollerY > 0)
-		writeVocab(CAT_INV_SCROLLER, _scrollerY);
+	if (_scrollbarActive)
+		writeVocab(CAT_INV_SCROLLER, _scrollbarActive);
 	writeVocab(CAT_INV_SCROLLER, 4);
 }
 
+void UserInterface::updateInventoryScroller() {
+	ScreenObjects &screenObjects = _vm->_game->_screenObjects;
+	Common::Array<int> &inventoryList = _vm->_game->_objects._inventoryList;
+
+	if (screenObjects._inputMode != kInputBuildingSentences)
+		return;
+
+	_scrollbarActive = SCROLLBAR_NONE;
+
+	if ((
+		(screenObjects._category == CAT_INV_SCROLLER) ||
+		(screenObjects._category != CAT_INV_SCROLLER && _scrollbarOldActive == SCROLLBAR_ELEVATOR)
+	) && (_vm->_events->_mouseStatusCopy || _vm->_easyMouse)) {
+		if ((_vm->_events->_mouseClicked || (_vm->_easyMouse && !_vm->_events->_mouseStatusCopy)) 
+				&& (screenObjects._category == CAT_INV_SCROLLER))
+			_scrollbarStrokeType = (ScrollbarActive)screenObjects._spotId;
+
+		if (screenObjects._spotId == _scrollbarStrokeType || _scrollbarOldActive == SCROLLBAR_ELEVATOR) {
+			_scrollbarActive = _scrollbarStrokeType;
+			uint32 currentMilli = g_system->getMillis();
+			uint32 timeInc = _scrollbarQuickly ? 100 : 380;
+
+			if (_vm->_events->_mouseClicked || (_vm->_events->_mouseStatusCopy && (_scrollbarMilliTime + timeInc) <= currentMilli)) {
+				_scrollbarQuickly = _vm->_events->_vD2 < 1;
+				_scrollbarMilliTime = currentMilli;
+
+				switch (_scrollbarStrokeType) {
+				case 1:
+					// Scroll up
+					if (_inventoryTopIndex > 0 && inventoryList.size() > 0) {
+						--_inventoryTopIndex;
+						_inventoryChanged = true;
+					}
+					break;
+
+				case 2:
+					// Scroll down
+					if (_inventoryTopIndex < ((int)inventoryList.size() - 1) && inventoryList.size() > 1) {
+						++_inventoryTopIndex;
+						_inventoryChanged = true;
+					}
+					break;
+
+				case 3: {
+					// Inventory slider
+					int newIndex = CLIP((int)_vm->_events->currentPos().y - 170, 0, 17)
+						* inventoryList.size() / 10;
+					if (newIndex >= (int)inventoryList.size())
+						newIndex = inventoryList.size() - 1;
+
+					if (inventoryList.size() > 0) {
+						_inventoryChanged = newIndex != _inventoryTopIndex;
+						_inventoryTopIndex = newIndex;
+					}
+					break;
+				}
+
+				default:
+					break;
+				}
+
+				if (_inventoryChanged) {
+					int dummy;
+					updateSelection(CAT_INV_LIST, 0, &dummy);
+				}
+			}
+		}
+	}
+
+	if (_scrollbarActive != _scrollbarOldActive || _scrollbarElevator != _scrollbarOldElevator)
+		scrollbarChanged();
+
+	_scrollbarOldActive = _scrollbarActive;
+	_scrollbarOldElevator = _scrollbarElevator;
+}
+
+void UserInterface::scrollbarChanged() {
+	Common::Rect r(73, 4, 73 + 9, 4 + 38);
+	_uiSlots.add(r);
+	_uiSlots.draw(false, false);
+	drawScrolller();
+	updateRect(r);
+}
+
 void UserInterface::writeVocab(ScrCategory category, int id) {
 	Common::Rect bounds;
 	if (!getBounds(category, id, bounds))
@@ -393,7 +481,8 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
 			break;
 		}
 
-		font->setColorMode((id == 4) || (_scrollerY == 3) ? SELMODE_HIGHLIGHTED : SELMODE_UNSELECTED);
+		font->setColorMode((id == 4) || (_scrollbarActive == SCROLLBAR_ELEVATOR) ? 
+			SELMODE_HIGHLIGHTED : SELMODE_UNSELECTED);
 		font->writeString(this, vocabStr, Common::Point(bounds.left, bounds.top));
 		break;
 	default:
@@ -561,7 +650,7 @@ bool UserInterface::getBounds(ScrCategory category, int v, Common::Rect &bounds)
 			break;
 		case 4:
 			// Thumb
-			bounds.top = _objectY + 14;
+			bounds.top = _scrollbarElevator + 14;
 			bounds.setHeight(1);
 			break;
 		default:
@@ -753,6 +842,7 @@ void UserInterface::selectObject(int invIndex) {
 
 void UserInterface::updateSelection(ScrCategory category, int newIndex, int *idx) {
 	Game &game = *_vm->_game;
+	Common::Array<int> &invList = game._objects._inventoryList;
 	Common::Rect bounds;
 
 	if (category == CAT_INV_LIST && _inventoryChanged) {
@@ -764,11 +854,11 @@ void UserInterface::updateSelection(ScrCategory category, int newIndex, int *idx
 		updateRect(bounds);
 		_inventoryChanged = false;
 
-		if (game._objects._inventoryList.size() > 1) {
-			_objectY = 0;
+		if (invList.size() < 2) {
+			_scrollbarElevator = 0;
 		} else {
-			int v = _inventoryTopIndex * 18 / (game._objects._inventoryList.size() - 1);
-			_objectY = MIN(v, 17);
+			int v = _inventoryTopIndex * 18 / (invList.size() - 1);
+			_scrollbarElevator = MIN(v, 17);
 		}
 	} else {
 		int oldIndex = *idx;
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 46ba478..f069173 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -33,6 +33,14 @@ namespace MADS {
 
 enum { IMG_SPINNING_OBJECT = 200, IMG_TEXT_UPDATE = 201 };
 
+enum ScrollbarActive {
+	SCROLLBAR_NONE = 0,		// No state
+	SCROLLBAR_UP = 1,		// Up butotn
+	SCROLLBAR_DOWN = 2,		// Down button
+	SCROLLBAR_ELEVATOR = 3,	// Elevator bar
+	SCROLLBAR_THUMB = 4		// Scrollbar thumb
+};
+
 class AnimFrameEntry;
 
 class UISlot {
@@ -96,6 +104,7 @@ private:
 	bool _scrollFlag;
 	int _noSegmentsActive;
 	int _someSegmentsActive;
+	ScrollbarActive _scrollbarStrokeType;
 
 	/**
 	 * Loads the elements of the user interface
@@ -138,6 +147,11 @@ private:
 	void drawScrolller();
 
 	/**
+	 * Called when the inventory scrollbar has changed
+	 */
+	void scrollbarChanged();
+
+	/**
 	 * Draw a UI textual element
 	 */
 	void writeVocab(ScrCategory category, int id);
@@ -153,11 +167,10 @@ public:
 	Common::Rect _drawBounds;
 	Common::Rect *_rectP;
 	int _inventoryTopIndex;
-	int _objectY;
 	int _selectedInvIndex;
 	int _selectedActionIndex;
 	int _selectedItemVocabIdx;
-	int _scrollerY;
+	ScrollbarActive _scrollbarActive, _scrollbarOldActive;
 	int _highlightedCommandIndex;
 	int _highlightedInvIndex;
 	int _highlightedItemVocabIndex;
@@ -165,6 +178,9 @@ public:
 	int _categoryIndexes[8];
 	Common::StringArray _talkStrings;
 	Common::Array<int> _talkIds;
+	bool _scrollbarQuickly;
+	uint32 _scrollbarMilliTime;
+	int _scrollbarElevator, _scrollbarOldElevator;
 public:
 	/**
 	* Constructor
@@ -219,6 +235,12 @@ public:
 
 	void scrollInventory();
 
+	/**
+	* Checks for the mouse being on the user interface inventory scroller,
+	* and update the scroller highlight and selected inventory object as necessary
+	*/
+	void updateInventoryScroller();
+
 	void emptyTalkList();
 };
 


Commit: a30e78137e326c49d7de09f4fb2293bedfdd4a30
    https://github.com/scummvm/scummvm/commit/a30e78137e326c49d7de09f4fb2293bedfdd4a30
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-10T22:34:26-04:00

Commit Message:
MADS: Added method stub for unhandled action method

Changed paths:
    engines/mads/game.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/game_nebular.h



diff --git a/engines/mads/game.h b/engines/mads/game.h
index 5659366..c7cb660 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -156,6 +156,11 @@ public:
 	virtual void doObjectAction() = 0;
 
 	/**
+	 * Fallback handler for any action that isn't explicitly handled
+	 */
+	virtual void unhandledAction() = 0;
+
+	/**
 	 * Global game step
 	 */
 	virtual void step() = 0;
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 467f3c3..ed7d976 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -376,7 +376,7 @@ void GameNebular::doObjectAction() {
 		_objects.addToInventory(OBJ_COMBINATION);
 		dialogs.showPicture(OBJ_COMBINATION, 851);
 	} else if ((action.isAction(VERB_LOOK) || action.isAction(NOUN_READ)) &&
-			((id = _objects.getIdFromDesc(action._activeAction._objectNameId)) != 0 ||
+			((id = _objects.getIdFromDesc(action._activeAction._objectNameId)) > 0 ||
 			(action._activeAction._indirectObjectId > 0 &&
 			(id = _objects.getIdFromDesc(action._activeAction._indirectObjectId))))) {
 		if (id == OBJ_REPAIR_LIST) {
@@ -565,6 +565,10 @@ void GameNebular::doObjectAction() {
 	action._inProgress = false;
 }
 
+void GameNebular::unhandledAction() {
+	warning("TODO: unhandledAction");
+}
+
 void GameNebular::step() {
 	if (_player._visible && _player._stepEnabled && !_player._moving &&
 		(_player._facing == _player._turnToFacing)) {
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index e4f4efc..4d011c2 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -67,6 +67,8 @@ public:
 
 	virtual void doObjectAction();
 
+	virtual void unhandledAction();
+
 	virtual void step();
 };
 


Commit: 4225304a34a5fc04280e72206c4d3dea13e29ad8
    https://github.com/scummvm/scummvm/commit/4225304a34a5fc04280e72206c4d3dea13e29ad8
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-11T07:47:38+02:00

Commit Message:
MADS: Implement scene 102

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 5064795..c9a6165 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -134,20 +134,20 @@ void Scene101::sayDang() {
 }
 
 void Scene101::enter() {
-	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 1), false);
-	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 2), false);
-	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 3), false);
-	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 4), false);
-	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('x', 5), false);
-	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('x', 6), false);
-	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('x', 7), false);
-	_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('m', -1), false);
-	_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('b', 1), false);
-	_globals._spriteIndexes[10] = _scene->_sprites.addSprites(formAnimName('b', 2), false);
-	_globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('a', 0), false);
-	_globals._spriteIndexes[12] = _scene->_sprites.addSprites(formAnimName('a', 1), false);
-	_globals._spriteIndexes[13] = _scene->_sprites.addSprites(formAnimName('x', 8), false);
-	_globals._spriteIndexes[14] = _scene->_sprites.addSprites(formAnimName('x', 0), false);
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 2));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 3));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 4));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('x', 5));
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('x', 6));
+	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('x', 7));
+	_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('m', -1));
+	_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('b', 1));
+	_globals._spriteIndexes[10] = _scene->_sprites.addSprites(formAnimName('b', 2));
+	_globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('a', 0));
+	_globals._spriteIndexes[12] = _scene->_sprites.addSprites(formAnimName('a', 1));
+	_globals._spriteIndexes[13] = _scene->_sprites.addSprites(formAnimName('x', 8));
+	_globals._spriteIndexes[14] = _scene->_sprites.addSprites(formAnimName('x', 0));
 
 	_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 0, 0, 25);
 	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 4, 0, 1, 0);
@@ -601,27 +601,594 @@ void Scene101::actions() {
 /*------------------------------------------------------------------------*/
 
 void Scene102::setup() {
+	_scene->_animationData->preLoad(formAnimName('A', -1), 3);
+	setPlayerSpritesPrefix();
+	setAAName();
+}
 
+void Scene102::addRandomMessage() {
+	_scene->_kernelMessages.reset();
+	_game._triggerSetupMode = KERNEL_TRIGGER_DAEMON;
+	int quoteId = _vm->getRandomNumber(65, 69);
+	_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 73, 120, _game.getQuote(quoteId));
+	_activeMsgFl = true;
 }
 
 void Scene102::enter() {
+	sceneEntrySound();
+
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 2));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 3));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 4));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('x', 5));
+
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('b', -1));
+	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('c', -1));
+	_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('e', -1));
+	_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('n', -1));
+	_globals._spriteIndexes[10] = _scene->_sprites.addSprites(formAnimName('g', -1));
+	_globals._spriteIndexes[11] = _scene->_sprites.addSprites("*RXMRC_8");
+	_globals._spriteIndexes[13] = _scene->_sprites.addSprites(formAnimName('x', 0));
+
+	_globals._spriteIndexes[15+1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 8, 0, 0, 0);
+	_globals._spriteIndexes[15+2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 170, 0, 1, 6);
+	_globals._spriteIndexes[15+3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 11, 0, 2, 3);
+	_globals._spriteIndexes[15+4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 4, 0, 1, 0);
+	_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 3, 0, 0, 5);
+
+	if (!_game._objects.isInRoom(OBJ_BINOCULARS))
+		_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 24, 0, 0, 24);
+	else
+		_scene->_hotspots.activate(0x27, false);
 
+	_scene->_hotspots.activate(0x35, false);
+
+	if (_globals[kMedicineCabinetOpen]) {
+		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[23], -2, -2);
+	}
+
+	if (_scene->_priorSceneId == 101) {
+		_game._player._playerPos = Common::Point(229, 109);
+		_game._player._stepEnabled = false;
+		_globals._spriteIndexes[21] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[6], false, 6, 1, 2, 0);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 70);
+	} else if (_scene->_priorSceneId == 103) {
+		_game._player._playerPos = Common::Point(47, 152);
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._facing = FACING_NORTHWEST;
+		_game._player._playerPos = Common::Point(32, 129);
+	}
+
+	if (_scene->_priorSceneId != 106) {
+		if (_globals[kWaterInAPuddle]) {
+			_globals._spriteIndexes[28] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[13], false, 6, 0, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._spriteIndexes[28], -2, -2);
+			_scene->_sequences.setDepth(_globals._spriteIndexes[28], 5);
+		}
+	} else {
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_globals._spriteIndexes[28] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[13], false, 6, 1, 0, 0);
+		_scene->_sequences.addSubEntry(_globals._spriteIndexes[28], SM_0, 0, 72);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[28], 5);
+		_vm->_sound->command(24);
+		_vm->_sound->command(28);
+	}
+
+	_fridgeOpenedFl = false;
+	_fridgeOpenedDescr = false;
+	_fridgeCommentCount = 0;
+	_fridgeFirstOpenFl = true;
+	_chairDescrFl = false;
+	_activeMsgFl = false;
+
+	_game.loadQuoteSet(0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x45, 0x43, 0);
+
+	if (_scene->_priorSceneId == 101)
+		_vm->_sound->command(20);
 }
 
 void Scene102::step() {
+	if (_game._trigger == 70)
+		_game._player._stepEnabled = true;
 
+	if (_game._trigger == 72) {
+		_globals._spriteIndexes[28] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[13], false, 6, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._spriteIndexes[28], -2, -2);
+		_scene->_sequences.setDepth(_globals._spriteIndexes[28], 5);
+		_scene->_sequences.addTimer(48, 90);
+	}
+
+	if (_game._trigger >= 90) {
+		if (_game._trigger >= 94) {
+			_scene->loadAnimation(formAnimName('B', -1), 71);
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+
+			_globals[kWaterInAPuddle] = true;
+			_vm->_sound->command(24);
+		} else {
+			_vm->_sound->command(23);
+			_scene->_sequences.addTimer(48, _game._trigger + 1);
+		}
+	}
+
+	if (_game._trigger == 71) {
+		_game._player._stepEnabled = true;
+		_game._player._visible = true;
+		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+	}
+
+	if (_fridgeOpenedFl && !_fridgeOpenedDescr) {
+		_fridgeCommentCount++;
+		if (_fridgeCommentCount > 16384) {
+			_fridgeOpenedDescr = true;
+			_vm->_dialogs->show(0x27E5);
+		}
+	}
+
+	if (!_activeMsgFl && (_game._player._playerPos == Common::Point(177, 114)) && (_game._player._facing == FACING_NORTH)
+	&& (_vm->getRandomNumber(1, 5000) == 1)) {
+		_scene->_kernelMessages.reset();
+		_activeMsgFl = false;
+		addRandomMessage();
+	}
+
+	if (_game._trigger == 73)
+		_activeMsgFl = false;
 }
 
 void Scene102::preActions() {
+	if (_action.isAction(0x122) || _action.isAction(0x117))
+		_game._player._needToWalk = _game._player._readyToWalk;
+
+	if (_fridgeOpenedFl && !_action.isAction(0x122)) {
+		switch (_game._trigger) {
+		case 0:
+			if (_game._player._needToWalk) {
+				_scene->_sequences.remove(_globals._spriteIndexes[22]);
+				_globals._spriteIndexes[22] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[7], false, 6, 1, 0, 0);
+				_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 1);
+				_scene->_sequences.setDepth(_globals._spriteIndexes[22], 15);
+				_game._player._stepEnabled = false;
+				_vm->_sound->command(20);
+			}
+			break;
+
+		case 1:
+			if (_game._objects.isInRoom(OBJ_BURGER)) {
+				_scene->_sequences.remove(_globals._spriteIndexes[25]);
+				_scene->_hotspots.activate(0x35, false);
+			}
+			_fridgeOpenedFl = false;
+			_game._player._stepEnabled = true;
+			break;
+		}
+	}
 
+	if (_game._player._needToWalk)
+		_scene->_kernelMessages.reset();
 }
 
 void Scene102::actions() {
+	bool justOpenedFl = false;
+
+	if (_action._lookFlag) {
+		_vm->_dialogs->show(0x27FA);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(0x122) && !_fridgeOpenedFl) {
+		switch (_game._trigger) {
+		case 0:
+			_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._spriteIndexes[22], 15);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 1);
+			if (_game._objects.isInRoom(OBJ_BURGER)) {
+				_globals._spriteIndexes[25] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[10], false, 7, 0, 0, 0);
+				_scene->_sequences.setDepth(_globals._spriteIndexes[25], 14);
+			}
+			_game._player._stepEnabled = false;
+			_vm->_sound->command(20);
+			_action._inProgress = false;
+			return;
+
+		case 1:
+			_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 6, 0, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._spriteIndexes[22], -2, -2);
+			_scene->_sequences.setDepth(_globals._spriteIndexes[22], 15);
+			int delay;
+			if (_action.isAction(VERB_WALKTO) && !_fridgeFirstOpenFl)
+				delay = 0;
+			else
+				delay = 48;
+			_scene->_sequences.addTimer(delay, 2);
+			_action._inProgress = false;
+			return;
+
+		case 2:
+			_fridgeOpenedFl = true;
+			_fridgeOpenedDescr = false;
+			_fridgeCommentCount = 0;
+			_game._player._stepEnabled = true;
+			justOpenedFl = true;
+			if (_game._objects.isInRoom(OBJ_BURGER))
+				_scene->_hotspots.activate(0x35, true);
+			break;
+		}
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x122) || _action.isAction(VERB_OPEN, 0x122)) {
+		if (_game._objects.isInRoom(OBJ_BURGER))
+			_vm->_dialogs->show(0x27F6);
+		else
+			_vm->_dialogs->show(0x27F5);
+
+		_fridgeFirstOpenFl = false;
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_WALKTO, 0x122) && justOpenedFl) {
+		_fridgeFirstOpenFl = false;
+		int quoteId = _vm->getRandomNumber(59, 63);
+		Common::String curQuote = _game.getQuote(quoteId);
+		int width = _vm->_font->getWidth(curQuote, -1);
+		_scene->_kernelMessages.reset();
+		_game._triggerSetupMode = KERNEL_TRIGGER_DAEMON;
+		_scene->_kernelMessages.add(Common::Point(210, 60), 0x1110, 0, 73, 120, curQuote);
+		_scene->_kernelMessages.add(Common::Point(214 + width, 60), 0x1110, 0, 73, 120, _game.getQuote(64));
+		_activeMsgFl = true;
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_CLOSE, 0x122)) {
+		_vm->_dialogs->show(0x27E5);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_TAKE, 0x122)) {
+		_vm->_dialogs->show(0x8);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(0x18B, 0x6E)) {
+		switch (_game._trigger) {
+		case 0:
+			_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 1, 0, 0);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 1);
+			_game._player._stepEnabled = false;
+			_vm->_sound->command(20);
+			break;
+
+		case 1:
+			_scene->_nextSceneId = 101;
+			break;
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_WALKTO, 0x79)) {
+		_scene->_nextSceneId = 103;
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_WALKTO, 0x117) || _action.isAction(VERB_LOOK, 0x117) || _action.isAction(VERB_WALKTO, 0x27)) {
+		addRandomMessage();
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x194)) {
+		_vm->_dialogs->show(0x27E4);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x79)) {
+		_vm->_dialogs->show(0x27DD);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x6E)) {
+		_vm->_dialogs->show(0x27DC);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(0x155, 0x46) || _action.isAction(VERB_LOOK, 0x46)) {
+		_vm->_dialogs->show(0x27DB);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(0x155, 0xFD) || _action.isAction(VERB_LOOK, 0xFD)) {
+		_vm->_dialogs->show(0x27DA);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x127)) {
+		_vm->_dialogs->show(0x27E7);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_PUT, 0x35, 0x127) && _game._objects.isInInventory(OBJ_BURGER)) {
+		_vm->_dialogs->show(0x27E8);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_PUT, 0x122) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
+		_vm->_dialogs->show(0x27E9);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_PUT, 0x127) && (_action.isAction(0x65) || _action.isAction(0x157))) {
+		_vm->_dialogs->show(0x27F6);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_OPEN, 0x127)) {
+		_vm->_dialogs->show(0x27EA);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x52)) {
+		_vm->_dialogs->show(0x27EB);
+		_action._inProgress = false;
+		return;
+	}
+
+	if ((_action.isAction(0xC7) || _action.isAction(0xA3)) && (_action.isAction(VERB_LOOK) || _action.isAction(0x50) || _action.isAction(0x4F))) {
+		if (_game._objects.isInInventory(OBJ_REBREATHER)) {
+			if (!_action.isAction(0x50) && !_action.isAction(0x4F)) {
+				_vm->_dialogs->show(0x27F7);
+				_action._inProgress = false;
+				return;
+			}
+		} else if (_action.isAction(VERB_LOOK) || (_game._difficulty == DIFFICULTY_IMPOSSIBLE)) {
+			_vm->_dialogs->show(0x27EE);
+			_action._inProgress = false;
+			return;
+		}
+	}
+
+	if ( (_action.isAction(0xC7) || _action.isAction(0xA3)) && (_action.isAction(0x50) || _action.isAction(0x4F)) ) {
+		switch (_game._trigger) {
+		case 0:
+			_scene->loadAnimation(formAnimName('A', -1), 1);
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			break;
+
+		case 1:
+			_vm->_sound->command(24);
+			_scene->_sequences.addTimer(48, 2);
+			break;
+
+		case 2:
+		case 3:
+		case 4:
+			_vm->_sound->command(23);
+			_scene->_sequences.addTimer(48, _game._trigger + 1);
+			break;
+
+		case 5:
+			_vm->_sound->command(24);
+			_scene->_sequences.addTimer(48, _game._trigger + 1);
+			break;
+
+		case 6:
+			if (_game._objects.isInInventory(OBJ_REBREATHER) && !_game._visitedScenes.exists(106))
+				_vm->_dialogs->show(0x27FD);
+			_scene->_nextSceneId = 106;
+			break;
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x118)) {
+		_vm->_dialogs->show(0x27F2);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x197) || _action.isAction(0xD3, 0x197)) {
+		_vm->_dialogs->show(0x27F3);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x70) || _action.isAction(VERB_WALKTO, 0x70)) {
+		_vm->_dialogs->show(0x27F4);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x71) || ((_action.isAction(VERB_CLOSE, 0x71) || _action.isAction(VERB_PUSH, 0x71)) && !_drawerDescrFl)) {
+		_vm->_dialogs->show(0x27EC);
+		_drawerDescrFl = true;
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_CLOSE, 0x71) || _action.isAction(VERB_PUSH, 0x71)) {
+		_vm->_dialogs->show(0x27ED);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_OPEN, 0x71)) {
+		_vm->_dialogs->show(0x27FC);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x47) || (_action.isAction(0x13F, 0x47) && !_chairDescrFl)) {
+		_chairDescrFl = true;
+		_vm->_dialogs->show(0x27E2);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(0x13F, 0x47)) {
+		_vm->_dialogs->show(0x27E3);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0xDE)) {
+		if (_globals[kMedicineCabinetOpen])
+			_vm->_dialogs->show(0x27DF);
+		else
+			_vm->_dialogs->show(0x27DE);
 
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_CLOSE, 0xDE) && _globals[kMedicineCabinetOpen]) {
+		switch (_game._trigger) {
+		case 0:
+			_scene->_sequences.remove(_globals._spriteIndexes[23]);
+			_globals._spriteIndexes[23] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 1);
+			_game._player._stepEnabled = false;
+			_vm->_sound->command(21);
+			break;
+
+		case 1:
+			_scene->_sequences.addTimer(48, 2);
+			break;
+
+		case 2:
+			_game._player._stepEnabled = true;
+			_globals[kMedicineCabinetOpen] = false;
+			_vm->_dialogs->show(0x27E1);
+			break;
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_OPEN, 0xDE) && !_globals[kMedicineCabinetOpen]) {
+		switch (_game._trigger) {
+		case 0:
+			_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 1);
+			_game._player._stepEnabled = false;
+			_vm->_sound->command(21);
+			break;
+
+		case 1:
+			_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 0, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._spriteIndexes[23], -2, -2);
+			_scene->_sequences.addTimer(48, 2);
+			break;
+
+		case 2:
+			_game._player._stepEnabled = true;
+			_globals[kMedicineCabinetOpen] = true;
+			if (_globals[kMedicineCabinetVirgin]) {
+				_vm->_dialogs->show(0x27E0);
+			} else {
+				_vm->_dialogs->show(0x27DF);
+			}
+			_globals[kMedicineCabinetVirgin] = false;
+			break;
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_TAKE, 0x27) && _game._objects.isInRoom(OBJ_BINOCULARS)) {
+		switch (_game._trigger) {
+		case 0:
+			_globals._spriteIndexes[26] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[11], false, 3, 1, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._spriteIndexes[26]);
+			_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_0, 0, 1);
+			_game._player._visible = false;
+			_game._player._stepEnabled = false;
+			break;
+
+		case 1:
+			_game._objects.addToInventory(OBJ_BINOCULARS);
+			_scene->_sequences.remove(_globals._spriteIndexes[15+9]);
+			_scene->_hotspots.activate(0x27, false);
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			_vm->_sound->command(22);
+			_vm->_dialogs->showPicture(OBJ_BINOCULARS, 0x27D9);
+			break;
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_TAKE, 0x35) && _game._objects.isInRoom(OBJ_BURGER)) {
+		if (_game._trigger == 0) {
+			_vm->_dialogs->showPicture(OBJ_BURGER, 0x27FB);
+			_scene->_sequences.remove(_globals._spriteIndexes[25]);
+			_game._objects.addToInventory(OBJ_BURGER);
+			_scene->_hotspots.activate(0x35, false);
+			_vm->_sound->command(22);
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_TAKE, 0x117)) {
+		_vm->_dialogs->show(0x27F0);
+		_action._inProgress = false;
+		return;
+	}
+
+	if ((_action.isAction(VERB_PUSH) || _action.isAction(VERB_PULL)) && _action.isAction(0x194)) {
+		_vm->_dialogs->show(0x27F1);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x89)) {
+		_vm->_dialogs->show(0x27F8);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x27) && !_game._objects.isInInventory(OBJ_BINOCULARS)) {
+		_vm->_dialogs->show(0x27F9);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x35) && (_action._mainObjectSource == 4)) {
+		_vm->_dialogs->show(0x321);
+		_action._inProgress = false;
+	}
 }
 
 void Scene102::postActions() {
-
+	if (_action.isAction(VERB_PUT, 0x127) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
+		_vm->_dialogs->show(0x27E9);
+		_action._inProgress = false;
+	}
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index 3f69223..782dbb5 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -77,6 +77,18 @@ public:
 };
 
 class Scene102 : public Scene1xx {
+private:
+	bool _fridgeOpenedFl;
+	bool _fridgeOpenedDescr;
+	bool _fridgeFirstOpenFl;
+	bool _chairDescrFl;
+	bool _drawerDescrFl;
+	bool _activeMsgFl;
+
+	int _fridgeCommentCount;
+
+	void addRandomMessage();
+
 public:
 	Scene102(MADSEngine *vm) : Scene1xx(vm) {}
 


Commit: d8c35b71dbd310d2012d501529867faab4875b29
    https://github.com/scummvm/scummvm/commit/d8c35b71dbd310d2012d501529867faab4875b29
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-11T08:19:18-04:00

Commit Message:
MADS: Fixed incorrect parameter order in scene 101 chair sit down

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/sequence.cpp
    engines/mads/sequence.h



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index c9a6165..7cc0ded 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -337,7 +337,7 @@ void Scene101::actions() {
 			switch (_game._trigger) {
 			case 0:
 				_scene->_sequences.remove(_globals._spriteIndexes[27]);
-				_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 0, 0, 1);
+				_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 1);
 				_scene->_sequences.setAnimRange(_globals._spriteIndexes[26], 1, 17);
 				_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_FRAME_INDEX, 10, 1);
 				_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_0, 0, 2);
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index fa6d745..409dc30 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -55,7 +55,7 @@ SequenceEntry::SequenceEntry() {
 	_entries._count = 0;
 	Common::fill(&_entries._mode[0], &_entries._mode[SEQUENCE_ENTRY_SUBSET_MAX], SM_0);
 	Common::fill(&_entries._frameIndex[0], &_entries._frameIndex[SEQUENCE_ENTRY_SUBSET_MAX], 0);
-	Common::fill(&_entries._abortVal[0], &_entries._abortVal[SEQUENCE_ENTRY_SUBSET_MAX], 0);
+	Common::fill(&_entries._trigger[0], &_entries._trigger[SEQUENCE_ENTRY_SUBSET_MAX], 0);
 }
 
 /*------------------------------------------------------------------------*/
@@ -80,14 +80,14 @@ void SequenceList::clear() {
 	}
 }
 
-bool SequenceList::addSubEntry(int index, SequenceSubEntryMode mode, int frameIndex, int abortVal) {
+bool SequenceList::addSubEntry(int index, SequenceSubEntryMode mode, int frameIndex, int trigger) {
 	if (_entries[index]._entries._count >= SEQUENCE_ENTRY_SUBSET_MAX)
 		return true;
 
 	int subIndex = _entries[index]._entries._count++;
 	_entries[index]._entries._mode[subIndex] = mode;
 	_entries[index]._entries._frameIndex[subIndex] = frameIndex;
-	_entries[index]._entries._abortVal[subIndex] = abortVal;
+	_entries[index]._entries._trigger[subIndex] = trigger;
 
 	return false;
 }
@@ -325,7 +325,7 @@ bool SequenceList::loadSprites(int seqIndex) {
 	}
 
 	if (idx >= 0) {
-		_vm->_game->_trigger = seqEntry._entries._abortVal[idx];
+		_vm->_game->_trigger = seqEntry._entries._trigger[idx];
 		_vm->_game->_triggerMode = seqEntry._triggerMode;
 
 		if (seqEntry._triggerMode != KERNEL_TRIGGER_DAEMON)
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index 6d12367..99e8951 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -42,7 +42,7 @@ struct SequenceSubEntries {
 	int _count;
 	SequenceSubEntryMode _mode[SEQUENCE_ENTRY_SUBSET_MAX];
 	int _frameIndex[SEQUENCE_ENTRY_SUBSET_MAX];
-	int8 _abortVal[SEQUENCE_ENTRY_SUBSET_MAX];
+	int8 _trigger[SEQUENCE_ENTRY_SUBSET_MAX];
 };
 
 struct SequenceEntry {
@@ -95,7 +95,7 @@ public:
 
 	SequenceEntry &operator[](int index) { return _entries[index]; }
 	void clear();
-	bool addSubEntry(int index, SequenceSubEntryMode mode, int frameIndex, int abortVal);
+	bool addSubEntry(int index, SequenceSubEntryMode mode, int frameIndex, int trigger);
 	int add(int spriteListIndex, bool flipped, int frameIndex, int triggerCountdown, int delayTicks,
 		int extraTicks, int numTicks, int msgX, int msgY, bool nonFixed, char scale, uint8 depth,
 		int frameInc, SpriteAnimType animType, int numSprites, int frameStart);


Commit: 9ef9dd24c273950328a4f5ea99b36c91b4a4de81
    https://github.com/scummvm/scummvm/commit/9ef9dd24c273950328a4f5ea99b36c91b4a4de81
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-11T08:52:18-04:00

Commit Message:
MADS: Replace warning with call to stubbed unhandledAction method

Changed paths:
    engines/mads/scene.cpp



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 02a066a..9f8c922 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -489,7 +489,7 @@ void Scene::doAction() {
 			}
 
 			if (_action._inProgress)
-				warning("TODO: sub_1D9DE");
+				_vm->_game->unhandledAction();
 		}
 	}
 


Commit: f548711b7740fcaa01027a9184e4ae90a1c792e9
    https://github.com/scummvm/scummvm/commit/f548711b7740fcaa01027a9184e4ae90a1c792e9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-11T09:34:46-04:00

Commit Message:
MADS: Fix palette transformation during SceneInfo::load

Changed paths:
    engines/mads/palette.cpp
    engines/mads/scene_data.cpp



diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 34ba0ac..2ff16fb5 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -250,7 +250,7 @@ void PaletteUsage::transform(Common::Array<RGB6> &palette) {
 	if (!empty()) {
 		for (uint i = 0; i < _data.size(); ++i) {
 			int palIndex = _data[i]._palIndex;
-			_data[i] = palette[palIndex]._palIndex;
+			_data[i]._palIndex = palette[palIndex]._palIndex;
 		}
 	}
 }
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index f92ff86..a82f65a 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -219,7 +219,7 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 
 			for (uint i = 0; i < _palAnimData.size(); ++i) {
 				byte g = _palAnimData[i].g;
-				_palAnimData[g].b = artHeader._palAnimData[g].u;
+				_palAnimData[i].b = artHeader._palette[g]._palIndex;
 			}
 		}
 	}


Commit: 84552f07b4992b743695300b860f585806705fbd
    https://github.com/scummvm/scummvm/commit/84552f07b4992b743695300b860f585806705fbd
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-11T19:33:56+02:00

Commit Message:
MADS: Implement unhandledAction

Changed paths:
    dists/msvc9/create_msvc9.bat
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/dists/msvc9/create_msvc9.bat b/dists/msvc9/create_msvc9.bat
index 34bcccd..561772b 100644
--- a/dists/msvc9/create_msvc9.bat
+++ b/dists/msvc9/create_msvc9.bat
@@ -55,21 +55,21 @@ goto done
 echo.
 echo Creating project files with all engines enabled (stable and unstable)
 echo.
-create_project ..\.. --enable-all-engines --msvc --msvc-version 9
+create_project ..\.. --enable-all-engines --msvc --msvc-version 9  --disable-taskbar --disable-freetype --disable-jpeg --disable-engine=zvision
 goto done
 
 :stable
 echo.
 echo Creating normal project files, with only the stable engines enabled
 echo.
-create_project ..\.. --msvc --msvc-version 9
+create_project ..\.. --msvc --msvc-version 9  --disable-taskbar --disable-freetype --disable-jpeg --disable-engine=zvision
 goto done
 
 :tools
 echo.
 echo Creating tools project files
 echo.
-create_project ..\.. --tools --msvc --msvc-version 9
+create_project ..\.. --tools --msvc --msvc-version 9  --disable-taskbar --disable-freetype --disable-jpeg --disable-engine=zvision
 goto done
 
 :tests
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index ed7d976..b5c6e33 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -566,7 +566,115 @@ void GameNebular::doObjectAction() {
 }
 
 void GameNebular::unhandledAction() {
-	warning("TODO: unhandledAction");
+	int random = _vm->getRandomNumber(1, 1000);
+	MADSAction &action = _scene._action;
+
+	if (action.isAction(VERB_THROW, NOUN_BOMB) || action.isAction(VERB_THROW, NOUN_BOMBS)
+	|| action.isAction(VERB_THROW, NOUN_TIMEBOMB) || action.isAction(VERB_THROW, NOUN_CHICKEN_BOMB))
+		_vm->_dialogs->show(0x2A);
+	else if (action.isAction(0x6C))
+		_vm->_dialogs->show(0x1B3);
+	else if ((action.isAction(NOUN_EAT, NOUN_DEAD_FISH) || action.isAction(NOUN_EAT, NOUN_STUFFED_FISH)) && _vm->_game->_objects.isInInventory(_vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId)))
+		_vm->_dialogs->show(0xC);
+	else if ((action.isAction(NOUN_SMELL, NOUN_DEAD_FISH) || action.isAction(NOUN_SMELL, NOUN_STUFFED_FISH)) && _vm->_game->_objects.isInInventory(_vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId)))
+		_vm->_dialogs->show(0xD);
+	else if (action.isAction(NOUN_EAT, NOUN_CHICKEN) && _vm->_game->_objects.isInInventory(OBJ_CHICKEN))
+		_vm->_dialogs->show(0x390);
+	else if ((action.isAction(NOUN_SHOOT) || action.isAction(NOUN_HOSE_DOWN)) && action.isAction(NOUN_BLOWGUN)) {
+		if ((_scene._currentSceneId >= 104) && (_scene._currentSceneId <= 111))
+			_vm->_dialogs->show(0x26);
+		else if (action.isAction(0x10D))
+			_vm->_dialogs->show(0x29);
+		else if (action.isAction(NOUN_CHICKEN) || action.isAction(0x185) || action.isAction(0x14D)
+				|| action.isAction(0x1DD) || action.isAction(0x15F) || action.isAction(NOUN_CAPTIVE_CREATURE)) {
+			_vm->_dialogs->show(0x28);
+		} else
+			_vm->_dialogs->show(0x27);
+	} else if (action.isAction(VERB_TALKTO)) {
+		_globals[kTalkInanimateCount] = (_globals[kTalkInanimateCount] + 1) % 16;
+		if (!_globals[kTalkInanimateCount]) {
+			_vm->_dialogs->show(0x2);
+		} else {
+			Common::String tmpMsg = "\"Greetings, ";
+			tmpMsg += _vm->_game->_scene.getVocab(action._activeAction._objectNameId);
+			tmpMsg += "!\"";
+			_scene._kernelMessages.reset();
+			_scene._kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, tmpMsg);
+		}
+	} else if (action.isAction(VERB_GIVE, NOUN_DOOR, 0x46) || action.isAction(VERB_CLOSE, NOUN_CHAIR))
+		_vm->_dialogs->show(0x3);
+	else if (action.isAction(VERB_THROW)) {
+		int objId = _vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId);
+		if (objId < 0)
+			_vm->_dialogs->show(0x4);
+		else if (_vm->_game->_objects[objId]._roomNumber != 2)
+			_vm->_dialogs->show(0x5);
+		else
+			_vm->_dialogs->show(0x6);
+	} else if (action.isAction(VERB_LOOK)) {
+		if (action.isAction(0x27) && (action._activeAction._indirectObjectId > 0))
+			_vm->_dialogs->show(0xA);
+		else if (random < 600)
+			_vm->_dialogs->show(0x7);
+		else
+			_vm->_dialogs->show(0x15);
+	} else if (action.isAction(VERB_TAKE)) {
+		int objId = _vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId);
+		if (_vm->_game->_objects.isInInventory(objId))
+			_vm->_dialogs->show(0x10);
+		else if (random <= 333)
+			_vm->_dialogs->show(0x8);
+		else if (random <= 666)
+			_vm->_dialogs->show(0x16);
+		else
+			_vm->_dialogs->show(0x17);
+	} else if (action.isAction(VERB_CLOSE)) {
+		if (random <= 333)
+			_vm->_dialogs->show(0x9);
+		else
+			_vm->_dialogs->show(0x21);
+	} else if (action.isAction(VERB_OPEN)) {
+		if (random <= 500)
+			_vm->_dialogs->show(0x1E);
+		else if (random <= 750)
+			_vm->_dialogs->show(0x1F);
+		else
+			_vm->_dialogs->show(0x20);
+	} else if (action.isAction(VERB_PULL))
+		_vm->_dialogs->show(0x12);
+	else if (action.isAction(VERB_PUSH)) {
+		if (random < 750)
+			_vm->_dialogs->show(0x13);
+		else
+			_vm->_dialogs->show(0x14);
+	} else if (action.isAction(VERB_PUT)) {
+		int objId = _vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId);
+		if (_vm->_game->_objects.isInInventory(objId))
+			_vm->_dialogs->show(0x19);
+		else
+			_vm->_dialogs->show(0x18);
+	} else if (action.isAction(VERB_GIVE)) {
+		int objId = _vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId);
+		if (!_vm->_game->_objects.isInInventory(objId))
+			_vm->_dialogs->show(0x1A);
+		else if (random <= 500)
+			_vm->_dialogs->show(0x1C);
+		else
+			_vm->_dialogs->show(0x1D);
+	} else if (!action.isAction(VERB_WALKTO) && !action.isAction(0x187) && !action.isAction(0x18C) && !action.isAction(0x1AD)
+			&& !action.isAction(0x15C) && !action.isAction(0x159) && !action.isAction(0x15A) && !action.isAction(0x15B)
+			&& !action.isAction(0x15E)) {
+		if (random <= 100)
+			_vm->_dialogs->show(0x24);
+		else if (random <= 200)
+			_vm->_dialogs->show(0x1);
+		else if (random <= 475)
+			_vm->_dialogs->show(0x22);
+		else if (random <= 750)
+			_vm->_dialogs->show(0x23);
+		else
+			_vm->_dialogs->show(0x25);
+	}
 }
 
 void GameNebular::step() {
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 8e5bc05..357180e 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -41,10 +41,13 @@ enum {
 enum Noun {
 	NOUN_D              = 0xD,
 	NOUN_BLOWGUN		= 0x29,
+	NOUN_BOMB           = 0x2A,
+	NOUN_BOMBS          = 0x2B,
 	NOUN_2C             = 0x2C,
 	NOUN_BURGER			= 0x35,
 	NOUN_CHAIR			= 0x47,
-	NOUN_49             = 0x49,
+	NOUN_CHICKEN        = 0x49,
+	NOUN_CHICKEN_BOMB   = 0x4A,
 	NOUN_4E             = 0x4E,
 	NOUN_DEAD_FISH		= 0x65,
 	NOUN_DOOR			= 0x6E,
@@ -85,8 +88,9 @@ enum Noun {
 	NOUN_SMELL			= 0x147,
 	NOUN_STUFFED_FISH	= 0x157,
 	NOUN_15F            = 0x15F,
-	NOUN_VIEW_SCREEN	= 0x180,
-	NOUN_CAPTIVE_CREATURE	= 0x1C3,
+	NOUN_TIMEBOMB       = 0x171,
+	NOUN_VIEW_SCREEN    = 0x180,
+	NOUN_CAPTIVE_CREATURE = 0x1C3,
 	NOUN_NATIVE_WOMAN	= 0x1DC,
 	NOUN_ALCOHOL		= 0x310,
 	NOUN_DOLLOP			= 0x3AC,
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index d78b85e..4ef6f24 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1095,7 +1095,7 @@ void Scene205::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 	_scene->addActiveVocab(NOUN_D);
-	_scene->addActiveVocab(NOUN_49);
+	_scene->addActiveVocab(NOUN_CHICKEN);
 	_scene->addActiveVocab(NOUN_10D);
 }
 


Commit: 5ef46aff111ca2545256ff47fc591ce2f9225af1
    https://github.com/scummvm/scummvm/commit/5ef46aff111ca2545256ff47fc591ce2f9225af1
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-11T19:45:25+02:00

Commit Message:
MADS: rename a variable in unhandledAction

Changed paths:
    engines/mads/nebular/game_nebular.cpp



diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index b5c6e33..30a67f9 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -566,7 +566,7 @@ void GameNebular::doObjectAction() {
 }
 
 void GameNebular::unhandledAction() {
-	int random = _vm->getRandomNumber(1, 1000);
+	int randVal = _vm->getRandomNumber(1, 1000);
 	MADSAction &action = _scene._action;
 
 	if (action.isAction(VERB_THROW, NOUN_BOMB) || action.isAction(VERB_THROW, NOUN_BOMBS)
@@ -614,7 +614,7 @@ void GameNebular::unhandledAction() {
 	} else if (action.isAction(VERB_LOOK)) {
 		if (action.isAction(0x27) && (action._activeAction._indirectObjectId > 0))
 			_vm->_dialogs->show(0xA);
-		else if (random < 600)
+		else if (randVal < 600)
 			_vm->_dialogs->show(0x7);
 		else
 			_vm->_dialogs->show(0x15);
@@ -622,28 +622,28 @@ void GameNebular::unhandledAction() {
 		int objId = _vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId);
 		if (_vm->_game->_objects.isInInventory(objId))
 			_vm->_dialogs->show(0x10);
-		else if (random <= 333)
+		else if (randVal <= 333)
 			_vm->_dialogs->show(0x8);
-		else if (random <= 666)
+		else if (randVal <= 666)
 			_vm->_dialogs->show(0x16);
 		else
 			_vm->_dialogs->show(0x17);
 	} else if (action.isAction(VERB_CLOSE)) {
-		if (random <= 333)
+		if (randVal <= 333)
 			_vm->_dialogs->show(0x9);
 		else
 			_vm->_dialogs->show(0x21);
 	} else if (action.isAction(VERB_OPEN)) {
-		if (random <= 500)
+		if (randVal <= 500)
 			_vm->_dialogs->show(0x1E);
-		else if (random <= 750)
+		else if (randVal <= 750)
 			_vm->_dialogs->show(0x1F);
 		else
 			_vm->_dialogs->show(0x20);
 	} else if (action.isAction(VERB_PULL))
 		_vm->_dialogs->show(0x12);
 	else if (action.isAction(VERB_PUSH)) {
-		if (random < 750)
+		if (randVal < 750)
 			_vm->_dialogs->show(0x13);
 		else
 			_vm->_dialogs->show(0x14);
@@ -657,20 +657,20 @@ void GameNebular::unhandledAction() {
 		int objId = _vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId);
 		if (!_vm->_game->_objects.isInInventory(objId))
 			_vm->_dialogs->show(0x1A);
-		else if (random <= 500)
+		else if (randVal <= 500)
 			_vm->_dialogs->show(0x1C);
 		else
 			_vm->_dialogs->show(0x1D);
 	} else if (!action.isAction(VERB_WALKTO) && !action.isAction(0x187) && !action.isAction(0x18C) && !action.isAction(0x1AD)
 			&& !action.isAction(0x15C) && !action.isAction(0x159) && !action.isAction(0x15A) && !action.isAction(0x15B)
 			&& !action.isAction(0x15E)) {
-		if (random <= 100)
+		if (randVal <= 100)
 			_vm->_dialogs->show(0x24);
-		else if (random <= 200)
+		else if (randVal <= 200)
 			_vm->_dialogs->show(0x1);
-		else if (random <= 475)
+		else if (randVal <= 475)
 			_vm->_dialogs->show(0x22);
-		else if (random <= 750)
+		else if (randVal <= 750)
 			_vm->_dialogs->show(0x23);
 		else
 			_vm->_dialogs->show(0x25);


Commit: 3ad447313be0e93f164d68f902e4840a0d1da141
    https://github.com/scummvm/scummvm/commit/3ad447313be0e93f164d68f902e4840a0d1da141
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-11T19:52:45+02:00

Commit Message:
MADS: Initialize scene102 variables, move an empty function of Scene 103 to header

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 7cc0ded..3722e43 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -1313,9 +1313,6 @@ void Scene103::step() {
 	}
 }
 
-void Scene103::preActions() {
-}
-
 void Scene103::actions() {
 	if (_action._savedFields._lookFlag) {
 		_vm->_dialogs->show(10322);
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index 782dbb5..ac1e118 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -90,7 +90,8 @@ private:
 	void addRandomMessage();
 
 public:
-	Scene102(MADSEngine *vm) : Scene1xx(vm) {}
+	Scene102(MADSEngine *vm) : Scene1xx(vm), _fridgeOpenedFl(false), _fridgeOpenedDescr(false), _fridgeFirstOpenFl(false),
+		_chairDescrFl(false), _drawerDescrFl(false), _activeMsgFl(false), _fridgeCommentCount(0) {}
 
 	virtual void setup();
 	virtual void enter();
@@ -107,7 +108,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions();
+	virtual void preActions() {};
 	virtual void actions();
 	virtual void postActions();
 };


Commit: f8469aa20ac767e3de169a8acdc97f06d8f30211
    https://github.com/scummvm/scummvm/commit/f8469aa20ac767e3de169a8acdc97f06d8f30211
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-11T19:56:47+02:00

Commit Message:
MADS: Fix CREATE_MSVC9

Changed paths:
    dists/msvc9/create_msvc9.bat



diff --git a/dists/msvc9/create_msvc9.bat b/dists/msvc9/create_msvc9.bat
index 561772b..34bcccd 100644
--- a/dists/msvc9/create_msvc9.bat
+++ b/dists/msvc9/create_msvc9.bat
@@ -55,21 +55,21 @@ goto done
 echo.
 echo Creating project files with all engines enabled (stable and unstable)
 echo.
-create_project ..\.. --enable-all-engines --msvc --msvc-version 9  --disable-taskbar --disable-freetype --disable-jpeg --disable-engine=zvision
+create_project ..\.. --enable-all-engines --msvc --msvc-version 9
 goto done
 
 :stable
 echo.
 echo Creating normal project files, with only the stable engines enabled
 echo.
-create_project ..\.. --msvc --msvc-version 9  --disable-taskbar --disable-freetype --disable-jpeg --disable-engine=zvision
+create_project ..\.. --msvc --msvc-version 9
 goto done
 
 :tools
 echo.
 echo Creating tools project files
 echo.
-create_project ..\.. --tools --msvc --msvc-version 9  --disable-taskbar --disable-freetype --disable-jpeg --disable-engine=zvision
+create_project ..\.. --tools --msvc --msvc-version 9
 goto done
 
 :tests


Commit: ad346bbd3be18e7b89f07b981dd3f95e4dfbb594
    https://github.com/scummvm/scummvm/commit/ad346bbd3be18e7b89f07b981dd3f95e4dfbb594
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-11T23:15:22+02:00

Commit Message:
MADS: Implement scene 104, start splitting the arrays storing sprite and sequence indexes

Changed paths:
    engines/mads/nebular/globals_nebular.cpp
    engines/mads/nebular/globals_nebular.h
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp
index 382a31e..11c2b81 100644
--- a/engines/mads/nebular/globals_nebular.cpp
+++ b/engines/mads/nebular/globals_nebular.cpp
@@ -29,11 +29,12 @@ namespace MADS {
 namespace Nebular {
 
 Globals::Globals() {
-	// Initialise lists
+	// Initialize lists
 	_flags.resize(210);
 	_spriteIndexes.resize(30);
+	_sequenceIndexes.resize(30);
 
-	// Initialise game flags
+	// Initialize game flags
 	_timebombClock = 0;
 	_timebombTimer = 0;
 	_v0 = 0;
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index 51e18ee..242e0d1 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -284,6 +284,7 @@ private:
 	Common::Array<int16> _flags;
 public:
 	Common::Array<int> _spriteIndexes;
+	Common::Array<int> _sequenceIndexes;
 	
 	int _timebombClock, _timebombTimer;
 	int _v0;
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 6528afe..9fa057e 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -53,6 +53,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene102(vm);
 	case 103:
 		return new Scene103(vm);
+	case 104:
+		return new Scene104(vm);
 
 	// Scene group #2
 	case 201:
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 3722e43..c460d7f 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -1514,6 +1514,199 @@ void Scene103::postActions() {
 	}
 }
 
-} // End of namespace Nebular
+/*------------------------------------------------------------------------*/
+
+void Scene104::setup() {
+	// Preloading has been skipped
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene104::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('h', -1), false);
+	_globals._sequenceIndexes[1]  = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 14, 0, 0, 1);
+
+	if (_scene->_priorSceneId == 105)
+		_game._player._playerPos = Common::Point(302, 107);
+	else if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(160, 134);
+
+	_loseFl = false;
+	_game.loadQuoteSet(0x35, 0x34, 0);
+	_kargShootingFl = false;
+
+	if (_vm->getRandomNumber(1, 3) == 1) {
+		_scene->loadAnimation(Resources::formatName(104, 'B', -1, EXT_AA, ""), 0);
+		_kargShootingFl = true;
+	}
 
+	sceneEntrySound();
+}
+
+void Scene104::step() {
+	if ((_game._player._playerPos == Common::Point(189, 70)) && (_game._trigger || !_loseFl)) {
+		if (_game._player._facing == FACING_SOUTHWEST || _game._player._facing == FACING_SOUTHEAST)
+			_game._player._facing = FACING_SOUTH;
+
+		if (_game._player._facing == FACING_NORTHWEST || _game._player._facing == FACING_NORTHEAST)
+			_game._player._facing = FACING_NORTH;
+
+		bool mirrorFl = false;
+		if (_game._player._facing == FACING_WEST) {
+			_game._player._facing = FACING_EAST;
+			mirrorFl = true;
+		}
+
+		_loseFl = true;
+
+		switch (_game._player._facing) {
+		case FACING_EAST:
+			switch (_game._trigger) {
+			case 0:
+				_scene->_kernelMessages.reset();
+				_scene->_activeAnimation->free();
+				_scene->resetScene();
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 0), false);
+				warning("TODO: sub7C8DE()");
+				_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], mirrorFl, 7, 1, 0, 0);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(198, 143));
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_0, 0, 1);
+				break;
+
+			case 1:
+				_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], mirrorFl, 7, 0, 0, 0);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(198, 143));
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -2, -2);
+				_scene->_sequences.addTimer(90, 2);
+				break;
+
+			case 2:
+				_vm->_dialogs->show(0x28A6);
+				_scene->_reloadSceneFlag = true;
+				break;
+			}
+			break;
+
+		case FACING_SOUTH:
+			switch (_game._trigger) {
+			case 0:
+				_scene->_kernelMessages.reset();
+				_scene->_activeAnimation->free();
+				_scene->resetScene();
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 1), false);
+				warning("TODO: sub7C8DE()");
+				_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 1, 0, 0);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(198, 143));
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 4);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 14);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 1);
+				break;
+
+			case 1:
+				_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 5, 1, 0, 0);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(198, 143));
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 4);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 15, 32);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 2);
+				break;
+
+			case 2:
+				_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 3, 0, 0, 0);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(198, 143));
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -2, -2);
+				_scene->_sequences.addTimer(90, 3);
+				break;
+
+			case 3:
+				_vm->_dialogs->show(0x28A6);
+				_scene->_reloadSceneFlag = true;
+				break;
+			}
+			break;
+
+		case FACING_NORTH:
+			switch (_game._trigger) {
+			case 0:
+				_scene->_kernelMessages.reset();
+				_scene->_activeAnimation->free();
+				_scene->resetScene();
+				_game._player._stepEnabled = false;
+				_game._player._visible   = false;
+				_globals._spriteIndexes[4]  = _scene->_sprites.addSprites(formAnimName('a', 2), false);
+				warning("TODO: sub7C8DE()");
+				_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 8, 1, 0, 0);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(198, 143));
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 4);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 1);
+				if (_game._storyMode >= STORYMODE_NICE)
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_FRAME_INDEX, 15, 2);
+				break;
+
+			case 1:
+				_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 8, 0, 0, 0);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(198, 143));
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], -2, -2);
+				_scene->_sequences.addTimer(90, 2);
+				break;
+
+			case 2:
+				_vm->_dialogs->show(0x28A6);
+				_scene->_reloadSceneFlag = true;
+				break;
+			}
+			break;
+		default:
+			break;
+		}
+
+		if (!_game._trigger)
+			_vm->_sound->command(34);
+	}
+
+	if (_game._player._moving && (_scene->_rails.getNext() > 0)) {
+		_game._player.cancelCommand();
+		_game._player.startWalking(Common::Point(189, 70), FACING_NONE);
+		_scene->_rails.resetNext();
+	}
+
+	if ((_game._player._special > 0) && _game._player._stepEnabled)
+		_game._player._stepEnabled = false;
+
+	if (_kargShootingFl && (_scene->_activeAnimation->getCurrentFrame() >= 19)) {
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(52));
+		_kargShootingFl = false;
+	}
+}
+
+void Scene104::preActions() {
+	if (_action.isAction(0x15D, 0x74))
+		_game._player._walkOffScreenSceneId = 105;
+
+	if (_action.isAction(0x15D, 0x75))
+		_game._player._walkOffScreenSceneId = 106;
+}
+
+void Scene104::actions() {
+	if (_action._lookFlag)
+		_vm->_dialogs->show(0x28A5);
+	else if (_action.isAction(VERB_LOOK, 0x5E))
+		_vm->_dialogs->show(0x28A4);
+	else if (_action.isAction(VERB_LOOK, 0x158))
+		_vm->_dialogs->show(0x28A3);
+	else if (_action.isAction(VERB_LOOK, 0x4D))
+		_vm->_dialogs->show(0x28A1);
+	else if (_action.isAction(VERB_LOOK, 0xF0))
+		_vm->_dialogs->show(0x28A2);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+} // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index ac1e118..e4c8618 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -113,8 +113,23 @@ public:
 	virtual void postActions();
 };
 
-} // End of namespace Nebular
+class Scene104 : public Scene1xx {
+private:
+	bool _kargShootingFl;
+	bool _loseFl;
+
+public:
+	Scene104(MADSEngine *vm) : Scene1xx(vm), _kargShootingFl(false), _loseFl(false) {}
 
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
+} // End of namespace Nebular
 } // End of namespace MADS
 
 #endif /* MADS_NEBULAR_SCENES1_H */


Commit: 03be9bb80742045c3d4e2fa7994622328c06bb0a
    https://github.com/scummvm/scummvm/commit/03be9bb80742045c3d4e2fa7994622328c06bb0a
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-11T23:23:36+02:00

Commit Message:
MADS: Fix check on asset name suffix

Changed paths:
    engines/mads/assets.cpp



diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index 47b2763..582b80d 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -32,7 +32,7 @@ namespace MADS {
 SpriteAsset::SpriteAsset(MADSEngine *vm, const Common::String &resourceName, int flags) :
 	_vm(vm) {
 	Common::String resName = resourceName;
-	if (!resName.hasSuffix(".SS"))
+	if (!resName.hasSuffix(".SS") && !resName.hasSuffix(".ss"))
 		resName += ".SS";
 
 	File file(resName);


Commit: 59d18733022b58672cea23d9349c29c22de13a27
    https://github.com/scummvm/scummvm/commit/59d18733022b58672cea23d9349c29c22de13a27
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-11T23:59:22+02:00

Commit Message:
MADS: Split the other sprite and sequence index arrays

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes8.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index c460d7f..32172da 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -111,17 +111,17 @@ void Scene101::sayDang() {
 
 	switch (_game._trigger) {
 	case 0:
-		_scene->_sequences.remove(_globals._spriteIndexes[26]);
-		_globals._spriteIndexes[26] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[11], false, 3, 6, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[26], 17, 21);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_0, 0, 72);
+		_scene->_sequences.remove(_globals._sequenceIndexes[11]);
+		_globals._sequenceIndexes[11] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[11], false, 3, 6, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], 17, 21);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_0, 0, 72);
 		_vm->_sound->command(17);
-		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 3, 2, 0, 0);
+		_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 3, 2, 0, 0);
 		break;
 
 	case 72:
-		_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 6, 0, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[26], 17, 17);
+		_globals._sequenceIndexes[11] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 6, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], 17, 17);
 		_scene->_kernelMessages.add(Common::Point(143, 61), 0x1110, 0, 0, 60, _game.getQuote(57));
 		_scene->_sequences.addTimer(120, 73);
 		break; 
@@ -149,16 +149,16 @@ void Scene101::enter() {
 	_globals._spriteIndexes[13] = _scene->_sprites.addSprites(formAnimName('x', 8));
 	_globals._spriteIndexes[14] = _scene->_sprites.addSprites(formAnimName('x', 0));
 
-	_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 0, 0, 25);
-	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 4, 0, 1, 0);
-	_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 2, 0);
-	_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_FRAME_INDEX, 7, 70);
-	_globals._spriteIndexes[19] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[4], false, 10, 0, 0, 60);
-	_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 5, 0, 1, 0);
-	_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 10, 0, 2, 0);
-	_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 6, 0, 0, 0);
-	_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, 0, 10, 4);
-	_globals._spriteIndexes[25] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[10], false, 6, 0, 32, 47);
+	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 0, 0, 25);
+	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 4, 0, 1, 0);
+	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 2, 0);
+	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_FRAME_INDEX, 7, 70);
+	_globals._sequenceIndexes[4] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[4], false, 10, 0, 0, 60);
+	_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 5, 0, 1, 0);
+	_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 10, 0, 2, 0);
+	_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 6, 0, 0, 0);
+	_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, 0, 10, 4);
+	_globals._sequenceIndexes[10] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[10], false, 6, 0, 32, 47);
 
 	_scene->_hotspots.activate(0x137, false);
 	_panelOpened = false;
@@ -174,15 +174,15 @@ void Scene101::enter() {
 		_sittingFl = true;
 		_game._player._playerPos = Common::Point(161, 123);
 		_game._player._facing = FACING_NORTHEAST;
-		_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 0, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[26], 17, 17);
+		_globals._sequenceIndexes[11] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], 17, 17);
 		_scene->_hotspots.activate(0x47, false);
 		_chairHotspotId = _scene->_dynamicHotspots.add(0x47, 0x13F, -1, Common::Rect(159, 84, 33, 36));
 		if (_scene->_priorSceneId == 112)
 			sayDang();
 	} else {
-		_globals._spriteIndexes[27] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[12], false, 6, 0, 0, 0);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[27], 4);
+		_globals._sequenceIndexes[12] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[12], false, 6, 0, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[12], 4);
 	}
 
 	_game.loadQuoteSet(0x31, 0x32, 0x39, 0x36, 0x37, 0x38, 0);
@@ -276,10 +276,10 @@ void Scene101::preActions() {
 			case 0:
 				_game._player._needToWalk = false;	
 				_game._player._stepEnabled = false;
-				_scene->_sequences.remove(_globals._spriteIndexes[26]);
-				_globals._spriteIndexes[26] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[11], false, 3, 1, 0, 0);
-				_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_0, 0, 1);
-				_scene->_sequences.setAnimRange(_globals._spriteIndexes[26], 1, 17);
+				_scene->_sequences.remove(_globals._sequenceIndexes[11]);
+				_globals._sequenceIndexes[11] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[11], false, 3, 1, 0, 0);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_0, 0, 1);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], 1, 17);
 				_vm->_sound->command(16);
 				break;
 
@@ -290,8 +290,8 @@ void Scene101::preActions() {
 				_game._player._needToWalk = true;
 				_scene->_hotspots.activate(71, true);
 				_scene->_dynamicHotspots.remove(_chairHotspotId);
-				_globals._spriteIndexes[27] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[12], false, 6, 0, 0, 0);
-				_scene->_sequences.setDepth(_globals._spriteIndexes[27], 4);
+				_globals._sequenceIndexes[12] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[12], false, 6, 0, 0, 0);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[12], 4);
 				break;
 			}
 		}
@@ -301,10 +301,10 @@ void Scene101::preActions() {
 		switch (_game._trigger) {
 		case 0:
 			if (_game._player._needToWalk) {
-				_scene->_sequences.remove(_globals._spriteIndexes[28]);
+				_scene->_sequences.remove(_globals._sequenceIndexes[13]);
 				_shieldSpriteIdx = _game._objects.isInRoom(0x18) ? 13 : 14;
-				_globals._spriteIndexes[28] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[_shieldSpriteIdx], false, 6, 1, 0, 0);
-				_scene->_sequences.addSubEntry(_globals._spriteIndexes[28], SM_0, 0, 1);
+				_globals._sequenceIndexes[13] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[_shieldSpriteIdx], false, 6, 1, 0, 0);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SM_0, 0, 1);
 				_game._player._stepEnabled = false;
 				_vm->_sound->command(20);
 			}
@@ -336,11 +336,11 @@ void Scene101::actions() {
 		if (!_sittingFl) {
 			switch (_game._trigger) {
 			case 0:
-				_scene->_sequences.remove(_globals._spriteIndexes[27]);
-				_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 1);
-				_scene->_sequences.setAnimRange(_globals._spriteIndexes[26], 1, 17);
-				_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_FRAME_INDEX, 10, 1);
-				_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_0, 0, 2);
+				_scene->_sequences.remove(_globals._sequenceIndexes[12]);
+				_globals._sequenceIndexes[11] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 1);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], 1, 17);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_FRAME_INDEX, 10, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_0, 0, 2);
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
 				_action._inProgress = false;
@@ -351,8 +351,8 @@ void Scene101::actions() {
 				break;
 
 			case 2:
-				_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 0, 0, 0);
-				_scene->_sequences.setAnimRange(_globals._spriteIndexes[26], 17, 17);
+				_globals._sequenceIndexes[11] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 0, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], 17, 17);
 				_game._player._stepEnabled = true;
 				_sittingFl = true;
 				_scene->_hotspots.activate(71, false);
@@ -375,16 +375,16 @@ void Scene101::actions() {
 		switch (_game._trigger) {
 		case 0:
 			_shieldSpriteIdx = _game._objects.isInRoom(0x18) ? 13 : 14;
-			_globals._spriteIndexes[28] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[_shieldSpriteIdx], false, 6, 1, 0, 0);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[28], SM_0, 0, 1);
+			_globals._sequenceIndexes[13] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[_shieldSpriteIdx], false, 6, 1, 0, 0);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SM_0, 0, 1);
 			_game._player._stepEnabled = false;
 			_vm->_sound->command(20);
 			break;
 
 		case 1:
-			_scene->_sequences.remove(_globals._spriteIndexes[28]);
-			_globals._spriteIndexes[28] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[_shieldSpriteIdx], false, 6, 0, 0, 0);
-			_scene->_sequences.setAnimRange(_globals._spriteIndexes[28], -2, -2);
+			_scene->_sequences.remove(_globals._sequenceIndexes[13]);
+			_globals._sequenceIndexes[13] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[_shieldSpriteIdx], false, 6, 0, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], -2, -2);
 			_game._player._stepEnabled = true;
 			_panelOpened = true;
 			if (_game._objects.isInRoom(0x18))
@@ -397,9 +397,9 @@ void Scene101::actions() {
 
 	if ((_action.isAction(VERB_TAKE, 0x137) || _action.isAction(VERB_PULL, 0x137)) && _game._objects.isInRoom(0x18)) {
 		_game._objects.addToInventory(0x18);
-		_scene->_sequences.remove(_globals._spriteIndexes[28]);
-		_globals._spriteIndexes[28] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[14], false, 6, 0, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[28], -2, -2);
+		_scene->_sequences.remove(_globals._sequenceIndexes[13]);
+		_globals._sequenceIndexes[13] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[14], false, 6, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], -2, -2);
 		_scene->_hotspots.activate(0x137, false);
 		_vm->_dialogs->showPicture(0x18, 0x2788);
 		_vm->_sound->command(22);
@@ -433,24 +433,24 @@ void Scene101::actions() {
 			switch (_game._trigger) {
 			case 0:
 				_game._player._stepEnabled = false;
-				_scene->_sequences.remove(_globals._spriteIndexes[26]);
-				_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 1, 0, 0);
-				_scene->_sequences.setAnimRange(_globals._spriteIndexes[26], 17, 21);
-				_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_0, 0, 1);
+				_scene->_sequences.remove(_globals._sequenceIndexes[11]);
+				_globals._sequenceIndexes[11] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], 17, 21);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_0, 0, 1);
 				_vm->_sound->command(17);
 				break;
 
 			case 1:
-				_globals._spriteIndexes[26] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[11], false, 3, 1, 0, 0);
-				_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_0, 0, 2);
-				_scene->_sequences.setAnimRange(_globals._spriteIndexes[26], 17, 21);
+				_globals._sequenceIndexes[11] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[11], false, 3, 1, 0, 0);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_0, 0, 2);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], 17, 21);
 				break;
 
 			case 2:
-				_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 0, 0, 0);
-				_scene->_sequences.setAnimRange(_globals._spriteIndexes[26], 17, 17);
-				_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 3, 1, 0, 0);
-				_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 3);
+				_globals._sequenceIndexes[11] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 0, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], 17, 17);
+				_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 3, 1, 0, 0);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 3);
 				break;
 
 			case 3:
@@ -635,25 +635,25 @@ void Scene102::enter() {
 	_globals._spriteIndexes[15+2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 170, 0, 1, 6);
 	_globals._spriteIndexes[15+3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 11, 0, 2, 3);
 	_globals._spriteIndexes[15+4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 4, 0, 1, 0);
-	_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 3, 0, 0, 5);
+	_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 3, 0, 0, 5);
 
 	if (!_game._objects.isInRoom(OBJ_BINOCULARS))
-		_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 24, 0, 0, 24);
+		_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 24, 0, 0, 24);
 	else
 		_scene->_hotspots.activate(0x27, false);
 
 	_scene->_hotspots.activate(0x35, false);
 
 	if (_globals[kMedicineCabinetOpen]) {
-		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[23], -2, -2);
+		_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], -2, -2);
 	}
 
 	if (_scene->_priorSceneId == 101) {
 		_game._player._playerPos = Common::Point(229, 109);
 		_game._player._stepEnabled = false;
-		_globals._spriteIndexes[21] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[6], false, 6, 1, 2, 0);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 70);
+		_globals._sequenceIndexes[6] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[6], false, 6, 1, 2, 0);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SM_0, 0, 70);
 	} else if (_scene->_priorSceneId == 103) {
 		_game._player._playerPos = Common::Point(47, 152);
 	} else if (_scene->_priorSceneId != -2) {
@@ -663,16 +663,16 @@ void Scene102::enter() {
 
 	if (_scene->_priorSceneId != 106) {
 		if (_globals[kWaterInAPuddle]) {
-			_globals._spriteIndexes[28] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[13], false, 6, 0, 0, 0);
-			_scene->_sequences.setAnimRange(_globals._spriteIndexes[28], -2, -2);
-			_scene->_sequences.setDepth(_globals._spriteIndexes[28], 5);
+			_globals._sequenceIndexes[13] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[13], false, 6, 0, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], -2, -2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 5);
 		}
 	} else {
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
-		_globals._spriteIndexes[28] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[13], false, 6, 1, 0, 0);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[28], SM_0, 0, 72);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[28], 5);
+		_globals._sequenceIndexes[13] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[13], false, 6, 1, 0, 0);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SM_0, 0, 72);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 5);
 		_vm->_sound->command(24);
 		_vm->_sound->command(28);
 	}
@@ -695,9 +695,9 @@ void Scene102::step() {
 		_game._player._stepEnabled = true;
 
 	if (_game._trigger == 72) {
-		_globals._spriteIndexes[28] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[13], false, 6, 0, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[28], -2, -2);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[28], 5);
+		_globals._sequenceIndexes[13] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[13], false, 6, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], -2, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 5);
 		_scene->_sequences.addTimer(48, 90);
 	}
 
@@ -748,10 +748,10 @@ void Scene102::preActions() {
 		switch (_game._trigger) {
 		case 0:
 			if (_game._player._needToWalk) {
-				_scene->_sequences.remove(_globals._spriteIndexes[22]);
-				_globals._spriteIndexes[22] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[7], false, 6, 1, 0, 0);
-				_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 1);
-				_scene->_sequences.setDepth(_globals._spriteIndexes[22], 15);
+				_scene->_sequences.remove(_globals._sequenceIndexes[7]);
+				_globals._sequenceIndexes[7] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[7], false, 6, 1, 0, 0);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_0, 0, 1);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 15);
 				_game._player._stepEnabled = false;
 				_vm->_sound->command(20);
 			}
@@ -759,7 +759,7 @@ void Scene102::preActions() {
 
 		case 1:
 			if (_game._objects.isInRoom(OBJ_BURGER)) {
-				_scene->_sequences.remove(_globals._spriteIndexes[25]);
+				_scene->_sequences.remove(_globals._sequenceIndexes[10]);
 				_scene->_hotspots.activate(0x35, false);
 			}
 			_fridgeOpenedFl = false;
@@ -784,12 +784,12 @@ void Scene102::actions() {
 	if (_action.isAction(0x122) && !_fridgeOpenedFl) {
 		switch (_game._trigger) {
 		case 0:
-			_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 6, 1, 0, 0);
-			_scene->_sequences.setDepth(_globals._spriteIndexes[22], 15);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 1);
+			_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 15);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_0, 0, 1);
 			if (_game._objects.isInRoom(OBJ_BURGER)) {
-				_globals._spriteIndexes[25] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[10], false, 7, 0, 0, 0);
-				_scene->_sequences.setDepth(_globals._spriteIndexes[25], 14);
+				_globals._sequenceIndexes[10] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[10], false, 7, 0, 0, 0);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 14);
 			}
 			_game._player._stepEnabled = false;
 			_vm->_sound->command(20);
@@ -797,9 +797,9 @@ void Scene102::actions() {
 			return;
 
 		case 1:
-			_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 6, 0, 0, 0);
-			_scene->_sequences.setAnimRange(_globals._spriteIndexes[22], -2, -2);
-			_scene->_sequences.setDepth(_globals._spriteIndexes[22], 15);
+			_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 6, 0, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[7], -2, -2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 15);
 			int delay;
 			if (_action.isAction(VERB_WALKTO) && !_fridgeFirstOpenFl)
 				delay = 0;
@@ -861,8 +861,8 @@ void Scene102::actions() {
 	if (_action.isAction(0x18B, 0x6E)) {
 		switch (_game._trigger) {
 		case 0:
-			_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 1, 0, 0);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 1);
+			_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 1, 0, 0);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SM_0, 0, 1);
 			_game._player._stepEnabled = false;
 			_vm->_sound->command(20);
 			break;
@@ -1065,9 +1065,9 @@ void Scene102::actions() {
 	if (_action.isAction(VERB_CLOSE, 0xDE) && _globals[kMedicineCabinetOpen]) {
 		switch (_game._trigger) {
 		case 0:
-			_scene->_sequences.remove(_globals._spriteIndexes[23]);
-			_globals._spriteIndexes[23] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 1);
+			_scene->_sequences.remove(_globals._sequenceIndexes[8]);
+			_globals._sequenceIndexes[8] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 1);
 			_game._player._stepEnabled = false;
 			_vm->_sound->command(21);
 			break;
@@ -1089,15 +1089,15 @@ void Scene102::actions() {
 	if (_action.isAction(VERB_OPEN, 0xDE) && !_globals[kMedicineCabinetOpen]) {
 		switch (_game._trigger) {
 		case 0:
-			_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 1);
+			_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 1);
 			_game._player._stepEnabled = false;
 			_vm->_sound->command(21);
 			break;
 
 		case 1:
-			_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 0, 0, 0);
-			_scene->_sequences.setAnimRange(_globals._spriteIndexes[23], -2, -2);
+			_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 0, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], -2, -2);
 			_scene->_sequences.addTimer(48, 2);
 			break;
 
@@ -1119,9 +1119,9 @@ void Scene102::actions() {
 	if (_action.isAction(VERB_TAKE, 0x27) && _game._objects.isInRoom(OBJ_BINOCULARS)) {
 		switch (_game._trigger) {
 		case 0:
-			_globals._spriteIndexes[26] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[11], false, 3, 1, 0, 0);
-			_scene->_sequences.setMsgLayout(_globals._spriteIndexes[26]);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_0, 0, 1);
+			_globals._sequenceIndexes[11] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[11], false, 3, 1, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[11]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_0, 0, 1);
 			_game._player._visible = false;
 			_game._player._stepEnabled = false;
 			break;
@@ -1143,7 +1143,7 @@ void Scene102::actions() {
 	if (_action.isAction(VERB_TAKE, 0x35) && _game._objects.isInRoom(OBJ_BURGER)) {
 		if (_game._trigger == 0) {
 			_vm->_dialogs->showPicture(OBJ_BURGER, 0x27FB);
-			_scene->_sequences.remove(_globals._spriteIndexes[25]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[10]);
 			_game._objects.addToInventory(OBJ_BURGER);
 			_scene->_hotspots.activate(0x35, false);
 			_vm->_sound->command(22);
@@ -1215,32 +1215,32 @@ void Scene103::enter() {
 	_globals._spriteIndexes[12] = _scene->_sprites.addSprites("*RXMBD_2");
 	_globals._spriteIndexes[13] = _scene->_sprites.addSprites("*RXMRD_3");
 	_globals._spriteIndexes[15] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 7, 0, 1, 0);
-	_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 2, 0);
-	_scene->_sequences.setDepth(_globals._spriteIndexes[16], 0);
+	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 2, 0);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 0);
 
-	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 25);	
-	_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], SM_FRAME_INDEX, 2, 72);
-	_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 1, 37);
-	_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_FRAME_INDEX, 2, 73);
+	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 25);	
+	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_FRAME_INDEX, 2, 72);
+	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 1, 37);
+	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_FRAME_INDEX, 2, 73);
 
-	_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8);
-	_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 6);
-	_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6);
-	_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6);
+	_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8);
+	_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 6);
+	_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6);
+	_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6);
 
 	if (_game._objects.isInRoom(OBJ_TIMER_MODULE))
-		_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 6);
+		_globals._sequenceIndexes[11] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 6);
 	else
 		_vm->_game->_scene._hotspots.activate(371, false);
 
 	if (_game._objects.isInRoom(OBJ_REBREATHER))
-		_globals._spriteIndexes[25] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[10], false, 6);
+		_globals._sequenceIndexes[10] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[10], false, 6);
 	else
 		_vm->_game->_scene._hotspots.activate(289, false);
 	
 	if (_globals[kTurkeyExploded]) {
-		_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[24], -2, -2);
+		_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[9], -2, -2);
 		_scene->_hotspots.activate(362, false);
 	}
 
@@ -1250,8 +1250,8 @@ void Scene103::enter() {
 	if (_scene->_priorSceneId == 102) {
 		_game._player._stepEnabled = false;
 
-		_globals._spriteIndexes[21] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[6], false, 6, 1, 0, 0);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 70);
+		_globals._sequenceIndexes[6] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[6], false, 6, 1, 0, 0);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SM_0, 0, 70);
 	}
 
 	sceneEntrySound();
@@ -1319,8 +1319,8 @@ void Scene103::actions() {
 	} else if (_action.isAction(395, 110)) {
 		switch (_vm->_game->_trigger) {
 		case 0:
-			_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 1);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 1);
+			_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SM_0, 0, 1);
 			_game._player._stepEnabled = false;
 			_vm->_sound->command(20);
 			break;
@@ -1338,18 +1338,18 @@ void Scene103::actions() {
 		switch (_vm->_game->_trigger) {
 		case 0:
 			_scene->changeVariant(1);
-			_globals._spriteIndexes[28] = _scene->_sequences.startReverseCycle(
+			_globals._sequenceIndexes[13] = _scene->_sequences.startReverseCycle(
 				_globals._spriteIndexes[13], false, 3, 2);
-			_scene->_sequences.setMsgLayout(_globals._spriteIndexes[28]);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[13]);
 
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[28], SM_FRAME_INDEX, 7, 1);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[28], SM_0, 0, 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SM_FRAME_INDEX, 7, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SM_0, 0, 2);
 			_vm->_game->_player._visible = false;
 			_vm->_game->_player._stepEnabled = false;
 			break;
 
 		case 1:
-			_scene->_sequences.remove(_globals._spriteIndexes[26]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[11]);
 			break;
 
 		case 2:
@@ -1370,18 +1370,18 @@ void Scene103::actions() {
 		switch (_vm->_game->_trigger) {
 		case 0:
 			_scene->changeVariant(1);
-			_globals._spriteIndexes[27] = _scene->_sequences.startReverseCycle(
+			_globals._sequenceIndexes[12] = _scene->_sequences.startReverseCycle(
 				_globals._spriteIndexes[12], false, 3, 2);
-			_scene->_sequences.setMsgLayout(_globals._spriteIndexes[27]);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[12]);
 
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[27], SM_FRAME_INDEX, 6, 1);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[27], SM_0, 0, 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SM_FRAME_INDEX, 6, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SM_0, 0, 2);
 			_vm->_game->_player._visible = false;
 			_vm->_game->_player._stepEnabled = false;
 			break;
 
 		case 1:
-			_scene->_sequences.remove(_globals._spriteIndexes[25]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[10]);
 			break;
 
 		case 2:
@@ -1404,10 +1404,10 @@ void Scene103::actions() {
 			_vm->_sound->command(31);
 
 		if (_vm->_game->_trigger < 2) {
-			_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, _vm->_game->_trigger < 1 ? 1 : 0);
+			_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, _vm->_game->_trigger < 1 ? 1 : 0);
 			if (_vm->_game->_trigger) {
 				// Lock the turkey into a permanent "exploded" frame
-				_scene->_sequences.setAnimRange(_globals._spriteIndexes[24], -1, -1);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[9], -1, -1);
 
 				// Rex says "Gads.."
 				Common::String msg = _game.getQuote(51);
@@ -1415,7 +1415,7 @@ void Scene103::actions() {
 				_scene->_sequences.addTimer(120, _vm->_game->_trigger + 1);
 			} else {
 				// Initial turky explosion
-				_scene->_sequences.addSubEntry(_globals._spriteIndexes[24], SM_0, 0, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SM_0, 0, 1);
 			}
 		}
 
@@ -1708,5 +1708,7 @@ void Scene104::actions() {
 	_action._inProgress = false;
 }
 
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 4ef6f24..a804dbb 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -132,14 +132,14 @@ void Scene201::enter() {
 	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('m', -1));
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('b', -1));
 	_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*SC002Z1");
-	_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 1, 0);
-	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 15, 0, 0, 50);
-	_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 4, 0, 0, 0);
-	_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 0, 0);
-	_scene->_sequences.setDepth(_globals._spriteIndexes[19], 8);
-	_scene->_sequences.setMsgPosition(_globals._spriteIndexes[19], Common::Point(185, 46));
-
-	int idx = _scene->_dynamicHotspots.add(1159, 209, _globals._spriteIndexes[19], Common::Rect(0, 0, 0, 0));
+	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 1, 0);
+	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 15, 0, 0, 50);
+	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 4, 0, 0, 0);
+	_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6, 0, 0, 0);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 8);
+	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(185, 46));
+
+	int idx = _scene->_dynamicHotspots.add(1159, 209, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 	_scene->_dynamicHotspots.setPosition(idx, Common::Point(186, 81), FACING_NORTH);
 
 	if ((_scene->_priorSceneId == 202) || (_scene->_priorSceneId == -1)) {
@@ -186,10 +186,10 @@ void Scene201::enter() {
 		_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('a', 1));
 		_game.loadQuoteSet(90, 91, 0);
 		_game._player._stepEnabled = false;
-		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 7, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[21], -1, 12);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_FRAME_INDEX, 12, 70);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 1);
+		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 7, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], -1, 12);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SM_FRAME_INDEX, 12, 70);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 1);
 		_pterodactylFlag = false;
 		_game._player.walk(Common::Point(157, 143), FACING_NORTH);
 		_vm->_palette->setEntry(252, 45, 63, 45);
@@ -206,25 +206,25 @@ void Scene201::enter() {
 
 void Scene201::step() {
 	if (_pterodactylFlag && (_vm->getRandomNumber(5000) == 9)) {
-		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 5, 1, 6, 0);
-		int idx = _scene->_dynamicHotspots.add(351, 13, _globals._spriteIndexes[20], Common::Rect(0, 0, 0, 0));
+		_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 5, 1, 6, 0);
+		int idx = _scene->_dynamicHotspots.add(351, 13, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(270, 80), FACING_EAST);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[20], 8);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 8);
 		_vm->_sound->command(14);
 		_pterodactylFlag = false;
 	}
 
 	if (_game._trigger == 70) {
-		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 9, 1, 0, 0);
+		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 9, 1, 0, 0);
 		_game._player._visible = false;
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[21], 12, 16);
-		_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 9, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 12, 16);
+		_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 9, 1, 0, 0);
 		_vm->_sound->command(42);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 1);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[22], 1);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_FRAME_INDEX, 3, 81);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 71);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 73);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 1);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_FRAME_INDEX, 3, 81);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_0, 0, 71);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SM_0, 0, 73);
 	}
 
 	if (_game._trigger == 81) {
@@ -232,25 +232,25 @@ void Scene201::step() {
 	}
 
 	if (_game._trigger == 71) {
-		_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 9, 0, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[22], -2, -2);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[22], 1);
+		_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 9, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[7], -2, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 1);
 	}
 
 	if (_game._trigger == 73) {
-		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 9, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[21], 17, -2);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 74);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 1);
+		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 9, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 17, -2);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SM_0, 0, 74);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 1);
 	}
 
 	if (_game._trigger == 74) {
 		_vm->_sound->command(40);
 
 		_scene->_kernelMessages.add(Common::Point(125, 56), 0xFDFC, 32, 82, 180, _game.getQuote(91));
-		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 9, 0, 0, 0);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 1);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[21], -2, -2);
+		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 9, 0, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 1);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], -2, -2);
 		_scene->_sequences.addTimer(180, 75);
 	}
 
@@ -354,26 +354,26 @@ void Scene202::enter() {
 	_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('a', 1));
 	_globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('a', 2));
 
-	_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 0, 0);
-	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 0);
-	_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(149, 113));
-	_scene->_sequences.setDepth(_globals._spriteIndexes[17], 10);
-	int idx = _scene->_dynamicHotspots.add(320, 13, _globals._spriteIndexes[17], Common::Rect(0, 0, 0, 0));
+	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 0, 0);
+	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 0);
+	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(149, 113));
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 10);
+	int idx = _scene->_dynamicHotspots.add(320, 13, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
 	_scene->_dynamicHotspots.setPosition(idx, Common::Point(153, 97), FACING_SOUTH);
 
 	if (!(_globals[kBone202Status] & 1)) {
-		_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[16], Common::Point(130, 108));
-		_scene->_sequences.setDepth(_globals._spriteIndexes[16], 10);
-		idx = _scene->_dynamicHotspots.add(44, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(130, 108));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
+		idx = _scene->_dynamicHotspots.add(44, 13, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(132, 97), FACING_SOUTH);
 	}
 
 	if (!(_globals[kBone202Status] & 2)) {
-		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 0, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[21], Common::Point(166, 110));
-		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 10);
-		idx = _scene->_dynamicHotspots.add(44, 13, _globals._spriteIndexes[21], Common::Rect(0, 0, 0, 0));
+		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 0, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[6], Common::Point(166, 110));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 10);
+		idx = _scene->_dynamicHotspots.add(44, 13, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(165, 99), FACING_SOUTH);
 	}
 
@@ -389,10 +389,10 @@ void Scene202::enter() {
 	}
 
 	if (_globals[kLadderBroken]) {
-		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 0, 0, 0);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[20], 6);
+		_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 0, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 6);
 		_scene->_hotspots.activate(199, false);
-		idx = _scene->_dynamicHotspots.add(457, 13, _globals._spriteIndexes[20], Common::Rect(0, 0, 0, 0));
+		idx = _scene->_dynamicHotspots.add(457, 13, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(246, 124), FACING_NORTH);
 	}
 
@@ -401,7 +401,7 @@ void Scene202::enter() {
 
 	if (_scene->_priorSceneId == -2) {
 		if (_waitingMeteoFl) {
-			_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
+			_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
 			_game._player._visible = false;
 		}
 	} else {
@@ -423,18 +423,18 @@ void Scene202::enter() {
 			_ladderTopFl = false;
 
 		if (_globals[kMeteorologistWatch] < 1)
-			_globals._spriteIndexes[25] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
+			_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
 		else
-			_globals._spriteIndexes[25] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 8);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
+			_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 8);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
 
 		if (_ladderTopFl) {
-			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(247, 82));
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(247, 82));
 			_game._player._playerPos = Common::Point(246, 124);
 			_game._player._facing = FACING_NORTH;
 			_globals[kTeleporterUnderstood] = true;
 		} else {
-			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
 			_game._player._playerPos = Common::Point(171, 122);
 			_game._player._facing = FACING_NORTH;
 		}
@@ -443,9 +443,9 @@ void Scene202::enter() {
 		_scene->_activeAnimation->setCurrentFrame(200);
 	} else {
 		_game._player._visible = false;
-		_scene->_sequences.startCycle(_globals._spriteIndexes[24], true, 1);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
-		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
+		_scene->_sequences.startCycle(_globals._sequenceIndexes[9], true, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
 		_game._player._playerPos = Common::Point(246, 124);
 		_game._player._facing = FACING_NORTH;
 	}
@@ -503,36 +503,36 @@ void Scene202::step() {
 	switch (_game._trigger) {
 	case 90:
 		_vm->_sound->command(41);
-		_scene->_sequences.remove(_globals._spriteIndexes[25]);
-		_globals._spriteIndexes[24] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
-		_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[24], SM_0, 0, 91);
+		_scene->_sequences.remove(_globals._sequenceIndexes[10]);
+		_globals._sequenceIndexes[9] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SM_0, 0, 91);
 		break;
 	case 91:
-		_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
-		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
-		_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
+		_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
 		_scene->_sequences.addTimer(60, 92);
 		break;
 	case 92: {
-		_scene->_sequences.remove(_globals._spriteIndexes[24]);
-		_globals._spriteIndexes[26] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 6, 1, 0, 0);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[26], 1);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_0, 0, 93);
+		_scene->_sequences.remove(_globals._sequenceIndexes[9]);
+		_globals._sequenceIndexes[11] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 6, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[11], 1);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_0, 0, 93);
 		_scene->_kernelMessages.reset();
 		int msgIndex = _scene->_kernelMessages.add(Common::Point(0, -65), 0x1110, 32, 0, 60, _game.getQuote(98));
-		_scene->_kernelMessages.setSeqIndex(msgIndex, _globals._spriteIndexes[26]);
+		_scene->_kernelMessages.setSeqIndex(msgIndex, _globals._sequenceIndexes[11]);
 		}
 		break;
 	case 93: {
 		_globals[kLadderBroken] = -1;
-		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 0, 0, 0);
+		_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 0, 0, 0);
 		_scene->_hotspots.activate(199, false);
-		int idx = _scene->_dynamicHotspots.add(457, 13, _globals._spriteIndexes[20], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(457, 13, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(246, 124), FACING_NORTH);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[26], _globals._spriteIndexes[20]);
-		_scene->_sequences.updateTimeout(-1, _globals._spriteIndexes[26]);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[11], _globals._sequenceIndexes[5]);
+		_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[11]);
 		_game._player._stepEnabled = true;
 		_game._player._visible = true;
 		_ladderTopFl = false;
@@ -713,12 +713,12 @@ void Scene202::preActions() {
 			_vm->_sound->command(29);
 			player._readyToWalk = false;
 			_game._player._stepEnabled = false;
-			_scene->_sequences.remove(_globals._spriteIndexes[24]);
-			_globals._spriteIndexes[23] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
-			_scene->_sequences.setDepth(_globals._spriteIndexes[23], 1);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 1);
+			_scene->_sequences.remove(_globals._sequenceIndexes[9]);
+			_globals._sequenceIndexes[8] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 1);
 		} else if (_game._trigger == 1) {
-			_scene->_sequences.updateTimeout(-1, _globals._spriteIndexes[23]);
+			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[8]);
 			_scene->_dynamicHotspots.remove(_ladderHotspotId);
 			_game._player._visible = true;
 			player._readyToWalk = true;
@@ -762,18 +762,18 @@ void Scene202::actions() {
 					} else {
 						_game._player._stepEnabled = false;
 						_game._player._visible = false;
-						_globals._spriteIndexes[22] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[6], false, 3, 2, 0, 0);
-						_scene->_sequences.setMsgLayout(_globals._spriteIndexes[22]);
-						_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_FRAME_INDEX, 6, 1);
-						_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 2);
+						_globals._sequenceIndexes[7] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[6], false, 3, 2, 0, 0);
+						_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[7]);
+						_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_FRAME_INDEX, 6, 1);
+						_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_0, 0, 2);
 					}
 					break;
 				case 1:
 					if (_game._player._playerPos == Common::Point(132,97)) {
-						_scene->_sequences.remove(_globals._spriteIndexes[16]);
+						_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 						_globals[kBone202Status] |= 1;
 					} else {
-						_scene->_sequences.remove(_globals._spriteIndexes[21]);
+						_scene->_sequences.remove(_globals._sequenceIndexes[6]);
 						_globals[kBone202Status] |= 2;
 					}
 					break;
@@ -805,15 +805,15 @@ void Scene202::actions() {
 
 				_ladderHotspotId = _scene->_dynamicHotspots.add(199, 79, -1, Common::Rect(241, 68, 12, 54));
 				_scene->_dynamicHotspots.setPosition(_ladderHotspotId, Common::Point(246, 124), FACING_NORTH);
-				_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
-				_scene->_sequences.setDepth(_globals._spriteIndexes[23], 1);
-				_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 1);
+				_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 1);
 				break;
 			case 1: {
-				_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
-				_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
-				_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
-				_scene->_sequences.updateTimeout(_globals._spriteIndexes[23], _globals._spriteIndexes[24]);
+				_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
+				_scene->_sequences.updateTimeout(_globals._sequenceIndexes[8], _globals._sequenceIndexes[9]);
 				_ladderTopFl = true;
 				_game._player._stepEnabled = true;
 				int msgIndex = _scene->_kernelMessages.add(Common::Point(248, 15), 0x1110, 32, 0, 60, _game.getQuote(97));
@@ -830,17 +830,17 @@ void Scene202::actions() {
 				case 0:
 					_game._player._stepEnabled = false;
 					_game._player._visible= false;
-					_globals._spriteIndexes[25] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
-					_scene->_sequences.setAnimRange(_globals._spriteIndexes[25], 1, 6);
-					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
-					_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
-					_scene->_sequences.updateTimeout(-1, _globals._spriteIndexes[25]);
-					_scene->_sequences.addSubEntry(_globals._spriteIndexes[25], SM_0, 0, 1);
+					_globals._sequenceIndexes[10] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
+					_scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 1, 6);
+					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
+					_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
+					_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[10]);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SM_0, 0, 1);
 					break;
 				case 1:
-					_globals._spriteIndexes[25] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
-					_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
-					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
+					_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
+					_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
+					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
 					if (_scene->_activeAnimation) {
 						_waitingMeteoFl = true;
 						_globals[kMeteorologistWatch] = 1;
@@ -852,15 +852,15 @@ void Scene202::actions() {
 					if (!_scene->_activeAnimation && (_globals._abortVal == 0)) {
 						_vm->_dialogs->show(0x4EFE);
 					}
-					_scene->_sequences.remove(_globals._spriteIndexes[25]);
-					_globals._spriteIndexes[25] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
-					_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
-					_scene->_sequences.setAnimRange(_globals._spriteIndexes[25], 1, 6);
-					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(172, 123));
-					_scene->_sequences.addSubEntry(_globals._spriteIndexes[25], SM_0, 0, 3);
+					_scene->_sequences.remove(_globals._sequenceIndexes[10]);
+					_globals._sequenceIndexes[10] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
+					_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
+					_scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 1, 6);
+					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SM_0, 0, 3);
 					break;
 				case 3:
-					_scene->_sequences.updateTimeout(-1, _globals._spriteIndexes[25]);
+					_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[10]);
 					_game._player._stepEnabled = true;
 					_game._player._visible = true;
 					break;
@@ -873,16 +873,16 @@ void Scene202::actions() {
 				case 0:
 					_toTeleportFl = true;
 					_game._player._stepEnabled = false;
-					_scene->_sequences.remove(_globals._spriteIndexes[24]);
-					_globals._spriteIndexes[24] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0);
-					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
-					_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
-					_scene->_sequences.addSubEntry(_globals._spriteIndexes[24], SM_0, 0, 1);
+					_scene->_sequences.remove(_globals._sequenceIndexes[9]);
+					_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0);
+					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
+					_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SM_0, 0, 1);
 					break;
 				case 1:
-					_globals._spriteIndexes[25] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, -2);
-					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[25], Common::Point(247, 82));
-					_scene->_sequences.setDepth(_globals._spriteIndexes[25], 1);
+					_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, -2);
+					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(247, 82));
+					_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
 					if (_scene->_activeAnimation) {
 						if (_scene->_activeAnimation->getCurrentFrame() > 200) {
 							_scene->_sequences.addTimer(120, 2);
@@ -906,16 +906,16 @@ void Scene202::actions() {
 					if (!_scene->_activeAnimation)
 						_vm->_dialogs->show(0x4EFE);
 					_globals._abortVal = 0;
-					_scene->_sequences.remove(_globals._spriteIndexes[25]);
-					_globals._spriteIndexes[24] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
-					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
-					_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
-					_scene->_sequences.addSubEntry(_globals._spriteIndexes[24], SM_0, 0, 3);
+					_scene->_sequences.remove(_globals._sequenceIndexes[10]);
+					_globals._sequenceIndexes[9] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
+					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
+					_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SM_0, 0, 3);
 					break;
 				case 3:
-					_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
-					_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(247, 82));
-					_scene->_sequences.setDepth(_globals._spriteIndexes[24], 1);
+					_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
+					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
+					_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
 					_game._player._stepEnabled = true;
 					break;
 				default:
@@ -1110,28 +1110,28 @@ void Scene205::enter() {
 	if (_globals[kSexOfRex] == SEX_MALE)
 		_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('a', 1));
 
-	_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 10, 0, 0, 3);
-	int idx = _scene->_dynamicHotspots.add(73, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
+	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 10, 0, 0, 3);
+	int idx = _scene->_dynamicHotspots.add(73, 13, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 	_scene->_dynamicHotspots.setPosition(idx, Common::Point(162, 120), FACING_NORTHEAST);
 
-	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 15, 0, 0, 0);
-	idx = _scene->_dynamicHotspots.add(73, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
+	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 15, 0, 0, 0);
+	idx = _scene->_dynamicHotspots.add(73, 13, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 	_scene->_dynamicHotspots.setPosition(idx, Common::Point(162, 120), FACING_NORTHEAST);
 
-	_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 9, 0, 0, 0);
-	_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 0, 0, 0);
-	_scene->_sequences.setDepth(_globals._spriteIndexes[20], 11);
+	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 9, 0, 0, 0);
+	_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 0, 0, 0);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 11);
 
 	if (!_game._visitedScenes._sceneRevisited) {
 		_lastFishTime = _scene->_frameStartTime;
-		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 7, 1, 0, 0);
-		idx = _scene->_dynamicHotspots.add(269, 13, _globals._spriteIndexes[21], Common::Rect(0, 0, 0, 0));
+		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 7, 1, 0, 0);
+		idx = _scene->_dynamicHotspots.add(269, 13, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(49, 86), FACING_NORTH);
 	}
 
 	if (_game._objects[12]._roomNumber == 205) {
-		_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 7, 0, 0, 0);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[19], 11);
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 7, 0, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 11);
 	} else {
 		_scene->_hotspots.activate(450, false);
 	}
@@ -1163,13 +1163,13 @@ void Scene205::enter() {
 		_scene->_activeAnimation->_resetFlag = false;
 	} else {
 		_globals._frameTime |= 0xFFFF0000;
-		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
+		_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
 		_game._player._visible = false;
 		_game._player._stepEnabled = false;
-		_scene->_sequences.setDepth(_globals._spriteIndexes[23], 2);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_FRAME_INDEX, 6, 73);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_FRAME_INDEX, 11, 74);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 2);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_FRAME_INDEX, 6, 73);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_FRAME_INDEX, 11, 74);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 0);
 	}
 	sceneEntrySound();
 }
@@ -1187,8 +1187,8 @@ void Scene205::step() {
 	}
 
 	if (_globals._frameTime - _lastFishTime > 1300) {
-		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 5, 1, 0, 0);
-		int idx = _scene->_dynamicHotspots.add(269, 13, _globals._spriteIndexes[21], Common::Rect(0, 0, 0, 0));
+		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 5, 1, 0, 0);
+		int idx = _scene->_dynamicHotspots.add(269, 13, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(49, 86), FACING_NORTH);
 		_lastFishTime = _globals._frameTime;
 	}
@@ -1203,9 +1203,9 @@ void Scene205::step() {
 	}
 
 	if (_game._trigger == 71) {
-		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 0, 0, 0);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[23], 2);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[23], -2, -2);
+		_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 0, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 2);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], -2, -2);
 		_scene->_kernelMessages.reset();
 		_scene->_kernelMessages.add(Common::Point(160, 68), 0xFBFA, 32, 72, 180, _game.getQuote(114));
 	}
@@ -1238,8 +1238,8 @@ void Scene207::enter() {
 	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('e', 1));
 	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('g', 1));
 	_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('g', 0));
-	_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 7, 0, 0, 0);
-	_scene->_sequences.setDepth(_globals._spriteIndexes[20], 7);
+	_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 7, 0, 0, 0);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 7);
 
 	int var2;
 	if (!_game._visitedScenes._sceneRevisited) {
@@ -1256,17 +1256,17 @@ void Scene207::enter() {
 	_spiderFl = (var2 & 1);
 
 	if (_vultureFl) {
-		_globals._spriteIndexes[16] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 30, 0, 0, 400);
+		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 30, 0, 0, 400);
 		_vultureTime = _game._player._priorTimer;
-		_vultureHotspotId = _scene->_dynamicHotspots.add(389, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
+		_vultureHotspotId = _scene->_dynamicHotspots.add(389, 13, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(_vultureHotspotId, Common::Point(254, 94), FACING_WEST);
 	}
 
 	if (_spiderFl) {
-		_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 7, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], -1, -1);
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 7, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], -1, -1);
 		_spiderTime = _game._player._priorTimer;
-		_spiderHotspotId = _scene->_dynamicHotspots.add(333, 13, _globals._spriteIndexes[19], Common::Rect(0, 0, 0, 0));
+		_spiderHotspotId = _scene->_dynamicHotspots.add(333, 13, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(_spiderHotspotId, Common::Point(59, 132), FACING_SOUTH);
 	}
 
@@ -1281,15 +1281,15 @@ void Scene207::enter() {
 		_game._player._playerPos = Common::Point(305, 131);
 	}
 
-	_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 10, 1, 0, 0);
-	_scene->_sequences.setAnimRange(_globals._spriteIndexes[21], 1, 22);
-	_scene->_sequences.setDepth(_globals._spriteIndexes[21], 6);
-	_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 70);
+	_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 10, 1, 0, 0);
+	_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 1, 22);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 6);
+	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SM_0, 0, 70);
 }
 
 void Scene207::moveVulture() {
-	_scene->_sequences.remove(_globals._spriteIndexes[16]);
-	_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
+	_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
 	_vm->_sound->command(43);
 	_vultureFl = false;
 	_vultureTime = _game._player._priorTimer;
@@ -1297,8 +1297,8 @@ void Scene207::moveVulture() {
 }
 
 void Scene207::moveSpider() {
-	_scene->_sequences.remove(_globals._spriteIndexes[19]);
-	_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 5, 1, 0, 0);
+	_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+	_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 5, 1, 0, 0);
 	_spiderFl = false;
 	_spiderTime = _game._player._priorTimer;
 	_scene->_dynamicHotspots.remove(_spiderHotspotId);
@@ -1312,9 +1312,9 @@ void Scene207::step() {
 		moveSpider();
 
 	if (_game._trigger == 70) {
-		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 10, 0, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[21], 23, 34);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[21], 6);
+		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 10, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 23, 34);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 6);
 	}
 
 	if (_game._trigger == 71)
@@ -1324,11 +1324,11 @@ void Scene207::step() {
 		return;
 
 	if ((_game._player._playerPos.x >= 124) && (_game._player._playerPos.x <= 201)) {
-		_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 10, 1, 0, 0);
-		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[22], 6);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[23], 6);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 71);
+		_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 10, 1, 0, 0);
+		_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 6);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 6);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_0, 0, 71);
 		_eyeFl = true;
 	}
 }
@@ -1359,14 +1359,14 @@ void Scene207::actions() {
 		    (_game._player._playerPos.y > 111) && (_game._player._playerPos.y < 130)) {
 			if ((_game._player._playerPos.x <= 162) && (_game._player._playerPos.x >= 181) &&
 			    (_game._player._playerPos.y <= 115) && (_game._player._playerPos.y >= 126)) {
-				_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 10, 2, 0, 0);
-				_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 2, 0, 0);
-				_scene->_sequences.setDepth(_globals._spriteIndexes[22], 6);
-				_scene->_sequences.setDepth(_globals._spriteIndexes[23], 6);
+				_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 10, 2, 0, 0);
+				_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 2, 0, 0);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 6);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 6);
 			}
 		} else if (_eyeFl) {
-			_scene->_sequences.remove(_globals._spriteIndexes[22]);
-			_scene->_sequences.remove(_globals._spriteIndexes[23]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[7]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[8]);
 			_eyeFl = false;
 		}
 
@@ -1418,9 +1418,9 @@ void Scene208::setup() {
 
 void Scene208::updateTrap() {
 	if (_globals[kRhotundaStatus] == 1) {
-		_globals._spriteIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 0, 0, 24);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[16], 5);
-		int idx = _scene->_dynamicHotspots.add(424, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 0, 0, 24);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
+		int idx = _scene->_dynamicHotspots.add(424, 13, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(100, 146), FACING_NORTH);
 		_scene->_hotspots.activate(414, false);
 		return;
@@ -1428,17 +1428,17 @@ void Scene208::updateTrap() {
 
 	switch (_globals[35]) {
 	case 0: {
-		_globals._spriteIndexes[17] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[17], 15);
-		int idx = _scene->_dynamicHotspots.add(426, 13, _globals._spriteIndexes[17], Common::Rect(0, 0, 0, 0));
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 15);
+		int idx = _scene->_dynamicHotspots.add(426, 13, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(60, 152), FACING_NORTH);
 		}
 		break;
 	case 2: {
-		_scene->_sequences.setDepth(_globals._spriteIndexes[18], 15);
-		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 15);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
 		_scene->_hotspots.activate(414, false);
-		int idx = _scene->_dynamicHotspots.add(425, 13, _globals._spriteIndexes[17], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(425, 13, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(100, 146), FACING_NORTH);
 		_scene->_dynamicHotspots[idx]._articleNumber = 5;
 		}
@@ -1491,7 +1491,7 @@ void Scene208::step() {
 		_rhotundaTime = _scene->_activeAnimation->getCurrentFrame();
 
 		if (_rhotundaTime == 125)
-			_scene->_sequences.remove(_globals._spriteIndexes[19]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 	}
 
 	if (!_rhotundaTurnFl)
@@ -1541,8 +1541,8 @@ void Scene208::subAction(int mode) {
 	case 0: {
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
-		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 1, 0, 0);
-		_scene->_sequences.setMsgLayout(_globals._spriteIndexes[20]);
+		_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 1, 0, 0);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
 
 		int abortVal;
 		if ((mode == 1) || (mode == 2))
@@ -1550,16 +1550,16 @@ void Scene208::subAction(int mode) {
 		else
 			abortVal = 2;
 
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[20], SM_0, 0, abortVal);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SM_0, 0, abortVal);
 		}
 		break;
 	case 1: {
-		int oldVal = _globals._spriteIndexes[20];
-		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 12, 3, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[20], 3, 4);
-		_scene->_sequences.setMsgLayout(_globals._spriteIndexes[20]);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[20], oldVal);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[20], SM_0, 0, 2);
+		int oldVal = _globals._sequenceIndexes[5];
+		_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 12, 3, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 3, 4);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[5], oldVal);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SM_0, 0, 2);
 		_vm->_sound->command(20);
 		}
 		break;
@@ -1567,7 +1567,7 @@ void Scene208::subAction(int mode) {
 		switch (mode) {
 		case 1:
 			_game._objects.addToInventory(6);
-			_scene->_sequences.remove(_globals._spriteIndexes[17]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 			_globals[kLeavesStatus] = 1;
 			break;
 		case 2:
@@ -1576,8 +1576,8 @@ void Scene208::subAction(int mode) {
 			updateTrap();
 			break;
 		case 3:
-			_scene->_sequences.remove(_globals._spriteIndexes[18]);
-			_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
+			_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 			_game._objects.removeFromInventory(10, 1);
 			_vm->_sound->command(34);
 			break;
@@ -1591,12 +1591,12 @@ void Scene208::subAction(int mode) {
 			break;
 		}
 
-		int oldVal = _globals._spriteIndexes[20];
-		_globals._spriteIndexes[20] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[5], false, 6, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[20], 1, 3);
-		_scene->_sequences.setMsgLayout(_globals._spriteIndexes[20]);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[20], oldVal);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[20], SM_0, 0, 3);
+		int oldVal = _globals._sequenceIndexes[5];
+		_globals._sequenceIndexes[5] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[5], false, 6, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 3);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[5], oldVal);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SM_0, 0, 3);
 		}
 		break;
 	case 3:
@@ -1720,36 +1720,36 @@ void Scene209::handlePeek() {
 	switch (_game._trigger) {
 	case 133:
 		_vm->_sound->command(18);
-		_globals._spriteIndexes[18] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 51, 52);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 134);
+		_globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 51, 52);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 134);
 		break;
 
 	case 134: {
-		int oldIdx = _globals._spriteIndexes[18];
-		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		int oldIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
 		_scene->_sequences.addTimer(60, 135);
 		}
 		break;
 
 	case 135:
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 7);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 7);
 		_scene->_sequences.addTimer(10, 136);
 		break;
 
 	case 136:
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
 		_scene->_sequences.addTimer(50, 137);
 		break;
 
 	case 137:
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 51, 52);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 138);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 51, 52);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 138);
 		break;
 
 	case 138:
@@ -1763,25 +1763,25 @@ void Scene209::handlePeek() {
 void Scene209::handleVerticalMove() {
 	switch (_game._trigger) {
 	case 140:
-		_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 8, 0, 1);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 1, 5);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 141);
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 8, 0, 1);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 5);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 141);
 		break;
 
 	case 141: {
 		_vm->_sound->command(18);
-		int oldIdx = _globals._spriteIndexes[18];
-		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 5);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		int oldIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 5);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
 		_scene->_sequences.addTimer(60, 142);
 		}
 		break;
 
 	case 142:
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[18] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 1, 5);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 143);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 5);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 143);
 		break;
 
 	case 143:
@@ -1797,28 +1797,28 @@ void Scene209::handleLookStay() {
 	case 145:
 		_vm->_sound->command(18);
 		_monkeyPosition = 2;
-		_globals._spriteIndexes[18] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 51, 52);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 146);
+		_globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 51, 52);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 146);
 		break;
 
 	case 146: {
-		int oldIdx = _globals._spriteIndexes[18];
-		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		int oldIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
 		_scene->_sequences.addTimer(15, 147);
 		}
 		break;
 
 	case 147:
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 7);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 7);
 		_scene->_sequences.addTimer(8, 148);
 		break;
 
 	case 148:
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
 
 		if (!_dodgeFl)
 			_scene->_sequences.addTimer(90, 149);
@@ -1837,16 +1837,16 @@ void Scene209::handleLookStay() {
 void Scene209::handleLookRight() {
 	switch (_game._trigger) {
 	case 151:
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 8, 2, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 8, 14);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 152);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 8, 2, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 8, 14);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 152);
 		break;
 
 	case 152: {
-		int oldIdx = _globals._spriteIndexes[18];
-		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		int oldIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
 		_scene->_sequences.addTimer(60, 153);
 		}
 		break;
@@ -1862,20 +1862,20 @@ void Scene209::handleLookRight() {
 void Scene209::handleBlink() {
 	switch (_game._trigger) {
 	case 155:
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
 		_scene->_sequences.addTimer(50, 156);
 		break;
 
 	case 156:
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 7);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 7);
 		_scene->_sequences.addTimer(10, 157);
 		break;
 
 	case 157:
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
 		_scene->_sequences.addTimer(50, 158);
 		break;
 
@@ -1892,31 +1892,31 @@ void Scene209::handleGetBinoculars() {
 	case 161:
 		_vm->_sound->command(18);
 		_monkeyPosition = 3;
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 8, 24);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_FRAME_INDEX, 20, 165);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 8, 24);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_FRAME_INDEX, 20, 165);
 		if (!_fallFl && !_dodgeFl) {
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 162);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 162);
 		} else {
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 163);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 163);
 		}
 		break;
 
 	case 162: {
-		int oldIdx = _globals._spriteIndexes[18];
-		_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 8, 6, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 23, 25);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 163);
+		int oldIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 8, 6, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 23, 25);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 163);
 		}
 		break;
 
 	case 163: {
-		int oldIdx = _globals._spriteIndexes[18];
-		_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 8, 0, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 23, 24);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		int oldIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 8, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 23, 24);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
 		_scene->_sequences.addTimer(8, 164);
 		}
 		break;
@@ -1936,20 +1936,20 @@ void Scene209::handleGetBinoculars() {
 void Scene209::handleBinocularBlink() {
 	switch (_game._trigger) {
 	case 167: {
-		int oldIdx = _globals._spriteIndexes[18];
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 8, 2, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 23, 25);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 168);
+		int oldIdx = _globals._sequenceIndexes[3];
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 8, 2, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 23, 25);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 168);
 		}
 		break;
 
 	case 168: {
-		int oldIdx = _globals._spriteIndexes[18];
-		_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 8, 0, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 23, 24);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		int oldIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 8, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 23, 24);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
 		_scene->_sequences.addTimer(30, 169);
 		}
 		break;
@@ -1965,46 +1965,46 @@ void Scene209::handleBinocularBlink() {
 void Scene209::handleBinocularScan() {
 	switch (_game._trigger) {
 	case 171: {
-		int oldIdx = _globals._spriteIndexes[18];
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 2, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 43, 45);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 172);
+		int oldIdx = _globals._sequenceIndexes[3];
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 2, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 43, 45);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 172);
 		}
 		break;
 
 	case 172: {
-		int oldIdx = _globals._spriteIndexes[18];
+		int oldIdx = _globals._sequenceIndexes[3];
 		int randAction = _vm->getRandomNumber(1,2);
 		switch (randAction) {
 		case 1:
-			_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 2, 0, 0);
+			_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 2, 0, 0);
 			break;
 		case 2:
-			_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 4, 0, 0);
+			_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 4, 0, 0);
 			break;
 		}
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 23, 25);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 173);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 23, 25);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 173);
 		}
 		break;
 
 	case 173: {
-		int oldIdx = _globals._spriteIndexes[18];
-		_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 2, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 26, 30);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 174);
+		int oldIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 2, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 26, 30);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 174);
 		}
 		break;
 
 	case 174: {
-		int oldIdx = _globals._spriteIndexes[18];
-		_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 0, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 23, 24);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+		int oldIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 23, 24);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
 		_scene->_sequences.addTimer(60, 175);
 		}
 		break;
@@ -2023,26 +2023,26 @@ void Scene209::handleJumpInTree() {
 		int oldIdx = 0;
 		_monkeyPosition = 1;
 		if (_removeMonkeyFl)
-			_scene->_sequences.remove(_globals._spriteIndexes[18]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[3]);
 		else
-			oldIdx = _globals._spriteIndexes[18];
+			oldIdx = _globals._sequenceIndexes[3];
 
-		_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 46, 49);
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 46, 49);
 		if (!_removeMonkeyFl)
-			_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
 
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 179);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 179);
 		}
 		break;
 
 	case 179: {
 		_vm->_sound->command(18);
-		int oldIdx = _globals._spriteIndexes[18];
-		_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 53, 61);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 180);
+		int oldIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 53, 61);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 180);
 		}
 		break;
 
@@ -2058,49 +2058,49 @@ void Scene209::handleJumpInTree() {
 void Scene209::handleTongue() {
 	switch (_game._trigger) {
 	case 182: {
-		int oldIdx = _globals._spriteIndexes[18];
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 26, 30);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 183);
+		int oldIdx = _globals._sequenceIndexes[3];
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 26, 30);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 183);
 		}
 		break;
 
 	case 183: {
-		int oldIdx = _globals._spriteIndexes[18];
-		_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 31, 33);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 184);
+		int oldIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 31, 33);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 184);
 		}
 		break;
 
 	case 184: {
-		int oldIdx = _globals._spriteIndexes[18];
-		_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 36, 37);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 185);
+		int oldIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 36, 37);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 185);
 		}
 		break;
 
 	case 185: {
 		_vm->_sound->command(18);
-		int oldIdx = _globals._spriteIndexes[18];
-		_globals._spriteIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 6, 20, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 38, 39);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 186);
+		int oldIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 6, 20, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 38, 39);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 186);
 		}
 		break;
 
 	case 186: {
-		int oldIdx = _globals._spriteIndexes[18];
-		_globals._spriteIndexes[18] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[18], 40, 41);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[18], SM_0, 0, 178);
+		int oldIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 40, 41);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 178);
 		_removeMonkeyFl = false;
 		}
 		break;
@@ -2111,36 +2111,36 @@ void Scene209::handleStandFromPeek() {
 	switch (_game._trigger) {
 	case 189:
 		_monkeyPosition = 4;
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 50);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 50);
 		_scene->_sequences.addTimer(8, 190);
 		break;
 
 	case 190:
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
 		_scene->_sequences.addTimer(8, 191);
 		break;
 
 	case 191:
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[21] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 8, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[21], 1, 5);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[21], SM_0, 0, 192);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 1, 5);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SM_0, 0, 192);
 		break;
 
 	case 192: {
 		_vm->_sound->command(18);
-		int oldIdx = _globals._spriteIndexes[21];
-		_globals._spriteIndexes[20] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[20], oldIdx);
+		int oldIdx = _globals._sequenceIndexes[6];
+		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[5], oldIdx);
 		_scene->_sequences.addTimer(8, 193);
 		}
 		break;
 
 	case 193:
-		_scene->_sequences.remove(_globals._spriteIndexes[20]);
-		_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 22);
+		_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 22);
 		_scene->_sequences.addTimer(5, 194);
 		break;
 
@@ -2154,20 +2154,20 @@ void Scene209::handleStandFromPeek() {
 void Scene209::handleStandBlink() {
 	switch (_game._trigger) {
 	case 246:
-		_scene->_sequences.remove(_globals._spriteIndexes[19]);
-		_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 22);
+		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 22);
 		_scene->_sequences.addTimer(10, 247);
 		break;
 
 	case 247:
-		_scene->_sequences.remove(_globals._spriteIndexes[19]);
-		_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 23);
+		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 23);
 		_scene->_sequences.addTimer(8, 248);
 		break;
 
 	case 248:
-		_scene->_sequences.remove(_globals._spriteIndexes[19]);
-		_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 22);
+		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 22);
 		_scene->_sequences.addTimer(10, 249);
 		break;
 
@@ -2182,10 +2182,10 @@ void Scene209::handleJumpAndHide() {
 	case 196:
 		_vm->_sound->command(18);
 		_monkeyPosition = 1;
-		_scene->_sequences.remove(_globals._spriteIndexes[19]);
-		_globals._spriteIndexes[20] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 8, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[20], 1, 16);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[20], SM_0, 0, 197);
+		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+		_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 16);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SM_0, 0, 197);
 		break;
 
 	case 197:
@@ -2200,66 +2200,66 @@ void Scene209::handleMonkeyEating() {
 	switch (_game._trigger) {
 	case 199:
 		_vm->_sound->command(18);
-		_scene->_sequences.remove(_globals._spriteIndexes[19]);
-		_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 10, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], 1, 14);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[19], SM_0, 0, 200);
+		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 1, 14);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 200);
 		break;
 
 	case 200: {
-		int oldIdx = _globals._spriteIndexes[19];
-		_globals._spriteIndexes[19] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 10, 10, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], 15, 16);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[19], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[19], SM_0, 0, 201);
+		int oldIdx = _globals._sequenceIndexes[4];
+		_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 10, 10, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 15, 16);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 201);
 		}
 		break;
 
 	case 201: {
-		int oldIdx = _globals._spriteIndexes[19];
-		_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 12);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[19], oldIdx);
+		int oldIdx = _globals._sequenceIndexes[4];
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 12);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], oldIdx);
 		_scene->_sequences.addTimer(20, 202);
 		}
 		break;
 
 	case 202:
-		_scene->_sequences.remove(_globals._spriteIndexes[19]);
-		_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 19);
+		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 19);
 		_scene->_sequences.addTimer(20, 203);
 		break;
 
 	case 203:
-		_scene->_sequences.remove(_globals._spriteIndexes[19]);
-		_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 17);
+		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 17);
 		_scene->_sequences.addTimer(20, 204);
 		break;
 
 	case 204:
-		_scene->_sequences.remove(_globals._spriteIndexes[19]);
-		_globals._spriteIndexes[19] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 10, 8, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], 18, 19);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[19], SM_0, 0, 205);
+		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+		_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 10, 8, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 18, 19);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 205);
 		break;
 
 	case 205: {
-		int oldIdx = _globals._spriteIndexes[19];
-		_globals._spriteIndexes[19] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 10, 8, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], 20, 21);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[19], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[19], SM_0, 0, 206);
+		int oldIdx = _globals._sequenceIndexes[4];
+		_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 10, 8, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 20, 21);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 206);
 		}
 		break;
 
 	case 206: {
-		int oldIdx = _globals._spriteIndexes[19];
-		_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 10, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], 22, 25);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[19], oldIdx);
+		int oldIdx = _globals._sequenceIndexes[4];
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 22, 25);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], oldIdx);
 		if (!_dodgeFl && !_fallFl)
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[19], SM_0, 0, 207);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 207);
 		else
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[19], SM_0, 0, 209);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 209);
 		}
 		break;
 
@@ -2268,28 +2268,28 @@ void Scene209::handleMonkeyEating() {
 		 int msgIndex = _scene->_kernelMessages.add(Common::Point(180, 25), 0xFDFC, 0, 0, 90, _game.getQuote(130));
 		 _scene->_kernelMessages.setQuoted(msgIndex, 4, true);
 
-		 int oldIdx = _globals._spriteIndexes[19];
-		_globals._spriteIndexes[19] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 15, 4, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], 26, 27);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[19], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[19], SM_0, 0, 208);
+		 int oldIdx = _globals._sequenceIndexes[4];
+		_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 15, 4, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 26, 27);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 208);
 		}
 		break;
 
 	case 208: {
 		_scene->_kernelMessages.add(Common::Point(180, 39), 0xFDFC, 0, 0, 90, _game.getQuote(131));
-		int oldIdx = _globals._spriteIndexes[19];
-		_globals._spriteIndexes[19] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 10, 4, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], 28, 29);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[19], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[19], SM_0, 0, 209);
+		int oldIdx = _globals._sequenceIndexes[4];
+		_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 10, 4, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 28, 29);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 209);
 		}
 		break;
 
 	case 209: {
-		int oldIdx = _globals._spriteIndexes[19];
-		_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 22);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[19], oldIdx);
+		int oldIdx = _globals._sequenceIndexes[4];
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 22);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], oldIdx);
 		_scene->_sequences.addTimer(1, 210);
 		}
 		break;
@@ -2313,14 +2313,14 @@ void Scene209::handleMonkeyFall() {
 		_scene->_kernelMessages.add(Common::Point(180, 26), 0xFDFC, 0, 0, 90, _game.getQuote(151));
 		_scene->_sequences.addTimer(40, 100);
 		_scene->_hotspots.activate(227, false);
-		int oldIdx = _globals._spriteIndexes[18];
+		int oldIdx = _globals._sequenceIndexes[3];
 		_monkeyPosition = 1;
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[23], 1, 35);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[23], 6);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 220);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 1, 35);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 6);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 220);
 		}
 		break;
 
@@ -2328,41 +2328,41 @@ void Scene209::handleMonkeyFall() {
 		_vm->_sound->command(18);
 		_scene->_kernelMessages.add(Common::Point(182, 109), 0xFDFC, 0, 0, 90, _game.getQuote(159));
 		_scene->_hotspots.activate(227, false);
-		int oldIdx = _globals._spriteIndexes[18];
+		int oldIdx = _globals._sequenceIndexes[3];
 		_monkeyPosition = 1;
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[23], 36, 42);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[23], 6);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[18], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 221);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 36, 42);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 6);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 221);
 		}
 		break;
 
 	case 221: {
 		_game._objects.setRoom(OBJ_BINOCULARS, 209);
 		_binocularsDroppedFl = true;
-		int oldIdx = _globals._spriteIndexes[23];
-		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
-		_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[24], oldIdx);
-		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(201, 131));
-		_scene->_sequences.setDepth(_globals._spriteIndexes[24], 8);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[23], oldIdx);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[23], 43, 72);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 222);
-		int idx = _scene->_dynamicHotspots.add(39, 13, _globals._spriteIndexes[24], Common::Rect(0, 0, 0, 0));
+		int oldIdx = _globals._sequenceIndexes[8];
+		_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
+		_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[9], oldIdx);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(201, 131));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[8], oldIdx);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 43, 72);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 222);
+		int idx = _scene->_dynamicHotspots.add(39, 13, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(200, 133), FACING_NORTH);
 		}
 		break;
 
 	case 222: {
 		_scene->_kernelMessages.add(Common::Point(182, 109), 0xFDFC, 0, 0, 70, _game.getQuote(160));
-		int oldIdx = _globals._spriteIndexes[23];
-		_globals._spriteIndexes[23] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[23], 73, 78);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[23], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[23], SM_0, 0, 223);
+		int oldIdx = _globals._sequenceIndexes[8];
+		_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 73, 78);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[8], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 223);
 		}
 		break;
 
@@ -2385,27 +2385,27 @@ void Scene209::handleMonkeyFall() {
 void Scene209::handleMonkey1() {
 	switch (_game._trigger) {
 	case 212:
-		_scene->_sequences.remove(_globals._spriteIndexes[19]);
-		_globals._spriteIndexes[19] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 9, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[19], 1, 13);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[19], SM_0, 0, 213);
+		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 9, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 1, 13);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 213);
 		break;
 
 	case 213: {
-		int oldIdx = _globals._spriteIndexes[19];
-		_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 7, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[22], 1, 22);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[22], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 214);
+		int oldIdx = _globals._sequenceIndexes[4];
+		_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 7, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[7], 1, 22);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[7], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_0, 0, 214);
 		}
 		break;
 
 	case 214: {
-		int oldIdx = _globals._spriteIndexes[22];
-		_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 7, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[22], 23, 26);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[22], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 215);
+		int oldIdx = _globals._sequenceIndexes[7];
+		_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 7, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[7], 23, 26);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[7], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_0, 0, 215);
 		int msgIndex = _scene->_kernelMessages.add(Common::Point(170, 21), 0xFDFC, 0, 0, 90, _game.getQuote(156));
 		_scene->_kernelMessages.setQuoted(msgIndex, 3, true);
 		}
@@ -2414,18 +2414,18 @@ void Scene209::handleMonkey1() {
 	case 215: {
 		_vm->_sound->command(18);
 		_scene->loadAnimation(Resources::formatName(209, 'a', -1, EXT_AA, ""), 251);
-		int oldIdx = _globals._spriteIndexes[22];
-		_globals._spriteIndexes[22] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 7, 1, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[22], 27, 35);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[22], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[22], SM_0, 0, 216);
+		int oldIdx = _globals._sequenceIndexes[7];
+		_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 7, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[7], 27, 35);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[7], oldIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_0, 0, 216);
 		}
 		break;
 
 	case 216: {
-		int oldIdx = _globals._spriteIndexes[22];
-		_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 22);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[19], oldIdx);
+		int oldIdx = _globals._sequenceIndexes[7];
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 22);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], oldIdx);
 		_scene->_sequences.addTimer(25, 217);
 		}
 		break;
@@ -2444,11 +2444,11 @@ void Scene209::handleMonkey2() {
 	case 251:
 		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 60, _game.getQuote(137));
 		_vm->_sound->command(22);
-		_globals._spriteIndexes[27] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[12], false, 11, 1, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[27], Common::Point(111, 133));
-		_scene->_sequences.setScale(_globals._spriteIndexes[27], 79);
-		_scene->_sequences.setAnimRange(_globals._spriteIndexes[27], 1, 6);
-		_scene->_sequences.addSubEntry(_globals._spriteIndexes[27], SM_0, 0, 252);
+		_globals._sequenceIndexes[12] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[12], false, 11, 1, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[12], Common::Point(111, 133));
+		_scene->_sequences.setScale(_globals._sequenceIndexes[12], 79);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[12], 1, 6);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SM_0, 0, 252);
 		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
 		_game._player._visible = false;
 		break;
@@ -2456,17 +2456,17 @@ void Scene209::handleMonkey2() {
 	case 252: {
 		_scene->_kernelMessages.reset();
 		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(132));
-		int oldIdx = _globals._spriteIndexes[27];
-		_globals._spriteIndexes[27] = _scene->_sequences.startCycle(_globals._spriteIndexes[12], false, 7);
-		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[27], Common::Point(111, 133));
-		_scene->_sequences.setScale(_globals._spriteIndexes[27], 79);
-		_scene->_sequences.updateTimeout(_globals._spriteIndexes[27], oldIdx);
+		int oldIdx = _globals._sequenceIndexes[12];
+		_globals._sequenceIndexes[12] = _scene->_sequences.startCycle(_globals._spriteIndexes[12], false, 7);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[12], Common::Point(111, 133));
+		_scene->_sequences.setScale(_globals._sequenceIndexes[12], 79);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[12], oldIdx);
 		_scene->_sequences.addTimer(120, 253);
 		}
 		break;
 
 	case 253:
-		_scene->_sequences.remove(_globals._spriteIndexes[27]);
+		_scene->_sequences.remove(_globals._sequenceIndexes[12]);
 		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
 		_game._player._visible = true;
 		_game._player._stepEnabled = true;
@@ -2478,22 +2478,22 @@ void Scene209::handleDodge() {
 	switch (_game._trigger) {
 	case 241:
 		_scene->_hotspots.activate(227, true);
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 7);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 7);
 		_scene->_sequences.addTimer(6, 242);
 		break;
 
 	case 242:
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 5);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 5);
 		_scene->_sequences.addTimer(25, 243);
 		_vm->_sound->command(24);
 		break;
 
 	case 243:
 		_vm->_sound->command(18);
-		_scene->_sequences.remove(_globals._spriteIndexes[18]);
-		_globals._spriteIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
 		_playingAnimFl = false;
 		_pauseMode = 0;
 		_scene->_kernelMessages.reset();
@@ -2526,10 +2526,10 @@ void Scene209::enter() {
 	_vm->_palette->setEntry(253, 63, 20, 22);
 
 	if (_game._objects.isInRoom(OBJ_PLANT_STALK)) {
-		_globals._spriteIndexes[16] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
-		int idx = _scene->_dynamicHotspots.add(271, 13, _globals._spriteIndexes[16], Common::Rect(0, 0, 0, 0));
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+		int idx = _scene->_dynamicHotspots.add(271, 13, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(263, 129), FACING_SOUTH);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[16], 13);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 13);
 	}
 
 	if (_scene->_priorSceneId == 208) {
@@ -2541,10 +2541,10 @@ void Scene209::enter() {
 	}
 
 	if (_game._objects.isInRoom(OBJ_BINOCULARS)) {
-		_globals._spriteIndexes[24] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
-		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[24], Common::Point(201, 131));
-		_scene->_sequences.setDepth(_globals._spriteIndexes[24], 8);
-		int idx = _scene->_dynamicHotspots.add(39, 13, _globals._spriteIndexes[24], Common::Rect(0, 0, 0, 0));
+		_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(201, 131));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
+		int idx = _scene->_dynamicHotspots.add(39, 13, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(200, 133), FACING_NORTH);
 	}
 
@@ -2802,52 +2802,52 @@ void Scene209::step() {
 		switch (_game._trigger) {
 		case 228:
 			_game._player._visible = false;
-			_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
-			_scene->_sequences.setAnimRange(_globals._spriteIndexes[17], 1, 7);
-			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(116, 131));
-			_scene->_sequences.setDepth(_globals._spriteIndexes[17], 4);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], SM_0, 0, 228);
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 7);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_0, 0, 228);
 			break;
 
 		case 229: {
-			int oldIdx = _globals._spriteIndexes[17];
-			_globals._spriteIndexes[17] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 7);
-			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(116, 131));
-			_scene->_sequences.setDepth(_globals._spriteIndexes[17], 4);
-			_scene->_sequences.updateTimeout(_globals._spriteIndexes[17], oldIdx);
+			int oldIdx = _globals._sequenceIndexes[2];
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 7);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], oldIdx);
 			_scene->_sequences.addTimer(35, 230);
 			}
 			break;
 
 		case 230:
-			_scene->_sequences.remove(_globals._spriteIndexes[17]);
-			_globals._spriteIndexes[17] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
-			_scene->_sequences.setAnimRange(_globals._spriteIndexes[17], 1, 7);
-			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(116, 131));
-			_scene->_sequences.setDepth(_globals._spriteIndexes[17], 4);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], SM_0, 0, 231);
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_globals._sequenceIndexes[2] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 7);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_0, 0, 231);
 			break;
 
 		case 231: {
-			int oldIdx = _globals._spriteIndexes[17];
-			_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
-			_scene->_sequences.setAnimRange(_globals._spriteIndexes[17], 8, 10);
-			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(116, 131));
-			_scene->_sequences.setDepth(_globals._spriteIndexes[17], 4);
-			_scene->_sequences.updateTimeout(_globals._spriteIndexes[17], oldIdx);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], SM_0, 0, 232);
+			int oldIdx = _globals._sequenceIndexes[2];
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 8, 10);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], oldIdx);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_0, 0, 232);
 			_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
-			_scene->_sequences.updateTimeout(_globals._spriteIndexes[17], -1);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], -1);
 			_game._player._visible = false;
 			}
 			break;
 
 		case 232: {
-			int oldIdx = _globals._spriteIndexes[17];
-			_globals._spriteIndexes[17] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 10);
-			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(116, 131));
-			_scene->_sequences.setDepth(_globals._spriteIndexes[17], 4);
-			_scene->_sequences.updateTimeout(_globals._spriteIndexes[17], oldIdx);
+			int oldIdx = _globals._sequenceIndexes[2];
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 10);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], oldIdx);
 			_scene->_sequences.addTimer(2, 233);
 			_scene->_kernelMessages.reset();
 			if (_dodgeFl && (_monkeyPosition != 1) && (_monkeyPosition != 2))
@@ -2862,31 +2862,31 @@ void Scene209::step() {
 			break;
 
 		case 234:
-			_scene->_sequences.remove(_globals._spriteIndexes[17]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 			_scene->_kernelMessages.reset();
 			if (_action.isAction(NOUN_HOSE_DOWN, NOUN_BLOWGUN, NOUN_MONKEY)) {
-				_globals._spriteIndexes[17] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[2], false, 7, 16, 0, 0);
-				_scene->_sequences.setAnimRange(_globals._spriteIndexes[17], 11, 12);
-				_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(116, 131));
-				_scene->_sequences.setDepth(_globals._spriteIndexes[17], 4);
-				_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], SM_FRAME_INDEX, 12, 239);
-				_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], SM_0, 0, 235);
+				_globals._sequenceIndexes[2] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[2], false, 7, 16, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 11, 12);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_FRAME_INDEX, 12, 239);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_0, 0, 235);
 			} else if (_action.isAction(NOUN_SHOOT, NOUN_BLOWGUN, NOUN_MONKEY)) {
-				_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
-				_scene->_sequences.setAnimRange(_globals._spriteIndexes[17], 11, 12);
-				_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(116, 131));
-				_scene->_sequences.setDepth(_globals._spriteIndexes[17], 4);
-				_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], SM_0, 0, 235);
+				_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 11, 12);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_0, 0, 235);
 				_vm->_sound->command(23);
 			}
 			break;
 
 		case 235: {
-			int oldIdx = _globals._spriteIndexes[17];
-			_globals._spriteIndexes[17] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 13);
-			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(116, 131));
-			_scene->_sequences.setDepth(_globals._spriteIndexes[17], 4);
-			_scene->_sequences.updateTimeout(_globals._spriteIndexes[17], oldIdx);
+			int oldIdx = _globals._sequenceIndexes[2];
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 13);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], oldIdx);
 			_scene->_sequences.addTimer(12, 236);
 			_forceFallFl = true;
 			_forceDodgeFl = true;
@@ -2894,12 +2894,12 @@ void Scene209::step() {
 			break;
 
 		case 236:
-			_scene->_sequences.remove(_globals._spriteIndexes[17]);
-			_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
-			_scene->_sequences.setAnimRange(_globals._spriteIndexes[17], 14, 16);
-			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(116, 131));
-			_scene->_sequences.setDepth(_globals._spriteIndexes[17], 4);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[17], SM_0, 0, 237);
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 14, 16);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_0, 0, 237);
 			break;
 
 		case 237:
@@ -2909,7 +2909,7 @@ void Scene209::step() {
 			break;
 
 		case 238:
-			_scene->_sequences.remove(_globals._spriteIndexes[17]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 			if (_dodgeFl)
 				_game._player._stepEnabled = true;
 
@@ -3122,14 +3122,14 @@ void Scene209::actions() {
 			_globals._spriteIndexes[11] = _scene->_sprites.addSprites("*RXMBD_2");
 			_game._player._stepEnabled = false;
 			_game._player._visible = false;
-			_globals._spriteIndexes[26] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[11], false, 3, 2, 0, 0);
-			_scene->_sequences.setMsgLayout(_globals._spriteIndexes[26]);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_FRAME_INDEX, 4, 1);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[26], SM_0, 0, 2);
+			_globals._sequenceIndexes[11] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[11], false, 3, 2, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[11]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_FRAME_INDEX, 4, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_0, 0, 2);
 			break;
 
 		case 1:
-			_scene->_sequences.remove(_globals._spriteIndexes[16]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_game._objects.addToInventory(OBJ_PLANT_STALK);
 			break;
 
@@ -3154,14 +3154,14 @@ void Scene209::actions() {
 			_globals._spriteIndexes[10] = _scene->_sprites.addSprites("*RXMBD_8");
 			_game._player._stepEnabled = false;
 			_game._player._visible = false;
-			_globals._spriteIndexes[25] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[10], false, 3, 2, 0, 0);
-			_scene->_sequences.setMsgLayout(_globals._spriteIndexes[25]);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[25], SM_FRAME_INDEX, 4, 1);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[25], SM_0, 0, 2);
+			_globals._sequenceIndexes[10] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[10], false, 3, 2, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[10]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SM_FRAME_INDEX, 4, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SM_0, 0, 2);
 			break;
 
 		case 1:
-			_scene->_sequences.remove(_globals._spriteIndexes[24]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[9]);
 			_game._objects.addToInventory(OBJ_BINOCULARS);
 			break;
 
@@ -3820,8 +3820,8 @@ void Scene210::enter() {
 		_game._player._playerPos = Common::Point(308, 132);
 
 	if (!_globals[kCurtainOpen]) {
-		_globals._spriteIndexes[8] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 5);
-		_scene->_sequences.setDepth(_globals._spriteIndexes[8], 5);
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 5);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
 	} else {
 		int idx = _scene->_dynamicHotspots.add(112, 395, -1, Common::Rect(163, 87, 19, 36)); 
 		_doorway = _scene->_dynamicHotspots.setPosition(idx, Common::Point(168, 127), FACING_NORTH);
@@ -4190,10 +4190,10 @@ void Scene210::actions() {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
-			_scene->_sequences.remove(_globals._spriteIndexes[8]);
-			_globals._spriteIndexes[8] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[1], false, 12, 1, 0, 0);
-			_scene->_sequences.setDepth(_globals._spriteIndexes[8], 5);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[8], SM_0, 0, 1);
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_globals._sequenceIndexes[1] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[1], false, 12, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SM_0, 0, 1);
 			break;
 
 		case 1:
@@ -4211,17 +4211,17 @@ void Scene210::actions() {
 	if ((_action.isAction(VERB_PULL, 0x5F) || _action.isAction(VERB_CLOSE, 0x5F)) && _globals[kCurtainOpen]) {
 		switch (_game._trigger) {
 		case 0:
-			_scene->_sequences.remove(_globals._spriteIndexes[8]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_game._player._stepEnabled = false;
 			_game._player._facing = FACING_NORTH;
-			_globals._spriteIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 12, 0, 0, 1);
-			_scene->_sequences.setDepth(_globals._spriteIndexes[8], 5);
-			_scene->_sequences.addSubEntry(_globals._spriteIndexes[8], SM_0, 0, 1);
+			_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 12, 0, 0, 1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SM_0, 0, 1);
 			_game._player._stepEnabled = false;
 			break;
 		case 1:
-			_globals._spriteIndexes[8] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 5);
-			_scene->_sequences.setDepth(_globals._spriteIndexes[8], 5);
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 5);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
 			_scene->_sequences.addTimer(48, 2);
 			break;
 		case 2:
@@ -4355,11 +4355,11 @@ void Scene211::enter() {
 	}
 
 	if (_vm->getRandomNumber(1, 8) == 1) {
-		_globals._spriteIndexes[17] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[17], Common::Point(202, 126));
-		_scene->_sequences.setDepth(_globals._spriteIndexes[17], 8);
-		_scene->_sequences.sub70C52(_globals._spriteIndexes[17], SM_FRAME_INDEX, -200, 0);
-		_scene->_dynamicHotspots.add(324, 13, _globals._spriteIndexes[17], Common::Rect(1, 1, 41, 10));
+		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(202, 126));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 8);
+		_scene->_sequences.sub70C52(_globals._sequenceIndexes[2], SM_FRAME_INDEX, -200, 0);
+		_scene->_dynamicHotspots.add(324, 13, _globals._sequenceIndexes[2], Common::Rect(1, 1, 41, 10));
 	}
 
 	if (_scene->_roomChanged)
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 6fee0cb..8a5c3df 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -105,24 +105,24 @@ void Scene804::enter() {
 
 	if (_globals[kInSpace]) {
 		if (_globals[kWindowFixed]) {
-			_globals._spriteIndexes[20] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], 0, 1);
+			_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], 0, 1);
 			_scene->_sequences.addTimer(60, 100);
 		} else {
-			_globals._spriteIndexes[21] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 1);
-			_globals._spriteIndexes[22] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[7], false, 4, 0, 0, 0);
+			_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 1);
+			_globals._sequenceIndexes[7] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[7], false, 4, 0, 0, 0);
 			_scene->_sequences.addTimer(160, 70);
 			_game._player._stepEnabled = false;
 		}
 	} else {
 		if (_globals[kBeamIsUp] == 0)
-			_globals._spriteIndexes[23] = _scene->_sequences.startCycle(_globals._spriteIndexes[8], false, 1);
+			_globals._sequenceIndexes[8] = _scene->_sequences.startCycle(_globals._spriteIndexes[8], false, 1);
 
 		if (_globals[kWindowFixed] == 0)
-			_globals._spriteIndexes[23] = _scene->_sequences.startCycle(_globals._spriteIndexes[19], false, 1);
+			_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
 
-		_globals._spriteIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
-		_scene->_sequences.setMsgPosition(_globals._spriteIndexes[16], Common::Point(133, 139));
-		_scene->_sequences.setDepth(_globals._spriteIndexes[16], 8);
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(133, 139));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 8);
 	}
 
 	_scene->loadAnimation(Resources::formatName(804, 'r', 1, EXT_AA, ""));
@@ -138,7 +138,7 @@ void Scene804::enter() {
 void Scene804::step() {
 	if (_globals._frameTime) {
 		if (_scene->_activeAnimation->getCurrentFrame() == 36 && !_globals._v3) {
-			_scene->_sequences.remove(_globals._spriteIndexes[16]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_globals._v3 = -1;
 		}
 		if (_scene->_activeAnimation->getCurrentFrame() == 39) {
@@ -160,9 +160,9 @@ void Scene804::step() {
 		}
 	} else {
 		if (_globals._v3 && _globals._v2 && _scene->_activeAnimation->getCurrentFrame() == 39) {
-			_globals._spriteIndexes[16] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
-			_scene->_sequences.setMsgPosition(_globals._spriteIndexes[16], Common::Point(133, 139));
-			_scene->_sequences.setDepth(_globals._spriteIndexes[16], 8);
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(133, 139));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 8);
 			_globals._v3 = 0;
 		}
 
@@ -175,7 +175,7 @@ void Scene804::step() {
 			_globals._v5 = 42;
 
 		if (_scene->_activeAnimation->getCurrentFrame() == 65)
-			_scene->_sequences.remove(_globals._spriteIndexes[22]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[7]);
 
 		switch (_game._storyMode)  {
 		case STORYMODE_NAUGHTY:
@@ -205,7 +205,7 @@ void Scene804::step() {
 
 		if (_scene->_activeAnimation->getCurrentFrame() == 34) {
 			_globals._v5 = 36;
-			_scene->_sequences.remove(_globals._spriteIndexes[16]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		}
 		if (_scene->_activeAnimation->getCurrentFrame() == 37) {
 			_globals._v5 = 36;
@@ -217,7 +217,7 @@ void Scene804::step() {
 			_scene->_nextSceneId = 803;
 
 		if (_scene->_activeAnimation->getCurrentFrame() == 7 && !_globals[kWindowFixed]) {
-			_globals._spriteIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
+			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 			_scene->_sequences.addTimer(20, 110);
 			_globals[kWindowFixed] = -1;
 		}


Commit: 5793daa75ea9364b163acaa83c1be126971444e4
    https://github.com/scummvm/scummvm/commit/5793daa75ea9364b163acaa83c1be126971444e4
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-12T10:28:09+02:00

Commit Message:
MADS: Implement Scene 105

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 9fa057e..f9d23be 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -55,6 +55,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene103(vm);
 	case 104:
 		return new Scene104(vm);
+	case 105:
+		return new Scene105(vm);
 
 	// Scene group #2
 	case 201:
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 32172da..3d87e9e 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -1710,5 +1710,152 @@ void Scene104::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene105::setup() {
+	// Preloading has been skipped
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene105::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('m', 1), false);
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('f', 4), false);
+	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 0, 0, 0);
+
+	if (_globals[kFishIn105]) {
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6, 0, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(48, 144));
+
+		int idx = _scene->_dynamicHotspots.add(101, 348, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(56, 141), FACING_NORTHWEST);
+	}
+
+	if (_scene->_priorSceneId == 104)
+		_game._player._playerPos = Common::Point(13, 97);
+	else if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(116, 147);
+
+	_game.loadQuoteSet(0x4A, 0x4B, 0x4C, 0x35, 0x34, 0);
+	_explosionFl = false;
+
+	sceneEntrySound();
+}
+
+void Scene105::step() {
+	if ((_game._player._playerPos == Common::Point(170, 87)) && (_game._trigger || !_explosionFl)) {
+		_explosionFl = true;
+		switch (_game._trigger) {
+		case 0:
+			_scene->_kernelMessages.reset();
+			_scene->resetScene();
+			_game._player._stepEnabled = false;
+			_game._player._visible   = false;
+
+			_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('m', 0), false);
+			_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('m', 2), false);
+			_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('m', 3), false);
+			_vm->_sound->command(33);
+			_scene->clearSequenceList();
+
+			warning("TODO: sub7C8DE();");
+
+			_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[0], 8);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SM_0, 0, 1);
+
+			if (_game._storyMode >= STORYMODE_NICE)
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SM_FRAME_INDEX, 8, 3);
+			break;
+
+		case 1:
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 8);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -2, -2);
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 9, 1, 0, 0);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], _globals._sequenceIndexes[0]);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 8);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 5, 7);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_0, 0, 2);
+			break;
+
+		case 2: {
+			int oldIdx = _globals._sequenceIndexes[2];
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 9, 0, 0, 0);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], oldIdx);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 8);
+			_scene->_sequences.addTimer(90, 3);
+			}
+			break;
+
+		case 3:
+			_vm->_dialogs->show(0x290B);
+			_scene->_reloadSceneFlag = true;
+			_scene->_sequences.addTimer(90, 4);
+			break;
+		}
+	}
+
+	if (_game._player._moving && (_scene->_rails.getNext() > 0)) {
+		_game._player.cancelCommand();
+		_game._player.startWalking(Common::Point(170, 87), FACING_NONE);
+		_scene->_rails.resetNext();
+	}
+
+	if ((_game._player._special > 0) && _game._player._stepEnabled)
+		_game._player._stepEnabled = false;
+}
+
+void Scene105::preActions() {
+	if (_action.isAction(0x15D, 0x195))
+		_game._player._walkOffScreenSceneId = 104;
+
+	if (_action.isAction(0x15D, 0xF5))
+		_game._player._walkOffScreenSceneId = 107;
+
+	if (_action.isAction(0xE0) && (_action.isAction(VERB_TALKTO) || _action.isAction(VERB_LOOK)))
+		_game._player._needToWalk = false;
+}
+
+void Scene105::actions() {
+	if (_action._lookFlag)
+		_vm->_dialogs->show(0x2910);
+	else if (_action.isAction(VERB_TAKE, 0x65) && _globals[kFishIn105]) {
+		if (_game._objects.isInInventory(OBJ_DEAD_FISH)) {
+			int randVal = _vm->getRandomNumber(74, 76);
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(randVal));
+		} else {
+			_scene->_sequences.remove (_globals._sequenceIndexes[4]);
+			_game._objects.addToInventory(OBJ_DEAD_FISH);
+			_globals[kFishIn105] = false;
+			_vm->_dialogs->showPicture(OBJ_DEAD_FISH, 0x322, 0);
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x195))
+		_vm->_dialogs->show(0x2905); 
+	else if (_action.isAction(VERB_LOOK, 0x4D))
+		_vm->_dialogs->show(0x2906); 
+	else if (_action.isAction(VERB_LOOK, 0xF0))
+		_vm->_dialogs->show(0x2907); 
+	else if (_action.isAction(VERB_LOOK, 0xDD))
+		_vm->_dialogs->show(0x2908); 
+	else if (_action.isAction(VERB_TAKE, 0xDD))
+		_vm->_dialogs->show(0x2909); 
+	else if (_action.isAction(VERB_LOOK, 0xE0))
+		_vm->_dialogs->show(0x290A); 
+	else if (_action.isAction(VERB_LOOK, 0x65))
+		_vm->_dialogs->show(0x290C); 
+	else if (_action.isAction(VERB_LOOK, 0x158))
+		_vm->_dialogs->show(0x290D); 
+	else if (_action.isAction(VERB_LOOK, 0xF5))
+		_vm->_dialogs->show(0x290E); 
+	else if (_action.isAction(VERB_LOOK, 0x129))
+		_vm->_dialogs->show(0x290F); 
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index e4c8618..2322406 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -129,6 +129,21 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene105 : public Scene1xx {
+private:
+	bool _explosionFl;
+
+public:
+	Scene105(MADSEngine *vm) : Scene1xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 2a979e59a0481f62d67b8b323c79cccaa6552d0a
    https://github.com/scummvm/scummvm/commit/2a979e59a0481f62d67b8b323c79cccaa6552d0a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-12T11:00:29-04:00

Commit Message:
MADS: Refactoring PaletteUsage to use external data arrays

Changed paths:
    engines/mads/animation.cpp
    engines/mads/game.cpp
    engines/mads/palette.cpp
    engines/mads/palette.h
    engines/mads/scene.cpp
    engines/mads/scene.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 40abdbe..0547c6b 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -403,6 +403,7 @@ void Animation::loadInterface(UserInterface &interfaceSurface, MSurface &depthSu
 		AAHeader &header, int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo) {
 	_scene->_depthStyle = 0;
 	if (header._animMode <= 2) {
+		_vm->_palette->_paletteUsage.setEmpty();
 		sceneInfo->load(header._roomNumber, flags, header._interfaceFile, 0, depthSurface, interfaceSurface);
 		_scene->_depthStyle = sceneInfo->_depthStyle == 2 ? 1 : 0;
 		if (palAnimData) {
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 9296b95..9eb2c5c 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -189,7 +189,12 @@ void Game::sectionLoop() {
 			_vm->_palette->initPalette();
 		}
 
-		_vm->_palette->_paletteUsage.load(3, 0xF0, 0xF1, 0xF2);
+		// Set up scene palette usage
+		_scene._scenePaletteUsage.clear();
+		_scene._scenePaletteUsage.push_back(PaletteUsage::UsageEntry(0xF0));
+		_scene._scenePaletteUsage.push_back(PaletteUsage::UsageEntry(0xF1));
+		_scene._scenePaletteUsage.push_back(PaletteUsage::UsageEntry(0xF2));
+		_vm->_palette->_paletteUsage.load(&_scene._scenePaletteUsage);
 		
 		if (!_player._spritesLoaded && _player._loadsFirst) {
 			if (_player.loadSprites(""))
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 2ff16fb5..a307a08 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -44,27 +44,20 @@ void RGB6::load(Common::SeekableReadStream *f) {
 
 PaletteUsage::PaletteUsage(MADSEngine *vm) {
 	_vm = vm;
+	_data = nullptr;
 }
 
-void PaletteUsage::load(int count, ...) {
-	va_list va;
-	va_start(va, count);
-
-	_data.clear();
-	for (int i = 0; i < count; ++i)
-		_data.push_back(UsageEntry(va_arg(va, int)));
-
-	va_end(va);
+void PaletteUsage::load(Common::Array<UsageEntry> *data) {
+	_data = data;
 }
 
-
 void PaletteUsage::getKeyEntries(Common::Array<RGB6> &palette) {
-	_data.clear();
+	_data->clear();
 
 	 for (uint i = 0; i < palette.size(); ++i) {
 		 byte *uPtr = &palette[i]._flags;
-		 if ((*uPtr & 0x10) && _data.size() < 3) {
-			 _data.push_back(UsageEntry(i));
+		 if ((*uPtr & 0x10) && _data->size() < 3) {
+			 _data->push_back(UsageEntry(i));
 		 }
 	 }
 }
@@ -74,12 +67,12 @@ static bool sortHelper(const PaletteUsage::UsageEntry &ue1, const PaletteUsage::
 }
 
 void PaletteUsage::prioritize(Common::Array<RGB6> &palette) {
-	for (uint i = 0; i < _data.size(); ++i) {
-		RGB6 &palEntry = palette[_data[i]._palIndex];
-		_data[i]._sortValue = rgbMerge(palEntry);
+	for (uint i = 0; i < _data->size(); ++i) {
+		RGB6 &palEntry = palette[(*_data)[i]._palIndex];
+		(*_data)[i]._sortValue = rgbMerge(palEntry);
 	}
 	
-	Common::sort(_data.begin(), _data.end(), sortHelper);
+	Common::sort(_data->begin(), _data->end(), sortHelper);
 }
 
 static bool rangeSorter(const PaletteUsage::UsageRange &ur1, const PaletteUsage::UsageRange &ur2) {
@@ -105,15 +98,15 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 
 	int rgbIndex = _vm->_palette->_rgbList.scan();
 	uint32 rgbMask = 1 << rgbIndex;
-	int varA = flags & 0x8000;
-	bool hasUsage = !_vm->_palette->_paletteUsage.empty();
+	bool noUsageFlag = flags & 0x8000;
+	bool hasUsage = _data != nullptr;
 	bool flag1 = false;
 
 	if (hasUsage) {
-		if (varA || _vm->_palette->_paletteUsage.empty())
+		if (noUsageFlag || _data->size() == 0)
 			hasUsage = false;
 
-		if (varA && !_vm->_palette->_paletteUsage.empty())
+		if (noUsageFlag && _data->size() > 0)
 			flag1 = true;
 	}
 
@@ -155,18 +148,18 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 		}
 
 		if (hasUsage && palette[v1]._flags & 0x10) {
-			for (uint usageIndex = 0; usageIndex < _data.size() && !var48; ++usageIndex) {
-				if (_data[usageIndex]._palIndex == palIndex) {
+			for (uint usageIndex = 0; usageIndex < _data->size() && !var48; ++usageIndex) {
+				if ((*_data)[usageIndex]._palIndex == palIndex) {
 					var48 = true;
-					int dataIndex = MIN(usageIndex, _data.size() - 1);
-					var4 = _data[dataIndex]._palIndex;
+					int dataIndex = MIN(usageIndex, _data->size() - 1);
+					var4 = (*_data)[dataIndex]._palIndex;
 				}
 			}
 		}
 
 		if (flag1 && palette[palIndex]._flags & 0x10) {
-			for (uint usageIndex = 0; usageIndex < _data.size() && !var48; ++usageIndex) {
-				if (_data[usageIndex]._palIndex == palIndex) {
+			for (uint usageIndex = 0; usageIndex < _data->size() && !var48; ++usageIndex) {
+				if ((*_data)[usageIndex]._palIndex == palIndex) {
 					var48 = true;
 					var4 = 0xF0 + usageIndex;
 
@@ -180,7 +173,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 			}
 		}
 
-		if (!var48 && !varA) {
+		if (!var48 && !noUsageFlag) {
 			int var2 = (palette[palIndex]._flags & 0x20) ||
 				(((flags & 0x2000) || (palette[palIndex]._flags & 0x4000)) &&
 				((flags & 0x1000) || (palCount == 0))) ? 0x7fff : 1;
@@ -229,7 +222,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 		}
 		
 		assert(var48);
-		int var52 = (varA && palette[palIndex]._u2) ? 2 : 0;
+		int var52 = (noUsageFlag && palette[palIndex]._u2) ? 2 : 0;
 
 		_vm->_palette->_palFlags[var4] |= var52 | rgbMask;
 		palette[palIndex]._palIndex = var4;
@@ -248,9 +241,9 @@ int PaletteUsage::rgbMerge(RGB6 &palEntry) {
 
 void PaletteUsage::transform(Common::Array<RGB6> &palette) {
 	if (!empty()) {
-		for (uint i = 0; i < _data.size(); ++i) {
-			int palIndex = _data[i]._palIndex;
-			_data[i]._palIndex = palette[palIndex]._palIndex;
+		for (uint i = 0; i < _data->size(); ++i) {
+			int palIndex = (*_data)[i]._palIndex;
+			(*_data)[i]._palIndex = palette[palIndex]._palIndex;
 		}
 	}
 }
@@ -433,7 +426,7 @@ void Palette::resetGamePalette(int lowRange, int highRange) {
 	if (highRange) {
 		_palFlags[255] = 1;
 
-		Common::fill(&_palFlags[255 - highRange], &_palFlags[254], _palFlags[255]);
+		Common::fill(&_palFlags[256 - highRange], &_palFlags[254], _palFlags[255]);
 	}
 
 	_rgbList.clear();
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index cceef09..74355f8 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -71,7 +71,7 @@ public:
 		uint16 _palIndex;
 		int _sortValue;
 
-		UsageEntry(int palIndex) { _palIndex = palIndex; }
+		UsageEntry(int palIndex) { _palIndex = palIndex; _sortValue = -1; }
 	};
 	struct UsageRange {
 		byte _v1, _v2;
@@ -80,27 +80,34 @@ public:
 	};
 private:
 	MADSEngine *_vm;
-	Common::Array<UsageEntry> _data;
+	Common::Array<UsageEntry> *_data;
 
 	int rgbMerge(RGB6 &palEntry);
 
 	int getGamePalFreeIndex(int *palIndex);
 
 	int rgbFactor(byte *palEntry, RGB6 &pal6);
+
+	Common::Array<UsageEntry> _nullUsage;
 public:
 	/**
 	 * Constructor
 	 */
 	PaletteUsage(MADSEngine *vm);
 
-	void load(int count, ...);
+	void load(Common::Array<UsageEntry> *data);
 
 	/**
 	 * Returns whether the usage list is empty
 	 */
-	bool empty() const { return _data.size() == 0;  }
+	bool empty() const { return _data == nullptr; }
+
+	uint16 &operator[](int index) { return (*_data)[index]._palIndex; }
 
-	uint16 &operator[](int index) { return _data[index]._palIndex; }
+	/**
+	 * Assigns the class to an empty usage array
+	 */
+	void setEmpty() { _data = &_nullUsage; }
 
 	/**
 	 * Gets key entries from the passed palette
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 9f8c922..92c5ced 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -50,6 +50,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 	_layer = LAYER_GUI;
 	_lookFlag = false;
 
+	_paletteUsageF.push_back(PaletteUsage::UsageEntry(0xF));
+
 	_verbList.push_back(VerbInit(VERB_LOOK, VERB_THAT, PREP_NONE));
 	_verbList.push_back(VerbInit(VERB_TAKE, VERB_THAT, PREP_NONE));
 	_verbList.push_back(VerbInit(VERB_PUSH, VERB_THAT, PREP_NONE));
@@ -121,8 +123,8 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	_spriteSlots.reset(false);
 	_sequences.clear();
 	_kernelMessages.clear();
+	_vm->_palette->_paletteUsage.load(&_scenePaletteUsage);
 
-	// TODO: palletteUsage reset?  setPalette(_nullPalette);
 	int flags = SCENEFLAG_LOAD_SHADOW;
 	if (_vm->_dithering)
 		flags |= SCENEFLAG_DITHER;
@@ -144,7 +146,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	loadVocab();
 
 	// Load palette usage
-	_vm->_palette->_paletteUsage.load(1, 0xF);
+	_vm->_palette->_paletteUsage.load(&_paletteUsageF);
 
 	// Load interface
 	flags = PALFLAG_RESERVED | ANIMFLAG_LOAD_BACKGROUND;
@@ -157,7 +159,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	MSurface depthSurface;
 	_animationData->load(_userInterface, depthSurface, prefix, flags, nullptr, nullptr);
 	
-	_vm->_palette->_paletteUsage.load(0);
+	_vm->_palette->_paletteUsage.load(&_scenePaletteUsage);
 
 	_bandsRange = _sceneInfo->_yBandsEnd - _sceneInfo->_yBandsStart;
 	_scaleRange = _sceneInfo->_maxScale - _sceneInfo->_minScale;
@@ -576,6 +578,7 @@ void Scene::free() {
 		_activeAnimation = nullptr;
 	}
 
+	_vm->_palette->_paletteUsage.load(nullptr);
 	_hotspots.clear();
 	_backgroundSurface.free();
 	_depthSurface.free();
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index a49692d..4d9a3f8 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -128,6 +128,8 @@ public:
 	Layer _layer;
 	bool _lookFlag;
 	Common::Point _customDest;
+	Common::Array<PaletteUsage::UsageEntry> _paletteUsageF;
+	Common::Array<PaletteUsage::UsageEntry> _scenePaletteUsage;
 
 	/**
 	 * Constructor


Commit: bb82a344a96bcf63c63ab6a297b83eaefa0383d6
    https://github.com/scummvm/scummvm/commit/bb82a344a96bcf63c63ab6a297b83eaefa0383d6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-12T11:08:50-04:00

Commit Message:
MADS: Further refactoring for PaletteUsage data arrays

Changed paths:
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index a307a08..8dfd8f6 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -84,6 +84,10 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 	int palHigh = (flags & 0x800) ? 0x100 : 0xFC;
 	int palIdx;
 
+	PaletteUsage tempUsage(_vm);
+	Common::Array<UsageEntry> tempUsageData;
+	tempUsage.load(&tempUsageData);
+
 	if (flags & 0x4000) {
 		palLow = 0;
 		palIdx = palHigh;
@@ -111,12 +115,12 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 	}
 
 	if (hasUsage) {
-		getKeyEntries(palette);
-		prioritize(palette);
+		tempUsage.getKeyEntries(palette);
+		tempUsage.prioritize(palette);
 	}
 
 	int freeIndex;
-	int palCount = getGamePalFreeIndex(&freeIndex);
+	int palCount = tempUsage.getGamePalFreeIndex(&freeIndex);
 	Common::Array<UsageRange> palRange;
 
 	for (uint palIndex = 0; palIndex < palette.size(); ++palIndex) {
@@ -148,8 +152,8 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 		}
 
 		if (hasUsage && palette[v1]._flags & 0x10) {
-			for (uint usageIndex = 0; usageIndex < _data->size() && !var48; ++usageIndex) {
-				if ((*_data)[usageIndex]._palIndex == palIndex) {
+			for (uint usageIndex = 0; usageIndex < tempUsage._data->size() && !var48; ++usageIndex) {
+				if ((*tempUsage._data)[usageIndex]._palIndex == palIndex) {
 					var48 = true;
 					int dataIndex = MIN(usageIndex, _data->size() - 1);
 					var4 = (*_data)[dataIndex]._palIndex;
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 74355f8..5ad7e23 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -72,6 +72,7 @@ public:
 		int _sortValue;
 
 		UsageEntry(int palIndex) { _palIndex = palIndex; _sortValue = -1; }
+		UsageEntry() { _palIndex = 0; _sortValue = 0; }
 	};
 	struct UsageRange {
 		byte _v1, _v2;


Commit: 8b2a7525cc6af408f05e2bac9b1b16ed0b36dcda
    https://github.com/scummvm/scummvm/commit/8b2a7525cc6af408f05e2bac9b1b16ed0b36dcda
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-12T12:09:29-04:00

Commit Message:
MADS: Fix a bunch of GCC warnings

Changed paths:
    engines/mads/action.cpp
    engines/mads/animation.cpp
    engines/mads/detection_tables.h
    engines/mads/game.h
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/rails.cpp
    engines/mads/screen.cpp
    engines/mads/sequence.cpp
    engines/mads/user_interface.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index f3e1d2d..2d3c115 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -403,6 +403,9 @@ void MADSAction::checkActionAtMousePos() {
 				}
 			}
 			break;
+
+		default:
+			break;
 		}
 	}
 
@@ -618,6 +621,9 @@ void MADSAction::leftClick() {
 			break;
 		}
 		break;
+
+	default:
+		break;
 	}
 }
 
diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 0547c6b..ddad63c 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -315,8 +315,8 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
 	}
 
 	if (_header._manualFlag) {
-		Common::String resName = "*" + _header._spriteSetNames[_header._spritesIndex];
-		SpriteAsset *sprites = new SpriteAsset(_vm, resName, flags);
+		Common::String assetResName = "*" + _header._spriteSetNames[_header._spritesIndex];
+		SpriteAsset *sprites = new SpriteAsset(_vm, assetResName, flags);
 		_spriteSets[_header._spritesIndex] = sprites;
 
 		_spriteListIndexes[_header._spritesIndex] = _scene->_sprites.add(sprites);
diff --git a/engines/mads/detection_tables.h b/engines/mads/detection_tables.h
index d7614cf..4eb1dd5 100644
--- a/engines/mads/detection_tables.h
+++ b/engines/mads/detection_tables.h
@@ -59,7 +59,7 @@ static const MADSGameDescription gameDescriptions[] = {
 		0
 	},
 
-	{ AD_TABLE_END_MARKER }
+	{ AD_TABLE_END_MARKER, 0, 0 }
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/game.h b/engines/mads/game.h
index c7cb660..2c87d70 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -51,7 +51,6 @@ enum KernelMode {
 enum ProtectionResult {
 	PROTECTION_SUCCEED = 0, PROTECTION_FAIL = 1, PROTECTION_ESCAPE = 2
 };
-;
 
 class Game {
 private:
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 13019d5..30b28fe 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -169,12 +169,12 @@ bool DialogsNebular::show(int msgId) {
 					} else if (commandCheck("VERB", valStr, commandText)) {
 						dialogText += getVocab(action._activeAction._verbId);
 					} else if (commandCheck("INDEX", valStr, commandText)) {
-						int idx = atoi(valStr.c_str());
-						if (_indexList[idx])
-							dialogText += getVocab(_indexList[idx]);
+						int idxLocal = atoi(valStr.c_str());
+						if (_indexList[idxLocal])
+							dialogText += getVocab(_indexList[idxLocal]);
 					} else if (commandCheck("NUMBER", valStr, commandText)) {
-						int idx = atoi(valStr.c_str());
-						dialogText += Common::String::format("%.4d", _indexList[idx]);
+						int idxLocal = atoi(valStr.c_str());
+						dialogText += Common::String::format("%.4d", _indexList[idxLocal]);
 					} else if (commandCheck("NOUN1", valStr, commandText)) {
 						if (!textNoun(dialogText, 1, valStr))
 							dialogText += getVocab(action._activeAction._objectNameId);
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 30a67f9..4142cb4 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -704,7 +704,7 @@ void GameNebular::step() {
 						}
 						break;
 
-					case 2:
+					case FACING_SOUTH:
 						if (randomVal < 500) {
 							for (int count = 0; count < 10; ++count) {
 								_player.addWalker((randomVal < 250) ? 1 : 2, 0);
@@ -722,6 +722,9 @@ void GameNebular::step() {
 							}
 						}
 						break;
+
+					default:
+						break;
 					}
 				}
 			}
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 3d87e9e..d6390dd 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -1298,7 +1298,7 @@ void Scene103::step() {
 	
 	if (_globals._frameTime <= _scene->_frameStartTime) {
 		pt = _vm->_game->_player._playerPos;
-		int dist = _vm->hypotenuse(pt.x - 79, pt.y - 137);
+		dist = _vm->hypotenuse(pt.x - 79, pt.y - 137);
 		_vm->_sound->command(29, (dist * -127 / 378) + 127);
 
 		pt = _vm->_game->_player._playerPos;
diff --git a/engines/mads/rails.cpp b/engines/mads/rails.cpp
index 4daa774..0c179f8 100644
--- a/engines/mads/rails.cpp
+++ b/engines/mads/rails.cpp
@@ -114,7 +114,7 @@ void Rails::setupRouteNode(int *routeIndexP, int nodeIndex, int flags, int route
 		for (int idx = _nodes.size() - 2; idx > 0; --idx) {
 			int nodePos = idx - 1;
 			if (!_nodes[nodePos]._active && ((currentNode._distances[nodePos] & flags) != 0))
-				setupRouteNode(routeIndexP, nodePos, 0x8000, routeLength + distanceVal & 0x3fff);
+				setupRouteNode(routeIndexP, nodePos, 0x8000, routeLength + (distanceVal & 0x3fff));
 		}
 	}
 
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 9824a3e..f4441ca 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -389,7 +389,7 @@ void ScreenObjects::elementHighlighted() {
 	int index;
 	int indexEnd = -1;
 	int var8 = 0;
-	int uiCount;
+	//int uiCount;
 
 	switch (userInterface._category) {
 	case CAT_COMMAND:
@@ -461,7 +461,7 @@ void ScreenObjects::elementHighlighted() {
 		break;
 
 	default:
-		uiCount = size() - _uiCount;
+		//uiCount = size() - _uiCount;
 		index = scene._hotspots.size();
 		indexEnd = index - 1;
 		varA = 0;
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 409dc30..d27f9d2 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -149,7 +149,7 @@ int SequenceList::addTimer(int time, int abortVal) {
 		if (!_entries[seqIndex]._active)
 			break;
 	}
-	assert(seqIndex < (int)_entries.size());
+	assert(seqIndex < _entries.size());
 
 	SequenceEntry &se = _entries[seqIndex];
 	se._active = true;
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index a850c9a..13d5569 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -865,7 +865,6 @@ void UserInterface::updateSelection(ScrCategory category, int newIndex, int *idx
 		*idx = newIndex;
 
 		if (oldIndex >= 0) {
-			Common::Rect bounds;
 			writeVocab(category, oldIndex);
 			
 			if (getBounds(category, oldIndex, bounds))


Commit: 9b0f0b6efec3da058157beb25bab7083328df1da
    https://github.com/scummvm/scummvm/commit/9b0f0b6efec3da058157beb25bab7083328df1da
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-12T16:14:57-04:00

Commit Message:
MADS: Add missing handling code for palette _rgbList

Changed paths:
    engines/mads/animation.cpp
    engines/mads/assets.cpp
    engines/mads/assets.h
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index ddad63c..b79a753 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -322,7 +322,12 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
 		_spriteListIndexes[_header._spritesIndex] = _scene->_sprites.add(sprites);
 	}
 
-	// TODO: List var_420/var_422 population that seems to overwrite other structures?
+	Common::Array<int> usageList;
+	for (int idx = 0; idx < _header._spriteSetsCount; ++idx)
+		usageList.push_back(_spriteSets[idx]->_usageIndex);
+
+	if (usageList.size() > 0 > 0)
+		_vm->_palette->_paletteUsage.updateUsage(usageList, _header._messagesCount);
 
 	if (_header._animMode == 4) {
 		// Remaps the sprite list indexes for frames to the loaded sprite list indexes
diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index 582b80d..3e18a67 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -46,6 +46,11 @@ SpriteAsset::SpriteAsset(MADSEngine *vm, Common::SeekableReadStream *stream, int
 	load(stream, flags);
 }
 
+SpriteAsset::~SpriteAsset() {
+	if (_usageIndex)
+		_vm->_palette->_paletteUsage.resetPalFlags(_usageIndex);
+}
+
 void SpriteAsset::load(Common::SeekableReadStream *stream, int flags) {
 	int curFrame = 0;
 	uint32 frameOffset = 0;
diff --git a/engines/mads/assets.h b/engines/mads/assets.h
index 54417f8..a5d3b3e 100644
--- a/engines/mads/assets.h
+++ b/engines/mads/assets.h
@@ -89,6 +89,11 @@ public:
 	 */
 	SpriteAsset(MADSEngine *vm, Common::SeekableReadStream *stream, int flags);
 
+	/**
+	 * Destructor
+	 */
+	~SpriteAsset();
+
 	int getCount() { return _frameCount; }
 	int getFrameRate() const { return _frameRate; }
 	int getPixelSpeed() const { return _pixelSpeed; }
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 8dfd8f6..0c1819c 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -276,6 +276,21 @@ void PaletteUsage::updateUsage(Common::Array<int> &usageList, int sceneUsageInde
 	_vm->_palette->_rgbList[sceneUsageIndex] = true;
 }
 
+void PaletteUsage::resetPalFlags(int idx) {
+	if (idx >= 0 && idx < 32) {
+		uint32 rgbMask = ~(1 << idx);
+
+		uint32 *flagP = _vm->_palette->_palFlags;
+		for (int i = 0; i < 256; ++i, ++flagP) {
+			*flagP &= rgbMask;
+			if (*flagP == 2)
+				*flagP = 0;
+		}
+
+		_vm->_palette->_rgbList[idx] = 0;
+	}
+}
+
 int PaletteUsage::getGamePalFreeIndex(int *palIndex) {
 	*palIndex = -1;
 	int count = 0;
@@ -330,6 +345,7 @@ Palette::Palette(MADSEngine *vm) : _vm(vm), _paletteUsage(vm) {
 	_lowRange = 0;
 	_highRange = 0;
 	Common::fill(&_mainPalette[0], &_mainPalette[PALETTE_SIZE], 0);
+	Common::fill(&_palFlags[0], &_palFlags[PALETTE_COUNT], 0);
 }
 
 void Palette::setPalette(const byte *colors, uint start, uint num) {
@@ -423,7 +439,7 @@ void Palette::resetGamePalette(int lowRange, int highRange) {
 
 	// Init low range to common RGB values
 	if (lowRange) {
-		Common::fill(&_palFlags[0], &_palFlags[lowRange], 1);
+		Common::fill(&_palFlags[0], &_palFlags[lowRange - 1], 1);
 	}
 
 	// Init high range to common RGB values
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 5ad7e23..9751351 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -127,6 +127,8 @@ public:
 	void transform(Common::Array<RGB6> &palette);
 
 	void updateUsage(Common::Array<int> &usageList, int sceneUsageIndex);
+
+	void resetPalFlags(int idx);
 };
 
 class RGBList {


Commit: d41833e8e587c3cf53c3e3263b32169fb6d1e353
    https://github.com/scummvm/scummvm/commit/d41833e8e587c3cf53c3e3263b32169fb6d1e353
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-12T23:10:54+02:00

Commit Message:
MADS: Implement Palette::refreshHighColors()

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index d6390dd..b3fbedf 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -1569,7 +1569,7 @@ void Scene104::step() {
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
 				_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 0), false);
-				warning("TODO: sub7C8DE()");
+				_vm->_palette->refreshHighColors();
 				_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], mirrorFl, 7, 1, 0, 0);
 				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(198, 143));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
@@ -1599,7 +1599,7 @@ void Scene104::step() {
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
 				_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 1), false);
-				warning("TODO: sub7C8DE()");
+				_vm->_palette->refreshHighColors();
 				_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 1, 0, 0);
 				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(198, 143));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 4);
@@ -1638,7 +1638,7 @@ void Scene104::step() {
 				_game._player._stepEnabled = false;
 				_game._player._visible   = false;
 				_globals._spriteIndexes[4]  = _scene->_sprites.addSprites(formAnimName('a', 2), false);
-				warning("TODO: sub7C8DE()");
+				_vm->_palette->refreshHighColors();
 				_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 8, 1, 0, 0);
 				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(198, 143));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 4);
@@ -1755,8 +1755,7 @@ void Scene105::step() {
 			_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('m', 3), false);
 			_vm->_sound->command(33);
 			_scene->clearSequenceList();
-
-			warning("TODO: sub7C8DE();");
+			_vm->_palette->refreshHighColors();
 
 			_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 6, 1, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[0], 8);
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 0c1819c..157754f 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -524,4 +524,13 @@ void Palette::unlock() {
 	_rgbList[31] = false;
 	_lockFl = false;
 }
+
+void Palette::refreshHighColors() {
+	int val = 18;
+	if (_vm->_game->_scene._animFlag)
+		val += _vm->_game->_scene._animCount;
+
+	setPalette(_mainPalette, val, 256 - val);
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 9751351..728fd09 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -254,6 +254,8 @@ public:
 
 	void lock();
 	void unlock();
+
+	void refreshHighColors();
 };
 
 } // End of namespace MADS


Commit: 41ea3e237459091338e6057c5cc759dd65451c98
    https://github.com/scummvm/scummvm/commit/41ea3e237459091338e6057c5cc759dd65451c98
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-12T17:15:05-04:00

Commit Message:
MADS: Fix misspelling in if statement

Changed paths:
    engines/mads/animation.cpp



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index b79a753..d5b8e21 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -326,7 +326,7 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
 	for (int idx = 0; idx < _header._spriteSetsCount; ++idx)
 		usageList.push_back(_spriteSets[idx]->_usageIndex);
 
-	if (usageList.size() > 0 > 0)
+	if (usageList.size() > 0)
 		_vm->_palette->_paletteUsage.updateUsage(usageList, _header._messagesCount);
 
 	if (_header._animMode == 4) {


Commit: 387e7d800d89c25e6a1a89caa7a915f4575fb47b
    https://github.com/scummvm/scummvm/commit/387e7d800d89c25e6a1a89caa7a915f4575fb47b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-12T17:21:04-04:00

Commit Message:
MADS: Add missing call to new refreshHighColors method

Changed paths:
    engines/mads/animation.cpp



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index d5b8e21..380770f 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -365,6 +365,9 @@ void Animation::startAnimation(int abortTimers) {
 		loadFrame(1);
 	}
 
+	if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE)
+		_vm->_palette->refreshHighColors();
+
 	_currentFrame = 0;
 	_oldFrameEntry = 0;
 	_nextFrameTimer = _vm->_game->_scene._frameStartTime;


Commit: d58d9075da363a8481859236b197a0e6b01b2bfd
    https://github.com/scummvm/scummvm/commit/d58d9075da363a8481859236b197a0e6b01b2bfd
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-12T23:33:21+02:00

Commit Message:
MADS: Initialize a variable in scene 105

Changed paths:
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index 2322406..f150e2f 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -134,7 +134,7 @@ private:
 	bool _explosionFl;
 
 public:
-	Scene105(MADSEngine *vm) : Scene1xx(vm) {}
+	Scene105(MADSEngine *vm) : Scene1xx(vm), _explosionFl(false) {}
 
 	virtual void setup();
 	virtual void enter();


Commit: a2d03dad4c5be915dfbc7a05af85be40d3e749f2
    https://github.com/scummvm/scummvm/commit/a2d03dad4c5be915dfbc7a05af85be40d3e749f2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-12T17:40:26-04:00

Commit Message:
MADS: Fix for sprite animation range

Changed paths:
    engines/mads/sequence.cpp



diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index d27f9d2..c74fe44 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -373,7 +373,7 @@ void SequenceList::setAnimRange(int seqIndex, int startVal, int endVal) {
 	SequenceEntry &seqEntry = _entries[seqIndex];
 	SpriteAsset &spriteSet = *scene._sprites[seqEntry._spritesIndex];
 	int numSprites = spriteSet.getCount();
-	int tempStart = startVal, tempEnd = endVal;
+	int tempStart, tempEnd;
 
 	switch (startVal) {
 	case -2:
@@ -382,6 +382,9 @@ void SequenceList::setAnimRange(int seqIndex, int startVal, int endVal) {
 	case -1:
 		tempStart = 1;
 		break;
+	default:
+		tempStart = startVal;
+		break;
 	}
 
 	switch (endVal) {
@@ -393,14 +396,14 @@ void SequenceList::setAnimRange(int seqIndex, int startVal, int endVal) {
 		tempEnd = 1;
 		break;
 	default:
-		tempEnd = numSprites;
+		tempEnd = endVal;
 		break;
 	}
 
 	seqEntry._frameStart = tempStart;
 	seqEntry._numSprites = tempEnd;
 
-	seqEntry._frameIndex = (seqEntry._frameInc < 0) ? tempStart : tempEnd;
+	seqEntry._frameIndex = (seqEntry._frameInc >= 0) ? tempStart : tempEnd;
 }
 
 void SequenceList::scan() {


Commit: 0e67669001ab1d664b00037c4382cb5e6de56d56
    https://github.com/scummvm/scummvm/commit/0e67669001ab1d664b00037c4382cb5e6de56d56
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-12T17:43:36-04:00

Commit Message:
MADS: Fix sitting down on chair in scene 101

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index b3fbedf..0c752e9 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -356,7 +356,7 @@ void Scene101::actions() {
 				_game._player._stepEnabled = true;
 				_sittingFl = true;
 				_scene->_hotspots.activate(71, false);
-				_chairHotspotId = _scene->_dynamicHotspots.add(71, 0x13F, -1, Common::Rect(159, 84, 33, 36));
+				_chairHotspotId = _scene->_dynamicHotspots.add(71, 0x13F, -1, Common::Rect(159, 84, 159 + 33, 84 + 36));
 				if (!_action.isAction(VERB_LOOK, 0x180)) {
 					_action._inProgress = false;
 					return;


Commit: 85b7a8d019f7ba2246c49b9bb3a713f0388786f8
    https://github.com/scummvm/scummvm/commit/85b7a8d019f7ba2246c49b9bb3a713f0388786f8
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-12T20:52:28-04:00

Commit Message:
MADS: Fix for resetting trigger mode between scenes

Changed paths:
    engines/mads/game.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 9eb2c5c..a665055 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -238,6 +238,7 @@ void Game::sectionLoop() {
 		_priorFrameTimer = _scene._frameStartTime;
 
 		// Call the scene logic for entering the given scene
+		_triggerSetupMode = KERNEL_TRIGGER_DAEMON;
 		_scene._sceneLogic->enter();
 
 		// Set player data


Commit: fc7e91691d73bcc0e58cd89f85597a2c42fd6d57
    https://github.com/scummvm/scummvm/commit/fc7e91691d73bcc0e58cd89f85597a2c42fd6d57
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-12T20:53:10-04:00

Commit Message:
MADS: Added noun constants for walking through doors

Changed paths:
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 357180e..56ea52d 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -90,6 +90,7 @@ enum Noun {
 	NOUN_15F            = 0x15F,
 	NOUN_TIMEBOMB       = 0x171,
 	NOUN_VIEW_SCREEN    = 0x180,
+	NOUN_WALK_THROUGH	= 0x18B,
 	NOUN_CAPTIVE_CREATURE = 0x1C3,
 	NOUN_NATIVE_WOMAN	= 0x1DC,
 	NOUN_ALCOHOL		= 0x310,
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 0c752e9..9d0cf5f 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -1316,7 +1316,7 @@ void Scene103::step() {
 void Scene103::actions() {
 	if (_action._savedFields._lookFlag) {
 		_vm->_dialogs->show(10322);
-	} else if (_action.isAction(395, 110)) {
+	} else if (_action.isAction(NOUN_WALK_THROUGH, NOUN_DOOR)) {
 		switch (_vm->_game->_trigger) {
 		case 0:
 			_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 1);


Commit: f4165c5f8a2a15a6b3cdf1ce46732e2e5efe772a
    https://github.com/scummvm/scummvm/commit/f4165c5f8a2a15a6b3cdf1ce46732e2e5efe772a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-12T22:08:21-04:00

Commit Message:
MADS: Field/method renaming

Changed paths:
    engines/mads/palette.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/sprites.cpp
    engines/mads/sprites.h



diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 157754f..64e0f80 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -527,7 +527,7 @@ void Palette::unlock() {
 
 void Palette::refreshHighColors() {
 	int val = 18;
-	if (_vm->_game->_scene._animFlag)
+	if (_vm->_game->_scene._cyclingActive)
 		val += _vm->_game->_scene._animCount;
 
 	setPalette(_mainPalette, val, 256 - val);
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 92c5ced..1aa1fd7 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -37,7 +37,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 	_currentSceneId = 0;
 	_sceneLogic = nullptr;
 	_sceneInfo = nullptr;
-	_animFlag = false;
+	_cyclingActive = false;
 	_animVal1 = 0;
 	_depthStyle = 0;
 	_roomChanged = false;
@@ -257,7 +257,7 @@ void Scene::initPaletteAnimation(Common::Array<RGB4> &animData, bool animFlag) {
 		_animCount += _animPalData[i].r;
 
 	_animVal1 = (_animCount > 16) ? 3 : 0;
-	_animFlag = animFlag;
+	_cyclingActive = animFlag;
 }
 
 bool Scene::getDepthHighBits(const Common::Point &pt) {
@@ -393,7 +393,7 @@ void Scene::doFrame() {
 	}
 
 	if (_vm->_game->_fx)
-		_animFlag = true;
+		_cyclingActive = true;
 	_vm->_game->_fx = kTransitionNone;
 
 	if (_freeAnimationFlag && _activeAnimation) {
@@ -403,7 +403,7 @@ void Scene::doFrame() {
 }
 
 void  Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
-	// Draw any sprites
+	// Draw any sprite backgrounds
 	_spriteSlots.drawBackground();
 
 	// Set up dirty areas for any text display
@@ -420,8 +420,8 @@ void  Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
 	_textDisplay.setDirtyAreas2();
 	_dirtyAreas.merge(1, DIRTY_AREAS_SIZE);
 
-	// Draw foreground sprites
-	_spriteSlots.drawForeground(&_vm->_screen);
+	// Draw sprites that have changed
+	_spriteSlots.drawSprites(&_vm->_screen);
 
 	// Draw text elements onto the view
 	_textDisplay.draw(&_vm->_screen);
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 4d9a3f8..e00924a 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -106,7 +106,7 @@ public:
 	MSurface _backgroundSurface;
 	DepthSurface _depthSurface;
 	UserInterface _userInterface;
-	bool _animFlag;
+	bool _cyclingActive;
 	int _animVal1;
 	int _animCount;
 	Common::Array<uint32> _animTicksList;
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 0dd640b..83f0143 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -283,7 +283,7 @@ void SpriteSlots::drawBackground() {
 	}
 }
 
-void SpriteSlots::drawForeground(MSurface *s) {
+void SpriteSlots::drawSprites(MSurface *s) {
 	DepthList depthList;
 	Scene &scene = _vm->_game->_scene;
 
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index 962d8c9..745e070 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -192,7 +192,7 @@ public:
 	/**
 	* Draw any sprites into the foreground of the scene
 	*/
-	void drawForeground(MSurface *s);
+	void drawSprites(MSurface *s);
 
 	void cleanUp();
 };


Commit: 38336886741dc9d980270cfbaae82805e7e4b046
    https://github.com/scummvm/scummvm/commit/38336886741dc9d980270cfbaae82805e7e4b046
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-13T11:27:07+02:00

Commit Message:
MADS: Implement scene 106

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index f9d23be..cd23370 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -57,6 +57,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene104(vm);
 	case 105:
 		return new Scene105(vm);
+	case 106:
+		return new Scene106(vm);
 
 	// Scene group #2
 	case 201:
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 9d0cf5f..8871032 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -11,7 +11,7 @@
 
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
 
  * You should have received a copy of the GNU General Public License
@@ -1338,10 +1338,8 @@ void Scene103::actions() {
 		switch (_vm->_game->_trigger) {
 		case 0:
 			_scene->changeVariant(1);
-			_globals._sequenceIndexes[13] = _scene->_sequences.startReverseCycle(
-				_globals._spriteIndexes[13], false, 3, 2);
+			_globals._sequenceIndexes[13] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[13], false, 3, 2);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[13]);
-
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SM_FRAME_INDEX, 7, 1);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SM_0, 0, 2);
 			_vm->_game->_player._visible = false;
@@ -1370,10 +1368,8 @@ void Scene103::actions() {
 		switch (_vm->_game->_trigger) {
 		case 0:
 			_scene->changeVariant(1);
-			_globals._sequenceIndexes[12] = _scene->_sequences.startReverseCycle(
-				_globals._spriteIndexes[12], false, 3, 2);
+			_globals._sequenceIndexes[12] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[12], false, 3, 2);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[12]);
-
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SM_FRAME_INDEX, 6, 1);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SM_0, 0, 2);
 			_vm->_game->_player._visible = false;
@@ -1523,8 +1519,8 @@ void Scene104::setup() {
 }
 
 void Scene104::enter() {
-	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('h', -1), false);
-	_globals._sequenceIndexes[1]  = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 14, 0, 0, 1);
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('h', -1));
+	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 14, 0, 0, 1);
 
 	if (_scene->_priorSceneId == 105)
 		_game._player._playerPos = Common::Point(302, 107);
@@ -1568,7 +1564,7 @@ void Scene104::step() {
 				_scene->resetScene();
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
-				_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 0), false);
+				_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 0));
 				_vm->_palette->refreshHighColors();
 				_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], mirrorFl, 7, 1, 0, 0);
 				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(198, 143));
@@ -1598,7 +1594,7 @@ void Scene104::step() {
 				_scene->resetScene();
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
-				_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 1), false);
+				_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 1));
 				_vm->_palette->refreshHighColors();
 				_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 1, 0, 0);
 				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(198, 143));
@@ -1636,8 +1632,8 @@ void Scene104::step() {
 				_scene->_activeAnimation->free();
 				_scene->resetScene();
 				_game._player._stepEnabled = false;
-				_game._player._visible   = false;
-				_globals._spriteIndexes[4]  = _scene->_sprites.addSprites(formAnimName('a', 2), false);
+				_game._player._visible = false;
+				_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('a', 2));
 				_vm->_palette->refreshHighColors();
 				_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 8, 1, 0, 0);
 				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(198, 143));
@@ -1717,8 +1713,8 @@ void Scene105::setup() {
 }
 
 void Scene105::enter() {
-	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('m', 1), false);
-	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('f', 4), false);
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('m', 1));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('f', 4));
 	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 0, 0, 0);
 
 	if (_globals[kFishIn105]) {
@@ -1748,11 +1744,11 @@ void Scene105::step() {
 			_scene->_kernelMessages.reset();
 			_scene->resetScene();
 			_game._player._stepEnabled = false;
-			_game._player._visible   = false;
+			_game._player._visible = false;
 
-			_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('m', 0), false);
-			_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('m', 2), false);
-			_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('m', 3), false);
+			_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('m', 0));
+			_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('m', 2));
+			_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('m', 3));
 			_vm->_sound->command(33);
 			_scene->clearSequenceList();
 			_vm->_palette->refreshHighColors();
@@ -1856,5 +1852,212 @@ void Scene105::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene106::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+
+	if ((_scene->_priorSceneId == 102) && !_game._objects.isInInventory(OBJ_REBREATHER) && !_scene->_roomChanged)
+		_game._player._spritesPrefix = "";
+
+	_vm->_dialogs->_defaultPosition.y = 100;
+}
+
+void Scene106::enter() {
+	_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('H', -1));
+
+	if (_game._objects.isInInventory(OBJ_REBREATHER) || (_scene->_priorSceneId != 102) || _scene->_roomChanged) {
+		_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('A', 0));
+		_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('A', 1));
+	}
+
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('G', -1));
+	_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 21, 0, 0, 0);
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('I', -1));
+	_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6, 0, 32, 47);
+
+	if (_scene->_priorSceneId == 102) {
+		_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 6, 1, 4, 0);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SM_0, 0, 70);
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+		_game._player._facing = FACING_EAST;
+		_game._player._playerPos = Common::Point(106, 69);
+	} else if (_scene->_priorSceneId != -2) {
+		if (_scene->_priorSceneId == 107) {
+			_game._player._playerPos = Common::Point(319, 84);
+			_game._player._facing = _game._player._prepareWalkFacing = FACING_WEST;
+		} else {
+			_game._player._playerPos = Common::Point(319, 44);
+			_game._player._facing = _game._player._prepareWalkFacing = FACING_SOUTHWEST;
+			_scene->_sprites[_game._player._spritesStart + 3]->_charInfo->_velocity = 24;
+		}
+
+		_game._player._prepareWalkPos = Common::Point(246, 69);
+		_game._player._needToWalk = true;
+		_game._player._readyToWalk = true;
+	}
+
+	if (_scene->_priorSceneId != 102) {
+		_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 6, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], -2, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14);
+	}
+
+	_backToShipFl = false;
+	_shadowFl = false;
+	_firstEmergingFl = false;
+
+	_game.loadQuoteSet(0x31, 0x32, 0x34, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0);
+	sceneEntrySound();
+}
+
+void Scene106::step() {
+	if (_game._trigger == 70) {
+		_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 6, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], -2, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[0], 14);
+
+		if (!_game._objects.isInInventory(OBJ_REBREATHER) && !_scene->_roomChanged) {
+			_scene->loadAnimation(Resources::formatName(106, 'A', -1, EXT_AA, ""), 75);
+		} else {
+			_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 4, 1, 0, 0);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SM_FRAME_INDEX, 28, 71);
+		}
+	}
+
+	if (_game._trigger == 71) {
+		_game._player._prepareWalkPos = Common::Point(246, 69);
+		_game._player._prepareWalkFacing = FACING_EAST;
+		_game._player._needToWalk = true;
+		_game._player._readyToWalk = true;
+		_game._player._visible = true;
+
+		if (_game._visitedScenes._sceneRevisited) {
+			_game._player._stepEnabled = true;
+		} else {
+			_game._player._prepareWalkFacing = FACING_SOUTHWEST;
+			_firstEmergingFl = true;
+			_scene->loadAnimation(Resources::formatName(106, 'B', -1, EXT_AA, ""), 80);
+		}
+	}
+
+	if (_firstEmergingFl && (_scene->_activeAnimation->getCurrentFrame() >= 19)) {
+		_firstEmergingFl = false;
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(52));
+	}
+
+	if ((_game._trigger >= 80) && (_game._trigger <= 87)) {
+		int tmpVal = _game._trigger - 80;
+		int msgId = -1;
+		switch (tmpVal) {
+		case 0:
+			_msgPosY = 26;
+			msgId = 49;
+			break;
+
+		case 1:
+		case 2:
+		case 3:
+		case 4:
+		case 5:
+			msgId = 76 + tmpVal;
+			break;
+
+		case 6:
+			msgId = 50;
+			break;
+
+		default:
+			msgId = -1;
+			_game._player._stepEnabled = true;
+			break;
+		}
+
+		if (msgId >= 0) {
+			int nextAbortVal = _game._trigger + 1;
+			_scene->_kernelMessages.add(Common::Point(15, _msgPosY), 0x1110, 0, 0, 360, _game.getQuote(msgId));
+			_scene->_sequences.addTimer(150, nextAbortVal);
+			_msgPosY += 14;
+		}
+	}
+
+	if (_backToShipFl) {
+		if (!_shadowFl) {
+			if (_game._player._playerPos.x < 204) {
+				_shadowFl = true;
+				_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 4, 1, 0, 0);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 72);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_FRAME_INDEX, 44, 73);
+			}
+		} else if (_game._trigger == 73)
+				_game._player._visible = false;
+		else if (_game._trigger == 72)
+				_scene->_sequences.addTimer(24, 74);
+		else if (_game._trigger == 74)
+				_scene->_nextSceneId = 102;
+	}
+
+	if (_game._trigger == 75) {
+		_game._visitedScenes.pop_back();
+		_scene->_nextSceneId = 102;
+	}
+}
+
+void Scene106::preActions() {
+	if (_action.isAction(0x15D, 0x12E) || _action.isAction(0x15D, 0x130)) {
+		_game._player._stepEnabled = false;
+		_scene->_sprites[_game._player._spritesStart + 1]->_charInfo->_velocity = 24;
+		_game._player._walkOffScreenSceneId = 104;
+	}
+
+	if (_action.isAction(0x15D, 0xF3))
+		_game._player._walkOffScreenSceneId = 107;
+}
+
+void Scene106::actions() {
+	if (_action._lookFlag)
+		_vm->_dialogs->show(0x2976);
+	else if (_action.isAction(0x15C, 0xD9)) {
+		_game._player._stepEnabled = false;
+		_game._player._prepareWalkPos = Common::Point(95, 72);
+		_game._player._prepareWalkFacing = FACING_WEST;
+		_game._player._needToWalk = true;
+		_game._player._readyToWalk = true;
+		_game._player._frameNumber = 9;
+		_backToShipFl = true;
+	} else if (_action.isAction(VERB_LOOK, 0x13) || _action.isAction(0xD1, 0x13))
+		_vm->_dialogs->show(0x2969);
+	else if (_action.isAction(VERB_TAKE, 0x13))
+		_vm->_dialogs->show(0x296A);
+	else if (_action.isAction(VERB_LOOK, 0x12F) || _action.isAction(VERB_LOOK, 0x130))
+		_vm->_dialogs->show(0x296B);
+	else if (_action.isAction(VERB_TAKE, 0x12F) || _action.isAction(VERB_TAKE, 0x130))
+		_vm->_dialogs->show(0x296C);
+	else if (_action.isAction(VERB_LOOK, 0xF3))
+		_vm->_dialogs->show(0x296D);
+	else if (_action.isAction(VERB_LOOK, 0x109) || _action.isAction(0xD1, 0x109))
+		_vm->_dialogs->show(0x296E);
+	else if (_action.isAction(0x109) && (_action.isAction(VERB_PUSH) || _action.isAction(VERB_PULL) || _action.isAction(VERB_TAKE)))
+		_vm->_dialogs->show(0x296F);
+	else if (_action.isAction(VERB_LOOK, 0x139) || _action.isAction(0xD1, 0x139))
+		_vm->_dialogs->show(0x2970);
+	else if (_action.isAction(VERB_LOOK, 0xD9))
+		_vm->_dialogs->show(0x2971);
+	else if (_action.isAction(VERB_OPEN, 0xD9))
+		_vm->_dialogs->show(0x2972);
+	else if (_action.isAction(VERB_CLOSE, 0xD9))
+		_vm->_dialogs->show(0x2973);
+	else if (_action.isAction(VERB_LOOK, 0x12E))
+		_vm->_dialogs->show(0x2974);
+	else if (_action.isAction(VERB_LOOK, 0xF0))
+		_vm->_dialogs->show(0x2975);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index f150e2f..ef6dc3c 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -144,6 +144,25 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene106 : public Scene1xx {
+private:
+	bool _backToShipFl;
+	bool _shadowFl;
+	bool _firstEmergingFl;
+
+	int _msgPosY;
+
+public:
+	Scene106(MADSEngine *vm) : Scene1xx(vm), _backToShipFl(false), _shadowFl(false), _firstEmergingFl(false), _msgPosY(0) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 7a6163584c103985766057a7613e597b0b2debc9
    https://github.com/scummvm/scummvm/commit/7a6163584c103985766057a7613e597b0b2debc9
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-13T23:46:59+02:00

Commit Message:
MADS: Implement scene 107

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index cd23370..64852c6 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -59,6 +59,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene105(vm);
 	case 106:
 		return new Scene106(vm);
+	case 107:
+		return new Scene107(vm);
 
 	// Scene group #2
 	case 201:
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 8871032..418ed1a 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -2059,5 +2059,117 @@ void Scene106::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene107::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+
+	_scene->addActiveVocab(0xDA);
+}
+
+void Scene107::enter() {
+	for (int i = 0; i < 3; i++)
+		_globals._spriteIndexes[i + 1] = _scene->_sprites.addSprites(formAnimName('G', i));
+
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(Resources::formatName(105, 'f', 4, EXT_SS, ""));
+
+	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 14, 0, 0, 7);
+	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 17, 0, 0, 13);
+	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 19, 0, 0, 9);
+
+	for (int i = 1; i < 4; i++)
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[i], 0);
+
+	if (_globals[kFishIn107]) {
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6, 0, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(68, 151));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
+		int idx = _scene->_dynamicHotspots.add(101, 348, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(78, 135), FACING_SOUTHWEST);
+	}
+
+	if (_scene->_priorSceneId == 105)
+		_game._player._playerPos = Common::Point(132, 47);
+	else if (_scene->_priorSceneId == 106)
+		_game._player._playerPos = Common::Point(20, 91);
+	else if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(223, 151);
+
+	if (((_scene->_priorSceneId == 105) || (_scene->_priorSceneId == 106)) && (_vm->getRandomNumber(1, 3) == 1)) {
+		_globals._spriteIndexes[0] = _scene->_sprites.addSprites(Resources::formatName(105, 'R', 1, EXT_SS, ""));
+		_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], true, 4, 0, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[0], Common::Point(270, 150));
+		_scene->_sequences.sub70C52(_globals._sequenceIndexes[0], SM_FRAME_INDEX, -200, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[0], 2);
+		_scene->_dynamicHotspots.add(218, 348, _globals._sequenceIndexes[0], Common::Rect(0, 0, 0, 0));
+	}
+
+	_game.loadQuoteSet(0x4A, 0x4B, 0x4C, 0x35, 0x34, 0);
+	_shootingFl = false;
+
+	if (_vm->getRandomNumber(1, 3) == 1) {
+		_scene->loadAnimation(Resources::formatName(107, 'B', -1, EXT_AA, ""), 0);
+		_shootingFl = true;
+	}
+
+	sceneEntrySound();
+}
+
+void Scene107::step() {
+	if (_shootingFl && (_scene->_activeAnimation->getCurrentFrame() >= 19)) {
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(52));
+		_shootingFl = false;
+	}
+}
+
+void Scene107::preActions() {
+	if (_action.isAction(0x15D, 0xF6))
+		_game._player._walkOffScreenSceneId = 106;
+
+	if (_action.isAction(0x15D, 0xF5))
+		_game._player._walkOffScreenSceneId = 108;
+}
+
+void Scene107::actions() {
+	if (_action._lookFlag)
+		_vm->_dialogs->show(0x29D4);
+	else if (_action.isAction(VERB_TAKE, 0x65) && _globals[kFishIn107]) {
+		if (_game._objects.isInInventory(OBJ_DEAD_FISH)) {
+			int randVal = _vm->getRandomNumber(74, 76);
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(randVal));
+		} else {
+			_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+			_game._objects.addToInventory(OBJ_DEAD_FISH);
+			_globals[kFishIn107] = false;
+			_vm->_dialogs->showPicture(OBJ_DEAD_FISH, 0x322);
+		}
+	} else if (_action.isAction(0x15D, 0xEE))
+		_scene->_nextSceneId = 105;
+	else if (_action.isAction(VERB_LOOK, 0xEE))
+		_vm->_dialogs->show(0x29CD);
+	else if (_action.isAction(VERB_LOOK, 0x65) && (_action._mainObjectSource == 4))
+		_vm->_dialogs->show(0x29CE);
+	else if (_action.isAction(VERB_LOOK, 0x38))
+		_vm->_dialogs->show(0x29CF);
+	else if (_action.isAction(VERB_LOOK, 0x128))
+		_vm->_dialogs->show(0x29D0);
+	else if (_action.isAction(VERB_LOOK, 0x12F))
+		_vm->_dialogs->show(0x29D1);
+	else if (_action.isAction(VERB_LOOK, 0xF5))
+		_vm->_dialogs->show(0x29D2);
+	else if (_action.isAction(VERB_LOOK, 0x4D))
+		_vm->_dialogs->show(0x29D3);
+	else if (_action.isAction(VERB_LOOK, 0xDA))
+		_vm->_dialogs->show(0x29D5);
+	else if (_action.isAction(VERB_TAKE, 0xDA))
+		_vm->_dialogs->show(0x29D6);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index ef6dc3c..1aa9f3d 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -163,6 +163,21 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene107 : public Scene1xx {
+private:
+	bool _shootingFl;
+
+public:
+	Scene107(MADSEngine *vm) : Scene1xx(vm), _shootingFl(false) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 5ee4123947cde518cff48030d889afe188a04f2f
    https://github.com/scummvm/scummvm/commit/5ee4123947cde518cff48030d889afe188a04f2f
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-14T00:34:56+02:00

Commit Message:
MADS: Implement scene 108

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 64852c6..55194b7 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -61,6 +61,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene106(vm);
 	case 107:
 		return new Scene107(vm);
+	case 108:
+		return new Scene108(vm);
 
 	// Scene group #2
 	case 201:
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 418ed1a..2aeb14d 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -2171,5 +2171,93 @@ void Scene107::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene108::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene108::enter() {
+	if (_globals[kHoovicSated] == 2)
+		_globals[kHoovicSated] = 0;
+
+	_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('X', 0));
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('X', 1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('X', 2));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('X', 3));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(Resources::formatName(105, 'f', 4, EXT_SS, ""));
+
+	_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 13, 0, 0, 7);
+	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 16, 0, 0, 9);
+	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 17, 0, 0, 3);
+	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 14, 0, 0, 13);
+
+	for (int i = 0; i <= 3; i++)
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[i], 0);
+
+	if (_globals[kFishIn108]) {
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6, 0, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(41, 109));
+		int idx = _scene->_dynamicHotspots.add(101, 348, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(41, 109), FACING_NORTHWEST);
+	}
+
+	if (_scene->_priorSceneId == 107)
+		_game._player._playerPos = Common::Point(138, 58);
+	else if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(305, 98);
+
+	_game.loadQuoteSet(0x4A, 0x4B, 0x4C, 0x35, 0x34, 0);
+	sceneEntrySound();
+}
+
+void Scene108::preActions() {
+	if (_action.isAction(0x15E, 0xFB))
+		_game._player._walkOffScreenSceneId = 109;
+}
+
+void Scene108::actions() {
+	if (_action._lookFlag)
+		_vm->_dialogs->show(0x2A3C);
+	else if (_action.isAction(VERB_TAKE, 0x65) && _globals[kFishIn108]) {
+		if (_game._objects.isInInventory(OBJ_DEAD_FISH)) {
+			int randVal = _vm->getRandomNumber(74, 76);
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(randVal));
+		} else {
+			_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+			_game._objects.addToInventory(OBJ_DEAD_FISH);
+			_globals[kFishIn108] = false;
+			_vm->_dialogs->showPicture(OBJ_DEAD_FISH, 0x2A38); 
+		}
+	} else if (_action.isAction(0x15D, 0xF4))
+		_scene->_nextSceneId = 107;
+	else if (_action.isAction(VERB_LOOK, 0x4D))
+		_vm->_dialogs->show(0x2A31);
+	else if (_action.isAction(VERB_LOOK, 0xF0))
+		_vm->_dialogs->show(0x2A32);
+	else if (_action.isAction(VERB_LOOK, 0xF1))
+		_vm->_dialogs->show(0x2A33);
+	else if (_action.isAction(VERB_TAKE, 0xF1))
+		_vm->_dialogs->show(0x2A34);
+	else if (_action.isAction(VERB_LOOK, 0x129))
+		_vm->_dialogs->show(0x2A35);
+	else if (_action.isAction(VERB_TAKE, 0x129))
+		_vm->_dialogs->show(0x2A36);
+	else if (_action.isAction(VERB_LOOK, 0x65))
+		_vm->_dialogs->show(0x2A37);
+	else if (_action.isAction(VERB_LOOK, 0xFB))
+		_vm->_dialogs->show(0x2A39);
+	else if (_action.isAction(VERB_LOOK, 0xF4))
+		_vm->_dialogs->show(0x2A3A);
+	else if (_action.isAction(VERB_LOOK, 0x158))
+		_vm->_dialogs->show(0x2A3B);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index 1aa9f3d..6d28252 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -178,6 +178,18 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene108 : public Scene1xx {
+public:
+	Scene108(MADSEngine *vm) : Scene1xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 3e1bbb724d271623ceb55a3b56d42e80ca2087f2
    https://github.com/scummvm/scummvm/commit/3e1bbb724d271623ceb55a3b56d42e80ca2087f2
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-14T21:52:31+02:00

Commit Message:
MADS: Fix a big in scene 102, implement scene 109

Changed paths:
    engines/mads/messages.h
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/messages.h b/engines/mads/messages.h
index 4778efd..7aabf91 100644
--- a/engines/mads/messages.h
+++ b/engines/mads/messages.h
@@ -67,8 +67,8 @@ public:
 class KernelMessages {
 private:
 	MADSEngine *_vm;
-	Common::Array<KernelMessage> _entries;
 public:
+	Common::Array<KernelMessage> _entries;
 	Font *_talkFont;
 	KernelMessages(MADSEngine *vm);
 	~KernelMessages();
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 55194b7..50c4b94 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -63,6 +63,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene107(vm);
 	case 108:
 		return new Scene108(vm);
+	case 109:
+		return new Scene109(vm);
 
 	// Scene group #2
 	case 201:
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 2aeb14d..5e2ed3d 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -631,10 +631,10 @@ void Scene102::enter() {
 	_globals._spriteIndexes[11] = _scene->_sprites.addSprites("*RXMRC_8");
 	_globals._spriteIndexes[13] = _scene->_sprites.addSprites(formAnimName('x', 0));
 
-	_globals._spriteIndexes[15+1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 8, 0, 0, 0);
-	_globals._spriteIndexes[15+2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 170, 0, 1, 6);
-	_globals._spriteIndexes[15+3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 11, 0, 2, 3);
-	_globals._spriteIndexes[15+4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 4, 0, 1, 0);
+	_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 8, 0, 0, 0);
+	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 170, 0, 1, 6);
+	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 11, 0, 2, 3);
+	_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 4, 0, 1, 0);
 	_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 3, 0, 0, 5);
 
 	if (!_game._objects.isInRoom(OBJ_BINOCULARS))
@@ -1128,7 +1128,7 @@ void Scene102::actions() {
 
 		case 1:
 			_game._objects.addToInventory(OBJ_BINOCULARS);
-			_scene->_sequences.remove(_globals._spriteIndexes[15+9]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[9]);
 			_scene->_hotspots.activate(0x27, false);
 			_game._player._visible = true;
 			_game._player._stepEnabled = true;
@@ -1819,7 +1819,7 @@ void Scene105::actions() {
 			_scene->_kernelMessages.reset();
 			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(randVal));
 		} else {
-			_scene->_sequences.remove (_globals._sequenceIndexes[4]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 			_game._objects.addToInventory(OBJ_DEAD_FISH);
 			_globals[kFishIn105] = false;
 			_vm->_dialogs->showPicture(OBJ_DEAD_FISH, 0x322, 0);
@@ -2258,6 +2258,407 @@ void Scene108::actions() {
 }
 
 /*------------------------------------------------------------------------*/
+Scene109::Scene109(MADSEngine *vm) : Scene1xx(vm) {
+	_rexThrowingObject = false;
+	_hoovicDifficultFl = false;
+	_beforeEatingRex = false;
+	_eatingRex = false;
+	_hungryFl = false;
+	_eatingFirstFish = false;
+
+	_throwingObjectId = -1;
+	_hoovicTrigger = 0;
+}
+
+void Scene109::setup() {
+	_scene->addActiveVocab(0x66);
+	_scene->addActiveVocab(0xE5);
+
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene109::enter() {
+	_globals[kFishIn105] = true;
+
+	_globals._spriteIndexes[0] = _scene->_sprites.addSprites("*RXSWRC_6");
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('O', 1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('O', 2));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('O', 0));
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('H', 4));
+
+	_rexThrowingObject = false;
+	_throwingObjectId = 0;
+	_beforeEatingRex = false;
+	_eatingRex = false;
+	_hungryFl = false;
+
+	if (_scene->_priorSceneId == 110) {
+		_game._player._playerPos = Common::Point(248, 38);
+		_globals[kHoovicSated] = 2;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(20, 68);
+		_game._player._facing = FACING_EAST;
+	}
+
+	if (!_globals[kHoovicAlive]) {
+		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 4);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], -2, -2);
+
+		int idx = _scene->_dynamicHotspots.add(102, 348, -1, Common::Rect(256, 57, 267, 87));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(241, 91), FACING_NORTHEAST);
+		idx = _scene->_dynamicHotspots.add(102, 348, -1, Common::Rect(242, 79, 265, 90));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(241, 91), FACING_NORTHEAST);
+		idx = _scene->_dynamicHotspots.add(229, 348, -1, Common::Rect(231, 88, 253, 94));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(241, 91), FACING_NORTHEAST);
+	}
+
+	if (!_globals[kHoovicAlive] || _globals[kHoovicSated])
+		_scene->changeVariant(1);
+
+	if (_game._objects.isInRoom(OBJ_BURGER)) {
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -2, -2);
+		int idx = _scene->_dynamicHotspots.add(53, 348, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(-3, 0), FACING_NORTHEAST);
+	} else if (_scene->_roomChanged)
+		_game._objects.addToInventory(OBJ_BURGER);
+
+	if (_scene->_roomChanged) {
+		_game._objects.addToInventory(OBJ_DEAD_FISH);
+		_game._objects.addToInventory(OBJ_STUFFED_FISH);
+	}
+
+	_vm->_palette->setEntry(252, 50, 50, 63);
+	_vm->_palette->setEntry(253, 30, 30, 50);
+
+	_game.loadQuoteSet(0x53, 0x52, 0x54, 0x55, 0x56, 0x57, 0x58, 0);
+	_eatingFirstFish = (!_game._visitedScenes._sceneRevisited) && (_scene->_priorSceneId < 110);
+
+	if (_eatingFirstFish) {
+		_globals._spriteIndexes[10] = _scene->_sprites.addSprites(Resources::formatName(105, 'F', 1, EXT_SS, ""));
+		_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('H', 1));
+
+		_globals._sequenceIndexes[10] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[10], true, 4, 0, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 5);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(126, 39));
+		_scene->_sequences.sub70C52(_globals._sequenceIndexes[10], 0, 200, 0);
+		_scene->_sequences.setScale(_globals._sequenceIndexes[10], 80);
+		_game._player._stepEnabled = false;
+	}
+
+	sceneEntrySound();
+}
+
+void Scene109::step() {
+	if (_beforeEatingRex) {
+		if (!_eatingRex) {
+			if (_game._player._playerPos.x > 205) {
+				_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6, 1, 0, 0);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 4);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_FRAME_INDEX, 6, 70);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 71);
+
+				_eatingRex = true;
+				_vm->_sound->command(34);
+			}
+		} else {
+			switch (_game._trigger) {
+			case 70:
+				_game._player._visible = false;
+				break;
+
+			case 71:
+				_scene->_reloadSceneFlag = true;
+				break;
+			}
+		}
+	}
+
+	if (_hungryFl && (_game._player._playerPos == Common::Point(160, 32)) && (_game._player._facing == FACING_EAST)) {
+		_game._player.walk(Common::Point(226, 24), FACING_EAST);
+		_game._player._stepEnabled = false;
+		_hungryFl = false;
+		_beforeEatingRex = true;
+		_scene->_sprites.remove(_globals._spriteIndexes[6]);
+		_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('H', 0));
+		_vm->_palette->refreshHighColors();
+	}
+
+	if (_game._player._moving && (_scene->_rails.getNext() > 0) && _globals[kHoovicAlive] && !_globals[kHoovicSated] && !_hungryFl && !_beforeEatingRex) {
+		_game._player.cancelCommand();
+		_game._player.startWalking(Common::Point(160, 32), FACING_EAST);
+		_scene->_rails.resetNext();
+		_hungryFl = true;
+	}
+
+	if (_eatingFirstFish && (_scene->_sequences[_globals._sequenceIndexes[10]]._msgPos.x >= 178)) {
+		_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 4, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 4);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SM_FRAME_INDEX, 29, 72);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SM_0, 29, 73);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[10], _globals._sequenceIndexes[9]);
+		_eatingFirstFish = false;
+		_game._player._stepEnabled = true;
+		_vm->_sound->command(34);
+	}
+
+	if (_game._trigger == 72)
+		_scene->_sequences.remove(_globals._sequenceIndexes[10]);
+
+	if (_game._trigger == 73) {
+		_scene->_sequences.remove(_globals._sequenceIndexes[9]);
+		_scene->_sprites.remove(_globals._spriteIndexes[9]);
+		_scene->_sprites.remove(_globals._spriteIndexes[10]);
+
+		_scene->_spriteSlots.clear();
+		_scene->_spriteSlots.fullRefresh();
+
+		int randVal = _vm->getRandomNumber(85, 88);
+		int idx = _scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(randVal));
+		_scene->_kernelMessages.setQuoted(idx, 4, true);
+		_scene->_kernelMessages._entries[idx]._frameTimer = _scene->_frameStartTime + 4;
+	}
+}
+
+void Scene109::preActions() {
+	if (_action.isAction(0x15E, 0xFC))
+		_game._player._walkOffScreenSceneId = 108;
+
+	if ((_action.isAction(VERB_THROW) || _action.isAction(VERB_GIVE) || _action.isAction(VERB_PUT))
+	&& (_action.isAction(0x146) || _action.isAction(0x178))
+	&& (_action.isAction(0x65) || _action.isAction(0x157) || _action.isAction(0x35))) {
+		int idx = _game._objects.getIdFromDesc(_action._activeAction._objectNameId);
+		if ((idx >= 0) && _game._objects.isInInventory(idx)) {
+			_game._player._prepareWalkPos = Common::Point(106, 38);
+			_game._player._prepareWalkFacing = FACING_EAST;
+			_game._player._needToWalk = true;
+			_game._player._readyToWalk = true;
+		}
+	}
+
+	if ((_action.isAction(0x15A, 0x178) || _action.isAction(0x15C, 0x146))
+	&& (!_globals[kHoovicAlive] || _globals[kHoovicSated]) && (_action.isAction(0x178)))
+		_game._player._walkOffScreenSceneId = 110;
+
+	_hungryFl = false;
+}
+
+void Scene109::actions() {
+	if (_action._lookFlag) {
+		_vm->_dialogs->show(0x2AA0);
+		_action._inProgress = false;
+		return;
+	}
+
+	if ((_action.isAction(VERB_THROW) || _action.isAction(VERB_GIVE)) && ((_action.isAction(0x146) || _action.isAction(0x178)))) {
+		if (_action.isAction(0x65) || _action.isAction(0x157) || _action.isAction(0x35)) {
+			_throwingObjectId = _game._objects.getIdFromDesc(_action._activeAction._objectNameId);
+			if (_throwingObjectId >= 0) {
+				if ((_game._objects.isInInventory(_throwingObjectId) && _globals[kHoovicAlive]) || _rexThrowingObject) {
+					switch (_game._trigger) {
+					case 0:
+						_rexThrowingObject = true;
+						_hoovicDifficultFl = false;
+						_game._objects.setRoom(_throwingObjectId, NOWHERE);
+						_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 4, 1, 0, 0);
+						_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[0]);
+						_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SM_0, 0, 1);
+						_game._player._visible = false;
+						_game._player._stepEnabled = false;
+
+						switch (_throwingObjectId) {
+						case OBJ_DEAD_FISH:
+						case OBJ_STUFFED_FISH:
+							_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('H', 1));
+							break;
+
+						case OBJ_BURGER:
+							_hoovicDifficultFl = (_game._difficulty == DIFFICULTY_IMPOSSIBLE);
+							_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('H', (_hoovicDifficultFl ? 3 : 1)));
+							break;
+						}
+
+						_vm->_palette->refreshHighColors();
+						break;
+
+					case 1:
+						_game._player._visible = true;
+						_hoovicTrigger = 4;
+						switch (_throwingObjectId) {
+						case OBJ_BURGER:
+							_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, (_hoovicDifficultFl ? 4 : 6), 1, 0, 0);
+							_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_FRAME_INDEX, 2, 2);
+							if (_hoovicDifficultFl) {
+								_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 30);
+								_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 5);
+							} else {
+								_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 4);
+								_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 8);
+								_hoovicTrigger = 3;
+							}
+							break;
+						case OBJ_DEAD_FISH:
+							_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 4, 1, 0, 0);
+							_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SM_FRAME_INDEX, 2, 2);
+							break;
+						case OBJ_STUFFED_FISH:
+							_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 4, 1, 0, 0);
+							_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_FRAME_INDEX, 2, 2);
+							_hoovicTrigger = 3;
+							break;
+						}
+						break;
+
+					case 2:
+						if (_hoovicDifficultFl)
+							_globals._sequenceIndexes[8] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[8], false, 4, 2, 0, 0);
+						else
+							_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 4, 1, 0, 0);
+
+						_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 4);
+						_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, _hoovicTrigger);
+						_vm->_sound->command(34);
+						break;
+
+					case 3:
+						_scene->loadAnimation(Resources::formatName(109, 'H', 2, EXT_AA, ""), 4);
+						_vm->_sound->command(35);
+						_globals[kHoovicAlive] = false;
+						break;
+
+					case 4:
+						if (!_globals[kHoovicAlive]) {
+							_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 1, 0, 0);
+							_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 4);
+							_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], -2, -2);
+							int idx = _scene->_dynamicHotspots.add(102, 348, -1, Common::Rect(256, 57, 12, 31));
+							_scene->_dynamicHotspots.setPosition(idx, Common::Point(241, 91), FACING_NORTHEAST);
+							idx = _scene->_dynamicHotspots.add(102, 348, -1, Common::Rect(242, 79, 24, 12));
+							_scene->_dynamicHotspots.setPosition(idx, Common::Point(241, 91), FACING_NORTHEAST);
+							idx = _scene->_dynamicHotspots.add(229, 348, -1, Common::Rect(231, 88, 23, 7));
+							_scene->_dynamicHotspots.setPosition(idx, Common::Point(241, 91), FACING_NORTHEAST);
+							_scene->changeVariant(1);
+						} else {
+							if (_throwingObjectId == OBJ_DEAD_FISH) {
+								++_globals[kHoovicFishEaten];
+								int threshold;
+								switch (_game._difficulty) {
+								case DIFFICULTY_HARD:
+									threshold = 1;
+									break;
+								case DIFFICULTY_REALLY_HARD:
+									threshold = 3;
+									break;
+								default:
+									threshold = 50;
+									break;
+								}
+								
+								if (_globals[kHoovicFishEaten] >= threshold) {
+									int randVal = _vm->getRandomNumber(83, 84);
+									_scene->_kernelMessages.add(Common::Point(230, 24), 0xFDFC, 0, 0, 120, _game.getQuote(randVal));
+									_globals[kHoovicFishEaten] = 0;
+									_globals[kHoovicSated] = 1;
+									_scene->changeVariant(1);
+								}
+							}
+						}
+						_scene->_activeAnimation->free();
+						_scene->_sequences.remove(_globals._sequenceIndexes[8]);
+						_scene->_sprites.remove(_globals._spriteIndexes[8]);
+						_scene->_spriteSlots.clear();
+						_scene->_spriteSlots.fullRefresh();
+						_scene->_sequences.scan();
+						if (_game._player._visible) {
+							_game._player._spritesChanged = true;
+							_game._player.update();
+						}
+
+						_game._player._stepEnabled = true;
+						_rexThrowingObject = false;
+						break;
+
+					case 5: {
+						_game._objects.setRoom(OBJ_BURGER, _scene->_currentSceneId);
+						_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 0, 0);
+						_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 30, 30);
+						int idx = _scene->_dynamicHotspots.add(53, 348, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+						_scene->_dynamicHotspots.setPosition(idx, Common::Point(-3, 0), FACING_NORTHEAST);
+						_scene->_sequences.addTimer(65, 6);
+						}
+						break;
+
+					case 6: {
+						_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+						_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 1, 0, 0);
+						_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 31, 46);
+						int idx = _scene->_dynamicHotspots.add(53, 348, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+						_scene->_dynamicHotspots.setPosition(idx, Common::Point(-3, 0), FACING_NORTHEAST);
+						_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 7);
+						}
+						break;
+
+					case 7: {
+						_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+						_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
+						int idx = _scene->_dynamicHotspots.add(53, 348, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+						_scene->_dynamicHotspots.setPosition(idx, Common::Point(-3, 0), FACING_NORTHEAST);
+						_vm->_dialogs->show(0x2AA3);
+						}
+						break;
+
+					case 8:
+						_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 7, 1, 0, 0);
+						_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 5, 16);
+						break;
+					}
+					_action._inProgress = false;
+					return;
+				} else if (_game._objects.isInInventory(_throwingObjectId)) {
+					// Nothing.
+				}
+			}
+		}
+	}
+
+	if (_action.isAction(VERB_TAKE, 0x35) && _game._objects.isInRoom(OBJ_BURGER)) {
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_game._objects.addToInventory(OBJ_BURGER);
+	} else if (_action.isAction(VERB_LOOK, 0xF0))
+		_vm->_dialogs->show(0x2A95); 
+	else if (_action.isAction(VERB_LOOK, 0x5A))
+		_vm->_dialogs->show(0x2A96); 
+	else if ((_action.isAction(VERB_TAKE) || _action.isAction(VERB_PULL)) && _action.isAction(0x5A))
+		_vm->_dialogs->show(0x2A97); 
+	else if (_action.isAction(VERB_LOOK, 0x129))
+		_vm->_dialogs->show(0x2A98); 
+	else if (_action.isAction(VERB_TAKE, 0x129))
+		_vm->_dialogs->show(0x2A99); 
+	else if (_action.isAction(VERB_LOOK, 0x45))
+		_vm->_dialogs->show(0x2A9A); 
+	else if (_action.isAction(VERB_LOOK, 0x178)) {
+		if (_globals[kHoovicAlive])
+			_vm->_dialogs->show(0x2A9B); 
+		else
+			_vm->_dialogs->show(0x2AA1);
+	} else if (_action.isAction(VERB_LOOK, 0x146))
+		_vm->_dialogs->show(0x2A9C); 
+	else if (_action.isAction(VERB_LOOK, 0xFC))
+		_vm->_dialogs->show(0x2A9F); 
+	else if (_action.isAction(VERB_PUT, 0x146))
+		_vm->_dialogs->show(0x2A9E); 
+	else if (_action.isAction(VERB_LOOK, 0x66))
+		_vm->_dialogs->show(0x2AA2);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+
+/*------------------------------------------------------------------------*/
 
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index 6d28252..267234c 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -190,6 +190,28 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene109 : public Scene1xx {
+private:
+	bool _rexThrowingObject;
+	bool _hoovicDifficultFl;
+	bool _beforeEatingRex;
+	bool _eatingRex;
+	bool _hungryFl;
+	bool _eatingFirstFish;
+
+	int _throwingObjectId;
+	int _hoovicTrigger;
+
+public:
+	Scene109(MADSEngine *vm);
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 848c94cd0e86bd9f170da7b06371fb0a12d7bb07
    https://github.com/scummvm/scummvm/commit/848c94cd0e86bd9f170da7b06371fb0a12d7bb07
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-14T21:33:58-04:00

Commit Message:
MADS: Fix for sprite refreshes when doing player cutscenes

Changed paths:
    engines/mads/sprites.cpp



diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 83f0143..cd838f7 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -212,8 +212,9 @@ void SpriteSlots::fullRefresh(bool clearAll) {
 
 void SpriteSlots::deleteTimer(int seqIndex) {
 	for (uint idx = 0; idx < size(); ++idx) {
-		if ((*this)[idx]._seqIndex == seqIndex) {
-			remove_at(idx);
+		SpriteSlot &slot = (*this)[idx];
+		if (slot._seqIndex == seqIndex) {
+			slot._flags = IMG_ERASE;
 			return;
 		}
 	}


Commit: 9643b543f088449bc6728c5a884087789aa4c5c7
    https://github.com/scummvm/scummvm/commit/9643b543f088449bc6728c5a884087789aa4c5c7
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-15T07:45:35+02:00

Commit Message:
MADS: Implement scene 110

Changed paths:
    engines/mads/animation.cpp
    engines/mads/animation.h
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 380770f..06eeaf8 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -609,4 +609,8 @@ void Animation::setCurrentFrame(int frameNumber) {
 	_nextScrollTimer = _nextFrameTimer = _vm->_game->_scene._frameStartTime;
 }
 
+void Animation::setNextFrameTimer(int frameNumber) {
+	_nextFrameTimer = frameNumber;
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 75f14a5..3b03417 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -213,6 +213,7 @@ public:
 	 */
 	void update();
 
+	void setNextFrameTimer(int frameNumber);
 	void setCurrentFrame(int frameNumber);
 	int getCurrentFrame() const { return _currentFrame; }
 
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 50c4b94..3ad856b 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -65,6 +65,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene108(vm);
 	case 109:
 		return new Scene109(vm);
+	case 110:
+		return new Scene110(vm);
 
 	// Scene group #2
 	case 201:
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 5e2ed3d..37c993e 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -2660,5 +2660,128 @@ void Scene109::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene110::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+
+	_scene->addActiveVocab(0x5B);
+}
+
+void Scene110::enter() {
+	_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('X', 0));
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('X', 1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('X', 2));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('X', 3));
+
+	crabs_here = false;
+
+	if (_scene->_priorSceneId == 109) {
+		_game._player._playerPos = Common::Point(59, 71);
+
+		_globals._sequenceIndexes[0] = _scene->_sequences.startCycle(_globals._spriteIndexes[0], false, 1);
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+
+		crabs_here = true;
+
+		int idx = _scene->_dynamicHotspots.add(91, 348, _globals._sequenceIndexes[0], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(-1, 0), FACING_NONE);
+		idx = _scene->_dynamicHotspots.add(91, 348, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(-1, 0), FACING_NONE);
+		idx = _scene->_dynamicHotspots.add(91, 348, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(-1, 0), FACING_NONE);
+		idx = _scene->_dynamicHotspots.add(91, 348, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(-1, 0), FACING_NONE);
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(194, 23);
+		_game._player._facing = FACING_SOUTH;
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+		_scene->loadAnimation(Resources::formatName(110, 'T', 1,EXT_AA, ""), 70);
+	}
+
+	sceneEntrySound();
+	_game.loadQuoteSet(0x59, 0);
+
+	if (!_game._visitedScenes._sceneRevisited && (_scene->_priorSceneId == 109))
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(109));
+}
+
+void Scene110::step() {
+	if (_game._trigger == 70) {
+		_game._player._visible = true;
+		_game._player._stepEnabled = true;
+	}
+}
+
+void Scene110::preActions() {
+	if (_action.isAction(0x15B, 0x41))
+		_game._player._walkOffScreenSceneId = 109;
+
+	if (crabs_here) {
+		crabs_here = false;
+
+		_scene->_sequences.remove(_globals._sequenceIndexes[0]);
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+
+		_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 16, 1, 0, 0);
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 16, 1, 0, 0);
+		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 16, 1, 0, 0);
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 16, 1, 0, 0);
+
+		int idx = _scene->_dynamicHotspots.add(91, 348, _globals._sequenceIndexes[0], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(-1, 0), FACING_NONE);
+		idx = _scene->_dynamicHotspots.add(91, 348, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(-1, 0), FACING_NONE);
+		idx = _scene->_dynamicHotspots.add(91, 348, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(-1, 0), FACING_NONE);
+		idx = _scene->_dynamicHotspots.add(91, 348, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(-1, 0), FACING_NONE);
+	}
+}
+
+void Scene110::actions() {
+	if (_action.isAction(0x15B, 0x178)) {
+		switch (_game._trigger) {
+		case 0:
+			_scene->loadAnimation(Resources::formatName(110, 'T', 0, EXT_AA, ""), 1);
+			_scene->_activeAnimation->setNextFrameTimer(_game._player._ticksAmount + _game._player._priorTimer);
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			break;
+		case 1:
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			_scene->_nextSceneId = 111;
+			break;
+		}
+	} else if ((_action._lookFlag) || _action.isAction(VERB_LOOK, 0x3F))
+		_vm->_dialogs->show(0x2AF9);
+	else if (_action.isAction(VERB_LOOK, 0x40) || _action.isAction(0xD1, 0x40))
+		_vm->_dialogs->show(0x2AFA); 
+	else if (_action.isAction(VERB_LOOK, 0x129))
+		_vm->_dialogs->show(0x2AFB); 
+	else if (_action.isAction(VERB_TAKE, 0x129))
+		_vm->_dialogs->show(0x2AFC); 
+	else if (_action.isAction(VERB_LOOK, 0x178))
+		_vm->_dialogs->show(0x2AFD); 
+	else if (_action.isAction(VERB_LOOK, 0x41))
+		_vm->_dialogs->show(0x2AFE); 
+	else if (_action.isAction(VERB_LOOK, 0x8F))
+		_vm->_dialogs->show(0x2AFF); 
+	else if (_action.isAction(VERB_TAKE, 0x8F))
+		_vm->_dialogs->show(0x2B00); 
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index 267234c..d4f69c3 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -212,6 +212,22 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene110 : public Scene1xx {
+private:
+	int crabs_here;       /* Flag if crabs are here */
+
+public:
+	Scene110(MADSEngine *vm) : Scene1xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 968a8e16a4317d28fc85d4607e7e7627693992dc
    https://github.com/scummvm/scummvm/commit/968a8e16a4317d28fc85d4607e7e7627693992dc
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-15T07:49:13+02:00

Commit Message:
MADS: Implement scene 110

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 37c993e..7b6f812 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -2673,7 +2673,7 @@ void Scene110::enter() {
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('X', 2));
 	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('X', 3));
 
-	crabs_here = false;
+	_crabsFl = false;
 
 	if (_scene->_priorSceneId == 109) {
 		_game._player._playerPos = Common::Point(59, 71);
@@ -2683,7 +2683,7 @@ void Scene110::enter() {
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
 		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
 
-		crabs_here = true;
+		_crabsFl = true;
 
 		int idx = _scene->_dynamicHotspots.add(91, 348, _globals._sequenceIndexes[0], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(-1, 0), FACING_NONE);
@@ -2719,8 +2719,8 @@ void Scene110::preActions() {
 	if (_action.isAction(0x15B, 0x41))
 		_game._player._walkOffScreenSceneId = 109;
 
-	if (crabs_here) {
-		crabs_here = false;
+	if (_crabsFl) {
+		_crabsFl = false;
 
 		_scene->_sequences.remove(_globals._sequenceIndexes[0]);
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index d4f69c3..b1fb7d1 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -215,7 +215,7 @@ public:
 
 class Scene110 : public Scene1xx {
 private:
-	int crabs_here;       /* Flag if crabs are here */
+	bool _crabsFl;
 
 public:
 	Scene110(MADSEngine *vm) : Scene1xx(vm) {}


Commit: eb1f885c42d7ef26ea8c39e67fcc8844b66ca544
    https://github.com/scummvm/scummvm/commit/eb1f885c42d7ef26ea8c39e67fcc8844b66ca544
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-15T08:40:40+02:00

Commit Message:
MADS: Implement scene 111

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 3ad856b..8b18fad 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -67,6 +67,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene109(vm);
 	case 110:
 		return new Scene110(vm);
+	case 111:
+		return new Scene111(vm);
 
 	// Scene group #2
 	case 201:
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 7b6f812..4cb6b8c 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -2780,6 +2780,147 @@ void Scene110::actions() {
 	_action._inProgress = false;
 }
 
+/*------------------------------------------------------------------------*/
+
+void Scene111::setup() {
+	_scene->addActiveVocab(0x1F);
+
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene111::enter() {
+	_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('X', 0));
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('X', 1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('X', 2));
+
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('B', 0));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('B', 1));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('B', 2));
+
+	_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 8, 0, 0, 0);
+	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SM_FRAME_INDEX, 9, 73);
+	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SM_FRAME_INDEX, 13, 73);
+
+	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 0, 0, 0);
+	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SM_FRAME_INDEX, 71, 71);
+
+	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 0, 0, 0);
+	_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
+	_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
+
+	int idx = _scene->_dynamicHotspots.add(0x1F, 0xD1, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+	_scene->_dynamicHotspots.setPosition(idx, Common::Point(-2, 0), FACING_NONE);
+	idx = _scene->_dynamicHotspots.add(0x1F, 0xD1, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+	_scene->_dynamicHotspots.setPosition(idx, Common::Point(-2, 0), FACING_NONE);
+	idx = _scene->_dynamicHotspots.add(0x1F, 0xD1, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+	_scene->_dynamicHotspots.setPosition(idx, Common::Point(-2, 0), FACING_NONE);
+
+	_launch1Fl = false;
+	_launched2Fl = false;
+	_stampedFl = false;
+
+	if ((_scene->_priorSceneId < 201) && (_scene->_priorSceneId != -2)) {
+		_game._player._stepEnabled = false;
+		_game._player._visible   = false;
+		_scene->loadAnimation(Resources::formatName(111, 'A', 0, EXT_AA, ""), 70);
+		_game._player._playerPos = Common::Point(234, 116);
+		_game._player._facing = FACING_EAST;
+
+		_launch1Fl = true;
+		_launched2Fl = true;
+
+		_vm->_sound->command(36);
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(300, 130);
+		_game._player._facing = FACING_WEST;
+	}
+
+	_rexDivingFl = false;
+
+	sceneEntrySound();
+}
+
+void Scene111::step() {
+	if (_game._trigger == 70) {
+		_game._player._stepEnabled = true;
+		_game._player._visible = true;
+		_launch1Fl = false;
+		_launched2Fl = false;
+	}
+
+	if ((_game._trigger == 71) && !_stampedFl) {
+		_stampedFl = true;
+		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 18, 1, 0, 0);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_0, 0, 72);
+	}
+
+	if (_game._trigger == 72) {
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 20);
+	}
+
+	if (!_launch1Fl && (_vm->getRandomNumber(1, 5000) == 1)) {
+		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 5, 1, 0, 0);
+		_launch1Fl = true;
+		int idx = _scene->_dynamicHotspots.add(0x1F, 0xD1, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(-2, 0), FACING_NONE);
+	}
+
+	if (!_launched2Fl && (_vm->getRandomNumber(1, 30000) == 1)) {
+		_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+		_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 5, 1, 0, 0);
+		int idx = _scene->_dynamicHotspots.add(0x1F, 0xD1, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(-2, 0), FACING_NONE);
+		_launched2Fl = true;
+	}
+
+	if (_game._trigger == 73)
+		_vm->_sound->command(37);
+
+	if (_rexDivingFl && (_scene->_activeAnimation->getCurrentFrame() >= 9)) {
+		_vm->_sound->command(36);
+		_rexDivingFl = false;
+	}
+}
+
+void Scene111::preActions() {
+	if (_action.isAction(0x18B, 0x41))
+		_game._player._walkOffScreenSceneId = 212;
+}
+
+void Scene111::actions() {
+	if (_action.isAction(0x6D, 0x116) && _game._objects.isInInventory(OBJ_REBREATHER)) {
+		switch (_game._trigger) {
+		case 0:
+			_scene->loadAnimation(Resources::formatName(111, 'A', 1, EXT_AA, ""), 1);
+			_rexDivingFl        = true;
+			_game._player._stepEnabled = false;
+			_game._player._visible   = false;
+			break;
+
+		case 1:
+			_scene->_nextSceneId = 110;
+			break;
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x43))
+		_vm->_dialogs->show(0x2B5D);
+	else if (_action.isAction(VERB_LOOK, 0x116))
+		_vm->_dialogs->show(0x2B5E);
+	else if (_action.isAction(VERB_LOOK, 0x41))
+		_vm->_dialogs->show(0x2B5F);
+	else if (_action.isAction(VERB_LOOK, 0x153))
+		_vm->_dialogs->show(0x2B60);
+	else if (_action.isAction(VERB_LOOK, 0xC8))
+		_vm->_dialogs->show(0x2B61);
+	else if ((_action.isAction(VERB_PULL) || _action.isAction(VERB_TAKE)) && (_action.isAction(0x153) || _action.isAction(0xC8)))
+		_vm->_dialogs->show(0x2B62);
+	else
+		return;
+
+	_action._inProgress = false;
+}
 
 /*------------------------------------------------------------------------*/
 
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index b1fb7d1..a2637b5 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -218,7 +218,25 @@ private:
 	bool _crabsFl;
 
 public:
-	Scene110(MADSEngine *vm) : Scene1xx(vm) {}
+	Scene110(MADSEngine *vm) : Scene1xx(vm), _crabsFl(false) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
+class Scene111 : public Scene1xx {
+private:
+	bool _stampedFl;
+	bool _launch1Fl;
+	bool _launched2Fl;
+	bool _rexDivingFl;
+
+public:
+	Scene111(MADSEngine *vm) : Scene1xx(vm), _stampedFl(false), _launch1Fl(false), _launched2Fl(false), _rexDivingFl(false) {}
 
 	virtual void setup();
 	virtual void enter();


Commit: 52ba3b408362970b1764e569ddd8a01a66bb495b
    https://github.com/scummvm/scummvm/commit/52ba3b408362970b1764e569ddd8a01a66bb495b
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-15T17:43:35+02:00

Commit Message:
MADS: Implement scene 112

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 8b18fad..a3b75c6 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -69,6 +69,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene110(vm);
 	case 111:
 		return new Scene111(vm);
+	case 112:
+		return new Scene112(vm);
 
 	// Scene group #2
 	case 201:
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 4cb6b8c..63f7f63 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -2822,7 +2822,7 @@ void Scene111::enter() {
 
 	if ((_scene->_priorSceneId < 201) && (_scene->_priorSceneId != -2)) {
 		_game._player._stepEnabled = false;
-		_game._player._visible   = false;
+		_game._player._visible = false;
 		_scene->loadAnimation(Resources::formatName(111, 'A', 0, EXT_AA, ""), 70);
 		_game._player._playerPos = Common::Point(234, 116);
 		_game._player._facing = FACING_EAST;
@@ -2895,9 +2895,9 @@ void Scene111::actions() {
 		switch (_game._trigger) {
 		case 0:
 			_scene->loadAnimation(Resources::formatName(111, 'A', 1, EXT_AA, ""), 1);
-			_rexDivingFl        = true;
+			_rexDivingFl = true;
 			_game._player._stepEnabled = false;
-			_game._player._visible   = false;
+			_game._player._visible = false;
 			break;
 
 		case 1:
@@ -2924,5 +2924,54 @@ void Scene111::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene112::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene112::enter() {
+	sceneEntrySound();
+
+	_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('X', 0));
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('X', 1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('X', 2));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('X', 5));
+
+	_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 10, 0, 17, 20);
+	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 4, 0, 0, 0);
+	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 3, 0);
+
+	_game._player._stepEnabled = false;
+	_game._player._visible = false;
+
+	_scene->_userInterface.emptyTalkList();
+	_scene->_userInterface.setup(kInputConversation);
+
+	_scene->loadAnimation(Resources::formatName(112, 'X', -1, EXT_AA, ""), 70);
+}
+
+void Scene112::step() {
+	if ((_scene->_activeAnimation != nullptr) && (_game._storyMode == STORYMODE_NICE)) {
+		if (_scene->_activeAnimation->getCurrentFrame() >= 54) {
+			_scene->_activeAnimation->free();
+			_game._trigger = 70;
+		}
+	}
+
+	if (_game._trigger == 70) {
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 7, 3, 0, 11);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 1);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 71);
+	}
+
+	if (_game._trigger == 71) {
+		_scene->_nextSceneId = 101;
+		_game._player._stepEnabled = true;
+		_game._player._visible = true;
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index a2637b5..b4585b0 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -246,6 +246,18 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene112 : public Scene1xx {
+public:
+	Scene112(MADSEngine *vm) : Scene1xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions() {};
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 27a2ead1541fb6247b578c03fbb6265e8feb32dd
    https://github.com/scummvm/scummvm/commit/27a2ead1541fb6247b578c03fbb6265e8feb32dd
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-15T17:52:42+02:00

Commit Message:
MADS: Fix several Rects in scene 101 and 109

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 63f7f63..9ae9a46 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -177,7 +177,7 @@ void Scene101::enter() {
 		_globals._sequenceIndexes[11] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 0, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], 17, 17);
 		_scene->_hotspots.activate(0x47, false);
-		_chairHotspotId = _scene->_dynamicHotspots.add(0x47, 0x13F, -1, Common::Rect(159, 84, 33, 36));
+		_chairHotspotId = _scene->_dynamicHotspots.add(0x47, 0x13F, -1, Common::Rect(159, 84, 159 + 33, 84 + 36));
 		if (_scene->_priorSceneId == 112)
 			sayDang();
 	} else {
@@ -2533,11 +2533,11 @@ void Scene109::actions() {
 							_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 1, 0, 0);
 							_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 4);
 							_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], -2, -2);
-							int idx = _scene->_dynamicHotspots.add(102, 348, -1, Common::Rect(256, 57, 12, 31));
+							int idx = _scene->_dynamicHotspots.add(102, 348, -1, Common::Rect(256, 57, 256 + 12, 57 + 31));
 							_scene->_dynamicHotspots.setPosition(idx, Common::Point(241, 91), FACING_NORTHEAST);
-							idx = _scene->_dynamicHotspots.add(102, 348, -1, Common::Rect(242, 79, 24, 12));
+							idx = _scene->_dynamicHotspots.add(102, 348, -1, Common::Rect(242, 79, 242 + 24, 79 + 12));
 							_scene->_dynamicHotspots.setPosition(idx, Common::Point(241, 91), FACING_NORTHEAST);
-							idx = _scene->_dynamicHotspots.add(229, 348, -1, Common::Rect(231, 88, 23, 7));
+							idx = _scene->_dynamicHotspots.add(229, 348, -1, Common::Rect(231, 88, 231 + 23, 88 + 7));
 							_scene->_dynamicHotspots.setPosition(idx, Common::Point(241, 91), FACING_NORTHEAST);
 							_scene->changeVariant(1);
 						} else {


Commit: 3db3aced02bd028b41939818b5aa1028733886f3
    https://github.com/scummvm/scummvm/commit/3db3aced02bd028b41939818b5aa1028733886f3
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-16T01:03:37+02:00

Commit Message:
MADS: Implement scene 214

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index a3b75c6..bf8e5b7 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -94,6 +94,9 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 212:
 		return new Scene212(vm);
 
+	case 214:
+		return new Scene214(vm);
+
 	// Scene group #8
 	case 804:
 		return new Scene804(vm);
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index a804dbb..333bdc2 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -4653,5 +4653,211 @@ void Scene212::actions() {
 
 /*------------------------------------------------------------------------*/
 
+
+/*------------------------------------------------------------------------*/
+
+void Scene214::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x1C3);
+	_scene->addActiveVocab(0xD);
+}
+
+void Scene214::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('e', 0));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('e', 1));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('t', -1));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXMRD_7");
+
+	_devilTime = _game._player._priorTimer;
+	_devilRunningFl = false;
+
+	if (_game._objects.isInRoom(OBJ_POISON_DARTS)) {
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(103, 86));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 11);
+	} else {
+		_scene->_hotspots.activate(0x114, false);
+	}
+
+	if (_game._objects.isInRoom(OBJ_BLOWGUN)) {
+		_globals._sequenceIndexes[2]  = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(90, 87));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 13);
+	} else {
+		_scene->_hotspots.activate(0x29, false);
+	}
+
+	if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(191, 152);
+
+	sceneEntrySound();
+}
+
+void Scene214::step() {
+	if ((_game._player._priorTimer - _devilTime > 800) && !_devilRunningFl) {
+		_devilRunningFl = true;
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 9, 1, 6, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 4);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 2);
+		_scene->_dynamicHotspots.add(451, 13, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 71);
+	}
+
+	if (_devilRunningFl) {
+		switch (_game._trigger) {
+		case 71: {
+			int oldIdx = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 9, 5, 0, 0);
+			_scene->_sequences.updateTimeout(oldIdx, _globals._sequenceIndexes[3]);
+			_scene->_dynamicHotspots.add(451, VERB_WALKTO, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 5, 8);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 72);
+			}
+			break;
+
+		case 72: {
+			int oldIdx = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 9, 1, 0, 0);
+			_scene->_sequences.updateTimeout(oldIdx, _globals._sequenceIndexes[3]);
+			_scene->_dynamicHotspots.add(451, VERB_WALKTO, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 9, -2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 2);
+			_devilTime = _game._player._priorTimer;
+			_devilRunningFl = false; 
+			}
+			break;
+		}
+	}
+}
+
+void Scene214::actions() {
+	if (_action._lookFlag)
+		_vm->_dialogs->show(0x53B3);
+	else if (_action.isAction(0x18A, 0xAA))
+		_scene->_nextSceneId = 207;
+	else if (_action.isAction(VERB_TAKE, 0x114) && (_game._trigger || _game._objects.isInRoom(OBJ_POISON_DARTS))) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_game._player._visible   = false;
+			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], true, 6, 1, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 1);
+			break;
+
+		case 1:
+			_globals._sequenceIndexes[4] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[4], true, 6, 1, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 2);
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_game._objects.addToInventory(OBJ_POISON_DARTS);
+			_scene->_hotspots.activate(0x114, false);
+			break;
+
+		case 2:
+			_game._player._visible = true;
+			_scene->_sequences.addTimer(48, 3);
+			break;
+
+		case 3:
+			_game._player._stepEnabled = true;
+			_vm->_dialogs->showPicture(OBJ_POISON_DARTS, 0x53A5);
+			break;
+		}
+	} else if (_action.isAction(VERB_TAKE, 0x29) && (_game._trigger || _game._objects.isInRoom(OBJ_BLOWGUN))) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6, 1, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 1);
+			break;
+
+		case 1:
+			_globals._sequenceIndexes[4] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[4], false, 6, 1, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 2);
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_game._objects.addToInventory(OBJ_BLOWGUN);
+			_scene->_hotspots.activate(0x29, false);
+			break;
+
+		case 2:
+			_game._player._visible = true;
+			_scene->_sequences.addTimer(48, 3);
+			break;
+
+		case 3:
+			_game._player._stepEnabled = true;
+			_vm->_dialogs->showPicture(OBJ_BLOWGUN, 0x329);
+			break;
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x197))
+		_vm->_dialogs->show(0x5399);
+	else if (_action.isAction(VERB_LOOK, 0x7E))
+		_vm->_dialogs->show(0x539A);
+	else if (_action.isAction(VERB_LOOK, 0x1C3))
+		_vm->_dialogs->show(0x539B);
+	else if (_action.isAction(VERB_LOOK, 0x21))
+		_vm->_dialogs->show(0x539C);
+	else if (_action.isAction(VERB_LOOK, 0x1BB))
+		_vm->_dialogs->show(0x539D);
+	else if (_action.isAction(VERB_LOOK, 0x1BE)) {
+		if (_game._storyMode == STORYMODE_NAUGHTY) {
+			_vm->_dialogs->show(0x539E);
+		} else {
+			_vm->_dialogs->show(0x539F);
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x1BC))
+		_vm->_dialogs->show(0x53A0);
+	else if (_action.isAction(VERB_TAKE, 0x1BE) || _action.isAction(VERB_TAKE, 0x1BC))
+		_vm->_dialogs->show(0x53A1);
+	else if (_action.isAction(VERB_LOOK, 0x13D))
+		_vm->_dialogs->show(0x53A2);
+	else if (_action.isAction(VERB_TAKE, 0x13D) || _action.isAction(VERB_TAKE, 0x48A))
+		_vm->_dialogs->show(0x53A3);
+	else if (_action.isAction(VERB_LOOK, 0x48A))
+		_vm->_dialogs->show(0x53B4);
+	else if (_action.isAction(VERB_LOOK, 0x114) && (_action._savedFields._mainObjectSource == 4))
+		_vm->_dialogs->show(0x53A4);
+	else if (_action.isAction(VERB_OPEN, 0x7E))
+		_vm->_dialogs->show(0x53A6);
+	else if (_action.isAction(VERB_TALKTO, 0x1C3))
+		_vm->_dialogs->show(0x53A7);
+	else if (_action.isAction(VERB_GIVE, 0x17A, 0x1C3))
+		_vm->_dialogs->show(0x53A8);
+	else if (_action.isAction(0x13A, 0x29, 0x1C3) || _action.isAction(0xA6, 0x29, 0x1C3))
+		_vm->_dialogs->show(0x53A9);
+	else if (_action.isAction(VERB_LOOK, 0x473))
+		_vm->_dialogs->show(0x53AA);
+	else if (_action.isAction(VERB_TAKE, 0x473))
+		_vm->_dialogs->show(0x53AB);
+	else if (_action.isAction(VERB_TAKE, 0x21))
+		_vm->_dialogs->show(0x53AC);
+	else if (_action.isAction(VERB_LOOK, 0x8A))
+		_vm->_dialogs->show(0x53AD);
+	else if (_action.isAction(VERB_LOOK, 0x29))
+		_vm->_dialogs->show(0x53AE);
+	else if (_action.isAction(VERB_LOOK, 0x160)) {
+		if (_game._objects.isInRoom(OBJ_POISON_DARTS) && _game._objects.isInRoom(OBJ_BLOWGUN)) {
+			_vm->_dialogs->show(0x53AF);
+		} else if (_game._objects.isInRoom(OBJ_POISON_DARTS) && !_game._objects.isInRoom(OBJ_BLOWGUN)) {
+			_vm->_dialogs->show(0x53B0);
+		} else if (!_game._objects.isInRoom(OBJ_POISON_DARTS)  && _game._objects.isInRoom(OBJ_BLOWGUN)) {
+			_vm->_dialogs->show(0x53B1);
+		} else {
+			_vm->_dialogs->show(0x53B2);
+		} 
+	} else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 0b446bb..c6ef759 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -265,6 +265,22 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene214: public Scene2xx {
+private:
+	uint32 _devilTime;
+	bool _devilRunningFl;
+
+public:
+	Scene214(MADSEngine *vm) : Scene2xx(vm), _devilTime(0), _devilRunningFl(false) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 7b907be93775167eab8efab45bea3b9a2776e288
    https://github.com/scummvm/scummvm/commit/7b907be93775167eab8efab45bea3b9a2776e288
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-15T19:28:29-04:00

Commit Message:
MADS: General cleanup and minor renamings

Changed paths:
    engines/mads/action.cpp
    engines/mads/dialogs.h
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/dialogs_nebular.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/player.cpp
    engines/mads/rails.cpp
    engines/mads/scene.cpp
    engines/mads/screen.cpp
    engines/mads/screen.h
    engines/mads/sprites.cpp
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 2d3c115..2da3c52 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -585,8 +585,7 @@ void MADSAction::leftClick() {
 				if (_prepType) {
 					_articleNumber = _prepType;
 					_interAwaiting = AWAITING_THAT;
-				}
-				else {
+				} else {
 					_selectedAction = -1;
 				}
 
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index 00b714d..0c24dea 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -211,7 +211,7 @@ public:
 	virtual ~Dialogs() {}
 
 	virtual void showDialog() = 0;
-	virtual void showPicture(int objId, int msgId, int arg3 = 0) = 0;
+	virtual void showItem(int objectId, int messageId, int arg = 0) = 0;
 
 	virtual bool show(int msgId) = 0;
 };
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 30b28fe..3606830 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -242,6 +242,33 @@ bool DialogsNebular::show(int msgId) {
 	return result;
 }
 
+void DialogsNebular::showItem(int objectId, int messageId, int arg) {
+	show(messageId);
+#if 0
+	Scene &scene = _vm->_game->_scene;
+	byte highPalette[8 * 3];
+	Common::copy(&_vm->_palette->_mainPalette[0x2E8], &_vm->_palette->_mainPalette[PALETTE_SIZE],
+		&highPalette[0]);
+	byte *depthP = scene._depthSurface.getData();
+	byte greyScale[3];
+	greyScale[0] = greyScale[1] = greyScale[2] = 0xFFFF;
+	Common::String setName = Common::String::format("*OBJ%.3d.SS", objectId);
+
+	// Turn off cycling if active
+	bool cyclingActive = scene._cyclingActive;
+	scene._cyclingActive = false;
+
+	// Make a copy of the current screen surface
+	byte *savedSurface = new byte[MADS_SCREEN_WIDTH * MADS_SCREEN_HEIGHT];
+	Common::copy(_vm->_screen.getData(), _vm->_screen.getData() +
+		MADS_SCREEN_WIDTH * MADS_SCREEN_HEIGHT, savedSurface);
+	
+
+
+	delete[] savedSurface;
+#endif
+}
+
 Common::String DialogsNebular::getVocab(int vocabId) {
 	assert(vocabId > 0);
 
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index e123efd..041deda 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -50,10 +50,9 @@ public:
 	virtual void showDialog() {
 		warning("TODO: showDialog");
 	}
-	virtual void showPicture(int objId, int msgId, int arg3) {
-		show(msgId);
-		warning("TODO: showPicture");
-	}
+
+	virtual void showItem(int objectId, int msgId, int arg);
+
 	virtual bool show(int id);
 };
 
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 4142cb4..23c8b3c 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -362,7 +362,7 @@ void GameNebular::doObjectAction() {
 		_objects.addToInventory(OBJ_BLOWGUN);
 		_objects.setRoom(OBJ_PLANT_STALK, PLAYER_INVENTORY);
 		_globals[kBlowgunStatus] = 0;
-		dialogs.showPicture(OBJ_BLOWGUN, 809);
+		dialogs.showItem(OBJ_BLOWGUN, 809);
 	} else if (action.isAction(VERB_PUT, 276, NOUN_BLOWGUN) && _objects.isInInventory(OBJ_POISON_DARTS)
 			&& _objects.isInInventory(OBJ_BLOWGUN)) {
 		dialogs.show(433);
@@ -374,7 +374,7 @@ void GameNebular::doObjectAction() {
 			action.isAction(936) && _objects.isInInventory(OBJ_NOTE)) {
 		_objects.setRoom(OBJ_NOTE, PLAYER_INVENTORY);
 		_objects.addToInventory(OBJ_COMBINATION);
-		dialogs.showPicture(OBJ_COMBINATION, 851);
+		dialogs.showItem(OBJ_COMBINATION, 851);
 	} else if ((action.isAction(VERB_LOOK) || action.isAction(NOUN_READ)) &&
 			((id = _objects.getIdFromDesc(action._activeAction._objectNameId)) > 0 ||
 			(action._activeAction._indirectObjectId > 0 &&
@@ -390,7 +390,7 @@ void GameNebular::doObjectAction() {
 			dialogs._indexList[7] = _globals[kTeleporterCode + 5];
 			dialogs._indexList[8] = _globals[kTeleporterCode + 2];
 
-			dialogs.showPicture(id, 402);
+			dialogs.showItem(id, 402);
 		} else {
 			int messageId = 800 + id;
 			if (id == OBJ_CHARGE_CASES) {
@@ -410,14 +410,14 @@ void GameNebular::doObjectAction() {
 			if (id == OBJ_PHONE_HANDSET && _globals[kHandsetCellStatus])
 				messageId = 861;
 
-			dialogs.showPicture(id, messageId);
+			dialogs.showItem(id, messageId);
 		}
 	} else if (action.isAction(VERB_PUT, NOUN_BURGER, NOUN_DEAD_FISH)) {
 		if (_objects.isInInventory(OBJ_BURGER) || _objects.isInInventory(OBJ_DEAD_FISH)) {
 			_objects.removeFromInventory(OBJ_DEAD_FISH, PLAYER_INVENTORY);
 			_objects.removeFromInventory(OBJ_BURGER, PLAYER_INVENTORY);
 			_objects.addToInventory(OBJ_STUFFED_FISH);
-			dialogs.showPicture(OBJ_STUFFED_FISH, 803);
+			dialogs.showItem(OBJ_STUFFED_FISH, 803);
 		}
 	} else if (action.isAction(VERB_PUT, 26, 357) && _objects.isInInventory(OBJ_AUDIO_TAPE) &&
 			_objects.isInInventory(OBJ_TAPE_PLAYER)) {
@@ -449,7 +449,7 @@ void GameNebular::doObjectAction() {
 
 		_objects.setRoom(OBJ_TIMER_MODULE, PLAYER_INVENTORY);
 		_objects.addToInventory(OBJ_TIMEBOMB);
-		dialogs.showPicture(OBJ_TIMEBOMB, 404);
+		dialogs.showItem(OBJ_TIMEBOMB, 404);
 	} else if (action.isAction(140, 271)) {
 		dialogs.show(410);
 	} else if (action.isAction(119, 46)) {
@@ -458,7 +458,7 @@ void GameNebular::doObjectAction() {
 	} else if (action.isAction(108, 136)) {
 		if (_objects[OBJ_FISHING_LINE]._roomNumber == 3) {
 			_objects.addToInventory(OBJ_FISHING_LINE);
-			dialogs.showPicture(OBJ_FISHING_LINE, 409);
+			dialogs.showItem(OBJ_FISHING_LINE, 409);
 		} else {
 			dialogs.show(428);
 		}
@@ -467,19 +467,19 @@ void GameNebular::doObjectAction() {
 		case 1:
 		case 2:
 			_objects.addToInventory(OBJ_DURAFAIL_CELLS);
-			dialogs.showPicture(OBJ_DURAFAIL_CELLS, 412);
+			dialogs.showItem(OBJ_DURAFAIL_CELLS, 412);
 			break;
 		case 3:
 			_objects.addToInventory(OBJ_PHONE_CELLS);
-			dialogs.showPicture(OBJ_DURAFAIL_CELLS, 413);
+			dialogs.showItem(OBJ_DURAFAIL_CELLS, 413);
 			break;
 		case 5:
 			_objects.addToInventory(OBJ_DURAFAIL_CELLS);
-			dialogs.showPicture(OBJ_DURAFAIL_CELLS, 411);
+			dialogs.showItem(OBJ_DURAFAIL_CELLS, 411);
 			break;
 		case 6:
 			_objects.addToInventory(OBJ_DURAFAIL_CELLS);
-			dialogs.showPicture(OBJ_DURAFAIL_CELLS, 429);
+			dialogs.showItem(OBJ_DURAFAIL_CELLS, 429);
 			break;
 		default:
 			dialogs.show(478);
@@ -489,24 +489,24 @@ void GameNebular::doObjectAction() {
 		switch (_globals[kHandsetCellStatus]) {
 		case 1:
 			_objects.addToInventory(OBJ_DURAFAIL_CELLS);
-			dialogs.showPicture(OBJ_DURAFAIL_CELLS,
+			dialogs.showItem(OBJ_DURAFAIL_CELLS,
 				_difficulty != 1 || _globals[kDurafailRecharged] ? 415 : 414);
 			break;
 		case 2:
 			_objects.addToInventory(OBJ_DURAFAIL_CELLS);
 			if (_difficulty == 1) {
-				dialogs.showPicture(OBJ_DURAFAIL_CELLS, 416);
+				dialogs.showItem(OBJ_DURAFAIL_CELLS, 416);
 			} else {
 				_globals[kHandsetCellStatus] = 0;
 			}
 			break;
 		case 3:
 			_objects.addToInventory(OBJ_PHONE_CELLS);
-			dialogs.showPicture(OBJ_PHONE_CELLS, 418);
+			dialogs.showItem(OBJ_PHONE_CELLS, 418);
 			break;
 		case 4:
 			_objects.addToInventory(OBJ_PHONE_CELLS);
-			dialogs.showPicture(OBJ_PHONE_CELLS, 417);
+			dialogs.showItem(OBJ_PHONE_CELLS, 417);
 			break;
 		default:
 			dialogs.show(478);
@@ -525,8 +525,7 @@ void GameNebular::doObjectAction() {
 			_globals[kHandsetCellStatus] = 3;
 			_objects.setRoom(OBJ_PHONE_CELLS, PLAYER_INVENTORY);
 			dialogs.show(421);
-		}
-		else {
+		} else {
 			dialogs.show(422);
 		}
 	} else if (action.isAction(VERB_PUT, 115, 262)) {
@@ -557,7 +556,7 @@ void GameNebular::doObjectAction() {
 		}
 
 		_objects.addToInventory(OBJ_CHICKEN_BOMB);
-		dialogs.showPicture(OBJ_CHICKEN_BOMB, 430);
+		dialogs.showItem(OBJ_CHICKEN_BOMB, 430);
 	} else {
 		return;
 	}
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 9ae9a46..1de0dcd 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -396,12 +396,12 @@ void Scene101::actions() {
 	}
 
 	if ((_action.isAction(VERB_TAKE, 0x137) || _action.isAction(VERB_PULL, 0x137)) && _game._objects.isInRoom(0x18)) {
-		_game._objects.addToInventory(0x18);
+		_game._objects.addToInventory(OBJ_SHIELD_MODULATOR);
 		_scene->_sequences.remove(_globals._sequenceIndexes[13]);
 		_globals._sequenceIndexes[13] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[14], false, 6, 0, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], -2, -2);
 		_scene->_hotspots.activate(0x137, false);
-		_vm->_dialogs->showPicture(0x18, 0x2788);
+		_vm->_dialogs->showItem(OBJ_SHIELD_MODULATOR, 10120);
 		_vm->_sound->command(22);
 		_action._inProgress = false;
 		return;
@@ -1133,7 +1133,7 @@ void Scene102::actions() {
 			_game._player._visible = true;
 			_game._player._stepEnabled = true;
 			_vm->_sound->command(22);
-			_vm->_dialogs->showPicture(OBJ_BINOCULARS, 0x27D9);
+			_vm->_dialogs->showItem(OBJ_BINOCULARS, 10201);
 			break;
 		}
 		_action._inProgress = false;
@@ -1142,7 +1142,7 @@ void Scene102::actions() {
 
 	if (_action.isAction(VERB_TAKE, 0x35) && _game._objects.isInRoom(OBJ_BURGER)) {
 		if (_game._trigger == 0) {
-			_vm->_dialogs->showPicture(OBJ_BURGER, 0x27FB);
+			_vm->_dialogs->showItem(OBJ_BURGER, 10235);
 			_scene->_sequences.remove(_globals._sequenceIndexes[10]);
 			_game._objects.addToInventory(OBJ_BURGER);
 			_scene->_hotspots.activate(0x35, false);
@@ -1358,7 +1358,7 @@ void Scene103::actions() {
 			_scene->_hotspots.activate(371, false);
 			_vm->_game->_player._visible = true;
 			_vm->_game->_player._stepEnabled = true;
-			_vm->_dialogs->showPicture(OBJ_REBREATHER, 805);
+			_vm->_dialogs->showItem(OBJ_REBREATHER, 805);
 			break;
 
 		default:
@@ -1386,7 +1386,7 @@ void Scene103::actions() {
 			_scene->_hotspots.activate(289, false);
 			_vm->_game->_player._visible = true;
 			_vm->_game->_player._stepEnabled = true;
-			_vm->_dialogs->showPicture(OBJ_REBREATHER, 804);
+			_vm->_dialogs->showItem(OBJ_REBREATHER, 804);
 			break;
 
 		default:
@@ -1822,7 +1822,7 @@ void Scene105::actions() {
 			_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 			_game._objects.addToInventory(OBJ_DEAD_FISH);
 			_globals[kFishIn105] = false;
-			_vm->_dialogs->showPicture(OBJ_DEAD_FISH, 0x322, 0);
+			_vm->_dialogs->showItem(OBJ_DEAD_FISH, 802, 0);
 		}
 	} else if (_action.isAction(VERB_LOOK, 0x195))
 		_vm->_dialogs->show(0x2905); 
@@ -2141,7 +2141,7 @@ void Scene107::actions() {
 			_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 			_game._objects.addToInventory(OBJ_DEAD_FISH);
 			_globals[kFishIn107] = false;
-			_vm->_dialogs->showPicture(OBJ_DEAD_FISH, 0x322);
+			_vm->_dialogs->showItem(OBJ_DEAD_FISH, 802);
 		}
 	} else if (_action.isAction(0x15D, 0xEE))
 		_scene->_nextSceneId = 105;
@@ -2227,7 +2227,7 @@ void Scene108::actions() {
 			_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 			_game._objects.addToInventory(OBJ_DEAD_FISH);
 			_globals[kFishIn108] = false;
-			_vm->_dialogs->showPicture(OBJ_DEAD_FISH, 0x2A38); 
+			_vm->_dialogs->showItem(OBJ_DEAD_FISH, 10808); 
 		}
 	} else if (_action.isAction(0x15D, 0xF4))
 		_scene->_nextSceneId = 107;
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 333bdc2..2e5ef35 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -781,10 +781,10 @@ void Scene202::actions() {
 					if (_game._objects.isInInventory(OBJ_BONE)) {
 						_game._objects.removeFromInventory(OBJ_BONE, 1);
 						_game._objects.addToInventory(OBJ_BONES);
-						_vm->_dialogs->showPicture(OBJ_BONES, 0x4EFA, 0);
+						_vm->_dialogs->showItem(OBJ_BONES, 0x4EFA, 0);
 					} else {
 						_game._objects.addToInventory(OBJ_BONE);
-						_vm->_dialogs->showPicture(OBJ_BONE, 0x4EFA, 0);
+						_vm->_dialogs->showItem(OBJ_BONE, 0x4EFA, 0);
 					}
 					_scene->changeVariant(_globals[kBone202Status]);
 					_game._player._stepEnabled = true;
@@ -1352,9 +1352,9 @@ void Scene207::preActions() {
 void Scene207::actions() {
 	if (_action._savedFields._lookFlag) {
 		_vm->_dialogs->show(0x50E7);
-	} else if (_action.isAction(0x18B, 0x70))
+	} else if (_action.isAction(0x18B, 0x70)) {
 		_scene->_nextSceneId = 214;
-	else {
+	} else {
 		if ((_game._player._playerPos.x > 150) && (_game._player._playerPos.x < 189) &&
 		    (_game._player._playerPos.y > 111) && (_game._player._playerPos.y < 130)) {
 			if ((_game._player._playerPos.x <= 162) && (_game._player._playerPos.x >= 181) &&
@@ -1622,7 +1622,7 @@ void Scene208::actions() {
 	} else if (_action.isAction(VERB_TAKE, 0x1AA) && (!_globals[kLeavesStatus] || _game._trigger)) {
 		subAction(1);
 		if (_game._player._stepEnabled)
-			_vm->_dialogs->showPicture(OBJ_BIG_LEAVES, 0x326, 0);
+			_vm->_dialogs->showItem(OBJ_BIG_LEAVES, 0x326, 0);
 	} else if (_action.isAction(VERB_PUT, 0x23, 0x19E) && (_globals[kLeavesStatus] == 1 || _game._trigger)) {
 		subAction(2);
 	} else if (_action.isAction(VERB_PUT, 0x17A, 0x1A9)) {
@@ -1820,9 +1820,9 @@ void Scene209::handleLookStay() {
 		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
 		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
 
-		if (!_dodgeFl)
+		if (!_dodgeFl) {
 			_scene->_sequences.addTimer(90, 149);
-		else {
+		} else {
 			_scene->_sequences.addTimer(1, 149);
 			_shouldDodgeFl = true;
 		}
@@ -3137,7 +3137,7 @@ void Scene209::actions() {
 			_game._player._visible = true;
 			_game._player._stepEnabled = true;
 			_scene->_sequences.addTimer(4, 3);
-			_vm->_dialogs->showPicture(OBJ_PLANT_STALK, 0x328);
+			_vm->_dialogs->showItem(OBJ_PLANT_STALK, 0x328);
 			break;
 
 		case 3:
@@ -3173,7 +3173,7 @@ void Scene209::actions() {
 			break;
 
 		case 3:
-			_vm->_dialogs->showPicture (OBJ_BINOCULARS, 0x51AF);
+			_vm->_dialogs->showItem (OBJ_BINOCULARS, 0x51AF);
 			_scene->_sprites.remove(_globals._spriteIndexes[10]);
 			break;
 		}
@@ -4763,7 +4763,7 @@ void Scene214::actions() {
 
 		case 3:
 			_game._player._stepEnabled = true;
-			_vm->_dialogs->showPicture(OBJ_POISON_DARTS, 0x53A5);
+			_vm->_dialogs->showItem(OBJ_POISON_DARTS, 0x53A5);
 			break;
 		}
 	} else if (_action.isAction(VERB_TAKE, 0x29) && (_game._trigger || _game._objects.isInRoom(OBJ_BLOWGUN))) {
@@ -4792,7 +4792,7 @@ void Scene214::actions() {
 
 		case 3:
 			_game._player._stepEnabled = true;
-			_vm->_dialogs->showPicture(OBJ_BLOWGUN, 0x329);
+			_vm->_dialogs->showItem(OBJ_BLOWGUN, 0x329);
 			break;
 		}
 	} else if (_action.isAction(VERB_LOOK, 0x197))
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index bf5e59e..b55d3f0 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -230,8 +230,7 @@ void Player::updateFrame() {
 
 		if (!_visible) {
 			_upcomingTrigger = 0;
-		}
-		else {
+		} else {
 			_upcomingTrigger = _stopWalkerTrigger[_stopWalkerIndex];
 
 			if (_stopWalkerIndex > 0)
@@ -597,11 +596,11 @@ void Player::startMovement() {
 
 	// Figure out direction that will need to be moved in
 	int majorDir;
-	if (xDiff == 0)
+	if (xDiff == 0) {
 		majorDir = 1;
-	else if (yDiff == 0)
+	} else if (yDiff == 0) {
 		majorDir = 3;
-	else {
+	} else {
 		if ((scaleAmount < xDiff) && ((xAmt33 / scaleAmount) >= 141))
 			majorDir = 3;
 		else if (yDiff <= xDiff)
diff --git a/engines/mads/rails.cpp b/engines/mads/rails.cpp
index 0c179f8..342238e 100644
--- a/engines/mads/rails.cpp
+++ b/engines/mads/rails.cpp
@@ -195,8 +195,7 @@ void Rails::setNodePosition(int nodeIndex, const Common::Point &pt) {
 		int entry;
 		if (idx == (uint)nodeIndex) {
 			entry = 0x3FFF;
-		}
-		else {
+		} else {
 			// Process the node
 			flags = getRouteFlags(pt, _nodes[idx]._walkPos);
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 1aa1fd7..a112228 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -426,11 +426,6 @@ void  Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
 	// Draw text elements onto the view
 	_textDisplay.draw(&_vm->_screen);
 
-	// 
-	_vm->_screen.setPointer(&_vm->_screen);
-	_userInterface.setBounds(Common::Rect(_vm->_screen._offset.x, _vm->_screen._offset.y,
-		_vm->_screen._offset.x + _vm->_screen.w, _vm->_screen._offset.y + _vm->_screen.h));
-
 	if (transitionType) {
 		// Fading in the screen
 		_vm->_screen.transition(transitionType, surfaceFlag);
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index f4441ca..5f09737 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -85,8 +85,7 @@ void DirtyArea::setSpriteSlot(const SpriteSlot *spriteSlot) {
 		_bounds.top = 0;
 		width = MADS_SCREEN_WIDTH;
 		height = MADS_SCENE_HEIGHT;
-	}
-	else {
+	} else {
 		// Standard sprite slots
 		_bounds.left = spriteSlot->_position.x - scene._posAdjust.x;
 		_bounds.top = spriteSlot->_position.y - scene._posAdjust.y;
@@ -548,7 +547,6 @@ void ScreenObjects::setActive(ScrCategory category, int descId, bool active) {
 /*------------------------------------------------------------------------*/
 
 ScreenSurface::ScreenSurface() {
-	_dataP = nullptr;
 }
 
 void ScreenSurface::init() {
@@ -610,10 +608,6 @@ void ScreenSurface::transition(ScreenTransition transitionType, bool surfaceFlag
 	}
 }
 
-void ScreenSurface::setPointer(MSurface *s) {
-	_dataP = s->getData();
-}
-
 void ScreenSurface::fadeOut() {
 	warning("TODO: Proper fade out");
 }
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index 5be627a..272ef9e 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -205,7 +205,6 @@ private:
 	void fadeIn();
 public:
 	Common::Point _offset;
-	byte *_dataP;
 public:
 	/**
 	 * Constructor
@@ -217,8 +216,6 @@ public:
 	 */
 	void init();
 
-	void setPointer(MSurface *s);
-
 	/**
 	 * Copys an area of the screen surface to a given destination position on
 	 * the ScummVM physical screen buffer
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index cd838f7..85e36d6 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -400,9 +400,9 @@ void SpriteSets::remove(int idx) {
 	if (idx >= 0) {
 		delete (*this)[idx];
 
-		if (idx < ((int)size() - 1))
+		if (idx < ((int)size() - 1)) {
 			(*this)[idx] = nullptr;
-		else {
+		} else {
 			do {
 				remove_at(size() - 1);
 			} while (size() > 0 && (*this)[size() - 1] == nullptr);
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 13d5569..4348d83 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -163,10 +163,6 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 
 	// Mark areas of the screen surface for updating
 	if (updateFlag) {
-		_vm->_screen.setPointer(&userInterface);
-		userInterface.setBounds(Common::Rect(0, scene._interfaceY,
-			MADS_SCREEN_WIDTH - 1, userInterface.h + scene._interfaceY - 1));
-
 		for (uint idx = 0; idx < size(); ++idx) {
 			DirtyArea &dirtyArea = userInterface._dirtyAreas[idx];
 
@@ -502,10 +498,6 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
 	}
 }
 
-void UserInterface::setBounds(const Common::Rect &r) {
-	_drawBounds = r;
-}
-
 void UserInterface::loadElements() {
 	Scene &scene = _vm->_game->_scene;
 	Common::Rect bounds;
@@ -881,9 +873,6 @@ void UserInterface::updateSelection(ScrCategory category, int newIndex, int *idx
 }
 
 void UserInterface::updateRect(const Common::Rect &bounds) {
-	_vm->_screen.setPointer(&_surface);
-	setBounds(Common::Rect(0, MADS_SCENE_HEIGHT, MADS_SCREEN_WIDTH - 1, MADS_SCREEN_HEIGHT));
-
 	Common::Rect r = bounds;
 	r.translate(0, MADS_SCENE_HEIGHT);
 	_vm->_screen.copyRectToScreen(r);
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index f069173..52512ef 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -164,7 +164,6 @@ public:
 	UISlots _uiSlots;
 	DirtyAreas _dirtyAreas;
 	ScrCategory _category;
-	Common::Rect _drawBounds;
 	Common::Rect *_rectP;
 	int _inventoryTopIndex;
 	int _selectedInvIndex;
@@ -199,8 +198,6 @@ public:
 
 	void drawTextElements();
 
-	void setBounds(const Common::Rect &r);
-
 	/**
 	 * Loads the animation sprite data for a given inventory object
 	 */


Commit: dea63c9fe8b64c30464119ffbfbc3491e6f158cc
    https://github.com/scummvm/scummvm/commit/dea63c9fe8b64c30464119ffbfbc3491e6f158cc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-15T22:56:52-04:00

Commit Message:
MADS: Renaming for sprite cycle triggers

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/sequence.cpp
    engines/mads/sequence.h



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 1de0dcd..ec81b5f 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -114,7 +114,7 @@ void Scene101::sayDang() {
 		_scene->_sequences.remove(_globals._sequenceIndexes[11]);
 		_globals._sequenceIndexes[11] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[11], false, 3, 6, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], 17, 21);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_0, 0, 72);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SEQUENCE_TRIGGER_EXPIRE, 0, 72);
 		_vm->_sound->command(17);
 		_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 3, 2, 0, 0);
 		break;
@@ -152,7 +152,7 @@ void Scene101::enter() {
 	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 0, 0, 25);
 	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 4, 0, 1, 0);
 	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 2, 0);
-	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_FRAME_INDEX, 7, 70);
+	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 7, 70);
 	_globals._sequenceIndexes[4] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[4], false, 10, 0, 0, 60);
 	_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 5, 0, 1, 0);
 	_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 10, 0, 2, 0);
@@ -278,7 +278,7 @@ void Scene101::preActions() {
 				_game._player._stepEnabled = false;
 				_scene->_sequences.remove(_globals._sequenceIndexes[11]);
 				_globals._sequenceIndexes[11] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[11], false, 3, 1, 0, 0);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_0, 0, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], 1, 17);
 				_vm->_sound->command(16);
 				break;
@@ -304,7 +304,7 @@ void Scene101::preActions() {
 				_scene->_sequences.remove(_globals._sequenceIndexes[13]);
 				_shieldSpriteIdx = _game._objects.isInRoom(0x18) ? 13 : 14;
 				_globals._sequenceIndexes[13] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[_shieldSpriteIdx], false, 6, 1, 0, 0);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SM_0, 0, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 				_game._player._stepEnabled = false;
 				_vm->_sound->command(20);
 			}
@@ -339,8 +339,8 @@ void Scene101::actions() {
 				_scene->_sequences.remove(_globals._sequenceIndexes[12]);
 				_globals._sequenceIndexes[11] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 1);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], 1, 17);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_FRAME_INDEX, 10, 1);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_0, 0, 2);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SEQUENCE_TRIGGER_SPRITE, 10, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
 				_action._inProgress = false;
@@ -376,7 +376,7 @@ void Scene101::actions() {
 		case 0:
 			_shieldSpriteIdx = _game._objects.isInRoom(0x18) ? 13 : 14;
 			_globals._sequenceIndexes[13] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[_shieldSpriteIdx], false, 6, 1, 0, 0);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SM_0, 0, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			_game._player._stepEnabled = false;
 			_vm->_sound->command(20);
 			break;
@@ -436,13 +436,13 @@ void Scene101::actions() {
 				_scene->_sequences.remove(_globals._sequenceIndexes[11]);
 				_globals._sequenceIndexes[11] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 1, 0, 0);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], 17, 21);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_0, 0, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 				_vm->_sound->command(17);
 				break;
 
 			case 1:
 				_globals._sequenceIndexes[11] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[11], false, 3, 1, 0, 0);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_0, 0, 2);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], 17, 21);
 				break;
 
@@ -450,7 +450,7 @@ void Scene101::actions() {
 				_globals._sequenceIndexes[11] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 0, 0, 0);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], 17, 17);
 				_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 3, 1, 0, 0);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 3);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
 				break;
 
 			case 3:
@@ -653,7 +653,7 @@ void Scene102::enter() {
 		_game._player._playerPos = Common::Point(229, 109);
 		_game._player._stepEnabled = false;
 		_globals._sequenceIndexes[6] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[6], false, 6, 1, 2, 0);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SM_0, 0, 70);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
 	} else if (_scene->_priorSceneId == 103) {
 		_game._player._playerPos = Common::Point(47, 152);
 	} else if (_scene->_priorSceneId != -2) {
@@ -671,7 +671,7 @@ void Scene102::enter() {
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
 		_globals._sequenceIndexes[13] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[13], false, 6, 1, 0, 0);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SM_0, 0, 72);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 72);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 5);
 		_vm->_sound->command(24);
 		_vm->_sound->command(28);
@@ -750,7 +750,7 @@ void Scene102::preActions() {
 			if (_game._player._needToWalk) {
 				_scene->_sequences.remove(_globals._sequenceIndexes[7]);
 				_globals._sequenceIndexes[7] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[7], false, 6, 1, 0, 0);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_0, 0, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 15);
 				_game._player._stepEnabled = false;
 				_vm->_sound->command(20);
@@ -786,7 +786,7 @@ void Scene102::actions() {
 		case 0:
 			_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 6, 1, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 15);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_0, 0, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			if (_game._objects.isInRoom(OBJ_BURGER)) {
 				_globals._sequenceIndexes[10] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[10], false, 7, 0, 0, 0);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 14);
@@ -862,7 +862,7 @@ void Scene102::actions() {
 		switch (_game._trigger) {
 		case 0:
 			_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 1, 0, 0);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SM_0, 0, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			_game._player._stepEnabled = false;
 			_vm->_sound->command(20);
 			break;
@@ -1067,7 +1067,7 @@ void Scene102::actions() {
 		case 0:
 			_scene->_sequences.remove(_globals._sequenceIndexes[8]);
 			_globals._sequenceIndexes[8] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			_game._player._stepEnabled = false;
 			_vm->_sound->command(21);
 			break;
@@ -1090,7 +1090,7 @@ void Scene102::actions() {
 		switch (_game._trigger) {
 		case 0:
 			_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			_game._player._stepEnabled = false;
 			_vm->_sound->command(21);
 			break;
@@ -1121,7 +1121,7 @@ void Scene102::actions() {
 		case 0:
 			_globals._sequenceIndexes[11] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[11], false, 3, 1, 0, 0);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[11]);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_0, 0, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			_game._player._visible = false;
 			_game._player._stepEnabled = false;
 			break;
@@ -1219,9 +1219,9 @@ void Scene103::enter() {
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 0);
 
 	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 25);	
-	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_FRAME_INDEX, 2, 72);
+	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 2, 72);
 	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 1, 37);
-	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_FRAME_INDEX, 2, 73);
+	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 2, 73);
 
 	_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8);
 	_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 6);
@@ -1251,7 +1251,7 @@ void Scene103::enter() {
 		_game._player._stepEnabled = false;
 
 		_globals._sequenceIndexes[6] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[6], false, 6, 1, 0, 0);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SM_0, 0, 70);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
 	}
 
 	sceneEntrySound();
@@ -1320,7 +1320,7 @@ void Scene103::actions() {
 		switch (_vm->_game->_trigger) {
 		case 0:
 			_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 1);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SM_0, 0, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			_game._player._stepEnabled = false;
 			_vm->_sound->command(20);
 			break;
@@ -1340,8 +1340,8 @@ void Scene103::actions() {
 			_scene->changeVariant(1);
 			_globals._sequenceIndexes[13] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[13], false, 3, 2);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[13]);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SM_FRAME_INDEX, 7, 1);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SM_0, 0, 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_SPRITE, 7, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 			_vm->_game->_player._visible = false;
 			_vm->_game->_player._stepEnabled = false;
 			break;
@@ -1370,8 +1370,8 @@ void Scene103::actions() {
 			_scene->changeVariant(1);
 			_globals._sequenceIndexes[12] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[12], false, 3, 2);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[12]);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SM_FRAME_INDEX, 6, 1);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SM_0, 0, 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_SPRITE, 6, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 			_vm->_game->_player._visible = false;
 			_vm->_game->_player._stepEnabled = false;
 			break;
@@ -1411,7 +1411,7 @@ void Scene103::actions() {
 				_scene->_sequences.addTimer(120, _vm->_game->_trigger + 1);
 			} else {
 				// Initial turky explosion
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SM_0, 0, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			}
 		}
 
@@ -1569,7 +1569,7 @@ void Scene104::step() {
 				_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], mirrorFl, 7, 1, 0, 0);
 				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(198, 143));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_0, 0, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 				break;
 
 			case 1:
@@ -1600,7 +1600,7 @@ void Scene104::step() {
 				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(198, 143));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 4);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 14);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 				break;
 
 			case 1:
@@ -1608,7 +1608,7 @@ void Scene104::step() {
 				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(198, 143));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 4);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 15, 32);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 2);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 				break;
 
 			case 2:
@@ -1638,9 +1638,9 @@ void Scene104::step() {
 				_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 8, 1, 0, 0);
 				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(198, 143));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 4);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 				if (_game._storyMode >= STORYMODE_NICE)
-					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_FRAME_INDEX, 15, 2);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 15, 2);
 				break;
 
 			case 1:
@@ -1755,10 +1755,10 @@ void Scene105::step() {
 
 			_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 6, 1, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[0], 8);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SM_0, 0, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 
 			if (_game._storyMode >= STORYMODE_NICE)
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SM_FRAME_INDEX, 8, 3);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_SPRITE, 8, 3);
 			break;
 
 		case 1:
@@ -1769,7 +1769,7 @@ void Scene105::step() {
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], _globals._sequenceIndexes[0]);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 8);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 5, 7);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_0, 0, 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 			break;
 
 		case 2: {
@@ -1877,7 +1877,7 @@ void Scene106::enter() {
 
 	if (_scene->_priorSceneId == 102) {
 		_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 6, 1, 4, 0);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SM_0, 0, 70);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
 		_game._player._visible = false;
 		_game._player._stepEnabled = false;
 		_game._player._facing = FACING_EAST;
@@ -1921,7 +1921,7 @@ void Scene106::step() {
 			_scene->loadAnimation(Resources::formatName(106, 'A', -1, EXT_AA, ""), 75);
 		} else {
 			_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 4, 1, 0, 0);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SM_FRAME_INDEX, 28, 71);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_SPRITE, 28, 71);
 		}
 	}
 
@@ -1986,8 +1986,8 @@ void Scene106::step() {
 			if (_game._player._playerPos.x < 204) {
 				_shadowFl = true;
 				_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 4, 1, 0, 0);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 72);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_FRAME_INDEX, 44, 73);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 72);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 44, 73);
 			}
 		} else if (_game._trigger == 73)
 				_game._player._visible = false;
@@ -2098,7 +2098,7 @@ void Scene107::enter() {
 		_globals._spriteIndexes[0] = _scene->_sprites.addSprites(Resources::formatName(105, 'R', 1, EXT_SS, ""));
 		_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], true, 4, 0, 0, 0);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[0], Common::Point(270, 150));
-		_scene->_sequences.sub70C52(_globals._sequenceIndexes[0], SM_FRAME_INDEX, -200, 0);
+		_scene->_sequences.sub70C52(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_SPRITE, -200, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[0], 2);
 		_scene->_dynamicHotspots.add(218, 348, _globals._sequenceIndexes[0], Common::Rect(0, 0, 0, 0));
 	}
@@ -2357,8 +2357,8 @@ void Scene109::step() {
 			if (_game._player._playerPos.x > 205) {
 				_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6, 1, 0, 0);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 4);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_FRAME_INDEX, 6, 70);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 71);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 6, 70);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
 
 				_eatingRex = true;
 				_vm->_sound->command(34);
@@ -2396,8 +2396,8 @@ void Scene109::step() {
 	if (_eatingFirstFish && (_scene->_sequences[_globals._sequenceIndexes[10]]._msgPos.x >= 178)) {
 		_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 4, 1, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 4);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SM_FRAME_INDEX, 29, 72);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SM_0, 29, 73);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_SPRITE, 29, 72);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 29, 73);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[10], _globals._sequenceIndexes[9]);
 		_eatingFirstFish = false;
 		_game._player._stepEnabled = true;
@@ -2464,7 +2464,7 @@ void Scene109::actions() {
 						_game._objects.setRoom(_throwingObjectId, NOWHERE);
 						_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 4, 1, 0, 0);
 						_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[0]);
-						_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SM_0, 0, 1);
+						_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 						_game._player._visible = false;
 						_game._player._stepEnabled = false;
 
@@ -2489,23 +2489,23 @@ void Scene109::actions() {
 						switch (_throwingObjectId) {
 						case OBJ_BURGER:
 							_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, (_hoovicDifficultFl ? 4 : 6), 1, 0, 0);
-							_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_FRAME_INDEX, 2, 2);
+							_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 2, 2);
 							if (_hoovicDifficultFl) {
 								_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 30);
-								_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 5);
+								_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 5);
 							} else {
 								_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 4);
-								_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 8);
+								_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 8);
 								_hoovicTrigger = 3;
 							}
 							break;
 						case OBJ_DEAD_FISH:
 							_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 4, 1, 0, 0);
-							_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SM_FRAME_INDEX, 2, 2);
+							_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_SPRITE, 2, 2);
 							break;
 						case OBJ_STUFFED_FISH:
 							_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 4, 1, 0, 0);
-							_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_FRAME_INDEX, 2, 2);
+							_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 2, 2);
 							_hoovicTrigger = 3;
 							break;
 						}
@@ -2518,7 +2518,7 @@ void Scene109::actions() {
 							_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 4, 1, 0, 0);
 
 						_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 4);
-						_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, _hoovicTrigger);
+						_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, _hoovicTrigger);
 						_vm->_sound->command(34);
 						break;
 
@@ -2596,7 +2596,7 @@ void Scene109::actions() {
 						_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 31, 46);
 						int idx = _scene->_dynamicHotspots.add(53, 348, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
 						_scene->_dynamicHotspots.setPosition(idx, Common::Point(-3, 0), FACING_NORTHEAST);
-						_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 7);
+						_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 7);
 						}
 						break;
 
@@ -2799,11 +2799,11 @@ void Scene111::enter() {
 	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('B', 2));
 
 	_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 8, 0, 0, 0);
-	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SM_FRAME_INDEX, 9, 73);
-	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SM_FRAME_INDEX, 13, 73);
+	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_SPRITE, 9, 73);
+	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_SPRITE, 13, 73);
 
 	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 0, 0, 0);
-	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SM_FRAME_INDEX, 71, 71);
+	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_SPRITE, 71, 71);
 
 	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 0, 0, 0);
 	_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
@@ -2852,7 +2852,7 @@ void Scene111::step() {
 	if ((_game._trigger == 71) && !_stampedFl) {
 		_stampedFl = true;
 		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 18, 1, 0, 0);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_0, 0, 72);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 72);
 	}
 
 	if (_game._trigger == 72) {
@@ -2961,7 +2961,7 @@ void Scene112::step() {
 	if (_game._trigger == 70) {
 		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 7, 3, 0, 11);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 1);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 71);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
 	}
 
 	if (_game._trigger == 71) {
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 2e5ef35..36f2919 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -188,7 +188,7 @@ void Scene201::enter() {
 		_game._player._stepEnabled = false;
 		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 7, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], -1, 12);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SM_FRAME_INDEX, 12, 70);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_SPRITE, 12, 70);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 1);
 		_pterodactylFlag = false;
 		_game._player.walk(Common::Point(157, 143), FACING_NORTH);
@@ -222,9 +222,9 @@ void Scene201::step() {
 		_vm->_sound->command(42);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 1);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_FRAME_INDEX, 3, 81);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_0, 0, 71);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SM_0, 0, 73);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_SPRITE, 3, 81);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 73);
 	}
 
 	if (_game._trigger == 81) {
@@ -240,7 +240,7 @@ void Scene201::step() {
 	if (_game._trigger == 73) {
 		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 9, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 17, -2);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SM_0, 0, 74);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 74);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 1);
 	}
 
@@ -507,7 +507,7 @@ void Scene202::step() {
 		_globals._sequenceIndexes[9] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SM_0, 0, 91);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 91);
 		break;
 	case 91:
 		_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
@@ -519,7 +519,7 @@ void Scene202::step() {
 		_scene->_sequences.remove(_globals._sequenceIndexes[9]);
 		_globals._sequenceIndexes[11] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 6, 1, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[11], 1);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_0, 0, 93);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SEQUENCE_TRIGGER_EXPIRE, 0, 93);
 		_scene->_kernelMessages.reset();
 		int msgIndex = _scene->_kernelMessages.add(Common::Point(0, -65), 0x1110, 32, 0, 60, _game.getQuote(98));
 		_scene->_kernelMessages.setSeqIndex(msgIndex, _globals._sequenceIndexes[11]);
@@ -716,7 +716,7 @@ void Scene202::preActions() {
 			_scene->_sequences.remove(_globals._sequenceIndexes[9]);
 			_globals._sequenceIndexes[8] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 1);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 		} else if (_game._trigger == 1) {
 			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[8]);
 			_scene->_dynamicHotspots.remove(_ladderHotspotId);
@@ -764,8 +764,8 @@ void Scene202::actions() {
 						_game._player._visible = false;
 						_globals._sequenceIndexes[7] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[6], false, 3, 2, 0, 0);
 						_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[7]);
-						_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_FRAME_INDEX, 6, 1);
-						_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_0, 0, 2);
+						_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_SPRITE, 6, 1);
+						_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 					}
 					break;
 				case 1:
@@ -807,7 +807,7 @@ void Scene202::actions() {
 				_scene->_dynamicHotspots.setPosition(_ladderHotspotId, Common::Point(246, 124), FACING_NORTH);
 				_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 1);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 				break;
 			case 1: {
 				_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
@@ -835,7 +835,7 @@ void Scene202::actions() {
 					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
 					_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
 					_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[10]);
-					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SM_0, 0, 1);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 					break;
 				case 1:
 					_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
@@ -857,7 +857,7 @@ void Scene202::actions() {
 					_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
 					_scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 1, 6);
 					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
-					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SM_0, 0, 3);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
 					break;
 				case 3:
 					_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[10]);
@@ -877,7 +877,7 @@ void Scene202::actions() {
 					_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0);
 					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
 					_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
-					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SM_0, 0, 1);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 					break;
 				case 1:
 					_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, -2);
@@ -910,7 +910,7 @@ void Scene202::actions() {
 					_globals._sequenceIndexes[9] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
 					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
 					_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
-					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SM_0, 0, 3);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
 					break;
 				case 3:
 					_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
@@ -1167,9 +1167,9 @@ void Scene205::enter() {
 		_game._player._visible = false;
 		_game._player._stepEnabled = false;
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 2);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_FRAME_INDEX, 6, 73);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_FRAME_INDEX, 11, 74);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 0);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_SPRITE, 6, 73);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_SPRITE, 11, 74);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 0);
 	}
 	sceneEntrySound();
 }
@@ -1284,7 +1284,7 @@ void Scene207::enter() {
 	_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 10, 1, 0, 0);
 	_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 1, 22);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 6);
-	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SM_0, 0, 70);
+	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
 }
 
 void Scene207::moveVulture() {
@@ -1328,7 +1328,7 @@ void Scene207::step() {
 		_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 6);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 6);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_0, 0, 71);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
 		_eyeFl = true;
 	}
 }
@@ -1550,7 +1550,7 @@ void Scene208::subAction(int mode) {
 		else
 			abortVal = 2;
 
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SM_0, 0, abortVal);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, abortVal);
 		}
 		break;
 	case 1: {
@@ -1559,7 +1559,7 @@ void Scene208::subAction(int mode) {
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 3, 4);
 		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[5], oldVal);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SM_0, 0, 2);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 		_vm->_sound->command(20);
 		}
 		break;
@@ -1596,7 +1596,7 @@ void Scene208::subAction(int mode) {
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 3);
 		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[5], oldVal);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SM_0, 0, 3);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
 		}
 		break;
 	case 3:
@@ -1722,7 +1722,7 @@ void Scene209::handlePeek() {
 		_vm->_sound->command(18);
 		_globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 51, 52);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 134);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 134);
 		break;
 
 	case 134: {
@@ -1749,7 +1749,7 @@ void Scene209::handlePeek() {
 		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
 		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 51, 52);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 138);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 138);
 		break;
 
 	case 138:
@@ -1765,7 +1765,7 @@ void Scene209::handleVerticalMove() {
 	case 140:
 		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 8, 0, 1);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 5);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 141);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 141);
 		break;
 
 	case 141: {
@@ -1781,7 +1781,7 @@ void Scene209::handleVerticalMove() {
 		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
 		_globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 5);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 143);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 143);
 		break;
 
 	case 143:
@@ -1799,7 +1799,7 @@ void Scene209::handleLookStay() {
 		_monkeyPosition = 2;
 		_globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 51, 52);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 146);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 146);
 		break;
 
 	case 146: {
@@ -1840,7 +1840,7 @@ void Scene209::handleLookRight() {
 		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
 		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 8, 2, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 8, 14);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 152);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 152);
 		break;
 
 	case 152: {
@@ -1895,11 +1895,11 @@ void Scene209::handleGetBinoculars() {
 		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
 		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 8, 24);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_FRAME_INDEX, 20, 165);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 20, 165);
 		if (!_fallFl && !_dodgeFl) {
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 162);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 162);
 		} else {
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 163);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 163);
 		}
 		break;
 
@@ -1908,7 +1908,7 @@ void Scene209::handleGetBinoculars() {
 		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 8, 6, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 23, 25);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 163);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 163);
 		}
 		break;
 
@@ -1941,7 +1941,7 @@ void Scene209::handleBinocularBlink() {
 		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 8, 2, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 23, 25);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 168);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 168);
 		}
 		break;
 
@@ -1970,7 +1970,7 @@ void Scene209::handleBinocularScan() {
 		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 2, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 43, 45);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 172);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 172);
 		}
 		break;
 
@@ -1987,7 +1987,7 @@ void Scene209::handleBinocularScan() {
 		}
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 23, 25);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 173);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 173);
 		}
 		break;
 
@@ -1996,7 +1996,7 @@ void Scene209::handleBinocularScan() {
 		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 2, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 26, 30);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 174);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 174);
 		}
 		break;
 
@@ -2032,7 +2032,7 @@ void Scene209::handleJumpInTree() {
 		if (!_removeMonkeyFl)
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
 
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 179);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 179);
 		}
 		break;
 
@@ -2042,7 +2042,7 @@ void Scene209::handleJumpInTree() {
 		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 53, 61);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 180);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 180);
 		}
 		break;
 
@@ -2063,7 +2063,7 @@ void Scene209::handleTongue() {
 		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 26, 30);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 183);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 183);
 		}
 		break;
 
@@ -2072,7 +2072,7 @@ void Scene209::handleTongue() {
 		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 31, 33);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 184);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 184);
 		}
 		break;
 
@@ -2081,7 +2081,7 @@ void Scene209::handleTongue() {
 		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 36, 37);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 185);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 185);
 		}
 		break;
 
@@ -2091,7 +2091,7 @@ void Scene209::handleTongue() {
 		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 6, 20, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 38, 39);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 186);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 186);
 		}
 		break;
 
@@ -2100,7 +2100,7 @@ void Scene209::handleTongue() {
 		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 40, 41);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 178);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 178);
 		_removeMonkeyFl = false;
 		}
 		break;
@@ -2126,7 +2126,7 @@ void Scene209::handleStandFromPeek() {
 		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
 		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 8, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 1, 5);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SM_0, 0, 192);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 192);
 		break;
 
 	case 192: {
@@ -2185,7 +2185,7 @@ void Scene209::handleJumpAndHide() {
 		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 		_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 8, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 16);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SM_0, 0, 197);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 197);
 		break;
 
 	case 197:
@@ -2203,7 +2203,7 @@ void Scene209::handleMonkeyEating() {
 		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 10, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 1, 14);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 200);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 200);
 		break;
 
 	case 200: {
@@ -2211,7 +2211,7 @@ void Scene209::handleMonkeyEating() {
 		_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 10, 10, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 15, 16);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 201);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 201);
 		}
 		break;
 
@@ -2239,7 +2239,7 @@ void Scene209::handleMonkeyEating() {
 		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 		_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 10, 8, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 18, 19);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 205);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 205);
 		break;
 
 	case 205: {
@@ -2247,7 +2247,7 @@ void Scene209::handleMonkeyEating() {
 		_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 10, 8, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 20, 21);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 206);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 206);
 		}
 		break;
 
@@ -2257,9 +2257,9 @@ void Scene209::handleMonkeyEating() {
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 22, 25);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], oldIdx);
 		if (!_dodgeFl && !_fallFl)
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 207);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 207);
 		else
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 209);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 209);
 		}
 		break;
 
@@ -2272,7 +2272,7 @@ void Scene209::handleMonkeyEating() {
 		_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 15, 4, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 26, 27);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 208);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 208);
 		}
 		break;
 
@@ -2282,7 +2282,7 @@ void Scene209::handleMonkeyEating() {
 		_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 10, 4, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 28, 29);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 209);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 209);
 		}
 		break;
 
@@ -2320,7 +2320,7 @@ void Scene209::handleMonkeyFall() {
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 1, 35);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 6);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 220);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 220);
 		}
 		break;
 
@@ -2335,7 +2335,7 @@ void Scene209::handleMonkeyFall() {
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 36, 42);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 6);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 221);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 221);
 		}
 		break;
 
@@ -2350,7 +2350,7 @@ void Scene209::handleMonkeyFall() {
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[8], oldIdx);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 43, 72);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 222);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 222);
 		int idx = _scene->_dynamicHotspots.add(39, 13, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(200, 133), FACING_NORTH);
 		}
@@ -2362,7 +2362,7 @@ void Scene209::handleMonkeyFall() {
 		_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 73, 78);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[8], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SM_0, 0, 223);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 223);
 		}
 		break;
 
@@ -2388,7 +2388,7 @@ void Scene209::handleMonkey1() {
 		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 9, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 1, 13);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 213);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 213);
 		break;
 
 	case 213: {
@@ -2396,7 +2396,7 @@ void Scene209::handleMonkey1() {
 		_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 7, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[7], 1, 22);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[7], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_0, 0, 214);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 214);
 		}
 		break;
 
@@ -2405,7 +2405,7 @@ void Scene209::handleMonkey1() {
 		_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 7, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[7], 23, 26);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[7], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_0, 0, 215);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 215);
 		int msgIndex = _scene->_kernelMessages.add(Common::Point(170, 21), 0xFDFC, 0, 0, 90, _game.getQuote(156));
 		_scene->_kernelMessages.setQuoted(msgIndex, 3, true);
 		}
@@ -2418,7 +2418,7 @@ void Scene209::handleMonkey1() {
 		_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 7, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[7], 27, 35);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[7], oldIdx);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SM_0, 0, 216);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 216);
 		}
 		break;
 
@@ -2448,7 +2448,7 @@ void Scene209::handleMonkey2() {
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[12], Common::Point(111, 133));
 		_scene->_sequences.setScale(_globals._sequenceIndexes[12], 79);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[12], 1, 6);
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SM_0, 0, 252);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_EXPIRE, 0, 252);
 		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
 		_game._player._visible = false;
 		break;
@@ -2806,7 +2806,7 @@ void Scene209::step() {
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 7);
 			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_0, 0, 228);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 228);
 			break;
 
 		case 229: {
@@ -2825,7 +2825,7 @@ void Scene209::step() {
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 7);
 			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_0, 0, 231);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 231);
 			break;
 
 		case 231: {
@@ -2835,7 +2835,7 @@ void Scene209::step() {
 			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], oldIdx);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_0, 0, 232);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 232);
 			_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], -1);
 			_game._player._visible = false;
@@ -2869,14 +2869,14 @@ void Scene209::step() {
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 11, 12);
 				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_FRAME_INDEX, 12, 239);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_0, 0, 235);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 12, 239);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 235);
 			} else if (_action.isAction(NOUN_SHOOT, NOUN_BLOWGUN, NOUN_MONKEY)) {
 				_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 11, 12);
 				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_0, 0, 235);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 235);
 				_vm->_sound->command(23);
 			}
 			break;
@@ -2899,7 +2899,7 @@ void Scene209::step() {
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 14, 16);
 			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SM_0, 0, 237);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 237);
 			break;
 
 		case 237:
@@ -3124,8 +3124,8 @@ void Scene209::actions() {
 			_game._player._visible = false;
 			_globals._sequenceIndexes[11] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[11], false, 3, 2, 0, 0);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[11]);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_FRAME_INDEX, 4, 1);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SM_0, 0, 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SEQUENCE_TRIGGER_SPRITE, 4, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 			break;
 
 		case 1:
@@ -3156,8 +3156,8 @@ void Scene209::actions() {
 			_game._player._visible = false;
 			_globals._sequenceIndexes[10] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[10], false, 3, 2, 0, 0);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[10]);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SM_FRAME_INDEX, 4, 1);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SM_0, 0, 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_SPRITE, 4, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 			break;
 
 		case 1:
@@ -4193,7 +4193,7 @@ void Scene210::actions() {
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_globals._sequenceIndexes[1] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[1], false, 12, 1, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SM_0, 0, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			break;
 
 		case 1:
@@ -4216,7 +4216,7 @@ void Scene210::actions() {
 			_game._player._facing = FACING_NORTH;
 			_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 12, 0, 0, 1);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SM_0, 0, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			_game._player._stepEnabled = false;
 			break;
 		case 1:
@@ -4358,7 +4358,7 @@ void Scene211::enter() {
 		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(202, 126));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 8);
-		_scene->_sequences.sub70C52(_globals._sequenceIndexes[2], SM_FRAME_INDEX, -200, 0);
+		_scene->_sequences.sub70C52(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, -200, 0);
 		_scene->_dynamicHotspots.add(324, 13, _globals._sequenceIndexes[2], Common::Rect(1, 1, 41, 10));
 	}
 
@@ -4701,7 +4701,7 @@ void Scene214::step() {
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 4);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 2);
 		_scene->_dynamicHotspots.add(451, 13, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
-		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 71);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
 	}
 
 	if (_devilRunningFl) {
@@ -4713,7 +4713,7 @@ void Scene214::step() {
 			_scene->_dynamicHotspots.add(451, VERB_WALKTO, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 5, 8);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 2);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SM_0, 0, 72);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 72);
 			}
 			break;
 
@@ -4744,13 +4744,13 @@ void Scene214::actions() {
 			_game._player._visible   = false;
 			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], true, 6, 1, 0, 0);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			break;
 
 		case 1:
 			_globals._sequenceIndexes[4] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[4], true, 6, 1, 0, 0);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_game._objects.addToInventory(OBJ_POISON_DARTS);
 			_scene->_hotspots.activate(0x114, false);
@@ -4773,13 +4773,13 @@ void Scene214::actions() {
 			_game._player._visible = false;
 			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6, 1, 0, 0);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			break;
 
 		case 1:
 			_globals._sequenceIndexes[4] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[4], false, 6, 1, 0, 0);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SM_0, 0, 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 			_game._objects.addToInventory(OBJ_BLOWGUN);
 			_scene->_hotspots.activate(0x29, false);
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index c74fe44..601d07d 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -53,7 +53,7 @@ SequenceEntry::SequenceEntry() {
 	_timeout = 0;
 
 	_entries._count = 0;
-	Common::fill(&_entries._mode[0], &_entries._mode[SEQUENCE_ENTRY_SUBSET_MAX], SM_0);
+	Common::fill(&_entries._mode[0], &_entries._mode[SEQUENCE_ENTRY_SUBSET_MAX], KERNEL_TRIGGER_EXPIRE);
 	Common::fill(&_entries._frameIndex[0], &_entries._frameIndex[SEQUENCE_ENTRY_SUBSET_MAX], 0);
 	Common::fill(&_entries._trigger[0], &_entries._trigger[SEQUENCE_ENTRY_SUBSET_MAX], 0);
 }
@@ -80,7 +80,7 @@ void SequenceList::clear() {
 	}
 }
 
-bool SequenceList::addSubEntry(int index, SequenceSubEntryMode mode, int frameIndex, int trigger) {
+bool SequenceList::addSubEntry(int index, SequenceTrigger mode, int frameIndex, int trigger) {
 	if (_entries[index]._entries._count >= SEQUENCE_ENTRY_SUBSET_MAX)
 		return true;
 
@@ -162,7 +162,7 @@ int SequenceList::addTimer(int time, int abortVal) {
 	se._entries._count = 0;
 	se._triggerMode = _vm->_game->_triggerSetupMode;
 	se._actionNouns = _vm->_game->_scene._action._activeAction;
-	addSubEntry(seqIndex, SM_0, 0, abortVal);
+	addSubEntry(seqIndex, KERNEL_TRIGGER_EXPIRE, 0, abortVal);
 
 	return seqIndex;
 }
@@ -305,14 +305,14 @@ bool SequenceList::loadSprites(int seqIndex) {
 
 	for (int i = 0; i < seqEntry._entries._count; ++i) {
 		switch (seqEntry._entries._mode[i]) {
-		case SM_0:
-		case SM_1:
-			if (((seqEntry._entries._mode[i] == SM_0) && seqEntry._doneFlag) ||
-				((seqEntry._entries._mode[i] == SM_1) && result))
+		case KERNEL_TRIGGER_EXPIRE:
+		case KERNEL_TRIGGER_LOOP:
+			if (((seqEntry._entries._mode[i] == KERNEL_TRIGGER_EXPIRE) && seqEntry._doneFlag) ||
+				((seqEntry._entries._mode[i] == KERNEL_TRIGGER_LOOP) && result))
 				idx = i;
 			break;
 
-		case SM_FRAME_INDEX: {
+		case KERNEL_TRIGGER_SPRITE: {
 			int v = seqEntry._entries._frameIndex[i];
 			if ((v == seqEntry._frameIndex) || (v == 0))
 				idx = i;
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index 99e8951..53a8afe 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -32,7 +32,11 @@ namespace MADS {
 
 class SpriteSlot;
 
-enum SequenceSubEntryMode { SM_0 = 0, SM_1 = 1, SM_FRAME_INDEX = 2 };
+enum SequenceTrigger { 
+	SEQUENCE_TRIGGER_EXPIRE = 0,	// Trigger when the sequence finishes 
+	SEQUENCE_TRIGGER_LOOP = 1,		// Trigger when the sequence loops
+	SEQUENCE_TRIGGER_SPRITE = 2		// Trigger when sequence reaches specific sprite
+};
 
 enum SpriteAnimType { ANIMTYPE_NONE = 0, ANIMTYPE_CYCLED = 1, ANIMTYPE_REVERSIBLE = 2 };
 
@@ -40,7 +44,7 @@ enum SpriteAnimType { ANIMTYPE_NONE = 0, ANIMTYPE_CYCLED = 1, ANIMTYPE_REVERSIBL
 
 struct SequenceSubEntries {
 	int _count;
-	SequenceSubEntryMode _mode[SEQUENCE_ENTRY_SUBSET_MAX];
+	SequenceTrigger _mode[SEQUENCE_ENTRY_SUBSET_MAX];
 	int _frameIndex[SEQUENCE_ENTRY_SUBSET_MAX];
 	int8 _trigger[SEQUENCE_ENTRY_SUBSET_MAX];
 };
@@ -95,7 +99,7 @@ public:
 
 	SequenceEntry &operator[](int index) { return _entries[index]; }
 	void clear();
-	bool addSubEntry(int index, SequenceSubEntryMode mode, int frameIndex, int trigger);
+	bool addSubEntry(int index, SequenceTrigger mode, int frameIndex, int trigger);
 	int add(int spriteListIndex, bool flipped, int frameIndex, int triggerCountdown, int delayTicks,
 		int extraTicks, int numTicks, int msgX, int msgY, bool nonFixed, char scale, uint8 depth,
 		int frameInc, SpriteAnimType animType, int numSprites, int frameStart);


Commit: 0b340a034330fd5124b1534544a8ef9500349411
    https://github.com/scummvm/scummvm/commit/0b340a034330fd5124b1534544a8ef9500349411
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-15T23:51:41-04:00

Commit Message:
MADS: Fix depth issues with sitting in chair in scene 101

Changed paths:
    engines/mads/action.h
    engines/mads/animation.cpp
    engines/mads/game.cpp
    engines/mads/messages.cpp
    engines/mads/msurface.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/scene.cpp
    engines/mads/scene_data.cpp
    engines/mads/sequence.cpp
    engines/mads/sequence.h



diff --git a/engines/mads/action.h b/engines/mads/action.h
index 6b3f1ca..599fb0e 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -29,9 +29,9 @@
 namespace MADS {
 
 enum TriggerMode { 
-	KERNEL_TRIGGER_PARSER = 0,		// Triggers parser
-	KERNEL_TRIGGER_DAEMON = 1,		// Triggers step/daemon code
-	KERNEL_TRIGGER_PREPARE = 2		// Triggers preparser
+	SEQUENCE_TRIGGER_PARSER = 0,		// Triggers parser
+	SEQUENCE_TRIGGER_DAEMON = 1,		// Triggers step/daemon code
+	SEQUENCE_TRIGGER_PREPARE = 2		// Triggers preparser
 };
 
 enum InterAwaiting {
diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 06eeaf8..93cc72f 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -590,7 +590,7 @@ void Animation::update() {
 			_vm->_game->_trigger = _trigger;
 			_vm->_game->_triggerMode = _triggerMode;
 
-			if (_triggerMode != KERNEL_TRIGGER_DAEMON) {
+			if (_triggerMode != SEQUENCE_TRIGGER_DAEMON) {
 				// Copy the noun list
 				scene._action._action = _actionDetails;
 			}
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index a665055..bf3822d 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -57,8 +57,8 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 	_aaName = "*I0.AA";
 	_priorFrameTimer = 0;
 	_anyEmergency = false;
-	_triggerMode = KERNEL_TRIGGER_PARSER;
-	_triggerSetupMode = KERNEL_TRIGGER_DAEMON;
+	_triggerMode = SEQUENCE_TRIGGER_PARSER;
+	_triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 	_winStatus = 0;
 	_widepipeCtr = 0;
 
@@ -238,7 +238,7 @@ void Game::sectionLoop() {
 		_priorFrameTimer = _scene._frameStartTime;
 
 		// Call the scene logic for entering the given scene
-		_triggerSetupMode = KERNEL_TRIGGER_DAEMON;
+		_triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_scene._sceneLogic->enter();
 
 		// Set player data
diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index 3903b71..46b05c1 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -179,7 +179,7 @@ void KernelMessages::processText(int msgIndex) {
 			_vm->_game->_trigger = msg._trigger;
 			_vm->_game->_triggerMode = msg._abortMode;
 
-			if (_vm->_game->_triggerMode != KERNEL_TRIGGER_DAEMON) {
+			if (_vm->_game->_triggerMode != SEQUENCE_TRIGGER_DAEMON) {
 				scene._action._activeAction = msg._actionDetails;
 			}
 		}
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 8f40173..2c9d093 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -516,7 +516,7 @@ int DepthSurface::getDepth(const Common::Point &pt) {
 		return v >> bits;
 	} else {
 		if (pt.x < 0 || pt.y < 0 || pt.x >= this->w || pt.y >= this->h)
-			return 8;
+			return 0;
 
 		return *getBasePtr(pt.x, pt.y) & 0xF;
 	}
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index ec81b5f..bb5229e 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -106,7 +106,7 @@ void Scene101::setup() {
 }
 
 void Scene101::sayDang() {
-	_game._triggerSetupMode = KERNEL_TRIGGER_DAEMON;
+	_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 	_game._player._stepEnabled = false;
 
 	switch (_game._trigger) {
@@ -608,7 +608,7 @@ void Scene102::setup() {
 
 void Scene102::addRandomMessage() {
 	_scene->_kernelMessages.reset();
-	_game._triggerSetupMode = KERNEL_TRIGGER_DAEMON;
+	_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 	int quoteId = _vm->getRandomNumber(65, 69);
 	_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 73, 120, _game.getQuote(quoteId));
 	_activeMsgFl = true;
@@ -838,7 +838,7 @@ void Scene102::actions() {
 		Common::String curQuote = _game.getQuote(quoteId);
 		int width = _vm->_font->getWidth(curQuote, -1);
 		_scene->_kernelMessages.reset();
-		_game._triggerSetupMode = KERNEL_TRIGGER_DAEMON;
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_scene->_kernelMessages.add(Common::Point(210, 60), 0x1110, 0, 73, 120, curQuote);
 		_scene->_kernelMessages.add(Common::Point(214 + width, 60), 0x1110, 0, 73, 120, _game.getQuote(64));
 		_activeMsgFl = true;
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 36f2919..96f6c6d 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -455,7 +455,7 @@ void Scene202::enter() {
 void Scene202::setRandomKernelMessage() {
 	int vocabId = _vm->getRandomNumber(92, 96);
 	_scene->_kernelMessages.reset();
-	_game._triggerSetupMode = KERNEL_TRIGGER_DAEMON;
+	_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 	_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 70, 120, _game.getQuote(vocabId));
 	_activeMsgFl = true;
 }
@@ -491,7 +491,7 @@ void Scene202::step() {
 			_action._activeAction._verbId = VERB_LOOK;
 			_action._activeAction._objectNameId = 39;
 			_action._activeAction._indirectObjectId = 438;
-			_game._triggerSetupMode = KERNEL_TRIGGER_PARSER;
+			_game._triggerSetupMode = SEQUENCE_TRIGGER_PARSER;
 			_scene->_sequences.addTimer(120, 2);
 			_globals._abortVal = -1;
 		} else if (_globals[kMeteorologistWatch] == 2) {
@@ -3087,7 +3087,7 @@ void Scene209::actions() {
 		if ((_action.isAction(NOUN_SHOOT) || _action.isAction(NOUN_HOSE_DOWN)) && _action.isAction(NOUN_MONKEY)
 			&& _action.isAction(NOUN_BLOWGUN) && _game._objects.isInInventory(OBJ_BLOWGUN) && _game._objects.isInInventory(OBJ_POISON_DARTS)) {
 			if (_action.isAction(NOUN_SHOOT, NOUN_BLOWGUN, NOUN_MONKEY) && !_startShootingInTimerFl) {
-				_game._triggerSetupMode = KERNEL_TRIGGER_DAEMON;
+				_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 				_scene->_sequences.addTimer(1, 231);
 				_startShootingInTimerFl = true;
 				_game._player._stepEnabled = false;
@@ -3097,7 +3097,7 @@ void Scene209::actions() {
 			} 
 			
 			if (_action.isAction(NOUN_HOSE_DOWN, NOUN_BLOWGUN, NOUN_MONKEY) && !_startShootingInTimerFl) {
-				_game._triggerSetupMode = KERNEL_TRIGGER_DAEMON;
+				_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 				_scene->_sequences.addTimer(1, 228);
 				_game._player._stepEnabled = false;
 				_fallFl = true;
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index a112228..948688e 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -313,7 +313,7 @@ void Scene::doFrame() {
 		flag = true;
 	}
 
-	if (flag || (_vm->_game->_trigger && _vm->_game->_triggerMode == KERNEL_TRIGGER_PREPARE)) {
+	if (flag || (_vm->_game->_trigger && _vm->_game->_triggerMode == SEQUENCE_TRIGGER_PREPARE)) {
 		doPreactions();
 	}
 
@@ -324,7 +324,7 @@ void Scene::doFrame() {
 	// Handle parser actions as well as game triggers
 	if ((_action._inProgress && !player._moving && !player._needToWalk && 
 			(player._facing == player._turnToFacing) && !_vm->_game->_trigger) ||
-			(_vm->_game->_trigger && (_vm->_game->_triggerMode == KERNEL_TRIGGER_PARSER))) {
+			(_vm->_game->_trigger && (_vm->_game->_triggerMode == SEQUENCE_TRIGGER_PARSER))) {
 		doAction();
 	}
 
@@ -442,11 +442,11 @@ void  Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
 void Scene::doPreactions() {
 	if (_vm->_game->_screenObjects._inputMode == kInputBuildingSentences || 
 			_vm->_game->_screenObjects._inputMode == kInputLimitedSentences) {
-		_vm->_game->_triggerSetupMode = KERNEL_TRIGGER_PREPARE;
+		_vm->_game->_triggerSetupMode = SEQUENCE_TRIGGER_PREPARE;
 		_action.checkAction();
 		_sceneLogic->preActions();
 
-		if (_vm->_game->_triggerMode == KERNEL_TRIGGER_PREPARE)
+		if (_vm->_game->_triggerMode == SEQUENCE_TRIGGER_PREPARE)
 			_vm->_game->_trigger = 0;
 	}
 }
@@ -454,7 +454,7 @@ void Scene::doPreactions() {
 void Scene::doAction() {
 	bool flag = false;
 
-	_vm->_game->_triggerSetupMode = KERNEL_TRIGGER_PARSER;
+	_vm->_game->_triggerSetupMode = SEQUENCE_TRIGGER_PARSER;
 	if ((_action._inProgress || _vm->_game->_trigger) && !_action._savedFields._commandError) {
 		_sceneLogic->actions();
 		flag = !_action._inProgress;
@@ -491,17 +491,17 @@ void Scene::doAction() {
 	}
 
 	_action._inProgress = false;
-	if (_vm->_game->_triggerMode == KERNEL_TRIGGER_PARSER)
+	if (_vm->_game->_triggerMode == SEQUENCE_TRIGGER_PARSER)
 		_vm->_game->_trigger = 0;
 }
 
 void Scene::doSceneStep() {
-	_vm->_game->_triggerSetupMode = KERNEL_TRIGGER_DAEMON;
+	_vm->_game->_triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 	_sceneLogic->step();
 	_vm->_game->_sectionHandler->step();
 	_vm->_game->step();
 
-	if (_vm->_game->_triggerMode == KERNEL_TRIGGER_DAEMON)
+	if (_vm->_game->_triggerMode == SEQUENCE_TRIGGER_DAEMON)
 		_vm->_game->_trigger = 0;
 }
 
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index a82f65a..6eb6be2 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -41,7 +41,7 @@ KernelMessage::KernelMessage() {
 	_frameTimer = 0;
 	_timeout = 0;
 	_trigger = 0;
-	_abortMode = KERNEL_TRIGGER_PARSER;
+	_abortMode = SEQUENCE_TRIGGER_PARSER;
 	_actionDetails._verbId = VERB_NONE;
 	_actionDetails._objectNameId = 0;
 	_actionDetails._indirectObjectId = 0;
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 601d07d..3c2bab5 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -47,13 +47,13 @@ SequenceEntry::SequenceEntry() {
 	_field22 = 0;
 	_triggerCountdown = 0;
 	_doneFlag = 0;
-	_triggerMode = KERNEL_TRIGGER_DAEMON;
+	_triggerMode = SEQUENCE_TRIGGER_DAEMON;
 	_numTicks = 0;
 	_extraTicks = 0;
 	_timeout = 0;
 
 	_entries._count = 0;
-	Common::fill(&_entries._mode[0], &_entries._mode[SEQUENCE_ENTRY_SUBSET_MAX], KERNEL_TRIGGER_EXPIRE);
+	Common::fill(&_entries._mode[0], &_entries._mode[SEQUENCE_ENTRY_SUBSET_MAX], SEQUENCE_TRIGGER_EXPIRE);
 	Common::fill(&_entries._frameIndex[0], &_entries._frameIndex[SEQUENCE_ENTRY_SUBSET_MAX], 0);
 	Common::fill(&_entries._trigger[0], &_entries._trigger[SEQUENCE_ENTRY_SUBSET_MAX], 0);
 }
@@ -93,7 +93,7 @@ bool SequenceList::addSubEntry(int index, SequenceTrigger mode, int frameIndex,
 }
 
 int SequenceList::add(int spriteListIndex, bool flipped, int frameIndex, int triggerCountdown, int delayTicks, int extraTicks, int numTicks,
-	int msgX, int msgY, bool nonFixed, char scale, uint8 depth, int frameInc, SpriteAnimType animType, int numSprites,
+	int msgX, int msgY, bool nonFixed, int scale, int depth, int frameInc, SpriteAnimType animType, int numSprites,
 	int frameStart) {
 	Scene &scene = _vm->_game->_scene;
 
@@ -162,7 +162,7 @@ int SequenceList::addTimer(int time, int abortVal) {
 	se._entries._count = 0;
 	se._triggerMode = _vm->_game->_triggerSetupMode;
 	se._actionNouns = _vm->_game->_scene._action._activeAction;
-	addSubEntry(seqIndex, KERNEL_TRIGGER_EXPIRE, 0, abortVal);
+	addSubEntry(seqIndex, SEQUENCE_TRIGGER_EXPIRE, 0, abortVal);
 
 	return seqIndex;
 }
@@ -305,14 +305,14 @@ bool SequenceList::loadSprites(int seqIndex) {
 
 	for (int i = 0; i < seqEntry._entries._count; ++i) {
 		switch (seqEntry._entries._mode[i]) {
-		case KERNEL_TRIGGER_EXPIRE:
-		case KERNEL_TRIGGER_LOOP:
-			if (((seqEntry._entries._mode[i] == KERNEL_TRIGGER_EXPIRE) && seqEntry._doneFlag) ||
-				((seqEntry._entries._mode[i] == KERNEL_TRIGGER_LOOP) && result))
+		case SEQUENCE_TRIGGER_EXPIRE:
+		case SEQUENCE_TRIGGER_LOOP:
+			if (((seqEntry._entries._mode[i] == SEQUENCE_TRIGGER_EXPIRE) && seqEntry._doneFlag) ||
+				((seqEntry._entries._mode[i] == SEQUENCE_TRIGGER_LOOP) && result))
 				idx = i;
 			break;
 
-		case KERNEL_TRIGGER_SPRITE: {
+		case SEQUENCE_TRIGGER_SPRITE: {
 			int v = seqEntry._entries._frameIndex[i];
 			if ((v == seqEntry._frameIndex) || (v == 0))
 				idx = i;
@@ -328,7 +328,7 @@ bool SequenceList::loadSprites(int seqIndex) {
 		_vm->_game->_trigger = seqEntry._entries._trigger[idx];
 		_vm->_game->_triggerMode = seqEntry._triggerMode;
 
-		if (seqEntry._triggerMode != KERNEL_TRIGGER_DAEMON)
+		if (seqEntry._triggerMode != SEQUENCE_TRIGGER_DAEMON)
 			scene._action._activeAction = seqEntry._actionNouns;
 	}
 
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index 53a8afe..6d59175 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -101,7 +101,7 @@ public:
 	void clear();
 	bool addSubEntry(int index, SequenceTrigger mode, int frameIndex, int trigger);
 	int add(int spriteListIndex, bool flipped, int frameIndex, int triggerCountdown, int delayTicks,
-		int extraTicks, int numTicks, int msgX, int msgY, bool nonFixed, char scale, uint8 depth,
+		int extraTicks, int numTicks, int msgX, int msgY, bool nonFixed, int scale, int depth,
 		int frameInc, SpriteAnimType animType, int numSprites, int frameStart);
 	
 	int addTimer(int time, int abortVal);


Commit: eb26b70fc55e47a44faefba2fca9570850a25ff2
    https://github.com/scummvm/scummvm/commit/eb26b70fc55e47a44faefba2fca9570850a25ff2
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-16T07:44:22+02:00

Commit Message:
MADS: Fix rects in scene 202, 210, 211, implement scene 215

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index bf8e5b7..7f3a7a4 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -96,6 +96,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 
 	case 214:
 		return new Scene214(vm);
+	case 215:
+		return new Scene215(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 96f6c6d..45ea496 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -803,7 +803,7 @@ void Scene202::actions() {
 				_game._player._visible = false;
 				_game._player._stepEnabled = false;
 
-				_ladderHotspotId = _scene->_dynamicHotspots.add(199, 79, -1, Common::Rect(241, 68, 12, 54));
+				_ladderHotspotId = _scene->_dynamicHotspots.add(199, 79, -1, Common::Rect(241, 68, 241 + 12, 68 + 54));
 				_scene->_dynamicHotspots.setPosition(_ladderHotspotId, Common::Point(246, 124), FACING_NORTH);
 				_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 1);
@@ -3823,7 +3823,7 @@ void Scene210::enter() {
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 5);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
 	} else {
-		int idx = _scene->_dynamicHotspots.add(112, 395, -1, Common::Rect(163, 87, 19, 36)); 
+		int idx = _scene->_dynamicHotspots.add(112, 395, -1, Common::Rect(163, 87, 163 + 19, 87 + 36)); 
 		_doorway = _scene->_dynamicHotspots.setPosition(idx, Common::Point(168, 127), FACING_NORTH);
 		_scene->_dynamicHotspots.setCursor(_doorway, CURSOR_GO_UP);
 	}
@@ -4199,7 +4199,7 @@ void Scene210::actions() {
 		case 1:
 			_game._player._stepEnabled = true;
 			_globals[kCurtainOpen] = true;
-			_doorway = _scene->_dynamicHotspots.add(112, 395, -1, Common::Rect(163, 87, 19, 36));
+			_doorway = _scene->_dynamicHotspots.add(112, 395, -1, Common::Rect(163, 87, 163 + 19, 87 + 36));
 			_scene->_dynamicHotspots.setPosition(_doorway, Common::Point(168, 127), FACING_NORTH);
 			_scene->_dynamicHotspots.setCursor(_doorway, CURSOR_GO_UP);
 			break;
@@ -4359,7 +4359,7 @@ void Scene211::enter() {
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(202, 126));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 8);
 		_scene->_sequences.sub70C52(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, -200, 0);
-		_scene->_dynamicHotspots.add(324, 13, _globals._sequenceIndexes[2], Common::Rect(1, 1, 41, 10));
+		_scene->_dynamicHotspots.add(324, 13, _globals._sequenceIndexes[2], Common::Rect(1, 1, 1 + 41, 1 + 10));
 	}
 
 	if (_scene->_roomChanged)
@@ -4859,5 +4859,126 @@ void Scene214::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene215::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene215::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('e', 0));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 0));
+
+	_globals._sequenceIndexes[1]   = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[1], false, 7, 0, 0, 0);
+	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(235, 83));
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
+
+	if (_globals[kSexOfRex] == REX_MALE)
+		_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RXMRC_9");
+	else
+		_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*ROXRC_9");
+
+	if (_scene->_priorSceneId == 216) {
+		_game._player._playerPos = Common::Point(140, 119);
+		_game._player._facing = FACING_SOUTHWEST;
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+		_scene->_sequences.addTimer(120, 70);
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(204, 152);
+		_game._player._facing = FACING_NORTH;
+	}
+
+	_game.loadQuoteSet(0xA9, 0xAA, 0);
+	sceneEntrySound();
+}
+
+void Scene215::step() {
+	if (_game._trigger == 70) {
+		_scene->_sequences.remove (_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 1, 0, 0);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
+	}
+
+	if (_game._trigger == 71) {
+		_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[3]);
+		_game._player._visible = true;
+		_game._player._stepEnabled = true;
+	}
+}
+
+void Scene215::actions() {
+	if (_action._lookFlag)
+		_vm->_dialogs->show(0x5405);
+	else if (_action.isAction(VERB_TAKE, 0x17A)) {
+		if (!_game._objects.isInInventory(OBJ_TWINKIFRUIT) || _game._trigger) {
+			switch (_game._trigger) {
+			case 0:
+				if (_globals[kSexOfRex] == REX_MALE) {
+					_game._player._visible = false;
+					_game._player._stepEnabled = false;
+					_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 6, 2, 0, 0);
+					_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 4);
+					_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_LOOP, 0, 1);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				} else {
+					_game._objects.addToInventory(OBJ_TWINKIFRUIT);
+					_vm->_dialogs->showItem(OBJ_TWINKIFRUIT, 0x5404);
+				}
+				break;
+
+			case 1:
+				if (!_game._objects.isInInventory(OBJ_TWINKIFRUIT)) {
+					_game._objects.addToInventory(OBJ_TWINKIFRUIT);
+					_vm->_dialogs->showItem(OBJ_TWINKIFRUIT, 0x5404);
+				}
+				break;
+
+			case 2:
+				_game._player._visible   = true;
+				_game._player._stepEnabled = true;
+				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[2]);
+				break;
+			}
+		} else {
+			int idx = _vm->getRandomNumber(169, 170);
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(idx));
+		}
+	} else if (_action.isAction(0x18A, 0xAA))
+		_scene->_nextSceneId = 210;
+	else if (_action.isAction(VERB_LOOK, 0x21))
+		_vm->_dialogs->show(0x53FD);
+	else if (_action.isAction(VERB_LOOK, 0x1CB))
+		_vm->_dialogs->show(0x53FE);
+	else if (_action.isAction(VERB_LOOK, 0x3A3))
+		_vm->_dialogs->show(0x53FF);
+	else if (_action.isAction(VERB_LOOK, 0xD5))
+		_vm->_dialogs->show(0x5400);
+	else if (_action.isAction(VERB_LOOK, 0x197))
+		_vm->_dialogs->show(0x5401);
+	else if (_action.isAction(VERB_LOOK, 0x289))
+		_vm->_dialogs->show(0x5402);
+	else if (_action.isAction(VERB_LOOK, 0x17A) && (_action._savedFields._mainObjectSource == 4))
+		_vm->_dialogs->show(0x5403);
+	else if (_action.isAction(VERB_TAKE, 0x21))
+		_vm->_dialogs->show(0x5406);
+	else if (_action.isAction(VERB_TAKE, 0xD5))
+		_vm->_dialogs->show(0x5407);
+	else if (_action.isAction(VERB_LOOK, 0x1CA))
+		_vm->_dialogs->show(0x5408);
+	else if (_action.isAction(VERB_TAKE, 0x1CA))
+		_vm->_dialogs->show(0x5409);
+	else if (_action.isAction(VERB_TAKE, 0x3A3))
+		_vm->_dialogs->show(0x540A);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index c6ef759..c5a9cb8 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -281,6 +281,18 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene215: public Scene2xx {
+public:
+	Scene215(MADSEngine *vm) : Scene2xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: ec9c7166abe03e19a663082649fc5be12bc5dae5
    https://github.com/scummvm/scummvm/commit/ec9c7166abe03e19a663082649fc5be12bc5dae5
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-16T07:54:46+02:00

Commit Message:
MADS: Remove some useless accolades, implement scene 216

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 7f3a7a4..562f31c 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -98,6 +98,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene214(vm);
 	case 215:
 		return new Scene215(vm);
+	case 216:
+		return new Scene216(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 45ea496..6080c09 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -11,7 +11,7 @@
 
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
 
  * You should have received a copy of the GNU General Public License
@@ -4537,12 +4537,11 @@ void Scene211::preActions() {
 	&& (_scene->_customDest.x <= 52) && (_scene->_customDest.y >= 132))
 		_game._player.walk(Common::Point(52, 132), FACING_WEST);
 
-	if (_action.isAction(0x1AD, 0x1AE))  {
-		if (_game._objects.isInInventory(OBJ_BINOCULARS) && (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY) )  {
+	if (_action.isAction(0x1AD, 0x1AE)) {
+		if (_game._objects.isInInventory(OBJ_BINOCULARS) && (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY))
 			_game._player.walk(Common::Point(52, 132), FACING_WEST);
-		} else {
+		else
 			_game._player._walkOffScreenSceneId = 210;
-		}
 	}
 
 	if (_action.isAction(0x1AD, 0x1B1))
@@ -4550,16 +4549,16 @@ void Scene211::preActions() {
 }
 
 void Scene211::actions() {
-	if (_action._lookFlag && (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY))  {
+	if (_action._lookFlag && (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY))
 		_vm->_dialogs->show(0x5277);
-	} else if (_action.isAction(VERB_LOOK, 0x27, 0x100)) {
+	else if (_action.isAction(VERB_LOOK, 0x27, 0x100))
 		_vm->_dialogs->show(0x527C);
-	} else if (_action.isAction(VERB_LOOK, 0x3A)) {
+	else if (_action.isAction(VERB_LOOK, 0x3A))
 		_vm->_dialogs->show(0x526D);
-	} else if (_action.isAction(VERB_LOOK, 0x1B2)) {
+	else if (_action.isAction(VERB_LOOK, 0x1B2))
 		_vm->_dialogs->show(0x526E);
-	} else if (_action.isAction(VERB_LOOK, 0x100)) {
-		if (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY)  {
+	else if (_action.isAction(VERB_LOOK, 0x100)) {
+		if (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY) {
 			if (_game._storyMode == STORYMODE_NAUGHTY)
 				_vm->_dialogs->show(0x526F);
 			else
@@ -4572,19 +4571,19 @@ void Scene211::actions() {
 			_vm->_dialogs->show(0x5272);
 		else
 			_vm->_dialogs->show(0x5273);
-	} else if (_action.isAction(VERB_LOOK, 0xB8)) {
+	} else if (_action.isAction(VERB_LOOK, 0xB8))
 		_vm->_dialogs->show(0x5274);
-	} else if (_action.isAction(VERB_LOOK, 0x1B1)) {
+	else if (_action.isAction(VERB_LOOK, 0x1B1))
 		_vm->_dialogs->show(0x5275);
-	} else if (_action.isAction(VERB_LOOK, 0x1AE)) {
+	else if (_action.isAction(VERB_LOOK, 0x1AE))
 		_vm->_dialogs->show(0x5276);
-	} else if (_action.isAction(VERB_LOOK, 0x144)) {
+	else if (_action.isAction(VERB_LOOK, 0x144))
 		_vm->_dialogs->show(0x5279);
-	} else if (_action.isAction(VERB_TAKE, 0x144)) {
+	else if (_action.isAction(VERB_TAKE, 0x144))
 		_vm->_dialogs->show(0x527A);
-	} else if (_action.isAction(VERB_LOOK, 0x129)) {
+	else if (_action.isAction(VERB_LOOK, 0x129))
 		_vm->_dialogs->show(0x527B);
-	} else 
+	else 
 		return;
 
 	_action._inProgress = false;
@@ -4681,7 +4680,7 @@ void Scene214::enter() {
 	}
 
 	if (_game._objects.isInRoom(OBJ_BLOWGUN)) {
-		_globals._sequenceIndexes[2]  = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 0);
+		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 0);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(90, 87));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 13);
 	} else {
@@ -4741,7 +4740,7 @@ void Scene214::actions() {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
-			_game._player._visible   = false;
+			_game._player._visible = false;
 			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], true, 6, 1, 0, 0);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
@@ -4846,7 +4845,7 @@ void Scene214::actions() {
 			_vm->_dialogs->show(0x53AF);
 		} else if (_game._objects.isInRoom(OBJ_POISON_DARTS) && !_game._objects.isInRoom(OBJ_BLOWGUN)) {
 			_vm->_dialogs->show(0x53B0);
-		} else if (!_game._objects.isInRoom(OBJ_POISON_DARTS)  && _game._objects.isInRoom(OBJ_BLOWGUN)) {
+		} else if (!_game._objects.isInRoom(OBJ_POISON_DARTS) && _game._objects.isInRoom(OBJ_BLOWGUN)) {
 			_vm->_dialogs->show(0x53B1);
 		} else {
 			_vm->_dialogs->show(0x53B2);
@@ -4868,7 +4867,7 @@ void Scene215::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('e', 0));
 	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 0));
 
-	_globals._sequenceIndexes[1]   = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[1], false, 7, 0, 0, 0);
+	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[1], false, 7, 0, 0, 0);
 	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(235, 83));
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
 
@@ -4936,7 +4935,7 @@ void Scene215::actions() {
 				break;
 
 			case 2:
-				_game._player._visible   = true;
+				_game._player._visible = true;
 				_game._player._stepEnabled = true;
 				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[2]);
 				break;
@@ -4980,5 +4979,28 @@ void Scene215::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene216::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene216::enter() {
+	_game._player._stepEnabled = false;
+	_game._player._visible = false;
+
+	_scene->_userInterface.emptyTalkList();
+	_scene->_userInterface.setup(kInputConversation);
+	_scene->loadAnimation(formAnimName('A', -1), 60);
+
+	sceneEntrySound();
+}
+
+void Scene216::step() {
+	if (_game._trigger == 60)
+		_scene->_nextSceneId = 215;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index c5a9cb8..2537b11 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -293,6 +293,18 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene216: public Scene2xx {
+public:
+	Scene216(MADSEngine *vm) : Scene2xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions() {};
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 48f49eeb8029a36931373de1927aac8021783337
    https://github.com/scummvm/scummvm/commit/48f49eeb8029a36931373de1927aac8021783337
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-16T08:27:13-04:00

Commit Message:
MADS: Fix player/sprite setup/teardown for scene 112

Changed paths:
    engines/mads/game.cpp
    engines/mads/player.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index bf3822d..82a7b66 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -274,8 +274,8 @@ void Game::sectionLoop() {
 		_vm->_events->waitCursor();
 		_kernelMode = KERNEL_ROOM_PRELOAD;
 
-		delete _scene._animationData;
-		_scene._animationData = nullptr;
+		delete _scene._activeAnimation;
+		_scene._activeAnimation = nullptr;
 
 		_scene._reloadSceneFlag = false;
 
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index b55d3f0..9301fdc 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -201,6 +201,10 @@ void Player::selectSeries() {
 		_mirror = true;
 	}
 
+	// If the user isn't to be present (such as for a cutscene), exit immediately
+	if ((_spritesStart + _spritesIdx) < 0)
+		return;
+
 	SpriteAsset &spriteSet = *scene._sprites[_spritesStart + _spritesIdx];
 	assert(spriteSet._charInfo);
 	_velocity = MAX(spriteSet._charInfo->_velocity, 100);
@@ -219,6 +223,9 @@ void Player::selectSeries() {
 }
 
 void Player::updateFrame() {
+	if ((_spritesStart + _spritesIdx) < 0)
+		return;
+
 	Scene &scene = _vm->_game->_scene;
 	SpriteAsset &spriteSet = *scene._sprites[_spritesStart + _spritesIdx];
 	assert(spriteSet._charInfo);
@@ -490,6 +497,9 @@ void Player::idle() {
 		return;
 	}
 
+	if ((_spritesStart + _spritesIdx) < 0)
+		return;
+
 	SpriteAsset &spriteSet = *scene._sprites[_spritesStart + _spritesIdx];
 	assert(spriteSet._charInfo);
 	if (spriteSet._charInfo->_numEntries == 0)


Commit: 9f67216b11c8c744430d106f36a77068ed8e55d6
    https://github.com/scummvm/scummvm/commit/9f67216b11c8c744430d106f36a77068ed8e55d6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-16T08:44:12-04:00

Commit Message:
MADS: Fix to stop game ending when loading a cutscene scene

Changed paths:
    engines/mads/game.cpp
    engines/mads/player.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 82a7b66..d3e3987 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -288,11 +288,9 @@ void Game::sectionLoop() {
 		}
 
 		// Clear the scene
-		_scene.free();
+		_scene.freeCurrentScene();
 		_sectionNumber = _scene._nextSceneId / 100;
 
-		// TODO: sub_1DD46(3)
-
 		// Check whether to show a dialog
 		checkShowDialog();
 	}
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 9301fdc..cc482c0 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -135,7 +135,7 @@ bool Player::loadSprites(const Common::String &prefix) {
 	} else {
 		Common::fill(&_spriteSetsPresent[0], &_spriteSetsPresent[PLAYER_SPRITES_FILE_COUNT], false);
 		_highSprites = false;
-		return true;
+		return false;
 	}
 }
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 948688e..e2892fb 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -563,7 +563,7 @@ void Scene::updateCursor() {
 	}
 }
 
-void Scene::free() {
+void Scene::freeCurrentScene() {
 	if (_animationData) {
 		delete _animationData;
 		_animationData = nullptr;
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index e00924a..f18d6ad 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -207,9 +207,9 @@ public:
 	Common::String getVocab(int vocabId) { return _vocabStrings[vocabId - 1]; }
 
 	/**
-	 * Clear the data for the scene
+	 * Clear the data for the currently loaded scene
 	 */
-	void free();
+	void freeCurrentScene();
 
 	/**
 	 * Set the walk surface for a scene to a different variant


Commit: c2bf78848d26d51593ab4f08ad361bbf9fa2d13c
    https://github.com/scummvm/scummvm/commit/c2bf78848d26d51593ab4f08ad361bbf9fa2d13c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-16T09:24:10-04:00

Commit Message:
MADS: Fix drawing background sprites

Changed paths:
    engines/mads/assets.cpp
    engines/mads/assets.h
    engines/mads/sprites.cpp



diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index 3e18a67..bb6f5bd 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -203,16 +203,12 @@ MSprite *SpriteAsset::getFrame(int frameIndex) {
 
 void SpriteAsset::drawScaled(int frameNumber, MSurface &depthSurface, MSurface &destSurface,
 		int scale, int depth, const Common::Point &pos) {
-	warning("TODO: SpriteAsset::drawScaled");
-}
-
-void SpriteAsset::draw(MSurface *surface, int frameNumber, const Common::Point &pt) {
-	error("TODO: draw");
+	error("TODO: SpriteAsset::drawScaled - map to frame methods");
 }
 
 void SpriteAsset::depthDraw(MSurface *surface, MSurface *depthSurface, int frameNumber,
 		const Common::Point &pt, int depth) {
-	error("TODO: depthDraw");
+	error("TODO: map depthDraw to frame draw methods");
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/assets.h b/engines/mads/assets.h
index a5d3b3e..dfe6db0 100644
--- a/engines/mads/assets.h
+++ b/engines/mads/assets.h
@@ -108,7 +108,6 @@ public:
 
 	void drawScaled(int frameNumber, MSurface &depthSurface, MSurface &destSurface,
 		int scale, int depth, const Common::Point &pos);
-	void draw(MSurface *surface, int frameNumber, const Common::Point &pt);
 	void depthDraw(MSurface *surface, MSurface *depthSurface, int frameNumber, 
 		const Common::Point &pt, int depth);
 };
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 85e36d6..f187295 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -254,8 +254,9 @@ void SpriteSlots::drawBackground() {
 					pt.y -= frame->h / 2;
 				}
 
+
 				if (spriteSlot._depth <= 1) {
-					asset->draw(&scene._backgroundSurface, spriteSlot._frameNumber, pt);
+					frame->copyTo(&scene._backgroundSurface, frame->getTransparencyIndex());
 				} else if (scene._depthStyle == 0) {
 					asset->depthDraw(&scene._backgroundSurface, &scene._depthSurface, spriteSlot._frameNumber,
 						pt, spriteSlot._depth);


Commit: c7567a90ca248c8e422769c11a2e24c3129a4f13
    https://github.com/scummvm/scummvm/commit/c7567a90ca248c8e422769c11a2e24c3129a4f13
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-16T17:31:21+02:00

Commit Message:
MADS: Add scene3xx functions

Changed paths:
  A engines/mads/nebular/nebular_scenes3.cpp
  A engines/mads/nebular/nebular_scenes3.h
    engines/mads/module.mk



diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 13b4f85..716521d 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -8,6 +8,7 @@ MODULE_OBJS := \
 	nebular/nebular_scenes.o \
 	nebular/nebular_scenes1.o \
 	nebular/nebular_scenes2.o \
+	nebular/nebular_scenes3.o \
 	nebular/nebular_scenes8.o \
 	action.o \
 	animation.o \
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
new file mode 100644
index 0000000..d74d275
--- /dev/null
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -0,0 +1,135 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/scene.h"
+#include "mads/nebular/nebular_scenes.h"
+#include "mads/nebular/nebular_scenes3.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+void Scene3xx::setAAName() {
+	_game._aaName = Resources::formatAAName(4);
+}
+
+void Scene3xx::setPlayerSpritesPrefix() {
+	_vm->_sound->command(5);
+
+	Common::String oldName = _game._player._spritesPrefix;
+
+	if (_globals[kSexOfRex] == REX_MALE)
+		_game._player._spritesPrefix = "RXM";
+	else
+		_game._player._spritesPrefix = "ROX";
+
+	if ((_scene->_nextSceneId == 313) || (_scene->_nextSceneId == 366)
+	|| ((_scene->_nextSceneId >= 301) && (_scene->_nextSceneId <= 303))
+	|| ((_scene->_nextSceneId == 304) && (_scene->_currentSceneId == 303))
+	|| ((_scene->_nextSceneId == 311) && (_scene->_currentSceneId == 304))
+	|| ((_scene->_nextSceneId >= 308) && (_scene->_nextSceneId <= 310))
+	|| ((_scene->_nextSceneId >= 319) && (_scene->_nextSceneId <= 322))
+	|| ((_scene->_nextSceneId >= 387) && (_scene->_nextSceneId <= 391))) {
+		_game._player._spritesPrefix = "";
+		_game._player._spritesChanged = true;
+	} 
+
+	_game._player._scalingVelocity = true;
+	if (oldName != _game._player._spritesPrefix)
+		_game._player._spritesChanged = true;
+
+  _vm->_palette->setEntry(16, 10, 63, 63);
+  _vm->_palette->setEntry(17, 10, 45, 45);
+}
+
+void Scene3xx::sceneEntrySound() {
+	if (!_vm->_musicFlag) {
+		_vm->_sound->command(2);
+		return;
+	}
+
+	switch (_scene->_nextSceneId) {
+	case 301:
+	case 302:
+	case 303:
+	case 304:
+	case 308:
+	case 309:
+	case 310:
+		_vm->_sound->command(11);
+		break;
+
+    case 311:
+		if (_scene->_priorSceneId == 304)
+			_vm->_sound->command(11);
+		else
+			_vm->_sound->command(10);
+		break;
+
+    case 313:
+    case 316:
+    case 320:
+    case 322:
+    case 357:
+    case 358:
+    case 359:
+    case 360:
+    case 361:
+    case 387:
+    case 388:
+    case 389:
+    case 390:
+    case 391:
+    case 399:
+		_vm->_sound->command(10);
+		break;
+
+	case 318:
+		if ((_scene->_priorSceneId == 357) || (_scene->_priorSceneId == 407))
+			_vm->_sound->command(10);
+		else if (_scene->_priorSceneId == 319)
+			_vm->_sound->command(16);
+		else
+			_vm->_sound->command(3);
+
+		_vm->_sound->command(50);
+		break;
+
+	case 319:
+		_vm->_sound->command(16);
+		break;
+
+	case 321:
+		_vm->_sound->command(18);
+		break;
+
+	default:
+		break;
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+} // End of namespace Nebular
+} // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
new file mode 100644
index 0000000..abba91d
--- /dev/null
+++ b/engines/mads/nebular/nebular_scenes3.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_NEBULAR_SCENES3_H
+#define MADS_NEBULAR_SCENES3_H
+
+#include "common/scummsys.h"
+#include "mads/game.h"
+#include "mads/scene.h"
+#include "mads/nebular/nebular_scenes.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+class Scene3xx : public NebularScene {
+protected:
+	/**
+	 * Plays an appropriate sound when entering a scene
+	 */
+	void setAAName();
+
+	/**
+	 * Updates the prefix used for getting player sprites for the scene
+	 */
+	void setPlayerSpritesPrefix();
+
+	void sceneEntrySound();
+public:
+	Scene3xx(MADSEngine *vm) : NebularScene(vm) {}
+};
+
+} // End of namespace Nebular
+} // End of namespace MADS
+
+#endif /* MADS_NEBULAR_SCENES3_H */


Commit: 39088c0121dec470f31a4171336ac8bd525b6fde
    https://github.com/scummvm/scummvm/commit/39088c0121dec470f31a4171336ac8bd525b6fde
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-16T17:48:36+02:00

Commit Message:
MADS: Implement scene 301

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 562f31c..fde69b6 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -30,6 +30,7 @@
 #include "mads/nebular/nebular_scenes.h"
 #include "mads/nebular/nebular_scenes1.h"
 #include "mads/nebular/nebular_scenes2.h"
+#include "mads/nebular/nebular_scenes3.h"
 #include "mads/nebular/nebular_scenes8.h"
 
 namespace MADS {
@@ -101,6 +102,10 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 216:
 		return new Scene216(vm);
 
+	// Scene group #3
+	case 301:
+		return new Scene301(vm);
+
 	// Scene group #8
 	case 804:
 		return new Scene804(vm);
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index d74d275..2d9f2d3 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -59,8 +59,8 @@ void Scene3xx::setPlayerSpritesPrefix() {
 	if (oldName != _game._player._spritesPrefix)
 		_game._player._spritesChanged = true;
 
-  _vm->_palette->setEntry(16, 10, 63, 63);
-  _vm->_palette->setEntry(17, 10, 45, 45);
+	_vm->_palette->setEntry(16, 10, 63, 63);
+	_vm->_palette->setEntry(17, 10, 45, 45);
 }
 
 void Scene3xx::sceneEntrySound() {
@@ -80,28 +80,28 @@ void Scene3xx::sceneEntrySound() {
 		_vm->_sound->command(11);
 		break;
 
-    case 311:
+	case 311:
 		if (_scene->_priorSceneId == 304)
 			_vm->_sound->command(11);
 		else
 			_vm->_sound->command(10);
 		break;
 
-    case 313:
-    case 316:
-    case 320:
-    case 322:
-    case 357:
-    case 358:
-    case 359:
-    case 360:
-    case 361:
-    case 387:
-    case 388:
-    case 389:
-    case 390:
-    case 391:
-    case 399:
+	case 313:
+	case 316:
+	case 320:
+	case 322:
+	case 357:
+	case 358:
+	case 359:
+	case 360:
+	case 361:
+	case 387:
+	case 388:
+	case 389:
+	case 390:
+	case 391:
+	case 399:
 		_vm->_sound->command(10);
 		break;
 
@@ -131,5 +131,31 @@ void Scene3xx::sceneEntrySound() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene301::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene301::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 9, 0, 0, 0);
+
+	_globals[kMeteorologistStatus] = METEOROLOGIST_GONE;
+	_globals[kTeleporterCommand] = TELEPORTER_NONE;
+
+	_game._player._stepEnabled = false;
+	_game._player._visible = false;
+	_scene->loadAnimation(formAnimName('a', -1), 60);
+
+	sceneEntrySound();
+}
+
+void Scene301::step() {
+	if (_game._trigger == 60)
+		_scene->_nextSceneId = 302;
+}
+
+/*------------------------------------------------------------------------*/
+	
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index abba91d..eb92de5 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -49,6 +49,17 @@ public:
 	Scene3xx(MADSEngine *vm) : NebularScene(vm) {}
 };
 
+class Scene301: public Scene3xx {
+public:
+	Scene301(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions() {};
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 301ca80915d4b9ad6fa61f732c9e736f81ea1997
    https://github.com/scummvm/scummvm/commit/301ca80915d4b9ad6fa61f732c9e736f81ea1997
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-16T18:08:26+02:00

Commit Message:
MADS: Implement scene 302

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index fde69b6..c0a1552 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -105,6 +105,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	// Scene group #3
 	case 301:
 		return new Scene301(vm);
+	case 302:
+		return new Scene302(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 2d9f2d3..8a305b8 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -156,6 +156,44 @@ void Scene301::step() {
 }
 
 /*------------------------------------------------------------------------*/
-	
+
+void Scene302::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene302::enter() {
+	_game._player._stepEnabled = false;
+	_game._player._visible  = false;
+
+	_scene->loadAnimation(formAnimName('a',-1), 71);
+	sceneEntrySound();
+}
+
+void Scene302::step() {
+	if (_game._trigger == 71)
+		_scene->_nextSceneId = 303;
+
+	if ((_scene->_activeAnimation != nullptr) && (_scene->_activeAnimation->getCurrentFrame() != _oldFrame)) {
+		_oldFrame = _scene->_activeAnimation->getCurrentFrame();
+		if (_oldFrame == 147) {
+			_game._objects.setRoom(OBJ_POISON_DARTS, 1);
+			_game._objects.setRoom(OBJ_BLOWGUN, 1);
+			_game._objects.setRoom(OBJ_REBREATHER, 1);
+			_game._objects.setRoom(OBJ_STUFFED_FISH, 1);
+			_game._objects.setRoom(OBJ_DEAD_FISH, 1);
+			_game._objects.setRoom(OBJ_BURGER, 1);
+
+			int count = (int)_game._objects._inventoryList.size();
+			for (int idx = 0; idx < count; idx++) {
+				if (_game._objects.isInInventory(idx))
+					_game._objects.setRoom(idx, 50);
+			}
+		}
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index eb92de5..fad60cf 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -60,6 +60,21 @@ public:
 	virtual void actions() {};
 	virtual void postActions() {};
 };
+
+class Scene302: public Scene3xx {
+private:
+	int _oldFrame;
+
+public:
+	Scene302(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions() {};
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 5f44b97d089f6e2db89838b50c685d9307997647
    https://github.com/scummvm/scummvm/commit/5f44b97d089f6e2db89838b50c685d9307997647
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-16T19:29:42+02:00

Commit Message:
MADS: Implement scene 303 and 304

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index c0a1552..67c32fd 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -107,6 +107,10 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene301(vm);
 	case 302:
 		return new Scene302(vm);
+	case 303:
+		return new Scene303(vm);
+	case 304:
+		return new Scene304(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 8a305b8..6d60395 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -164,7 +164,7 @@ void Scene302::setup() {
 
 void Scene302::enter() {
 	_game._player._stepEnabled = false;
-	_game._player._visible  = false;
+	_game._player._visible = false;
 
 	_scene->loadAnimation(formAnimName('a',-1), 71);
 	sceneEntrySound();
@@ -195,5 +195,158 @@ void Scene302::step() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene303::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene303::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('b', 0));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('b', 1));
+
+	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 10, 0, 50, 120);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 10, 0, 0, 0);
+
+	_game._player._visible = false;
+	_game._player._stepEnabled = false;
+	_scene->loadAnimation(formAnimName('a', -1), 60);
+
+	sceneEntrySound();
+}
+
+void Scene303::step() {
+	if (_game._trigger == 60)
+		_scene->_nextSceneId = 304;
+}
+
+/*------------------------------------------------------------------------*/
+
+void Scene304::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene304::enter() {
+	if (_scene->_priorSceneId == 303) {
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+		_scene->loadAnimation(formAnimName('a',-1), 60);
+	} else {
+		if (_globals[kSexOfRex] == REX_MALE)
+			_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('a', 0));
+		else
+			_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('a', 2));
+
+		_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 1));
+		_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('b', 0));
+
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 150, 0, 3, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 2);
+		_vm->_palette->setEntry(252, 45, 63, 45);
+		_vm->_palette->setEntry(253, 20, 45, 20);
+
+		if (_globals[kSexOfRex] == REX_MALE)
+			_game._player._playerPos = Common::Point(111, 117);
+		else
+			_game._player._playerPos = Common::Point(113, 116);
+
+		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 11, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, -1);
+		_scene->_sequences.addTimer(48, 70);
+	}
+
+	sceneEntrySound();
+	_game.loadQuoteSet(0xEB, 0xEC, 0);
+}
+
+void Scene304::step() {
+	if (_game._trigger == 60)
+		_scene->_nextSceneId = 311;
+
+	if (_game._trigger >= 70) { 
+		switch (_game._trigger) {
+		case 70: {
+			_game._player._visible = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 2, 4);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			if (_globals[kSexOfRex] == REX_MALE)
+				_explosionSpriteId = _globals._spriteIndexes[1];
+			else
+				_explosionSpriteId = _globals._spriteIndexes[4];
+
+			int sprIdx = _scene->_sequences.addSpriteCycle(_explosionSpriteId, false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(sprIdx, -1, 4);
+			_scene->_sequences.setDepth(sprIdx, 1);
+			_scene->_sequences.addSubEntry(sprIdx, SEQUENCE_TRIGGER_EXPIRE, 0, 71);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 74);
+			}
+			break;
+
+		case 71:
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 60, _game.getQuote(0xEB));
+			_scene->_sequences.addTimer(1, 72);
+			break;
+
+		case 72: {
+			_vm->_sound->command(43);
+			int sprIdx = _scene->_sequences.addSpriteCycle(_explosionSpriteId, false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(sprIdx, 5, -2);
+			_scene->_sequences.setDepth(sprIdx, 1);
+			_scene->_sequences.addSubEntry(sprIdx, SEQUENCE_TRIGGER_EXPIRE, 0, 73);
+			if (_game._storyMode == STORYMODE_NICE)
+				_scene->_sequences.addSubEntry(sprIdx, SEQUENCE_TRIGGER_SPRITE, 8, 78);
+			}
+			break;
+
+		case 73: {
+			int sprIdx = _scene->_sequences.addSpriteCycle(_explosionSpriteId, false, 8, 0, 0, 0);
+			_scene->_sequences.setAnimRange(sprIdx, -2, -2);
+			_scene->_sequences.setDepth(sprIdx, 1);
+			}
+			break;
+
+		case 74:
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 5, -2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 75);
+			break;
+
+		case 75: 
+			_globals._sequenceIndexes[2] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 2, -2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 76);
+			break;
+
+		case 76:
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 0, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 2, 2);
+			_scene->_sequences.addTimer(48, 77);
+			break;
+
+		case 77:
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(211, 45), 0xFDFC, 32, 0, 180, _game.getQuote(0xEC));
+			_scene->_sequences.addTimer(120, 78);
+			break;
+
+		case 78: 
+			_scene->_nextSceneId = 316;
+			break;
+
+		default:
+			break;
+		}
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index fad60cf..74611a6 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -66,7 +66,7 @@ private:
 	int _oldFrame;
 
 public:
-	Scene302(MADSEngine *vm) : Scene3xx(vm) {}
+	Scene302(MADSEngine *vm) : Scene3xx(vm), _oldFrame(0) {}
 
 	virtual void setup();
 	virtual void enter();
@@ -75,6 +75,34 @@ public:
 	virtual void actions() {};
 	virtual void postActions() {};
 };
+
+class Scene303: public Scene3xx {
+public:
+	Scene303(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions() {};
+	virtual void postActions() {};
+};
+
+class Scene304: public Scene3xx {
+private:
+	int _explosionSpriteId;
+
+public:
+	Scene304(MADSEngine *vm) : Scene3xx(vm), _explosionSpriteId(-1) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions() {};
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: cfd49436478c356c7a9baf320d3ae86dc8485361
    https://github.com/scummvm/scummvm/commit/cfd49436478c356c7a9baf320d3ae86dc8485361
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-16T21:26:46-04:00

Commit Message:
MADS: Fix for correctly loading animation sprite sets

Changed paths:
    engines/mads/animation.cpp



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 93cc72f..dd79772 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -51,23 +51,13 @@ void AAHeader::load(Common::SeekableReadStream *f) {
 	buffer[FILENAME_SIZE - 1] = '\0';
 	_interfaceFile = Common::String(buffer);
 
-	for (int i = 0; i < _spriteSetsCount; ++i) {
+	for (int i = 0; i < 50; ++i) {
 		f->read(buffer, FILENAME_SIZE);
 		buffer[FILENAME_SIZE - 1] = '\0';
-		_spriteSetNames.push_back(Common::String(buffer));
+		if (i < _spriteSetsCount)
+			_spriteSetNames.push_back(Common::String(buffer));
 	}
 
-	f->skip(81);
-	f->read(buffer, FILENAME_SIZE);
-	buffer[FILENAME_SIZE - 1] = '\0';
-	_lbmFilename = Common::String(buffer);
-
-	f->skip(365);
-	f->read(buffer, FILENAME_SIZE);
-	buffer[FILENAME_SIZE - 1] = '\0';
-	_spritesFilename = Common::String(buffer);
-
-	f->skip(48);
 	f->read(buffer, FILENAME_SIZE);
 	buffer[FILENAME_SIZE - 1] = '\0';
 	_soundName = Common::String(buffer);


Commit: 73a505543829c5da58f7ac31f3a9ab87f0f8b93a
    https://github.com/scummvm/scummvm/commit/73a505543829c5da58f7ac31f3a9ab87f0f8b93a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-16T22:03:18-04:00

Commit Message:
MADS: Fix unloading animations with associated messages

Changed paths:
    engines/mads/animation.cpp



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index dd79772..b2c2573 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -188,7 +188,8 @@ void Animation::free() {
 	// Remove any kernel messages in use by the animation
 	for (uint i = 0; i < _messages.size(); ++i) {
 		int msgIndex = _messages[i]._kernelMsgIndex;
-		scene._kernelMessages.remove(msgIndex);
+		if (msgIndex >= 0)
+			scene._kernelMessages.remove(msgIndex);
 	}
 
 	_resetFlag = false;


Commit: 45084a4702bbdbc4a560470fa1dc12dba3549a61
    https://github.com/scummvm/scummvm/commit/45084a4702bbdbc4a560470fa1dc12dba3549a61
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-16T22:59:07-04:00

Commit Message:
MADS: Fix scene animation data being unloaded prematurely

Changed paths:
    engines/mads/scene.cpp
    engines/mads/scene.h



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index e2892fb..99151c1 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -398,6 +398,7 @@ void Scene::doFrame() {
 
 	if (_freeAnimationFlag && _activeAnimation) {
 		_activeAnimation->free();
+		_freeAnimationFlag = false;
 		_activeAnimation = nullptr;
 	}
 }
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index f18d6ad..b695f3b 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -91,7 +91,6 @@ public:
 	TextDisplayList _textDisplay;
 	SpriteSlots _spriteSlots;
 	SpriteSets _sprites;
-	int _spritesIndex;
 	DynamicHotspots _dynamicHotspots;
 	Common::Array<int> _activeVocabs;
 	SequenceList _sequences;


Commit: 0483ad2e0d4ffce4a09d47e044c8de12258c705f
    https://github.com/scummvm/scummvm/commit/0483ad2e0d4ffce4a09d47e044c8de12258c705f
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-17T23:57:40+02:00

Commit Message:
MADS: Implement scene 307

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 67c32fd..6a78903 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -111,6 +111,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene303(vm);
 	case 304:
 		return new Scene304(vm);
+	case 307:
+		return new Scene307(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 6d60395..68c2783 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -53,7 +53,7 @@ void Scene3xx::setPlayerSpritesPrefix() {
 	|| ((_scene->_nextSceneId >= 387) && (_scene->_nextSceneId <= 391))) {
 		_game._player._spritesPrefix = "";
 		_game._player._spritesChanged = true;
-	} 
+	}
 
 	_game._player._scalingVelocity = true;
 	if (oldName != _game._player._spritesPrefix)
@@ -129,6 +129,109 @@ void Scene3xx::sceneEntrySound() {
 	}
 }
 
+void Scene3xx::initForceField(ForceField *force, bool flag) {
+	force->_flag = flag;
+	force->_vertical = 0;
+	force->_horizontal = 0;
+	force->_timer = 0;
+
+	for (int count = 0; count < 40; count++)
+		force->_seqId[count] = -1;
+
+	if (force->_flag)
+		_vm->_sound->command(24);
+}
+
+int Scene3xx::computeScale(int low, int high, int id) {
+	int diff = high - (low + 2);
+	int quotient = diff / 20;
+	int remainder = diff % 20;
+	int value = low + 2 + (quotient * id) + (remainder / (id + 1));
+
+	return (value);
+}
+
+void Scene3xx::handleForceField(ForceField *force, int *sprites) {
+	if (_game._trigger >= 150) {
+		int id = _game._trigger - 150;
+		if (id < 40) {
+			if (id < 20)
+				force->_vertical--;
+			else
+				force->_horizontal--;
+
+			force->_seqId[id] = -1;
+		}
+		return;
+	}
+
+	if (!force->_flag || (_scene->_frameStartTime < force->_timer) || (force->_vertical + force->_horizontal >= 5))
+		return;
+
+	if (_vm->getRandomNumber(1, 1000) <= (200 + ((40 - (force->_vertical + force->_horizontal)) << 5))) {
+		int id = -1;
+		for (int i = 0; i < 100; i++) {
+			int randIdx = _vm->getRandomNumber(0, 39);
+			if (force->_seqId[randIdx] < 0) {
+				id = randIdx;
+				break;
+			}
+		}
+
+		if (id < 0) {
+			for (int i = 0; i < 40; i++) {
+				if (force->_seqId[i] < 0) {
+					id = i;
+					break;
+				}
+			}
+		}
+
+		int speedX, speedY;
+		int posX, posY;
+		int randVal = _vm->getRandomNumber(1, 100);
+		int spriteId;
+		bool mirror;
+
+		if (id >= 20) {
+			spriteId = 2;
+			mirror = (randVal <= 50);
+			posX = mirror ? 315 : 5;
+			posY = computeScale(15, 119, id - 20);
+			speedX = 1000 * (mirror ? -1 : 1);
+			speedY = 0;
+		} else if (randVal <= 50) {
+			spriteId = 1;
+			mirror = false;
+			posX = computeScale(21, 258, id);
+			posY = 0;
+			speedX = 0;
+			speedY = 600;
+		} else {
+			spriteId = 0;
+			mirror = false;
+			posX = computeScale(21, 258, id);
+			posY = 155;
+			speedX = 0;
+			speedY = -600;
+		}
+
+		if (id >= 0) {
+			force->_seqId[id] = _scene->_sequences.addSpriteCycle(sprites[spriteId], mirror, 2, 0, 0, 0);
+			_scene->_sequences.setDepth(force->_seqId[id], 8);
+			_scene->_sequences.setMsgPosition(force->_seqId[id], Common::Point(posX, posY));
+			_scene->_sequences.sub70C52(force->_seqId[id], 2, speedX, speedY);
+			_scene->_sequences.addSubEntry(force->_seqId[id], SEQUENCE_TRIGGER_EXPIRE, 0, 150 + id);
+			if (spriteId == 2)
+				force->_horizontal++;
+			else
+				force->_vertical++;
+		}
+	}
+
+	force->_timer = _scene->_frameStartTime + 4;
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene301::setup() {
@@ -166,7 +269,7 @@ void Scene302::enter() {
 	_game._player._stepEnabled = false;
 	_game._player._visible = false;
 
-	_scene->loadAnimation(formAnimName('a',-1), 71);
+	_scene->loadAnimation(formAnimName('a', -1), 71);
 	sceneEntrySound();
 }
 
@@ -231,7 +334,7 @@ void Scene304::enter() {
 	if (_scene->_priorSceneId == 303) {
 		_game._player._visible = false;
 		_game._player._stepEnabled = false;
-		_scene->loadAnimation(formAnimName('a',-1), 60);
+		_scene->loadAnimation(formAnimName('a', -1), 60);
 	} else {
 		if (_globals[kSexOfRex] == REX_MALE)
 			_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('a', 0));
@@ -264,7 +367,7 @@ void Scene304::step() {
 	if (_game._trigger == 60)
 		_scene->_nextSceneId = 311;
 
-	if (_game._trigger >= 70) { 
+	if (_game._trigger >= 70) {
 		switch (_game._trigger) {
 		case 70: {
 			_game._player._visible = false;
@@ -316,7 +419,7 @@ void Scene304::step() {
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 75);
 			break;
 
-		case 75: 
+		case 75:
 			_globals._sequenceIndexes[2] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 2, -2);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
@@ -336,7 +439,7 @@ void Scene304::step() {
 			_scene->_sequences.addTimer(120, 78);
 			break;
 
-		case 78: 
+		case 78:
 			_scene->_nextSceneId = 316;
 			break;
 
@@ -348,5 +451,679 @@ void Scene304::step() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene307::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x11);
+	_scene->addActiveVocab(0x2F7);
+}
+
+void Scene307::handleRexDialog(int quote) {
+	Common::String curQuote = _game.getQuote(_action._activeAction._verbId);
+	if (_vm->_font->getWidth(curQuote, _scene->_textSpacing) > 200) {
+		Common::String subQuote1;
+		_game.splitQuote(curQuote, subQuote1, _subQuote2);
+		_scene->_kernelMessages.add(Common::Point(0, -14), 0x1110, 34, 0, 240, subQuote1);
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 1, 180, _subQuote2);
+	} else
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 1, 120, curQuote);
+}
+
+void Scene307::handlePrisonerEncounter() {
+	switch (_action._activeAction._verbId) {
+	case 275:
+		setDialogNode(5);
+		break;
+
+	case 277:
+		setDialogNode(4);
+		break;
+
+	case 276:
+		setDialogNode(6);
+		break;
+	}
+}
+
+void Scene307::handlePrisonerSpeech(int firstQuoteId, int number, long time) {
+	int height = number * 14;
+	int posY;
+
+	if (height < 60)
+		posY = 65 - height;
+	else
+		posY = 78 - (height / 2);
+
+	_scene->_kernelMessages.reset();
+	_activePrisonerFl = true;
+
+	int quoteId = firstQuoteId;
+	for (int count = 0; count < number; count++) {
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_kernelMessages.add(Common::Point(5, posY), 0xFDFC, 0, 81, time, _game.getQuote(quoteId));
+		posY += 14;
+		quoteId++;
+	}
+}
+
+void Scene307::setDialogNode(int node) {
+	switch (node) {
+	case 0:
+		handlePrisonerSpeech(0x153, 2, 120);
+		_scene->_userInterface.setup(kInputBuildingSentences);
+		break;
+
+	case 1:
+		_globals[kMetBuddyBeast] = true;
+		handlePrisonerSpeech(0x10F, 2, 9999999);
+		warning("TODO: talk_init(&dialog1);");
+		break;
+
+	case 2:
+		_globals[kMetBuddyBeast] = true;
+		handlePrisonerSpeech(0x111, 2, 9999999);
+		warning("TODO: talk_init(&dialog1);");
+		break;
+
+	case 4:
+		handlePrisonerSpeech(0x116, 1, 120);
+		_scene->_userInterface.setup(kInputBuildingSentences);
+		break;
+
+	case 5:
+		_globals[kKnowsBuddyBeast] = true;
+		handlePrisonerSpeech(0x117, 2, 9999999);
+		warning("TODO: talk_init(&dialog2);");
+		break;
+
+	case 6:
+		handlePrisonerSpeech(0x123, 1, 120);
+		_scene->_userInterface.setup(kInputBuildingSentences);
+		break;
+
+	case 7:
+		_globals[kKnowsBuddyBeast] = true;
+		handlePrisonerSpeech(0x124, 10, 9999999);
+		warning("TODO: sub71B9E(&dialog2, 0x11A, false);");
+		warning("TODO: sub71B9E(&dialog2, 0x11B, true);");
+		warning("TODO: sub71B9E(&dialog2, 0x120, true);");
+		warning("TODO: talk_init(&dialog2);");
+		break;
+
+	case 8:
+		handlePrisonerSpeech(0x12E, 6, 9999999);
+		warning("TODO: sub71B9E(&dialog2, 0x11A, false);");
+		warning("TODO: sub71B9E(&dialog2, 0x11B, false);");
+		warning("TODO: sub71B9E(&dialog2, 0x11C, true);");
+		warning("TODO: sub71B9E(&dialog2, 0x11D, true);");
+		warning("TODO: sub71B9E(&dialog2, 0x11F, true);");
+		warning("TODO: talk_init(&dialog2);");
+		break;
+
+	case 9:
+		handlePrisonerSpeech(0x134, 4, 9999999);
+		warning("TODO: sub71B9E(&dialog2, 0x11D, false);");
+		warning("TODO: talk_init(&dialog2);");
+		break;
+
+	case 10:
+		handlePrisonerSpeech(0x138, 6, 9999999);
+		warning("TODO: sub71B9E(&dialog2, 0x11E, false);");
+		warning("TODO: talk_init(&dialog2);");
+		break;
+
+	case 11:
+		handlePrisonerSpeech(0x13E, 6, 9999999);
+		warning("TODO: sub71B9E(&dialog2, 0x11F, false);");
+		warning("TODO: sub71B9E(&dialog2, 0x121, true);");
+		warning("TODO: talk_init(&dialog2);");
+		break;
+
+	case 12:
+		handlePrisonerSpeech(0x144, 4, 9999999);
+		warning("TODO: sub71B9E(&dialog2, 0x11C, false);");
+		warning("TODO: talk_init(&dialog2);");
+		break;
+
+	case 13:
+		handlePrisonerSpeech(0x148, 7, 9999999);
+		warning("TODO: sub71B9E(&dialog2, 0x120, false);");
+		warning("TODO: talk_init(&dialog2);");
+		break;
+
+	case 14:
+		handlePrisonerSpeech(0x14F, 3, 9999999);
+		warning("TODO: sub71B9E(&dialog2, 0x121, false);");
+		warning("TODO: talk_init(&dialog2);");
+		break;
+
+	case 15:
+		handlePrisonerSpeech(0x152, 1, 120);
+		_scene->_userInterface.setup(kInputBuildingSentences);
+		break;
+
+	case 16:
+		_globals[kKnowsBuddyBeast] = true;
+		handlePrisonerSpeech(0x10C, 1, 9999999);
+		warning("TODO: talk_init(&dialog2);");
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene307::handlePrisonerDialog() {
+	switch (_action._activeAction._verbId) {
+	case 0x11A:
+		setDialogNode(7);
+		break;
+
+	case 0x11B:
+		setDialogNode(8);
+		break;
+
+	case 0x11C:
+		setDialogNode(12);
+		break;
+
+	case 0x11D:
+		setDialogNode(9);
+		break;
+
+	case 0x11E:
+		setDialogNode(10);
+		break;
+
+	case 0x11F:
+		setDialogNode(11);
+		break;
+
+	case 0x120:
+		setDialogNode(13);
+		break;
+
+	case 0x121:
+		setDialogNode(14);
+		break;
+
+	case 0x122:
+		setDialogNode(15);
+		break;
+	}
+}
+
+void Scene307::handleDialog() {
+	if (_game._trigger == 0) {
+		_scene->_kernelMessages.reset();
+		_game._player._stepEnabled = false;
+		handleRexDialog(_action._activeAction._verbId);
+	} else {
+		_game._player._stepEnabled = true;
+
+		if (!_globals[kKnowsBuddyBeast]) {
+			handlePrisonerEncounter();
+		} else {
+			handlePrisonerDialog();
+		}
+	}
+}
+
+void Scene307::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites("*SC003x0");
+	_globals._spriteIndexes[0] = _scene->_sprites.addSprites("*SC003x1");
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*SC003x2");
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 0));
+
+	initForceField(&_forceField, true);
+
+	_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
+	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 15);
+
+	_animationMode = 0;
+	_fieldCollisionCounter = 0;
+
+	_scene->changeVariant(1);
+
+	_game.loadQuoteSet(0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0x10C, 0x104, 0x106, 0x107, 0x108, 0x105,
+		0x109, 0x10A, 0x10B, 0x10D, 0x10E, 0x10F, 0x110, 0x111, 0x112, 0x113, 0x114, 0x115, 0x116, 0x117,
+		0x118, 0x119, 0x11A, 0x11B, 0x11C, 0x11D, 0x11E, 0x11F, 0x120, 0x121, 0x122, 0x123, 0x124, 0x125,
+		0x126, 0x127, 0x128, 0x129, 0x12A, 0x12B, 0x12C, 0x12D, 0x12E, 0x12F, 0x130, 0x131, 0x132, 0x133,
+		0x134, 0x135, 0x136, 0x137, 0x138, 0x139, 0x13A, 0x13B, 0x13C, 0x13D, 0x13E, 0x13F, 0x140, 0x141,
+		0x142, 0x143, 0x144, 0x145, 0x146, 0x147, 0x148, 0x149, 0x14A, 0x14B, 0x14C, 0x14D, 0x14E, 0x14F,
+		0x150, 0x151, 0x152, 0x153, 0);
+
+	warning("TODO: sub71A50(&dialog1, 0x3F, 0x113, 0x114, 0x115, -1);");
+	warning("TODO: sub71A50(&dialog2, 0x40, 0x11A, 0x11B, 0x11C, 0x11D, 0x11E, 0x11F, 0x120, 0x121, 0x122, 0);");
+
+	if (!_game._visitedScenes._sceneRevisited)
+		warning("TODO: sub71B18(&dialog2, 0x11A, 0x122, 0);");
+	else if (_scene->_priorSceneId == 318)
+		warning("TODO: sub71B9E(&dialog2, 0x11E, -1);");
+
+
+	if (_scene->_priorSceneId == -2) {
+		if (_grateOpenedFl)
+			_vm->_sound->command(10);
+		else
+			_vm->_sound->command(3);
+	} else {
+		_afterPeeingFl = false;
+		_duringPeeingFl = false;
+		_guardTime = 0;
+		_grateOpenedFl = false;
+		_activePrisonerFl = false;
+		_prisonerTimer = 0;
+		_prisonerMessageId = 0x104;
+
+		if (_scene->_priorSceneId == 308) {
+			_game._player._visible = false;
+			_game._player._stepEnabled = false;
+			_game._player._playerPos = Common::Point(156, 113);
+			_game._player._facing = FACING_NORTH;
+			_animationMode = 1;
+			_vm->_sound->command(11);
+			_scene->loadAnimation(formAnimName('a', -1), 60);
+		} else if (_scene->_priorSceneId == 387) {
+			_game._player._playerPos = Common::Point(129, 108);
+			_game._player._facing = FACING_NORTH;
+			_vm->_sound->command(3);
+			_grateOpenedFl = true;
+		} else {
+			_game._player._playerPos = Common::Point(159, 109);
+			_game._player._facing = FACING_SOUTH;
+			_vm->_sound->command(3);
+		}
+	}
+
+	if (_grateOpenedFl) {
+		_scene->_hotspots.activate(17, false);
+
+		int idx = _scene->_dynamicHotspots.add(17, 0x2F7, -1, Common::Rect(117, 67, 117 + 19, 67 + 13));
+		int hotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(129, 104), FACING_NORTH);
+		_scene->_dynamicHotspots.setCursor(hotspotId, CURSOR_GO_UP);
+
+		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 2);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 15);
+	}
+
+	_vm->_palette->setEntry(252, 63, 30, 20);
+	_vm->_palette->setEntry(253, 45, 15, 12);
+
+	sceneEntrySound();
+
+	if ((_scene->_priorSceneId == 318) || (_scene->_priorSceneId == 387))
+		_scene->_kernelMessages.addQuote(0xF3, 120, 0);
+}
+
+void Scene307::step() {
+	handleForceField(&_forceField, &_globals._spriteIndexes[0]);
+
+	if ((_animationMode == 1) && (_scene->_activeAnimation != nullptr)) {
+		if (_scene->_activeAnimation->getCurrentFrame() == 126) {
+			_forceField._flag = false;
+			_vm->_sound->command(5);
+		}
+
+		if (_scene->_activeAnimation->getCurrentFrame() == 194) {
+			_forceField._flag = true;
+			_vm->_sound->command(24);
+		}
+	}
+
+	if ((_animationMode == 2) && (_scene->_activeAnimation != nullptr)) {
+		if (_scene->_activeAnimation->getCurrentFrame() == 54)
+			_forceField._flag = false;
+
+		if (_scene->_activeAnimation->getCurrentFrame() == 150) {
+			_game._player._visible = false;
+			_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+		}
+	}
+
+	if (_game._trigger == 60) {
+		_game._player._visible = true;
+		_game._player._stepEnabled = true;
+		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+		_animationMode = 0;
+		_vm->_sound->command(9);
+	}
+
+	if ((_lastFrameTime != _scene->_frameStartTime) && !_duringPeeingFl) {
+		int32 elapsedTime = _lastFrameTime - _scene->_frameStartTime;
+		if ((elapsedTime > 0) && (elapsedTime <= 4)) {
+			_guardTime += elapsedTime;
+			_prisonerTimer += elapsedTime;
+		} else {
+			_guardTime++;
+			_prisonerTimer++;
+		}
+		_lastFrameTime = _scene->_frameStartTime;
+
+		if ((_guardTime > 3000) && !_duringPeeingFl && (_scene->_activeAnimation == nullptr)
+		&& (_game._screenObjects._inputMode != 1) && _globals[kMetBuddyBeast] && !_activePrisonerFl) {
+			if (!_game._objects.isInInventory(OBJ_SCALPEL) && !_grateOpenedFl) {
+				_game._player._stepEnabled = false;
+				_game._player.walk(Common::Point(151, 119), FACING_SOUTHEAST);
+				_animationMode = 2;
+				_vm->_sound->command(11);
+				_scene->loadAnimation(formAnimName('b', -1), 70);
+			}
+			_guardTime = 0;
+		} else if ((_prisonerTimer > 300) && (_game._screenObjects._inputMode != 1) && (_scene->_activeAnimation == nullptr) && !_activePrisonerFl) {
+			if (!_globals[kMetBuddyBeast]) {
+				int idx = _scene->_kernelMessages.add(Common::Point(5, 51), 0xFDFC, 0, 81, 120, _game.getQuote(_prisonerMessageId));
+				_scene->_kernelMessages.setQuoted(idx, 4, true);
+				_prisonerMessageId++;
+				if (_prisonerMessageId > 0x10A)
+					_prisonerMessageId = 0x104;
+			} else if (_globals[kKnowsBuddyBeast] && (_vm->getRandomNumber(1, 3) == 1)) {
+				warning("TODO: if (_globals[kKnowsBuddyBeast] && (sub71C16(&dialog2, 0) > 1) && (_vm->getRandomNumber(1, 3) == 1)) {");
+				int idx = _scene->_kernelMessages.add(Common::Point(5, 51), 0xFDFC, 0, 81, 120, _game.getQuote(267));
+				_scene->_kernelMessages.setQuoted(idx, 4, true);
+			}
+			_prisonerTimer = 0;
+		}
+	}
+
+	if (_game._trigger == 70)
+		_scene->_nextSceneId = 318;
+
+	if (_game._trigger == 81) {
+		_prisonerTimer = 0;
+		if (_activePrisonerFl && (_guardTime > 2600))
+			_guardTime = 3000 - _vm->getRandomNumber(1, 800);
+
+		_activePrisonerFl = false;
+	}
+}
+
+void Scene307::actions() {
+	if (_action._lookFlag)
+		_vm->_dialogs->show(0x77FB);
+	else if (_game._screenObjects._inputMode == 1)
+		handleDialog();
+	else if (_action.isAction(VERB_TALKTO, 0x207) || _action.isAction(VERB_TALKTO, 0x18D) || _action.isAction(VERB_TALKTO, 0x21B)) {
+		int node, say;
+		if (_globals[kKnowsBuddyBeast]) {
+			say = 0x10E;
+			node = 16;
+		} else if (_globals[kMetBuddyBeast]) {
+			say = 0x10E;
+			node = 2;
+		} else {
+			say = 0x10D;
+			node = 1;
+		}
+
+		switch (_game._trigger) {
+		case 0:
+			handleRexDialog(say);
+			break;
+
+		case 1:
+			setDialogNode(node);
+			break;
+		}
+	} else if (_action.isAction(0x11C, 0x12C, 0x11)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(239));
+			_scene->_sequences.addTimer(120, 1);
+			break;
+
+		case 1:
+			_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RXCL_8");
+			_game._player._visible = false;
+			_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 12, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], -1, 3);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+
+		case 2: {
+			int oldIdx = _globals._sequenceIndexes[5];
+			_globals._sequenceIndexes[5] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], false, 12, 6, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 2, 3);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[5], oldIdx);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+			}
+			break;
+
+		case 3: {
+			int oldIdx = _globals._sequenceIndexes[5];
+			_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[5], oldIdx);
+			_scene->_sequences.addTimer(48, 4);
+			}
+			break;
+
+		case 4:
+			_vm->_sound->command(26);
+			_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 2);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 15);
+			_scene->_sequences.addTimer(90, 5);
+			break;
+
+		case 5:
+			_vm->_sound->command(10);
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(241));
+			_scene->_sequences.addTimer(120, 6);
+			break;
+
+		case 6: {
+			_game._player._visible = true;
+			_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+			_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+			_grateOpenedFl = true;
+			_scene->_hotspots.activate(17, false);
+			int idx = _scene->_dynamicHotspots.add(17, 0x2F7, -1, Common::Rect(117, 67, 117 + 19, 67 + 13));
+			int hotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(129, 104), FACING_NORTH);
+			_scene->_dynamicHotspots.setCursor(hotspotId, CURSOR_GO_UP);
+			_game._objects.removeFromInventory(OBJ_SCALPEL, NOWHERE);
+			_scene->_kernelMessages.addQuote(0xF2, 120, 7);
+			}
+			break;
+
+		case 7:
+			_scene->_sprites.remove(_globals._spriteIndexes[5]);
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+	}else if (_action.isAction(0x2F7, 0x11)) {
+		if (_grateOpenedFl) {
+			switch (_game._trigger) {
+			case 0:
+				_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RXCL_8");
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+				_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 60, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 3, -2);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 15);
+				_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 18, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], -1, 4);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				break;
+
+			case 1:
+				_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, -2);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 15);
+				break;
+
+			case 2: {
+				int oldIdx = _globals._sequenceIndexes[5];
+				_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 12, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 4, 10);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+				_scene->_sequences.updateTimeout(_globals._sequenceIndexes[5], oldIdx);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+				}
+				break;
+
+			case 3:
+				_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+				_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 3);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
+				_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 11);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[5], Common::Point(129, 102));
+				_scene->_sequences.addTimer(48, 4);
+				break;
+
+			case 4:
+				_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+				_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 2);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
+				_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+				_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 12, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 12, 14);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[5], Common::Point(129, 102));
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 5);
+				break;
+
+			case 5:
+				_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 15);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[5], Common::Point(129, 102));
+				_scene->_sequences.addTimer(48, 6);
+				break;
+
+			case 6:
+				_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+				_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+				_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
+				_scene->_sequences.addTimer(48, 7);
+				break;
+
+			case 7:
+				_scene->_nextSceneId = 313;
+				break;
+
+			default:
+				break;
+			}
+		}
+	} else if (_action.isAction(0x20C, 0x21B) && (_game._storyMode != STORYMODE_NAUGHTY))
+		_vm->_dialogs->show(0x7803);
+	else if (_action.isAction(0x20C, 0x21B)) {
+		if (!_afterPeeingFl) {
+			switch (_game._trigger) {
+			case 0:
+				_vm->_sound->command(25);
+				_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 0));
+				_duringPeeingFl = true;
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 9, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -1, 2);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 9);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+				break;
+
+			case 1:
+				_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 9, 5, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 3, -2);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 9);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				break;
+
+			case 2:
+				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[3]);
+				_game._player._visible = true;
+				_scene->_sequences.addTimer(48, 3);
+				break;
+
+			case 3: {
+				_scene->_sprites.remove(_globals._spriteIndexes[3]);
+				_scene->_kernelMessages.reset();
+				int idx = _scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 4, 120, _game.getQuote(237));
+				_scene->_kernelMessages.setQuoted(idx, 4, true);
+				}
+				break;
+
+			case 4:
+				_game._player._stepEnabled = true;
+				_duringPeeingFl = false;
+				_afterPeeingFl = true;
+				break;
+
+			default:
+				break;
+			}
+		} else {
+			_scene->_kernelMessages.reset();
+			int idx = _scene->_kernelMessages.add(Common::Point(85, 39), 0x1110, 0, 0, 180, _game.getQuote(238));
+			_scene->_kernelMessages.setQuoted(idx, 4, true);
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x11)) {
+		if (!_grateOpenedFl)
+			_vm->_dialogs->show(0x77F6);
+		else
+			_vm->_dialogs->show(0x77F7);
+	} else if (_action.isAction(VERB_LOOK, 0x1CB))
+		_vm->_dialogs->show(0x77F8);
+	else if (_action.isAction(VERB_LOOK, 0x216))
+		_vm->_dialogs->show(0x77F9);
+	else if (_action.isAction(VERB_LOOK, 0x21B))
+		_vm->_dialogs->show(0x77FA);
+	else if (_action.isAction(0x134, 0x12C))
+		_vm->_dialogs->show(0x77FC);
+	else if (_action.isAction(VERB_LOOK, 0x207))
+		_vm->_dialogs->show(0x77FD);
+	else if (_action.isAction(VERB_LOOK, 0xCD))
+		_vm->_dialogs->show(0x77FE);
+	else if (_action.isAction(0x242, 0x204)) {
+		switch (_fieldCollisionCounter) {
+		case 0:
+			_vm->_dialogs->show(0x77FF);
+			_fieldCollisionCounter = 1;
+			break;
+
+		case 1:
+			_vm->_dialogs->show(0x7800);
+			_fieldCollisionCounter = 2;
+			break;
+
+		case 2:
+			_vm->_dialogs->show(0x7801);
+			_fieldCollisionCounter = 3;
+			break;
+
+		case 3:
+			_vm->_dialogs->show(0x7802);
+			break;
+		}
+	} else
+		return;
+
+	_action._inProgress = false;
+}
+
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 74611a6..5b25e39 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -32,6 +32,14 @@ namespace MADS {
 
 namespace Nebular {
 
+typedef struct {
+	bool _flag;
+	int _vertical;
+	int _horizontal;
+	int _seqId[40];
+	uint32 _timer;
+} ForceField;
+
 class Scene3xx : public NebularScene {
 protected:
 	/**
@@ -45,6 +53,11 @@ protected:
 	void setPlayerSpritesPrefix();
 
 	void sceneEntrySound();
+
+	void initForceField(ForceField *force, bool flag);
+	void handleForceField(ForceField *force, int *sprites);
+	int computeScale(int low, int high, int id);
+
 public:
 	Scene3xx(MADSEngine *vm) : NebularScene(vm) {}
 };
@@ -103,6 +116,45 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene307: public Scene3xx {
+private:
+	ForceField _forceField;
+
+	bool _afterPeeingFl;
+	bool _duringPeeingFl;
+	bool _grateOpenedFl;
+	bool _activePrisonerFl;
+
+	int _animationMode;
+	int  _prisonerMessageId;
+	int _fieldCollisionCounter;
+
+	uint32 _lastFrameTime;
+	uint32 _guardTime;
+	uint32 _prisonerTimer;
+
+	Common::String _subQuote2;
+
+	//	dialog1, dialog2;
+
+	void handleDialog();
+	void handleRexDialog(int quote);
+	void handlePrisonerDialog();
+	void handlePrisonerEncounter();
+	void setDialogNode(int node);
+	void handlePrisonerSpeech(int firstQuoteId, int number, long time);
+
+public:
+	Scene307(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 40f2b01dfb20ac68986d44765dd7b045b6f5861b
    https://github.com/scummvm/scummvm/commit/40f2b01dfb20ac68986d44765dd7b045b6f5861b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-17T19:26:47-04:00

Commit Message:
Merge branch 'mads' of github.com:/dreammaster/scummvm into mads

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h





Commit: 8c9b65c34ae264686efb3f4bb276506eb6d727c3
    https://github.com/scummvm/scummvm/commit/8c9b65c34ae264686efb3f4bb276506eb6d727c3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-17T22:11:25-04:00

Commit Message:
MADS: Fixes for inventory scroller

Changed paths:
    engines/mads/user_interface.cpp



diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 4348d83..594d549 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -354,12 +354,12 @@ void UserInterface::updateInventoryScroller() {
 			uint32 currentMilli = g_system->getMillis();
 			uint32 timeInc = _scrollbarQuickly ? 100 : 380;
 
-			if (_vm->_events->_mouseClicked || (_vm->_events->_mouseStatusCopy && (_scrollbarMilliTime + timeInc) <= currentMilli)) {
+			if (_vm->_events->_mouseStatus && (_scrollbarMilliTime + timeInc) <= currentMilli) {
 				_scrollbarQuickly = _vm->_events->_vD2 < 1;
 				_scrollbarMilliTime = currentMilli;
 
 				switch (_scrollbarStrokeType) {
-				case 1:
+				case SCROLLBAR_UP:
 					// Scroll up
 					if (_inventoryTopIndex > 0 && inventoryList.size() > 0) {
 						--_inventoryTopIndex;
@@ -367,7 +367,7 @@ void UserInterface::updateInventoryScroller() {
 					}
 					break;
 
-				case 2:
+				case SCROLLBAR_DOWN:
 					// Scroll down
 					if (_inventoryTopIndex < ((int)inventoryList.size() - 1) && inventoryList.size() > 1) {
 						++_inventoryTopIndex;
@@ -375,7 +375,7 @@ void UserInterface::updateInventoryScroller() {
 					}
 					break;
 
-				case 3: {
+				case SCROLLBAR_ELEVATOR: {
 					// Inventory slider
 					int newIndex = CLIP((int)_vm->_events->currentPos().y - 170, 0, 17)
 						* inventoryList.size() / 10;
@@ -447,11 +447,11 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
 			_vm->_font->setColorMode(SELMODE_HIGHLIGHTED);
 		} else {
 			_vm->_font->setColorMode(id == _selectedInvIndex ? SELMODE_SELECTED : SELMODE_UNSELECTED);
-			vocabStr = scene.getVocab(vocabId);
-			vocabStr.setChar(toupper(vocabStr[0]), 0);
-			font->writeString(this, vocabStr, Common::Point(bounds.left, bounds.top));
-			break;
 		}
+
+		vocabStr = scene.getVocab(vocabId);
+		vocabStr.setChar(toupper(vocabStr[0]), 0);
+		font->writeString(this, vocabStr, Common::Point(bounds.left, bounds.top));
 		break;
 
 	case CAT_TALK_ENTRY:
@@ -583,7 +583,7 @@ bool UserInterface::getBounds(ScrCategory category, int v, Common::Rect &bounds)
 		break;
 
 	case CAT_INV_LIST:
-		if (v < _inventoryTopIndex || v > (_inventoryTopIndex + 5))
+		if (v < _inventoryTopIndex || v >= (_inventoryTopIndex + 5))
 			return false;
 
 		heightMultiplier = v - _inventoryTopIndex;
@@ -625,22 +625,22 @@ bool UserInterface::getBounds(ScrCategory category, int v, Common::Rect &bounds)
 
 	if (category == CAT_INV_SCROLLER) {
 		switch (v) {
-		case 1:
+		case SCROLLBAR_UP:
 			// Arrow up
 			bounds.top = 4;
 			bounds.setHeight(7);
 			break;
-		case 2:
+		case SCROLLBAR_DOWN:
 			// Arrow down
 			bounds.top = 35;
 			bounds.setHeight(7);
 			break;
-		case 3:
+		case SCROLLBAR_ELEVATOR:
 			// Scroller
 			bounds.top = 12;
 			bounds.setHeight(22);
 			break;
-		case 4:
+		case SCROLLBAR_THUMB:
 			// Thumb
 			bounds.top = _scrollbarElevator + 14;
 			bounds.setHeight(1);


Commit: 15c64dd9725a9799878d80e978120d06b7b7074a
    https://github.com/scummvm/scummvm/commit/15c64dd9725a9799878d80e978120d06b7b7074a
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-18T07:53:55+02:00

Commit Message:
MADS: Implement scene 308

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 6a78903..edefd5b 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -113,6 +113,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene304(vm);
 	case 307:
 		return new Scene307(vm);
+	case 308:
+		return new Scene308(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 68c2783..e107c67 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -1122,6 +1122,128 @@ void Scene307::actions() {
 	_action._inProgress = false;
 }
 
+/*------------------------------------------------------------------------*/
+
+void Scene308::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene308::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites("*SC003x0");
+	_globals._spriteIndexes[0] = _scene->_sprites.addSprites("*SC003x1");
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*SC003x2");
+
+	initForceField(&_forceField, true);
+
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('b', 0));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(Resources::formatName(307, 'X', 0, EXT_SS, ""));
+
+	_vm->_palette->setEntry(252, 63, 30, 20);
+	_vm->_palette->setEntry(253, 45, 15, 12);
+
+	_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
+	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 15);
+	_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 9);
+	_scene->_sequences.addTimer(48, 70);
+
+	_game._player._visible   = false;
+	_game._player._stepEnabled = false;
+	_scene->loadAnimation(formAnimName('a', -1), 60);
+
+	sceneEntrySound();
+	_game.loadQuoteSet(0xF4, 0xF5, 0xF6, 0);
+}
+
+void Scene308::step() {
+	handleForceField(&_forceField, &_globals._spriteIndexes[0]);
+
+	if (_game._trigger == 60)
+		_scene->_nextSceneId = 307;
+
+	if (_game._trigger < 70)
+		return;
+
+	switch (_game._trigger) {
+	case 70: {
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 18, 9, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 2, 3);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 9);
+		_scene->_kernelMessages.reset();
+		int idx = _scene->_kernelMessages.add(Common::Point(171, 21), 0xFDFC, 0, 0, 120, _game.getQuote(244));
+		_scene->_kernelMessages.setQuoted(idx, 2, true);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
+		}
+		break;
+
+	case 71: { 
+		int seqIdx = _globals._sequenceIndexes[3]; 
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 4);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 9);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], seqIdx);
+		_scene->_sequences.addTimer(48, 72);
+		}
+		break;
+
+	case 72:
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 20, 5, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 3, 4);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 9);
+		_scene->_kernelMessages.reset();
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 73);
+		break;
+
+	case 73: {
+		int seqIdx = _globals._sequenceIndexes[3];  
+		_globals._sequenceIndexes[3]  = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 5);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 9);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], seqIdx);
+		_scene->_sequences.addTimer(48, 74);
+		}
+		break;
+
+	case 74: {
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 20, 8, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 6, 7);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 9);
+		_scene->_kernelMessages.reset();
+		int idx = _scene->_kernelMessages.add(Common::Point(171, 21), 0xFDFC, 0, 0, 120, _game.getQuote(245));
+		_scene->_kernelMessages.setQuoted(idx, 2, true);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 75);
+		}
+		break;
+
+	case 75: { 
+		int seqIdx = _globals._sequenceIndexes[3];  
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 23, 5, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 8, 10);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 9);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], seqIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 76);
+		}
+		break;
+
+	case 76: {
+		int seqIdx = _globals._sequenceIndexes[3];  
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 26, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 2, 3);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 9);
+		_scene->_kernelMessages.reset();
+		int idx = _scene->_kernelMessages.add(Common::Point(171, 21), 0xFDFC, 0, 0, 120, _game.getQuote(246));
+		_scene->_kernelMessages.setQuoted(idx, 2, true);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], seqIdx);
+		}
+		break;
+
+	default:
+		break;
+	}
+}
 
 /*------------------------------------------------------------------------*/
 
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 5b25e39..d841ce6 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -155,6 +155,21 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene308: public Scene3xx {
+private:
+	ForceField _forceField;
+
+public:
+	Scene308(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions() {};
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 3813eddf023e25692d92402ddcbdbe491359c698
    https://github.com/scummvm/scummvm/commit/3813eddf023e25692d92402ddcbdbe491359c698
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-18T09:01:04-04:00

Commit Message:
MADS: Skip the unused SECTION0.HAG for now

Changed paths:
    engines/mads/resources.cpp



diff --git a/engines/mads/resources.cpp b/engines/mads/resources.cpp
index 2742b5b..aef22d3 100644
--- a/engines/mads/resources.cpp
+++ b/engines/mads/resources.cpp
@@ -150,6 +150,9 @@ void HagArchive::loadIndex() {
 	Common::File hagFile;
 
 	for (int sectionIndex = -1; sectionIndex < 10; ++sectionIndex) {
+		if (sectionIndex == 0)
+			continue;
+
 		Common::String filename = (sectionIndex == -1) ? "GLOBAL.HAG" :
 			Common::String::format("SECTION%d.HAG", sectionIndex);
 		if (!hagFile.open(filename))


Commit: cce0a4a3cf2f3380c25109f055e8b0d87b4c8b32
    https://github.com/scummvm/scummvm/commit/cce0a4a3cf2f3380c25109f055e8b0d87b4c8b32
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-18T09:16:47-04:00

Commit Message:
MADS: Fix some memory leaks in SpriteAsset class

Changed paths:
    engines/mads/assets.cpp



diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index bb6f5bd..46a6d3c 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -49,6 +49,11 @@ SpriteAsset::SpriteAsset(MADSEngine *vm, Common::SeekableReadStream *stream, int
 SpriteAsset::~SpriteAsset() {
 	if (_usageIndex)
 		_vm->_palette->_paletteUsage.resetPalFlags(_usageIndex);
+
+	for (uint i = 0; i < _frames.size(); ++i)
+		delete _frames[i]._frame;
+
+	delete _charInfo;
 }
 
 void SpriteAsset::load(Common::SeekableReadStream *stream, int flags) {


Commit: 058e1ae575cdb6acdc9625076c6449d2600c559c
    https://github.com/scummvm/scummvm/commit/058e1ae575cdb6acdc9625076c6449d2600c559c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-18T21:55:00+02:00

Commit Message:
MADS: Implement scene 309

Changed paths:
    engines/mads/animation.h
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 3b03417..1fff2c4 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -136,15 +136,13 @@ class Animation {
 private:
 	MADSEngine *_vm;
 	Scene *_scene;
-	AAHeader _header;
 
-	Common::Array<int> _spriteListIndexes;
 	Common::Array<AnimMessage> _messages;
 	Common::Array<AnimMiscEntry> _miscEntries;
 	Common::Array<SpriteAsset *> _spriteSets;
 	Font *_font;
 
-	int _currentFrame, _oldFrameEntry;
+	int _currentFrame;
 	bool _freeFlag;
 	bool _skipLoad;
 	int _unkIndex;
@@ -177,9 +175,12 @@ private:
 protected:
 	Animation(MADSEngine *vm, Scene *scene);
 public:
+	AAHeader _header;
+	Common::Array<int> _spriteListIndexes;
 	Common::Array<AnimFrameEntry> _frameEntries;
 	Common::Array<AnimUIEntry> _uiEntries;
 	bool _resetFlag;
+	int _oldFrameEntry;
 
 	static Animation *init(MADSEngine *vm, Scene *scene);
 	/*
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index edefd5b..9978f57 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -115,6 +115,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene307(vm);
 	case 308:
 		return new Scene308(vm);
+	case 309:
+		return new Scene309(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index e107c67..aefc018 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -1149,7 +1149,7 @@ void Scene308::enter() {
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 9);
 	_scene->_sequences.addTimer(48, 70);
 
-	_game._player._visible   = false;
+	_game._player._visible = false;
 	_game._player._stepEnabled = false;
 	_scene->loadAnimation(formAnimName('a', -1), 60);
 
@@ -1198,8 +1198,8 @@ void Scene308::step() {
 		break;
 
 	case 73: {
-		int seqIdx = _globals._sequenceIndexes[3];  
-		_globals._sequenceIndexes[3]  = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 5);
+		int seqIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 5);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 9);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], seqIdx);
 		_scene->_sequences.addTimer(48, 74);
@@ -1219,7 +1219,7 @@ void Scene308::step() {
 		break;
 
 	case 75: { 
-		int seqIdx = _globals._sequenceIndexes[3];  
+		int seqIdx = _globals._sequenceIndexes[3];
 		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 23, 5, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 8, 10);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 9);
@@ -1229,7 +1229,7 @@ void Scene308::step() {
 		break;
 
 	case 76: {
-		int seqIdx = _globals._sequenceIndexes[3];  
+		int seqIdx = _globals._sequenceIndexes[3];
 		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 26, 0, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 2, 3);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 9);
@@ -1247,5 +1247,190 @@ void Scene308::step() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene309::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene309::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites("*SC003x0");
+	_globals._spriteIndexes[0] = _scene->_sprites.addSprites("*SC003x1");
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*SC003x2");
+
+	initForceField(&_forceField, true);
+
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(Resources::formatName(307, 'X', 0, EXT_SS, ""));
+
+	_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
+	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 15);
+
+	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 7, 1, 0, 0);
+	_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -1, 3);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 11);
+	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 3, 70);
+
+	_vm->_palette->setEntry(252, 63, 37, 26);
+	_vm->_palette->setEntry(253, 45, 24, 17);
+	_vm->_palette->setEntry(16, 63, 63, 63);
+	_vm->_palette->setEntry(17, 45, 45, 45);
+	_vm->_palette->setEntry(250, 63, 20, 20);
+	_vm->_palette->setEntry(251, 45, 10, 10);
+
+	_game._player._visible = false;
+	_game._player._stepEnabled = false;
+	_scene->loadAnimation(formAnimName('a', -1), 60);
+
+	_characterSpriteIndexes[0] = _scene->_activeAnimation->_spriteListIndexes[2];
+	_characterSpriteIndexes[1] = _scene->_activeAnimation->_spriteListIndexes[2];
+	_characterSpriteIndexes[2] = _scene->_activeAnimation->_spriteListIndexes[1];
+
+	_messagesIndexes[0] = -1;
+	_messagesIndexes[1] = -1;
+	_messagesIndexes[2] = -1;
+
+	sceneEntrySound();
+
+	_game.loadQuoteSet(0xF7, 0xF8, 0xF9, 0x15C, 0x15D, 0x15E, 0);
+}
+
+void Scene309::step() {
+	handleForceField(&_forceField, &_globals._spriteIndexes[0]);
+
+	if (_game._trigger == 61) {
+		_messagesIndexes[0] = -1;
+		_messagesIndexes[1] = -1;
+	}
+
+	if (_game._trigger == 62)
+		_messagesIndexes[2] = -1;
+
+	if (_scene->_activeAnimation != nullptr) {
+		if (_lastFrame != _scene->_activeAnimation->getCurrentFrame()) {
+			_lastFrame = _scene->_activeAnimation->getCurrentFrame();
+			if (_lastFrame == 39) {
+				_messagesIndexes[0] = _scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 32, 61, 210, _game.getQuote(348));
+				_messagesIndexes[1] = _scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 32, 0, 210, _game.getQuote(349));
+			}
+
+			if (_lastFrame == 97)
+				_messagesIndexes[2] = _scene->_kernelMessages.add(Common::Point(0, 0), 0xFBFA, 32, 62, 180, _game.getQuote(350));
+
+			for (int charIdx = 0; charIdx < 3; charIdx++) {
+				if (_messagesIndexes[charIdx] >= 0) {
+					bool match = false;
+					int j = -1;
+					for (j = _scene->_activeAnimation->_oldFrameEntry; j < _scene->_activeAnimation->_header._frameEntriesCount; j++) {
+						if (_scene->_activeAnimation->_frameEntries[j]._spriteSlot._spritesIndex == _characterSpriteIndexes[charIdx]) {
+							match = true;
+							break;
+						}
+					}
+
+					if (match) {
+						SpriteSlotSubset *curSpriteSlot = &_scene->_activeAnimation->_frameEntries[j]._spriteSlot;
+						_scene->_kernelMessages._entries[_messagesIndexes[charIdx]]._position.x = curSpriteSlot->_position.x;
+						_scene->_kernelMessages._entries[_messagesIndexes[charIdx]]._position.y = curSpriteSlot->_position.y - (50 + (14 * ((charIdx == 0) ? 2 : 1)));
+					}
+				}
+			}
+		}
+	}
+
+	if (_game._trigger >= 70) {
+		switch (_game._trigger) {
+		case 70: {
+			int idx = _scene->_dynamicHotspots.add(689, 690, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+			_scene->_dynamicHotspots.setPosition(idx, Common::Point(142, 146), FACING_NORTHEAST);
+			_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 7, 4, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 2, 3);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 11);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
+			}
+			break;
+
+		case 71: {
+			int _oldIdx = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 7, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 4, 7);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 11);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], _oldIdx);
+			int idx = _scene->_kernelMessages.add(Common::Point(85, 37), 0xFDFC, 0, 0, 120, _game.getQuote(248));
+			_scene->_kernelMessages.setQuoted(idx, 2, true);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 72);
+			}
+			break;
+
+		case 72: {
+			int _oldIdx = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 7, 8, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 8, 11);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 11);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], _oldIdx);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 73);
+			}
+			break;
+
+		case 73: {
+			int _oldIdx = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 7, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 12, 20);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 11);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], _oldIdx);
+			int idx = _scene->_kernelMessages.add(Common::Point(170, 49), 0xFDFC, 0, 0, 120, _game.getQuote(249));
+			_scene->_kernelMessages.setQuoted(idx, 2, true);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 74);
+			}
+			break;
+
+		case 74: {
+			int _oldIdx = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 7, 6, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 21, 23);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 11);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], _oldIdx);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 75);
+			}
+			break;
+
+		case 75: {
+			int _oldIdx = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 6, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 24, 25);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], _oldIdx);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 11);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 76);
+			}
+			break;
+
+		case 76: {
+			int _oldIdx = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 26, 28);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], _oldIdx);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 11);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 77);
+			}
+			break;
+
+		case 77: {
+			_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 90, 0, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 29, 30);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 11);
+			int idx = _scene->_kernelMessages.add(Common::Point(15, 46), 0xFDFC, 0, 0, 120, _game.getQuote(247));
+			_scene->_kernelMessages.setQuoted(idx, 2, true);
+			_scene->_sequences.addTimer(120, 78);
+			}
+			break;
+		}
+	}
+
+	if (_game._trigger == 60)
+		_scene->_nextSceneId = 308;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index d841ce6..4ca2c5a 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -170,6 +170,24 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene309: public Scene3xx {
+private:
+	ForceField _forceField;
+	int _characterSpriteIndexes[3];
+	int _messagesIndexes[3];
+	int _lastFrame;
+	
+public:
+	Scene309(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions() {};
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 66f2a8572155caea28c0ff803d0028710cc7c4ff
    https://github.com/scummvm/scummvm/commit/66f2a8572155caea28c0ff803d0028710cc7c4ff
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-18T22:15:22+02:00

Commit Message:
MADS: Implement scene 310

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 9978f57..ff32eab 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -117,6 +117,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene308(vm);
 	case 309:
 		return new Scene309(vm);
+	case 310:
+		return new Scene310(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index aefc018..b6f5142 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -1432,5 +1432,39 @@ void Scene309::step() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene310::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene310::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites("*SC003x0");
+	_globals._spriteIndexes[0] = _scene->_sprites.addSprites("*SC003x1");
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*SC003x2");
+
+	initForceField(&_forceField, true);
+
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(Resources::formatName(307, 'X', 0, EXT_SS, ""));
+	_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(127, 78));
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 15);
+
+	_game._player._visible = false;
+	_game._player._stepEnabled = false;
+	_scene->loadAnimation(formAnimName('a', -1), 70);
+
+	sceneEntrySound();
+}
+
+void Scene310::step() {
+	handleForceField(&_forceField, &_globals._spriteIndexes[0]);
+
+	if (_game._trigger == 70)
+		_scene->_nextSceneId = 309;
+}
+
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 4ca2c5a..5b380c3 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -188,6 +188,21 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene310: public Scene3xx {
+private:
+	ForceField _forceField;
+
+public:
+	Scene310(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions() {};
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 3fa488db3a9174607d066c017a3f923e1919fd51
    https://github.com/scummvm/scummvm/commit/3fa488db3a9174607d066c017a3f923e1919fd51
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-19T00:57:18+02:00

Commit Message:
MADS: Implement scene 311

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h
    engines/mads/sequence.cpp
    engines/mads/sequence.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index ff32eab..ac2ab85 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -119,6 +119,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene309(vm);
 	case 310:
 		return new Scene310(vm);
+	case 311:
+		return new Scene311(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index b6f5142..59167cc 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -1179,8 +1179,8 @@ void Scene308::step() {
 		}
 		break;
 
-	case 71: { 
-		int seqIdx = _globals._sequenceIndexes[3]; 
+	case 71: {
+		int seqIdx = _globals._sequenceIndexes[3];
 		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 4);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 9);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], seqIdx);
@@ -1218,7 +1218,7 @@ void Scene308::step() {
 		}
 		break;
 
-	case 75: { 
+	case 75: {
 		int seqIdx = _globals._sequenceIndexes[3];
 		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 23, 5, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 8, 10);
@@ -1463,6 +1463,294 @@ void Scene310::step() {
 		_scene->_nextSceneId = 309;
 }
 
+/*------------------------------------------------------------------------*/
+
+void Scene311::setup() {
+	if (_scene->_currentSceneId == 391)
+		_globals[kSexOfRex] = REX_MALE;
+
+	setPlayerSpritesPrefix();
+	setAAName();
+
+	if (_scene->_currentSceneId == 304)
+		_game._player._spritesPrefix = "";
+}
+
+void Scene311::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(Resources::formatName(307, 'X', 0, EXT_SS, ""));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RXCL_8");
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RXCL_2");
+
+	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
+
+	_checkGuardFl = false;
+	_game.loadQuoteSet(0xFA, 0);
+
+	if (_scene->_priorSceneId == 391) {
+		_globals[kSexOfRex] = REX_MALE;
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_game._player._facing = FACING_SOUTH;
+		_game._player._playerPos = Common::Point(166, 101);
+		_scene->_sequences.addTimer(120, 71);
+	} else if (_scene->_priorSceneId == 310)
+		_game._player._playerPos = Common::Point(302, 145);
+	else if (_scene->_priorSceneId == 320) {
+		_game._player._playerPos = Common::Point(129, 113);
+		_game._player._facing = FACING_SOUTH;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+		_scene->loadAnimation(formAnimName('a', -1), 70);
+	}
+
+	sceneEntrySound();
+}
+
+void Scene311::step() {
+	if (_game._trigger == 70)
+		_scene->_nextSceneId = 310;
+
+	if (_game._trigger >= 71) {
+		switch (_game._trigger) {
+		case 71:
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 2);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addTimer(15, 72);
+			break;
+
+		case 72:
+			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addTimer(15, 73);
+			break;
+
+		case 73:
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 3);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+
+			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 3);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addTimer(15, 74);
+			break;
+
+		case 74:
+			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 4, 5);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 75);
+			break;
+
+		case 75: {
+			int oldIdx = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
+			_scene->_sequences.addTimer(15, 76);
+			}
+			break;
+
+		case 76:
+			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 7);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addTimer(15, 77);
+			break;
+
+		case 77:
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 2);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+
+			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 8);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addTimer(15, 78);
+			break;
+
+		case 78:
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
+
+			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 9);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addTimer(15, 79);
+			break;
+
+		case 79:
+			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 10, -2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
+			break;
+
+		case 80:
+			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[3]);
+			_game._player._stepEnabled = true;
+			_game._player._visible = true;
+			break;
+
+		default:
+			break;
+		}
+	}
+
+	if (_game._player._moving && (_scene->_rails.getNext() > 0)) {
+		int x = _game._player._prepareWalkPos.x;
+		if (x < 75)
+			x = 75;
+		if (x > 207)
+			x = 207;
+
+		_checkGuardFl = true;
+		_game._player.startWalking(Common::Point(x, 122), FACING_SOUTH);
+		_scene->_rails.resetNext();
+	}
+}
+
+void Scene311::actions() {
+	if (_action._lookFlag)
+		_vm->_dialogs->show(0x798F);
+	else if (_checkGuardFl) {
+		_checkGuardFl = false;
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.addQuote(0xFA, 120, 0);
+	} else if (_action.isAction(0x21F, 0x1E4))
+		_scene->_nextSceneId = 320;
+	else if (_action.isAction(0x2F7, 0x11)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 50, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 3, -2);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
+
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 15, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, 4);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+
+		case 1: {
+			int oldIdx = _globals._sequenceIndexes[1];
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[1], oldIdx);
+			}
+			break;
+
+		case 2: {
+			int oldIdx = _globals._sequenceIndexes[2];
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 12, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 4, 10);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], oldIdx);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+			}
+			break;
+
+		case 3: {
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 3);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+
+			int oldIdx = _globals._sequenceIndexes[2];
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 11);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(167, 100));
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], oldIdx);
+			_scene->_sequences.addTimer(15, 4);
+			}
+			break;
+
+		case 4:
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 2);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 12, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 12, 14);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(167, 100));
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 5);
+			break;
+
+		case 5: {
+			int oldIdx = _globals._sequenceIndexes[2];
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 15);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(167, 100));
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], oldIdx);
+			_scene->_sequences.addTimer(15, 6);
+			}
+			break;
+
+		case 6:
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+			_scene->_sequences.addTimer(15, 7);
+			break;
+
+		case 7:
+			_scene->_nextSceneId = 313;
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x1E4))
+		_vm->_dialogs->show(0x7986);
+	else if (_action.isAction(VERB_LOOK, 0x18D))
+		_vm->_dialogs->show(0x7987);
+	else if (_action.isAction(VERB_LOOK, 0x220) || _action.isAction(0x155, 0x220))
+		_vm->_dialogs->show(0x7988);
+	else if (_action.isAction(VERB_LOOK, 0x208) || _action.isAction(0x155, 0x208))
+		_vm->_dialogs->show(0x7989);
+	else if (_action.isAction(VERB_TAKE, 0x208))
+		_vm->_dialogs->show(0x798A);
+	else if (_action.isAction(VERB_LOOK, 0xCD) || _action.isAction(0x155, 0xCD))
+		_vm->_dialogs->show(0x798B);
+	else if (_action.isAction(VERB_TAKE, 0xCD))
+		_vm->_dialogs->show(0x798C);
+	else if (_action.isAction(VERB_LOOK, 0x2BA))
+		_vm->_dialogs->show(0x798D);
+	else if (_action.isAction(VERB_LOOK, 0x2B9))
+		_vm->_dialogs->show(0x798E);
+	else if (_action.isAction(VERB_LOOK, 0x11))
+		_vm->_dialogs->show(0x7990);
+	else
+		return;
+
+	_action._inProgress = false;
+}
 
 /*------------------------------------------------------------------------*/
 
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 5b380c3..d4f26f4 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -203,6 +203,20 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene311: public Scene3xx {
+private:
+	bool _checkGuardFl;
+
+public:
+	Scene311(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 3c2bab5..07f7f9c 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -503,4 +503,9 @@ void SequenceList::setMsgLayout(int seqIndex) {
 	updateTimeout(-1, seqIndex);
 }
 
+void SequenceList::setDone(int seqIndex) {
+	_entries[seqIndex]._doneFlag = true;
+	_entries[seqIndex]._timeout = _vm->_game->_player._priorTimer;
+}
+
 } // End of namespace 
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index 6d59175..6cef3de 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -125,6 +125,7 @@ public:
 	void updateTimeout(int spriteIdx, int seqIndex);
 	void setScale(int spriteIdx, int scale);
 	void setMsgLayout(int seqIndex);
+	void setDone(int seqIndex);
 	void sub70C52(int seqIndex, int flags, int deltaX, int deltaY) { warning("TODO: sub70C52()"); }
 };
 


Commit: 559efad195b2ec7e77bd9192328d9e48b2a81e29
    https://github.com/scummvm/scummvm/commit/559efad195b2ec7e77bd9192328d9e48b2a81e29
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-19T14:46:28-04:00

Commit Message:
MADS: Moved Animation::free to be Scene::freeAnimation

Changed paths:
    engines/mads/animation.cpp
    engines/mads/animation.h
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/scene.cpp
    engines/mads/scene.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index b2c2573..ed274eb 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -170,32 +170,6 @@ Animation::~Animation() {
 	}
 }
 
-void Animation::free() {
-	Scene &scene = _vm->_game->_scene;
-	Player &player = _vm->_game->_player;
-
-	if (!scene._freeAnimationFlag) {
-		scene._spriteSlots.fullRefresh(true);
-		scene._sequences.scan();
-	}
-
-	// Refresh the player
-	if (player._visible) {
-		player._forceRefresh = true;
-		player.update();
-	}
-
-	// Remove any kernel messages in use by the animation
-	for (uint i = 0; i < _messages.size(); ++i) {
-		int msgIndex = _messages[i]._kernelMsgIndex;
-		if (msgIndex >= 0)
-			scene._kernelMessages.remove(msgIndex);
-	}
-
-	_resetFlag = false;
-	delete this;
-}
-
 void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
 		const Common::String &resName, int flags, Common::Array<RGB4> *palAnimData,
 		SceneInfo *sceneInfo) {
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 1fff2c4..8afb8cf 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -137,7 +137,6 @@ private:
 	MADSEngine *_vm;
 	Scene *_scene;
 
-	Common::Array<AnimMessage> _messages;
 	Common::Array<AnimMiscEntry> _miscEntries;
 	Common::Array<SpriteAsset *> _spriteSets;
 	Font *_font;
@@ -179,6 +178,7 @@ public:
 	Common::Array<int> _spriteListIndexes;
 	Common::Array<AnimFrameEntry> _frameEntries;
 	Common::Array<AnimUIEntry> _uiEntries;
+	Common::Array<AnimMessage> _messages;
 	bool _resetFlag;
 	int _oldFrameEntry;
 
@@ -189,11 +189,6 @@ public:
 	~Animation();
 
 	/**
-	 * Releases scene resources used by the animation, and then deletes it
-	 */
-	void free();
-
-	/**
 	 * Loads animation data
 	 */
 	void load(UserInterface &interfaceSurface, MSurface &depthSurface, const Common::String &resName,
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index bb5229e..c7ab075 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -1560,7 +1560,7 @@ void Scene104::step() {
 			switch (_game._trigger) {
 			case 0:
 				_scene->_kernelMessages.reset();
-				_scene->_activeAnimation->free();
+				_scene->freeAnimation();
 				_scene->resetScene();
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
@@ -1590,7 +1590,7 @@ void Scene104::step() {
 			switch (_game._trigger) {
 			case 0:
 				_scene->_kernelMessages.reset();
-				_scene->_activeAnimation->free();
+				_scene->freeAnimation();
 				_scene->resetScene();
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
@@ -1629,7 +1629,7 @@ void Scene104::step() {
 			switch (_game._trigger) {
 			case 0:
 				_scene->_kernelMessages.reset();
-				_scene->_activeAnimation->free();
+				_scene->freeAnimation();
 				_scene->resetScene();
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
@@ -2565,7 +2565,7 @@ void Scene109::actions() {
 								}
 							}
 						}
-						_scene->_activeAnimation->free();
+						_scene->freeAnimation();
 						_scene->_sequences.remove(_globals._sequenceIndexes[8]);
 						_scene->_sprites.remove(_globals._spriteIndexes[8]);
 						_scene->_spriteSlots.clear();
@@ -2953,7 +2953,7 @@ void Scene112::enter() {
 void Scene112::step() {
 	if ((_scene->_activeAnimation != nullptr) && (_game._storyMode == STORYMODE_NICE)) {
 		if (_scene->_activeAnimation->getCurrentFrame() >= 54) {
-			_scene->_activeAnimation->free();
+			_scene->freeAnimation();
 			_game._trigger = 70;
 		}
 	}
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 6080c09..a2d3c45 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -3709,7 +3709,7 @@ void Scene210::setDialogNode(int node) {
 			_game._player._visible = false;
 			_vm->_palette->lock();
 			_scene->_kernelMessages.reset();
-			_scene->_activeAnimation->free();
+			_scene->freeAnimation();
 			_scene->_activeAnimation = nullptr;
 			_scene->resetScene();
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 99151c1..65d1c04 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -396,11 +396,8 @@ void Scene::doFrame() {
 		_cyclingActive = true;
 	_vm->_game->_fx = kTransitionNone;
 
-	if (_freeAnimationFlag && _activeAnimation) {
-		_activeAnimation->free();
-		_freeAnimationFlag = false;
-		_activeAnimation = nullptr;
-	}
+	if (_freeAnimationFlag)
+		freeAnimation();
 }
 
 void  Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
@@ -600,4 +597,35 @@ void Scene::resetScene() {
 	_sequences.clear();
 }
 
+void Scene::freeAnimation() {
+	if (_activeAnimation) {
+		Player &player = _vm->_game->_player;
+
+		if (!_freeAnimationFlag) {
+			_spriteSlots.fullRefresh(true);
+			_sequences.scan();
+		}
+
+		// Refresh the player
+		if (player._visible) {
+			player._forceRefresh = true;
+			player.update();
+		}
+
+		// Remove any kernel messages in use by the animation
+		for (uint i = 0; i < _activeAnimation->_messages.size(); ++i) {
+			int msgIndex = _activeAnimation->_messages[i]._kernelMsgIndex;
+			if (msgIndex >= 0)
+				_kernelMessages.remove(msgIndex);
+		}
+
+		// Delete the animation
+		delete _activeAnimation;
+		_activeAnimation = nullptr;
+	}
+
+	_freeAnimationFlag = false;
+}
+
+
 } // End of namespace MADS
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index b695f3b..7944576 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -222,6 +222,11 @@ public:
 	* leaving any player sprites list in place at the start of the list.
 	*/
 	void removeSprites();
+
+	/**
+	 * Frees any currently active animation for the scene
+	 */
+	void freeAnimation();
 };
 
 } // End of namespace MADS


Commit: 34d0bc72b571e5e6e0b4b4f3ee1a627cbf470d72
    https://github.com/scummvm/scummvm/commit/34d0bc72b571e5e6e0b4b4f3ee1a627cbf470d72
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-19T23:27:01+02:00

Commit Message:
MADS: Implement scene 313, come renaming in RGB4 structure, used by AnimPalData

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h
    engines/mads/palette.h
    engines/mads/scene.cpp
    engines/mads/scene_data.cpp



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index ac2ab85..1c19d24 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -121,6 +121,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene310(vm);
 	case 311:
 		return new Scene311(vm);
+	case 313:
+		return new Scene313(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 59167cc..603f875 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -1754,5 +1754,80 @@ void Scene311::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene313::setup() {
+	setPlayerSpritesPrefix();
+	_game._player._spritesPrefix = "RM313A";
+	setAAName();
+}
+
+void Scene313::enter() {
+	_scene->_userInterface.setup(kInputLimitedSentences);
+	gender_timer = 0;
+	gender_threshold = _vm->getRandomNumber(3, 9) * 600;
+
+	if ((_scene->_priorSceneId == 366) || (_scene->_priorSceneId == 316)) {
+		_game._player._playerPos = Common::Point(30, 80);
+		_game._player._facing = FACING_NORTH;
+	} else if ((_scene->_priorSceneId == 311) || (_scene->_priorSceneId == 361) || (_scene->_priorSceneId == 391)) {
+		_game._player._playerPos = Common::Point(90, 70);
+		_game._player._facing = FACING_EAST;
+	} else if (_scene->_priorSceneId == 390) {
+		_game._player._playerPos = Common::Point(126, 70);
+		_game._player._facing = FACING_EAST;
+	} else if ((_scene->_priorSceneId == 389) || (_scene->_priorSceneId == 399)) {
+		_game._player._playerPos = Common::Point(163, 70);
+		_game._player._facing = FACING_WEST;
+	} else if (_scene->_priorSceneId == 388) {
+		_game._player._playerPos = Common::Point(199, 70);
+		_game._player._facing = FACING_WEST;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(234, 70);
+		_game._player._facing = FACING_WEST;
+	}
+
+	if (_globals[kAfterHavoc]) {
+		for (uint16 i = 0; i < _scene->_animPalData.size(); i++) {
+			int palIdx = _scene->_animPalData[i]._firstColorIndex;
+			int size = _scene->_animPalData[i]._colorCount * 3;
+			memset(&_vm->_palette->_savedPalette[palIdx], 0, size);
+			memset(&_vm->_palette->_mainPalette[palIdx], 0, size);
+		}
+	}
+
+	sceneEntrySound();
+}
+
+void Scene313::actions() {
+	if (_action.isAction(0x2FB, 0x2FC))
+		_scene->_nextSceneId = 387;
+	else if (_action.isAction(0x2FB, 0x2FD))
+		_scene->_nextSceneId = 388;
+	else if (_action.isAction(0x2FB, 0x2FE)) {
+		if (_globals[kAfterHavoc])
+			_scene->_nextSceneId = 399;
+		else
+			_scene->_nextSceneId = 389;
+	} else if (_action.isAction(0x2FB, 0x2FF))
+		_scene->_nextSceneId = 390;
+	else if (_action.isAction(0x2FB, 0x2EF)) {
+		if (_globals[kSexOfRex] == REX_FEMALE) {
+			_globals[kSexOfRex] = REX_MALE;
+			_vm->_dialogs->show(0x7A45);
+		}
+		_scene->_nextSceneId = 391;
+	} else if (_action.isAction(0x2FB, 0x300)) {
+		if (_globals[kSexOfRex] == REX_FEMALE) {
+			_globals[kSexOfRex] = REX_MALE;
+			_vm->_dialogs->show(0x7A45);
+		}
+		_scene->_nextSceneId = 366;
+	} else if (!_action.isAction(0x301, 0x2D4))
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index d4f26f4..57b05e8 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -217,6 +217,23 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene313: public Scene3xx {
+private:
+	uint32 gender_clock;
+	uint32 gender_timer;
+	uint32 gender_threshold;
+
+public:
+	Scene313(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 728fd09..b306c8a 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -46,12 +46,12 @@ enum {
 };
 
 struct RGB4 {
-	byte r;
+	byte _colorCount;
 	byte g;
-	byte b;
+	byte _firstColorIndex;
 	byte u;
 
-	RGB4() { r = g = b = u = 0; }
+	RGB4() { _colorCount = g = _firstColorIndex = u = 0; }
 };
 
 struct RGB6 {
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 65d1c04..aff4aa3 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -254,7 +254,7 @@ void Scene::initPaletteAnimation(Common::Array<RGB4> &animData, bool animFlag) {
 	// Calculate total
 	_animCount = 0;
 	for (uint i = 0; i < _animPalData.size(); ++i)
-		_animCount += _animPalData[i].r;
+		_animCount += _animPalData[i]._colorCount;
 
 	_animVal1 = (_animCount > 16) ? 3 : 0;
 	_cyclingActive = animFlag;
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 6eb6be2..d921465 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -67,9 +67,9 @@ void ARTHeader::load(Common::SeekableReadStream *f) {
 	palCount = f->readUint16LE();
 	for (int i = 0; i < palCount; ++i) {
 		RGB4 rgb;
-		rgb.r = f->readByte();
+		rgb._colorCount = f->readByte();
 		rgb.g = f->readByte();
-		rgb.b = f->readByte();
+		rgb._firstColorIndex = f->readByte();
 		rgb.u = f->readByte();
 
 		_palAnimData.push_back(rgb);
@@ -219,7 +219,7 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 
 			for (uint i = 0; i < _palAnimData.size(); ++i) {
 				byte g = _palAnimData[i].g;
-				_palAnimData[i].b = artHeader._palette[g]._palIndex;
+				_palAnimData[i]._firstColorIndex = artHeader._palette[g]._palIndex;
 			}
 		}
 	}


Commit: c4669dd2f2ec850f3a42794dbbc134febed229e2
    https://github.com/scummvm/scummvm/commit/c4669dd2f2ec850f3a42794dbbc134febed229e2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-19T17:43:44-04:00

Commit Message:
MADS: Fix refresh of inventory list after scrolling

Changed paths:
    engines/mads/screen.cpp
    engines/mads/screen.h
    engines/mads/user_interface.cpp



diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 5f09737..9dec5a8 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -54,8 +54,6 @@ void DirtyArea::setArea(int width, int height, int maxWidth, int maxHeight) {
 		right = maxWidth;
 
 	_bounds.right = right;
-	_bounds2.left = _bounds.width() / 2;
-	_bounds2.right = _bounds.left + (_bounds.width() + 1) / 2 - 1;
 
 	if (_bounds.top < 0)
 		_bounds.top = 0;
@@ -68,9 +66,6 @@ void DirtyArea::setArea(int width, int height, int maxWidth, int maxHeight) {
 		bottom = maxHeight;
 
 	_bounds.bottom = bottom;
-	_bounds2.top = _bounds.height() / 2;
-	_bounds2.bottom = _bounds.top + (_bounds.height() + 1) / 2 - 1;
-
 	_active = true;
 }
 
@@ -193,7 +188,7 @@ void DirtyAreas::merge(int startIndex, int count) {
 * Returns true if two dirty areas intersect
 */
 bool DirtyAreas::intersects(int idx1, int idx2) {
-	return (*this)[idx1]._bounds2.intersects((*this)[idx2]._bounds2);
+	return (*this)[idx1]._bounds.intersects((*this)[idx2]._bounds);
 }
 
 void DirtyAreas::mergeAreas(int idx1, int idx2) {
@@ -202,11 +197,6 @@ void DirtyAreas::mergeAreas(int idx1, int idx2) {
 
 	da1._bounds.extend(da2._bounds);
 
-	da1._bounds2.left = da1._bounds.width() / 2;
-	da1._bounds2.right = da1._bounds.left + (da1._bounds.width() + 1) / 2 - 1;
-	da1._bounds2.top = da1._bounds.height() / 2;
-	da1._bounds2.bottom = da1._bounds.top + (da1._bounds.height() + 1) / 2 - 1;
-
 	da2._active = false;
 	da2._mergedArea = &da1;
 	da1._textActive = true;
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index 272ef9e..ba01cbc 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -66,7 +66,6 @@ private:
 	friend class DirtyAreas;
 public:
 	Common::Rect _bounds;
-	Common::Rect _bounds2;
 	bool _textActive;
 	bool _active;
 	DirtyArea *_mergedArea;
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 594d549..7b12ef4 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -98,7 +98,7 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 	if (dirtyAreaPtr)
 		dirtyAreaPtr->_active = true;
 
-	// Copy parts of the user interface background that are going to have sprites drawn
+	// Copy parts of the user interface background that need to be erased
 	for (uint idx = 0; idx < size(); ++idx) {
 		DirtyArea &dirtyArea = userInterface._dirtyAreas[idx];
 		UISlot &slot = (*this)[idx];
@@ -106,11 +106,13 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 		if (dirtyArea._active && dirtyArea._bounds.width() > 0
 				&& dirtyArea._bounds.height() > 0 && slot._flags >= -20) {
 
-			// TODO: Figure out the difference between two copy methods used
 			if (slot._flags >= IMG_ERASE) {
+				// Merge area
+				error("TODO: Create a sprite merge method");
 				userInterface._surface.copyTo(&userInterface, dirtyArea._bounds,
 					Common::Point(dirtyArea._bounds.left, dirtyArea._bounds.top));
 			} else {
+				// Copy area
 				userInterface._surface.copyTo(&userInterface, dirtyArea._bounds,
 					Common::Point(dirtyArea._bounds.left, dirtyArea._bounds.top));
 			}
@@ -183,7 +185,7 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 		if (slot._flags < IMG_STATIC) {
 			if (delFlag || updateFlag)
 				remove_at(idx);
-			else if (slot._flags >= -20)
+			else if (slot._flags > -20)
 				slot._flags -= 20;
 		} else {
 			if (updateFlag)
@@ -721,7 +723,7 @@ void UserInterface::inventoryAnim() {
 	// Loop through the slots list for inventory animation entry
 	for (uint i = 0; i < _uiSlots.size(); ++i) {
 		if (_uiSlots[i]._segmentId == IMG_SPINNING_OBJECT)
-			_uiSlots[i]._flags = -5;
+			_uiSlots[i]._flags = IMG_UPDATE_ONLY;
 	}
 
 	// Add a new slot entry for the inventory animation


Commit: 58378a0965dd2a0631973786500b0fd171b8f680
    https://github.com/scummvm/scummvm/commit/58378a0965dd2a0631973786500b0fd171b8f680
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-19T19:20:57-04:00

Commit Message:
MADS: Implemented MSurface::mergeFrom method

Changed paths:
    engines/mads/msurface.cpp
    engines/mads/msurface.h
    engines/mads/user_interface.cpp



diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 2c9d093..75aad01 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -418,6 +418,50 @@ void MSurface::copyFrom(MSurface *src, const Common::Point &destPos, int depth,
 	}
 }
 
+void MSurface::mergeFrom(MSurface *src, const Common::Rect &srcBounds, const Common::Point &destPos) {
+	// Validation of the rectangle and position	
+	int destX = destPos.x, destY = destPos.y;
+	if ((destX >= w) || (destY >= h))
+		return;
+
+	Common::Rect copyRect = srcBounds;
+	if (destX < 0) {
+		copyRect.left += -destX;
+		destX = 0;
+	}
+	else if (destX + copyRect.width() > w) {
+		copyRect.right -= destX + copyRect.width() - w;
+	}
+	if (destY < 0) {
+		copyRect.top += -destY;
+		destY = 0;
+	}
+	else if (destY + copyRect.height() > h) {
+		copyRect.bottom -= destY + copyRect.height() - h;
+	}
+
+	if (!copyRect.isValidRect())
+		return;
+
+	// Copy the specified area
+
+	byte *data = src->getData();
+	byte *srcPtr = data + (src->getWidth() * copyRect.top + copyRect.left);
+	byte *destPtr = (byte *)pixels + (destY * getWidth()) + destX;
+
+	for (int rowCtr = 0; rowCtr < copyRect.height(); ++rowCtr) {
+		// Process each line of the area
+		for (int xCtr = 0; xCtr < copyRect.width(); ++xCtr) {
+			// Check for the range used for on-screen text, which should be kept intact
+			if (srcPtr[xCtr] < 8 || srcPtr[xCtr] > 15)
+				destPtr[xCtr] = srcPtr[xCtr];
+		}
+
+		srcPtr += src->getWidth();
+		destPtr += getWidth();
+	}
+}
+
 void MSurface::scrollX(int xAmount) {
 	if (xAmount == 0)
 		return;
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index 7cf2bbe..f590bac 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -188,6 +188,14 @@ public:
 	}
 
 	/**
+	* Merges a sub-section of another surface into the current one.
+	* @param src			Source surface
+	* @param srcBounds		Area to copy/merge from
+	* @param destPos		Destination position to draw in current surface
+	*/
+	void mergeFrom(MSurface *src, const Common::Rect &srcBounds, const Common::Point &destPos);
+
+	/**
 	 * Scroll the screen horizontally by a given amount
 	 * @param xAmount	Horizontal amount
 	 */
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 7b12ef4..52b466a 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -108,8 +108,7 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 
 			if (slot._flags >= IMG_ERASE) {
 				// Merge area
-				error("TODO: Create a sprite merge method");
-				userInterface._surface.copyTo(&userInterface, dirtyArea._bounds,
+				userInterface.mergeFrom(&userInterface._surface, dirtyArea._bounds,
 					Common::Point(dirtyArea._bounds.left, dirtyArea._bounds.top));
 			} else {
 				// Copy area


Commit: ad6a80cae796f781e7c8a0e53ad008504c54e266
    https://github.com/scummvm/scummvm/commit/ad6a80cae796f781e7c8a0e53ad008504c54e266
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-19T20:18:39-04:00

Commit Message:
MADS: Add support for sprite flipping in UI background animations

Changed paths:
    engines/mads/animation.cpp
    engines/mads/user_interface.cpp



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index ed274eb..fec7f74 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -101,16 +101,19 @@ void AnimMessage::load(Common::SeekableReadStream *f) {
 void AnimFrameEntry::load(Common::SeekableReadStream *f, bool uiFlag) {
 	if (uiFlag) {
 		f->skip(2);
+		_frameNumber = -1;		// Unused
 		_seqIndex = f->readByte();
 		_spriteSlot._spritesIndex = f->readByte();
-		_spriteSlot._frameNumber = f->readUint16LE();
+		_spriteSlot._frameNumber = (int8)f->readByte();
+		f->skip(1);
 		_spriteSlot._position.x = f->readSint16LE();
 		_spriteSlot._position.y = f->readSint16LE();
 	} else {
 		_frameNumber = f->readUint16LE();
 		_seqIndex = f->readByte();
 		_spriteSlot._spritesIndex = f->readByte();
-		_spriteSlot._frameNumber = f->readUint16LE();
+		uint frame = f->readUint16LE();
+		_spriteSlot._frameNumber = (frame < 0x80) ? frame : -(frame & 0x7f);
 		_spriteSlot._position.x = f->readSint16LE();
 		_spriteSlot._position.y = f->readSint16LE();
 		_spriteSlot._depth = f->readSByte();
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 52b466a..09b3c8d 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -65,7 +65,7 @@ void UISlots::add(const AnimFrameEntry &frameEntry) {
 	ie._flags = IMG_UPDATE;
 	ie._segmentId = frameEntry._seqIndex;
 	ie._spritesIndex = frameEntry._spriteSlot._spritesIndex;
-	ie._frameNumber = frameEntry._frameNumber;
+	ie._frameNumber = frameEntry._spriteSlot._frameNumber;
 	ie._position = frameEntry._spriteSlot._position;
 
 	push_back(ie);
@@ -148,15 +148,25 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 
 			if (dirtyArea->_textActive) {
 				SpriteAsset *asset = scene._sprites[slot._spritesIndex];
-				
+			
+				// Get the frame details
+				int frameNumber = ABS(slot._frameNumber);
+				bool flipped = slot._frameNumber < 0;
+
 				if (slot._segmentId == IMG_SPINNING_OBJECT) {
-					MSprite *sprite = asset->getFrame(slot._frameNumber & 0x7F);
+					MSprite *sprite = asset->getFrame(frameNumber);
 					sprite->copyTo(&userInterface, slot._position, 
 						sprite->getTransparencyIndex());
 				} else {
-					MSprite *sprite = asset->getFrame(slot._frameNumber - 1);
-					sprite->copyTo(&userInterface, slot._position,
-						sprite->getTransparencyIndex());
+					MSprite *sprite = asset->getFrame(frameNumber - 1);
+
+					if (flipped) {
+						MSurface *spr = sprite->flipHorizontal();
+						spr->copyTo(&userInterface, slot._position, sprite->getTransparencyIndex());
+						delete spr;
+					} else {
+						sprite->copyTo(&userInterface, slot._position, sprite->getTransparencyIndex());
+					}
 				}
 			}
 		}
@@ -251,7 +261,7 @@ void UserInterface::load(const Common::String &resName) {
 	// Read in the surface data
 	Common::SeekableReadStream *pixelsStream = madsPack.getItemStream(1);
 	pixelsStream->read(_surface.getData(), MADS_SCREEN_WIDTH * MADS_INTERFACE_HEIGHT);
-	delete pixelsStream;
+	delete pixelsStream; 
 }
 
 void UserInterface::setup(InputMode inputMode) {


Commit: 1362414e77bfbd17d7a0224ce5fb7275c793c7c4
    https://github.com/scummvm/scummvm/commit/1362414e77bfbd17d7a0224ce5fb7275c793c7c4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-19T22:49:14-04:00

Commit Message:
MADS: Implement palette animation code

Changed paths:
    engines/mads/animation.cpp
    engines/mads/animation.h
    engines/mads/dialogs.cpp
    engines/mads/dialogs.h
    engines/mads/events.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/palette.cpp
    engines/mads/palette.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index fec7f74..874ce69 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -112,8 +112,7 @@ void AnimFrameEntry::load(Common::SeekableReadStream *f, bool uiFlag) {
 		_frameNumber = f->readUint16LE();
 		_seqIndex = f->readByte();
 		_spriteSlot._spritesIndex = f->readByte();
-		uint frame = f->readUint16LE();
-		_spriteSlot._frameNumber = (frame < 0x80) ? frame : -(frame & 0x7f);
+		_spriteSlot._frameNumber = f->readSint16LE();
 		_spriteSlot._position.x = f->readSint16LE();
 		_spriteSlot._position.y = f->readSint16LE();
 		_spriteSlot._depth = f->readSByte();
@@ -174,7 +173,7 @@ Animation::~Animation() {
 }
 
 void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
-		const Common::String &resName, int flags, Common::Array<RGB4> *palAnimData,
+		const Common::String &resName, int flags, Common::Array<PaletteCycle> *palCycles,
 		SceneInfo *sceneInfo) {
 	Common::String resourceName = resName;
 	if (!resourceName.contains("."))
@@ -191,7 +190,7 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
 		flags |= PALFLAG_RESERVED;
 
 	if (flags & ANIMFLAG_LOAD_BACKGROUND) {
-		loadInterface(interfaceSurface, depthSurface, _header, flags, palAnimData, sceneInfo);
+		loadInterface(interfaceSurface, depthSurface, _header, flags, palCycles, sceneInfo);
 	}
 	if (flags & ANIMFLAG_LOAD_BACKGROUND_ONLY) {
 		// No data
@@ -376,24 +375,24 @@ bool Animation::drawFrame(SpriteAsset &spriteSet, const Common::Point &pt, int f
 }
 
 void Animation::loadInterface(UserInterface &interfaceSurface, MSurface &depthSurface,
-		AAHeader &header, int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo) {
+		AAHeader &header, int flags, Common::Array<PaletteCycle> *palCycles, SceneInfo *sceneInfo) {
 	_scene->_depthStyle = 0;
 	if (header._animMode <= 2) {
 		_vm->_palette->_paletteUsage.setEmpty();
 		sceneInfo->load(header._roomNumber, flags, header._interfaceFile, 0, depthSurface, interfaceSurface);
 		_scene->_depthStyle = sceneInfo->_depthStyle == 2 ? 1 : 0;
-		if (palAnimData) {
-			palAnimData->clear();
-			for (uint i = 0; i < sceneInfo->_palAnimData.size(); ++i)
-				palAnimData->push_back(sceneInfo->_palAnimData[i]);
+		if (palCycles) {
+			palCycles->clear();
+			for (uint i = 0; i < sceneInfo->_paletteCycles.size(); ++i)
+				palCycles->push_back(sceneInfo->_paletteCycles[i]);
 		}
 	} else if (header._animMode == 4) {
 		// Load a scene interface
 		Common::String resourceName = "*" + header._interfaceFile;
 		interfaceSurface.load(resourceName);
 
-		if (palAnimData)
-			palAnimData->clear();
+		if (palCycles)
+			palCycles->clear();
 	} else {
 		// Original has useless code here
 	}
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 8afb8cf..5faa478 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -165,7 +165,7 @@ private:
 	 * Load the user interface display for an animation
 	 */
 	void loadInterface(UserInterface &interfaceSurface, MSurface &depthSurface,
-		AAHeader &header, int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo);
+		AAHeader &header, int flags, Common::Array<PaletteCycle> *palCycles, SceneInfo *sceneInfo);
 
 	/**
 	 * Returns true if there is a scroll required
@@ -192,7 +192,7 @@ public:
 	 * Loads animation data
 	 */
 	void load(UserInterface &interfaceSurface, MSurface &depthSurface, const Common::String &resName,
-		int flags, Common::Array<RGB4> *palAnimData, SceneInfo *sceneInfo);
+		int flags, Common::Array<PaletteCycle> *palCycles, SceneInfo *sceneInfo);
 
 	/**
 	 * Preload animation data for the scene
diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index 8bc73e5..3c771e7 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -125,7 +125,7 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName,
 	// Save the high end of the palette, and set up the entries for dialog display
 	Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3], 
 		&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3 + 8 * 3], 
-		&_savedPalette[0]);
+		&_cyclingPalette[0]);
 	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_CONTENT1, 2, 0x90, 0x80);
 	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_EDGE, 2, 0x9C, 0x70);
 	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FC, 2, 0x90, 0x80);
@@ -319,7 +319,7 @@ void TextDialog::drawWithInput() {
 }
 
 void TextDialog::restorePalette() {
-	Common::copy(&_savedPalette[0], &_savedPalette[8 * 3],
+	Common::copy(&_cyclingPalette[0], &_cyclingPalette[8 * 3],
 		&_vm->_palette->_mainPalette[248 * 3]);
 	_vm->_palette->setPalette(_vm->_palette->_mainPalette, 248, 8);
 }
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index 0c24dea..e4f9bbb 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -114,7 +114,7 @@ protected:
 	int _askLineNum;
 	Common::String _lines[TEXT_DIALOG_MAX_LINES];
 	int _lineXp[TEXT_DIALOG_MAX_LINES];
-	byte _savedPalette[8 * 3];
+	byte _cyclingPalette[8 * 3];
 public:
 	/**
 	 * Constructor
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 85c62e3..ac03dd5 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -26,6 +26,7 @@
 #include "engines/util.h"
 #include "mads/mads.h"
 #include "mads/events.h"
+#include "mads/scene.h"
 
 #define GAME_FRAME_RATE 50
 #define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE) 
@@ -165,6 +166,9 @@ void EventsManager::checkForNextFrameCounter() {
 		++_frameCounter;
 		_priorFrameTime = milli;
 
+		// Do any palette cycling
+		_vm->_game->_scene.animatePalette();
+
 		// Give time to the debugger
 		_vm->_debugger->onFrame();
 
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 603f875..8287605 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -1786,10 +1786,10 @@ void Scene313::enter() {
 	}
 
 	if (_globals[kAfterHavoc]) {
-		for (uint16 i = 0; i < _scene->_animPalData.size(); i++) {
-			int palIdx = _scene->_animPalData[i]._firstColorIndex;
-			int size = _scene->_animPalData[i]._colorCount * 3;
-			memset(&_vm->_palette->_savedPalette[palIdx], 0, size);
+		for (uint16 i = 0; i < _scene->_paletteCycles.size(); i++) {
+			int palIdx = _scene->_paletteCycles[i]._firstColorIndex;
+			int size = _scene->_paletteCycles[i]._colorCount * 3;
+			memset(&_vm->_palette->_cyclingPalette[palIdx], 0, size);
 			memset(&_vm->_palette->_mainPalette[palIdx], 0, size);
 		}
 	}
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 64e0f80..4a3ea04 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -458,7 +458,6 @@ void Palette::resetGamePalette(int lowRange, int highRange) {
 }
 
 void Palette::initPalette() {
-	RGB4 rgb;
 	uint32 palMask = 1;
 
 	if (_vm->_game->_player._spritesLoaded && _vm->_game->_player._numSprites) {
@@ -528,7 +527,7 @@ void Palette::unlock() {
 void Palette::refreshHighColors() {
 	int val = 18;
 	if (_vm->_game->_scene._cyclingActive)
-		val += _vm->_game->_scene._animCount;
+		val += _vm->_game->_scene._totalCycleColors;
 
 	setPalette(_mainPalette, val, 256 - val);
 }
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index b306c8a..75aff7a 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -45,13 +45,13 @@ enum {
 	PALFLAG_MASK			= 0xfc00   // Mask for all the palette flags   
 };
 
-struct RGB4 {
+struct PaletteCycle {
 	byte _colorCount;
-	byte g;
+	byte _firstListColor;
 	byte _firstColorIndex;
-	byte u;
+	byte _ticks;
 
-	RGB4() { _colorCount = g = _firstColorIndex = u = 0; }
+	PaletteCycle() { _colorCount = _firstListColor = _firstColorIndex = _ticks = 0; }
 };
 
 struct RGB6 {
@@ -165,7 +165,7 @@ protected:
 	void reset();
 public:
 	byte _mainPalette[PALETTE_SIZE];
-	byte _savedPalette[PALETTE_SIZE];
+	byte _cyclingPalette[PALETTE_SIZE];
 	uint32 _palFlags[PALETTE_COUNT];
 	PaletteUsage _paletteUsage;
 	RGBList _rgbList;
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index aff4aa3..78a36d9 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -38,7 +38,8 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 	_sceneLogic = nullptr;
 	_sceneInfo = nullptr;
 	_cyclingActive = false;
-	_animVal1 = 0;
+	_cyclingThreshold = 0;
+	_cyclingDelay = 0;
 	_depthStyle = 0;
 	_roomChanged = false;
 	_reloadSceneFlag = false;
@@ -134,7 +135,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 		_depthSurface, _backgroundSurface);
 
 	// Initialise palette animation for the scene
-	initPaletteAnimation(_sceneInfo->_palAnimData, false);
+	initPaletteAnimation(_sceneInfo->_paletteCycles, false);
 
 	// Copy over nodes
 	_rails.load(_sceneInfo->_nodes, &_depthSurface, _sceneInfo->_depthStyle);
@@ -237,29 +238,75 @@ void Scene::loadVocabStrings() {
 	f.close();
 }
 
-void Scene::initPaletteAnimation(Common::Array<RGB4> &animData, bool animFlag) {
+void Scene::initPaletteAnimation(Common::Array<PaletteCycle> &palCycles, bool animFlag) {
 	// Initialise the animation palette and ticks list
-	_animTicksList.clear();
-	_animPalData.clear();
+	_cycleTicks.clear();
+	_paletteCycles.clear();
 
-	for (uint i = 0; i < animData.size(); ++i) {
-		_animTicksList.push_back(_vm->_events->getFrameCounter());
-		_animPalData.push_back(animData[i]);
+	for (uint i = 0; i < palCycles.size(); ++i) {
+		_cycleTicks.push_back(_vm->_events->getFrameCounter());
+		_paletteCycles.push_back(palCycles[i]);
 	}
 
 	// Save the initial starting palette
 	Common::copy(&_vm->_palette->_mainPalette[0], &_vm->_palette->_mainPalette[PALETTE_SIZE],
-		&_vm->_palette->_savedPalette[0]);
+		&_vm->_palette->_cyclingPalette[0]);
 
 	// Calculate total
-	_animCount = 0;
-	for (uint i = 0; i < _animPalData.size(); ++i)
-		_animCount += _animPalData[i]._colorCount;
+	_totalCycleColors = 0;
+	for (uint i = 0; i < _paletteCycles.size(); ++i)
+		_totalCycleColors += _paletteCycles[i]._colorCount;
 
-	_animVal1 = (_animCount > 16) ? 3 : 0;
+	_cyclingThreshold = (_totalCycleColors > 16) ? 3 : 0;
 	_cyclingActive = animFlag;
 }
 
+void Scene::animatePalette() {
+	byte rgb[3];
+
+	if (_cyclingActive) {
+		Scene::_cyclingDelay++;
+		if (_cyclingDelay >= _cyclingThreshold) {
+			uint32 frameCounter = _vm->_events->getFrameCounter();
+			bool changesFlag = false;
+			for (int idx = 0; idx < _paletteCycles.size(); idx++) {
+				if (frameCounter >= (_cycleTicks[idx] + _paletteCycles[idx]._ticks)) {
+					_cycleTicks[idx] = frameCounter;
+					int count = _paletteCycles[idx]._colorCount;
+					int first = _paletteCycles[idx]._firstColorIndex;
+					int listIndex = _paletteCycles[idx]._firstListColor;
+					changesFlag = true;
+
+					if (count > 1) {
+						// Make a copy of the last color
+						byte *pSrc = &_vm->_palette->_cyclingPalette[first * 3];
+						byte *pEnd = pSrc + count * 3;
+						Common::copy(pEnd - 3, pEnd, &rgb[0]);
+
+						// Shift the cycle palette forward one entry
+						Common::copy_backward(pSrc, pEnd - 3, pEnd);
+
+						// Move the saved color to the start of the cycle
+						Common::copy(&rgb[0], &rgb[3], pSrc);
+
+						if (++listIndex >= count)
+							listIndex = 0;
+					}
+
+					_paletteCycles[idx]._firstListColor = listIndex;
+				}
+			}
+
+			if (changesFlag) {
+				_vm->_palette->setPalette(_vm->_palette->_cyclingPalette,
+					_paletteCycles[0]._firstColorIndex, _totalCycleColors);
+			}
+
+			_cyclingDelay = 0;
+		}
+	}
+}
+
 bool Scene::getDepthHighBits(const Common::Point &pt) {
 	if (_sceneInfo->_depthStyle == 2) {
 		return 0;
@@ -627,5 +674,4 @@ void Scene::freeAnimation() {
 	_freeAnimationFlag = false;
 }
 
-
 } // End of namespace MADS
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 7944576..eb84fbd 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -55,7 +55,7 @@ private:
 	/*
 	 * Initialises the data for palette animation within the scene
 	 */
-	void initPaletteAnimation(Common::Array<RGB4> &animData, bool animFlag);
+	void initPaletteAnimation(Common::Array<PaletteCycle> &palCycles, bool animFlag);
 
 	/**
 	 * Handles a single frame within the game scene
@@ -106,10 +106,11 @@ public:
 	DepthSurface _depthSurface;
 	UserInterface _userInterface;
 	bool _cyclingActive;
-	int _animVal1;
-	int _animCount;
-	Common::Array<uint32> _animTicksList;
-	Common::Array<RGB4> _animPalData;
+	int _cyclingThreshold;
+	int _cyclingDelay;
+	int _totalCycleColors;
+	Common::Array<uint32> _cycleTicks;
+	Common::Array<PaletteCycle> _paletteCycles;
 	Common::StringArray _vocabStrings;
 	Animation *_animationData;
 	Animation *_activeAnimation;
@@ -196,6 +197,11 @@ public:
 	void drawElements(ScreenTransition transitionType, bool surfaceFlag);
 
 	/**
+	* Handles cycling palette colors for the scene
+	*/
+	void animatePalette();
+
+	/**
 	 * Load an animation
 	 */
 	void loadAnimation(const Common::String &resName, int abortTimers = 0);
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index d921465..9f4d7d9 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -63,16 +63,16 @@ void ARTHeader::load(Common::SeekableReadStream *f) {
 	}
 	f->skip(6 * (256 - palCount));
 
-	// Read unknown???
-	palCount = f->readUint16LE();
-	for (int i = 0; i < palCount; ++i) {
-		RGB4 rgb;
-		rgb._colorCount = f->readByte();
-		rgb.g = f->readByte();
-		rgb._firstColorIndex = f->readByte();
-		rgb.u = f->readByte();
-
-		_palAnimData.push_back(rgb);
+	// Read palette animations
+	int cycleCount = f->readUint16LE();
+	for (int i = 0; i < cycleCount; ++i) {
+		PaletteCycle cycle;
+		cycle._colorCount = f->readByte();
+		cycle._firstListColor = f->readByte();
+		cycle._firstColorIndex = f->readByte();
+		cycle._ticks = f->readByte();
+
+		_paletteCycles.push_back(cycle);
 	}
 }
 
@@ -202,9 +202,9 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 	artHeader.load(stream);
 	delete stream;
 
-	// Copy out the palette data
-	for (uint i = 0; i < artHeader._palAnimData.size(); ++i)
-		_palAnimData.push_back(artHeader._palAnimData[i]);
+	// Copy out the palette animation data
+	for (uint i = 0; i < artHeader._paletteCycles.size(); ++i)
+		_paletteCycles.push_back(artHeader._paletteCycles[i]);
 
 	if (!(flags & 1)) {
 		if (!_vm->_palette->_paletteUsage.empty()) {
@@ -217,9 +217,9 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 		if (_usageIndex > 0) {
 			_vm->_palette->_paletteUsage.transform(artHeader._palette);
 
-			for (uint i = 0; i < _palAnimData.size(); ++i) {
-				byte g = _palAnimData[i].g;
-				_palAnimData[i]._firstColorIndex = artHeader._palette[g]._palIndex;
+			for (uint i = 0; i < _paletteCycles.size(); ++i) {
+				byte listColor = _paletteCycles[i]._firstListColor;
+				_paletteCycles[i]._firstColorIndex = artHeader._palette[listColor]._palIndex;
 			}
 		}
 	}
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index e37aa43..5b3d818 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -118,7 +118,7 @@ struct ARTHeader {
 	int _width;
 	int _height;
 	Common::Array<RGB6> _palette;
-	Common::Array<RGB4> _palAnimData;
+	Common::Array<PaletteCycle> _paletteCycles;
 
 	void load(Common::SeekableReadStream *f);
 };
@@ -158,7 +158,7 @@ public:
 	int _field4A;
 
 	int _usageIndex;
-	Common::Array<RGB4> _palAnimData;
+	Common::Array<PaletteCycle> _paletteCycles;
 	WalkNodeList _nodes;
 public:
 	/**


Commit: a05f3fef9eb03a0616c602afa4e80ea2e5bb2f92
    https://github.com/scummvm/scummvm/commit/a05f3fef9eb03a0616c602afa4e80ea2e5bb2f92
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-20T09:27:20+02:00

Commit Message:
MADS: Remove unused variables in scene 313

Changed paths:
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 8287605..7c48548 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -1762,8 +1762,6 @@ void Scene313::setup() {
 
 void Scene313::enter() {
 	_scene->_userInterface.setup(kInputLimitedSentences);
-	gender_timer = 0;
-	gender_threshold = _vm->getRandomNumber(3, 9) * 600;
 
 	if ((_scene->_priorSceneId == 366) || (_scene->_priorSceneId == 316)) {
 		_game._player._playerPos = Common::Point(30, 80);
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 57b05e8..f746b9f 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -219,11 +219,6 @@ public:
 };
 
 class Scene313: public Scene3xx {
-private:
-	uint32 gender_clock;
-	uint32 gender_timer;
-	uint32 gender_threshold;
-
 public:
 	Scene313(MADSEngine *vm) : Scene3xx(vm) {}
 
@@ -234,6 +229,18 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene316: public Scene3xx {
+public:
+	Scene316(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 9d25832a8106478eed9a1b581043c6ae16fc4f5c
    https://github.com/scummvm/scummvm/commit/9d25832a8106478eed9a1b581043c6ae16fc4f5c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-20T11:08:25-04:00

Commit Message:
MADS: Fix color of on-screen text

Changed paths:
    engines/mads/palette.cpp



diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 4a3ea04..d6cf652 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -120,7 +120,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 	}
 
 	int freeIndex;
-	int palCount = tempUsage.getGamePalFreeIndex(&freeIndex);
+	int palCount = getGamePalFreeIndex(&freeIndex);
 	Common::Array<UsageRange> palRange;
 
 	for (uint palIndex = 0; palIndex < palette.size(); ++palIndex) {
@@ -437,16 +437,14 @@ void Palette::resetGamePalette(int lowRange, int highRange) {
 	Common::fill((byte *)&_palFlags[0], (byte *)&_palFlags[PALETTE_COUNT], 0);
 	initVGAPalette(_mainPalette);
 
-	// Init low range to common RGB values
+	// Reserve the start of the palette for things like on-screen text
 	if (lowRange) {
-		Common::fill(&_palFlags[0], &_palFlags[lowRange - 1], 1);
+		Common::fill(&_palFlags[0], &_palFlags[lowRange], 1);
 	}
 
-	// Init high range to common RGB values
+	// Reserve the high end of the palette for dialog display
 	if (highRange) {
-		_palFlags[255] = 1;
-
-		Common::fill(&_palFlags[256 - highRange], &_palFlags[254], _palFlags[255]);
+		Common::fill(&_palFlags[256 - highRange], &_palFlags[256], 1);
 	}
 
 	_rgbList.clear();


Commit: a31cae55a113e2103d6e5359bd27f64f84c16ed5
    https://github.com/scummvm/scummvm/commit/a31cae55a113e2103d6e5359bd27f64f84c16ed5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-20T11:14:11-04:00

Commit Message:
MADS: Added extra initialisation of Scene class fields

Changed paths:
    engines/mads/scene.cpp



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 78a36d9..40a0a8f 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -40,6 +40,7 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 	_cyclingActive = false;
 	_cyclingThreshold = 0;
 	_cyclingDelay = 0;
+	_totalCycleColors = 0;
 	_depthStyle = 0;
 	_roomChanged = false;
 	_reloadSceneFlag = false;
@@ -50,6 +51,11 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 	_frameStartTime = 0;
 	_layer = LAYER_GUI;
 	_lookFlag = false;
+	_bandsRange = 0;
+	_scaleRange = 0;
+	_interfaceY = 0;
+	_spritesCount = 0;
+	_variant = 0;
 
 	_paletteUsageF.push_back(PaletteUsage::UsageEntry(0xF));
 


Commit: 2ccaea811f7c1859fc474eda92e7ceb48b3d5adf
    https://github.com/scummvm/scummvm/commit/2ccaea811f7c1859fc474eda92e7ceb48b3d5adf
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-20T11:32:55-04:00

Commit Message:
MADS: Fix update of palette due to palette cycling

Changed paths:
    engines/mads/scene.cpp



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 40a0a8f..e688816 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -304,8 +304,9 @@ void Scene::animatePalette() {
 			}
 
 			if (changesFlag) {
-				_vm->_palette->setPalette(_vm->_palette->_cyclingPalette,
-					_paletteCycles[0]._firstColorIndex, _totalCycleColors);
+				int firstColor = _paletteCycles[0]._firstColorIndex;
+				byte *pSrc = &_vm->_palette->_cyclingPalette[firstColor * 3];
+				_vm->_palette->setPalette(pSrc, firstColor, _totalCycleColors);
 			}
 
 			_cyclingDelay = 0;


Commit: fb78efa3a798707f86e8902ce10a5370033a9b8d
    https://github.com/scummvm/scummvm/commit/fb78efa3a798707f86e8902ce10a5370033a9b8d
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-20T22:13:24+02:00

Commit Message:
MADS: Implement scene 316

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 1c19d24..8c75cbd 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -123,6 +123,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene311(vm);
 	case 313:
 		return new Scene313(vm);
+	case 316:
+		return new Scene316(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 7c48548..e1d1180 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -1827,5 +1827,462 @@ void Scene313::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene316::setup() {
+	if (_scene->_currentSceneId == 366)
+		_globals[kSexOfRex] = REX_MALE;
+
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene316::handleRexInGrate() {
+	switch (_game._trigger) {
+	case 0:
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+		_scene->_sequences.addTimer(15, 1);
+		break;
+
+	case 1:
+		_scene->_sequences.setDone(_globals._sequenceIndexes[4]);
+		_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 12, 3, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 2, 3);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+		break;
+
+	case 2: {
+		int oldIdx = _globals._sequenceIndexes[4];
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 4, 8);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], oldIdx);
+
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 2, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 12);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 4);
+		}
+		break;
+
+	case 3: {
+		int oldIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 12);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
+		}
+		break;
+
+	case 4: {
+		int oldIdx = _globals._sequenceIndexes[4];
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 10, 11);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], oldIdx);
+
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 5, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 5);
+		}
+		break;
+
+	case 5: {
+		int oldIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 3);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
+
+		oldIdx = _globals._sequenceIndexes[4];
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 12);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], oldIdx);
+		_scene->_sequences.addTimer(15, 6);
+		}
+		break;
+
+	case 6:
+		_scene->_sequences.setDone(_globals._sequenceIndexes[4]);
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 13, 14);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 2, 3);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 7);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 8);
+		break;
+
+	case 7:
+		_scene->_sequences.setDone(_globals._sequenceIndexes[4]);
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 15);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], -1);
+		break;
+
+	case 8: {
+		int oldIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], oldIdx);
+		_scene->_sequences.addTimer(15, 9);
+		}
+		break;
+
+	case 9:
+		_scene->_sequences.setDone(_globals._sequenceIndexes[4]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
+		_scene->_sequences.addTimer(48, 10);
+		break;
+
+	case 10:
+		_scene->_nextSceneId = 313;
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene316::handleRoxInGrate() {
+	int temp;
+	int temp1;
+
+	switch (_game._trigger) {
+	case 0:
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+		_scene->_sequences.addTimer(15, 1);
+		break;
+
+	case 1:
+		_scene->_sequences.setDone(_globals._sequenceIndexes[5]);
+		_globals._sequenceIndexes[5] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], false, 17, 3, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 2, 3);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+		break;
+
+	case 2:
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 17, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 2, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 12);
+
+		temp = _globals._sequenceIndexes[5];
+		_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 17, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 4, 8);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[5], temp);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 4);
+		break;
+
+	case 3:
+		temp1 = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 12);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], temp1);
+		break;
+
+	case 4:
+		temp = _globals._sequenceIndexes[5];
+		_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 17, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 10, 11);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[5], temp);
+
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 17, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 5, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 5);
+		break;
+
+	case 5:
+		temp = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 3);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], temp);
+
+		temp = _globals._sequenceIndexes[5];
+		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 12);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[5], temp);
+		_scene->_sequences.addTimer(20, 6);
+		break;
+
+	case 6:
+		_scene->_sequences.setDone(_globals._sequenceIndexes[5]);
+		_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 17, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 13, 15);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 17, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 2, 3);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 7);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 8);
+		break;
+
+	case 7:
+		_scene->_sequences.setDone(_globals._sequenceIndexes[5]);
+		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 16);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[5], -1);
+		break;
+
+	case 8:
+		temp = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], temp);
+		_scene->_sequences.addTimer(20, 9);
+		break;
+
+	case 9:
+		_scene->_sequences.setDone(_globals._sequenceIndexes[5]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
+		_scene->_sequences.addTimer(48, 10);
+		break;
+
+	case 10:
+		_scene->_nextSceneId = 313;
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene316::enter() {
+	int series;
+
+	if (_globals[kSexOfRex] == REX_MALE) {
+		_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('g', -1));
+		_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXCL_8");
+		_globals._spriteIndexes[6] = _scene->_sprites.addSprites("*RXCL_2");
+	} else {
+		_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('g', 0));
+		_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*ROXCL_8");
+	}
+
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('v', 0));
+	_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 12);
+
+	if (_scene->_priorSceneId == 366) {
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_game._player._playerPos = Common::Point(78, 87);
+		_game._player._facing = FACING_SOUTH;
+		_scene->_sequences.addTimer(48, 70);
+	} else if (_scene->_priorSceneId == 321) {
+		_game._player._playerPos = Common::Point(153, 102);
+		_game._player._facing = FACING_SOUTH;
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_vm->_sound->command(44);
+		series = (_globals[kSexOfRex] == REX_MALE) ? 1 : 2;
+		_globals._sequenceIndexes[1] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[series], false, 6, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 2);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 60);
+	} else if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(291, 126);
+
+	sceneEntrySound();
+	_game.loadQuoteSet(0xFD, 0);
+}
+
+void Scene316::step() {
+	int temp;
+
+	if (_game._trigger == 60) {
+		_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[1]);
+		_game._player._visible = true;
+		_game._player._stepEnabled = true;
+	}
+
+	if (_game._trigger >= 70) {
+		switch (_game._trigger) {
+		case 70:
+			_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 2, 6);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
+
+			_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 12, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 1, 5);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[6]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 72);
+			break;
+
+		case 71:
+			temp = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], temp);
+			break;
+
+		case 72:
+			temp = _globals._sequenceIndexes[6];
+			_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 12, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 6, 9);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[6]);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[6], temp);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 73);
+			break;
+
+		case 73:
+			_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 5);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 12);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[6]);
+
+			_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 12, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 10, -2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[6]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 74);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 75);
+			break;
+
+		case 74:
+			temp = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 12);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], temp);
+			break;
+
+		case 75:
+			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[6]);
+			_game._player._stepEnabled = true;
+			_game._player._visible = true;
+			break;
+
+		default:
+			break;
+		}
+	}
+}
+
+void Scene316::preActions() {
+	if (_action.isAction(0x1AD, 0x2B9)) {
+		if (_globals[kAfterHavoc])
+			_game._player._walkOffScreenSceneId = 354;
+		else
+			_game._player._walkOffScreenSceneId = 304;
+	}
+}
+
+void Scene316::actions() {
+	if (_action.isAction(0x2F7, 0x11)) {
+		if (_globals[kSexOfRex] == REX_FEMALE)
+			handleRoxInGrate();
+		else
+			handleRexInGrate();
+	} else if (_action.isAction(0x227, 0x226) || _action.isAction(0x2B5, 0x22C)) {
+		switch (_game._trigger) {
+		case 0:
+			if (_globals[kCityFlooded]) {
+				_vm->_dialogs->show(0x7B87);
+			} else {
+				_vm->_sound->command(45);
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				if (_globals[kSexOfRex] == REX_MALE) {
+					_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 7, 1, 0, 0);
+					_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], -1, 7);
+					_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 2);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+				} else {
+					_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
+					_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+				}
+			}
+			break;
+
+		case 1:
+			_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 7, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 8, -2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 2);
+			_scene->_kernelMessages.reset();
+			if (!_game._visitedScenes.exists(321))
+				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(253));
+
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+
+		case 2:
+			_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 7, 0, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], -2, -2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 2);
+			_scene->_sequences.addTimer(48, 4);
+			break;
+
+		case 3:
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 7, 0, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -2, -2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2);
+			_scene->_sequences.addTimer(48, 4);
+			break;
+
+		case 4:
+			_scene->_nextSceneId = 321;
+			break;
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x22C))
+		_vm->_dialogs->show(0x7B7A);
+	else if (_action.isAction(VERB_LOOK, 0x1B6)) {
+		if (_game._visitedScenes.exists(321))
+			_vm->_dialogs->show(0x7B7C);
+		else
+			_vm->_dialogs->show(0x7B7B);
+	} else if (_action.isAction(VERB_LOOK, 0x2C6))
+		_vm->_dialogs->show(0x7B7D);
+	else if (_action.isAction(VERB_LOOK, 0x2C7))
+		_vm->_dialogs->show(0x7B7E);
+	else if (_action.isAction(VERB_LOOK, 0x1E0))
+		_vm->_dialogs->show(0x7B7F);
+	else if (_action.isAction(VERB_LOOK, 0xE2))
+		_vm->_dialogs->show(0x7B80);
+	else if (_action.isAction(VERB_LOOK, 0x226))
+		_vm->_dialogs->show(0x7B81);
+	else if (_action.isAction(VERB_LOOK, 0x11))
+		_vm->_dialogs->show(0x7B82);
+	else if (_action.isAction(VERB_LOOK, 0x2B9)) {
+		if (!_globals[kAfterHavoc]) {
+			if (_game._difficulty != DIFFICULTY_IMPOSSIBLE)
+				_vm->_dialogs->show(0x7B84);
+			else
+				_vm->_dialogs->show(0x7B83);
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x89))
+		_vm->_dialogs->show(0x7B85);
+	else if (_action.isAction(VERB_LOOK, 0x257))
+		_vm->_dialogs->show(0x7B86);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index f746b9f..9dd2e12 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -231,6 +231,10 @@ public:
 };
 
 class Scene316: public Scene3xx {
+private:
+	void handleRexInGrate();
+	void handleRoxInGrate();
+
 public:
 	Scene316(MADSEngine *vm) : Scene3xx(vm) {}
 


Commit: 4559444c54a6e910f89532e899058448eb835b08
    https://github.com/scummvm/scummvm/commit/4559444c54a6e910f89532e899058448eb835b08
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-20T17:18:06-04:00

Commit Message:
MADS: Fix calculating Rails::_next

Changed paths:
    engines/mads/rails.cpp



diff --git a/engines/mads/rails.cpp b/engines/mads/rails.cpp
index 342238e..105a853 100644
--- a/engines/mads/rails.cpp
+++ b/engines/mads/rails.cpp
@@ -81,7 +81,7 @@ void Rails::setupRoute(bool bitFlag, const Common::Point &srcPos, const Common::
 	_next = 0;
 	if (_routeIndexes.size() > 0) {
 		Common::Point currPos = srcPos;
-		for (int routeCtr = size() - 1; (routeCtr >= 0) && (_next == 0); --routeCtr) {
+		for (int routeCtr = size() - 1; (routeCtr >= 0) && !_next; --routeCtr) {
 			int idx = _routeIndexes[routeCtr];
 			const Common::Point &pt = _nodes[idx]._walkPos;
 
@@ -124,7 +124,7 @@ void Rails::setupRouteNode(int *routeIndexP, int nodeIndex, int flags, int route
 
 int Rails::scanPath(const Common::Point &srcPos, const Common::Point &destPos) {
 	// For compressed depth surfaces, always return 0
-	if (_depthStyle != 2)
+	if (_depthStyle == 2)
 		return 0;
 
 	int yDiff = destPos.y - srcPos.y;
@@ -135,7 +135,7 @@ int Rails::scanPath(const Common::Point &srcPos, const Common::Point &destPos) {
 		yAmount = -yAmount;
 	}
 
-	int xDiff = destPos.x - srcPos.y;
+	int xDiff = destPos.x - srcPos.x;
 	int xDirection = 1;
 	int xAmount = 0;
 	if (xDiff < 0) {
@@ -150,8 +150,8 @@ int Rails::scanPath(const Common::Point &srcPos, const Common::Point &destPos) {
 	const byte *srcP = _depthSurface->getBasePtr(srcPos.x, srcPos.y);
 	int index = xAmount;
 
-	// Outer horizontal movement loop
-	for (int yIndex = 0; yIndex < yDiff; ++yIndex) {
+	// Outer loop
+	for (int xCtr = 0; xCtr < xDiff; ++xCtr, srcP += xDirection) {
 		index += yDiff;
 		int v = (*srcP & 0x7F) >> 4;
 		if (v)
@@ -167,8 +167,6 @@ int Rails::scanPath(const Common::Point &srcPos, const Common::Point &destPos) {
 
 			srcP += yAmount;
 		}
-
-		srcP += xDirection;
 	}
 
 	return 0;


Commit: 254519296e87e8a6b29305b91c045446b1421d19
    https://github.com/scummvm/scummvm/commit/254519296e87e8a6b29305b91c045446b1421d19
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-20T18:31:18-04:00

Commit Message:
MADS: Beginnings of implementing conversation methods

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index c7ab075..2440068 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -2944,7 +2944,7 @@ void Scene112::enter() {
 	_game._player._stepEnabled = false;
 	_game._player._visible = false;
 
-	_scene->_userInterface.emptyTalkList();
+	_scene->_userInterface.emptyConversationList();
 	_scene->_userInterface.setup(kInputConversation);
 
 	_scene->loadAnimation(Resources::formatName(112, 'X', -1, EXT_AA, ""), 70);
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index a2d3c45..22c7062 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -3689,7 +3689,7 @@ void Scene210::setDialogNode(int node) {
 			_shouldTalk = true;
 			_game._player._stepEnabled = false;
 			if (_twinklesTalking) {
-				_scene->_userInterface.emptyTalkList();
+				_scene->_userInterface.emptyConversationList();
 				_scene->_userInterface.setup(kInputConversation);
 				handleTwinklesSpeech(0xE4, -1, 0);
 				_scene->_sequences.addTimer(180, 2);
@@ -3805,6 +3805,8 @@ void Scene210::restoreDialogNode(int node, int msgId, int posY) {
 }
 
 void Scene210::enter() {
+	UserInterface &userInterface = _vm->_game->_scene._userInterface;
+
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', -1));
 
 	if (!_game._visitedScenes._sceneRevisited)
@@ -3832,7 +3834,8 @@ void Scene210::enter() {
 		0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA,
 		0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC,
 		0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0);
-	warning("TODO: sub71A50(&dialog1, 0x2E, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0);");
+	
+	userInterface.initConversation(&_conv1, 0x2E, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0);
 
 	if (!_game._visitedScenes._sceneRevisited) {
 		warning("TODO: sub71B18(0x2E, 0xB4, 0xB5, 0xB6, 0xB8, 0);");
@@ -3841,12 +3844,13 @@ void Scene210::enter() {
 		warning("TODO: \tsub71B9E(&dialog1, 0xB7, -1);");
 	}
 
-	warning("TODO: sub71A50(&dialog2, 0x2F, 0xBC, 0xBB, 0xBD, _game._visitedScenes._sceneRevisited ? 0, -1);");
-	warning("TODO: sub71A50(&dialog3, 0x30, 0xC3, 0xC2, 0xC1, 0xC4, _game._visitedScenes._sceneRevisited ? 0, -1);");
-	warning("TODO: sub71A50(&dialog5, 0x31, 0xCD, 0xCC, 0xCE, 0xCF, _game._visitedScenes._sceneRevisited ? 0, -1);");
-	warning("TODO: sub71A50(&dialog6, 0x32, 0xD3, 0xD4, 0xD5, _game._visitedScenes._sceneRevisited ? 0, -1);");
-	warning("TODO: sub71A50(&dialog7, 0x33, 0xD8, 0xDA, 0xD9, 0xDB, 0xDC, _game._visitedScenes._sceneRevisited ? 0, -1);");
-	warning("TODO: sub71A50(&dialog8, 0x34, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, _game._visitedScenes._sceneRevisited ? 0, -1);");
+	bool sceneRevisited = _game._visitedScenes._sceneRevisited;
+	userInterface.initConversation(&_conv2, 0x2F, 0xBC, 0xBB, 0xBD, (int)!sceneRevisited);
+	userInterface.initConversation(&_conv3, 0x30, 0xC3, 0xC2, 0xC1, 0xC4, (int)!sceneRevisited);
+	userInterface.initConversation(&_conv5, 0x31, 0xCD, 0xCC, 0xCE, 0xCF, (int)!sceneRevisited);
+	userInterface.initConversation(&_conv6, 0x32, 0xD3, 0xD4, 0xD5, (int)!sceneRevisited);
+	userInterface.initConversation(&_conv7, 0x33, 0xD8, 0xDA, 0xD9, 0xDB, 0xDC, (int)!sceneRevisited);
+	userInterface.initConversation(&_conv8, 0x34, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, (int)!sceneRevisited);
 
 	_twinkleAnimationType = 0;
 	_twinklesCurrentFrame = 0;
@@ -4087,19 +4091,13 @@ void Scene210::preActions() {
 }
 
 void Scene210::actions() {
+	UserInterface &userInterface = _vm->_game->_scene._userInterface;
+
 	if (_action.isAction(VERB_LOOK, 0x27, 0x1C0)) {
 		_vm->_dialogs->show(0x5219);
-		_action._inProgress = false;
-		return;
-	}
-
-	if (_game._screenObjects._inputMode == 1) {
+	} else if (_game._screenObjects._inputMode == 1) {
 		handleDialogs();
-		_action._inProgress = false;
-		return;
-	}
-
-	if (_action.isAction(VERB_TALKTO, 0x1DC) || 
+	} else if (_action.isAction(VERB_TALKTO, 0x1DC) || 
 		((_game._player._playerPos == Common::Point(214, 150)) && (_game._player._facing == FACING_NORTHWEST) && (_twinkleAnimationType == 1) && _stopWalking)) {
 		switch (_game._trigger) {
 		case 0: {
@@ -4146,15 +4144,11 @@ void Scene210::actions() {
 			if (_globals[kTwinklesApproached] < 2)
 				_globals[kTwinklesApproached]++;
 
-			warning("TODO: talk_init(&dialog1);");
+			userInterface.startConversation(&_conv1);
 			_curDialogNode = 1;
 			break;
 		}
-		_action._inProgress = false;
-		return;
-	}
-
-	if (_action.isAction(VERB_GIVE, 0x1DC) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
+	} else if (_action.isAction(VERB_GIVE, 0x1DC) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
 		switch (_game._trigger) {
 		case 0: {
 			int quote = _vm->getRandomNumber(172, 174);
@@ -4170,23 +4164,11 @@ void Scene210::actions() {
 			_shouldMoveHead = false;
 			break;
 		}
-		_action._inProgress = false;
-		return;
-	}
-
-	if (_action.isAction(0x1AD, 0x1BF) || _action.isAction(0x18C, 0x1C0)) {
+	} else if (_action.isAction(0x1AD, 0x1BF) || _action.isAction(0x18C, 0x1C0)) {
 		_scene->_nextSceneId = 205;
-		_action._inProgress = false;
-		return;
-	}
-
-	if (_action.isAction(0x18B, 0x70)) {
+	} else if (_action.isAction(0x18B, 0x70)) {
 		_scene->_nextSceneId = 215;
-		_action._inProgress = false;
-		return;
-	}
-
-	if ((_action.isAction(VERB_PULL, 0x5F) || _action.isAction(VERB_OPEN, 0x5F)) && !_globals[kCurtainOpen]) {
+	} else if ((_action.isAction(VERB_PULL, 0x5F) || _action.isAction(VERB_OPEN, 0x5F)) && !_globals[kCurtainOpen]) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -4204,11 +4186,7 @@ void Scene210::actions() {
 			_scene->_dynamicHotspots.setCursor(_doorway, CURSOR_GO_UP);
 			break;
 		}
-		_action._inProgress = false;
-		return;
-	}
-
-	if ((_action.isAction(VERB_PULL, 0x5F) || _action.isAction(VERB_CLOSE, 0x5F)) && _globals[kCurtainOpen]) {
+	} else if ((_action.isAction(VERB_PULL, 0x5F) || _action.isAction(VERB_CLOSE, 0x5F)) && _globals[kCurtainOpen]) {
 		switch (_game._trigger) {
 		case 0:
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
@@ -4230,11 +4208,7 @@ void Scene210::actions() {
 			_globals[kCurtainOpen] = false;
 			break;
 		}
-		_action._inProgress = false;
-		return;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0xAA)) {
+	} else if (_action.isAction(VERB_LOOK, 0xAA)) {
 		if (_globals[kTwinklesStatus] == TWINKLES_GONE) {
 			if (_game._storyMode == STORYMODE_NAUGHTY)
 				_vm->_dialogs->show(0x520B);
@@ -4243,87 +4217,38 @@ void Scene210::actions() {
 		} else {
 			_vm->_dialogs->show(0x5209);
 		}
-		_action._inProgress = false;
-		return;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0x31)) {
+	} else if (_action.isAction(VERB_LOOK, 0x31)) {
 		_vm->_dialogs->show(0x520C);
-		_action._inProgress = false;
-		return;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0xA7)) {
+	} else if (_action.isAction(VERB_LOOK, 0xA7)) {
 		_vm->_dialogs->show(0x520D);
-		_action._inProgress = false;
-		return;
-	}
-
-	if (_action.isAction(VERB_TAKE, 0xA7) || _action.isAction(VERB_TAKE, 0x31)) {
+	} else if (_action.isAction(VERB_TAKE, 0xA7) || _action.isAction(VERB_TAKE, 0x31)) {
 		_vm->_dialogs->show(0x520E);
-		_action._inProgress = false;
-		return;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0x1C5)) {
+	} else if (_action.isAction(VERB_LOOK, 0x1C5)) {
 		_vm->_dialogs->show(0x520F);
-		_action._inProgress = false;
-		return;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0x3A)) {
+	} else if (_action.isAction(VERB_LOOK, 0x3A)) {
 		_vm->_dialogs->show(0x5210);
-		_action._inProgress = false;
-		return;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0x1B0)) {
+	} else if (_action.isAction(VERB_LOOK, 0x1B0)) {
 		_vm->_dialogs->show(0x5211);
-		_action._inProgress = false;
-		return;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0x1DC)) {
+	} else if (_action.isAction(VERB_LOOK, 0x1DC)) {
 		_vm->_dialogs->show(0x5212);
-		_action._inProgress = false;
-		return;
-	}
-
-	if (_action.isAction(0x13A, 0x1DC) || _action.isAction(0xA6, 0x1DC)) {
+	} else if (_action.isAction(0x13A, 0x1DC) || _action.isAction(0xA6, 0x1DC)) {
 		_vm->_dialogs->show(0x5213);
-		_action._inProgress = false;
-		return;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0x1BF)) {
+	} else if (_action.isAction(VERB_LOOK, 0x1BF)) {
 		_vm->_dialogs->show(0x5214);
-		_action._inProgress = false;
-		return;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0x5F)) {
+	} else if (_action.isAction(VERB_LOOK, 0x5F)) {
 		_vm->_dialogs->show(0x5215);
-		_action._inProgress = false;
-		return;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0x53)) {
+	} else if (_action.isAction(VERB_LOOK, 0x53)) {
 		_vm->_dialogs->show(0x5216);
-		_action._inProgress = false;
-		return;
-	}
-
-	if (_action.isAction(VERB_TAKE, 0x53)) {
+	} else if (_action.isAction(VERB_TAKE, 0x53)) {
 		_vm->_dialogs->show(0x5217);
-		_action._inProgress = false;
-		return;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0x1C0)) {
+	} else if (_action.isAction(VERB_LOOK, 0x1C0)) {
 		_vm->_dialogs->show(0x5218);
-		_action._inProgress = false;
+	} else {
+		// Not handled
 		return;
 	}
+
+	_action._inProgress = false;
 }
 
 /*------------------------------------------------------------------------*/
@@ -4988,7 +4913,7 @@ void Scene216::enter() {
 	_game._player._stepEnabled = false;
 	_game._player._visible = false;
 
-	_scene->_userInterface.emptyTalkList();
+	_scene->_userInterface.emptyConversationList();
 	_scene->_userInterface.setup(kInputConversation);
 	_scene->loadAnimation(formAnimName('A', -1), 60);
 
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 2537b11..f507899 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -214,6 +214,8 @@ private:
 	bool _twinklesTalk2;
 	int _doorway;
 	Common::String _subQuote2;
+	Conversation _conv1, _conv2, _conv3;
+	Conversation _conv5, _conv6, _conv7, _conv8;
 
 	void handleDialogs();
 	void handleSubDialog1();
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 09b3c8d..0a0b896 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -672,8 +672,24 @@ void UserInterface::drawTalkList() {
 	warning("TODO: drawTalkList");
 }
 
-void UserInterface::emptyTalkList() {
-	warning("TODO: emptyTalkList");
+void UserInterface::initConversation(Conversation *conversatin, int globalId, int quoteId, ...) {
+
+}
+
+void UserInterface::setConversation(Conversation *conversation, int quoteId, ...) {
+
+}
+
+void UserInterface::writeConversation(Conversation *conversation, int quoteId, int flag) {
+
+}
+
+void UserInterface::emptyConversationList() {
+	_talkStrings.clear();
+}
+
+void UserInterface::startConversation(Conversation *conversation) {
+
 }
 
 void UserInterface::loadInventoryAnim(int objectId) {
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 52512ef..a6cc9e3 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -93,6 +93,10 @@ public:
 	void draw(bool updateFlag, bool delFlag);
 };
 
+class Conversation {
+public:
+
+};
 
 class UserInterface : public MSurface {
 	friend class UISlots;
@@ -238,7 +242,30 @@ public:
 	*/
 	void updateInventoryScroller();
 
-	void emptyTalkList();
+	/**
+	 * Set up a conversation sequence
+	 */
+	void initConversation(Conversation *conversatin, int globalId, int quoteId, ...);
+
+	/**
+	 * Activates the passed set of quotes in the given conversation node
+	 */
+	void setConversation(Conversation *conversation, int quoteId, ...);
+
+	/** 
+	 * Activates or deactivates the specified quote in the given conversation node
+	 */
+	void writeConversation(Conversation *conversation, int quoteId, int flag);
+
+	/**
+	 * Start an interactive conversation
+	 */
+	void startConversation(Conversation *conversation);
+
+	/**
+	 * Empties the current conversation talk list
+	 */
+	void emptyConversationList();
 };
 
 } // End of namespace MADS


Commit: f0ce06f0e9e0ebcf21368fdf01856a026dd4d2fb
    https://github.com/scummvm/scummvm/commit/f0ce06f0e9e0ebcf21368fdf01856a026dd4d2fb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-20T21:32:29-04:00

Commit Message:
MADS: Implemented display of conversation topics

Changed paths:
    engines/mads/action.cpp
    engines/mads/game.h
    engines/mads/mads.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/screen.cpp
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 2da3c52..9d496d5 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -97,7 +97,8 @@ void MADSAction::set() {
 	if (_commandSource == CAT_TALK_ENTRY) {
 		// Handle showing the conversation selection. Rex at least doesn't actually seem to use this
 		if (_selectedRow >= 0) {
-			Common::String desc = userInterface._talkStrings[userInterface._talkIds[_selectedRow]];
+			_action._verbId = userInterface._talkIds[_selectedRow];
+			Common::String desc = userInterface._talkStrings[_selectedRow];
 			if (!desc.empty())
 				_statusText = desc;
 		}
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 2c87d70..44aa0db 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -77,7 +77,6 @@ protected:
 	bool _quoteEmergency;
 	bool _vocabEmergency;
 	bool _anyEmergency;
-	int _widepipeCtr;
 
 	/**
 	 * Constructor
@@ -136,6 +135,7 @@ public:
 	uint32 _priorFrameTimer;
 	Common::String _aaName;
 	int _winStatus;
+	int _widepipeCtr;
 public:
 	virtual ~Game();
 
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 229d3fc..c40d4bf 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -78,6 +78,7 @@ void MADSEngine::initialise() {
 	MSprite::setVm(this);
 
 	Resources::init(this);
+	Conversation::init(this);
 	_debugger = new Debugger(this);
 	_dialogs = Dialogs::init(this);
 	_events = new EventsManager(this);
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 22c7062..37e7aaa 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -3835,22 +3835,22 @@ void Scene210::enter() {
 		0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC,
 		0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0);
 	
-	userInterface.initConversation(&_conv1, 0x2E, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0);
+	_conv1.setup(0x2E, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0);
 
 	if (!_game._visitedScenes._sceneRevisited) {
-		warning("TODO: sub71B18(0x2E, 0xB4, 0xB5, 0xB6, 0xB8, 0);");
+		_conv1.set(0x2E, 0xB4, 0xB5, 0xB6, 0xB8, 0);
 
-		warning("TODO: if (Debugger_widepipe_ctr >= 2)");
-		warning("TODO: \tsub71B9E(&dialog1, 0xB7, -1);");
+		if (_game._widepipeCtr >= 2)
+			_conv1.write(0xB7, -1);
 	}
 
 	bool sceneRevisited = _game._visitedScenes._sceneRevisited;
-	userInterface.initConversation(&_conv2, 0x2F, 0xBC, 0xBB, 0xBD, (int)!sceneRevisited);
-	userInterface.initConversation(&_conv3, 0x30, 0xC3, 0xC2, 0xC1, 0xC4, (int)!sceneRevisited);
-	userInterface.initConversation(&_conv5, 0x31, 0xCD, 0xCC, 0xCE, 0xCF, (int)!sceneRevisited);
-	userInterface.initConversation(&_conv6, 0x32, 0xD3, 0xD4, 0xD5, (int)!sceneRevisited);
-	userInterface.initConversation(&_conv7, 0x33, 0xD8, 0xDA, 0xD9, 0xDB, 0xDC, (int)!sceneRevisited);
-	userInterface.initConversation(&_conv8, 0x34, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, (int)!sceneRevisited);
+	_conv2.setup(0x2F, 0xBC, 0xBB, 0xBD, (int)!sceneRevisited);
+	_conv3.setup(0x30, 0xC3, 0xC2, 0xC1, 0xC4, (int)!sceneRevisited);
+	_conv5.setup(0x31, 0xCD, 0xCC, 0xCE, 0xCF, (int)!sceneRevisited);
+	_conv6.setup(0x32, 0xD3, 0xD4, 0xD5, (int)!sceneRevisited);
+	_conv7.setup(0x33, 0xD8, 0xDA, 0xD9, 0xDB, 0xDC, (int)!sceneRevisited);
+	_conv8.setup(0x34, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, (int)!sceneRevisited);
 
 	_twinkleAnimationType = 0;
 	_twinklesCurrentFrame = 0;
@@ -4144,7 +4144,7 @@ void Scene210::actions() {
 			if (_globals[kTwinklesApproached] < 2)
 				_globals[kTwinklesApproached]++;
 
-			userInterface.startConversation(&_conv1);
+			_conv1.start();
 			_curDialogNode = 1;
 			break;
 		}
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 9dec5a8..cb914e4 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -436,12 +436,7 @@ void ScreenObjects::elementHighlighted() {
 		break;
 
 	case CAT_TALK_ENTRY:
-		index = 0;
-		for (int idx = 0; idx < 5; ++idx) {
-			if (!userInterface._talkStrings[idx].empty())
-				++index;
-		}
-
+		index = userInterface._talkStrings.size();
 		indexEnd = index - 1;
 		varA = 0;
 		topIndex = 0;
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 0a0b896..48e62a5 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -24,6 +24,7 @@
 #include "mads/mads.h"
 #include "mads/compression.h"
 #include "mads/user_interface.h"
+#include "mads/nebular/game_nebular.h"
 
 namespace MADS {
 
@@ -71,7 +72,6 @@ void UISlots::add(const AnimFrameEntry &frameEntry) {
 	push_back(ie);
 }
 
-
 void UISlots::draw(bool updateFlag, bool delFlag) {
 	Scene &scene = _vm->_game->_scene;
 	UserInterface &userInterface = scene._userInterface;
@@ -207,6 +207,95 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 
 /*------------------------------------------------------------------------*/
 
+MADSEngine *Conversation::_vm;
+
+void Conversation::init(MADSEngine *vm) {
+	_vm = vm;
+}
+
+void Conversation::setup(int globalId, ...) {
+	va_list va;
+	va_start(va, globalId);
+
+	// Load the list of conversation quotes
+	_quotes.clear();
+	int quoteId = va_arg(va, int);
+	while (quoteId > 0) {
+		_quotes.push_back(quoteId);
+		quoteId = va_arg(va, int);
+	}
+	va_end(va);
+
+	assert(_vm->getGameID() == GType_RexNebular);
+	Nebular::GameNebular *game = (Nebular::GameNebular *)_vm->_game;
+	game->_globals[globalId] = -1;
+
+	_globalId = globalId;
+}
+
+void Conversation::set(int quoteId, ...) {
+	assert(_vm->getGameID() == GType_RexNebular);
+	Nebular::GameNebular *game = (Nebular::GameNebular *)_vm->_game;
+	game->_globals[_globalId] = 0;
+
+	va_list va;
+	va_start(va, quoteId);
+
+	// Loop through handling each quote
+	while (quoteId > 0) {
+		for (uint idx = 0; idx < _quotes.size(); ++idx) {
+			if (_quotes[idx] == quoteId) {
+				// Found index, so set that bit in the global keeping track of conversation state
+				game->_globals[_globalId] |= 1 << idx;
+				break;
+			}
+		}
+
+		quoteId = va_arg(va, int);
+	}
+	va_end(va);
+}
+
+void Conversation::write(int quoteId, bool flag) {
+	assert(_vm->getGameID() == GType_RexNebular);
+	Nebular::GameNebular *game = (Nebular::GameNebular *)_vm->_game;
+
+	for (uint idx = 0; idx < _quotes.size(); ++idx) {
+		if (_quotes[idx] == quoteId) {
+			// Found index, so set or clear the flag
+			if (flag) {
+				// Set bit
+				game->_globals[_globalId] |= 1 << idx;
+			} else {
+				// Clear bit
+				game->_globals[_globalId] &= ~(1 << idx);
+			}
+			return;
+		}
+	}
+}
+
+void Conversation::start() {
+	assert(_vm->getGameID() == GType_RexNebular);
+	Nebular::GameNebular *game = (Nebular::GameNebular *)_vm->_game;
+	UserInterface &userInterface = game->_scene._userInterface;
+	userInterface.emptyConversationList();
+
+	// Loop through each of the quotes loaded into the conversation
+	for (uint idx = 0; idx < _quotes.size(); ++idx) {
+		// Check whether the given quote is enabled or not
+		if (game->_globals[_globalId] & (1 << idx)) {
+			// Quote enabled, so add it to the list of talk selections
+			Common::String msg = game->getQuote(_quotes[idx]);
+			userInterface.addConversationMessage(_quotes[idx], msg);
+		}
+	}
+
+	userInterface.setup(kInputConversation);
+}
+
+/*------------------------------------------------------------------------*/
+
 UserInterface::UserInterface(MADSEngine *vm) : _vm(vm), _dirtyAreas(vm), 
 		_uiSlots(vm) {
 	_invSpritesIndex = -1;
@@ -305,7 +394,7 @@ void UserInterface::setup(InputMode inputMode) {
 
 void UserInterface::drawTextElements() {
 	if (_vm->_game->_screenObjects._inputMode) {
-		drawTalkList();
+		drawConversationList();
 	} else {
 		// Draw the actions
 		drawActions();
@@ -466,7 +555,10 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
 		break;
 
 	case CAT_TALK_ENTRY:
-		error("TODO: CAT_TALK_ENTRY");
+		font = _vm->_font->getFont(FONT_INTERFACE);
+		font->setColorMode(id == _highlightedCommandIndex ? SELMODE_HIGHLIGHTED : SELMODE_UNSELECTED);
+		font->writeString(this, _talkStrings[id], Common::Point(bounds.left, bounds.top));
+		break;
 
 	case CAT_INV_SCROLLER:
 		font = _vm->_font->getFont(FONT_MISC);
@@ -668,28 +760,22 @@ void UserInterface::moveRect(Common::Rect &bounds) {
 	bounds.translate(0, MADS_SCENE_HEIGHT);
 }
 
-void UserInterface::drawTalkList() {
-	warning("TODO: drawTalkList");
-}
-
-void UserInterface::initConversation(Conversation *conversatin, int globalId, int quoteId, ...) {
-
-}
-
-void UserInterface::setConversation(Conversation *conversation, int quoteId, ...) {
-
-}
-
-void UserInterface::writeConversation(Conversation *conversation, int quoteId, int flag) {
-
+void UserInterface::drawConversationList() {
+	for (uint idx = 0; idx < _talkStrings.size(); ++idx) {
+		writeVocab(CAT_TALK_ENTRY, idx);
+	}
 }
 
 void UserInterface::emptyConversationList() {
 	_talkStrings.clear();
+	_talkIds.clear();
 }
 
-void UserInterface::startConversation(Conversation *conversation) {
+void UserInterface::addConversationMessage(int vocabId, const Common::String &msg) {
+	assert(_talkStrings.size() < 5);
 
+	_talkStrings.push_back(msg);
+	_talkIds.push_back(vocabId);
 }
 
 void UserInterface::loadInventoryAnim(int objectId) {
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index a6cc9e3..7541bb8 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -42,6 +42,7 @@ enum ScrollbarActive {
 };
 
 class AnimFrameEntry;
+class MADSEngine;
 
 class UISlot {
 public:
@@ -94,8 +95,33 @@ public:
 };
 
 class Conversation {
+private:
+	static MADSEngine *_vm;
+public:
+	static void init(MADSEngine *vm);
 public:
+	int _globalId;
+	Common::Array<int> _quotes;
 
+	/**
+	* Set up a conversation sequence
+	*/
+	void setup(int globalId, ...);
+
+	/**
+	* Activates the passed set of quotes in the given conversation node
+	*/
+	void set(int quoteId, ...);
+
+	/**
+	* Activates or deactivates the specified quote in the given conversation node
+	*/
+	void write(int quoteId, bool flag);
+
+	/**
+	 * Starts the conversation
+	 */
+	void start();
 };
 
 class UserInterface : public MSurface {
@@ -128,7 +154,7 @@ private:
 	/**
 	 * Draw options during a conversation.
 	 */
-	void drawTalkList();
+	void drawConversationList();
 
 	/**
 	 * Draw the action list
@@ -243,29 +269,14 @@ public:
 	void updateInventoryScroller();
 
 	/**
-	 * Set up a conversation sequence
-	 */
-	void initConversation(Conversation *conversatin, int globalId, int quoteId, ...);
-
-	/**
-	 * Activates the passed set of quotes in the given conversation node
-	 */
-	void setConversation(Conversation *conversation, int quoteId, ...);
-
-	/** 
-	 * Activates or deactivates the specified quote in the given conversation node
-	 */
-	void writeConversation(Conversation *conversation, int quoteId, int flag);
-
-	/**
-	 * Start an interactive conversation
+	 * Empties the current conversation talk list
 	 */
-	void startConversation(Conversation *conversation);
+	void emptyConversationList();
 
 	/**
-	 * Empties the current conversation talk list
+	 * Add a msesage to the list of conversation items to select from
 	 */
-	void emptyConversationList();
+	void addConversationMessage(int vocabId, const Common::String &msg);
 };
 
 } // End of namespace MADS


Commit: ed4cedd81675f2ce57356dee90549ef52fb761b3
    https://github.com/scummvm/scummvm/commit/ed4cedd81675f2ce57356dee90549ef52fb761b3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-20T23:07:21-04:00

Commit Message:
MADS: Fixes for scene 210 conversation

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h
    engines/mads/user_interface.cpp



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 37e7aaa..5054fbe 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -3287,7 +3287,7 @@ void Scene210::setup() {
 	_scene->addActiveVocab(0x18B);
 }
 
-void Scene210::handleDialogs() {
+void Scene210::handleConversations() {
 	if (_game._trigger == 0) {
 		_scene->_kernelMessages.reset();
 		_game._player._stepEnabled = false;
@@ -3298,7 +3298,7 @@ void Scene210::handleDialogs() {
 			_scene->_kernelMessages.add(Common::Point(0, -14), 0x1110, 34, 0, 240, subQuote1);
 			_scene->_sequences.addTimer(60, 50);
 		} else {
-			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 1, 12, curQuote);
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 1, 120, curQuote);
 		}
 	} else if (_game._trigger == 50) {
 		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 240, _subQuote2);
@@ -3309,37 +3309,37 @@ void Scene210::handleDialogs() {
 
 		switch (_curDialogNode) {
 		case 1:
-			handleSubDialog1();
+			handleConversation1();
 			break;
 
 		case 2:
-			handleSubDialog2();
+			handleConversation2();
 			break;
 
 		case 3:
-			handleSubDialog3();
+			handleConversation3();
 			break;
 
 		case 5:
-			handleSubDialog5();
+			handleConversation5();
 			break;
 
 		case 6:
-			handleSubDialog6();
+			handleConversation6();
 			break;
 
 		case 7:
-			handleSubDialog7();
+			handleConversation7();
 			break;
 
 		case 8:
-			handleSubDialog8();
+			handleConversation8();
 			break;
 		}
 	}
 }
 
-void Scene210::handleSubDialog1() {
+void Scene210::handleConversation1() {
 	switch (_action._activeAction._verbId) {
 	case 180:
 		setDialogNode(2);
@@ -3363,7 +3363,7 @@ void Scene210::handleSubDialog1() {
 	}
 }
 
-void Scene210::handleSubDialog2() {
+void Scene210::handleConversation2() {
 	switch (_action._activeAction._verbId) {
 	case 187:
 		setDialogNode(3);
@@ -3379,7 +3379,7 @@ void Scene210::handleSubDialog2() {
 	}
 }
 
-void Scene210::handleSubDialog3() {
+void Scene210::handleConversation3() {
 	switch (_action._activeAction._verbId) {
 	case 193:
 		setDialogNode(6);
@@ -3399,7 +3399,7 @@ void Scene210::handleSubDialog3() {
 	}
 }
 
-void Scene210::handleSubDialog5() {
+void Scene210::handleConversation5() {
 	switch (_action._activeAction._verbId) {
 	case 204:
 		setDialogNode(6);
@@ -3416,7 +3416,7 @@ void Scene210::handleSubDialog5() {
 	}
 }
 
-void Scene210::handleSubDialog6() {
+void Scene210::handleConversation6() {
 	switch (_action._activeAction._verbId) {
 	case 211:
 		setDialogNode(7);
@@ -3432,7 +3432,7 @@ void Scene210::handleSubDialog6() {
 	}
 }
 
-void Scene210::handleSubDialog7() {
+void Scene210::handleConversation7() {
 	switch (_action._activeAction._verbId) {
 	case 216:
 	case 217:
@@ -3450,7 +3450,7 @@ void Scene210::handleSubDialog7() {
 	}
 }
 
-void Scene210::handleSubDialog8() {
+void Scene210::handleConversation8() {
 	switch (_action._activeAction._verbId) {
 	case 223:
 	case 224:
@@ -3502,7 +3502,7 @@ void Scene210::setDialogNode(int node) {
 			_nextHandsPlace = 0;
 			_shouldTalk = false;
 			_game._player._stepEnabled = true;
-			initNode(2);
+			newNode(2);
 			break;
 		}
 		break;
@@ -3533,7 +3533,7 @@ void Scene210::setDialogNode(int node) {
 		default:
 			_shouldTalk = false;
 			_game._player._stepEnabled = true;
-			initNode(3);
+			newNode(3);
 			break;
 		}
 		break;
@@ -3588,7 +3588,7 @@ void Scene210::setDialogNode(int node) {
 			_nextHandsPlace = 2;
 			_shouldTalk = false;
 			_game._player._stepEnabled = true;
-			initNode(5);
+			newNode(5);
 			break;
 		}
 		break;
@@ -3622,7 +3622,7 @@ void Scene210::setDialogNode(int node) {
 			_nextHandsPlace = 0;
 			_shouldTalk = false;
 			_game._player._stepEnabled = true;
-			initNode(6);
+			newNode(6);
 			break;
 		}
 		break;
@@ -3649,7 +3649,7 @@ void Scene210::setDialogNode(int node) {
 		default:
 			_shouldTalk = false;
 			_game._player._stepEnabled = true;
-			initNode(7);
+			newNode(7);
 			break;
 		}
 		break;
@@ -3676,7 +3676,7 @@ void Scene210::setDialogNode(int node) {
 		default:
 			_shouldTalk = false;
 			_game._player._stepEnabled = true;
-			initNode(8);
+			newNode(8);
 			break;
 		}
 		break;
@@ -3758,36 +3758,39 @@ void Scene210::handleTwinklesSpeech(int quoteId, int shiftX, uint32 delay) {
 	_scene->_kernelMessages.add(Common::Point(10, 70 + (shiftX * 14)), 0xFDFC, 0, 0, (delay == 0) ? 9999999 : delay, _game.getQuote(quoteId));
 }
 
-void Scene210::initNode(int node) {
+void Scene210::newNode(int node) {
 	_curDialogNode = node;
 
 	switch (_curDialogNode) {
 	case 1:
-		warning("TODO: talk_init(&dialog1);");
+		_conv1.start();
 		break;
 
 	case 2:
-		warning("TODO: talk_init(&dialog2);");
+		_conv2.start();
 		break;
 
 	case 3:
-		warning("TODO: talk_init(&dialog3);");
+		_conv3.start();
 		break;
 
 	case 5:
-		warning("TODO: talk_init(&dialog5);");
+		_conv5.start();
 		break;
 
 	case 6:
-		warning("TODO: talk_init(&dialog6);");
+		_conv6.start();
 		break;
 
 	case 7:
-		warning("TODO: talk_init(&dialog7);");
+		_conv7.start();
 		break;
 
 	case 8:
-		warning("TODO: talk_init(&dialog8);");
+		_conv8.start();
+		break;
+
+	default:
 		break;
 	}
 }
@@ -3801,12 +3804,10 @@ void Scene210::restoreDialogNode(int node, int msgId, int posY) {
 		curQuoteId++;
 	}
 
-	initNode(node);
+	newNode(node);
 }
 
 void Scene210::enter() {
-	UserInterface &userInterface = _vm->_game->_scene._userInterface;
-
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', -1));
 
 	if (!_game._visitedScenes._sceneRevisited)
@@ -3841,16 +3842,16 @@ void Scene210::enter() {
 		_conv1.set(0x2E, 0xB4, 0xB5, 0xB6, 0xB8, 0);
 
 		if (_game._widepipeCtr >= 2)
-			_conv1.write(0xB7, -1);
+			_conv1.write(0xB7, true);
 	}
 
 	bool sceneRevisited = _game._visitedScenes._sceneRevisited;
-	_conv2.setup(0x2F, 0xBC, 0xBB, 0xBD, (int)!sceneRevisited);
-	_conv3.setup(0x30, 0xC3, 0xC2, 0xC1, 0xC4, (int)!sceneRevisited);
-	_conv5.setup(0x31, 0xCD, 0xCC, 0xCE, 0xCF, (int)!sceneRevisited);
-	_conv6.setup(0x32, 0xD3, 0xD4, 0xD5, (int)!sceneRevisited);
-	_conv7.setup(0x33, 0xD8, 0xDA, 0xD9, 0xDB, 0xDC, (int)!sceneRevisited);
-	_conv8.setup(0x34, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, (int)!sceneRevisited);
+	_conv2.setup(0x2F, 0xBC, 0xBB, 0xBD, sceneRevisited ? 0 : -1);
+	_conv3.setup(0x30, 0xC3, 0xC2, 0xC1, 0xC4, sceneRevisited ? 0 : -1);
+	_conv5.setup(0x31, 0xCD, 0xCC, 0xCE, 0xCF, sceneRevisited ? 0 : -1);
+	_conv6.setup(0x32, 0xD3, 0xD4, 0xD5, sceneRevisited ? 0 : -1);
+	_conv7.setup(0x33, 0xD8, 0xDA, 0xD9, 0xDB, 0xDC, sceneRevisited ? 0 : -1);
+	_conv8.setup(0x34, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, sceneRevisited ? 0 : -1);
 
 	_twinkleAnimationType = 0;
 	_twinklesCurrentFrame = 0;
@@ -4091,12 +4092,10 @@ void Scene210::preActions() {
 }
 
 void Scene210::actions() {
-	UserInterface &userInterface = _vm->_game->_scene._userInterface;
-
 	if (_action.isAction(VERB_LOOK, 0x27, 0x1C0)) {
 		_vm->_dialogs->show(0x5219);
 	} else if (_game._screenObjects._inputMode == 1) {
-		handleDialogs();
+		handleConversations();
 	} else if (_action.isAction(VERB_TALKTO, 0x1DC) || 
 		((_game._player._playerPos == Common::Point(214, 150)) && (_game._player._facing == FACING_NORTHWEST) && (_twinkleAnimationType == 1) && _stopWalking)) {
 		switch (_game._trigger) {
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index f507899..ad87681 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -217,17 +217,17 @@ private:
 	Conversation _conv1, _conv2, _conv3;
 	Conversation _conv5, _conv6, _conv7, _conv8;
 
-	void handleDialogs();
-	void handleSubDialog1();
-	void handleSubDialog2();
-	void handleSubDialog3();
-	void handleSubDialog5();
-	void handleSubDialog6();
-	void handleSubDialog7();
-	void handleSubDialog8();
+	void handleConversations();
+	void handleConversation1();
+	void handleConversation2();
+	void handleConversation3();
+	void handleConversation5();
+	void handleConversation6();
+	void handleConversation7();
+	void handleConversation8();
 	void setDialogNode(int node);
 	void handleTwinklesSpeech(int quoteId, int shiftX, uint32 delay);
-	void initNode(int node);
+	void newNode(int node);
 	void restoreDialogNode(int node, int msgId, int posY);
 public:
 	Scene210(MADSEngine *vm) : Scene2xx(vm), _curDialogNode(-1), _nextHandsPlace(0), _twinkleAnimationType(0), _twinklesCurrentFrame(0),
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 48e62a5..a5e8a84 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -226,9 +226,13 @@ void Conversation::setup(int globalId, ...) {
 	}
 	va_end(va);
 
-	assert(_vm->getGameID() == GType_RexNebular);
-	Nebular::GameNebular *game = (Nebular::GameNebular *)_vm->_game;
-	game->_globals[globalId] = -1;
+	if (quoteId < 0) {
+		// For an ending value of -1, also initial the bitflags for the global
+		// associated with the conversation entry, which enables all the quote Ids
+		assert(_vm->getGameID() == GType_RexNebular);
+		Nebular::GameNebular *game = (Nebular::GameNebular *)_vm->_game;
+		game->_globals[globalId] = (int16)0xffff;
+	}
 
 	_globalId = globalId;
 }


Commit: 034773fda7cab67cd5d5e4446daa1402c4f6054d
    https://github.com/scummvm/scummvm/commit/034773fda7cab67cd5d5e4446daa1402c4f6054d
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-21T20:00:32+02:00

Commit Message:
MADS: Implement scene 318, some renaming

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h
    engines/mads/sequence.cpp
    engines/mads/sequence.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 8c75cbd..77146a0 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -125,6 +125,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene313(vm);
 	case 316:
 		return new Scene316(vm);
+	case 318:
+		return new Scene318(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index e1d1180..e828c28 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -485,7 +485,7 @@ void Scene307::handlePrisonerEncounter() {
 	}
 }
 
-void Scene307::handlePrisonerSpeech(int firstQuoteId, int number, long time) {
+void Scene307::handlePrisonerSpeech(int firstQuoteId, int number, long timeout) {
 	int height = number * 14;
 	int posY;
 
@@ -500,7 +500,7 @@ void Scene307::handlePrisonerSpeech(int firstQuoteId, int number, long time) {
 	int quoteId = firstQuoteId;
 	for (int count = 0; count < number; count++) {
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
-		_scene->_kernelMessages.add(Common::Point(5, posY), 0xFDFC, 0, 81, time, _game.getQuote(quoteId));
+		_scene->_kernelMessages.add(Common::Point(5, posY), 0xFDFC, 0, 81, timeout, _game.getQuote(quoteId));
 		posY += 14;
 		quoteId++;
 	}
@@ -2284,5 +2284,591 @@ void Scene316::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene318::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene318::handleDialog() {
+	int temp;
+
+	if (!_game._trigger) {
+		_game._player._stepEnabled = false;
+		handleRexDialogs(_action._activeAction._verbId);
+	} else if (_game._trigger == 2) {
+		temp = _globals._sequenceIndexes[2];
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], temp);
+		_vm->_sound->command(3);
+		_scene->_userInterface.setup(kInputLimitedSentences);
+		_game._player._stepEnabled = true;
+	} else {
+		if (_action._activeAction._verbId < 0x19C)
+			warning("TODO: sub71B9E(&dialog1, _action._activeAction._verbId, false);");
+
+		switch (_action._activeAction._verbId) {
+		case 0x191:
+			handleInternDialog(0x19E, 2, 9999999);
+			warning("TODO: sub71B9E(&dialog1, 0x192, true);");
+			break;
+
+		case 0x192:
+			handleInternDialog(0x1A0, 5, 9999999);
+			warning("TODO: sub71B9E(&dialog1, 0x193, true);");
+			break;
+
+		case 0x193:
+			handleInternDialog(0x1A5, 4, 9999999);
+			warning("TODO: sub71B9E(&dialog1, 0x194, true);");
+			break;
+
+		case 0x194:
+			handleInternDialog(0x1A9, 6, 9999999);
+			warning("TODO: sub71B9E(&dialog1, 0x195, true);");
+			warning("TODO: sub71B9E(&dialog1, 0x196, true);");
+			warning("TODO: sub71B9E(&dialog1, 0x19D, false);");
+			break;
+
+		case 0x195:
+			handleInternDialog(0x1AF, 7, 9999999);
+			warning("TODO: if (!sub71C16(&_dialog1, 0x196))");
+			warning("TODO: \tsub71B9E(&dialog1, 0x197, true);");
+			break;
+
+		case 0x196:
+			handleInternDialog(0x1B6, 5, 9999999);
+			warning("TODO: if (!sub71C16(&_dialog1, 0x195))");
+			warning("TODO: \tsub71B9E(&dialog1, 0x197, true);");
+			break;
+
+		case 0x197:
+			handleInternDialog(0x1BB, 5, 9999999);
+			break;
+
+		case 0x198:
+			handleInternDialog(0x1C0, 5, 9999999);
+			warning("TODO: sub71B9E(&dialog1, 0x19A, true);");
+			break;
+
+		case 0x199:
+			handleInternDialog(0x1C5, 3, 9999999);
+			break;
+
+		case 0x19A:
+			handleInternDialog(0x1C8, 5, 9999999);
+			warning("TODO: sub71B9E(&dialog1, 0x19B, true);");
+			break;
+
+		case 0x19B:
+			handleInternDialog(0x1CD, 3, 9999999);
+			break;
+
+		case 0x19C:
+		case 0x19D:
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 6, 8);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+
+			_dialogFl = false;
+			handleInternDialog(0x1D0, 1, 120);
+			warning("TODO: if ((sub71C16(&_dialog1, 0) == 1) || (_action._activeAction._verbId == 0x19D)) {");
+			_explosionFl = true;
+			_internCounter = 3420;
+			//			}
+			break;
+		}
+
+		if (_action._activeAction._verbId < 0x19C) {
+			warning("TODO: talk_init(&dialog1);");
+			_game._player._stepEnabled = true;
+		}
+
+	}
+}
+
+void Scene318::handleRexDialogs(int quote) {
+	_scene->_kernelMessages.reset();
+
+	Common::String curQuote = _game.getQuote(quote);
+	if (_vm->_font->getWidth(curQuote, _scene->_textSpacing) > 200) {
+		Common::String subQuote1;
+		_game.splitQuote(curQuote, subQuote1, _subQuote2);
+		_scene->_kernelMessages.add(Common::Point(138, 59), 0x1110, 32, 0, 240, subQuote1);
+		_scene->_kernelMessages.add(Common::Point(138, 73), 0x1110, 32, 1, 180, _subQuote2);
+	} else
+		_scene->_kernelMessages.add(Common::Point(138, 73), 0x1110, 32, 1, 120, curQuote);
+}
+
+void Scene318::handleInternDialog(int quoteId, int quoteNum, uint32 timeout) {
+	int height = quoteNum * 14;
+	int posY;
+	if (height < 85)
+		posY = 87 - height;
+	else
+		posY = 2;
+
+	int curQuoteId= quoteId;
+
+	int maxWidth = 0;
+	for (int i = 0; i < quoteNum; i++) {
+		maxWidth = MAX(maxWidth, _vm->_font->getWidth(_game.getQuote(curQuoteId), -1));
+		curQuoteId++;
+	}
+
+	int posX = MIN(319 - maxWidth, 178 - (maxWidth >> 1));
+	curQuoteId = quoteId;
+
+	_scene->_kernelMessages.reset();
+	_internTalkingFl = true;
+
+	for (int i = 0; i < quoteNum; i++) {
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(180, 63);
+		_scene->_kernelMessages.add(Common::Point(posX, posY), 0xFDFC, 0, 0, timeout, _game.getQuote(curQuoteId));
+		posY += 14;
+		curQuoteId++;
+	}
+}
+
+void Scene318::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('k', -1));
+
+	if (_globals[kAfterHavoc]) {
+		_scene->loadAnimation(formAnimName('f', -1));
+		_scene->_activeAnimation->_resetFlag = true;
+	} else if (!_globals[kHasSeenProfPyro]) {
+		_scene->_hotspots.activate(0x3A2, false);
+		_scene->_hotspots.activate(0x3A1, false);
+		_scene->_hotspots.activate(0x165, false);
+	}
+
+	if (_game._objects.isInRoom(OBJ_SCALPEL)) {
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 0, 120);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 4);
+		_scene->_dynamicHotspots.add(0x12C, VERB_TAKE, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+	}
+
+	if (_scene->_priorSceneId == 357)
+		_game._player._playerPos = Common::Point(15, 110);
+	else if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(214, 152);
+
+	warning("TODO: sub71A50(&dialog1, 0x47, 0x191, 0x192, 0x193, 0x194, 0x195, 0x196, 0x197, 0x198, 0x199, 0x19A, 0x19B, 0x19C, 0x19D, 0);");
+
+	if (!_game._visitedScenes._sceneRevisited) {
+		warning("TODO: sub71B18(&dialog1, 0x191, 0x198, 0x199, 0x19C, 0);");
+		warning("TODO: if (Debugger_widepipe_ctr >= 2)");
+		warning("TODO: \tsub71B9E(&dialog1, 0x19D, -1);");
+	}
+
+	if (_scene->_priorSceneId == 307) {
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+		_scene->loadAnimation(formAnimName('a', -1), 60);
+		_animMode = 1;
+	}
+
+	_lastFrame = 0;
+	_scene->_hotspots.activate(0x307, false);
+
+	if (_scene->_priorSceneId != -2) {
+		_dialogFl = false;
+		_internWalkingFl = false;
+		_counter= 0;
+		_internCounter= 0;
+		_internVisibleFl = true;
+		_explosionFl = false;
+	}
+
+	_game.loadQuoteSet(0x18C, 0x18D, 0x18E, 0x18F, 0x191, 0x192, 0x193, 0x194, 0x195, 0x196,
+		0x197, 0x198, 0x199, 0x19A, 0x19B, 0x19C, 0x19E, 0x19E, 0x1A0, 0x1A1, 0x1A2, 0x1A3,
+		0x1A4, 0x1A5, 0x1A6, 0x1A7, 0x1A8, 0x1A9, 0x1AA, 0x1AB, 0x1AC, 0x1AD, 0x1AE, 0x1AF,
+		0x1B0, 0x1B1, 0x1B2, 0x1B3, 0x1B4, 0x1B5, 0x1B6, 0x1B7, 0x1B8, 0x1B9, 0x1BA, 0x1BB,
+		0x1BC, 0x1BD, 0x1BE, 0x1BF, 0x1C0, 0x1C1, 0x1C2, 0x1C3, 0x1C4, 0x1C5, 0x1C6, 0x1C7,
+		0x1C8, 0x1C9, 0x1CA, 0x1CB, 0x1CC, 0x1CD, 0x1CE, 0x1CF, 0x1D0, 0x1D1, 0x1D2, 0x1D3,
+		0x190, 0x19D, 0);
+
+	if ((_scene->_priorSceneId== -2) || (((_scene->_priorSceneId == 318) || (_scene->_priorSceneId == -1)) && (!_globals[kAfterHavoc]))) {
+		if (!_globals[kAfterHavoc]) {
+			_game._player._visible = false;
+			_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('g', -1));
+			_animMode = 2;
+
+			if (_game._visitedScenes.exists(319) || !_internVisibleFl) {
+				_internVisibleFl = false;
+				_dialogFl = false;
+			} else {
+				_scene->loadAnimation(formAnimName('b', -1), 61);
+				_scene->_hotspots.activate(0x307, true);
+			}
+
+			if (_dialogFl) {
+				warning("TODO: talk_init(&dialog1);");
+				_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 8);
+			} else
+				_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
+
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+		}
+	}
+
+	if (_scene->_priorSceneId == 319) {
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_animMode = 4;
+		if (!_globals[kHasSeenProfPyro]) {
+			_scene->loadAnimation(formAnimName('d', -1), 64);
+			_globals[kHasSeenProfPyro] = true;
+		} else {
+			_scene->loadAnimation(formAnimName('e', -1), 64);
+		}
+	}
+
+	_internTalkingFl = false;
+	_vm->_palette->setEntry(252, 63, 63, 10);
+	_vm->_palette->setEntry(253, 45, 45, 05);
+
+	_dropTimer = _globals._frameTime;
+	sceneEntrySound();
+
+	if (_dialogFl)
+		_vm->_sound->command(15);
+}
+
+void Scene318::step() {
+	if ((_scene->_activeAnimation != nullptr) && (_animMode == 2)) {
+		if (_lastFrame != _scene->_activeAnimation->getCurrentFrame()) {
+			_lastFrame = _scene->_activeAnimation->getCurrentFrame();
+			int nextFrame = -1;
+
+			switch (_lastFrame) {
+			case 20:
+			case 30:
+			case 40:
+			case 50:
+			case 60:
+			case 70:
+			case 80:
+			case 90:
+			case 100:
+			case 110:
+			case 120:
+			case 130:
+			case 140:
+			case 149:
+				if (_internWalkingFl) {
+					nextFrame = 149;
+				} else if (_internTalkingFl) {
+					nextFrame = 149;
+				} else if (_lastFrame == 149) {
+					nextFrame = 4;
+				}
+				break;
+
+			case 151:
+				if (_internWalkingFl)
+					nextFrame = 183;
+				break;
+
+			case 167:
+			case 184:
+				if (_internWalkingFl) {
+					nextFrame = 184;
+				} else if (!_internTalkingFl) {
+					nextFrame = 0;
+				} else if (_vm->getRandomNumber(1, 100) <= 50) {
+					nextFrame = 151;
+				} else {
+					nextFrame = 167;
+				}
+
+				if (nextFrame == 184) {
+					handleInternDialog(0x1D1, 3, 240);
+					_scene->_hotspots.activate(0x307, false);
+					_internVisibleFl = false;
+				}
+				break;
+			}
+
+			if ((nextFrame >= 0) && (nextFrame != _scene->_activeAnimation->getCurrentFrame())) {
+				_scene->_activeAnimation->setCurrentFrame(nextFrame);
+				_lastFrame = nextFrame;
+			}
+		}
+	}
+
+	switch (_game._trigger) {
+	case 60:
+		_vm->_sound->command(3);
+		_animMode = 2;
+		_scene->_reloadSceneFlag= true;
+		break;
+
+	case 61:
+		_counter = 0;
+		break;
+
+	case 62:
+		_scene->_nextSceneId = 319;
+		break;
+
+	case 63:
+		_internTalkingFl = false;
+		break;
+
+	case 64:
+		_vm->_sound->command(3);
+		_scene->_nextSceneId = 307;
+		break;
+	}
+
+	uint32 tmpFrame = _vm->_events->getFrameCounter();
+	uint32 diffFrame = tmpFrame - _lastFrameCounter;
+	_lastFrameCounter = tmpFrame;
+
+	if ((_animMode == 2) && !_internVisibleFl && _game._player._stepEnabled) {
+		if ((diffFrame >= 0) && (diffFrame <= 4))
+			_counter += diffFrame;
+		else
+			_counter++;
+
+		int extraCounter = _game._objects.isInInventory(OBJ_SCALPEL) ? 900 : 0;
+
+		if (_counter + extraCounter >= 1800) {
+			_scene->freeAnimation();
+			_game._player._stepEnabled = false;
+			_scene->loadAnimation(formAnimName('c', -1), 62);
+			_animMode = 3;
+		}
+	} else if ((_animMode == 2) && _explosionFl && _internVisibleFl && !_dialogFl
+			&& !_internWalkingFl && (_game._screenObjects._inputMode != 1)) {
+		if ((diffFrame >= 0) && (diffFrame <= 4))
+			_internCounter += diffFrame;
+		else
+			_internCounter++;
+
+		if (_internCounter >= 3600) {
+			_vm->_sound->command(59);
+			warning("TODO: shake_countdown = 20;");
+			_internWalkingFl = true;
+		}
+	}
+
+	if ((_globals._frameTime - _dropTimer) > 600) {
+		_vm->_sound->command(51);
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 14, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
+		_dropTimer = _globals._frameTime;
+	}
+}
+
+void Scene318::preActions() {
+	if (_game._player._needToWalk)
+		_game._player._needToWalk = _game._player._visible;
+
+	if (_action.isAction(0x1AD, 0x2BA))
+		_game._player._walkOffScreenSceneId = 357;
+}
+
+void Scene318::actions() {
+	if (_game._screenObjects._inputMode == 1) {
+		handleDialog();
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_TALKTO, 0x307)) {
+		switch (_game._trigger) {
+		case 0: {
+			_dialogFl = true;
+			_vm->_sound->command(15);
+			_game._player._stepEnabled = false;
+			handleRexDialogs(_vm->getRandomNumber(0x18C, 0x18E));
+
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 80);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 6, 8);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			}
+			break;
+
+		case 1:
+			_game._player._stepEnabled = true;
+			handleInternDialog(0x18F, 1, 9999999);
+			warning("TODO: talk_init(&dialog1);");
+			break;
+
+		case 2: {
+			int oldIdx = _globals._sequenceIndexes[2];
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 8);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], oldIdx);
+			}
+			break;
+
+		default:
+			break;
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_TAKE, 0x12C) && (_game._objects.isInRoom(OBJ_SCALPEL) || _game._trigger)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 8, 2, 0, 80);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 2, 5);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 5, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+
+		case 1:
+			if (_internVisibleFl)
+				handleInternDialog(0x190, 1, 120);
+			else {
+				_game._objects.addToInventory(OBJ_SCALPEL);
+				_vm->_dialogs->showItem(OBJ_SCALPEL, 0x7C5D);
+				_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+			}
+			break;
+
+		case 2: {
+			int oldIdx = _globals._sequenceIndexes[2];
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], oldIdx);
+			_scene->_sequences.addTimer(60, 3);
+			}
+			break;
+
+		case 3:
+			_game._player._stepEnabled = true;
+			break;
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_game._player._visible) {
+		if (_action.isAction(0x1AD, 0x2B3)) {
+			_scene->_nextSceneId = 407;
+			_action._inProgress = false;
+			return;
+		}
+
+		if (_action.isAction(VERB_TAKE, 0x165)) {
+			if (_game._objects.isInRoom(OBJ_AUDIO_TAPE)) {
+				_vm->_dialogs->showItem(OBJ_AUDIO_TAPE, 0x7C5B);
+				_game._objects.addToInventory(OBJ_AUDIO_TAPE);
+			} else
+				_vm->_dialogs->show(0x7C5A);
+
+			_action._inProgress = false;
+			return;
+		}
+
+		if (_action.isAction(VERB_LOOK, 0x165)) {
+			if (_game._objects.isInRoom(OBJ_AUDIO_TAPE))
+				_vm->_dialogs->show(0x7C59);
+			else
+				_vm->_dialogs->show(0x7C5A);
+
+			_action._inProgress = false;
+			return;
+		}
+
+		if (_action.isAction(0x242, 0x488)) {
+			_vm->_dialogs->show(0x7C57);
+			_action._inProgress = false;
+			return;
+		}
+
+		if (_action.isAction(VERB_LOOK, 0x2D9)) {
+			_vm->_dialogs->show(0x7C4F);
+			_action._inProgress = false;
+			return;
+		}
+
+		if (_action.isAction(VERB_LOOK, 0x308)) {
+			_vm->_dialogs->show(0x7C51);
+			_action._inProgress = false;
+			return;
+		}
+	} else { // Not visible
+		if (_action.isAction(VERB_LOOK, 0x2D9)) {
+			_vm->_dialogs->show(0x7C4E);
+			_action._inProgress = false;
+			return;
+		}
+
+		if (_action.isAction(VERB_LOOK, 0x308)) {
+			_vm->_dialogs->show(0x7C50);
+			_action._inProgress = false;
+			return;
+		}
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x18D))
+		_vm->_dialogs->show(0x7C42);
+	else if (_action.isAction(VERB_LOOK, 0x89))
+		_vm->_dialogs->show(0x7C43);
+	else if (_action.isAction(VERB_LOOK, 0x2BA))
+		_vm->_dialogs->show(0x7C44);
+	else if (_action.isAction(VERB_LOOK, 0x2B3))
+		_vm->_dialogs->show(0x7C45);
+	else if (_action.isAction(VERB_LOOK, 0x2CB))
+		_vm->_dialogs->show(0x7C46);
+	else if (_action.isAction(VERB_LOOK, 0x216))
+		_vm->_dialogs->show(0x7C47);
+	else if (_action.isAction(VERB_LOOK, 0x319))
+		_vm->_dialogs->show(0x7C48);
+	else if (_action.isAction(VERB_LOOK, 0x477))
+		_vm->_dialogs->show(0x7C49);
+	else if (_action.isAction(VERB_LOOK, 0xE2))
+		_vm->_dialogs->show(0x7C4A);
+	else if (_action.isAction(VERB_LOOK, 0x2C9))
+		_vm->_dialogs->show(0x7C4B);
+	else if (_action.isAction(VERB_LOOK, 0x2C7))
+		_vm->_dialogs->show(0x7C4C);
+	else if (_action.isAction(VERB_LOOK, 0x2C8))
+		_vm->_dialogs->show(0x7C4D);
+	else if (_action.isAction(VERB_OPEN, 0x2C9))
+		_vm->_dialogs->show(0x7C55);
+	else if (_action.isAction(VERB_LOOK, 0x307))
+		_vm->_dialogs->show(0x7C56);
+	else if (_action.isAction(VERB_LOOK, 0x3A1))
+		_vm->_dialogs->show(0x7C58);
+	else if (_action.isAction(VERB_LOOK, 0x3A2))
+		_vm->_dialogs->show(0x7C5C);
+	else if (_action._lookFlag) {
+		if (_game._player._visible || _game._objects.isInInventory(OBJ_SCALPEL))
+			_vm->_dialogs->show(0x7C54);
+		else if (_internVisibleFl)
+			_vm->_dialogs->show(0x7C52);
+		else
+			_vm->_dialogs->show(0x7C53);
+	} else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 9dd2e12..c563102 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -142,7 +142,7 @@ private:
 	void handlePrisonerDialog();
 	void handlePrisonerEncounter();
 	void setDialogNode(int node);
-	void handlePrisonerSpeech(int firstQuoteId, int number, long time);
+	void handlePrisonerSpeech(int firstQuoteId, int number, long timeout);
 
 public:
 	Scene307(MADSEngine *vm) : Scene3xx(vm) {}
@@ -245,6 +245,43 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene318: public Scene3xx {
+private:
+	uint32 _dropTimer;
+
+	int _lastFrame;
+	int _animMode;
+	int _internCounter;
+	int _counter;
+
+	bool _dialogFl;
+	bool _internTalkingFl;
+	bool _internWalkingFl;
+	bool _internVisibleFl;
+	bool _explosionFl;
+
+	uint32 _lastFrameCounter;
+
+	Common::String _subQuote2;
+
+	// dialog1
+
+	void handleDialog();
+	void handleRexDialogs(int quote);
+	void handleInternDialog(int quoteId, int quoteNum, uint32 timeout);
+
+public:
+	Scene318(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index 07f7f9c..b46b5c0 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -142,7 +142,7 @@ int SequenceList::add(int spriteListIndex, bool flipped, int frameIndex, int tri
 	return seqIndex;
 }
 
-int SequenceList::addTimer(int time, int abortVal) {
+int SequenceList::addTimer(int timeout, int abortVal) {
 	Scene &scene = _vm->_game->_scene;
 	uint seqIndex;
 	for (seqIndex = 0; seqIndex < _entries.size(); ++seqIndex) {
@@ -154,9 +154,9 @@ int SequenceList::addTimer(int time, int abortVal) {
 	SequenceEntry &se = _entries[seqIndex];
 	se._active = true;
 	se._spritesIndex = -1;
-	se._numTicks = time;
+	se._numTicks = timeout;
 	se._extraTicks = 0;
-	se._timeout = scene._frameStartTime + time;
+	se._timeout = scene._frameStartTime + timeout;
 	se._triggerCountdown = true;
 	se._doneFlag = false;
 	se._entries._count = 0;
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index 6cef3de..5f052e9 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -104,7 +104,7 @@ public:
 		int extraTicks, int numTicks, int msgX, int msgY, bool nonFixed, int scale, int depth,
 		int frameInc, SpriteAnimType animType, int numSprites, int frameStart);
 	
-	int addTimer(int time, int abortVal);
+	int addTimer(int timeout, int abortVal);
 	void remove(int seqIndex);
 	void setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot);
 	bool loadSprites(int seqIndex);


Commit: 0e6c4abd13e7bea64ce36537cc8c4ebb03ccfbfc
    https://github.com/scummvm/scummvm/commit/0e6c4abd13e7bea64ce36537cc8c4ebb03ccfbfc
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-21T23:54:15+02:00

Commit Message:
MADS: Use Conversation class in Scene Group 3

Changed paths:
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index e828c28..1928461 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -516,13 +516,13 @@ void Scene307::setDialogNode(int node) {
 	case 1:
 		_globals[kMetBuddyBeast] = true;
 		handlePrisonerSpeech(0x10F, 2, 9999999);
-		warning("TODO: talk_init(&dialog1);");
+		dialog1.start();
 		break;
 
 	case 2:
 		_globals[kMetBuddyBeast] = true;
 		handlePrisonerSpeech(0x111, 2, 9999999);
-		warning("TODO: talk_init(&dialog1);");
+		dialog1.start();
 		break;
 
 	case 4:
@@ -533,7 +533,7 @@ void Scene307::setDialogNode(int node) {
 	case 5:
 		_globals[kKnowsBuddyBeast] = true;
 		handlePrisonerSpeech(0x117, 2, 9999999);
-		warning("TODO: talk_init(&dialog2);");
+		dialog2.start();
 		break;
 
 	case 6:
@@ -544,57 +544,57 @@ void Scene307::setDialogNode(int node) {
 	case 7:
 		_globals[kKnowsBuddyBeast] = true;
 		handlePrisonerSpeech(0x124, 10, 9999999);
-		warning("TODO: sub71B9E(&dialog2, 0x11A, false);");
-		warning("TODO: sub71B9E(&dialog2, 0x11B, true);");
-		warning("TODO: sub71B9E(&dialog2, 0x120, true);");
-		warning("TODO: talk_init(&dialog2);");
+		dialog2.write(0x11A, false);
+		dialog2.write(0x11B, true);
+		dialog2.write(0x120, true);
+		dialog2.start();
 		break;
 
 	case 8:
 		handlePrisonerSpeech(0x12E, 6, 9999999);
-		warning("TODO: sub71B9E(&dialog2, 0x11A, false);");
-		warning("TODO: sub71B9E(&dialog2, 0x11B, false);");
-		warning("TODO: sub71B9E(&dialog2, 0x11C, true);");
-		warning("TODO: sub71B9E(&dialog2, 0x11D, true);");
-		warning("TODO: sub71B9E(&dialog2, 0x11F, true);");
-		warning("TODO: talk_init(&dialog2);");
+		dialog2.write(0x11A, false);
+		dialog2.write(0x11B, false);
+		dialog2.write(0x11C, true);
+		dialog2.write(0x11D, true);
+		dialog2.write(0x11F, true);
+		dialog2.start();
 		break;
 
 	case 9:
 		handlePrisonerSpeech(0x134, 4, 9999999);
-		warning("TODO: sub71B9E(&dialog2, 0x11D, false);");
-		warning("TODO: talk_init(&dialog2);");
+		dialog2.write(0x11D, false);
+		dialog2.start();
 		break;
 
 	case 10:
 		handlePrisonerSpeech(0x138, 6, 9999999);
-		warning("TODO: sub71B9E(&dialog2, 0x11E, false);");
-		warning("TODO: talk_init(&dialog2);");
+		dialog2.write(0x11E, false);
+		dialog2.start();
 		break;
 
 	case 11:
 		handlePrisonerSpeech(0x13E, 6, 9999999);
-		warning("TODO: sub71B9E(&dialog2, 0x11F, false);");
-		warning("TODO: sub71B9E(&dialog2, 0x121, true);");
-		warning("TODO: talk_init(&dialog2);");
+		dialog2.write(0x11F, false);
+		dialog2.write(0x121, true);
+		dialog2.start();
 		break;
 
 	case 12:
 		handlePrisonerSpeech(0x144, 4, 9999999);
-		warning("TODO: sub71B9E(&dialog2, 0x11C, false);");
-		warning("TODO: talk_init(&dialog2);");
+		dialog2.write(0x11C, false);
+		dialog2.start();
 		break;
 
 	case 13:
 		handlePrisonerSpeech(0x148, 7, 9999999);
-		warning("TODO: sub71B9E(&dialog2, 0x120, false);");
-		warning("TODO: talk_init(&dialog2);");
+		dialog2.write(0x120, false);
+		dialog2.start();
 		break;
 
 	case 14:
 		handlePrisonerSpeech(0x14F, 3, 9999999);
-		warning("TODO: sub71B9E(&dialog2, 0x121, false);");
-		warning("TODO: talk_init(&dialog2);");
+		dialog2.write(0x121, false);
+		dialog2.start();
 		break;
 
 	case 15:
@@ -605,7 +605,7 @@ void Scene307::setDialogNode(int node) {
 	case 16:
 		_globals[kKnowsBuddyBeast] = true;
 		handlePrisonerSpeech(0x10C, 1, 9999999);
-		warning("TODO: talk_init(&dialog2);");
+		dialog2.start();
 		break;
 
 	default:
@@ -694,13 +694,13 @@ void Scene307::enter() {
 		0x142, 0x143, 0x144, 0x145, 0x146, 0x147, 0x148, 0x149, 0x14A, 0x14B, 0x14C, 0x14D, 0x14E, 0x14F,
 		0x150, 0x151, 0x152, 0x153, 0);
 
-	warning("TODO: sub71A50(&dialog1, 0x3F, 0x113, 0x114, 0x115, -1);");
-	warning("TODO: sub71A50(&dialog2, 0x40, 0x11A, 0x11B, 0x11C, 0x11D, 0x11E, 0x11F, 0x120, 0x121, 0x122, 0);");
+	dialog1.setup(0x3F, 0x113, 0x114, 0x115, -1);
+	dialog2.setup(0x40, 0x11A, 0x11B, 0x11C, 0x11D, 0x11E, 0x11F, 0x120, 0x121, 0x122, 0);
 
 	if (!_game._visitedScenes._sceneRevisited)
-		warning("TODO: sub71B18(&dialog2, 0x11A, 0x122, 0);");
+		dialog2.set(0x11A, 0x122, 0);
 	else if (_scene->_priorSceneId == 318)
-		warning("TODO: sub71B9E(&dialog2, 0x11E, -1);");
+		dialog2.write(0x11E, true);
 
 
 	if (_scene->_priorSceneId == -2) {
@@ -2306,41 +2306,41 @@ void Scene318::handleDialog() {
 		_game._player._stepEnabled = true;
 	} else {
 		if (_action._activeAction._verbId < 0x19C)
-			warning("TODO: sub71B9E(&dialog1, _action._activeAction._verbId, false);");
+			dialog1.write(_action._activeAction._verbId, false);
 
 		switch (_action._activeAction._verbId) {
 		case 0x191:
 			handleInternDialog(0x19E, 2, 9999999);
-			warning("TODO: sub71B9E(&dialog1, 0x192, true);");
+			dialog1.write(0x192, true);
 			break;
 
 		case 0x192:
 			handleInternDialog(0x1A0, 5, 9999999);
-			warning("TODO: sub71B9E(&dialog1, 0x193, true);");
+			dialog1.write(0x193, true);
 			break;
 
 		case 0x193:
 			handleInternDialog(0x1A5, 4, 9999999);
-			warning("TODO: sub71B9E(&dialog1, 0x194, true);");
+			dialog1.write(0x194, true);
 			break;
 
 		case 0x194:
 			handleInternDialog(0x1A9, 6, 9999999);
-			warning("TODO: sub71B9E(&dialog1, 0x195, true);");
-			warning("TODO: sub71B9E(&dialog1, 0x196, true);");
-			warning("TODO: sub71B9E(&dialog1, 0x19D, false);");
+			dialog1.write(0x195, true);
+			dialog1.write(0x196, true);
+			dialog1.write(0x19D, false);
 			break;
 
 		case 0x195:
 			handleInternDialog(0x1AF, 7, 9999999);
 			warning("TODO: if (!sub71C16(&_dialog1, 0x196))");
-			warning("TODO: \tsub71B9E(&dialog1, 0x197, true);");
+				dialog1.write(0x197, true);
 			break;
 
 		case 0x196:
 			handleInternDialog(0x1B6, 5, 9999999);
 			warning("TODO: if (!sub71C16(&_dialog1, 0x195))");
-			warning("TODO: \tsub71B9E(&dialog1, 0x197, true);");
+				dialog1.write(0x197, true);
 			break;
 
 		case 0x197:
@@ -2349,7 +2349,7 @@ void Scene318::handleDialog() {
 
 		case 0x198:
 			handleInternDialog(0x1C0, 5, 9999999);
-			warning("TODO: sub71B9E(&dialog1, 0x19A, true);");
+			dialog1.write(0x19A, true);
 			break;
 
 		case 0x199:
@@ -2358,7 +2358,7 @@ void Scene318::handleDialog() {
 
 		case 0x19A:
 			handleInternDialog(0x1C8, 5, 9999999);
-			warning("TODO: sub71B9E(&dialog1, 0x19B, true);");
+			dialog1.write(0x19B, true);
 			break;
 
 		case 0x19B:
@@ -2384,7 +2384,7 @@ void Scene318::handleDialog() {
 		}
 
 		if (_action._activeAction._verbId < 0x19C) {
-			warning("TODO: talk_init(&dialog1);");
+			dialog1.start();
 			_game._player._stepEnabled = true;
 		}
 
@@ -2459,12 +2459,12 @@ void Scene318::enter() {
 	else if (_scene->_priorSceneId != -2)
 		_game._player._playerPos = Common::Point(214, 152);
 
-	warning("TODO: sub71A50(&dialog1, 0x47, 0x191, 0x192, 0x193, 0x194, 0x195, 0x196, 0x197, 0x198, 0x199, 0x19A, 0x19B, 0x19C, 0x19D, 0);");
+	dialog1.setup(0x47, 0x191, 0x192, 0x193, 0x194, 0x195, 0x196, 0x197, 0x198, 0x199, 0x19A, 0x19B, 0x19C, 0x19D, 0);
 
 	if (!_game._visitedScenes._sceneRevisited) {
-		warning("TODO: sub71B18(&dialog1, 0x191, 0x198, 0x199, 0x19C, 0);");
-		warning("TODO: if (Debugger_widepipe_ctr >= 2)");
-		warning("TODO: \tsub71B9E(&dialog1, 0x19D, -1);");
+		dialog1.set(0x191, 0x198, 0x199, 0x19C, 0);
+		if (_game._widepipeCtr >= 2)
+			dialog1.write(0x19D, true);
 	}
 
 	if (_scene->_priorSceneId == 307) {
@@ -2509,7 +2509,7 @@ void Scene318::enter() {
 			}
 
 			if (_dialogFl) {
-				warning("TODO: talk_init(&dialog1);");
+				dialog1.start();
 				_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 8);
 			} else
 				_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
@@ -2704,7 +2704,7 @@ void Scene318::actions() {
 		case 1:
 			_game._player._stepEnabled = true;
 			handleInternDialog(0x18F, 1, 9999999);
-			warning("TODO: talk_init(&dialog1);");
+			dialog1.start();
 			break;
 
 		case 2: {
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index c563102..c48017f 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -135,7 +135,7 @@ private:
 
 	Common::String _subQuote2;
 
-	//	dialog1, dialog2;
+	Conversation dialog1, dialog2;
 
 	void handleDialog();
 	void handleRexDialog(int quote);
@@ -265,7 +265,7 @@ private:
 
 	Common::String _subQuote2;
 
-	// dialog1
+	Conversation dialog1;
 
 	void handleDialog();
 	void handleRexDialogs(int quote);


Commit: ff70186855bec22fe77043d89917b189218ff856
    https://github.com/scummvm/scummvm/commit/ff70186855bec22fe77043d89917b189218ff856
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-21T19:12:28-04:00

Commit Message:
MADS: Improve background user interface sprite animations

Changed paths:
    engines/mads/msurface.cpp
    engines/mads/msurface.h
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 75aad01..2c9d093 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -418,50 +418,6 @@ void MSurface::copyFrom(MSurface *src, const Common::Point &destPos, int depth,
 	}
 }
 
-void MSurface::mergeFrom(MSurface *src, const Common::Rect &srcBounds, const Common::Point &destPos) {
-	// Validation of the rectangle and position	
-	int destX = destPos.x, destY = destPos.y;
-	if ((destX >= w) || (destY >= h))
-		return;
-
-	Common::Rect copyRect = srcBounds;
-	if (destX < 0) {
-		copyRect.left += -destX;
-		destX = 0;
-	}
-	else if (destX + copyRect.width() > w) {
-		copyRect.right -= destX + copyRect.width() - w;
-	}
-	if (destY < 0) {
-		copyRect.top += -destY;
-		destY = 0;
-	}
-	else if (destY + copyRect.height() > h) {
-		copyRect.bottom -= destY + copyRect.height() - h;
-	}
-
-	if (!copyRect.isValidRect())
-		return;
-
-	// Copy the specified area
-
-	byte *data = src->getData();
-	byte *srcPtr = data + (src->getWidth() * copyRect.top + copyRect.left);
-	byte *destPtr = (byte *)pixels + (destY * getWidth()) + destX;
-
-	for (int rowCtr = 0; rowCtr < copyRect.height(); ++rowCtr) {
-		// Process each line of the area
-		for (int xCtr = 0; xCtr < copyRect.width(); ++xCtr) {
-			// Check for the range used for on-screen text, which should be kept intact
-			if (srcPtr[xCtr] < 8 || srcPtr[xCtr] > 15)
-				destPtr[xCtr] = srcPtr[xCtr];
-		}
-
-		srcPtr += src->getWidth();
-		destPtr += getWidth();
-	}
-}
-
 void MSurface::scrollX(int xAmount) {
 	if (xAmount == 0)
 		return;
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index f590bac..7cf2bbe 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -188,14 +188,6 @@ public:
 	}
 
 	/**
-	* Merges a sub-section of another surface into the current one.
-	* @param src			Source surface
-	* @param srcBounds		Area to copy/merge from
-	* @param destPos		Destination position to draw in current surface
-	*/
-	void mergeFrom(MSurface *src, const Common::Rect &srcBounds, const Common::Point &destPos);
-
-	/**
 	 * Scroll the screen horizontally by a given amount
 	 * @param xAmount	Horizontal amount
 	 */
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index a5e8a84..f775e45 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -162,10 +162,12 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 
 					if (flipped) {
 						MSurface *spr = sprite->flipHorizontal();
-						spr->copyTo(&userInterface, slot._position, sprite->getTransparencyIndex());
+						userInterface.mergeFrom(spr, spr->getBounds(), slot._position,
+							sprite->getTransparencyIndex());
 						delete spr;
 					} else {
-						sprite->copyTo(&userInterface, slot._position, sprite->getTransparencyIndex());
+						userInterface.mergeFrom(sprite, sprite->getBounds(), slot._position,
+							sprite->getTransparencyIndex());
 					}
 				}
 			}
@@ -407,6 +409,49 @@ void UserInterface::drawTextElements() {
 	}
 }
 
+void UserInterface::mergeFrom(MSurface *src, const Common::Rect &srcBounds,
+	const Common::Point &destPos, int transparencyIndex) {
+	// Validation of the rectangle and position	
+	int destX = destPos.x, destY = destPos.y;
+	if ((destX >= w) || (destY >= h))
+		return;
+
+	Common::Rect copyRect = srcBounds;
+	if (destX < 0) {
+		copyRect.left += -destX;
+		destX = 0;
+	} else if (destX + copyRect.width() > w) {
+		copyRect.right -= destX + copyRect.width() - w;
+	}
+	if (destY < 0) {
+		copyRect.top += -destY;
+		destY = 0;
+	} else if (destY + copyRect.height() > h) {
+		copyRect.bottom -= destY + copyRect.height() - h;
+	}
+
+	if (!copyRect.isValidRect())
+		return;
+
+	// Copy the specified area
+
+	byte *data = src->getData();
+	byte *srcPtr = data + (src->getWidth() * copyRect.top + copyRect.left);
+	byte *destPtr = (byte *)this->pixels + (destY * getWidth()) + destX;
+
+	for (int rowCtr = 0; rowCtr < copyRect.height(); ++rowCtr) {
+		// Process each line of the area
+		for (int xCtr = 0; xCtr < copyRect.width(); ++xCtr) {
+			// Check for the range used for on-screen text, which should be kept intact
+			if ((destPtr[xCtr] >= 8 && destPtr[xCtr] <= 15) && (int)srcPtr[xCtr] != transparencyIndex)
+				destPtr[xCtr] = srcPtr[xCtr];
+		}
+
+		srcPtr += src->getWidth();
+		destPtr += getWidth();
+	}
+}
+
 void UserInterface::drawActions() {
 	for (int idx = 0; idx < 10; ++idx) {
 		writeVocab(CAT_COMMAND, idx);
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 7541bb8..a29a0e6 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -229,6 +229,17 @@ public:
 	void drawTextElements();
 
 	/**
+	* Merges a sub-section of another surface into the user interface without
+	* destroying any on-screen text
+	* @param src			Source surface
+	* @param srcBounds		Area to copy/merge from
+	* @param destPos		Destination position to draw in current surface
+	* @param transparencyIndex	Transparency color
+	*/
+	void mergeFrom(MSurface *src, const Common::Rect &srcBounds, const Common::Point &destPos,
+		int transparencyIndex = -1);
+
+	/**
 	 * Loads the animation sprite data for a given inventory object
 	 */
 	void loadInventoryAnim(int objectId);


Commit: 692af23f6f0a698e9089fcef0592fcb20e56efa6
    https://github.com/scummvm/scummvm/commit/692af23f6f0a698e9089fcef0592fcb20e56efa6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-21T20:50:05-04:00

Commit Message:
MADS: Create a Globals base class that the games will derive from

Changed paths:
  A engines/mads/globals.cpp
  A engines/mads/globals.h
    engines/mads/game.h
    engines/mads/module.mk
    engines/mads/nebular/game_nebular.h
    engines/mads/nebular/globals_nebular.cpp
    engines/mads/nebular/globals_nebular.h
    engines/mads/nebular/nebular_scenes.h
    engines/mads/user_interface.cpp



diff --git a/engines/mads/game.h b/engines/mads/game.h
index 44aa0db..5bb7b31 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -27,6 +27,7 @@
 #include "common/str-array.h"
 #include "mads/scene.h"
 #include "mads/game_data.h"
+#include "mads/globals.h"
 #include "mads/inventory.h"
 #include "mads/player.h"
 #include "mads/screen.h"
@@ -150,6 +151,11 @@ public:
 	Common::StringArray getMessage(uint32 id);
 
 	/**
+	 * Returns the globals for the game
+	 */
+	virtual Globals &globals() = 0;
+
+	/**
 	* Standard object handling across the game
 	*/
 	virtual void doObjectAction() = 0;
diff --git a/engines/mads/globals.cpp b/engines/mads/globals.cpp
new file mode 100644
index 0000000..68a2cf1
--- /dev/null
+++ b/engines/mads/globals.cpp
@@ -0,0 +1,34 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "mads/globals.h"
+
+namespace MADS {
+
+void Globals::reset() {
+	for (uint i = 0; i < _flags.size(); ++i)
+		_flags[i] = 0;
+}
+
+
+} // End of namespace MADS
diff --git a/engines/mads/globals.h b/engines/mads/globals.h
new file mode 100644
index 0000000..ea327b0
--- /dev/null
+++ b/engines/mads/globals.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_GLOBALS_H
+#define MADS_GLOBALS_H
+
+#include "common/scummsys.h"
+#include "common/array.h"
+
+namespace MADS {
+
+class Globals {
+protected:
+	Common::Array<int16> _flags;
+public:
+	Globals() {}
+
+	/**
+	* Square brackets operator for accessing flags
+	*/
+	int16 &operator[](int idx) { return _flags[idx]; }
+
+	/*
+	 * Resets all the globals to empty
+	 */
+	void reset();
+};
+
+} // End of namespace MADS
+
+#endif /* MADS_GLOBALS_H */
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 716521d..43853f5 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -21,6 +21,7 @@ MODULE_OBJS := \
 	font.o \
 	game.o \
 	game_data.o \
+	globals.o \
 	hotspots.o \
 	inventory.o \
 	mads.o \
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index 4d011c2..7d64e3e 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "mads/game.h"
+#include "mads/globals.h"
 #include "mads/nebular/globals_nebular.h"
 
 namespace MADS {
@@ -62,9 +63,11 @@ protected:
 
 	virtual void checkShowDialog();
 public:
-	Globals _globals;
+	NebularGlobals _globals;
 	StoryMode _storyMode;
 
+	virtual Globals &globals() { return _globals; }
+
 	virtual void doObjectAction();
 
 	virtual void unhandledAction();
diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp
index 11c2b81..3e9a9f7 100644
--- a/engines/mads/nebular/globals_nebular.cpp
+++ b/engines/mads/nebular/globals_nebular.cpp
@@ -28,7 +28,7 @@ namespace MADS {
 
 namespace Nebular {
 
-Globals::Globals() {
+NebularGlobals::NebularGlobals(): Globals() {
 	// Initialize lists
 	_flags.resize(210);
 	_spriteIndexes.resize(30);
@@ -53,11 +53,6 @@ Globals::Globals() {
 	_v84268 = 0;
 }
 
-void Globals::reset() {
-	for (uint i = 0; i < _flags.size(); ++i)
-		_flags[i] = 0;
-}
-
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index 242e0d1..b8fe17f 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -279,9 +279,7 @@ enum {
 #define TELEPORTER_WORK_COUNT 6  // Total number that actually work
 
 
-class Globals {
-private:
-	Common::Array<int16> _flags;
+class NebularGlobals: public Globals {
 public:
 	Common::Array<int> _spriteIndexes;
 	Common::Array<int> _sequenceIndexes;
@@ -302,17 +300,7 @@ public:
 	/**
 	 * Constructor
 	 */
-	Globals();
-
-	/**
-	 * Square brackets operator for accessing flags
-	 */
-	int16 &operator[](int idx) { return _flags[idx]; }
-
-	/*
-	 * Resets all the globals to empty
-	 */
-	void reset();
+	NebularGlobals();
 };
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 56ea52d..a227b76 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -111,7 +111,7 @@ public:
  */
 class NebularScene : public SceneLogic {
 protected:
-	Globals &_globals;
+	NebularGlobals &_globals;
 	GameNebular &_game;
 	MADSAction &_action;
 
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index f775e45..346ad2d 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -231,18 +231,14 @@ void Conversation::setup(int globalId, ...) {
 	if (quoteId < 0) {
 		// For an ending value of -1, also initial the bitflags for the global
 		// associated with the conversation entry, which enables all the quote Ids
-		assert(_vm->getGameID() == GType_RexNebular);
-		Nebular::GameNebular *game = (Nebular::GameNebular *)_vm->_game;
-		game->_globals[globalId] = (int16)0xffff;
+		_vm->_game->globals()[globalId] = (int16)0xffff;
 	}
 
 	_globalId = globalId;
 }
 
 void Conversation::set(int quoteId, ...) {
-	assert(_vm->getGameID() == GType_RexNebular);
-	Nebular::GameNebular *game = (Nebular::GameNebular *)_vm->_game;
-	game->_globals[_globalId] = 0;
+	_vm->_game->globals()[_globalId] = 0;
 
 	va_list va;
 	va_start(va, quoteId);
@@ -252,7 +248,7 @@ void Conversation::set(int quoteId, ...) {
 		for (uint idx = 0; idx < _quotes.size(); ++idx) {
 			if (_quotes[idx] == quoteId) {
 				// Found index, so set that bit in the global keeping track of conversation state
-				game->_globals[_globalId] |= 1 << idx;
+				_vm->_game->globals()[_globalId] |= 1 << idx;
 				break;
 			}
 		}
@@ -263,18 +259,15 @@ void Conversation::set(int quoteId, ...) {
 }
 
 void Conversation::write(int quoteId, bool flag) {
-	assert(_vm->getGameID() == GType_RexNebular);
-	Nebular::GameNebular *game = (Nebular::GameNebular *)_vm->_game;
-
 	for (uint idx = 0; idx < _quotes.size(); ++idx) {
 		if (_quotes[idx] == quoteId) {
 			// Found index, so set or clear the flag
 			if (flag) {
 				// Set bit
-				game->_globals[_globalId] |= 1 << idx;
+				_vm->_game->globals()[_globalId] |= 1 << idx;
 			} else {
 				// Clear bit
-				game->_globals[_globalId] &= ~(1 << idx);
+				_vm->_game->globals()[_globalId] &= ~(1 << idx);
 			}
 			return;
 		}
@@ -282,17 +275,15 @@ void Conversation::write(int quoteId, bool flag) {
 }
 
 void Conversation::start() {
-	assert(_vm->getGameID() == GType_RexNebular);
-	Nebular::GameNebular *game = (Nebular::GameNebular *)_vm->_game;
-	UserInterface &userInterface = game->_scene._userInterface;
+	UserInterface &userInterface = _vm->_game->_scene._userInterface;
 	userInterface.emptyConversationList();
 
 	// Loop through each of the quotes loaded into the conversation
 	for (uint idx = 0; idx < _quotes.size(); ++idx) {
 		// Check whether the given quote is enabled or not
-		if (game->_globals[_globalId] & (1 << idx)) {
+		if (_vm->_game->globals()[_globalId] & (1 << idx)) {
 			// Quote enabled, so add it to the list of talk selections
-			Common::String msg = game->getQuote(_quotes[idx]);
+			Common::String msg = _vm->_game->getQuote(_quotes[idx]);
 			userInterface.addConversationMessage(_quotes[idx], msg);
 		}
 	}


Commit: b2e2a2deeee660ec2b28bc0098dfe0da67869e04
    https://github.com/scummvm/scummvm/commit/b2e2a2deeee660ec2b28bc0098dfe0da67869e04
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-22T23:26:39+02:00

Commit Message:
MADS: Implement scene 319

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 77146a0..2c16fdb 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -127,6 +127,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene316(vm);
 	case 318:
 		return new Scene318(vm);
+	case 319:
+		return new Scene319(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 1928461..15cd482 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -2870,5 +2870,465 @@ void Scene318::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene319::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene319::handleRexDialogues(int quote) {
+	_scene->_kernelMessages.reset();
+
+	Common::String curQuote = _game.getQuote(quote);
+	if (_vm->_font->getWidth(curQuote, _scene->_textSpacing) > 200) {
+		Common::String subQuote1;
+		_game.splitQuote(curQuote, subQuote1, _subQuote2);
+		_scene->_kernelMessages.add(Common::Point(160, 106), 0x1110, 32, 0, 120, subQuote1);
+		_scene->_kernelMessages.add(Common::Point(160, 120), 0x1110, 32, 1, 120, _subQuote2);
+	} else
+		_scene->_kernelMessages.add(Common::Point(160, 120), 0x1110, 32, 1, 120, curQuote);
+}
+
+void Scene319::handleSlacheDialogs(int quoteId, int counter, uint32 timer) {
+	int curQuote = quoteId;
+	int posY = 5 + (_slachePosY * 14);
+
+	for (int count = 0; count < counter; count++, curQuote++) {
+		_scene->_kernelMessages.add(Common::Point(8, posY), 0xFDFC, 0, 0, timer, _game.getQuote(curQuote));
+		posY += 14;
+	}
+}
+
+void Scene319::enter() {
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('e', 0));
+	_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('a', 0));
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('a', 1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 2));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 3));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('k', -1));
+
+	if (!_game._objects.isInInventory(OBJ_SCALPEL)) {
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
+	}
+
+	_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 18, 0, 0, 300);
+	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 67, 0, 0, 377);
+	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 173, 0, 0, 233);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14);
+
+	_globals._sequenceIndexes[0] = _scene->_sequences.startCycle (_globals._spriteIndexes[0], false, 1);
+	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle (_globals._spriteIndexes[1], false, 1);
+
+	_dialog1.setup(0x43, 0x165, 0x166, 0x167, 0x168, 0x169, 0x16A, 0);
+	_dialog2.setup(0x44, 0x171, 0x172, 0x173, 0x174, 0x175, 0x176, 0);
+	_dialog3.setup(0x45, 0x17D, 0x17E, 0x17F, 0x180, 0x181, 0x182, 0x183, 0);
+
+	if (_scene->_priorSceneId != -2) {
+		_dialog1.set(0x165, 0x166, 0x167, 0x168, 0);
+		_dialog2.set(0x171, 0x172, 0x173, 0x174, 0);
+		_dialog3.set(0x17D, 0x17E, 0x17F, 0x180, 0);
+	}
+
+	_game.loadQuoteSet(0x15F, 0x160, 0x161, 0x162, 0x163, 0x164, 0x16B, 0x16C, 0x16D,
+		0x16E, 0x16F, 0x170, 0x177, 0x178, 0x178, 0x17A, 0x17B, 0x17C, 0x165, 0x166,
+		0x167, 0x168, 0x169, 0x16A, 0x171, 0x172, 0x173, 0x174, 0x175, 0x176, 0x17D,
+		0x17E, 0x17F, 0x180, 0x181, 0x182, 0x183, 0x184, 0x185, 0x186, 0x187, 0x188,
+		0x189, 0x18A, 0x18B, 0);
+
+	_vm->_palette->setEntry(252, 63, 30, 2);
+	_vm->_palette->setEntry(253, 45, 15, 1);
+
+	_slachePosY = 0;
+	_slacheInitFl = false;
+	_slacheTalkingFl = false;
+	_slacheReady = false;
+	_animFrame = 0;
+
+	_scene->loadAnimation(formAnimName('b', 0));
+
+	if (_scene->_priorSceneId != -2) {
+		_animMode = 1;
+		_nextAction1 = 2;
+		_nextAction2 = 2;
+		_slacheMode = 1;
+		_slacheTopic = 1;
+		_slacheInitFl = true;
+
+		if (_globals[kRexHasMetSlache]) {
+			handleSlacheDialogs(0x18A, 2, 9999999);
+			_slachePosY = 3;
+		} else {
+			handleSlacheDialogs(0x186, 4, 9999999);
+			_slachePosY = 5;
+		}
+	}
+
+	switch (_slacheTopic) {
+	case 1:
+		handleSlacheDialogs(0x15F, 2, 9999999);
+		_dialog1.start();
+		break;
+
+	case 2:
+		handleSlacheDialogs(0x16B, 2, 9999999);
+		_dialog2.start();
+		break;
+
+	case 3:
+		handleSlacheDialogs(0x177, 2, 9999999);
+		_dialog3.start();
+		break;
+
+	default:
+		break;
+	}
+
+	_slachePosY = 0;
+	sceneEntrySound();
+}
+
+void Scene319::step() {
+	if (_scene->_activeAnimation == nullptr)
+		return;
+
+	if (_animFrame != _scene->_activeAnimation->getCurrentFrame()) {
+		_animFrame = _scene->_activeAnimation->getCurrentFrame();
+		int nextFrame = -1;
+		if (_animMode == 1) {
+			switch (_animFrame) {
+			case 6:
+				_slacheTalkingFl = true;
+				break;
+
+			case 29:
+				_slacheReady = true;
+				break;
+
+			case 39:
+				if (_slacheInitFl) {
+					_slacheInitFl = false;
+					if (_nextAction1 == 2)
+						nextFrame = 0;
+				} else if (_nextAction1 == 2)
+					_nextAction1 = 1;
+				break;
+
+			case 50:
+			case 60:
+			case 70:
+			case 85:
+				if (_nextAction1 == 2)
+					nextFrame = 0;
+				else if (_nextAction1 == 3) {
+					nextFrame = 85;
+					_slacheTalkingFl = true;
+				} else if (_animFrame == 85) {
+					if (!_game._player._stepEnabled)
+						_slacheTalkingFl = true;
+					nextFrame = 40;
+				}
+				break;
+
+			case 115:
+				_slacheReady = true;
+				break;
+
+			case 129:
+				if (_nextAction1 == 3) {
+					nextFrame = 115;
+					if (!_game._player._stepEnabled)
+						_slacheTalkingFl = true;
+				}
+				break;
+
+			case 145:
+				nextFrame = 40;
+				break;
+
+			default:
+				break;
+			}
+
+			if ((_animFrame > 40) && (_animFrame < 85) && (nextFrame < 0)) {
+				switch (_nextAction1) {
+				case 4:
+					_animFrame = 0;
+					_scene->freeAnimation();
+					_animMode = 2;
+					_scene->loadAnimation(formAnimName('b', 3), 70);
+					break;
+
+				case 5:
+					_animFrame = 0;
+					_scene->freeAnimation();
+					_animMode = 3;
+					_scene->loadAnimation(formAnimName('b', 4), 71);
+					break;
+
+				case 6:
+					_animFrame = 0;
+					_scene->freeAnimation();
+					_animMode = 4;
+					_scene->loadAnimation(formAnimName('b', 5), 72);
+					break;
+
+				default:
+					break;
+				}
+
+				if (!_animFrame) {
+					_scene->_sequences.remove(_globals._sequenceIndexes[0]);
+					_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+
+					for (int i = 0; i <= 1; i++) {
+						_globals._sequenceIndexes[i] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[i], false, 8, 1, 0, 0);
+						_scene->_sequences.setAnimRange(_globals._sequenceIndexes[i], 1, 7);
+					}
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 73);
+				}
+			}
+		}
+
+		if (_animMode == 2) {
+			if (_animFrame == 13)
+				warning("TODO: shake_countdown = 40;");
+
+			if (_animFrame == 16)
+				warning("TODO: shake_countdown = 1;");
+		}
+
+		if (_animMode == 3) {
+			if (_animFrame == 11)
+				warning("TODO: shake_countdown = 60;");
+
+			if (_animFrame == 18)
+				warning("TODO: shake_countdown = 1;");
+		}
+
+		if ((_animMode == 4) && (_animFrame == 16))
+			warning("TODO: shake_countdown = 80;");
+
+		if ((nextFrame >= 0) && (nextFrame != _scene->_activeAnimation->getCurrentFrame())) {
+			_scene->_activeAnimation->setCurrentFrame(nextFrame);
+			_animFrame = nextFrame;
+		}
+	}
+
+	switch (_game._trigger) {
+	case 70:
+	case 71:
+		_animMode = 1;
+		_nextAction1 = _nextAction2;
+		_animFrame = 0;
+		_scene->freeAnimation();
+		_scene->loadAnimation(formAnimName('b', 0), false);
+		if (_nextAction1 == 3)
+			_scene->_activeAnimation->setCurrentFrame(85);
+		else if (_nextAction1 == 1)
+			_scene->_activeAnimation->setCurrentFrame(40);
+
+		_animFrame = _scene->_activeAnimation->getCurrentFrame();
+		_slacheTalkingFl = true;
+		warning("TODO: shake_countdown = 1;");
+
+		for (int i = 0; i <= 1; i++) {
+			int oldIdx = _globals._sequenceIndexes[i];
+			_scene->_sequences.remove(_globals._sequenceIndexes[i]);
+			_globals._sequenceIndexes[i] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[i], false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[i], 8, 13);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[i], oldIdx);
+		}
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_EXPIRE, 0, 74);
+		break;
+
+	case 72:
+		warning("TODO: sub7CBD8(-1, 0, 0);");
+		warning("TODO: sub7CBE4(0, 0, 0);");
+		_vm->_palette->fadeOut(_vm->_palette->_mainPalette, 18, 228, 16, 1, 8, 248, 0, 0);
+		warning("TODO: shake_countdown = 1;");
+		_scene->_reloadSceneFlag = true;
+		break;
+
+	case 73:
+		for (int i = 0; i <= 1; i++) {
+			int oldIdx = _globals._sequenceIndexes[i];
+			_scene->_sequences.remove(_globals._sequenceIndexes[i]);
+			_globals._sequenceIndexes[i] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[i], false, 8, 0, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[i], 6, 7);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[i], oldIdx);
+		}
+		break;
+
+	case 74:
+		for (int i = 0; i <= 1; i++) {
+			int oldIdx = _globals._sequenceIndexes[i];
+			_scene->_sequences.remove(_globals._sequenceIndexes[i]);
+			_globals._sequenceIndexes[i] = _scene->_sequences.startCycle (_globals._spriteIndexes[i], false, 1);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[i], oldIdx);
+		}
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene319::actions() {
+	if (_game._trigger == 0) {
+		_game._player._stepEnabled = false;
+		handleRexDialogues(_action._activeAction._verbId);
+	} else {
+		if ((_action._activeAction._verbId == 0x165) || (_action._activeAction._verbId == 0x166)) {
+			if (_game._trigger == 1) {
+				_nextAction1 = 3;
+				_slacheTalkingFl = false;
+				_slacheMode = 1;
+				_slacheTopic = 2;
+			}
+
+			if (!_slacheTalkingFl) {
+				_scene->_sequences.addTimer(4, 2);
+			} else {
+				handleSlacheDialogs(0x16B, 2, 9999999);
+				_dialog2.start();
+				_game._player._stepEnabled = true;
+			}
+		}
+
+		if ((_action._activeAction._verbId == 0x171) || (_action._activeAction._verbId == 0x172)) {
+			if (_game._trigger == 1) {
+				_nextAction1 = 2;
+				_slacheTalkingFl = false;
+				_slacheMode = 1;
+				_slacheTopic = 3;
+			}
+
+			if (!_slacheTalkingFl) {
+				_scene->_sequences.addTimer(4, 2);
+			} else {
+				handleSlacheDialogs(0x177, 2, 9999999);
+				_dialog3.start();
+				_game._player._stepEnabled = true;
+			}
+		}
+
+		if ((_action._activeAction._verbId == 0x17D) || (_action._activeAction._verbId == 0x17E)) {
+			if (_game._trigger == 1) {
+				_nextAction1 = 3;
+				_slacheTalkingFl = false;
+				_slacheReady = false;
+				_slacheMode = 1;
+				_slacheTopic = 1;
+			}
+
+			if (!_slacheTalkingFl) {
+				_scene->_sequences.addTimer(4, 2);
+			} else {
+				if (_game._trigger == 2)
+					handleSlacheDialogs(0x184, 2, 180);
+
+				if (!_slacheReady) {
+					_scene->_sequences.addTimer(120, 3);
+				} else {
+					_globals[kRexHasMetSlache] = true;
+					_scene->_nextSceneId = 318;
+				}
+			}
+		}
+
+		if ((_action._activeAction._verbId == 0x168) || (_action._activeAction._verbId == 0x174) ||
+			(_action._activeAction._verbId == 0x180) || (_action._activeAction._verbId == 0x169) ||
+			(_action._activeAction._verbId == 0x175) || (_action._activeAction._verbId == 0x181) ||
+			(_action._activeAction._verbId == 0x16A) || (_action._activeAction._verbId == 0x176) ||
+			(_action._activeAction._verbId == 0x182) || (_action._activeAction._verbId == 0x183) ||
+			(_action._activeAction._verbId == 0x167) || (_action._activeAction._verbId == 0x173) ||
+			(_action._activeAction._verbId == 0x17F)) {
+
+			bool addDialogLine = !((_action._activeAction._verbId == 0x167) || (_action._activeAction._verbId == 0x173) ||
+					(_action._activeAction._verbId == 0x17F) || (_action._activeAction._verbId == 0x16A) ||
+					(_action._activeAction._verbId == 0x176) || (_action._activeAction._verbId == 0x182) ||
+					(_action._activeAction._verbId == 0x183));
+
+			int addVerbId = _action._activeAction._verbId + 1;
+			if ((addVerbId == 0x182) && (_game._storyMode != STORYMODE_NAUGHTY))
+				addVerbId = 0x183;
+
+			if (_slacheMode == 1) {
+				if (_game._trigger == 1) {
+					_nextAction2 = _nextAction1;
+					_nextAction1 = 4;
+				}
+
+				if (_nextAction1 != _nextAction2) {
+					_scene->_sequences.addTimer(4, 2);
+				} else {
+					Conversation *curDialog;
+					int nextDocQuote;
+					if ((_action._activeAction._verbId == 0x168) || (_action._activeAction._verbId == 0x167)) {
+						curDialog = &_dialog1;
+						nextDocQuote = 0x161;
+					} else if ((_action._activeAction._verbId == 0x174) || (_action._activeAction._verbId == 0x1753)) {
+						nextDocQuote = 0x16D;
+						curDialog = &_dialog2;
+					} else {
+						nextDocQuote = 0x179;
+						curDialog = &_dialog3;
+					}
+
+					handleSlacheDialogs(nextDocQuote, 2, 9999999);
+					if (addDialogLine) {
+						curDialog->write(_action._activeAction._verbId, false);
+						curDialog->write(addVerbId, true);
+					}
+
+					curDialog->start();
+					_game._player._stepEnabled = true;
+					_slacheMode = 2;
+				}
+			} else if (_slacheMode == 2) {
+				if (_game._trigger == 1) {
+					_nextAction2 = _nextAction1;
+					_nextAction1 = 5;
+				}
+
+				if (_nextAction1 != _nextAction2) {
+					_scene->_sequences.addTimer(4, 2);
+				} else {
+					Conversation *curDialog;
+					int nextDocQuote;
+					if ((_action._activeAction._verbId == 0x168) || (_action._activeAction._verbId == 0x169)  || (_action._activeAction._verbId == 0x167)) {
+						curDialog = &_dialog1;
+						nextDocQuote = 0x163;
+					} else if ((_action._activeAction._verbId == 0x174) || (_action._activeAction._verbId == 0x175) || (_action._activeAction._verbId == 0x173)) {
+						nextDocQuote = 0x16F;
+						curDialog = &_dialog2;
+					} else {
+						nextDocQuote = 0x17B;
+						curDialog = &_dialog3;
+					}
+
+					handleSlacheDialogs(nextDocQuote, 2, 9999999);
+					if (addDialogLine) {
+						curDialog->write(_action._activeAction._verbId, false);
+						curDialog->write(addVerbId, true);
+					}
+
+					curDialog->start();
+					_game._player._stepEnabled = true;
+					_slacheMode = 3;
+				}
+			} else {
+				_nextAction2 = _nextAction1;
+				_nextAction1 = 6;
+			}
+		}
+	}
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index c48017f..b284a2e 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -282,6 +282,34 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene319: public Scene3xx {
+private:
+	Conversation _dialog1, _dialog2, _dialog3;
+
+	int _animMode, _animFrame;
+	int _nextAction1, _nextAction2;
+	int _slacheMode;
+	int _slacheTopic;
+	int _slachePosY;
+
+	bool _slacheTalkingFl;
+	bool _slacheReady;
+	bool _slacheInitFl;
+
+	Common::String _subQuote2;
+
+	void handleRexDialogues(int quote);
+	void handleSlacheDialogs(int quoteId, int counter, uint32 timer);
+public:
+	Scene319(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index d6cf652..d9a46a9 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -495,7 +495,8 @@ void Palette::setLowRange() {
 	_vm->_palette->setPalette(_mainPalette, 0, 4);
 }
 
-void Palette::fadeOut(byte palette[PALETTE_SIZE], int v1, int v2, int v3, int v4, int v5, int v6) {
+void Palette::fadeOut(byte palette[PALETTE_SIZE], int start, int count, int v1, int v2, int v3, int v4, int v5, int v6) {
+	warning("TODO: Palette::fadeOut()");
 }
 
 void Palette::lock() {
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 75aff7a..0d808ce 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -250,7 +250,7 @@ public:
 		warning("TODO: Palette::close");
 	}
 
-	void fadeOut(byte palette[PALETTE_SIZE], int v1, int v2, int v3, int v4, int v5, int v6);
+	void fadeOut(byte palette[PALETTE_SIZE], int start, int count, int v1, int v2, int v3, int v4, int v5, int v6);
 
 	void lock();
 	void unlock();


Commit: aedf8593034303066bf83d041f63731aa65a3ef6
    https://github.com/scummvm/scummvm/commit/aedf8593034303066bf83d041f63731aa65a3ef6
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-22T23:28:23+02:00

Commit Message:
MADS: Fix compilation warning

Changed paths:
    engines/mads/scene.cpp



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index e688816..9d0332e 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -275,7 +275,7 @@ void Scene::animatePalette() {
 		if (_cyclingDelay >= _cyclingThreshold) {
 			uint32 frameCounter = _vm->_events->getFrameCounter();
 			bool changesFlag = false;
-			for (int idx = 0; idx < _paletteCycles.size(); idx++) {
+			for (uint16 idx = 0; idx < _paletteCycles.size(); idx++) {
 				if (frameCounter >= (_cycleTicks[idx] + _paletteCycles[idx]._ticks)) {
 					_cycleTicks[idx] = frameCounter;
 					int count = _paletteCycles[idx]._colorCount;


Commit: 3f1a49b567aac10fe8a195f7a2b8e07603470a72
    https://github.com/scummvm/scummvm/commit/3f1a49b567aac10fe8a195f7a2b8e07603470a72
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-22T19:47:58-04:00

Commit Message:
MADS: Implemented Conversation::read method

Changed paths:
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 15cd482..f7c727b 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -821,9 +821,10 @@ void Scene307::step() {
 				if (_prisonerMessageId > 0x10A)
 					_prisonerMessageId = 0x104;
 			} else if (_globals[kKnowsBuddyBeast] && (_vm->getRandomNumber(1, 3) == 1)) {
-				warning("TODO: if (_globals[kKnowsBuddyBeast] && (sub71C16(&dialog2, 0) > 1) && (_vm->getRandomNumber(1, 3) == 1)) {");
-				int idx = _scene->_kernelMessages.add(Common::Point(5, 51), 0xFDFC, 0, 81, 120, _game.getQuote(267));
-				_scene->_kernelMessages.setQuoted(idx, 4, true);
+				if (_globals[kKnowsBuddyBeast] && (dialog2.read(0) > 1) && (_vm->getRandomNumber(1, 3) == 1)) {
+					int idx = _scene->_kernelMessages.add(Common::Point(5, 51), 0xFDFC, 0, 81, 120, _game.getQuote(267));
+					_scene->_kernelMessages.setQuoted(idx, 4, true);
+				}
 			}
 			_prisonerTimer = 0;
 		}
@@ -2333,13 +2334,13 @@ void Scene318::handleDialog() {
 
 		case 0x195:
 			handleInternDialog(0x1AF, 7, 9999999);
-			warning("TODO: if (!sub71C16(&_dialog1, 0x196))");
+			if (!dialog1.read(0x196))
 				dialog1.write(0x197, true);
 			break;
 
 		case 0x196:
 			handleInternDialog(0x1B6, 5, 9999999);
-			warning("TODO: if (!sub71C16(&_dialog1, 0x195))");
+			if (!dialog1.read(0x195))
 				dialog1.write(0x197, true);
 			break;
 
@@ -2376,10 +2377,10 @@ void Scene318::handleDialog() {
 
 			_dialogFl = false;
 			handleInternDialog(0x1D0, 1, 120);
-			warning("TODO: if ((sub71C16(&_dialog1, 0) == 1) || (_action._activeAction._verbId == 0x19D)) {");
-			_explosionFl = true;
-			_internCounter = 3420;
-			//			}
+			if (dialog1.read(0) || (_action._activeAction._verbId == 0x19D)) {
+				_explosionFl = true;
+				_internCounter = 3420;
+			}
 			break;
 		}
 
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 346ad2d..493804c 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -258,6 +258,18 @@ void Conversation::set(int quoteId, ...) {
 	va_end(va);
 }
 
+bool Conversation::read(int quoteId) {
+	uint16 flags = _vm->_game->globals()[_globalId];
+
+	for (uint idx = 0; idx < _quotes.size(); ++idx) {
+		if (_quotes[idx] == quoteId) {
+			return flags & (1 << idx);
+		}
+	}
+
+	return false;
+}
+
 void Conversation::write(int quoteId, bool flag) {
 	for (uint idx = 0; idx < _quotes.size(); ++idx) {
 		if (_quotes[idx] == quoteId) {
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index a29a0e6..baae269 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -104,18 +104,23 @@ public:
 	Common::Array<int> _quotes;
 
 	/**
-	* Set up a conversation sequence
-	*/
+	 * Set up a conversation sequence
+	 */
 	void setup(int globalId, ...);
 
 	/**
-	* Activates the passed set of quotes in the given conversation node
-	*/
+	 * Activates the passed set of quotes in the given conversation node
+	 */
 	void set(int quoteId, ...);
 
 	/**
-	* Activates or deactivates the specified quote in the given conversation node
-	*/
+	 * Returns true whether the given quote is enabled in the conversation
+	 */
+	bool read(int quoteId);
+
+	/**
+	 * Activates or deactivates the specified quote in the given conversation node
+	 */
 	void write(int quoteId, bool flag);
 
 	/**


Commit: 0e9e6cda40ee0bf739e6c7a6320a81307df7c8b9
    https://github.com/scummvm/scummvm/commit/0e9e6cda40ee0bf739e6c7a6320a81307df7c8b9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-22T23:00:41-04:00

Commit Message:
MADS: Beginnings of savegame synchronisation

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/inventory.cpp
    engines/mads/inventory.h
    engines/mads/messages.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/player.cpp
    engines/mads/player.h
    engines/mads/rails.cpp
    engines/mads/rails.h
    engines/mads/scene.cpp
    engines/mads/scene.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 9d496d5..03c0c1e 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -29,6 +29,14 @@
 
 namespace MADS {
 
+void ActionDetails::synchronize(Common::Serializer &s) {
+	s.syncAsUint16LE(_verbId);
+	s.syncAsUint16LE(_objectNameId);
+	s.syncAsUint16LE(_indirectObjectId);
+}
+
+/*------------------------------------------------------------------------*/
+
 MADSAction::MADSAction(MADSEngine *vm) : _vm(vm) {
 	clear();
 	_statusTextIndex = -1;
diff --git a/engines/mads/action.h b/engines/mads/action.h
index 599fb0e..c588a42 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -24,6 +24,7 @@
 #define MADS_ACTION_H
 
 #include "common/scummsys.h"
+#include "common/serializer.h"
 #include "common/str.h"
 
 namespace MADS {
@@ -76,6 +77,8 @@ struct ActionDetails {
 	int _verbId;
 	int _objectNameId;
 	int _indirectObjectId;
+
+	void synchronize(Common::Serializer &s);
 };
 
 struct ActionSavedFields {
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index d3e3987..3b591d7 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -22,6 +22,7 @@
 
 #include "common/scummsys.h"
 #include "common/memstream.h"
+#include "common/serializer.h"
 #include "mads/mads.h"
 #include "mads/compression.h"
 #include "mads/game.h"
@@ -45,7 +46,7 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 		_scene(vm), _screenObjects(vm), _player(vm) {
 	_sectionNumber = _priorSectionNumber = 0;
 	_difficulty = DIFFICULTY_HARD;
-	_saveSlot = -1;
+	_serializer = nullptr;
 	_statusFlag = 0;
 	_sectionHandler = nullptr;
 	_sectionNumber = 1;
@@ -86,7 +87,6 @@ void Game::run() {
 	case PROTECTION_FAIL:
 		// Copy protection failed
 		_scene._nextSceneId = 804;
-		_saveSlot = -1;
 		break;
 	case PROTECTION_ESCAPE:
 		// User escaped out of copy protection dialog
@@ -102,7 +102,7 @@ void Game::run() {
 	// Get the initial starting time for the first scene
 	_scene._frameStartTime = _vm->_events->getFrameCounter();
 
-	if (_saveSlot == -1 && protectionResult != -1 && protectionResult != -2) {
+	if (_serializer == nullptr && protectionResult != -1 && protectionResult != -2) {
 		initSection(_sectionNumber);
 		_statusFlag = true;
 
@@ -118,11 +118,6 @@ void Game::run() {
 
 	if (protectionResult != 1 && protectionResult != 2) {
 		initialiseGlobals();
-
-		if (_saveSlot != -1) {
-			warning("TODO: loadGame(\"REX.SAV\", 210)");
-			_statusFlag = false;
-		}
 	}
 
 	if (_statusFlag)
@@ -131,6 +126,9 @@ void Game::run() {
 
 void Game::gameLoop() {
 	while (!_vm->shouldQuit() && _statusFlag) {
+		if (_serializer)
+			synchronize(*_serializer, true);
+
 		setSectionHandler();
 		_sectionHandler->preLoadSection();
 		initSection(_sectionNumber);
@@ -248,7 +246,7 @@ void Game::sectionLoop() {
 		_player.selectSeries();
 		_player.updateFrame();
 
-		_player._visible3 = _player._visible;
+		_player._beenVisible = _player._visible;
 		_player._special = _scene.getDepthHighBits(_player._playerPos);
 		_player._priorTimer = _scene._frameStartTime - _player._ticksAmount;
 		_player.idle();
@@ -402,4 +400,22 @@ void Game::handleKeypress(const Common::Event &event) {
 	warning("TODO: handleKeypress - %d", (int)event.kbd.keycode);
 }
 
+void Game::synchronize(Common::Serializer &s, bool phase1) {
+	if (phase1) {
+		s.syncAsUint16LE(_scene._nextSceneId);
+		s.syncAsUint16LE(_scene._priorSceneId);
+
+		if (s.isLoading()) {
+			_sectionNumber = _scene._nextSceneId / 100;
+			_currentSectionNumber = _sectionNumber;
+		}
+	} else {
+		s.syncAsByte(_difficulty);
+		
+		_scene.synchronize(s);
+		_objects.synchronize(s);
+		_player.synchronize(s);
+	}
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 5bb7b31..ad40fbd 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "common/str-array.h"
+#include "common/serializer.h"
 #include "mads/scene.h"
 #include "mads/game_data.h"
 #include "mads/globals.h"
@@ -72,12 +73,12 @@ private:
 protected:
 	MADSEngine *_vm;
 	MSurface *_surface;
-	int _saveSlot;
 	int _statusFlag;
 	Common::StringArray _quotes;
 	bool _quoteEmergency;
 	bool _vocabEmergency;
 	bool _anyEmergency;
+	Common::Serializer *_serializer;
 
 	/**
 	 * Constructor
@@ -170,6 +171,13 @@ public:
 	 */
 	virtual void step() = 0;
 
+	/**
+	 * Synchronise the game data
+	 * @param s			Serializer
+	 * @param phase1	If true, it's synchronising the basic scene information
+	 */
+	virtual void synchronize(Common::Serializer &s, bool phase1);
+
 	// DEPRECATED: ScummVM re-implementation keeps all the quotes loaded, so the methods below are stubs
 	void clearQuotes() {}
 	void loadQuoteRange(int startNum, int endNum) {}
diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index bb65430..abd281d 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -26,42 +26,57 @@
 
 namespace MADS {
 
-void InventoryObject::load(Common::SeekableReadStream &f) {
-	_descId = f.readUint16LE();
-	_roomNumber = f.readUint16LE();
-	_article = f.readByte();
-	_vocabCount = f.readByte();
+void InventoryObject::synchronize(Common::Serializer &s) {
+	s.syncAsUint16LE(_descId);
+	s.syncAsUint16LE(_roomNumber);
+	s.syncAsByte(_article);
+	s.syncAsByte(_vocabCount);
 	
 	for (int i = 0; i < 3; ++i) {
-		_vocabList[i]._verbType = (VerbType)f.readByte();
-		_vocabList[i]._prepType = (PrepType)f.readByte();
-		_vocabList[i]._vocabId = f.readUint16LE();
+		s.syncAsByte(_vocabList[i]._verbType);
+		s.syncAsByte(_vocabList[i]._prepType);
+		s.syncAsUint16LE( _vocabList[i]._vocabId);
 	}
 
-	f.skip(4);	// field12
-	f.read(&_mutilateString[0], 10);
-	f.skip(16);
+	s.skip(4);	// field12
+	s.syncBytes((byte *)&_mutilateString[0], 10);
+	s.skip(16);
 }
 
 /*------------------------------------------------------------------------*/
 
 void InventoryObjects::load() {
 	File f("*OBJECTS.DAT");
+	Common::Serializer s(&f, nullptr);
 
-	// Get the total numer of inventory objects
-	int count = f.readUint16LE();
-	reserve(count);
-
-	// Read in each object
-	for (int i = 0; i < count; ++i) {
-		InventoryObject obj;
-		obj.load(f);
-		push_back(obj);
+	// Load the objects data
+	synchronize(s);
+}
 
-		// If it's for the player's inventory, add the index to the inventory list
-		if (obj._roomNumber == PLAYER_INVENTORY) {
-			_inventoryList.push_back(i);
-			assert(_inventoryList.size() <= 32);
+void InventoryObjects::synchronize(Common::Serializer &s) {
+	int count = size();
+	s.syncAsUint16LE(count);
+
+	if (s.isSaving()) {
+		// Store the data for each object in the inventory lsit
+		for (int idx = 0; idx < count; ++idx)
+			(*this)[idx].synchronize(s);
+	} else {
+		clear();
+		_inventoryList.clear();
+		reserve(count);
+
+		// Read in each object
+		for (int i = 0; i < count; ++i) {
+			InventoryObject obj;
+			obj.synchronize(s);
+			push_back(obj);
+
+			// If it's for the player's inventory, add the index to the inventory list
+			if (obj._roomNumber == PLAYER_INVENTORY) {
+				_inventoryList.push_back(i);
+				assert(_inventoryList.size() <= 32);
+			}
 		}
 	}
 }
diff --git a/engines/mads/inventory.h b/engines/mads/inventory.h
index 5c2f925..5e3ecd6 100644
--- a/engines/mads/inventory.h
+++ b/engines/mads/inventory.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "common/array.h"
+#include "common/serializer.h"
 
 namespace MADS {
 
@@ -49,9 +50,9 @@ public:
 	const byte *_objFolder;		// ???
 
 	/**
-	 * Loads the data for a given object
+	 * Synchronizes the data for a given object
 	 */
-	void load(Common::SeekableReadStream &f);
+	void synchronize(Common::Serializer &s);
 };
 
 class InventoryObjects: public Common::Array<InventoryObject> {
@@ -72,6 +73,11 @@ public:
 	void load();
 
 	/**
+	* Synchronize the objects list in a savegame
+	*/
+	void synchronize(Common::Serializer &s);
+
+	/**
 	 * Returns the inventory item from the player's inventory
 	 */
 	InventoryObject &getItem(int itemIndex) {
diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index 46b05c1..2f59a67 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -203,7 +203,7 @@ void KernelMessages::processText(int msgIndex) {
 
 	Player &player = _vm->_game->_player;
 	if (msg._flags & KMSG_PLAYER_TIMEOUT) {
-		if (player._visible3) {
+		if (player._beenVisible) {
 			SpriteAsset &asset = *_vm->_game->_scene._sprites[player._spritesStart + player._spritesIdx];
 			MSprite *frame = asset.getFrame(player._frameNumber - 1);
 
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 5054fbe..7491ed1 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -339,7 +339,7 @@ void Scene202::setup() {
 }
 
 void Scene202::enter() {
-	_game._player._visible3 = true;
+	_game._player._beenVisible = true;
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('b', 0));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('b', 1));
 	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('b', 2));
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index cc482c0..3b727b3 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -48,7 +48,7 @@ Player::Player(MADSEngine *vm): _vm(vm) {
 	_priorVisible = false;
 	_needToWalk = false;
 	_readyToWalk = false;
-	_visible3 = false;
+	_beenVisible = false;
 	_loadsFirst = false;
 	_loadedFirst = false;
 	_walkAnywhere = false;
@@ -337,7 +337,7 @@ void Player::update() {
 		}
 	}
 
-	_visible3 = _visible;
+	_beenVisible |= _visible;
 	_priorVisible = _visible;
 	_forceRefresh = false;
 }
@@ -691,4 +691,72 @@ void Player::releasePlayerSprites() {
 	_spritesChanged = true;
 }
 
+void Player::synchronize(Common::Serializer &s) {
+	s.syncAsByte(_visible);
+	s.syncAsByte(_priorVisible);
+	s.syncAsByte(_beenVisible);
+	s.syncAsByte(_moving);
+	s.syncAsByte(_stepEnabled);
+	s.syncAsSint16LE(_playerPos.x);
+	s.syncAsSint16LE(_playerPos.y);
+	s.syncAsSint16LE(_targetPos.x);
+	s.syncAsSint16LE(_targetPos.y);
+	s.syncAsSint16LE(_posChange.x);
+	s.syncAsSint16LE(_posChange.y);
+	s.syncAsSint16LE(_posDiff.x);
+	s.syncAsSint16LE(_posDiff.y);
+	s.syncAsSint16LE(_xDirection);
+	s.syncAsSint16LE(_yDirection);
+	s.syncAsUint16LE(_facing);
+	s.syncAsUint16LE(_targetFacing);
+	s.syncAsByte(_spritesChanged);
+	s.syncAsByte(_walkAnywhere);
+	s.syncAsByte(_walkOffScreen);
+	s.syncAsSint16LE(_ticksAmount);
+	s.syncAsSint16LE(_centerOfGravity);
+	s.syncAsUint16LE(_walkOffScreenSceneId);
+	s.syncAsByte(_needToWalk);
+	s.syncAsByte(_readyToWalk);
+	s.syncAsUint16LE(_prepareWalkFacing);
+	s.syncAsSint16LE(_prepareWalkPos.x);
+	s.syncAsSint16LE(_prepareWalkPos.y);
+
+	s.syncAsByte(_mirror);
+	s.syncAsUint16LE(_frameCount);
+	s.syncAsSint16LE(_frameListIndex);
+	s.syncAsSint16LE(_distAccum);
+	s.syncAsSint16LE(_pixelAccum);
+	s.syncAsSint16LE(_deltaDistance);
+	
+	for (int i = 0; i < 12; ++i) {
+		s.syncAsSint16LE(_stopWalkerList[i]);
+		s.syncAsSint16LE(_stopWalkerTrigger[i]);
+	}
+	s.syncAsSint16LE(_stopWalkerIndex);
+	s.syncAsSint16LE(_totalDistance);
+	s.syncAsSint16LE(_frameNumber);
+	s.syncAsSint16LE(_special);
+	s.syncAsSint16LE(_velocity);
+	s.syncAsSint16LE(_scalingVelocity);
+	s.syncAsSint16LE(_upcomingTrigger);
+	s.syncAsSint16LE(_trigger);
+	s.syncAsSint16LE(_currentDepth);
+	s.syncAsSint16LE(_currentScale);
+
+	int count;
+	char ch;
+	if (s.isSaving()) {
+		count = _spritesPrefix.size();
+		s.syncAsUint16LE(count);
+		s.syncBytes((byte *)_spritesPrefix.c_str(), count);
+	} else {
+		s.syncAsSint16LE(count);
+		_spritesPrefix.clear();
+		for (int i = 0; i < count; ++i) {
+			s.syncAsByte(ch);
+			_spritesPrefix += ch;
+		}			
+	}
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 6df1159..97fc3e7 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "common/str.h"
+#include "common/serializer.h"
 
 namespace MADS {
 
@@ -110,7 +111,7 @@ public:
 	bool _spritesChanged;
 	bool _visible;
 	bool _priorVisible;
-	bool _visible3;
+	bool _beenVisible;
 	bool _walkAnywhere;
 	int _frameNumber;
 	bool _loadsFirst;
@@ -122,7 +123,6 @@ public:
 	Common::Point _prepareWalkPos;
 	bool _moving;
 	int _walkOffScreen, _walkOffScreenSceneId;
-	int _next;
 	int _special;
 	int _ticksAmount;
 	uint32 _priorTimer;
@@ -211,6 +211,11 @@ public:
 	*/
 	void releasePlayerSprites();
 
+	/**
+	 * Serialize the data of the player
+	 */
+	void synchronize(Common::Serializer &s);
+
 	static void preloadSequences(const Common::String &prefix, int level) {
 		// No implementation in ScummVM
 	}
diff --git a/engines/mads/rails.cpp b/engines/mads/rails.cpp
index 105a853..00f7f4c 100644
--- a/engines/mads/rails.cpp
+++ b/engines/mads/rails.cpp
@@ -263,5 +263,22 @@ int Rails::getRouteFlags(const Common::Point &src, const Common::Point &dest) {
 	return result;
 }
 
+void Rails::synchronize(Common::Serializer &s) {
+	s.syncAsSint16LE(_routeLength);
+	s.syncAsSint16LE(_next);
+	
+	int count = _routeIndexes.size();
+	if (s.isSaving()) {
+		for (int i = 0; i < count; ++i)
+			s.syncAsUint16LE(_routeIndexes[i]);
+	} else {
+		_routeIndexes.clear();
+		for (int i = 0; i < count; ++i) {
+			int v = 0;
+			s.syncAsUint16LE(v);
+			_routeIndexes.push(v);
+		}
+	}
+}
 
 } // End of namespace MADS
diff --git a/engines/mads/rails.h b/engines/mads/rails.h
index 6338aea..4014491 100644
--- a/engines/mads/rails.h
+++ b/engines/mads/rails.h
@@ -26,6 +26,7 @@
 #include "common/scummsys.h"
 #include "common/array.h"
 #include "common/rect.h"
+#include "common/serializer.h"
 #include "common/stack.h"
 #include "mads/msurface.h"
 
@@ -60,7 +61,6 @@ private:
 	int _depthStyle;
 	int _routeLength;
 	int _next;
-	int _routeOffset;
 	int _tempRoute[MAX_ROUTE_NODES];
 	Common::Stack<int> _routeIndexes;
 private:
@@ -122,6 +122,11 @@ public:
 
 	void resetNext() { _next = 0; }
 	int  getNext() { return _next; }
+
+	/**
+	 * Synchronize the data for the route
+	 */
+	void synchronize(Common::Serializer &s);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 9d0332e..239a91c 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -681,4 +681,9 @@ void Scene::freeAnimation() {
 	_freeAnimationFlag = false;
 }
 
+void Scene::synchronize(Common::Serializer &s) {
+	_action._activeAction.synchronize(s);
+	_rails.synchronize(s);
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index eb84fbd..48b01b2 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -233,6 +233,11 @@ public:
 	 * Frees any currently active animation for the scene
 	 */
 	void freeAnimation();
+
+	/**
+	* Synchronise the game
+	*/
+	void synchronize(Common::Serializer &s);
 };
 
 } // End of namespace MADS


Commit: ee1a33946fb8f7b61d37e15285e1c5f21f012aa0
    https://github.com/scummvm/scummvm/commit/ee1a33946fb8f7b61d37e15285e1c5f21f012aa0
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-23T23:42:48+02:00

Commit Message:
MADS: Implement scene 320

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 2c16fdb..32d567a 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -129,6 +129,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene318(vm);
 	case 319:
 		return new Scene319(vm);
+	case 320:
+		return new Scene320(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index f7c727b..4ca5a6c 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -2918,8 +2918,8 @@ void Scene319::enter() {
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14);
 
-	_globals._sequenceIndexes[0] = _scene->_sequences.startCycle (_globals._spriteIndexes[0], false, 1);
-	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle (_globals._spriteIndexes[1], false, 1);
+	_globals._sequenceIndexes[0] = _scene->_sequences.startCycle(_globals._spriteIndexes[0], false, 1);
+	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
 
 	_dialog1.setup(0x43, 0x165, 0x166, 0x167, 0x168, 0x169, 0x16A, 0);
 	_dialog2.setup(0x44, 0x171, 0x172, 0x173, 0x174, 0x175, 0x176, 0);
@@ -3165,7 +3165,7 @@ void Scene319::step() {
 		for (int i = 0; i <= 1; i++) {
 			int oldIdx = _globals._sequenceIndexes[i];
 			_scene->_sequences.remove(_globals._sequenceIndexes[i]);
-			_globals._sequenceIndexes[i] = _scene->_sequences.startCycle (_globals._spriteIndexes[i], false, 1);
+			_globals._sequenceIndexes[i] = _scene->_sequences.startCycle(_globals._spriteIndexes[i], false, 1);
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[i], oldIdx);
 		}
 		break;
@@ -3298,7 +3298,7 @@ void Scene319::actions() {
 				} else {
 					Conversation *curDialog;
 					int nextDocQuote;
-					if ((_action._activeAction._verbId == 0x168) || (_action._activeAction._verbId == 0x169)  || (_action._activeAction._verbId == 0x167)) {
+					if ((_action._activeAction._verbId == 0x168) || (_action._activeAction._verbId == 0x169) || (_action._activeAction._verbId == 0x167)) {
 						curDialog = &_dialog1;
 						nextDocQuote = 0x163;
 					} else if ((_action._activeAction._verbId == 0x174) || (_action._activeAction._verbId == 0x175) || (_action._activeAction._verbId == 0x173)) {
@@ -3331,5 +3331,313 @@ void Scene319::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene320::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene320::setRightView(int view) {
+	if (_rightItemId < 8) _scene->_sequences.remove(_globals._sequenceIndexes[10]);
+
+	int spriteNum;
+	switch (view) {
+	case 0:
+		spriteNum = 16;
+		break;
+
+	case 1:
+		spriteNum = 14;
+		break;
+
+	case 2:
+		spriteNum = 17;
+		break;
+
+	case 3:
+		spriteNum = 15;
+		break;
+
+	default:
+		spriteNum = view + 6;
+		break;
+	}
+
+	if (view != 8) {
+		_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[spriteNum], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 0);
+	}
+
+	_globals[kRightView320] = _rightItemId = view;
+}
+
+void Scene320::setLeftView(int view) {
+	if (_leftItemId < 10)
+		_scene->_sequences.remove(_globals._sequenceIndexes[0]);
+
+	if (view != 10) {
+		_globals._sequenceIndexes[0] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[view], false, 6, 0, 0, 18);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[0], 0);
+		if (!_blinkFl)
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[0], 2, 2);
+	}
+
+	_leftItemId = view;
+}
+
+void Scene320::handleButtons() {
+	switch(_action._activeAction._objectNameId) {
+	case 0x2DD:
+		_buttonId = 5;
+		break;
+
+	case 0x2DE:
+		_buttonId = 4;
+		break;
+
+	case 0x2E0:
+		_buttonId = 6;
+		break;
+
+	case 0x2E1:
+		_buttonId = 7;
+		break;
+
+	case 0x2E2:
+		_buttonId = 8;
+		break;
+
+	case 0x2E3:
+		_buttonId = 9;
+		break;
+
+	case 0x2E4:
+		_buttonId = 10;
+		break;
+
+	case 0x2E5:
+		_buttonId = 11;
+		break;
+
+	case 0x2E6:
+		_buttonId = 12;
+		break;
+
+	case 0x2E7:
+		_buttonId = 13;
+		break;
+
+	case 0x2E8:
+		_buttonId = 0;
+		break;
+
+	case 0x2E9:
+		_buttonId = 1;
+		break;
+
+	case 0x2EA:
+		_buttonId = 2;
+		break;
+
+	case 0x2EB:
+		_buttonId = 3;
+		break;
+
+	default:
+		break;
+	}
+
+	if (_buttonId <= 3) {
+		_posX = (8 * _buttonId) - 2;
+		_flippedFl = true;
+	} else if (_buttonId <= 5) {
+		_posX = (13 * _buttonId) - 14;
+		_flippedFl = true;
+	} else {
+		_posX = (8 * _buttonId) + 98;
+		_flippedFl = false;
+	}
+}
+
+void Scene320::enter() {
+	_blinkFl = true;
+	_rightItemId = 8;
+	_leftItemId = 10;
+	_lastFrame = 0;
+
+	for (int i = 0; i < 10; i++)
+		_globals._spriteIndexes[i] = _scene->_sprites.addSprites(formAnimName('M', i));
+
+	for (int i = 0; i < 8; i++)
+		_globals._spriteIndexes[10 + i] = _scene->_sprites.addSprites(formAnimName('N', i));
+
+	_globals._spriteIndexes[18] = _scene->_sprites.addSprites("*REXHAND");
+	_game._player._visible = false;
+
+	setRightView(_globals[kRightView320]);
+	setLeftView(0);
+
+	_vm->_palette->setEntry(252, 63, 30, 20);
+	_vm->_palette->setEntry(253, 45, 15, 10);
+
+	sceneEntrySound();
+}
+
+void Scene320::step() {
+	if (_scene->_activeAnimation != nullptr) {
+		if (_lastFrame != _scene->_activeAnimation->getCurrentFrame()) {
+			_lastFrame = _scene->_activeAnimation->getCurrentFrame();
+			switch (_lastFrame) {
+			case 95:
+				_blinkFl = true;
+				setLeftView(9);
+				_vm->_sound->command(41);
+				break;
+
+			case 139:
+				_blinkFl = false;
+				setLeftView(9);
+				break;
+
+			case 191:
+				_scene->_kernelMessages.add(Common::Point(1, 1), 0xFDFC, 0, 0, 60, _game.getQuote(0xFE));
+				break;
+
+			case 417:
+			case 457:
+				warning("TODO: shake_countdown = 40;");
+				_vm->_sound->command(59);
+				break;
+
+			case 430:
+				_blinkFl = true;
+				setLeftView(4);
+				break;
+
+			default:
+				break;
+			}
+		}
+	}
+
+	if (_game._trigger == 70) {
+		_globals[kAfterHavoc] = true;
+		_globals[kTeleporterRoom + 1] = 351;
+		_scene->_nextSceneId = 361;
+	}
+}
+
+void Scene320::actions() {
+	if (_action._lookFlag)
+		_vm->_dialogs->show(0x7D0B);
+	else if ((_action.isAction(0x11A) || _action.isAction(VERB_PUSH)) &&
+		(_action.isAction(0x2E8) || _action.isAction(0x2E9) || _action.isAction(0x2EA) || _action.isAction(0x2EB) ||
+		 _action.isAction(0x2DE) || _action.isAction(0x2DD) || _action.isAction(0x2E0) || _action.isAction(0x2E1) ||
+		 _action.isAction(0x2E2) || _action.isAction(0x2E3) || _action.isAction(0x2E4) || _action.isAction(0x2E5) ||
+		 _action.isAction(0x2E6) || _action.isAction(0x2E7)
+		)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			handleButtons();
+			_globals._sequenceIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[18], _flippedFl, 4, 2, 0, 0);
+			_scene->_sequences.setScale(_globals._sequenceIndexes[18], 60);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[18], Common::Point(_posX, 170));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[18], 0);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[18], SEQUENCE_TRIGGER_LOOP, 0, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[18], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+
+		case 1:
+			if (_buttonId >= 6) {
+				_vm->_sound->command(60);
+				setRightView(_buttonId - 6);
+			}
+			if (_buttonId == 4) {
+				_vm->_sound->command(38);
+				if (_leftItemId == 3)
+					setLeftView(0);
+				else
+					setLeftView(3);
+			}
+			if (_buttonId == 5) {
+				_vm->_sound->command(38);
+				if (_leftItemId == 1)
+					setLeftView(2);
+				else
+					setLeftView(1);
+			}
+			if (_buttonId <= 3) {
+				_vm->_sound->command(60);
+				setLeftView(_buttonId + 5);
+			}
+			break;
+
+		case 2:
+			_game._player._stepEnabled = true;
+			if (_buttonId == 5) {
+				if (_leftItemId == 2) {
+					_game._player._stepEnabled = false;
+					setRightView(8);
+					setLeftView(10);
+					_scene->_kernelMessages.reset();
+					_scene->resetScene();
+					_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('m', 2));
+					_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('m', 4));
+					_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('m', 9));
+					_blinkFl = false;
+					setLeftView(2);
+					_game.loadQuoteSet(0xFE, 0);
+					_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+					_scene->loadAnimation(formAnimName('a', -1), 70);
+					_vm->_sound->command(17);
+				}
+			}
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(0x1CD, 0x2EF))
+		_scene->_nextSceneId = 311;
+	else if (_action.isAction(VERB_LOOK, 0x2DC))
+		_vm->_dialogs->show(0x7D01);
+	else if (_action.isAction(VERB_LOOK, 0x2DB))
+		_vm->_dialogs->show(0x7D02);
+	else if (_action.isAction(VERB_LOOK, 0x1E4))
+		_vm->_dialogs->show(0x7D03);
+	else if (_action.isAction(VERB_LOOK, 0x2EF))
+		_vm->_dialogs->show(0x7D04);
+	else if (_action.isAction(VERB_LOOK, 0x2ED))
+		_vm->_dialogs->show(0x7D05);
+	else if (_action.isAction(VERB_LOOK, 0x2EE))
+		_vm->_dialogs->show(0x7D06);
+	else if (_action.isAction(VERB_LOOK, 0x2F1))
+		_vm->_dialogs->show(0x7D06);
+	else if (_action.isAction(VERB_LOOK, 0x2F3))
+		_vm->_dialogs->show(0x7D08);
+	else if (_action.isAction(VERB_LOOK, 0x2F0))
+		_vm->_dialogs->show(0x7D09);
+	else if (_action.isAction(VERB_LOOK, 0x2F2))
+		_vm->_dialogs->show(0x7D0A);
+	else if (_action.isAction(VERB_TAKE, 0x2ED))
+		_vm->_dialogs->show(0x7D0C);
+	else if (_action.isAction(VERB_TAKE, 0x2F2))
+		_vm->_dialogs->show(0x7D0D);
+	else if (_action.isAction(VERB_TAKE, 0x2EE) || _action.isAction(0x75, 0x2EE))
+		_vm->_dialogs->show(0x7D0E);
+	else if (_action.isAction(VERB_TAKE, 0x2F3))
+		_vm->_dialogs->show(0x7D0F);
+	else if (_action.isAction(VERB_TAKE, 0x2F1))
+		_vm->_dialogs->show(0x7D10);
+	else if (_action.isAction(VERB_TAKE, 0x2F0))
+		_vm->_dialogs->show(0x7D11);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index b284a2e..79ffa31 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -310,6 +310,33 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene320: public Scene3xx {
+private:
+	void setRightView(int view);
+	void setLeftView(int view);
+	void handleButtons();
+
+	bool _blinkFl;
+	bool _flippedFl;
+
+	int _buttonId;
+	int _lastFrame;
+	int _leftItemId;
+	int _posX;
+	int _rightItemId;
+
+public:
+	Scene320(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: c1a90cdda1f1424cb9b6b2e91b82c47cf0913335
    https://github.com/scummvm/scummvm/commit/c1a90cdda1f1424cb9b6b2e91b82c47cf0913335
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-23T21:01:48-04:00

Commit Message:
MADS: Further synchronization implementation

Changed paths:
    engines/mads/game.cpp
    engines/mads/globals.cpp
    engines/mads/globals.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/game_nebular.h
    engines/mads/nebular/globals_nebular.cpp
    engines/mads/scene.cpp
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 3b591d7..462c640 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -408,6 +408,7 @@ void Game::synchronize(Common::Serializer &s, bool phase1) {
 		if (s.isLoading()) {
 			_sectionNumber = _scene._nextSceneId / 100;
 			_currentSectionNumber = _sectionNumber;
+			_scene._frameStartTime = _vm->_events->getFrameCounter();
 		}
 	} else {
 		s.syncAsByte(_difficulty);
diff --git a/engines/mads/globals.cpp b/engines/mads/globals.cpp
index 68a2cf1..de15ba9 100644
--- a/engines/mads/globals.cpp
+++ b/engines/mads/globals.cpp
@@ -26,8 +26,27 @@
 namespace MADS {
 
 void Globals::reset() {
-	for (uint i = 0; i < _flags.size(); ++i)
-		_flags[i] = 0;
+	for (uint i = 0; i < _data.size(); ++i)
+		_data[i] = 0;
+}
+
+void Globals::synchronize(Common::Serializer &s) {
+	int count = 0;
+	int16 v;
+	s.syncAsUint16LE(count);
+
+	if (s.isSaving()) {
+		for (int idx = 0; idx < count; ++idx) {
+			v = _data[idx];
+			s.syncAsSint16LE(v);
+		}	
+	} else {
+		_data.clear();
+		for (int idx = 0; idx < count; ++idx) {
+			s.syncAsSint16LE(v);
+			_data.push_back(v);
+		}
+	}
 }
 
 
diff --git a/engines/mads/globals.h b/engines/mads/globals.h
index ea327b0..fa7a630 100644
--- a/engines/mads/globals.h
+++ b/engines/mads/globals.h
@@ -25,24 +25,30 @@
 
 #include "common/scummsys.h"
 #include "common/array.h"
+#include "common/serializer.h"
 
 namespace MADS {
 
 class Globals {
 protected:
-	Common::Array<int16> _flags;
+	Common::Array<int16> _data;
 public:
 	Globals() {}
 
 	/**
 	* Square brackets operator for accessing flags
 	*/
-	int16 &operator[](int idx) { return _flags[idx]; }
+	int16 &operator[](int idx) { return _data[idx]; }
 
 	/*
 	 * Resets all the globals to empty
 	 */
 	void reset();
+
+	/**
+	 * Synchronize the globals data
+	 */
+	void synchronize(Common::Serializer &s);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 23c8b3c..34eb6f1 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -744,6 +744,14 @@ void GameNebular::step() {
 	}
 }
 
+void GameNebular::synchronize(Common::Serializer &s, bool phase1) {
+	Game::synchronize(s, phase1);
+
+	if (!phase1) {
+		_globals.synchronize(s);
+	}
+}
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index 7d64e3e..0e2d564 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -73,6 +73,8 @@ public:
 	virtual void unhandledAction();
 
 	virtual void step();
+
+	virtual void synchronize(Common::Serializer &s, bool phase1);
 };
 
 
diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp
index 3e9a9f7..a8b7cdc 100644
--- a/engines/mads/nebular/globals_nebular.cpp
+++ b/engines/mads/nebular/globals_nebular.cpp
@@ -30,7 +30,7 @@ namespace Nebular {
 
 NebularGlobals::NebularGlobals(): Globals() {
 	// Initialize lists
-	_flags.resize(210);
+	_data.resize(210);
 	_spriteIndexes.resize(30);
 	_sequenceIndexes.resize(30);
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 239a91c..2421847 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -684,6 +684,7 @@ void Scene::freeAnimation() {
 void Scene::synchronize(Common::Serializer &s) {
 	_action._activeAction.synchronize(s);
 	_rails.synchronize(s);
+	_userInterface.synchronize(s);
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 493804c..9a63ac3 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -1079,4 +1079,12 @@ void UserInterface::scrollInventory() {
 	_vm->_game->_screenObjects._v8332A = 0;
 }
 
+void UserInterface::synchronize(Common::Serializer &s) {
+	InventoryObjects &invObjects = _vm->_game->_objects;
+
+	if (s.isLoading()) {
+		_selectedInvIndex = invObjects._inventoryList.empty() ? -1 : 0;
+	}
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index baae269..1e07681 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -293,6 +293,11 @@ public:
 	 * Add a msesage to the list of conversation items to select from
 	 */
 	void addConversationMessage(int vocabId, const Common::String &msg);
+
+	/**
+	 * Synchronize the data
+	 */
+	void synchronize(Common::Serializer &s);
 };
 
 } // End of namespace MADS


Commit: 1495f04bbcbe26bb3f2b93131e3d89c30ea47279
    https://github.com/scummvm/scummvm/commit/1495f04bbcbe26bb3f2b93131e3d89c30ea47279
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-23T21:57:25-04:00

Commit Message:
MADS: Fix scenes previously using globals to properly use locals

Changed paths:
    engines/mads/game.cpp
    engines/mads/nebular/globals_nebular.cpp
    engines/mads/nebular/globals_nebular.h
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/nebular/nebular_scenes8.h



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 462c640..9c124aa 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -409,6 +409,9 @@ void Game::synchronize(Common::Serializer &s, bool phase1) {
 			_sectionNumber = _scene._nextSceneId / 100;
 			_currentSectionNumber = _sectionNumber;
 			_scene._frameStartTime = _vm->_events->getFrameCounter();
+
+			_player._spritesLoaded = false;
+			_player._spritesChanged = true;
 		}
 	} else {
 		s.syncAsByte(_difficulty);
diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp
index a8b7cdc..4144797 100644
--- a/engines/mads/nebular/globals_nebular.cpp
+++ b/engines/mads/nebular/globals_nebular.cpp
@@ -37,20 +37,6 @@ NebularGlobals::NebularGlobals(): Globals() {
 	// Initialize game flags
 	_timebombClock = 0;
 	_timebombTimer = 0;
-	_v0 = 0;
-	_frameTime = 0;
-	_v2 = 0;
-	_v3 = 0;
-	_v4 = 0;
-	_v5 = 0;
-	_v6 = 0;
-	_v7 = 0;
-	_v8 = 0;
-	_abortVal = 0;
-	_v84262 = 0;
-	_v84264 = 0;
-	_v84266 = 0;
-	_v84268 = 0;
 }
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index b8fe17f..56fbc1b 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -285,6 +285,7 @@ public:
 	Common::Array<int> _sequenceIndexes;
 	
 	int _timebombClock, _timebombTimer;
+	/*
 	int _v0;
 	uint32 _frameTime;
 	int _v2;
@@ -296,6 +297,7 @@ public:
 	int _v8;
 	int _abortVal;
 	int _v84262, _v84264, _v84266, _v84268;
+	*/
 public:
 	/**
 	 * Constructor
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 2440068..da2d358 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -1267,8 +1267,8 @@ void Scene103::enter() {
 
 	_vm->_palette->setEntry(252, 63, 63, 10);
 	_vm->_palette->setEntry(253, 45, 45, 10);
-	_globals._v0 = 0;
-	_globals._frameTime = _scene->_frameStartTime;
+	_sayHiToBinky = false;
+	_updateClock = _scene->_frameStartTime;
 }
 
 void Scene103::step() {
@@ -1296,7 +1296,7 @@ void Scene103::step() {
 		break;
 	}
 	
-	if (_globals._frameTime <= _scene->_frameStartTime) {
+	if (_scene->_frameStartTime >= _updateClock) {
 		pt = _vm->_game->_player._playerPos;
 		dist = _vm->hypotenuse(pt.x - 79, pt.y - 137);
 		_vm->_sound->command(29, (dist * -127 / 378) + 127);
@@ -1309,7 +1309,7 @@ void Scene103::step() {
 		dist = _vm->hypotenuse(pt.x - 266, pt.y - 138);
 		_vm->_sound->command(32, (dist * -127 / 378) + 127);
 
-		_globals._frameTime = _scene->_frameStartTime + _vm->_game->_player._ticksAmount;
+		_updateClock = _scene->_frameStartTime + _vm->_game->_player._ticksAmount;
 	}
 }
 
@@ -1438,7 +1438,7 @@ void Scene103::actions() {
 		case 1: {
 			Common::String msg = _game.getQuote(72);
 			_scene->_kernelMessages.add(Common::Point(310, 132), 0xFDFC, 16, 2, 120, msg);
-			_globals._v0 = 0;
+			_sayHiToBinky = false;
 			break;
 		}
 			
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index b4585b0..d295c4d 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -102,6 +102,9 @@ public:
 };
 
 class Scene103 : public Scene1xx {
+private:
+	bool _sayHiToBinky;
+	uint32 _updateClock;
 public:
 	Scene103(MADSEngine *vm) : Scene1xx(vm) {}
 
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 7491ed1..88b3f94 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -449,7 +449,8 @@ void Scene202::enter() {
 		_game._player._playerPos = Common::Point(246, 124);
 		_game._player._facing = FACING_NORTH;
 	}
-	_globals._abortVal = 0;
+
+	_meteorologistSpecial = 0;
 }
 
 void Scene202::setRandomKernelMessage() {
@@ -493,7 +494,7 @@ void Scene202::step() {
 			_action._activeAction._indirectObjectId = 438;
 			_game._triggerSetupMode = SEQUENCE_TRIGGER_PARSER;
 			_scene->_sequences.addTimer(120, 2);
-			_globals._abortVal = -1;
+			_meteorologistSpecial = -1;
 		} else if (_globals[kMeteorologistWatch] == 2) {
 			_scene->_sequences.addTimer(120, 90);
 		}
@@ -849,7 +850,7 @@ void Scene202::actions() {
 					}
 					break;
 				case 2:
-					if (!_scene->_activeAnimation && (_globals._abortVal == 0)) {
+					if (!_scene->_activeAnimation && !_meteorologistSpecial) {
 						_vm->_dialogs->show(0x4EFE);
 					}
 					_scene->_sequences.remove(_globals._sequenceIndexes[10]);
@@ -905,7 +906,7 @@ void Scene202::actions() {
 				case 2:
 					if (!_scene->_activeAnimation)
 						_vm->_dialogs->show(0x4EFE);
-					_globals._abortVal = 0;
+					_meteorologistSpecial = 0;
 					_scene->_sequences.remove(_globals._sequenceIndexes[10]);
 					_globals._sequenceIndexes[9] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
 					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
@@ -1136,7 +1137,7 @@ void Scene205::enter() {
 		_scene->_hotspots.activate(450, false);
 	}
 
-	_globals._frameTime &= 0xFFFF;
+	_beingKicked = false;
 	_game.loadQuoteSet(0x6B, 0x70, 0x71, 0x72, 0x5A, 0x74, 0x75, 0x76, 0x77, 0x78, 0x73, 0x79, 0x7A, 0x7B, 0x7C,
 		0x7D, 0x7E, 0x7F, 0x80, 0xAC, 0xAD, 0xAE, 0x6C, 0x6D, 0x6E, 0x6F, 0x2, 0);
 	warning("TODO: sub71A50(&dialog1, 0x5A, 0x78, 0x74, 0x75, 0x76, 0x77, 0);");
@@ -1150,7 +1151,7 @@ void Scene205::enter() {
 	_vm->_palette->setEntry(252, 63, 63, 40);
 	_vm->_palette->setEntry(253, 50, 50, 30);
 
-	_chickenTime = _globals._frameTime;
+	_chickenTime = _vm->_game->_scene._frameStartTime;
 
 	if (_globals[kSexOfRex] == SEX_FEMALE)
 		warning("sub71704(0x3, 0xC3, 0x108, 0x63, 0x86, 0xD, 2, 0xFDFC, 0x3C, 0x6C, 0x6C, 0x6D, 0x6D, 0x6E, 0x6E, 0x6F, 0x6C, 0);");
@@ -1162,7 +1163,7 @@ void Scene205::enter() {
 		_scene->loadAnimation(formAnimName('a', -1), 0);
 		_scene->_activeAnimation->_resetFlag = false;
 	} else {
-		_globals._frameTime |= 0xFFFF0000;
+		_beingKicked = true;
 		_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
 		_game._player._visible = false;
 		_game._player._stepEnabled = false;
@@ -1178,19 +1179,21 @@ void Scene205::step() {
 	if (_globals[kSexOfRex] == SEX_FEMALE) {
 		warning("TODO: sub7178C()");
 
-		if (_globals._frameTime >= _chickenTime) {
+		if (_vm->_game->_scene._frameStartTime >= _chickenTime) {
 			warning("TODO: if (sub717B2(100, 1 + sub7176C()))");
 				_vm->_sound->command(28);
 //			}
-			_chickenTime = _globals._frameTime + 2;
+				_chickenTime = _vm->_game->_scene._frameStartTime + 2;
 		}
 	}
 
-	if (_globals._frameTime - _lastFishTime > 1300) {
-		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 5, 1, 0, 0);
-		int idx = _scene->_dynamicHotspots.add(269, 13, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
+	if (_vm->_game->_scene._frameStartTime - _lastFishTime > 1300) {
+		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(
+			_globals._spriteIndexes[6], false, 5, 1, 0, 0);
+		int idx = _scene->_dynamicHotspots.add(269, 13, _globals._sequenceIndexes[6], 
+			Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(49, 86), FACING_NORTH);
-		_lastFishTime = _globals._frameTime;
+		_lastFishTime = _vm->_game->_scene._frameStartTime;
 	}
 
 	if (_game._trigger == 73) {
@@ -4296,7 +4299,7 @@ void Scene211::enter() {
 	if (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY)
 		warning("sub71704(0x2, 0x0, 0x36, 0x0, 0x1E, 0xD, 2, 0xFDFC, 0x3C, 0x97, 0x98, 0x99, 0x9A, 0);");
 
-	_monkeyTime = _globals._frameTime;
+	_monkeyTime = _vm->_game->_scene._frameStartTime;
 	_scrollY = 30;
 
 	_ambushFl = false;
@@ -4309,11 +4312,11 @@ void Scene211::step() {
 	if (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY) {
 		warning("TODO: sub7178C()");
 
-		if (!_ambushFl && !_wakeFl && (_globals._frameTime >= _monkeyTime)) {
+		if (!_ambushFl && !_wakeFl && (_vm->_game->_scene._frameStartTime >= _monkeyTime)) {
 			warning("if (sub717B2(80, 1 + sub7176C())) {");
 				_vm->_sound->command(18);
 			// }
-			_monkeyTime = _globals._frameTime + 2;
+			_monkeyTime = _vm->_game->_scene._frameStartTime + 2;
 		}
 
 		if ((_game._player._playerPos == Common::Point(52, 132)) && (_game._player._facing == FACING_WEST) && !_game._player._moving && 
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index ad87681..45fe790 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -68,6 +68,7 @@ private:
 	bool _activeMsgFl, _ladderTopFl, _waitingMeteoFl, _toStationFl, _toTeleportFl;
 	int _ladderHotspotId, _lastRoute, _stationCounter, _meteoFrame;
 	uint32 _meteoClock1, _meteoClock2, _startTime;
+	int _meteorologistSpecial;
 
 	int subStep1(int randVal);
 	int subStep2(int randVal);
@@ -105,7 +106,7 @@ public:
 class Scene205: public Scene2xx {
 private:
 	uint32 _lastFishTime, _chickenTime;
-
+	bool _beingKicked;
 public:
 	Scene205(MADSEngine *vm) : Scene2xx(vm), _lastFishTime(0), _chickenTime(0) {}
 
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 4ca5a6c..9f4873f 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -2536,7 +2536,7 @@ void Scene318::enter() {
 	_vm->_palette->setEntry(252, 63, 63, 10);
 	_vm->_palette->setEntry(253, 45, 45, 05);
 
-	_dropTimer = _globals._frameTime;
+	_dropTimer = _vm->_game->_scene._frameStartTime;
 	sceneEntrySound();
 
 	if (_dialogFl)
@@ -2662,11 +2662,11 @@ void Scene318::step() {
 		}
 	}
 
-	if ((_globals._frameTime - _dropTimer) > 600) {
+	if ((_vm->_game->_scene._frameStartTime - _dropTimer) > 600) {
 		_vm->_sound->command(51);
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 14, 1, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
-		_dropTimer = _globals._frameTime;
+		_dropTimer = _vm->_game->_scene._frameStartTime;
 	}
 }
 
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 8a5c3df..5a283d5 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -80,14 +80,17 @@ void Scene804::setup() {
 }
 
 void Scene804::enter() {
-	_globals._frameTime = 0;
-	_globals._v2 = 0;
-	_globals._v3 = 0;
-	_globals._v4 = 0;
-	_globals._v5 = -1;
-	_globals._v6 = 0;
-	_globals._v7 = 0;
-	_globals._v8 = 0;
+	_messWithThrottle = false;
+	_throttleCounter = 0;
+	_movingThrottle = false;
+	_throttleGone = false;
+	_dontPullThrottleAgain = false;
+	_resetFrame = -1;
+	_pullThrottleReally = false;
+	_alreadyOrgan = false;
+	_alreadyPop = false;
+
+
 	if (_globals[kCopyProtectFailed]) {
 		// Copy protection failed
 		_globals[kInSpace] = true;
@@ -136,152 +139,170 @@ void Scene804::enter() {
 }
 
 void Scene804::step() {
-	if (_globals._frameTime) {
-		if (_scene->_activeAnimation->getCurrentFrame() == 36 && !_globals._v3) {
-			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
-			_globals._v3 = -1;
-		}
-		if (_scene->_activeAnimation->getCurrentFrame() == 39) {
-			_globals._v2 = 0;
-			if ((_globals._frameTime / 256) == 3)
-				_scene->_sequences.addTimer(130, 120);
-		}
+	if (!_messWithThrottle) {
 
-		if (!_globals._v2) {
-			_globals._frameTime += 0x100;
-			_globals._v2 = -1;
-
-			if ((_globals._frameTime / 256) >= 4) {
-				_globals._frameTime = 0;
-				_game._player._stepEnabled = true;
-			} else {
-				_globals._v5 = 34;
-			}
-		}
-	} else {
-		if (_globals._v3 && _globals._v2 && _scene->_activeAnimation->getCurrentFrame() == 39) {
-			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+		if ((_throttleGone) && (_movingThrottle) && (_scene->_activeAnimation->getCurrentFrame() == 39)) {
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle
+				(_globals._spriteIndexes[1], false, 1);
 			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(133, 139));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 8);
-			_globals._v3 = 0;
+			_throttleGone = false;
 		}
 
-		if (_globals._v2 && _scene->_activeAnimation->getCurrentFrame() == 42) {
-			_globals._v5 = 0;
-			_globals._v2 = 0;
+		if ((_movingThrottle) && (_scene->_activeAnimation->getCurrentFrame() == 42)) {
+			_resetFrame = 0;
+			_movingThrottle = false;
 		}
 
-		if (_game._trigger == 70)
-			_globals._v5 = 42;
+		if (_game._trigger == 70) {
+			_resetFrame = 42;
+		}
 
-		if (_scene->_activeAnimation->getCurrentFrame() == 65)
+		if (_scene->_activeAnimation->getCurrentFrame() == 65) {
 			_scene->_sequences.remove(_globals._sequenceIndexes[7]);
+		}
 
-		switch (_game._storyMode)  {
+		switch (_game._storyMode) {
 		case STORYMODE_NAUGHTY:
 			if (_scene->_activeAnimation->getCurrentFrame() == 81) {
-				_globals._v5 = 80;
-			} else {
-				_globals[kInSpace] = 0;
-				_globals[kBeamIsUp] = -1;
+				_resetFrame = 80; 
+				_globals[kInSpace] = false;
+				_globals[kBeamIsUp] = true;
+
 				assert(!_globals[kCopyProtectFailed]);
 				_game._winStatus = 4;
 				_vm->quitGame();
 			}
 			break;
 
-		case STORYMODE_NICE:
+		case STORYMODE_NICE:			 
 			if (_scene->_activeAnimation->getCurrentFrame() == 68) {
-				_globals._v5 = 66;
-			} else {
-				_globals[kInSpace] = 0;
-				_globals[kBeamIsUp] = -1;
+				_resetFrame = 66;
+				_globals[kInSpace] = false;
+				_globals[kBeamIsUp] = true;
+
 				assert(!_globals[kCopyProtectFailed]);
 				_game._winStatus = 4;
 				_vm->quitGame();
 			}
-			break;
 		}
 
 		if (_scene->_activeAnimation->getCurrentFrame() == 34) {
-			_globals._v5 = 36;
+			_resetFrame = 36;
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		}
+
 		if (_scene->_activeAnimation->getCurrentFrame() == 37) {
-			_globals._v5 = 36;
-			if (!_globals._v4)
+			_resetFrame = 36;
+			if (!_dontPullThrottleAgain) {
+				_dontPullThrottleAgain = true;
 				_scene->_sequences.addTimer(60, 80);
+			}
 		}
 
-		if (_game._trigger == 80)
+		if (_game._trigger == 80) {
 			_scene->_nextSceneId = 803;
+		}
 
-		if (_scene->_activeAnimation->getCurrentFrame() == 7 && !_globals[kWindowFixed]) {
+		if ((_scene->_activeAnimation->getCurrentFrame() == 7) && (!_globals[kWindowFixed])) {
 			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 			_scene->_sequences.addTimer(20, 110);
-			_globals[kWindowFixed] = -1;
+			_globals[kWindowFixed] = true;
 		}
 
 		if (_scene->_activeAnimation->getCurrentFrame() == 10) {
-			_globals._v5 = 0;
+			_resetFrame = 0;
 			_game._player._stepEnabled = true;
-			_game._objects.setRoom(OBJ_POLYCEMENT, 1);
+			_game._objects.setRoom(OBJ_POLYCEMENT, NOWHERE);
 		}
 
-		switch (_scene->_activeAnimation->getCurrentFrame()) {
-		case 1:
-			_globals[kRandomNumber] = _vm->getRandomNumber(1, 30);
-			switch (_globals[kRandomNumber]) {
+		if (_scene->_activeAnimation->getCurrentFrame() == 1) {
+			int randomVal = _vm->getRandomNumber(29) + 1;
+			switch (randomVal) {
 			case 1:
-				_globals._v5 = 25;
+				_resetFrame = 25;
 				break;
 			case 2:
-				_globals._v5 = 27;
+				_resetFrame = 27;
 				break;
 			case 3:
-				_globals._v5 = 9;
+				_resetFrame = 29;
 				break;
 			default:
-				_globals._v5 = 0;
+				_resetFrame = 0;
 				break;
 			}
-			break;
+		}
 
+		switch (_scene->_activeAnimation->getCurrentFrame()) {
 		case 26:
 		case 28:
 		case 31:
-			_globals._v5 = 0;
+			_resetFrame = 0; 
 			break;
+		}
+	} else {   
+		if ((_scene->_activeAnimation->getCurrentFrame() == 36) && (!_throttleGone)) {
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_throttleGone = true;
+		}
 
-		default:
-			break;
+		if (_scene->_activeAnimation->getCurrentFrame() == 39) {
+			_movingThrottle = false;
+			switch (_throttleCounter) {
+			case 1:
+				break;
+			case 3:
+				_scene->_sequences.addTimer(130, 120);
+				break;
+			}
 		}
+
+		if (!_movingThrottle) {
+			++_throttleCounter;
+			_movingThrottle = true;
+			if (_throttleCounter < 4) {
+				_resetFrame = 34;
+			} else {
+				_messWithThrottle = false;
+				_throttleCounter = 0;
+				_game._player._stepEnabled = true;
+			}
+		}
+	}
+
+	if (_game._trigger == 120) {
+		_vm->_dialogs->show(80422);
 	}
 
-	if (_game._trigger == 120)
-		_vm->_dialogs->show(0x13a26);
-	if (_game._trigger == 110)
-		_vm->_dialogs->show(0x13a2a);
+	if (_game._trigger == 110) {
+		_vm->_dialogs->show(80426);
+	}
 
-	if (_globals._v6) {
-		_globals._v5 = 32;
-		_globals._v6 = 0;
+	if (_pullThrottleReally) {
+		_resetFrame = 32;
+		_pullThrottleReally = false;
 	}
-	if (_globals._v5 >= 0 && (_scene->_activeAnimation->getCurrentFrame() != _globals._v5)) {
-		_scene->_activeAnimation->setCurrentFrame(_globals._v5);
-		_globals._v5 = -1;
+
+	if (_resetFrame >= 0) {
+		if (_resetFrame != _scene->_activeAnimation->getCurrentFrame()) {
+			_scene->_activeAnimation->setCurrentFrame(_resetFrame);
+			_resetFrame = -1;
+		}
 	}
 
-	if (_game._trigger == 90)
+	if (_game._trigger == 90) {
 		_scene->_nextSceneId = 803;
+	}
 
-	if (_scene->_activeAnimation->getCurrentFrame() == 7 &&!_globals._v8) {
+	if ((_scene->_activeAnimation->getCurrentFrame() == 72) && !_alreadyPop)  {
 		_vm->_sound->command(21);
-		_globals._v8 = -1;
+		_alreadyPop = true;
 	}
-	if (_scene->_activeAnimation->getCurrentFrame() == 80 && !_globals._v7) {
+
+	if ((_scene->_activeAnimation->getCurrentFrame() == 80) && !_alreadyOrgan) {
 		_vm->_sound->command(22);
-		_globals._v7 = 0xFFFFFFFF;
+		_alreadyOrgan = true;
 	}
 }
 
diff --git a/engines/mads/nebular/nebular_scenes8.h b/engines/mads/nebular/nebular_scenes8.h
index a3bc97a..45e8716 100644
--- a/engines/mads/nebular/nebular_scenes8.h
+++ b/engines/mads/nebular/nebular_scenes8.h
@@ -53,6 +53,16 @@ public:
 };
 
 class Scene804: public Scene8xx {
+private:
+	bool _messWithThrottle;
+	uint32 _throttleCounter = 0;
+	bool _movingThrottle;
+	bool _throttleGone;
+	bool _dontPullThrottleAgain;
+	int _resetFrame;
+	bool _pullThrottleReally;
+	bool _alreadyOrgan;
+	bool _alreadyPop;
 public:
 	Scene804(MADSEngine *vm) : Scene8xx(vm) {}
 


Commit: 0f1cb2a5c123e44c6a21c168fd25ef1a06c911b6
    https://github.com/scummvm/scummvm/commit/0f1cb2a5c123e44c6a21c168fd25ef1a06c911b6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-23T22:09:15-04:00

Commit Message:
MADS: Add a synchronize method to some of the group 1 scenes

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h
    engines/mads/scene_data.h



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index da2d358..923d8c0 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -598,6 +598,19 @@ void Scene101::actions() {
 	}
 }
 
+void Scene101::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+
+	s.syncAsByte(_sittingFl);
+	s.syncAsByte(_panelOpened);
+
+	s.syncAsSint16LE(_messageNum);
+	s.syncAsSint16LE(_posY);
+	s.syncAsSint16LE(_shieldSpriteIdx);
+	s.syncAsSint16LE(_chairHotspotId);
+	s.syncAsSint16LE(_oldSpecial);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene102::setup() {
@@ -1191,6 +1204,19 @@ void Scene102::postActions() {
 	}
 }
 
+void Scene102::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+
+	s.syncAsByte(_fridgeOpenedFl);
+	s.syncAsByte(_fridgeOpenedDescr);
+	s.syncAsByte(_fridgeFirstOpenFl);
+	s.syncAsByte(_chairDescrFl);
+	s.syncAsByte(_drawerDescrFl);
+	s.syncAsByte(_activeMsgFl);
+
+	s.syncAsSint16LE(_fridgeCommentCount);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene103::setup() {
@@ -1510,6 +1536,12 @@ void Scene103::postActions() {
 	}
 }
 
+void Scene103::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+	s.syncAsByte(_sayHiToBinky);
+	s.syncAsUint32LE(_updateClock);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene104::setup() {
@@ -1704,6 +1736,13 @@ void Scene104::actions() {
 	_action._inProgress = false;
 }
 
+void Scene104::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+
+	s.syncAsByte(_kargShootingFl);
+	s.syncAsByte(_loseFl);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene105::setup() {
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index d295c4d..25a8b52 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -24,6 +24,7 @@
 #define MADS_NEBULAR_SCENES1_H
 
 #include "common/scummsys.h"
+#include "common/serializer.h"
 #include "mads/game.h"
 #include "mads/scene.h"
 #include "mads/nebular/nebular_scenes.h"
@@ -73,7 +74,8 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
+	virtual void postActions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene102 : public Scene1xx {
@@ -99,6 +101,7 @@ public:
 	virtual void preActions();
 	virtual void actions();
 	virtual void postActions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene103 : public Scene1xx {
@@ -111,9 +114,9 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
 	virtual void postActions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene104 : public Scene1xx {
@@ -129,7 +132,7 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene105 : public Scene1xx {
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 5b3d818..d59d746 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -96,12 +96,12 @@ public:
 	/**
 	 * Called one per frame
 	 */
-	virtual void step() = 0;
+	virtual void step() {}
 
 	/**
 	 * Called before an action is started
 	 */
-	virtual void preActions() = 0;
+	virtual void preActions() {}
 
 	/**
 	 * Handles scene actions
@@ -111,7 +111,12 @@ public:
 	/**
 	 * Post-action handling
 	 */
-	virtual void postActions() = 0;
+	virtual void postActions() {}
+
+	/**
+	 * Synchronize any local data for the scene
+	 */
+	virtual void synchronize(Common::Serializer &s) {}
 };
 
 struct ARTHeader {


Commit: ba34b1f8823e9e39a6d9c5bed76f10910d8c65ec
    https://github.com/scummvm/scummvm/commit/ba34b1f8823e9e39a6d9c5bed76f10910d8c65ec
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-24T07:14:55+02:00

Commit Message:
MADS: Implement scene 321

Changed paths:
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 9f4873f..b0b837b 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -3639,5 +3639,42 @@ void Scene320::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene321::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene321::enter() {
+	_game._player._visible = false;
+	_game._player._stepEnabled = false;
+
+	_scene->_userInterface.emptyConversationList();
+	_scene->_userInterface.setup(kInputConversation);
+
+	int suffixNum;
+	if (_globals[kSexOfRex] == REX_FEMALE) {
+		_globals[kSexOfRex] = REX_MALE;
+		suffixNum = 1;
+	} else {
+		_globals[kSexOfRex] = REX_FEMALE;
+		suffixNum = _game._visitedScenes._sceneRevisited ? 2 : 0;
+	}
+
+	_scene->loadAnimation(formAnimName('g', suffixNum), 60);
+	sceneEntrySound();
+}
+
+void Scene321::step() {
+	if (_scene->_activeAnimation != nullptr) {
+		if ((_scene->_activeAnimation->getCurrentFrame() >= 260) && (_globals[kSexOfRex] == REX_MALE) && (_game._storyMode >= STORYMODE_NICE))
+			_scene->_nextSceneId = 316;
+	}
+
+	if (_game._trigger == 60)
+		_scene->_nextSceneId = 316;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 79ffa31..6da0f3e 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -337,6 +337,18 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene321: public Scene3xx {
+public:
+	Scene321(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions() {};
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 26b7deb6106ded2d68ecb4feb4a484b3313b7af2
    https://github.com/scummvm/scummvm/commit/26b7deb6106ded2d68ecb4feb4a484b3313b7af2
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-24T07:14:58+02:00

Commit Message:
MADS: Fix bugs in scene 307

Changed paths:
    engines/mads/nebular/nebular_scenes3.cpp



diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index b0b837b..6f22b7b 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -821,7 +821,7 @@ void Scene307::step() {
 				if (_prisonerMessageId > 0x10A)
 					_prisonerMessageId = 0x104;
 			} else if (_globals[kKnowsBuddyBeast] && (_vm->getRandomNumber(1, 3) == 1)) {
-				if (_globals[kKnowsBuddyBeast] && (dialog2.read(0) > 1) && (_vm->getRandomNumber(1, 3) == 1)) {
+				if (_globals[kKnowsBuddyBeast] && (dialog2.read(0)) && (_vm->getRandomNumber(1, 3) == 1)) {
 					int idx = _scene->_kernelMessages.add(Common::Point(5, 51), 0xFDFC, 0, 81, 120, _game.getQuote(267));
 					_scene->_kernelMessages.setQuoted(idx, 4, true);
 				}


Commit: f330106be2368df453fec7799a2d061c829f525d
    https://github.com/scummvm/scummvm/commit/f330106be2368df453fec7799a2d061c829f525d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-24T08:24:23-04:00

Commit Message:
MADS: Hook game scene into synchronisation logic

Changed paths:
    engines/mads/nebular/nebular_scenes1.h
    engines/mads/scene.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index 25a8b52..ee98179 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -74,7 +74,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions();
 	virtual void synchronize(Common::Serializer &s);
 };
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 2421847..9217be6 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -685,6 +685,7 @@ void Scene::synchronize(Common::Serializer &s) {
 	_action._activeAction.synchronize(s);
 	_rails.synchronize(s);
 	_userInterface.synchronize(s);
+	_sceneLogic->synchronize(s);
 }
 
 } // End of namespace MADS


Commit: 1098246f2be705de82dd3077dd25323380c32dd1
    https://github.com/scummvm/scummvm/commit/1098246f2be705de82dd3077dd25323380c32dd1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-24T09:12:09-04:00

Commit Message:
MADS: Added methods for can save/load currently

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



diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index c40d4bf..6f57b1d 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -26,6 +26,7 @@
 #include "common/events.h"
 #include "engines/util.h"
 #include "mads/mads.h"
+#include "mads/game.h"
 #include "mads/screen.h"
 #include "mads/msurface.h"
 #include "mads/resources.h"
@@ -119,4 +120,14 @@ int MADSEngine::hypotenuse(int xv, int yv) {
 	return (int)sqrt((double)(xv * xv + yv * yv));
 }
 
+bool MADSEngine::canLoadGameStateCurrently() {
+	return !_game->_winStatus && !_game->globals()[5]
+		&& _dialogs->_pendingDialog == DIALOG_NONE;
+}
+
+bool MADSEngine::canSaveGameStateCurrently() {
+	return !_game->_winStatus && !_game->globals()[5]
+		&& _dialogs->_pendingDialog == DIALOG_NONE;
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index 4ea0758..f13b3b9 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -119,6 +119,16 @@ public:
 	int getRandomNumber(int maxNumber);
 	int getRandomNumber(int minNumber, int maxNumber);
 	int hypotenuse(int xv, int yv);
+
+	/**
+	* Returns true if it is currently okay to restore a game
+	*/
+	bool canLoadGameStateCurrently();
+
+	/**
+	* Returns true if it is currently okay to save the game
+	*/
+	bool canSaveGameStateCurrently();
 };
 
 } // End of namespace MADS


Commit: f18104e7564b9d0b7a0377bd9510959d7a2d8867
    https://github.com/scummvm/scummvm/commit/f18104e7564b9d0b7a0377bd9510959d7a2d8867
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-24T09:21:21-04:00

Commit Message:
MADS: Fixed Conversation::read method

Changed paths:
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 9a63ac3..d4ab0d3 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -258,16 +258,20 @@ void Conversation::set(int quoteId, ...) {
 	va_end(va);
 }
 
-bool Conversation::read(int quoteId) {
+int Conversation::read(int quoteId) {
 	uint16 flags = _vm->_game->globals()[_globalId];
+	int count = 0;
 
 	for (uint idx = 0; idx < _quotes.size(); ++idx) {
-		if (_quotes[idx] == quoteId) {
+		if (flags & (1 << idx))
+			++count;
+
+		if (_quotes[idx] == quoteId)
 			return flags & (1 << idx);
-		}
 	}
 
-	return false;
+	// Could not find it, simply return number of active quotes
+	return count;
 }
 
 void Conversation::write(int quoteId, bool flag) {
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 1e07681..9948278 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -114,9 +114,10 @@ public:
 	void set(int quoteId, ...);
 
 	/**
-	 * Returns true whether the given quote is enabled in the conversation
+	 * Returns the bit for a given quote to indicate whether it's active or not or,
+	 * if 0 is passed, returns the number of currently active quotes
 	 */
-	bool read(int quoteId);
+	int read(int quoteId);
 
 	/**
 	 * Activates or deactivates the specified quote in the given conversation node


Commit: 41c6ad69716ec4b4df459811fc470e3134bb2229
    https://github.com/scummvm/scummvm/commit/41c6ad69716ec4b4df459811fc470e3134bb2229
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-24T15:26:53+02:00

Commit Message:
MADS: Better fix of scene 307

Changed paths:
    engines/mads/nebular/nebular_scenes3.cpp



diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 6f22b7b..3f5d693 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -820,11 +820,9 @@ void Scene307::step() {
 				_prisonerMessageId++;
 				if (_prisonerMessageId > 0x10A)
 					_prisonerMessageId = 0x104;
-			} else if (_globals[kKnowsBuddyBeast] && (_vm->getRandomNumber(1, 3) == 1)) {
-				if (_globals[kKnowsBuddyBeast] && (dialog2.read(0)) && (_vm->getRandomNumber(1, 3) == 1)) {
-					int idx = _scene->_kernelMessages.add(Common::Point(5, 51), 0xFDFC, 0, 81, 120, _game.getQuote(267));
-					_scene->_kernelMessages.setQuoted(idx, 4, true);
-				}
+			} else if (_globals[kKnowsBuddyBeast] && (dialog2.read(0) > 1) && (_vm->getRandomNumber(1, 3) == 1)) {
+				int idx = _scene->_kernelMessages.add(Common::Point(5, 51), 0xFDFC, 0, 81, 120, _game.getQuote(267));
+				_scene->_kernelMessages.setQuoted(idx, 4, true);
 			}
 			_prisonerTimer = 0;
 		}


Commit: 6801694070d24b02344899959a25e961ce4fded1
    https://github.com/scummvm/scummvm/commit/6801694070d24b02344899959a25e961ce4fded1
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-24T15:27:18+02:00

Commit Message:
MADS: Fix compilation warning in scene 804

Changed paths:
    engines/mads/nebular/nebular_scenes8.h



diff --git a/engines/mads/nebular/nebular_scenes8.h b/engines/mads/nebular/nebular_scenes8.h
index 45e8716..e854fef 100644
--- a/engines/mads/nebular/nebular_scenes8.h
+++ b/engines/mads/nebular/nebular_scenes8.h
@@ -55,7 +55,7 @@ public:
 class Scene804: public Scene8xx {
 private:
 	bool _messWithThrottle;
-	uint32 _throttleCounter = 0;
+	uint32 _throttleCounter;
 	bool _movingThrottle;
 	bool _throttleGone;
 	bool _dontPullThrottleAgain;
@@ -64,7 +64,7 @@ private:
 	bool _alreadyOrgan;
 	bool _alreadyPop;
 public:
-	Scene804(MADSEngine *vm) : Scene8xx(vm) {}
+	Scene804(MADSEngine *vm) : Scene8xx(vm), _throttleCounter(0) {}
 
 	virtual void setup();
 


Commit: 41d8af2d5632099f36573e66b364839cadbc9dff
    https://github.com/scummvm/scummvm/commit/41d8af2d5632099f36573e66b364839cadbc9dff
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-25T06:57:02+02:00

Commit Message:
MADS: Implement scene 351

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 32d567a..df2433d 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -132,6 +132,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 320:
 		return new Scene320(vm);
 
+	case 351:
+		return new Scene351(vm);
 	// Scene group #8
 	case 804:
 		return new Scene804(vm);
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 3f5d693..50cc7ca 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -3674,5 +3674,217 @@ void Scene321::step() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene351::setup() {
+	if (_scene->_currentSceneId == 391)
+		_globals[kSexOfRex] = REX_MALE;
+
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0xD);
+}
+
+void Scene351::enter() {
+	_globals[kAfterHavoc] = -1;
+	_globals[kTeleporterRoom + 1] = 351;
+
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', -1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*ROXRC_7");
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RXRD_7");
+
+	if (_game._objects.isInRoom(0xF)) {
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 4);
+	} else
+		_scene->_hotspots.activate(0x5C, false);
+
+	if (_scene->_priorSceneId == 352)
+		_game._player._playerPos = Common::Point(148, 152);
+	else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(207, 81);
+		_game._player._facing = FACING_NORTH;
+	} 
+
+	if (_globals[kTeleporterCommand]) {
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+
+		char sepChar = 'a';
+		if (_globals[kSexOfRex] != REX_MALE)
+			sepChar = 'b';
+
+		int suffixNum = -1;
+		int trigger = 0;
+
+		switch (_globals[kTeleporterCommand]) {
+		case 1:
+			suffixNum = 0;
+			trigger = 60;
+			_globals[kTeleporterCommand] = true;
+			break;
+
+		case 2:
+			suffixNum = 1;
+			trigger = 61;
+			break;
+
+		case 3:
+		case 4:
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			_game._player._turnToFacing = FACING_SOUTH;
+			suffixNum = -1;
+			break;
+
+		default:
+			break;
+		}
+
+		_globals[kTeleporterCommand] = 0;
+
+		if (suffixNum >= 0)
+			_scene->loadAnimation(formAnimName(sepChar, suffixNum), trigger);
+	}
+
+	sceneEntrySound();
+}
+
+void Scene351::step() {
+	if (_game._trigger == 60) {
+		_game._player._stepEnabled = true;
+		_game._player._visible = true;
+		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+		_game._player._turnToFacing = FACING_SOUTH;
+	}
+
+	if (_game._trigger == 61) {
+		_globals[kTeleporterCommand] = 1;
+		_scene->_nextSceneId = _globals[kTeleporterDestination];
+		_scene->_reloadSceneFlag = true;
+	}
+}
+
+void Scene351::actions() {
+	if (_action._lookFlag) {
+		_vm->_dialogs->show(0x8931);
+		goto handled;
+	}
+
+	if (_action.isAction(0x2F9, 0x16C)) {
+		_scene->_nextSceneId = 322;
+		goto handled;
+	}
+
+	if (_action.isAction(0x1AD, 0x2B3)) {
+		_scene->_nextSceneId = 352;
+		goto handled;
+	}
+
+	if (_action.isAction(VERB_TAKE, 0x5C)) {
+		if (_game._trigger || !_game._objects.isInInventory(0xF)) {
+			switch (_game._trigger) {
+			case 0:
+				_game._player._stepEnabled = false;
+				_game._player._visible = false; 
+				if (_globals[kSexOfRex] == REX_FEMALE) {
+					_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 5, 2, 0, 0);
+					_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 5, 1);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				} else {
+					_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 5, 2, 0, 0);
+					_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 6, 1);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				} 
+				break;
+
+			case 1:
+				_scene->_hotspots.activate(0x5C, false);
+				_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+				_game._objects.addToInventory(0xF);
+				break;
+
+			case 2:
+				_game._player._visible = true;
+				_game._player._stepEnabled = true;
+				_vm->_dialogs->showItem(0xF, 0x32F);
+				break;
+			}
+		}
+		goto handled;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x180)) {
+		_vm->_dialogs->show(0x8926);
+		goto handled;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x23A)) {
+		_vm->_dialogs->show(0x8927);
+		goto handled;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x1E6)) {
+		_vm->_dialogs->show(0x8928);
+		goto handled;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x239)) {
+		if (_game._objects[0xF]._roomNumber == 351)
+			_vm->_dialogs->show(0x892A);
+		else
+			_vm->_dialogs->show(0x8929);
+
+		goto handled;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x2C7)) {
+		_vm->_dialogs->show(0x892B);
+		goto handled;
+	} 
+
+	if (_action.isAction(VERB_LOOK, 0x1E4)) {
+		_vm->_dialogs->show(0x892C);
+		goto handled;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0xD7)) {
+		_vm->_dialogs->show(0x892D);
+		goto handled;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x16C)) {
+		_vm->_dialogs->show(0x892E);
+		goto handled;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x59)) {
+		_vm->_dialogs->show(0x892F);
+		goto handled;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x2B3)) {
+		_vm->_dialogs->show(0x8930);
+		goto handled;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x1EB)) {
+		_vm->_dialogs->show(0x8932);
+		goto handled;
+	} 
+
+
+
+	goto done;
+
+handled:
+	_action._inProgress = false;
+
+done:
+	;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 6da0f3e..5be10ac 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -349,6 +349,17 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene351: public Scene3xx {
+public:
+	Scene351(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 44fd705fdf39ea0a0b96fbd1f19e31334a3d2113
    https://github.com/scummvm/scummvm/commit/44fd705fdf39ea0a0b96fbd1f19e31334a3d2113
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-25T07:13:29+02:00

Commit Message:
MADS: Refactor Scene351::actions()

Changed paths:
    engines/mads/nebular/nebular_scenes3.cpp



diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 50cc7ca..bc4c04d4 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -3764,22 +3764,13 @@ void Scene351::step() {
 }
 
 void Scene351::actions() {
-	if (_action._lookFlag) {
+	if (_action._lookFlag)
 		_vm->_dialogs->show(0x8931);
-		goto handled;
-	}
-
-	if (_action.isAction(0x2F9, 0x16C)) {
+	else if (_action.isAction(0x2F9, 0x16C))
 		_scene->_nextSceneId = 322;
-		goto handled;
-	}
-
-	if (_action.isAction(0x1AD, 0x2B3)) {
+	else if (_action.isAction(0x1AD, 0x2B3))
 		_scene->_nextSceneId = 352;
-		goto handled;
-	}
-
-	if (_action.isAction(VERB_TAKE, 0x5C)) {
+	else if (_action.isAction(VERB_TAKE, 0x5C)) {
 		if (_game._trigger || !_game._objects.isInInventory(0xF)) {
 			switch (_game._trigger) {
 			case 0:
@@ -3811,77 +3802,35 @@ void Scene351::actions() {
 				break;
 			}
 		}
-		goto handled;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0x180)) {
+	} else if (_action.isAction(VERB_LOOK, 0x180))
 		_vm->_dialogs->show(0x8926);
-		goto handled;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0x23A)) {
+	else if (_action.isAction(VERB_LOOK, 0x23A))
 		_vm->_dialogs->show(0x8927);
-		goto handled;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0x1E6)) {
+	else if (_action.isAction(VERB_LOOK, 0x1E6))
 		_vm->_dialogs->show(0x8928);
-		goto handled;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0x239)) {
+	else if (_action.isAction(VERB_LOOK, 0x239)) {
 		if (_game._objects[0xF]._roomNumber == 351)
 			_vm->_dialogs->show(0x892A);
 		else
 			_vm->_dialogs->show(0x8929);
-
-		goto handled;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0x2C7)) {
+	} else if (_action.isAction(VERB_LOOK, 0x2C7))
 		_vm->_dialogs->show(0x892B);
-		goto handled;
-	} 
-
-	if (_action.isAction(VERB_LOOK, 0x1E4)) {
+	else if (_action.isAction(VERB_LOOK, 0x1E4))
 		_vm->_dialogs->show(0x892C);
-		goto handled;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0xD7)) {
+	else if (_action.isAction(VERB_LOOK, 0xD7))
 		_vm->_dialogs->show(0x892D);
-		goto handled;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0x16C)) {
+	else if (_action.isAction(VERB_LOOK, 0x16C))
 		_vm->_dialogs->show(0x892E);
-		goto handled;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0x59)) {
+	else if (_action.isAction(VERB_LOOK, 0x59))
 		_vm->_dialogs->show(0x892F);
-		goto handled;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0x2B3)) {
+	else if (_action.isAction(VERB_LOOK, 0x2B3))
 		_vm->_dialogs->show(0x8930);
-		goto handled;
-	}
-
-	if (_action.isAction(VERB_LOOK, 0x1EB)) {
+	else if (_action.isAction(VERB_LOOK, 0x1EB))
 		_vm->_dialogs->show(0x8932);
-		goto handled;
-	} 
-
-
-
-	goto done;
+	else
+		return;
 
-handled:
 	_action._inProgress = false;
-
-done:
-	;
 }
 
 /*------------------------------------------------------------------------*/


Commit: bae0a6590a4ba843ef51f4cc67875c578863f5b2
    https://github.com/scummvm/scummvm/commit/bae0a6590a4ba843ef51f4cc67875c578863f5b2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-26T09:08:46-04:00

Commit Message:
MADS: Implemented savegame header read/writes

Changed paths:
    engines/mads/detection.cpp
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/mads.cpp
    engines/mads/mads.h



diff --git a/engines/mads/detection.cpp b/engines/mads/detection.cpp
index 015859f..b8e75b4 100644
--- a/engines/mads/detection.cpp
+++ b/engines/mads/detection.cpp
@@ -31,6 +31,7 @@
 #include "common/system.h"
 #include "graphics/colormasks.h"
 #include "graphics/surface.h"
+#include "mads/game.h"
 
 #define MAX_SAVES 99
 
@@ -124,6 +125,7 @@ SaveStateList MADSMetaEngine::listSaves(const char *target) const {
 	Common::StringArray filenames;
 	Common::String saveDesc;
 	Common::String pattern = Common::String::format("%s.0??", target);
+	MADS::MADSSavegameHeader header;
 
 	filenames = saveFileMan->listSavefiles(pattern);
 	sort(filenames.begin(), filenames.end());   // Sort to get the files in numerical order
@@ -137,6 +139,11 @@ SaveStateList MADSMetaEngine::listSaves(const char *target) const {
 			Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file);
 
 			if (in) {
+				MADS::Game::readSavegameHeader(in, header);
+				saveList.push_back(SaveStateDescriptor(slot, header._saveName));
+
+				header._thumbnail->free();
+				delete header._thumbnail;
 				delete in;
 			}
 		}
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 9c124aa..50c3ccd 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -21,8 +21,12 @@
  */
 
 #include "common/scummsys.h"
+#include "common/config-manager.h"
 #include "common/memstream.h"
 #include "common/serializer.h"
+#include "graphics/palette.h"
+#include "graphics/scaler.h"
+#include "graphics/thumbnail.h"
 #include "mads/mads.h"
 #include "mads/compression.h"
 #include "mads/game.h"
@@ -46,6 +50,7 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 		_scene(vm), _screenObjects(vm), _player(vm) {
 	_sectionNumber = _priorSectionNumber = 0;
 	_difficulty = DIFFICULTY_HARD;
+	_loadGameSlot = -1;
 	_serializer = nullptr;
 	_statusFlag = 0;
 	_sectionHandler = nullptr;
@@ -81,22 +86,33 @@ Game::~Game() {
 void Game::run() {
 	initialiseGlobals();
 
+	// If requested, load a savegame instead of showing the intro
+	if (ConfMan.hasKey("save_slot")) {
+		int saveSlot = ConfMan.getInt("save_slot");
+		if (saveSlot >= 0 && saveSlot <= 999)
+			_loadGameSlot = saveSlot;
+	}
+
 	_statusFlag = true;
-	int protectionResult = checkCopyProtection();
-	switch (protectionResult) {
-	case PROTECTION_FAIL:
-		// Copy protection failed
-		_scene._nextSceneId = 804;
-		break;
-	case PROTECTION_ESCAPE:
-		// User escaped out of copy protection dialog
-		_vm->quitGame();
-		break;
-	default:
-		// Copy protection check succeeded
-		_scene._nextSceneId = 103;
-		_scene._priorSceneId = 102;
-		break;
+	int protectionResult = -1;
+	
+	if (_loadGameSlot == -1) {
+		protectionResult = checkCopyProtection();
+		switch (protectionResult) {
+		case PROTECTION_FAIL:
+			// Copy protection failed
+			_scene._nextSceneId = 804;
+			break;
+		case PROTECTION_ESCAPE:
+			// User escaped out of copy protection dialog
+			_vm->quitGame();
+			break;
+		default:
+			// Copy protection check succeeded
+			_scene._nextSceneId = 103;
+			_scene._priorSceneId = 102;
+			break;
+		}
 	}
 
 	// Get the initial starting time for the first scene
@@ -422,4 +438,80 @@ void Game::synchronize(Common::Serializer &s, bool phase1) {
 	}
 }
 
+void Game::loadGame(int slotNumber) {
+
+}
+
+void Game::saveGame(int slotNumber, const Common::String &saveName) {
+
+}
+
+const char *const SAVEGAME_STR = "MADS";
+#define SAVEGAME_STR_SIZE 4
+
+bool Game::readSavegameHeader(Common::InSaveFile *in, MADSSavegameHeader &header) {
+	char saveIdentBuffer[SAVEGAME_STR_SIZE + 1];
+	header._thumbnail = NULL;
+
+	// Validate the header Id
+	in->read(saveIdentBuffer, SAVEGAME_STR_SIZE + 1);
+	if (strncmp(saveIdentBuffer, SAVEGAME_STR, SAVEGAME_STR_SIZE))
+		return false;
+
+	header._version = in->readByte();
+	if (header._version > MADS_SAVEGAME_VERSION)
+		return false;
+
+	// Read in the string
+	header._saveName.clear();
+	char ch;
+	while ((ch = (char)in->readByte()) != '\0') header._saveName += ch;
+
+	// Get the thumbnail
+	header._thumbnail = Graphics::loadThumbnail(*in);
+	if (!header._thumbnail)
+		return false;
+
+	// Read in save date/time
+	header._year = in->readSint16LE();
+	header._month = in->readSint16LE();
+	header._day = in->readSint16LE();
+	header._hour = in->readSint16LE();
+	header._minute = in->readSint16LE();
+	header._totalFrames = in->readUint32LE();
+
+	return true;
+}
+
+void Game::writeSavegameHeader(Common::OutSaveFile *out, MADSSavegameHeader &header) {
+	// Write out a savegame header
+	out->write(SAVEGAME_STR, SAVEGAME_STR_SIZE + 1);
+
+	out->writeByte(MADS_SAVEGAME_VERSION);
+
+	// Write savegame name
+	out->write(header._saveName.c_str(), header._saveName.size() + 1);
+
+	// Get the active palette
+	uint8 thumbPalette[256 * 3];
+	g_system->getPaletteManager()->grabPalette(thumbPalette, 0, 256);
+
+	// Create a thumbnail and save it
+	Graphics::Surface *thumb = new Graphics::Surface();
+	::createThumbnail(thumb, _vm->_screen.getData(), MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT, thumbPalette);
+	Graphics::saveThumbnail(*out, *thumb);
+	thumb->free();
+	delete thumb;
+
+	// Write out the save date/time
+	TimeDate td;
+	g_system->getTimeAndDate(td);
+	out->writeSint16LE(td.tm_year + 1900);
+	out->writeSint16LE(td.tm_mon + 1);
+	out->writeSint16LE(td.tm_mday);
+	out->writeSint16LE(td.tm_hour);
+	out->writeSint16LE(td.tm_min);
+	out->writeUint32LE(_vm->_events->getFrameCounter());
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/game.h b/engines/mads/game.h
index ad40fbd..8334d94 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -24,6 +24,7 @@
 #define MADS_GAME_H
 
 #include "common/scummsys.h"
+#include "common/savefile.h"
 #include "common/str-array.h"
 #include "common/serializer.h"
 #include "mads/scene.h"
@@ -54,6 +55,17 @@ enum ProtectionResult {
 	PROTECTION_SUCCEED = 0, PROTECTION_FAIL = 1, PROTECTION_ESCAPE = 2
 };
 
+#define MADS_SAVEGAME_VERSION 1
+
+struct MADSSavegameHeader {
+	uint8 _version;
+	Common::String _saveName;
+	Graphics::Surface *_thumbnail;
+	int _year, _month, _day;
+	int _hour, _minute;
+	int _totalFrames;
+};
+
 class Game {
 private:
 	/**
@@ -78,6 +90,8 @@ protected:
 	bool _quoteEmergency;
 	bool _vocabEmergency;
 	bool _anyEmergency;
+	int _loadGameSlot;
+	Common::String _saveName;
 	Common::Serializer *_serializer;
 
 	/**
@@ -188,6 +202,28 @@ public:
 	* Handle a keyboard event
 	*/
 	void handleKeypress(const Common::Event &event);
+
+	/**
+	 * Starts a savegame loading.
+	 * @remarks	Due to the way the engine is implemented, loading is done in two
+	 * parts, the second part after the specific scene has been loaded
+	 */
+	void loadGame(int slotNumber);
+
+	/**
+	 * Save the current game
+	 */
+	void saveGame(int slotNumber, const Common::String &saveName);
+
+	/**
+	 * Write out a savegame header
+	 */
+	void writeSavegameHeader(Common::OutSaveFile *out, MADSSavegameHeader &header);
+
+	/**
+	 * Read in a savegame header
+	 */
+	static bool readSavegameHeader(Common::InSaveFile *in, MADSSavegameHeader &header);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 6f57b1d..1df41ad 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -130,4 +130,12 @@ bool MADSEngine::canSaveGameStateCurrently() {
 		&& _dialogs->_pendingDialog == DIALOG_NONE;
 }
 
+/**
+* Support method that generates a savegame name
+* @param slot		Slot number
+*/
+Common::String MADSEngine::generateSaveName(int slot) {
+	return Common::String::format("%s.%03d", _targetName.c_str(), slot);
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index f13b3b9..8a4b7f6 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -129,6 +129,12 @@ public:
 	* Returns true if it is currently okay to save the game
 	*/
 	bool canSaveGameStateCurrently();
+
+	/**
+	* Support method that generates a savegame name
+	* @param slot		Slot number
+	*/
+	Common::String generateSaveName(int slot);
 };
 
 } // End of namespace MADS


Commit: bb5edf5426c3d8717d3a3f843a3dbf6193bbe9e9
    https://github.com/scummvm/scummvm/commit/bb5edf5426c3d8717d3a3f843a3dbf6193bbe9e9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-26T11:01:21-04:00

Commit Message:
MADS: Implemented more save/load logic

Changed paths:
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/game_data.cpp
    engines/mads/game_data.h
    engines/mads/mads.cpp
    engines/mads/mads.h



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 50c3ccd..9a5ec12 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -51,7 +51,7 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 	_sectionNumber = _priorSectionNumber = 0;
 	_difficulty = DIFFICULTY_HARD;
 	_loadGameSlot = -1;
-	_serializer = nullptr;
+	_saveFile = nullptr;
 	_statusFlag = 0;
 	_sectionHandler = nullptr;
 	_sectionNumber = 1;
@@ -79,6 +79,7 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 }
 
 Game::~Game() {
+	delete _saveFile;
 	delete _surface;
 	delete _sectionHandler;
 }
@@ -118,7 +119,7 @@ void Game::run() {
 	// Get the initial starting time for the first scene
 	_scene._frameStartTime = _vm->_events->getFrameCounter();
 
-	if (_serializer == nullptr && protectionResult != -1 && protectionResult != -2) {
+	if (_saveFile == nullptr && protectionResult != -1 && protectionResult != -2) {
 		initSection(_sectionNumber);
 		_statusFlag = true;
 
@@ -142,8 +143,10 @@ void Game::run() {
 
 void Game::gameLoop() {
 	while (!_vm->shouldQuit() && _statusFlag) {
-		if (_serializer)
-			synchronize(*_serializer, true);
+		if (_loadGameSlot != -1) {
+			loadGame(_loadGameSlot);
+			_loadGameSlot = -1;
+		}
 
 		setSectionHandler();
 		_sectionHandler->preLoadSection();
@@ -255,6 +258,13 @@ void Game::sectionLoop() {
 		_triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_scene._sceneLogic->enter();
 
+		// If in the middle of restoring a game, handle the rest of the loading
+		if (_saveFile != nullptr) {
+			Common::Serializer s(_saveFile, nullptr);
+			synchronize(s, false);
+			delete _saveFile;
+		}
+
 		// Set player data
 		_player._targetPos = _player._playerPos;
 		_player._turnToFacing = _player._facing;
@@ -420,6 +430,7 @@ void Game::synchronize(Common::Serializer &s, bool phase1) {
 	if (phase1) {
 		s.syncAsUint16LE(_scene._nextSceneId);
 		s.syncAsUint16LE(_scene._priorSceneId);
+		_visitedScenes.synchronize(s);
 
 		if (s.isLoading()) {
 			_sectionNumber = _scene._nextSceneId / 100;
@@ -439,11 +450,39 @@ void Game::synchronize(Common::Serializer &s, bool phase1) {
 }
 
 void Game::loadGame(int slotNumber) {
+	_saveFile = g_system->getSavefileManager()->openForLoading(
+		_vm->generateSaveName(slotNumber));
+	
+	Common::Serializer s(_saveFile, nullptr);
+	
+	// Load the savaegame header
+	MADSSavegameHeader header;
+	if (!readSavegameHeader(_saveFile, header))
+		error("Invalid savegame");
+
+	if (header._thumbnail) {
+		header._thumbnail->free();
+		delete header._thumbnail;
+	}
 
+	// Load the initial data such as what scene needs to be loaded up
+	synchronize(s, true);
 }
 
 void Game::saveGame(int slotNumber, const Common::String &saveName) {
+	Common::OutSaveFile *out = g_system->getSavefileManager()->openForSaving(
+		_vm->generateSaveName(slotNumber));
+
+	MADSSavegameHeader header;
+	header._saveName = saveName;
+	writeSavegameHeader(out, header);
+
+	Common::Serializer s(nullptr, out);
+	synchronize(s, true);
+	synchronize(s, false);
 
+	out->finalize();
+	delete out;
 }
 
 const char *const SAVEGAME_STR = "MADS";
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 8334d94..982f880 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -92,7 +92,7 @@ protected:
 	bool _anyEmergency;
 	int _loadGameSlot;
 	Common::String _saveName;
-	Common::Serializer *_serializer;
+	Common::InSaveFile *_saveFile;
 
 	/**
 	 * Constructor
diff --git a/engines/mads/game_data.cpp b/engines/mads/game_data.cpp
index 0f41692..9211bbf 100644
--- a/engines/mads/game_data.cpp
+++ b/engines/mads/game_data.cpp
@@ -46,4 +46,23 @@ bool VisitedScenes::exists(int sceneId) {
 	return false;
 }
 
+void VisitedScenes::synchronize(Common::Serializer &s) {
+	int count = size();
+	int v = 0;
+	s.syncAsUint16LE(count);
+
+	if (s.isSaving()) {
+		for (uint i = 0; i < size(); ++i) {
+			v = (*this)[i];
+			s.syncAsSint16LE(v);
+		}
+	} else {
+		clear();
+		for (uint i = 0; i < count; ++i) {
+			s.syncAsSint16LE(v);
+			push_back(v);
+		}
+	}
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/game_data.h b/engines/mads/game_data.h
index 8b31e52..1a8791e 100644
--- a/engines/mads/game_data.h
+++ b/engines/mads/game_data.h
@@ -47,6 +47,11 @@ public:
 	 * Adds a scene Id to the list of previously visited scenes, if it doesn't already exist
 	 */
 	void add(int sceneId);
+
+	/**
+	 * Synchronizes the list
+	 */
+	void synchronize(Common::Serializer &s);
 };
 
 class SectionHandler {
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 1df41ad..cb84f4d 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -138,4 +138,14 @@ Common::String MADSEngine::generateSaveName(int slot) {
 	return Common::String::format("%s.%03d", _targetName.c_str(), slot);
 }
 
+Common::Error MADSEngine::loadGameState(int slot) {
+	_game->loadGame(slot);
+	return Common::kNoError;
+}
+
+Common::Error MADSEngine::saveGameState(int slot, const Common::String &desc) {
+	_game->saveGame(slot, desc);
+	return Common::kNoError;
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index 8a4b7f6..9acd469 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -135,6 +135,16 @@ public:
 	* @param slot		Slot number
 	*/
 	Common::String generateSaveName(int slot);
+
+	/**
+	 * Handles loading a game via the GMM 
+	 */
+	virtual Common::Error loadGameState(int slot);
+
+	/**
+	 * Handles saving the game via the GMM
+	 */
+	virtual Common::Error saveGameState(int slot, const Common::String &desc);
 };
 
 } // End of namespace MADS


Commit: f9d26d7b4ff2627544ddb3faf11aea91fef9e2a5
    https://github.com/scummvm/scummvm/commit/f9d26d7b4ff2627544ddb3faf11aea91fef9e2a5
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-26T17:26:03+02:00

Commit Message:
MADS: Add Scene 352

Changed paths:
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index bc4c04d4..b812d43 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -3835,5 +3835,544 @@ void Scene351::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene352::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+
+	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(0x2F4);
+	_scene->addActiveVocab(0x2F5);
+	_scene->addActiveVocab(0x2F6);
+}
+
+void Scene352::putArmDown(bool corridorExit, bool doorwayExit) {
+	switch (_game._trigger) {
+	case 0:
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 60, _game.getQuote(0xFF));
+		_scene->_sequences.addTimer(48, 1);
+		break;
+
+	case 1:
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		if (_globals[kSexOfRex] == REX_FEMALE) {
+			_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 5, 2, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 5, 2); 
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+		} else {
+			_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 5, 2, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 6, 2); 
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+		}
+		break;
+
+	case 2: {
+		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 0);
+		int idx = _scene->_dynamicHotspots.add(0x3B6, 0xD, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(230, 117), FACING_NORTHWEST);
+		_scene->changeVariant(0); 
+		}
+		break;
+
+	case 3:
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x100));
+		_game._objects.setRoom(0x2F, _scene->_currentSceneId);
+		_game._player._visible = true;
+		if (corridorExit)
+			_scene->_sequences.addTimer(48, 6);
+		else if (doorwayExit) 
+			_scene->_sequences.addTimer(48, 4);
+		else {
+			_mustPutArmDownFl = false;
+			_game._player._stepEnabled = true;
+		} 
+		break;
+
+	case 4:
+		_game._player.walk(Common::Point(116, 107), FACING_NORTH);
+		_game._player._stepEnabled = true;
+		_mustPutArmDownFl = false;
+		_scene->_sequences.addTimer(180, 5);
+		_leaveRoomFl = true;
+		break;
+
+	case 5:
+		if (_leaveRoomFl)
+			_scene->_nextSceneId = 351;
+
+		break; 
+
+	case 6:
+		_game._player.walk(Common::Point(171, 152), FACING_SOUTH);
+		_game._player._stepEnabled = true;
+		_mustPutArmDownFl = false;
+		_scene->_sequences.addTimer(180, 7);
+		_leaveRoomFl = true;
+		break;
+
+	case 7:
+		if (_leaveRoomFl)
+			_scene->_nextSceneId = 353;
+
+		break; 
+
+	default:
+		break;
+	}
+}
+
+void Scene352::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites("*RM302x0");
+	_globals._spriteIndexes[13] = _scene->_sprites.addSprites("*RM302x2");
+	_globals._spriteIndexes[12] = _scene->_sprites.addSprites("*RM302x3");
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('g', -1));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('b', -1));
+
+
+	if (_globals[kSexOfRex] == REX_FEMALE) {
+		_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*ROXRC_7");
+		_globals._spriteIndexes[7] = _scene->_sprites.addSprites("*ROXRC_6");
+		_globals._spriteIndexes[15] = _scene->_sprites.addSprites("*ROXRC_9");
+		_globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('a', 3));
+		_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('a', 2));
+	} else {
+		_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXRD_7");
+		_globals._spriteIndexes[6] = _scene->_sprites.addSprites("*RXRC_6");
+		_globals._spriteIndexes[14] = _scene->_sprites.addSprites("*RXMRC_9");
+		_globals._spriteIndexes[10] = _scene->_sprites.addSprites(formAnimName('a', 1));
+		_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('a', 0));
+	}
+
+	_leaveRoomFl = false;
+
+	if (_game._objects.isInRoom(OBJ_TAPE_PLAYER)) {
+		_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 12, 0, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 5);
+		int idx = _scene->_dynamicHotspots.add(0x165, 0xD, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+		_tapePlayerHotspotIdx = _scene->_dynamicHotspots.setPosition(idx, Common::Point(84, 145), FACING_WEST);
+	}
+
+	_vaultOpenFl = false;
+
+	if (_scene->_priorSceneId != -2) {
+		_mustPutArmDownFl = false;
+		if (!_game._visitedScenes._sceneRevisited)
+			_globals[kHaveYourStuff] = false;
+	}
+
+	if (_game._objects.isInRoom(OBJ_GUARDS_ARM)) {
+		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 0);
+		int idx = _scene->_dynamicHotspots.add(0x3B6, 0xD, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(230, 117), FACING_NORTHWEST);
+	} else
+		_mustPutArmDownFl = true;
+
+	if (_scene->_priorSceneId == 353)
+		_game._player._playerPos = Common::Point(171, 155);
+	else if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(116, 107);
+
+	sceneEntrySound();
+
+	_game.loadQuoteSet(0xFF, 0x100, 0x101, 0x102, 0x103, 0);
+}
+
+void Scene352::preActions() {
+	_leaveRoomFl = false;
+
+	if (_action.isAction(VERB_OPEN, 0x1F8))
+		_game._player.walk(Common::Point(266, 111), FACING_NORTHEAST);
+
+	if (_vaultOpenFl && !_action.isAction(0x1F8) && !_action.isAction(0x2F6) && !_action.isAction(0x2F5) && !_action.isAction(0x2F4)) {
+		if (_globals[kHaveYourStuff]) {
+			_commonSpriteIndex = _globals._spriteIndexes[13];
+			_commonSequenceIdx = _globals._sequenceIndexes[13];
+		} else {
+			_commonSpriteIndex = _globals._spriteIndexes[1];
+			_commonSequenceIdx = _globals._sequenceIndexes[1];
+		}
+
+		switch (_game._trigger) {
+		case 0:
+			if (_game._player._needToWalk) {
+				_game._player._stepEnabled = false;
+				_scene->_sequences.remove(_commonSequenceIdx);
+				_vm->_sound->command(20);
+				_commonSequenceIdx = _scene->_sequences.startReverseCycle(_commonSpriteIndex, false, 6, 1, 0, 0);
+				_scene->_sequences.addSubEntry(_commonSequenceIdx, SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+				_scene->_sequences.setDepth(_commonSequenceIdx, 15);
+			}
+			break;
+
+		case 1:
+			if (!_globals[kHaveYourStuff])
+				_scene->_dynamicHotspots.remove(_hotspot2Idx);
+
+			_scene->_dynamicHotspots.remove(_hotspot1Idx);
+			_scene->_dynamicHotspots.remove(_lampHostpotIdx);
+			_vaultOpenFl = false;
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+	}
+
+	if (_action.isAction(VERB_PUT, 0x3B6, 0x1F3)) {
+		if (_globals[kSexOfRex] == REX_MALE)
+			_game._player.walk(Common::Point(269, 111), FACING_NORTHEAST); 
+		else
+			_game._player.walk(Common::Point(271, 111), FACING_NORTHEAST); 
+	}
+
+	if (_action.isAction(0x18B, 0x70) || _action.isAction(0x1AD, 0x2B3) || _action.isAction(VERB_PUT, 0x3B6, 0x89)) {
+		if (_game._objects.isInInventory(OBJ_GUARDS_ARM))
+			_game._player.walk(Common::Point(230, 117), FACING_NORTHWEST);
+	}
+}
+
+void Scene352::actions() {
+	if (_action._lookFlag) {
+		_vm->_dialogs->show(0x8999);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_OPEN, 0x1F8)) { 
+		if (!_vaultOpenFl) { 
+			switch (_game._trigger) {
+			case 0:
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				if (_globals[kSexOfRex] == REX_FEMALE)
+					_commonSpriteIndex = _globals._spriteIndexes[9];
+				else
+					_commonSpriteIndex = _globals._spriteIndexes[8];
+
+				_commonSequenceIdx = _scene->_sequences.addSpriteCycle(_commonSpriteIndex, false, 8, 1, 0, 0);
+				_scene->_sequences.updateTimeout(_commonSequenceIdx, -1);
+				_scene->_sequences.addSubEntry(_commonSequenceIdx, SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+				break;
+
+			case 1: {
+				_vm->_sound->command(21);
+				_globals._sequenceIndexes[12] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[12], false, 7, 2, 20, 0);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[12], FACING_NORTH); 
+				int oldIdx = _commonSequenceIdx;
+				_commonSequenceIdx = _scene->_sequences.startCycle(_commonSpriteIndex, false, -2); 
+				_scene->_sequences.updateTimeout(_commonSequenceIdx, oldIdx);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				}
+				break;
+
+			case 2:
+				_vm->_sound->command(22);
+				_scene->_sequences.remove(_commonSequenceIdx);
+				_commonSequenceIdx = _scene->_sequences.startReverseCycle(_commonSpriteIndex, false, 8, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_commonSequenceIdx, 1, 3);
+				_scene->_sequences.addSubEntry(_commonSequenceIdx, SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+				break;
+
+			case 3:
+				_scene->_sequences.updateTimeout(-1, _commonSequenceIdx);
+				_game._player._visible = true;
+				_scene->_sequences.addTimer(60, 4);
+				break;
+
+			case 4:
+				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x101));
+				_game._player._stepEnabled = true;
+				break;
+			}
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_game._objects.isInInventory(OBJ_GUARDS_ARM)) {
+		_mustPutArmDownFl = true;
+	}
+
+	bool exit_corridor = false;
+	bool exit_doorway = false;
+
+	if (_action.isAction(0x1AD, 0x2B3)) {
+		exit_corridor = true;
+	}
+
+	if (_action.isAction(0x18B, 0x70)) {
+		exit_doorway = true;
+	}
+
+	if (_action.isAction(0x1AD, 0x2B3) || _action.isAction(0x18B, 0x70) || _action.isAction(VERB_PUT, 0x3B6, 0x89)) {
+		if (_mustPutArmDownFl)
+			putArmDown(exit_corridor, exit_doorway); 
+		else if (exit_corridor)
+			_scene->_nextSceneId = 353;
+		else 
+			_scene->_nextSceneId = 351;
+
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_TAKE, 0x3B6)) {
+		if (_game._trigger || !_game._objects.isInInventory(OBJ_GUARDS_ARM)) {
+			switch (_game._trigger) {
+			case 0:
+				_game._player._stepEnabled = false;
+				_game._player._visible = false; 
+				if (_globals[kSexOfRex] == REX_FEMALE) {
+					_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 5, 2, 0, 0);
+					_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 5, 1);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				} else {
+					_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 5, 2, 0, 0);
+					_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 6, 1);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				} 
+				break;
+
+			case 1:
+				_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+				_game._objects.addToInventory(0x2F);
+				_scene->changeVariant(1); 
+				break;
+
+			case 2:
+				_game._player._visible = true;
+				_game._player._stepEnabled = true;
+				_vm->_dialogs->showItem(0x2F, 0x899C);
+				break;
+			}
+			_action._inProgress = false;
+			return;
+		}
+	}
+
+	if (_action.isAction(VERB_PUT, 0x3B6, 0x1F3)) {
+		if (!_vaultOpenFl) { 
+			switch (_game._trigger) {
+			case 0:
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				if (_globals[kSexOfRex] == REX_FEMALE)
+					_commonSpriteIndex = _globals._spriteIndexes[11];
+				else
+					_commonSpriteIndex = _globals._spriteIndexes[10];
+
+				_commonSequenceIdx = _scene->_sequences.addSpriteCycle(_commonSpriteIndex, false, 8, 1, 0, 0);
+				_scene->_sequences.updateTimeout(_commonSequenceIdx, -1);
+				_scene->_sequences.addSubEntry(_commonSequenceIdx, SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+				break;
+
+			case 1: {
+				_vm->_sound->command(21);
+				_globals._sequenceIndexes[12] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[12], false, 7, 2, 20, 0);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[12], 8); 
+				int oldIdx = _commonSequenceIdx;
+				_commonSequenceIdx = _scene->_sequences.startCycle(_commonSpriteIndex, false, -2); 
+				_scene->_sequences.updateTimeout(_commonSequenceIdx, oldIdx);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				}
+				break;
+
+			case 2:
+				_vm->_sound->command(23);
+				_scene->_sequences.remove(_commonSequenceIdx);
+				_commonSequenceIdx = _scene->_sequences.startReverseCycle(_commonSpriteIndex, false, 8, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_commonSequenceIdx, 1, 4);
+				_scene->_sequences.addSubEntry(_commonSequenceIdx, SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+				break;
+
+
+			case 3:
+				_scene->_sequences.updateTimeout(-1, _commonSequenceIdx);
+				_game._player._visible = true;
+				if (_globals[kHaveYourStuff])
+					_commonSpriteIndex = _globals._spriteIndexes[13];
+				else
+					_commonSpriteIndex = _globals._spriteIndexes[1];
+
+				_vm->_sound->command(20);
+				_commonSequenceIdx = _scene->_sequences.addSpriteCycle(_commonSpriteIndex, false, 6, 1, 0, 0);
+				_scene->_sequences.setDepth(_commonSequenceIdx, 15);
+				_scene->_sequences.addSubEntry(_commonSequenceIdx, SEQUENCE_TRIGGER_EXPIRE, 0, 4);
+				break;
+
+			case 4:
+				_commonSequenceIdx = _scene->_sequences.addSpriteCycle(_commonSpriteIndex, false, 6, 0, 0, 0);
+				_scene->_sequences.setAnimRange(_commonSequenceIdx, -2, -2);
+				_scene->_sequences.setDepth(_commonSequenceIdx, 15);
+				_scene->_sequences.addTimer(60, 5);
+				break;
+
+			case 5: {
+				_vaultOpenFl = true;
+				int idx;
+				if (!_globals[kHaveYourStuff]) {
+					idx = _scene->_dynamicHotspots.add(0x2F4, 0xD, -1, Common::Rect(282, 87, 282 + 13, 87 + 7));
+					_hotspot2Idx = _scene->_dynamicHotspots.setPosition(idx, Common::Point(280, 111), FACING_NORTHEAST);
+					_globals._sequenceIndexes[1] = _commonSequenceIdx;
+					_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x102));
+				} else {
+					_globals._sequenceIndexes[13] = _commonSequenceIdx; 
+					_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x103));
+				}
+
+				idx = _scene->_dynamicHotspots.add(0x2F5, 0xD, -1, Common::Rect(282, 48, 282 + 36, 48 + 27));
+				_hotspot1Idx = _scene->_dynamicHotspots.setPosition(idx, Common::Point(287, 115), FACING_NORTHEAST);
+				idx = _scene->_dynamicHotspots.add(0x2F6, 0xD, -1, Common::Rect(296, 76, 296 + 11, 76 + 17));
+				_lampHostpotIdx = _scene->_dynamicHotspots.setPosition(idx, Common::Point(287, 115), FACING_NORTHEAST);
+				_game._player._stepEnabled = true;
+				}
+				break;
+			}
+		}
+	} else if (_action.isAction(VERB_TAKE, 0x2F4)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_game._player._visible = false; 
+			if (_globals[kSexOfRex] == REX_MALE) {
+				_globals._sequenceIndexes[14] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[14], false, 8, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[14], 1, 2);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[14]);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[14], SEQUENCE_TRIGGER_SPRITE, 2, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[14], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			} else {
+				_globals._sequenceIndexes[15] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[15], false, 8, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[15], 1, 2);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[15]);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[15], SEQUENCE_TRIGGER_SPRITE, 2, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[15], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			} 
+			break;
+
+		case 1:
+			_scene->_dynamicHotspots.remove(_hotspot2Idx);
+			_globals[kHaveYourStuff] = true;
+
+			for (uint16 i = 0; i < _game._objects.size(); i++) {
+				if (_game._objects[i]._roomNumber == 50)
+					_game._objects.addToInventory(i);
+			}
+
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_globals._sequenceIndexes[13] = _scene->_sequences.startCycle(_globals._spriteIndexes[13], false, -2); 
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 15); 
+			break;
+
+		case 2:
+			if (_globals[kSexOfRex] == REX_MALE)
+				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[14]);
+			else
+				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[15]);
+
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(VERB_TAKE, 0x165) && !_game._objects.isInInventory(OBJ_TAPE_PLAYER)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_game._player._visible = false; 
+			if (_globals[kSexOfRex] == REX_MALE) {
+				_globals._sequenceIndexes[6] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[6], true, 6, 2, 0, 0);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[6]);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_SPRITE, 6, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			} else {
+				_globals._sequenceIndexes[7] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[7], true, 6, 2, 0, 0);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[7]);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_SPRITE, 6, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			} 
+			break;
+
+		case 1:
+			_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+			_scene->_dynamicHotspots.remove(_tapePlayerHotspotIdx);
+			break;
+
+		case 2:
+			_game._objects.addToInventory(OBJ_TAPE_PLAYER); 
+			if (_globals[kSexOfRex] == REX_MALE)
+				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[6]);
+			else
+				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[7]);
+
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			_vm->_dialogs->showItem(OBJ_TAPE_PLAYER, 0x899B);
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x1F3))
+		_vm->_dialogs->show(0x898A);
+	else if (_action.isAction(VERB_LOOK, 0xE2)) {
+		if (_game._storyMode == STORYMODE_NAUGHTY)
+			_vm->_dialogs->show(0x898B);
+		else
+			_vm->_dialogs->show(0x898C);
+	} else if (_action.isAction(VERB_LOOK, 0x1CC))
+		_vm->_dialogs->show(0x898D);
+	else if (_action.isAction(VERB_LOOK, 0x2CD))
+		_vm->_dialogs->show(0x898E);
+	else if (_action.isAction(VERB_LOOK, 0x165) && (_action._savedFields._mainObjectSource == 4))
+		_vm->_dialogs->show(0x898F);
+	else if (_action.isAction(VERB_LOOK, 0x11))
+		_vm->_dialogs->show(0x8990);
+	else if (_action.isAction(VERB_LOOK, 0x3B6) && (_action._savedFields._mainObjectSource == 4))
+		_vm->_dialogs->show(0x8991);
+	else if (_action.isAction(VERB_LOOK, 0x2DA))
+		_vm->_dialogs->show(0x8992);
+	else if (_action.isAction(VERB_LOOK, 0x51))
+		_vm->_dialogs->show(0x8993);
+	else if (_action.isAction(VERB_LOOK, 0x2CE))
+		_vm->_dialogs->show(0x8994);
+	else if (_action.isAction(VERB_LOOK, 0x1F8)) {
+		if (!_vaultOpenFl)
+			_vm->_dialogs->show(0x8995);
+	} else if (_action.isAction(VERB_LOOK, 0x2F4))
+		_vm->_dialogs->show(0x8996);
+	else if (_action.isAction(VERB_LOOK, 0x2F5))
+		_vm->_dialogs->show(0x8997);
+	else if (_action.isAction(VERB_LOOK, 0x2B3))
+		_vm->_dialogs->show(0x8998);
+	else if (_action.isAction(VERB_TAKE, 0x2F5))
+		_vm->_dialogs->show(0x899A);
+	else if (_action.isAction(VERB_LOOK, 0x1E4))
+		_vm->_dialogs->show(0x899D);
+	else if (_action.isAction(VERB_LOOK, 0x239))
+		_vm->_dialogs->show(0x899E);
+	else if (_action.isAction(VERB_LOOK, 0x70))
+		_vm->_dialogs->show(0x899F);
+	else if (_action.isAction(VERB_LOOK, 0x160))
+		_vm->_dialogs->show(0x89A0);
+	else if (_action.isAction(VERB_LOOK, 0x3B5))
+		_vm->_dialogs->show(0x89A1);
+	else if (_action.isAction(VERB_LOOK, 0x257))
+		_vm->_dialogs->show(0x89A2);
+	else if (_action.isAction(VERB_LOOK, 0x1F5))
+		_vm->_dialogs->show(0x89A3);
+	else
+		return;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 5be10ac..1834ffe 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -360,6 +360,33 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene352: public Scene3xx {
+private:
+	bool _vaultOpenFl;
+	bool _mustPutArmDownFl;
+	bool _leaveRoomFl;
+
+	int _tapePlayerHotspotIdx;
+	int _hotspot1Idx;
+	int _hotspot2Idx;
+	int _lampHostpotIdx;
+	int _commonSequenceIdx;
+	int _commonSpriteIndex;
+
+	void putArmDown(bool corridorExit, bool doorwayExit);
+
+public:
+	Scene352(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 1e024f42605effeb6928ff5c0f5177a6ff9edcb3
    https://github.com/scummvm/scummvm/commit/1e024f42605effeb6928ff5c0f5177a6ff9edcb3
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-27T00:05:26+02:00

Commit Message:
MADS: Implement scene 353

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index df2433d..21c3e9c 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -134,6 +134,11 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 
 	case 351:
 		return new Scene351(vm);
+	case 352:
+		return new Scene352(vm);
+	case 353:
+		return new Scene353(vm);
+
 	// Scene group #8
 	case 804:
 		return new Scene804(vm);
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index b812d43..22b3c71 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -4374,5 +4374,52 @@ void Scene352::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene353::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene353::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(Resources::formatName(303, 'B', 0, EXT_SS, ""));
+	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 0, 5, 0);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1); 
+
+	if (_scene->_priorSceneId == 352)
+		_game._player._playerPos = Common::Point(144, 95);
+	else
+		_game._player._playerPos = Common::Point(139, 155);
+
+	sceneEntrySound();
+}
+
+void Scene353::actions() {
+	if (_action._lookFlag)
+		_vm->_dialogs->show(0x89F3);
+	else if (_action.isAction(0x18B, 0x70))
+		_scene->_nextSceneId = 352;
+	else if (_action.isAction(0x1AD, 0x2B3))
+		_scene->_nextSceneId = 354;
+	else if (_action.isAction(VERB_LOOK, 0x23D))
+		_vm->_dialogs->show(0x89EE);
+	else if (_action.isAction(VERB_LOOK, 0x1FA) || _action.isAction(VERB_LOOK, 0x10C))
+		_vm->_dialogs->show(0x89EF);
+	else if (_action.isAction(VERB_LOOK, 0x23C))
+		_vm->_dialogs->show(0x89F0);
+	else if (_action.isAction(VERB_LOOK, 0x70))
+		_vm->_dialogs->show(0x89F1);
+	else if (_action.isAction(VERB_LOOK, 0x2B3))
+		_vm->_dialogs->show(0x89F2);
+	else if (_action.isAction(VERB_LOOK, 0x89))
+		_vm->_dialogs->show(0x89F4);
+	else if (_action.isAction(VERB_LOOK, 0x46))
+		_vm->_dialogs->show(0x89F5);
+	else if (_action.isAction(VERB_LOOK, 0x18D))
+		_vm->_dialogs->show(0x89F6);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 1834ffe..20cd1c3 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -387,6 +387,18 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene353: public Scene3xx {
+public:
+	Scene353(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 6405d96ae487d0a29e6f641eaa4fdb55570586d9
    https://github.com/scummvm/scummvm/commit/6405d96ae487d0a29e6f641eaa4fdb55570586d9
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-27T00:46:37+02:00

Commit Message:
MADS: Implement scene 354

Changed paths:
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 22b3c71..41777b1 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -4421,5 +4421,74 @@ void Scene353::actions() {
 	_action._inProgress = false;
 }
 
+/*------------------------------------------------------------------------*/
+
+void Scene354::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene354::enter() {
+	_globals[kAfterHavoc] = true;
+	_globals[kTeleporterRoom + 1] = 351;
+
+	if (_scene->_priorSceneId == 361)
+		_game._player._playerPos = Common::Point(231, 110);
+	else if (_scene->_priorSceneId == 401) {
+		_game._player._playerPos = Common::Point(106, 152);
+		_game._player._facing = FACING_NORTH;
+	} else if (_scene->_priorSceneId == 316)
+		_game._player._playerPos = Common::Point(71, 107);
+	else if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(167, 57);
+
+	sceneEntrySound();
+}
+
+void Scene354::preActions() {
+	if (_action.isAction(0x1AD, 0x2B3))
+		_game._player._walkOffScreenSceneId = 401;
+}
+
+void Scene354::actions() {
+	if (_action._lookFlag)
+		_vm->_dialogs->show(0x8A56);
+	else if (_action.isAction(0x1AD, 0x2B4)) {
+		_game._player.startWalking(Common::Point(208, 0), FACING_NORTHEAST);
+		_game._player._walkOffScreenSceneId = 353;
+	} else if (_action.isAction(0x1AD, 0x2B9))
+		_scene->_nextSceneId = 361;
+	else if (_action.isAction(0x1AD, 0x2BA))
+		_scene->_nextSceneId = 316;
+	else if (_action.isAction(0x1AD, 0x2B3))
+		_scene->_nextSceneId = 401;
+	else if (_action.isAction(VERB_LOOK, 0x2C6))
+		_vm->_dialogs->show(0x8A52);
+	else if (_action.isAction(VERB_LOOK, 0x1FD))
+		_vm->_dialogs->show(0x8A53);
+	else if (_action.isAction(VERB_LOOK, 0x2D0))
+		_vm->_dialogs->show(0x8A54);
+	else if (_action.isAction(VERB_LOOK, 0x206))
+		_vm->_dialogs->show(0x8A55);
+	else if (_action.isAction(VERB_LOOK, 0x2B4))
+		_vm->_dialogs->show(0x8A57);
+	else if (_action.isAction(VERB_LOOK, 0x2B3))
+		_vm->_dialogs->show(0x8A58);
+	else if (_action.isAction(VERB_LOOK, 0x2B9))
+		_vm->_dialogs->show(0x8A59);
+	else if (_action.isAction(VERB_LOOK, 0x2BA))
+		_vm->_dialogs->show(0x8A5A);
+	else if (_action.isAction(VERB_LOOK, 0x218))
+		_vm->_dialogs->show(0x8A5B);
+	else if (_action.isAction(VERB_LOOK, 0x239))
+		_vm->_dialogs->show(0x8A5C);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 20cd1c3..8950fa5 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -399,6 +399,18 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene354: public Scene3xx {
+public:
+	Scene354(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 2cff7557fe57581c578b8eb17e099597ee33cbc1
    https://github.com/scummvm/scummvm/commit/2cff7557fe57581c578b8eb17e099597ee33cbc1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-26T22:35:28-04:00

Commit Message:
MADS: Beginnings of full screen dialogs

Changed paths:
    engines/mads/game.cpp
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/dialogs_nebular.h



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 9a5ec12..d9d1fea 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -423,6 +423,20 @@ void Game::handleKeypress(const Common::Event &event) {
 		}
 	}
 
+	switch (event.kbd.keycode) {
+	case Common::KEYCODE_F1:
+		_vm->_dialogs->_pendingDialog = DIALOG_GAME_MENU;
+		break;
+	case Common::KEYCODE_F5:
+		_vm->_dialogs->_pendingDialog = DIALOG_SAVE;
+		break;
+	case Common::KEYCODE_F7:
+		_vm->_dialogs->_pendingDialog = DIALOG_RESTORE;
+		break;
+	default:
+		break;
+	}
+
 	warning("TODO: handleKeypress - %d", (int)event.kbd.keycode);
 }
 
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 3606830..98e05ad 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -320,6 +320,246 @@ bool DialogsNebular::commandCheck(const char *idStr, Common::String &valStr,
 	return true;
 }
 
+void DialogsNebular::showDialog() {
+	switch (_pendingDialog) {
+	case DIALOG_GAME_MENU:
+		//GameMenuDialog::show();
+		break;
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+ScreenDialog::DialogLine::DialogLine() {
+	_state = 0;
+	_textDisplayIndex = -1;
+	_font = nullptr;
+	_widthAdjust = 0;
+}
+
+ScreenDialog::DialogLine::DialogLine(const Common::String &s) {
+	_state = 0;
+	_textDisplayIndex = -1;
+	_font = nullptr;
+	_widthAdjust = -1;
+	_msg = s;
+}
+
+/*------------------------------------------------------------------------*/
+
+ScreenDialog::ScreenDialog(MADSEngine *vm) : _vm(vm), 
+		_savedSurface(MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT) {
+	Game &game = *_vm->_game;
+	Scene &scene = game._scene;
+
+	_v1 = 0;
+	_selectedLine = 0;
+	_dirFlag = false;
+	_textLineCount = 0;
+
+	game.loadQuoteSet(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+		17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
+		34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 0);
+	game._kernelMode = KERNEL_ROOM_PRELOAD;
+	_vm->_events->waitCursor();
+	scene.clearVocab();
+	scene._dynamicHotspots.clear();
+	_vm->_dialogs->_defaultPosition = Common::Point(-1, -1);
+
+	bool palFlag = false;
+	int nextSceneId = scene._nextSceneId;
+	int currentSceneId = scene._currentSceneId;
+	int priorSceneId = scene._priorSceneId;
+
+	if (_vm->_dialogs->_pendingDialog == DIALOG_DIFFICULTY) {
+		palFlag = true;
+	} else {
+		_vm->_palette->initPalette();
+	}
+	scene.loadScene(_screenId, game._aaName, palFlag);
+
+	scene._priorSceneId = priorSceneId;
+	scene._currentSceneId = currentSceneId;
+	scene._nextSceneId = nextSceneId;
+	_vm->_screen._offset.y = 22;
+	_vm->_sound->pauseNewCommands();
+	_vm->_events->initVars();
+	game._kernelMode = KERNEL_ROOM_INIT;
+
+	SpriteAsset *menuSprites = new SpriteAsset(_vm, "*MENU", 0);
+	_menuSpritesIndex = scene._sprites.add(menuSprites);
+
+	byte pal[768];
+	if (_vm->_screenFade) {
+		Common::fill(&pal[0], &pal[PALETTE_SIZE], 0);
+		_vm->_palette->setFullPalette(pal);
+	} else {
+		_vm->_palette->getFullPalette(pal);
+		_vm->_palette->fadeOut(pal, 0, PALETTE_COUNT, 16, 1, 1, 0, 0, 0);
+	}
+
+	_vm->_screen.copyTo(&_savedSurface);
+	/*
+	_vm->_screen.hLine(0, 0, MADS_SCREEN_WIDTH, 2);
+	_vm->_screen.copyRectToScreen(Common::Rect(0, _vm->_screen._offset.y,
+		MADS_SCREEN_WIDTH, _vm->_screen._offset.y + 1));
+	_vm->_screen.copyRectToScreen(Common::Rect(0, _vm->_screen._offset.y + 157,
+		MADS_SCREEN_WIDTH, _vm->_screen._offset.y + 157));
+	*/
+
+	game._fx = _vm->_screenFade == SCREEN_FADE_SMOOTH ? 
+		kCenterVertTransition : kTransitionFadeIn;
+	game._trigger = 0;
+	_vm->_events->setCursor(CURSOR_ARROW);
+
+	_vm->_palette->setEntry(10, 0, 63, 0);
+	_vm->_palette->setEntry(11, 0, 45, 0);
+	_vm->_palette->setEntry(12, 63, 63, 0);
+	_vm->_palette->setEntry(13, 45, 45, 0);
+	_vm->_palette->setEntry(14, 63, 63, 63);
+	_vm->_palette->setEntry(15, 45, 45, 45);
+}
+
+void ScreenDialog::clearLines() {
+	Scene &scene = _vm->_game->_scene;
+	_lines.clear();
+	scene._spriteSlots.fullRefresh(true);
+}
+
+void ScreenDialog::addQuote(int id1, int id2, DialogTextAlign align,
+		const Common::Point &pt, Font *font) {
+	Common::String msg = _vm->_game->getQuote(id1);
+
+	if (id2 > 0) {
+		msg += " ";
+		msg += _vm->_game->getQuote(id2);
+	}
+
+	addLine(msg, align, pt, font);
+}
+
+void ScreenDialog::addLine(const Common::String &msg, DialogTextAlign align,
+		const Common::Point &pt, Font *font) {
+	Scene &scene = _vm->_game->_scene;
+	DialogLine *line;
+
+	if (_lineIndex < (int)_lines.size()) {
+		if (_lines.size() >= 20)
+			goto finish;
+
+		_lines.push_back(msg);
+		line = &_lines[_lines.size() - 1];
+	} else {
+		line = &_lines[_lineIndex];
+		if (msg.compareToIgnoreCase(msg))
+			goto finish;
+
+		if (line->_textDisplayIndex >= 0) {
+			TextDisplay &textDisplay = scene._textDisplay[line->_textDisplayIndex];
+			if (textDisplay._active) {
+				textDisplay._expire = -1;
+				if (_textLineCount < 20) {
+					textDisplay._msg = msg;
+					++_textLineCount;
+				}
+			}
+		}
+	}
+
+	line->_font = font;
+	line->_state = 0;
+	line->_pos = pt;
+	line->_widthAdjust = -1;
+	line->_textDisplayIndex = -1;
+
+	int xOffset;
+	switch (align) {
+	case ALIGN_CENTER:
+		xOffset = (MADS_SCREEN_WIDTH / 2) - font->getWidth(msg, -1) / 2;
+		line->_pos.x += xOffset;
+		break;
+
+	case ALIGN_AT_CENTER: {
+		const char *msgP = msg.c_str();
+		const char *ch = strchr(msgP, '@');
+		if (ch) {
+			xOffset = (MADS_SCREEN_WIDTH / 2) - font->getWidth(
+				Common::String(msgP, ch), line->_widthAdjust);
+			line->_pos.x += xOffset;
+		}
+		break;
+	}
+
+	case ALIGN_RIGHT:
+		xOffset = font->getWidth(msg, -1);
+		line->_pos.x -= xOffset;
+		break;
+
+	default:
+		break;
+	}
+
+finish:
+	++_lineIndex;
+}
+
+
+void ScreenDialog::initVars() {
+	_v1 = -1;
+	_selectedLine = -1;
+	_lineIndex = 0;
+	_enterFlag = false;
+	_textLineCount = 0;
+}
+
+void ScreenDialog::chooseBackground() {
+	switch (_vm->_game->_currentSectionNumber) {
+	case 1:
+	case 2:
+		_screenId = 921;
+		break;
+	case 3:
+	case 4:
+		_screenId = 922;
+		break;
+	case 5:
+	case 6:
+	case 7:
+		_screenId = 923;
+		break;
+	case 8:
+		_screenId = 924;
+		break;
+	default:
+		_screenId = 920;
+		break;
+	}
+}
+
+void ScreenDialog::setFrame(int frameNumber, int depth) {
+	Scene &scene = _vm->_game->_scene;
+	SpriteSlot &spriteSlot = scene._spriteSlots[scene._spriteSlots.add()];
+	spriteSlot._flags = IMG_UPDATE;
+	spriteSlot._seqIndex = 1;
+	spriteSlot._spritesIndex = _menuSpritesIndex;
+	spriteSlot._frameNumber = frameNumber;
+
+}
+
+/*------------------------------------------------------------------------*/
+
+GameMenuDialog::GameMenuDialog(MADSEngine *vm) : ScreenDialog(vm) {
+	clearLines();
+	setFrame(1, 2);
+}
+
+void GameMenuDialog::addLines() {
+	initVars();
+	Font *font = _vm->_font->getFont(FONT_CONVERSATION);
+	int top = 78 - (font->getHeight() + 2) * 12;
+	addQuote(10, 0, ALIGN_CENTER, Common::Point(0, top),  font);
+	// TODO
+}
 
 } // End of namespace Nebular
 
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index 041deda..b5ee090 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -47,9 +47,7 @@ private:
 
 	bool commandCheck(const char *idStr, Common::String &valStr, const Common::String &command);
 public:
-	virtual void showDialog() {
-		warning("TODO: showDialog");
-	}
+	virtual void showDialog();
 
 	virtual void showItem(int objectId, int msgId, int arg);
 
@@ -84,6 +82,80 @@ public:
 	bool show();
 };
 
+enum DialogTextAlign { ALIGN_CENTER = -1, ALIGN_AT_CENTER = -2, ALIGN_RIGHT = -3 };
+
+class ScreenDialog {
+	struct DialogLine {
+		int _state;
+		Common::Point _pos;
+		int _textDisplayIndex;
+		Common::String _msg;
+		Font *_font;
+		int _widthAdjust;
+
+		DialogLine();
+		DialogLine(const Common::String &s);
+	};
+protected:
+	MADSEngine *_vm;
+	MSurface _savedSurface;
+	Common::Array<DialogLine> _lines;
+	int _v1;
+	int _selectedLine;
+	bool _dirFlag;
+	int _screenId;
+	int _menuSpritesIndex;
+	int _lineIndex;
+	bool _enterFlag;
+	int _textLineCount;
+
+	/**
+	 * Reset the lines list for the dialog
+	 */
+	void clearLines();
+
+	/**
+	 * Add a quote to the lines list
+	 */
+	void addQuote(int id1, int id2, DialogTextAlign align, const Common::Point &pt, Font *font);
+
+	/**
+	 * Adds a line to the lines list
+	 */
+	void addLine(const Common::String &msg, DialogTextAlign align, const Common::Point &pt, Font *font);
+
+	/**
+	 * Initializes variables
+	 */
+	void initVars();
+
+	/**
+	 * Sets the display for the screen background behind the dialog
+	 */
+	void setFrame(int frameNumber, int depth);
+
+	/**
+	 * Choose the background to display for the dialog
+	 */
+	void chooseBackground();
+public:
+	/**
+	 * Constructor
+	 */
+	ScreenDialog(MADSEngine *vm);
+};
+
+class GameMenuDialog : public ScreenDialog {
+private:
+	/**
+	 * Add the lines for the Game Menu dialog
+	 */
+	void addLines();
+public:
+	GameMenuDialog(MADSEngine *vm);
+
+};
+
 } // End of namespace Nebular
 
 } // End of namespace MADS


Commit: da1b4c8316d0b960b6e44553a965e863c6ba2345
    https://github.com/scummvm/scummvm/commit/da1b4c8316d0b960b6e44553a965e863c6ba2345
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-27T10:28:28+02:00

Commit Message:
MADS: Implement scene 357

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 21c3e9c..00b49d0 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -138,6 +138,10 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene352(vm);
 	case 353:
 		return new Scene353(vm);
+	case 354:
+		return new Scene354(vm);
+	case 357:
+		return new Scene357(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 41777b1..e7f1dda 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -4490,5 +4490,72 @@ void Scene354::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene357::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene357::enter() {
+	_globals[kAfterHavoc] = true;
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(Resources::formatName(307, 'X', 0, EXT_SS, ""));
+	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(127, 78));
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
+
+	if (_scene->_priorSceneId == 318)
+		_game._player._playerPos = Common::Point(298, 142); 
+	else if (_scene->_priorSceneId == 313)
+		_game._player._playerPos = Common::Point(127, 101);
+	else if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(15, 148);
+
+	sceneEntrySound();
+}
+
+void Scene357::preActions() {
+	if (_action.isAction(0x1AD, 0x2B9))
+		_game._player._walkOffScreenSceneId = 318;
+
+	if (_action.isAction(0x1AD, 0x2BA))
+		_game._player._walkOffScreenSceneId = 358;
+}
+
+void Scene357::actions() {
+	if (_action._lookFlag)
+		_vm->_dialogs->show(0x8B83);
+	else if (_action.isAction(VERB_LOOK, 0x11))
+		_vm->_dialogs->show(0x8B7E);
+	else if (_action.isAction(0x2F7, 0x11))
+		_vm->_dialogs->show(0x8B7F);
+	else if (_action.isAction(VERB_LOOK, 0x1CB))
+		_vm->_dialogs->show(0x8B80);
+	else if (_action.isAction(VERB_LOOK, 0x216))
+		_vm->_dialogs->show(0x8B81);
+	else if (_action.isAction(VERB_LOOK, 0x21B))
+		_vm->_dialogs->show(0x8B82);
+	else if (_action.isAction(VERB_LOOK, 0x207))
+		_vm->_dialogs->show(0x8B84);
+	else if (_action.isAction(VERB_LOOK, 0xCD))
+		_vm->_dialogs->show(0x8B85);
+	else if (_action.isAction(VERB_LOOK, 0x23A))
+		_vm->_dialogs->show(0x8B86);
+	else if (_action.isAction(VERB_LOOK, 0x218))
+		_vm->_dialogs->show(0x8B87);
+	else if (_action.isAction(VERB_TAKE, 0x218))
+		_vm->_dialogs->show(0x8B88);
+	else if (_action.isAction(VERB_LOOK, 0x18D))
+		_vm->_dialogs->show(0x8B89);
+	else if (_action.isAction(VERB_LOOK, 0x2B9))
+		_vm->_dialogs->show(0x8B8A);
+	else if (_action.isAction(VERB_LOOK, 0x2BA))
+		_vm->_dialogs->show(0x8B8B);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 8950fa5..e27806b 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -411,6 +411,17 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene357: public Scene3xx {
+public:
+	Scene357(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: bf106aeb6a18dc019c7775f48338346c527f16aa
    https://github.com/scummvm/scummvm/commit/bf106aeb6a18dc019c7775f48338346c527f16aa
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-27T10:47:58+02:00

Commit Message:
MADS: Implement scene 358

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 00b49d0..46a5e89 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -142,6 +142,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene354(vm);
 	case 357:
 		return new Scene357(vm);
+	case 358:
+		return new Scene358(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index e7f1dda..647ea67 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -4557,5 +4557,57 @@ void Scene357::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene358::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene358::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(Resources::formatName(307, 'X', 0, EXT_SS, ""));
+	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(127, 78));
+	_scene->_sequences.setDepth (_globals._sequenceIndexes[1], 15);
+
+	if (_scene->_priorSceneId == 357)
+		_game._player._playerPos = Common::Point(305, 142);
+	else if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(12, 141);
+
+	sceneEntrySound();
+}
+
+void Scene358::preActions() {
+	if (_action.isAction(0x1AD, 0x2B9))
+		_game._player._walkOffScreenSceneId = 357;
+
+	if (_action.isAction(0x1AD, 0x2BA))
+		_game._player._walkOffScreenSceneId = 359;
+}
+
+void Scene358::actions() {
+	if (_action._lookFlag)
+		_vm->_dialogs->show(0x8BE7);
+	else if (_action.isAction(VERB_LOOK, 0x2BA))
+		_vm->_dialogs->show(0x8BE2);
+	else if (_action.isAction(VERB_LOOK, 0x2B9))
+		_vm->_dialogs->show(0x8BE3);
+	else if (_action.isAction(VERB_LOOK, 0x1CB))
+		_vm->_dialogs->show(0x8BE4);
+	else if (_action.isAction(VERB_LOOK, 0x216))
+		_vm->_dialogs->show(0x8BE5);
+	else if (_action.isAction(VERB_LOOK, 0x21B))
+		_vm->_dialogs->show(0x8BE6);
+	else if (_action.isAction(VERB_LOOK, 0x204) || _action.isAction(VERB_LOOK, 0x18D))
+		_vm->_dialogs->show(0x8BE8);
+	else if (_action.isAction(VERB_LOOK, 0x11))
+		_vm->_dialogs->show(0x8BE9);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index e27806b..60b3bc1 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -422,6 +422,18 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene358: public Scene3xx {
+public:
+	Scene358(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 2e4e0f76aae0121309b86cdbd5ece9be2764b587
    https://github.com/scummvm/scummvm/commit/2e4e0f76aae0121309b86cdbd5ece9be2764b587
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-27T19:05:33+02:00

Commit Message:
MADS: Implement scene 359

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 46a5e89..9ef5f05 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -144,6 +144,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene357(vm);
 	case 358:
 		return new Scene358(vm);
+	case 359:
+		return new Scene359(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 647ea67..22f2007 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -3702,7 +3702,7 @@ void Scene351::enter() {
 	else if (_scene->_priorSceneId != -2) {
 		_game._player._playerPos = Common::Point(207, 81);
 		_game._player._facing = FACING_NORTH;
-	} 
+	}
 
 	if (_globals[kTeleporterCommand]) {
 		_game._player._visible = false;
@@ -3775,7 +3775,7 @@ void Scene351::actions() {
 			switch (_game._trigger) {
 			case 0:
 				_game._player._stepEnabled = false;
-				_game._player._visible = false; 
+				_game._player._visible = false;
 				if (_globals[kSexOfRex] == REX_FEMALE) {
 					_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 5, 2, 0, 0);
 					_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
@@ -3786,7 +3786,7 @@ void Scene351::actions() {
 					_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
 					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 6, 1);
 					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
-				} 
+				}
 				break;
 
 			case 1:
@@ -3858,12 +3858,12 @@ void Scene352::putArmDown(bool corridorExit, bool doorwayExit) {
 		if (_globals[kSexOfRex] == REX_FEMALE) {
 			_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 5, 2, 0, 0);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 5, 2); 
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 5, 2);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
 		} else {
 			_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 5, 2, 0, 0);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 6, 2); 
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 6, 2);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
 		}
 		break;
@@ -3872,7 +3872,7 @@ void Scene352::putArmDown(bool corridorExit, bool doorwayExit) {
 		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 0);
 		int idx = _scene->_dynamicHotspots.add(0x3B6, 0xD, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(230, 117), FACING_NORTHWEST);
-		_scene->changeVariant(0); 
+		_scene->changeVariant(0);
 		}
 		break;
 
@@ -3883,12 +3883,12 @@ void Scene352::putArmDown(bool corridorExit, bool doorwayExit) {
 		_game._player._visible = true;
 		if (corridorExit)
 			_scene->_sequences.addTimer(48, 6);
-		else if (doorwayExit) 
+		else if (doorwayExit)
 			_scene->_sequences.addTimer(48, 4);
 		else {
 			_mustPutArmDownFl = false;
 			_game._player._stepEnabled = true;
-		} 
+		}
 		break;
 
 	case 4:
@@ -3903,7 +3903,7 @@ void Scene352::putArmDown(bool corridorExit, bool doorwayExit) {
 		if (_leaveRoomFl)
 			_scene->_nextSceneId = 351;
 
-		break; 
+		break;
 
 	case 6:
 		_game._player.walk(Common::Point(171, 152), FACING_SOUTH);
@@ -3917,7 +3917,7 @@ void Scene352::putArmDown(bool corridorExit, bool doorwayExit) {
 		if (_leaveRoomFl)
 			_scene->_nextSceneId = 353;
 
-		break; 
+		break;
 
 	default:
 		break;
@@ -4024,9 +4024,9 @@ void Scene352::preActions() {
 
 	if (_action.isAction(VERB_PUT, 0x3B6, 0x1F3)) {
 		if (_globals[kSexOfRex] == REX_MALE)
-			_game._player.walk(Common::Point(269, 111), FACING_NORTHEAST); 
+			_game._player.walk(Common::Point(269, 111), FACING_NORTHEAST);
 		else
-			_game._player.walk(Common::Point(271, 111), FACING_NORTHEAST); 
+			_game._player.walk(Common::Point(271, 111), FACING_NORTHEAST);
 	}
 
 	if (_action.isAction(0x18B, 0x70) || _action.isAction(0x1AD, 0x2B3) || _action.isAction(VERB_PUT, 0x3B6, 0x89)) {
@@ -4042,8 +4042,8 @@ void Scene352::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_OPEN, 0x1F8)) { 
-		if (!_vaultOpenFl) { 
+	if (_action.isAction(VERB_OPEN, 0x1F8)) {
+		if (!_vaultOpenFl) {
 			switch (_game._trigger) {
 			case 0:
 				_game._player._stepEnabled = false;
@@ -4061,9 +4061,9 @@ void Scene352::actions() {
 			case 1: {
 				_vm->_sound->command(21);
 				_globals._sequenceIndexes[12] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[12], false, 7, 2, 20, 0);
-				_scene->_sequences.setDepth(_globals._sequenceIndexes[12], FACING_NORTH); 
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[12], FACING_NORTH);
 				int oldIdx = _commonSequenceIdx;
-				_commonSequenceIdx = _scene->_sequences.startCycle(_commonSpriteIndex, false, -2); 
+				_commonSequenceIdx = _scene->_sequences.startCycle(_commonSpriteIndex, false, -2);
 				_scene->_sequences.updateTimeout(_commonSequenceIdx, oldIdx);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 				}
@@ -4110,10 +4110,10 @@ void Scene352::actions() {
 
 	if (_action.isAction(0x1AD, 0x2B3) || _action.isAction(0x18B, 0x70) || _action.isAction(VERB_PUT, 0x3B6, 0x89)) {
 		if (_mustPutArmDownFl)
-			putArmDown(exit_corridor, exit_doorway); 
+			putArmDown(exit_corridor, exit_doorway);
 		else if (exit_corridor)
 			_scene->_nextSceneId = 353;
-		else 
+		else
 			_scene->_nextSceneId = 351;
 
 		_action._inProgress = false;
@@ -4125,7 +4125,7 @@ void Scene352::actions() {
 			switch (_game._trigger) {
 			case 0:
 				_game._player._stepEnabled = false;
-				_game._player._visible = false; 
+				_game._player._visible = false;
 				if (_globals[kSexOfRex] == REX_FEMALE) {
 					_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 5, 2, 0, 0);
 					_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
@@ -4136,13 +4136,13 @@ void Scene352::actions() {
 					_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
 					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 6, 1);
 					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
-				} 
+				}
 				break;
 
 			case 1:
 				_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 				_game._objects.addToInventory(0x2F);
-				_scene->changeVariant(1); 
+				_scene->changeVariant(1);
 				break;
 
 			case 2:
@@ -4157,7 +4157,7 @@ void Scene352::actions() {
 	}
 
 	if (_action.isAction(VERB_PUT, 0x3B6, 0x1F3)) {
-		if (!_vaultOpenFl) { 
+		if (!_vaultOpenFl) {
 			switch (_game._trigger) {
 			case 0:
 				_game._player._stepEnabled = false;
@@ -4175,9 +4175,9 @@ void Scene352::actions() {
 			case 1: {
 				_vm->_sound->command(21);
 				_globals._sequenceIndexes[12] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[12], false, 7, 2, 20, 0);
-				_scene->_sequences.setDepth(_globals._sequenceIndexes[12], 8); 
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[12], 8);
 				int oldIdx = _commonSequenceIdx;
-				_commonSequenceIdx = _scene->_sequences.startCycle(_commonSpriteIndex, false, -2); 
+				_commonSequenceIdx = _scene->_sequences.startCycle(_commonSpriteIndex, false, -2);
 				_scene->_sequences.updateTimeout(_commonSequenceIdx, oldIdx);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 				}
@@ -4222,7 +4222,7 @@ void Scene352::actions() {
 					_globals._sequenceIndexes[1] = _commonSequenceIdx;
 					_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x102));
 				} else {
-					_globals._sequenceIndexes[13] = _commonSequenceIdx; 
+					_globals._sequenceIndexes[13] = _commonSequenceIdx;
 					_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x103));
 				}
 
@@ -4239,7 +4239,7 @@ void Scene352::actions() {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
-			_game._player._visible = false; 
+			_game._player._visible = false;
 			if (_globals[kSexOfRex] == REX_MALE) {
 				_globals._sequenceIndexes[14] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[14], false, 8, 1, 0, 0);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[14], 1, 2);
@@ -4252,7 +4252,7 @@ void Scene352::actions() {
 				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[15]);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[15], SEQUENCE_TRIGGER_SPRITE, 2, 1);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[15], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
-			} 
+			}
 			break;
 
 		case 1:
@@ -4265,8 +4265,8 @@ void Scene352::actions() {
 			}
 
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
-			_globals._sequenceIndexes[13] = _scene->_sequences.startCycle(_globals._spriteIndexes[13], false, -2); 
-			_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 15); 
+			_globals._sequenceIndexes[13] = _scene->_sequences.startCycle(_globals._spriteIndexes[13], false, -2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 15);
 			break;
 
 		case 2:
@@ -4286,7 +4286,7 @@ void Scene352::actions() {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
-			_game._player._visible = false; 
+			_game._player._visible = false;
 			if (_globals[kSexOfRex] == REX_MALE) {
 				_globals._sequenceIndexes[6] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[6], true, 6, 2, 0, 0);
 				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[6]);
@@ -4297,7 +4297,7 @@ void Scene352::actions() {
 				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[7]);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_SPRITE, 6, 1);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
-			} 
+			}
 			break;
 
 		case 1:
@@ -4306,7 +4306,7 @@ void Scene352::actions() {
 			break;
 
 		case 2:
-			_game._objects.addToInventory(OBJ_TAPE_PLAYER); 
+			_game._objects.addToInventory(OBJ_TAPE_PLAYER);
 			if (_globals[kSexOfRex] == REX_MALE)
 				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[6]);
 			else
@@ -4382,7 +4382,7 @@ void Scene353::setup() {
 void Scene353::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(Resources::formatName(303, 'B', 0, EXT_SS, ""));
 	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 0, 5, 0);
-	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1); 
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 
 	if (_scene->_priorSceneId == 352)
 		_game._player._playerPos = Common::Point(144, 95);
@@ -4503,7 +4503,7 @@ void Scene357::enter() {
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
 
 	if (_scene->_priorSceneId == 318)
-		_game._player._playerPos = Common::Point(298, 142); 
+		_game._player._playerPos = Common::Point(298, 142);
 	else if (_scene->_priorSceneId == 313)
 		_game._player._playerPos = Common::Point(127, 101);
 	else if (_scene->_priorSceneId != -2)
@@ -4566,7 +4566,7 @@ void Scene358::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(Resources::formatName(307, 'X', 0, EXT_SS, ""));
 	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
 	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(127, 78));
-	_scene->_sequences.setDepth (_globals._sequenceIndexes[1], 15);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
 
 	if (_scene->_priorSceneId == 357)
 		_game._player._playerPos = Common::Point(305, 142);
@@ -4609,5 +4609,142 @@ void Scene358::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene359::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0xD);
+}
+
+void Scene359::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('b', -1));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(Resources::formatName(307, 'X', 0, EXT_SS, ""));
+
+	if (_globals[kSexOfRex] == REX_MALE)
+		_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RXMBD_2", false);
+	else
+		_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*ROXBD_2", false);
+
+	_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(127, 78));
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 15);
+
+	if (_game._objects.isInRoom(OBJ_SECURITY_CARD)) {
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 9, 0, 0, 0);
+		_cardHotspotId = _scene->_dynamicHotspots.add(0x131, 0xD, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(_cardHotspotId, Common::Point(107, 107), FACING_SOUTH);
+	}
+
+	if (_scene->_priorSceneId == 358)
+		_game._player._playerPos = Common::Point(301, 141);
+	else if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(15, 148);
+
+	sceneEntrySound();
+}
+
+void Scene359::preActions() {
+	if (_action.isAction(0x1AD, 0x2B9))
+		_game._player._walkOffScreenSceneId = 358;
+
+	if (_action.isAction(0x1AD, 0x2BA))
+		_game._player._walkOffScreenSceneId = 360;
+}
+
+void Scene359::actions() {
+	if (_action._lookFlag) {
+		if ((_game._difficulty != DIFFICULTY_HARD) && (_game._objects[OBJ_SECURITY_CARD]._roomNumber == 359))
+			_vm->_dialogs->show(0x8C4A);
+		else
+			_vm->_dialogs->show(0x8C4B);
+	} else if (_action.isAction(VERB_TAKE, 0x131)) {
+		if (_game._trigger || !_game._objects.isInInventory(OBJ_SECURITY_CARD)) {
+			switch (_game._trigger) {
+			case 0:
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				_vm->_dialogs->show(0x8C50);
+				if (_globals[kSexOfRex] == REX_MALE) {
+					_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 4, 2, 0, 0);
+					_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 6, 1);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				} else {
+					_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], true, 7, 2, 0, 0);
+					_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(106, 110));
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 6, 1);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				}
+				break;
+
+			case 1:
+				_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+				_scene->_dynamicHotspots.remove(_cardHotspotId);
+				_vm->_sound->command(57);
+				_game._objects.addToInventory(OBJ_SECURITY_CARD);
+				_vm->_dialogs->showItem(OBJ_SECURITY_CARD, 0x330);
+				_scene->changeVariant(1);
+				break;
+
+			case 2:
+				if (_globals[kSexOfRex] == REX_MALE)
+					_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[2]);
+				else
+					_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[4]);
+
+				_game._player._visible = true;
+				_game._player._stepEnabled = true;
+				break;
+
+			default:
+				break;
+			}
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x23E))
+		_vm->_dialogs->show(0x8C46);
+	else if (_action.isAction(VERB_LOOK, 0x1CB))
+		_vm->_dialogs->show(0x8C47);
+	else if (_action.isAction(VERB_LOOK, 0x216))
+		_vm->_dialogs->show(0x8C48);
+	else if (_action.isAction(VERB_LOOK, 0x21B))
+		_vm->_dialogs->show(0x8C49);
+	else if (_action.isAction(VERB_LOOK, 0x2B9))
+		_vm->_dialogs->show(0x8C4C);
+	else if (_action.isAction(VERB_LOOK, 0x2BA))
+		_vm->_dialogs->show(0x8C4D);
+	else if (_action.isAction(VERB_LOOK, 0x215))
+		_vm->_dialogs->show(0x8C4E);
+	else if (_action.isAction(VERB_TAKE, 0x215))
+		_vm->_dialogs->show(0x8C4F);
+	else if (_action.isAction(VERB_LOOK, 0x131) && (_action._mainObjectSource == 4))
+		_vm->_dialogs->show(0x8C51);
+	else if (_action.isAction(VERB_LOOK, 0x2D2)) {
+		if ((_game._difficulty != DIFFICULTY_HARD) && (_game._objects[OBJ_SECURITY_CARD]._roomNumber == 359))
+			_vm->_dialogs->show(0x8C52);
+		else
+			_vm->_dialogs->show(0x8C53);
+	} else if (_action.isAction(VERB_LOOK, 0x23F))
+		_vm->_dialogs->show(0x8C54);
+	else if (_action.isAction(VERB_TAKE, 0x23F))
+		_vm->_dialogs->show(0x8C55);
+	else if (_action.isAction(VERB_LOOK, 0x23A))
+		_vm->_dialogs->show(0x8C56);
+	else if (_action.isAction(VERB_LOOK, 0x204))
+		_vm->_dialogs->show(0x8C57);
+	else if (_action.isAction(VERB_LOOK, 0x89)) {
+		if ((_game._difficulty != DIFFICULTY_HARD) && (_game._objects[OBJ_SECURITY_CARD]._roomNumber == 359))
+			_vm->_dialogs->show(0x8C58);
+		else
+			_vm->_dialogs->show(0x8C59);
+	} else if (_action.isAction(VERB_OPEN, 0x11) || _action.isAction(VERB_LOOK, 0x11))
+		_vm->_dialogs->show(0x8CB0);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 60b3bc1..247224b7 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -434,6 +434,21 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene359: public Scene3xx {
+private:
+	int _cardHotspotId;
+
+public:
+	Scene359(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 6bac381576488e5865b852705005a94e5b814a69
    https://github.com/scummvm/scummvm/commit/6bac381576488e5865b852705005a94e5b814a69
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-27T20:06:06+02:00

Commit Message:
MADS: Implement scene 360

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 9ef5f05..fe915ed 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -146,6 +146,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene358(vm);
 	case 359:
 		return new Scene359(vm);
+	case 360:
+		return new Scene360(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 22f2007..1213cd8 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -4746,5 +4746,59 @@ void Scene359::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene360::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene360::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(Resources::formatName(307, 'X', 0, EXT_SS, ""));
+	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(127, 78));
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
+
+	if (_scene->_priorSceneId == 359)
+		_game._player._playerPos = Common::Point(304, 143);
+	else if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(13, 141);
+
+	sceneEntrySound();
+}
+
+void Scene360::preActions() {
+	if (_action.isAction(0x1AD, 0x2B9))
+		_game._player._walkOffScreenSceneId = 359;
+
+	if (_action.isAction(0x1AD, 0x2BA))
+		_game._player._walkOffScreenSceneId = 361;
+}
+
+void Scene360::actions() {
+	if (_action._lookFlag)
+		_vm->_dialogs->show(0x8CAF);
+	else if (_action.isAction(VERB_LOOK, 0x2BA))
+		_vm->_dialogs->show(0x8CAA);
+	else if (_action.isAction(VERB_LOOK, 0x2B9))
+		_vm->_dialogs->show(0x8CAB);
+	else if (_action.isAction(VERB_LOOK, 0x1CB))
+		_vm->_dialogs->show(0x8CAC);
+	else if (_action.isAction(VERB_LOOK, 0x216))
+		_vm->_dialogs->show(0x8CAD);
+	else if (_action.isAction(VERB_LOOK, 0x21B))
+		_vm->_dialogs->show(0x8CAE);
+	else if (_action.isAction(VERB_LOOK, 0x11))
+		_vm->_dialogs->show(0x8CB0);
+	else if (_action.isAction(VERB_LOOK, 0x204))
+		_vm->_dialogs->show(0x8CB1);
+	else if (_action.isAction(VERB_LOOK, 0x18D))
+		_vm->_dialogs->show(0x8CB2);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 247224b7..7f2996e 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -449,6 +449,18 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene360: public Scene3xx {
+public:
+	Scene360(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 15658397d418833d7839e1c85e3093c1fc79fdcf
    https://github.com/scummvm/scummvm/commit/15658397d418833d7839e1c85e3093c1fc79fdcf
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-04-27T21:20:01+03:00

Commit Message:
MADS: Show the current scene when using "scene" without params

Changed paths:
    engines/mads/debugger.cpp



diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp
index 7d66b56..a6192b2 100644
--- a/engines/mads/debugger.cpp
+++ b/engines/mads/debugger.cpp
@@ -69,6 +69,7 @@ bool Debugger::Cmd_Mouse(int argc, const char **argv) {
 
 bool Debugger::Cmd_LoadScene(int argc, const char **argv) {
 	if (argc != 2) {
+		DebugPrintf("Current scene is: %d\n", _vm->_game->_scene._currentSceneId);
 		DebugPrintf("Usage: %s <scene number>\n", argv[0]);
 		return true;
 	} else {


Commit: 62f800341dbcab48acafcb1753f86aa51958b69d
    https://github.com/scummvm/scummvm/commit/62f800341dbcab48acafcb1753f86aa51958b69d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-04-27T21:20:01+03:00

Commit Message:
MADS: Add detection entries for Dragonsphere and Phantom

Also, disable the unsupported compressed Rex version for now

Changed paths:
    engines/mads/detection.cpp
    engines/mads/detection_tables.h
    engines/mads/mads.h



diff --git a/engines/mads/detection.cpp b/engines/mads/detection.cpp
index b8e75b4..49253f0 100644
--- a/engines/mads/detection.cpp
+++ b/engines/mads/detection.cpp
@@ -68,7 +68,9 @@ Common::Platform MADSEngine::getPlatform() const {
 
 static const PlainGameDescriptor MADSGames[] = {
 	{"MADS", "MADS"},
+	{"dragonsphere", "Dragonsphere"},
 	{"nebular", "Rex Nebular and the Cosmic Gender Bender"},
+	{"phantom", "Return of the Phantom"},
 	{0, 0}
 };
 
diff --git a/engines/mads/detection_tables.h b/engines/mads/detection_tables.h
index 4eb1dd5..a5a9c33 100644
--- a/engines/mads/detection_tables.h
+++ b/engines/mads/detection_tables.h
@@ -23,8 +23,10 @@
 namespace MADS {
 
 static const MADSGameDescription gameDescriptions[] = {
+#if 0
 	{
-		// Rex Nebular and the Cosmic Gender Bender DOS English
+		// Rex Nebular and the Cosmic Gender Bender DOS English (compressed)
+		// Removed for now, until the original floppy compression is supported
 		{
 			"nebular",
 			0,
@@ -40,6 +42,7 @@ static const MADSGameDescription gameDescriptions[] = {
 		GType_RexNebular,
 		0
 	},
+#endif
 
 	{
 		// Rex Nebular and the Cosmic Gender Bender DOS English
@@ -59,6 +62,42 @@ static const MADSGameDescription gameDescriptions[] = {
 		0
 	},
 
+	{
+		// Return of the Phantom DOS English
+		{
+			"phantom",
+			0,
+			{
+				{"section1.hag", 0, "76e2d47a7aebafe48edc9884b3d91782", 1130939},
+				AD_LISTEND
+			},
+			Common::EN_ANY,
+			Common::kPlatformDOS,
+			ADGF_NO_FLAGS,
+			GUIO1(GUIO_NONE)
+		},
+		GType_Phantom,
+		0
+	},
+
+	{
+		// Dragonsphere DOS English
+		{
+			"dragonsphere",
+			0,
+			{
+				{"section1.hag", 0, "2770e441d296be5e806194693eebd95a", 2061199},
+				AD_LISTEND
+			},
+			Common::EN_ANY,
+			Common::kPlatformDOS,
+			ADGF_NO_FLAGS,
+			GUIO1(GUIO_NONE)
+		},
+		GType_Dragonsphere,
+		0
+	},
+
 	{ AD_TABLE_END_MARKER, 0, 0 }
 };
 
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index 9acd469..5ae8b8e 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -62,7 +62,7 @@ enum MADSDebugChannels {
 
 enum {
 	GType_RexNebular = 0,
-	GType_DragonSphere = 1,
+	GType_Dragonsphere = 1,
 	GType_Phantom = 2,
 	GType_Riddle = 3
 };


Commit: 4d159955a1eb79eb625d8e8dcb0c38d7a0a235ec
    https://github.com/scummvm/scummvm/commit/4d159955a1eb79eb625d8e8dcb0c38d7a0a235ec
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-04-27T21:20:01+03:00

Commit Message:
MADS: Set Rex to start from scene 101, like the original

There's a temporary hack to skip showing Rex's standing up animation
cause it takes ages to finish

Changed paths:
    engines/mads/game.cpp
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index d9d1fea..a12f8e8 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -110,8 +110,8 @@ void Game::run() {
 			break;
 		default:
 			// Copy protection check succeeded
-			_scene._nextSceneId = 103;
-			_scene._priorSceneId = 102;
+			_scene._nextSceneId = 101;
+			_scene._priorSceneId = -1;
 			break;
 		}
 	}
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 923d8c0..54db1d3 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -163,6 +163,10 @@ void Scene101::enter() {
 	_scene->_hotspots.activate(0x137, false);
 	_panelOpened = false;
 
+	// HACK: set the prior scene to 102 for now when the game starts, to avoid Rex's getting up animation
+	if (_scene->_priorSceneId == -1)
+		_scene->_priorSceneId = 102;
+
 	if (_scene->_priorSceneId != -1)
 		_globals[kNeedToStandUp] = false;
 


Commit: 76950bf0ac210ecc31e798ce34de9a3f010371b2
    https://github.com/scummvm/scummvm/commit/76950bf0ac210ecc31e798ce34de9a3f010371b2
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-04-27T21:20:01+03:00

Commit Message:
MADS: Add skeleton classes for Phantom and Dragonsphere

Changed paths:
  A engines/mads/dragonsphere/dragonsphere_scenes.cpp
  A engines/mads/dragonsphere/dragonsphere_scenes.h
  A engines/mads/dragonsphere/game_dragonsphere.cpp
  A engines/mads/dragonsphere/game_dragonsphere.h
  A engines/mads/phantom/game_phantom.cpp
  A engines/mads/phantom/game_phantom.h
  A engines/mads/phantom/phantom_scenes.cpp
  A engines/mads/phantom/phantom_scenes.h
    engines/mads/game.cpp
    engines/mads/module.mk



diff --git a/engines/mads/dragonsphere/dragonsphere_scenes.cpp b/engines/mads/dragonsphere/dragonsphere_scenes.cpp
new file mode 100644
index 0000000..fd4fcc1
--- /dev/null
+++ b/engines/mads/dragonsphere/dragonsphere_scenes.cpp
@@ -0,0 +1,112 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "common/config-manager.h"
+#include "mads/mads.h"
+#include "mads/compression.h"
+#include "mads/resources.h"
+#include "mads/scene.h"
+#include "mads/dragonsphere/game_dragonsphere.h"
+#include "mads/dragonsphere/dragonsphere_scenes.h"
+
+namespace MADS {
+
+namespace Dragonsphere {
+
+SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
+	Scene &scene = vm->_game->_scene;
+
+	// TODO
+	//scene.addActiveVocab(NOUN_DROP);
+
+	// TODO: Just return a dummy scene for now
+	return new DummyScene(vm);
+
+	switch (scene._nextSceneId) {
+	// Scene group #1
+	case 101:
+	// TODO
+
+	// Scene group #2
+	// TODO
+
+	// Scene group #3
+	// TODO
+
+	// Scene group #8
+	// TODO
+
+	default:
+		error("Invalid scene %d called", scene._nextSceneId);
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+DragonsphereScene::DragonsphereScene(MADSEngine *vm) : SceneLogic(vm),
+		_globals(static_cast<GameDragonsphere *>(vm->_game)->_globals),
+		_game(*static_cast<GameDragonsphere *>(vm->_game)),
+		_action(vm->_game->_scene._action) {
+}
+
+Common::String DragonsphereScene::formAnimName(char sepChar, int suffixNum) {
+	return Resources::formatName(_scene->_currentSceneId, sepChar, suffixNum,
+		EXT_NONE, "");
+}
+
+/*------------------------------------------------------------------------*/
+
+void SceneInfoDragonsphere::loadCodes(MSurface &depthSurface, int variant) {
+	File f(Resources::formatName(RESPREFIX_RM, _sceneId, ".DAT"));
+	MadsPack codesPack(&f);
+	Common::SeekableReadStream *stream = codesPack.getItemStream(variant + 1);
+
+	loadCodes(depthSurface, stream);
+
+	delete stream;
+	f.close();
+}
+
+void SceneInfoDragonsphere::loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream) {
+	byte *destP = depthSurface.getData();
+	byte *endP = depthSurface.getBasePtr(0, depthSurface.h);
+
+	byte runLength = stream->readByte();
+	while (destP < endP && runLength > 0) {
+		byte runValue = stream->readByte();
+
+		// Write out the run length
+		Common::fill(destP, destP + runLength, runValue);
+		destP += runLength;
+
+		// Get the next run length
+		runLength = stream->readByte();
+	}
+
+	if (destP < endP)
+		Common::fill(destP, endP, 0);
+}
+
+} // End of namespace Dragonsphere
+
+} // End of namespace MADS
diff --git a/engines/mads/dragonsphere/dragonsphere_scenes.h b/engines/mads/dragonsphere/dragonsphere_scenes.h
new file mode 100644
index 0000000..596a59e
--- /dev/null
+++ b/engines/mads/dragonsphere/dragonsphere_scenes.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_DRAGONSPHERE_SCENES_H
+#define MADS_DRAGONSPHERE_SCENES_H
+
+#include "common/scummsys.h"
+#include "mads/game.h"
+#include "mads/scene.h"
+#include "mads/dragonsphere/game_dragonsphere.h"
+//#include "mads/dragonsphere/globals_dragonsphere.h"
+
+
+namespace MADS {
+
+namespace Dragonsphere {
+
+enum Noun {
+	NOUN_LOOK_AT		= 0x0D1,
+	// TODO
+};
+
+class SceneFactory {
+public:
+	static SceneLogic *createScene(MADSEngine *vm);
+};
+
+/**
+ * Specialized base class for Dragonsphere game scenes
+ */
+class DragonsphereScene : public SceneLogic {
+protected:
+	DragonsphereGlobals &_globals;
+	GameDragonsphere &_game;
+	MADSAction &_action;
+
+	/**
+	 * Forms an animation resource name
+	 */
+	Common::String formAnimName(char sepChar, int suffixNum);
+
+	/**
+	 * Plays appropriate sound for entering varous rooms
+	 */
+	void lowRoomsEntrySound();
+public:
+	/**
+	 * Constructor
+	 */
+	DragonsphereScene(MADSEngine *vm);
+
+	void sub7178C();
+};
+
+class SceneInfoDragonsphere : public SceneInfo {
+	friend class SceneInfo;
+protected:
+	virtual void loadCodes(MSurface &depthSurface, int variant);
+
+	virtual void loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream);
+
+	/**
+	* Constructor
+	*/
+	SceneInfoDragonsphere(MADSEngine *vm) : SceneInfo(vm) {}
+};
+
+// TODO: Temporary, remove once implemented properly
+class Scene1xx : public DragonsphereScene {
+protected:
+	/**
+	 * Plays an appropriate sound when entering a scene
+	 */
+	void sceneEntrySound() {}
+
+	/**
+	 *Sets the AA file to use for the scene
+	 */
+	void setAAName() {}
+
+	/**
+	 * Updates the prefix used for getting player sprites for the scene
+	 */
+	void setPlayerSpritesPrefix() {}
+public:
+	Scene1xx(MADSEngine *vm) : DragonsphereScene(vm) {}
+};
+
+// TODO: Temporary, remove once implemented properly
+class DummyScene: public Scene1xx {
+public:
+	DummyScene(MADSEngine *vm) : Scene1xx(vm) {}
+
+	virtual void setup() {}
+	virtual void enter() {}
+	virtual void step() {}
+	virtual void preActions() {}
+	virtual void actions() {}
+	virtual void synchronize(Common::Serializer &s) {}
+};
+
+} // End of namespace Dragonsphere
+
+} // End of namespace MADS
+
+#endif /* MADS_DRAGONSPHERE_SCENES_H */
diff --git a/engines/mads/dragonsphere/game_dragonsphere.cpp b/engines/mads/dragonsphere/game_dragonsphere.cpp
new file mode 100644
index 0000000..7d3864e
--- /dev/null
+++ b/engines/mads/dragonsphere/game_dragonsphere.cpp
@@ -0,0 +1,172 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "common/config-manager.h"
+#include "mads/mads.h"
+#include "mads/game.h"
+#include "mads/screen.h"
+#include "mads/msurface.h"
+#include "mads/dragonsphere/game_dragonsphere.h"
+//#include "mads/nebular/dialogs_nebular.h"
+//#include "mads/nebular/globals_nebular.h"
+#include "mads/dragonsphere/dragonsphere_scenes.h"
+
+namespace MADS {
+
+namespace Dragonsphere {
+
+GameDragonsphere::GameDragonsphere(MADSEngine *vm): Game(vm) {
+	_surface = new MSurface(MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT);
+	_storyMode = STORYMODE_NAUGHTY;
+}
+
+ProtectionResult GameDragonsphere::checkCopyProtection() {
+	/*
+	// DEBUG: Flag copy protection failure
+	_globals[5] = -1;
+	
+	if (!ConfMan.getBool("copy_protection"))
+		return true;
+
+	* DEBUG: Disabled for now
+	CopyProtectionDialog *dlg = new CopyProtectionDialog(_vm, false);
+	dlg->show();
+	delete dlg;
+	*/
+
+	// DEBUG: Return that copy protection failed
+	return PROTECTION_SUCCEED;
+}
+
+void GameDragonsphere::initialiseGlobals() {
+	//int count, count2;
+	//int bad;
+
+	_globals.reset();
+	//_globals[kTalkInanimateCount] = 8;
+
+	/* Section #1 variables */
+	// TODO
+
+	/* Section #2 variables */
+	// TODO
+
+	/* Section #3 variables */
+	// TODO
+
+	/* Section #4 variables */
+	// TODO
+
+	/* Section #5 variables */
+	// TODO
+
+	/* Section #6 variables */
+	// TODO
+
+	/* Section #9 variables */
+	// TODO
+
+	_player._facing = FACING_NORTH;
+	_player._turnToFacing = FACING_NORTH;
+
+	//Player::preloadSequences("RXM", 1);
+	//Player::preloadSequences("ROX", 1);
+}
+
+void GameDragonsphere::setSectionHandler() {
+	delete _sectionHandler;
+
+	switch (_sectionNumber) {
+	case 1:
+		_sectionHandler = new Section1Handler(_vm);
+		break;
+	case 2:
+		_sectionHandler = new Section2Handler(_vm);
+		break;
+	case 3:
+		_sectionHandler = new Section3Handler(_vm);
+		break;
+	case 4:
+		_sectionHandler = new Section4Handler(_vm);
+		break;
+	case 5:
+		_sectionHandler = new Section5Handler(_vm);
+		break;
+	case 6:
+		_sectionHandler = new Section6Handler(_vm);
+		break;
+	case 7:
+		_sectionHandler = new Section7Handler(_vm);
+		break;
+	case 8:
+		_sectionHandler = new Section8Handler(_vm);
+		break;
+	default:
+		break;
+	}
+}
+
+void GameDragonsphere::checkShowDialog() {
+	// TODO: Copied from Nebular
+	if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globals[5]) {
+		_player.releasePlayerSprites();
+		_vm->_dialogs->showDialog();
+		_vm->_dialogs->_pendingDialog = DIALOG_NONE;
+	}
+}
+
+void GameDragonsphere::doObjectAction() {
+	// TODO: Copied from Nebular
+	//Scene &scene = _scene;
+	MADSAction &action = _scene._action;
+	//Dialogs &dialogs = *_vm->_dialogs;
+	//int id;
+
+	action._inProgress = false;
+}
+
+void GameDragonsphere::unhandledAction() {
+	// TODO
+}
+
+void GameDragonsphere::step() {
+	if (_player._visible && _player._stepEnabled && !_player._moving &&
+		(_player._facing == _player._turnToFacing)) {
+
+		// TODO
+	}
+
+}
+
+void GameDragonsphere::synchronize(Common::Serializer &s, bool phase1) {
+	Game::synchronize(s, phase1);
+
+	// TODO: Copied from Nebular
+	if (!phase1) {
+		_globals.synchronize(s);
+	}
+}
+
+} // End of namespace Dragonsphere
+
+} // End of namespace MADS
diff --git a/engines/mads/dragonsphere/game_dragonsphere.h b/engines/mads/dragonsphere/game_dragonsphere.h
new file mode 100644
index 0000000..dd96146
--- /dev/null
+++ b/engines/mads/dragonsphere/game_dragonsphere.h
@@ -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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_GAME_DRAGONSPHERE_H
+#define MADS_GAME_DRAGONSPHERE_H
+
+#include "common/scummsys.h"
+#include "mads/game.h"
+#include "mads/globals.h"
+//#include "mads/nebular/globals_nebular.h"
+
+namespace MADS {
+
+namespace Dragonsphere {
+
+// TODO: Adapt for Dragonsphere's difficulty setting
+enum StoryMode { STORYMODE_NAUGHTY = 1, STORYMODE_NICE = 2 };
+
+enum InventoryObject { OBJ_NONE = -1
+	// TODO
+};
+
+// HACK: A stub for now, remove from here once it's implemented properly
+class DragonsphereGlobals: public Globals {
+public:
+	DragonsphereGlobals() {}
+};
+
+class GameDragonsphere: public Game {
+	friend class Game;
+protected:
+	GameDragonsphere(MADSEngine *vm);
+
+	virtual ProtectionResult checkCopyProtection();
+
+	virtual void initialiseGlobals();
+
+	virtual void setSectionHandler();
+
+	virtual void checkShowDialog();
+public:
+	DragonsphereGlobals _globals;
+	StoryMode _storyMode;
+
+	virtual Globals &globals() { return _globals; }
+
+	virtual void doObjectAction();
+
+	virtual void unhandledAction();
+
+	virtual void step();
+
+	virtual void synchronize(Common::Serializer &s, bool phase1);
+};
+
+
+class Section1Handler: public SectionHandler {
+public:
+	Section1Handler(MADSEngine *vm): SectionHandler(vm) {}
+
+	// TODO: Properly implement handler methods
+	virtual void preLoadSection() {}
+	virtual void sectionPtr2() {}
+	virtual void postLoadSection() {}
+};
+
+// TODO: Properly implement handler classes
+typedef Section1Handler Section2Handler;
+typedef Section1Handler Section3Handler;
+typedef Section1Handler Section4Handler;
+typedef Section1Handler Section5Handler;
+typedef Section1Handler Section6Handler;
+typedef Section1Handler Section7Handler;
+typedef Section1Handler Section8Handler;
+
+} // End of namespace Nebular
+
+} // End of namespace MADS
+
+#endif /* MADS_GAME_DRAGONSPHERE_H */
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index a12f8e8..2c2f636 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -35,13 +35,23 @@
 #include "mads/screen.h"
 #include "mads/msurface.h"
 #include "mads/resources.h"
+#include "mads/dragonsphere/game_dragonsphere.h"
 #include "mads/nebular/game_nebular.h"
+#include "mads/phantom/game_phantom.h"
 
 namespace MADS {
 
 Game *Game::init(MADSEngine *vm) {
-	if (vm->getGameID() == GType_RexNebular)
+	switch (vm->getGameID()) {
+	case GType_RexNebular:
 		return new Nebular::GameNebular(vm);
+	case GType_Dragonsphere:
+		return new Dragonsphere::GameDragonsphere(vm);
+	case GType_Phantom:
+		return new Phantom::GamePhantom(vm);
+	default:
+		error("Game: Unknown game");
+	}
 
 	return nullptr;
 }
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 43853f5..e5b9efe 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -1,6 +1,10 @@
 MODULE := engines/mads
 
 MODULE_OBJS := \
+	dragonsphere/game_dragonsphere.o \
+	dragonsphere/dragonsphere_scenes.o \
+	phantom/game_phantom.o \
+	phantom/phantom_scenes.o \
 	nebular/dialogs_nebular.o \
 	nebular/game_nebular.o \
 	nebular/globals_nebular.o \
diff --git a/engines/mads/phantom/game_phantom.cpp b/engines/mads/phantom/game_phantom.cpp
new file mode 100644
index 0000000..43dec7c
--- /dev/null
+++ b/engines/mads/phantom/game_phantom.cpp
@@ -0,0 +1,172 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "common/config-manager.h"
+#include "mads/mads.h"
+#include "mads/game.h"
+#include "mads/screen.h"
+#include "mads/msurface.h"
+#include "mads/phantom/game_phantom.h"
+//#include "mads/nebular/dialogs_nebular.h"
+//#include "mads/nebular/globals_nebular.h"
+#include "mads/phantom/phantom_scenes.h"
+
+namespace MADS {
+
+namespace Phantom {
+
+GamePhantom::GamePhantom(MADSEngine *vm): Game(vm) {
+	_surface = new MSurface(MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT);
+	_storyMode = STORYMODE_NAUGHTY;
+}
+
+ProtectionResult GamePhantom::checkCopyProtection() {
+	/*
+	// DEBUG: Flag copy protection failure
+	_globals[5] = -1;
+	
+	if (!ConfMan.getBool("copy_protection"))
+		return true;
+
+	* DEBUG: Disabled for now
+	CopyProtectionDialog *dlg = new CopyProtectionDialog(_vm, false);
+	dlg->show();
+	delete dlg;
+	*/
+
+	// DEBUG: Return that copy protection failed
+	return PROTECTION_SUCCEED;
+}
+
+void GamePhantom::initialiseGlobals() {
+	//int count, count2;
+	//int bad;
+
+	_globals.reset();
+	//_globals[kTalkInanimateCount] = 8;
+
+	/* Section #1 variables */
+	// TODO
+
+	/* Section #2 variables */
+	// TODO
+
+	/* Section #3 variables */
+	// TODO
+
+	/* Section #4 variables */
+	// TODO
+
+	/* Section #5 variables */
+	// TODO
+
+	/* Section #6 variables */
+	// TODO
+
+	/* Section #9 variables */
+	// TODO
+
+	_player._facing = FACING_NORTH;
+	_player._turnToFacing = FACING_NORTH;
+
+	//Player::preloadSequences("RXM", 1);
+	//Player::preloadSequences("ROX", 1);
+}
+
+void GamePhantom::setSectionHandler() {
+	delete _sectionHandler;
+
+	switch (_sectionNumber) {
+	case 1:
+		_sectionHandler = new Section1Handler(_vm);
+		break;
+	case 2:
+		_sectionHandler = new Section2Handler(_vm);
+		break;
+	case 3:
+		_sectionHandler = new Section3Handler(_vm);
+		break;
+	case 4:
+		_sectionHandler = new Section4Handler(_vm);
+		break;
+	case 5:
+		_sectionHandler = new Section5Handler(_vm);
+		break;
+	case 6:
+		_sectionHandler = new Section6Handler(_vm);
+		break;
+	case 7:
+		_sectionHandler = new Section7Handler(_vm);
+		break;
+	case 8:
+		_sectionHandler = new Section8Handler(_vm);
+		break;
+	default:
+		break;
+	}
+}
+
+void GamePhantom::checkShowDialog() {
+	// TODO: Copied from Nebular
+	if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globals[5]) {
+		_player.releasePlayerSprites();
+		_vm->_dialogs->showDialog();
+		_vm->_dialogs->_pendingDialog = DIALOG_NONE;
+	}
+}
+
+void GamePhantom::doObjectAction() {
+	// TODO: Copied from Nebular
+	//Scene &scene = _scene;
+	MADSAction &action = _scene._action;
+	//Dialogs &dialogs = *_vm->_dialogs;
+	//int id;
+
+	action._inProgress = false;
+}
+
+void GamePhantom::unhandledAction() {
+	// TODO
+}
+
+void GamePhantom::step() {
+	if (_player._visible && _player._stepEnabled && !_player._moving &&
+		(_player._facing == _player._turnToFacing)) {
+
+		// TODO
+	}
+
+}
+
+void GamePhantom::synchronize(Common::Serializer &s, bool phase1) {
+	Game::synchronize(s, phase1);
+
+	// TODO: Copied from Nebular
+	if (!phase1) {
+		_globals.synchronize(s);
+	}
+}
+
+} // End of namespace Phantom
+
+} // End of namespace MADS
diff --git a/engines/mads/phantom/game_phantom.h b/engines/mads/phantom/game_phantom.h
new file mode 100644
index 0000000..bb574a9
--- /dev/null
+++ b/engines/mads/phantom/game_phantom.h
@@ -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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_GAME_PHANTOM_H
+#define MADS_GAME_PHANTOM_H
+
+#include "common/scummsys.h"
+#include "mads/game.h"
+#include "mads/globals.h"
+//#include "mads/nebular/globals_nebular.h"
+
+namespace MADS {
+
+namespace Phantom {
+
+// TODO: Adapt for Phantom's difficulty setting
+enum StoryMode { STORYMODE_NAUGHTY = 1, STORYMODE_NICE = 2 };
+
+enum InventoryObject { OBJ_NONE = -1
+	// TODO
+};
+
+// HACK: A stub for now, remove from here once it's implemented properly
+class PhantomGlobals: public Globals {
+public:
+	PhantomGlobals() {}
+};
+
+class GamePhantom: public Game {
+	friend class Game;
+protected:
+	GamePhantom(MADSEngine *vm);
+
+	virtual ProtectionResult checkCopyProtection();
+
+	virtual void initialiseGlobals();
+
+	virtual void setSectionHandler();
+
+	virtual void checkShowDialog();
+public:
+	PhantomGlobals _globals;
+	StoryMode _storyMode;
+
+	virtual Globals &globals() { return _globals; }
+
+	virtual void doObjectAction();
+
+	virtual void unhandledAction();
+
+	virtual void step();
+
+	virtual void synchronize(Common::Serializer &s, bool phase1);
+};
+
+
+class Section1Handler: public SectionHandler {
+public:
+	Section1Handler(MADSEngine *vm): SectionHandler(vm) {}
+
+	// TODO: Properly implement handler methods
+	virtual void preLoadSection() {}
+	virtual void sectionPtr2() {}
+	virtual void postLoadSection() {}
+};
+
+// TODO: Properly implement handler classes
+typedef Section1Handler Section2Handler;
+typedef Section1Handler Section3Handler;
+typedef Section1Handler Section4Handler;
+typedef Section1Handler Section5Handler;
+typedef Section1Handler Section6Handler;
+typedef Section1Handler Section7Handler;
+typedef Section1Handler Section8Handler;
+
+} // End of namespace Nebular
+
+} // End of namespace MADS
+
+#endif /* MADS_GAME_PHANTOM_H */
diff --git a/engines/mads/phantom/phantom_scenes.cpp b/engines/mads/phantom/phantom_scenes.cpp
new file mode 100644
index 0000000..83b664b
--- /dev/null
+++ b/engines/mads/phantom/phantom_scenes.cpp
@@ -0,0 +1,112 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "common/config-manager.h"
+#include "mads/mads.h"
+#include "mads/compression.h"
+#include "mads/resources.h"
+#include "mads/scene.h"
+#include "mads/phantom/game_phantom.h"
+#include "mads/phantom/phantom_scenes.h"
+
+namespace MADS {
+
+namespace Phantom {
+
+SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
+	Scene &scene = vm->_game->_scene;
+
+	// TODO
+	//scene.addActiveVocab(NOUN_DROP);
+
+	// TODO: Just return a dummy scene for now
+	return new DummyScene(vm);
+
+	switch (scene._nextSceneId) {
+	// Scene group #1
+	case 101:
+	// TODO
+
+	// Scene group #2
+	// TODO
+
+	// Scene group #3
+	// TODO
+
+	// Scene group #8
+	// TODO
+
+	default:
+		error("Invalid scene %d called", scene._nextSceneId);
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+PhantomScene::PhantomScene(MADSEngine *vm) : SceneLogic(vm),
+		_globals(static_cast<GamePhantom *>(vm->_game)->_globals),
+		_game(*static_cast<GamePhantom *>(vm->_game)),
+		_action(vm->_game->_scene._action) {
+}
+
+Common::String PhantomScene::formAnimName(char sepChar, int suffixNum) {
+	return Resources::formatName(_scene->_currentSceneId, sepChar, suffixNum,
+		EXT_NONE, "");
+}
+
+/*------------------------------------------------------------------------*/
+
+void SceneInfoPhantom::loadCodes(MSurface &depthSurface, int variant) {
+	File f(Resources::formatName(RESPREFIX_RM, _sceneId, ".DAT"));
+	MadsPack codesPack(&f);
+	Common::SeekableReadStream *stream = codesPack.getItemStream(variant + 1);
+
+	loadCodes(depthSurface, stream);
+
+	delete stream;
+	f.close();
+}
+
+void SceneInfoPhantom::loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream) {
+	byte *destP = depthSurface.getData();
+	byte *endP = depthSurface.getBasePtr(0, depthSurface.h);
+
+	byte runLength = stream->readByte();
+	while (destP < endP && runLength > 0) {
+		byte runValue = stream->readByte();
+
+		// Write out the run length
+		Common::fill(destP, destP + runLength, runValue);
+		destP += runLength;
+
+		// Get the next run length
+		runLength = stream->readByte();
+	}
+
+	if (destP < endP)
+		Common::fill(destP, endP, 0);
+}
+
+} // End of namespace Phantom
+
+} // End of namespace MADS
diff --git a/engines/mads/phantom/phantom_scenes.h b/engines/mads/phantom/phantom_scenes.h
new file mode 100644
index 0000000..6476710
--- /dev/null
+++ b/engines/mads/phantom/phantom_scenes.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_PHANTOM_SCENES_H
+#define MADS_PHANTOM_SCENES_H
+
+#include "common/scummsys.h"
+#include "mads/game.h"
+#include "mads/scene.h"
+#include "mads/phantom/game_phantom.h"
+//#include "mads/phantom/globals_phantom.h"
+
+
+namespace MADS {
+
+namespace Phantom {
+
+enum Noun {
+	NOUN_LOOK_AT		= 0x0D1,
+	// TODO
+};
+
+class SceneFactory {
+public:
+	static SceneLogic *createScene(MADSEngine *vm);
+};
+
+/**
+ * Specialized base class for Dragonsphere game scenes
+ */
+class PhantomScene : public SceneLogic {
+protected:
+	PhantomGlobals &_globals;
+	GamePhantom &_game;
+	MADSAction &_action;
+
+	/**
+	 * Forms an animation resource name
+	 */
+	Common::String formAnimName(char sepChar, int suffixNum);
+
+	/**
+	 * Plays appropriate sound for entering varous rooms
+	 */
+	void lowRoomsEntrySound();
+public:
+	/**
+	 * Constructor
+	 */
+	PhantomScene(MADSEngine *vm);
+
+	void sub7178C();
+};
+
+class SceneInfoPhantom : public SceneInfo {
+	friend class SceneInfo;
+protected:
+	virtual void loadCodes(MSurface &depthSurface, int variant);
+
+	virtual void loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream);
+
+	/**
+	* Constructor
+	*/
+	SceneInfoPhantom(MADSEngine *vm) : SceneInfo(vm) {}
+};
+
+// TODO: Temporary, remove once implemented properly
+class Scene1xx : public PhantomScene {
+protected:
+	/**
+	 * Plays an appropriate sound when entering a scene
+	 */
+	void sceneEntrySound() {}
+
+	/**
+	 *Sets the AA file to use for the scene
+	 */
+	void setAAName() {}
+
+	/**
+	 * Updates the prefix used for getting player sprites for the scene
+	 */
+	void setPlayerSpritesPrefix() {}
+public:
+	Scene1xx(MADSEngine *vm) : PhantomScene(vm) {}
+};
+
+// TODO: Temporary, remove once implemented properly
+class DummyScene: public Scene1xx {
+public:
+	DummyScene(MADSEngine *vm) : Scene1xx(vm) {}
+
+	virtual void setup() {}
+	virtual void enter() {}
+	virtual void step() {}
+	virtual void preActions() {}
+	virtual void actions() {}
+	virtual void synchronize(Common::Serializer &s) {}
+};
+
+} // End of namespace Phantom
+
+} // End of namespace MADS
+
+#endif /* MADS_PHANTOM_SCENES_H */


Commit: 4eba5032d817ea32e3f2f7be52826c2e40471852
    https://github.com/scummvm/scummvm/commit/4eba5032d817ea32e3f2f7be52826c2e40471852
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-04-27T21:20:02+03:00

Commit Message:
MADS: Add initial support for V2 backgrounds and hotspots

V2 games include Phantom and Dragonsphere. OUAF hasn't been tested yet

Changed paths:
    engines/mads/hotspots.cpp
    engines/mads/hotspots.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
index a5b56ee..47d8204 100644
--- a/engines/mads/hotspots.cpp
+++ b/engines/mads/hotspots.cpp
@@ -153,7 +153,7 @@ Hotspot::Hotspot() {
 	_active = false;
 }
 
-Hotspot::Hotspot(Common::SeekableReadStream &f) {
+Hotspot::Hotspot(Common::SeekableReadStream &f, bool isV2) {
 	_bounds.left = f.readSint16LE();
 	_bounds.top = f.readSint16LE();
 	_bounds.right = f.readSint16LE();
@@ -166,6 +166,11 @@ Hotspot::Hotspot(Common::SeekableReadStream &f) {
 	_cursor = (CursorType)f.readByte();
 	_vocabId = f.readUint16LE();
 	_verbId = f.readUint16LE();
+	if (isV2) {
+		// This looks to be some sort of bitmask. Perhaps it signifies
+		// the valid verbs for this hotspot
+		f.skip(2);		// unknown
+	}
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/hotspots.h b/engines/mads/hotspots.h
index bd803e8..a6b991e 100644
--- a/engines/mads/hotspots.h
+++ b/engines/mads/hotspots.h
@@ -81,7 +81,7 @@ public:
 	int _verbId;
 
 	Hotspot();
-	Hotspot(Common::SeekableReadStream &f);
+	Hotspot(Common::SeekableReadStream &f, bool isV2);
 };
 
 class Hotspots : public Common::Array<Hotspot> {
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 9f4d7d9..646106e 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -26,7 +26,9 @@
 #include "mads/compression.h"
 #include "mads/screen.h"
 #include "mads/resources.h"
+#include "mads/dragonsphere/dragonsphere_scenes.h"
 #include "mads/nebular/nebular_scenes.h"
+#include "mads/phantom/phantom_scenes.h"
 
 namespace MADS {
 
@@ -49,10 +51,12 @@ KernelMessage::KernelMessage() {
 
 /*------------------------------------------------------------------------*/
 
-void ARTHeader::load(Common::SeekableReadStream *f) {
-	// Read in dimensions of image
-	_width = f->readUint16LE();
-	_height = f->readUint16LE();
+void ARTHeader::load(Common::SeekableReadStream *f, bool isV2) {
+	if (!isV2) {
+		// Read in dimensions of image
+		_width = f->readUint16LE();
+		_height = f->readUint16LE();
+	}
 
 	// Read in palette information
 	int palCount = f->readUint16LE();
@@ -91,11 +95,18 @@ void SceneInfo::SpriteInfo::load(Common::SeekableReadStream *f) {
 /*------------------------------------------------------------------------*/
 
 SceneInfo *SceneInfo::init(MADSEngine *vm) {
-	if (vm->getGameID() == GType_RexNebular) {
+	switch (vm->getGameID()) {
+	case GType_RexNebular:
 		return new Nebular::SceneInfoNebular(vm);
-	} else {
-		error("Unknown game");
+	case GType_Dragonsphere:
+		return new Dragonsphere::SceneInfoDragonsphere(vm);
+	case GType_Phantom:
+		return new Phantom::SceneInfoPhantom(vm);
+	default:
+		error("SceneInfo: Unknown game");
 	}
+
+	return nullptr;
 }
 
 void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
@@ -116,12 +127,25 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 
 	// Read in basic data
 	Common::SeekableReadStream *infoStream = infoPack.getItemStream(0);
-	_sceneId = infoStream->readUint16LE();
+	if (_vm->getGameID() == GType_RexNebular) {
+		_sceneId = infoStream->readUint16LE();
+	} else {
+		infoStream->skip(6);	// actual scene ID (string)
+		_sceneId = sceneId;
+	}
+	
+	// TODO: The following isn't quite right for V2 games (it's all 0)
 	_artFileNum = infoStream->readUint16LE();
 	_depthStyle = infoStream->readUint16LE();
 	_width = infoStream->readUint16LE();
 	_height = infoStream->readUint16LE();
 
+	// HACK for V2 games (for now)
+	if (_vm->getGameID() != GType_RexNebular && _width == 0) {
+		_width = 320;
+		_height = 156;
+	}
+
 	infoStream->skip(24);
 
 	int nodeCount = infoStream->readUint16LE();
@@ -157,12 +181,15 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 
 	// Load in sprite draw information
 	Common::Array<SpriteInfo> spriteInfo;
-	for (int i = 0; i < 50; ++i) {
-		SpriteInfo info;
-		info.load(infoStream);
-
-		if (i < spriteInfoCount)
-			spriteInfo.push_back(info);
+	// TODO: The following isn't quite right for V2 games
+	if (_vm->getGameID() == GType_RexNebular) {
+		for (int i = 0; i < 50; ++i) {
+			SpriteInfo info;
+			info.load(infoStream);
+
+			if (i < spriteInfoCount)
+				spriteInfo.push_back(info);
+		}
 	}
 	delete infoStream;
 
@@ -179,16 +206,67 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 		depthSurface.setSize(width, height);
 	}
 
-	// Load the depth surface with the scene codes
-	Common::SeekableReadStream *depthStream = infoPack.getItemStream(variant + 1);
-	loadCodes(depthSurface, depthStream);
-	delete depthStream;
+	if (_vm->getGameID() == GType_RexNebular) {
+		// Load the depth surface with the scene codes
+		Common::SeekableReadStream *depthStream = infoPack.getItemStream(variant + 1);
+		loadCodes(depthSurface, depthStream);
+		delete depthStream;
+	}
 
 	infoFile.close();
 
+	if (_vm->getGameID() == GType_RexNebular) {
+		loadMadsV1Background(sceneId, resName, flags, bgSurface);
+		loadPalette(sceneId, _artFileNum, resName, flags, bgSurface);
+	} else {
+		loadMadsV2Background(sceneId, resName, flags, bgSurface);
+		loadPalette(sceneId, sceneId, resName, flags, bgSurface);
+	}
+
+	Common::Array<SpriteAsset *> spriteSets;
+	Common::Array<int> usageList;
+
+	if (flags & 1) {
+		for (uint i = 0; i < setNames.size(); ++i) {
+			Common::String setResName;
+			if (sceneFlag || resName.hasPrefix("*"))
+				setResName += "*";
+			setResName += setNames[i];
+
+			SpriteAsset *sprites = new SpriteAsset(_vm, setResName, flags);
+			spriteSets.push_back(sprites);
+			usageList.push_back(sprites->_usageIndex); 
+		}
+	}
+
+	_vm->_palette->_paletteUsage.updateUsage(usageList, _usageIndex);
+
+	for (uint i = 0; i < spriteInfo.size(); ++i) {
+		SpriteInfo &si = spriteInfo[i];
+		SpriteAsset *asset = spriteSets[si._spriteSetIndex];
+		assert(asset && _depthStyle != 2);
+
+		asset->drawScaled(asset->getCount(), depthSurface, bgSurface,
+			si._scale, si._depth, si._position);
+	}
+
+	// Free the sprite sets
+	for (int i = (int)spriteSets.size() - 1; i >= 0; --i) {
+		warning("TODO: sub_201C8 SPRITE_SET.field_6");
+		delete spriteSets[i];
+	}
+}
+
+void SceneInfo::loadPalette(int sceneId, int artFileNum, const Common::String &resName, int flags, MSurface &bgSurface) {
+	bool sceneFlag = sceneId >= 0;
+	Common::String resourceName;
+	bool isV2 = (_vm->getGameID() != GType_RexNebular);
+	Common::String extension = !isV2 ? ".ART" : ".TT";
+	int paletteStream = !isV2 ? 0 : 2;
+
 	// Get the ART resource
 	if (sceneFlag) {
-		resourceName = Resources::formatName(RESPREFIX_RM, _artFileNum, ".ART");
+		resourceName = Resources::formatName(RESPREFIX_RM, artFileNum, extension);
 	} else {
 		resourceName = "*" + Resources::formatResource(resName, resName);
 	}
@@ -196,10 +274,10 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 	// Load in the ART header and palette
 	File artFile(resourceName);
 	MadsPack artResource(&artFile);
-	Common::SeekableReadStream *stream = artResource.getItemStream(0);
+	Common::SeekableReadStream *stream = artResource.getItemStream(paletteStream);
 
 	ARTHeader artHeader;
-	artHeader.load(stream);
+	artHeader.load(stream, isV2);
 	delete stream;
 
 	// Copy out the palette animation data
@@ -224,52 +302,137 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 		}
 	}
 
-	// Read in the background surface data
-	assert(_width == bgSurface.w && _height == bgSurface.h);
-	stream = artResource.getItemStream(1);
-	stream->read(bgSurface.getPixels(), bgSurface.w * bgSurface.h);
-
 	if (!(flags & 1)) {
 		// Translate the background to use the correct palette indexes
 		bgSurface.translate(artHeader._palette);
 	}
+}
+
+void SceneInfo::loadMadsV1Background(int sceneId, const Common::String &resName, int flags, MSurface &bgSurface) {
+	bool sceneFlag = sceneId >= 0;
+	Common::String resourceName;
+	Common::SeekableReadStream *stream;
+
+	// Get the ART resource
+	if (sceneFlag) {
+		resourceName = Resources::formatName(RESPREFIX_RM, _artFileNum, ".ART");
+	} else {
+		resourceName = "*" + Resources::formatResource(resName, resName);
+	}
+
+	// Load in the ART data
+	File artFile(resourceName);
+	MadsPack artResource(&artFile);
+
+	// Read in the background surface data
+	assert(_width == bgSurface.w && _height == bgSurface.h);
+	stream = artResource.getItemStream(1);
+	stream->read(bgSurface.getPixels(), bgSurface.w * bgSurface.h);
 
 	// Close the ART file
 	delete stream;
 	artFile.close();
+}
 
-	Common::Array<SpriteAsset *> spriteSets;
-	Common::Array<int> usageList;
-
-	if (flags & 1) {
-		for (uint i = 0; i < setNames.size(); ++i) {
-			Common::String setResName;
-			if (sceneFlag || resName.hasPrefix("*"))
-				setResName += "*";
-			setResName += setNames[i];
-
-			SpriteAsset *sprites = new SpriteAsset(_vm, setResName, flags);
-			spriteSets.push_back(sprites);
-			usageList.push_back(sprites->_usageIndex); 
-		}
+void SceneInfo::loadMadsV2Background(int sceneId, const Common::String &resName, int flags, MSurface &bgSurface) {
+	Common::String tileMapResourceName = Resources::formatName(RESPREFIX_RM, sceneId, ".MM");
+	File tileMapFile(tileMapResourceName);
+	MadsPack tileMapPack(&tileMapFile);
+	Common::SeekableReadStream *mapStream = tileMapPack.getItemStream(0);
+
+	// Get the details of the tiles and map
+	mapStream->readUint32LE();
+	int tileCountX = mapStream->readUint16LE();
+	int tileCountY = mapStream->readUint16LE();
+	int tileWidthMap = mapStream->readUint16LE();
+	int tileHeightMap = mapStream->readUint16LE();
+	int screenWidth = mapStream->readUint16LE();
+	int screenHeight = mapStream->readUint16LE();
+	int tileCountMap = tileCountX * tileCountY;
+	delete mapStream;
+
+	// Obtain tile map information
+	typedef Common::List<Common::SharedPtr<MSurface> > TileSetList;
+	typedef TileSetList::iterator TileSetIterator;
+	TileSetList tileSet;
+	uint16 *tileMap = new uint16[tileCountMap];
+	mapStream = tileMapPack.getItemStream(1);
+	for (int i = 0; i < tileCountMap; ++i)
+		tileMap[i] = mapStream->readUint16LE();
+	delete mapStream;
+	tileMapFile.close();
+
+	// --------------------------------------------------------------------------------
+
+	// Tile data, which needs to be kept compressed, as the tile map offsets refer to
+	// the compressed data. Each tile is then uncompressed separately
+	Common::String tileDataResourceName = Resources::formatName(RESPREFIX_RM, sceneId, ".TT");
+	File tileDataFile(tileDataResourceName);
+	MadsPack tileDataPack(&tileDataFile);
+	Common::SeekableReadStream *tileDataUncomp = tileDataPack.getItemStream(0);
+
+	// Validate that the data matches between the tiles and tile map file and is valid
+	int tileCount = tileDataUncomp->readUint16LE();
+	int tileWidth = tileDataUncomp->readUint16LE();
+	int tileHeight = tileDataUncomp->readUint16LE();
+	delete tileDataUncomp;
+	assert(tileCountMap == tileCount);
+	assert(tileWidth == tileWidthMap);
+	assert(tileHeight == tileHeightMap);
+	assert(screenWidth == _width);
+	assert(screenHeight <= _height);
+
+	// --------------------------------------------------------------------------------
+
+	// Get tile data
+
+	tileDataUncomp = tileDataPack.getItemStream(1);
+	FabDecompressor fab;
+	uint32 compressedTileDataSize = 0;
+
+	for (int i = 0; i < tileCount; i++) {
+		tileDataUncomp->seek(i * 4, SEEK_SET);
+		uint32 tileOfs = tileDataUncomp->readUint32LE();
+		MSurface* newTile = new MSurface(tileWidth, tileHeight);
+
+		if (i == tileCount - 1)
+			compressedTileDataSize = tileDataFile.size() - tileOfs;
+		else
+			compressedTileDataSize = tileDataUncomp->readUint32LE() - tileOfs;
+
+		//debugCN(kDebugGraphics, "Tile: %i, compressed size: %i\n", i, compressedTileDataSize);
+
+		newTile->empty();
+
+		byte *compressedTileData = new byte[compressedTileDataSize];
+
+		tileDataFile.seek(tileDataPack.getDataOffset() + tileOfs, SEEK_SET);
+		tileDataFile.read(compressedTileData, compressedTileDataSize);
+
+		fab.decompress(compressedTileData, compressedTileDataSize, (byte*)newTile->getPixels(), tileWidth * tileHeight);
+		tileSet.push_back(TileSetList::value_type(newTile));
+		delete[] compressedTileData;
 	}
 
-	_vm->_palette->_paletteUsage.updateUsage(usageList, _usageIndex);
+	delete tileDataUncomp;
 
-	for (uint i = 0; i < spriteInfo.size(); ++i) {
-		SpriteInfo &si = spriteInfo[i];
-		SpriteAsset *asset = spriteSets[si._spriteSetIndex];
-		assert(asset && _depthStyle != 2);
+	// --------------------------------------------------------------------------------
 
-		asset->drawScaled(asset->getCount(), depthSurface, bgSurface,
-			si._scale, si._depth, si._position);
-	}
+	// Loop through the mapping data to place the tiles on the screen
 
-	// Free the sprite sets
-	for (int i = (int)spriteSets.size() - 1; i >= 0; --i) {
-		warning("TODO: sub_201C8 SPRITE_SET.field_6");
-		delete spriteSets[i];
+	uint16 *tIndex = &tileMap[0];
+	for (int y = 0; y < tileCountY; y++) {
+		for (int x = 0; x < tileCountX; x++) {
+			int tileIndex = *tIndex++;
+			assert(tileIndex < tileCount);
+			TileSetIterator tile = tileSet.begin();
+			for (int i = 0; i < tileIndex; i++)
+				++tile;
+			((*tile).get())->copyTo(&bgSurface, Common::Point(x * tileWidth, y * tileHeight));
+		}
 	}
+	tileSet.clear();
+	tileDataFile.close();
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index d59d746..9b1825f 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -125,7 +125,7 @@ struct ARTHeader {
 	Common::Array<RGB6> _palette;
 	Common::Array<PaletteCycle> _paletteCycles;
 
-	void load(Common::SeekableReadStream *f);
+	void load(Common::SeekableReadStream *f, bool isV2);
 };
 
 /**
@@ -177,23 +177,38 @@ public:
 	static SceneInfo *init(MADSEngine *vm);
 
 	/**
-	 loads the data
+	 * loads the data
 	 */
 	void load(int sceneId, int variant, const Common::String &resName, int flags, 
 		MSurface &depthSurface, MSurface &bgSurface);
 
 	/**
-	* Loads the given surface with depth information of a given scene
-	* @param depthSurface	Depth/walk surface
-	* @param variant		Variant number to load
-	*/
+	 * Loads the palette for a scene
+	 */
+	void loadPalette(int sceneId, int artFileNum, const Common::String &resName, int flags, MSurface &bgSurface);
+
+	/**
+	 * Loads a V1 game background
+	 */
+	void loadMadsV1Background(int sceneId, const Common::String &resName, int flags, MSurface &bgSurface);
+
+	/**
+	 * Loads a V2 game background
+	 */
+	void loadMadsV2Background(int sceneId, const Common::String &resName, int flags, MSurface &bgSurface);
+
+	/**
+	 * Loads the given surface with depth information of a given scene
+	 * @param depthSurface	Depth/walk surface
+	 * @param variant		Variant number to load
+	 */
 	virtual void loadCodes(MSurface &depthSurface, int variant) = 0;
 
 	/**
-	* Loads the given surface with depth information of a given scene
-	* @param depthSurface	Depth/walk surface
-	* @param stream			Stream to load the data from
-	*/
+	 * Loads the given surface with depth information of a given scene
+	 * @param depthSurface	Depth/walk surface
+	 * @param stream		Stream to load the data from
+	 */
 	virtual void loadCodes(MSurface &depthSurface, Common::SeekableReadStream *stream) = 0;
 };
 


Commit: 16bbc100ddf15da2c321bf54cf1f66f580dcdc93
    https://github.com/scummvm/scummvm/commit/16bbc100ddf15da2c321bf54cf1f66f580dcdc93
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-04-27T21:20:02+03:00

Commit Message:
MADS: Handle the missing sections in Phantom and Dragonsphere

Changed paths:
    engines/mads/resources.cpp



diff --git a/engines/mads/resources.cpp b/engines/mads/resources.cpp
index aef22d3..b6caed7 100644
--- a/engines/mads/resources.cpp
+++ b/engines/mads/resources.cpp
@@ -60,7 +60,7 @@ private:
 	/**
 	 * Load the index of all the game's HAG files
 	 */
-	void loadIndex();
+	void loadIndex(MADSEngine *vm);
 
 	/**
 	 * Given a resource name, opens up the correct HAG file and returns whether
@@ -78,7 +78,7 @@ private:
 	 */
 	ResourceType getResourceType(const Common::String &resourceName) const;
 public:
-	HagArchive();
+	HagArchive(MADSEngine *vm);
 	virtual ~HagArchive();
 
 	// Archive implementation
@@ -90,8 +90,8 @@ public:
 
 const char *const MADSCONCAT_STRING = "MADSCONCAT";
 
-HagArchive::HagArchive() {
-	loadIndex();
+HagArchive::HagArchive(MADSEngine *vm) {
+	loadIndex(vm);
 }
 
 HagArchive::~HagArchive() {
@@ -146,13 +146,25 @@ Common::SeekableReadStream *HagArchive::createReadStreamForMember(const Common::
 	return nullptr;
 }
 
-void HagArchive::loadIndex() {
+void HagArchive::loadIndex(MADSEngine *vm) {
 	Common::File hagFile;
 
 	for (int sectionIndex = -1; sectionIndex < 10; ++sectionIndex) {
 		if (sectionIndex == 0)
 			continue;
 
+		// Dragonsphere does not have some sections - skip them
+		if (vm->getGameID() == GType_Dragonsphere)  {
+			if (sectionIndex == 7 || sectionIndex == 8)
+				continue;
+		}
+
+		// Phantom does not have some sections - skip them
+		if (vm->getGameID() == GType_Phantom)  {
+			if (sectionIndex == 6 || sectionIndex == 7 || sectionIndex == 8)
+				continue;
+		}
+
 		Common::String filename = (sectionIndex == -1) ? "GLOBAL.HAG" :
 			Common::String::format("SECTION%d.HAG", sectionIndex);
 		if (!hagFile.open(filename))
@@ -275,7 +287,7 @@ ResourceType HagArchive::getResourceType(const Common::String &resourceName) con
 /*------------------------------------------------------------------------*/
 
 void Resources::init(MADSEngine *vm) {
-	SearchMan.add("HAG", new HagArchive());
+	SearchMan.add("HAG", new HagArchive(vm));
 }
 
 Common::String Resources::formatName(RESPREFIX resType, int id, const Common::String &ext) {


Commit: 9c30f3e0734271a2a259c1dc75202cef88f370f3
    https://github.com/scummvm/scummvm/commit/9c30f3e0734271a2a259c1dc75202cef88f370f3
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-04-27T21:20:02+03:00

Commit Message:
MADS: Hook up the new skeleton scene logic for Phantom and Dragonsphere

Also, add a HACK to stub out the sprite refresh code for these games,
as sprites aren't loaded yet

Changed paths:
    engines/mads/scene.cpp



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 9217be6..545ee03 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -24,7 +24,9 @@
 #include "mads/scene.h"
 #include "mads/compression.h"
 #include "mads/mads.h"
+#include "mads/dragonsphere/dragonsphere_scenes.h"
 #include "mads/nebular/nebular_scenes.h"
+#include "mads/phantom/phantom_scenes.h"
 
 namespace MADS {
 
@@ -113,8 +115,14 @@ void Scene::loadSceneLogic() {
 	case GType_RexNebular:
 		_sceneLogic = Nebular::SceneFactory::createScene(_vm);
 		break;
+	case GType_Dragonsphere:
+		_sceneLogic = Dragonsphere::SceneFactory::createScene(_vm);
+		break;
+	case GType_Phantom:
+		_sceneLogic = Phantom::SceneFactory::createScene(_vm);
+		break;
 	default:
-		error("Unknown game");
+		error("Scene logic: Unknown game");
 	}
 }
 
@@ -185,6 +193,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 void Scene::loadHotspots() {
 	File f(Resources::formatName(RESPREFIX_RM, _currentSceneId, ".HH"));
 	MadsPack madsPack(&f);
+	bool isV2 = (_vm->getGameID() != GType_RexNebular);
 
 	Common::SeekableReadStream *stream = madsPack.getItemStream(0);
 	int count = stream->readUint16LE();
@@ -193,7 +202,7 @@ void Scene::loadHotspots() {
 	stream = madsPack.getItemStream(1);
 	_hotspots.clear();
 	for (int i = 0; i < count; ++i)
-		_hotspots.push_back(Hotspot(*stream));
+		_hotspots.push_back(Hotspot(*stream, isV2));
 
 	delete stream;
 	f.close();
@@ -467,6 +476,19 @@ void  Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
 	// Copy background for the dirty areas to the screen
 	_dirtyAreas.copy(&_backgroundSurface, &_vm->_screen, _posAdjust);
 
+	// TODO: Remove this HACK when sprites are implemented for V2 games
+	if (_vm->getGameID() != GType_RexNebular) {
+		if (transitionType) {
+			// Fading in the screen
+			_vm->_screen.transition(transitionType, surfaceFlag);
+			_vm->_sound->startQueuedCommands();
+		} else {
+			// Copy dirty areas to the screen
+			_dirtyAreas.copyToScreen(_vm->_screen._offset);
+		}
+		return;
+	}
+
 	// Handle dirty areas for foreground objects
 	_spriteSlots.setDirtyAreas();
 	_textDisplay.setDirtyAreas2();


Commit: 87ad5a8397cc332c6e3580725df39925eb5b66c5
    https://github.com/scummvm/scummvm/commit/87ad5a8397cc332c6e3580725df39925eb5b66c5
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-04-27T21:20:02+03:00

Commit Message:
MADS: Add a HACK to reuse the Nebular dialog class for now for V2 games

There aren't any dialogs shown yet for these games, we just reuse the
implemented class to avoid crashes when it's initialized

Changed paths:
    engines/mads/dialogs.cpp



diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index 3c771e7..519b273 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -362,7 +362,10 @@ Dialogs *Dialogs::init(MADSEngine *vm) {
 	if (vm->getGameID() == GType_RexNebular)
 		return new Nebular::DialogsNebular(vm);
 
-	error("Unknown game");
+	// Throw a warning for now, since the associated Dialogs class isn't implemented yet
+	warning("Dialogs: Unknown game");
+	// HACK: Reuse the implemented Nebular dialogs for now, to avoid crashing later on
+	return new Nebular::DialogsNebular(vm);
 }
 
 Dialogs::Dialogs(MADSEngine *vm): _vm(vm) {


Commit: 027a2f3710b05fcefc5135ad9a2b562f7c1ab50c
    https://github.com/scummvm/scummvm/commit/027a2f3710b05fcefc5135ad9a2b562f7c1ab50c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-04-27T21:20:03+03:00

Commit Message:
MADS: Disable the hotspot description code for V2 games

This doesn't quite work yet, and it causes crashes, thus it has been
disabled for now for these games

Changed paths:
    engines/mads/user_interface.cpp



diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index d4ab0d3..194fda0 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -704,12 +704,15 @@ void UserInterface::loadElements() {
 			CAT_INV_ANIM, 0);
 	}
 
-	if (_vm->_game->_screenObjects._inputMode == kInputBuildingSentences || 
-			_vm->_game->_screenObjects._inputMode == kInputLimitedSentences) {
-		_categoryIndexes[CAT_HOTSPOT - 1] = _vm->_game->_screenObjects.size() + 1;
-		for (int hotspotIdx = scene._hotspots.size() - 1; hotspotIdx >= 0; --hotspotIdx) {
-			Hotspot &hs = scene._hotspots[hotspotIdx];
-			_vm->_game->_screenObjects.add(hs._bounds, LAYER_GUI, CAT_HOTSPOT, hotspotIdx);
+	// TODO: Implement for V2 games
+	if (_vm->getGameID() == GType_RexNebular) {
+		if (_vm->_game->_screenObjects._inputMode == kInputBuildingSentences || 
+				_vm->_game->_screenObjects._inputMode == kInputLimitedSentences) {
+			_categoryIndexes[CAT_HOTSPOT - 1] = _vm->_game->_screenObjects.size() + 1;
+			for (int hotspotIdx = scene._hotspots.size() - 1; hotspotIdx >= 0; --hotspotIdx) {
+				Hotspot &hs = scene._hotspots[hotspotIdx];
+				_vm->_game->_screenObjects.add(hs._bounds, LAYER_GUI, CAT_HOTSPOT, hotspotIdx);
+			}
 		}
 	}
 


Commit: 29234dc34d12e0f5fc28819bef34d394d3143b4b
    https://github.com/scummvm/scummvm/commit/29234dc34d12e0f5fc28819bef34d394d3143b4b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-04-27T22:54:57+03:00

Commit Message:
MADS: Remove the unused GType_Riddle game ID (it's an M4 game)

Changed paths:
    engines/mads/mads.h



diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index 5ae8b8e..d6a2a84 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -63,8 +63,7 @@ enum MADSDebugChannels {
 enum {
 	GType_RexNebular = 0,
 	GType_Dragonsphere = 1,
-	GType_Phantom = 2,
-	GType_Riddle = 3
+	GType_Phantom = 2
 };
 
 enum ScreenFade {


Commit: 6c9075eb2539aa4264ce4298772437caec55b256
    https://github.com/scummvm/scummvm/commit/6c9075eb2539aa4264ce4298772437caec55b256
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-04-27T22:56:15+03:00

Commit Message:
MADS: Implement the audio player

This is used for all digital samples, plus voices in talkie versions.
Currently, it's only hooked to the "play_audio" debugger command

Changed paths:
  A engines/mads/audio.cpp
  A engines/mads/audio.h
    engines/mads/debugger.cpp
    engines/mads/debugger.h
    engines/mads/game.h
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/module.mk



diff --git a/engines/mads/audio.cpp b/engines/mads/audio.cpp
new file mode 100644
index 0000000..0a9637b
--- /dev/null
+++ b/engines/mads/audio.cpp
@@ -0,0 +1,129 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 "mads/audio.h"
+#include "mads/compression.h"
+
+#include "common/stream.h"
+#include "audio/audiostream.h"
+#include "audio/mixer.h"
+#include "audio/decoders/raw.h"
+
+namespace MADS {
+
+AudioPlayer::AudioPlayer(Audio::Mixer *mixer, uint32 gameID) : _mixer(mixer), _gameID(gameID) {
+	setVolume(Audio::Mixer::kMaxChannelVolume);
+	setDefaultSoundGroup();
+}
+
+AudioPlayer::~AudioPlayer() {
+	_dsrEntries.clear();
+}
+
+bool AudioPlayer::isPlaying() const {
+	return _mixer->isSoundHandleActive(_handle);
+}
+
+void AudioPlayer::setVolume(int volume) {
+	_mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, volume);
+	_mixer->setVolumeForSoundType(Audio::Mixer::kSpeechSoundType, volume);
+}
+
+void AudioPlayer::setDefaultSoundGroup() {
+	switch (_gameID) {
+	case GType_RexNebular:
+		setSoundGroup("rex009.dsr");
+		break;
+	case GType_Dragonsphere:
+		setSoundGroup("drag009.dsr");
+		break;
+	case GType_Phantom:
+		setSoundGroup("phan009.dsr");
+		break;
+	default:
+		error("setDefaultSoundGroup: Unknown game");
+	}
+}
+
+void AudioPlayer::setSoundGroup(const Common::String &filename) {
+	_dsrEntries.clear();
+
+	_filename = filename;
+	_dsrFile.open(filename);
+
+	// Read header
+	uint16 entryCount = _dsrFile.readUint16LE();
+
+	for (uint16 i = 0; i < entryCount; i++) {
+		DSREntry newEntry;
+		newEntry.frequency = _dsrFile.readUint16LE();
+		newEntry.channels = _dsrFile.readUint32LE();
+		newEntry.compSize = _dsrFile.readUint32LE();
+		newEntry.uncompSize = _dsrFile.readUint32LE();
+		newEntry.offset = _dsrFile.readUint32LE();
+		_dsrEntries.push_back(newEntry);
+	}
+
+	_dsrFile.close();
+}
+
+void AudioPlayer::playSound(int soundIndex, bool loop) {
+	if (_dsrEntries.empty()) {
+		warning("DSR file not loaded, not playing sound");
+		return;
+	}
+
+	if (soundIndex < 0 || soundIndex > _dsrEntries.size() - 1) {
+		warning("Invalid sound index: %i (max %i), not playing sound", soundIndex, _dsrEntries.size() - 1);
+		return;
+	}
+
+	// Get sound data
+	FabDecompressor fab;
+	int32 compSize = _dsrEntries[soundIndex].compSize;
+	int32 uncompSize = _dsrEntries[soundIndex].uncompSize;
+	int32 offset = _dsrEntries[soundIndex].offset;
+	int16 frequency = _dsrEntries[soundIndex].frequency;
+	byte *compData = new byte[compSize];
+	byte *buffer = new byte[uncompSize];
+	_dsrFile.open(_filename);
+	_dsrFile.seek(offset, SEEK_SET);
+	_dsrFile.read(compData, compSize);
+	_dsrFile.close();
+
+	fab.decompress(compData, compSize, buffer, uncompSize);
+
+	// Play sound
+	Audio::AudioStream *stream = Audio::makeLoopingAudioStream(
+				Audio::makeRawStream(buffer, uncompSize, frequency, Audio::FLAG_UNSIGNED),
+				loop ? 0 : 1);
+	_mixer->playStream(Audio::Mixer::kSFXSoundType, &_handle, stream, -1,  Audio::Mixer::kMaxChannelVolume);
+
+	/*
+	// Dump the sound file
+	FILE *destFile = fopen("sound.raw", "wb");
+	fwrite(_dsrFile.dsrEntries[soundIndex]->data, _dsrFile.dsrEntries[soundIndex].uncompSize, 1, destFile);
+	fclose(destFile);
+	*/
+}
+
+} // End of namespace M4
diff --git a/engines/mads/audio.h b/engines/mads/audio.h
new file mode 100644
index 0000000..21f4bed
--- /dev/null
+++ b/engines/mads/audio.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_AUDIO_H
+#define MADS_AUDIO_H
+
+#include "mads/resources.h"
+
+#include "common/array.h"
+#include "audio/mixer.h"
+
+namespace MADS {
+
+struct DSREntry {
+	int16 frequency;
+	int channels;
+	int32 compSize;
+	int32 uncompSize;
+	int32 offset;
+};
+
+class AudioPlayer {
+public:
+	AudioPlayer(Audio::Mixer *mixer, uint32 gameID);
+	~AudioPlayer();
+
+	void setSoundGroup(const Common::String &filename);
+	void setDefaultSoundGroup();
+	void playSound(int soundIndex, bool loop = false);
+	void setVolume(int volume);
+	bool isPlaying() const;
+
+ private:
+	Audio::Mixer *_mixer;
+	Audio::SoundHandle _handle;
+	uint32 _gameID;
+
+	File _dsrFile;
+	Common::String _filename;
+	Common::Array<DSREntry> _dsrEntries;
+};
+
+} // End of namespace MADS
+
+#endif
diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp
index a6192b2..80a8cb7 100644
--- a/engines/mads/debugger.cpp
+++ b/engines/mads/debugger.cpp
@@ -35,6 +35,7 @@ Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) {
 	DCmd_Register("show_hotspots", WRAP_METHOD(Debugger, Cmd_ShowHotSpots));
 	DCmd_Register("list_hotspots", WRAP_METHOD(Debugger, Cmd_ListHotSpots));
 	DCmd_Register("play_sound", WRAP_METHOD(Debugger, Cmd_PlaySound));
+	DCmd_Register("play_audio", WRAP_METHOD(Debugger, Cmd_PlayAudio));
 	DCmd_Register("show_codes", WRAP_METHOD(Debugger, Cmd_ShowCodes));
 	DCmd_Register("dump_file", WRAP_METHOD(Debugger, Cmd_DumpFile));
 	DCmd_Register("show_quote", WRAP_METHOD(Debugger, Cmd_ShowQuote));
@@ -125,6 +126,24 @@ bool Debugger::Cmd_PlaySound(int argc, const char **argv) {
 	return false;
 }
 
+bool Debugger::Cmd_PlayAudio(int argc, const char **argv) {
+	if (argc < 2) {
+		DebugPrintf("Usage: %s <sound index> <sound group>\n", argv[0]);
+		DebugPrintf("If the sound group isn't defined, the default one will be used\n");
+	} else {
+		int index = strToInt(argv[1]);
+		Common::String soundGroup = (argc >= 3) ? argv[2] : "";
+		if (argc >= 3)
+			_vm->_audio->setSoundGroup(argv[2]);
+		else
+			_vm->_audio->setDefaultSoundGroup();
+
+		_vm->_audio->playSound(index);
+	}
+
+	return true;
+}
+
 bool Debugger::Cmd_ShowCodes(int argc, const char **argv) {
 	Scene &scene = _vm->_game->_scene;
 
diff --git a/engines/mads/debugger.h b/engines/mads/debugger.h
index c2d66d9..1982749 100644
--- a/engines/mads/debugger.h
+++ b/engines/mads/debugger.h
@@ -39,6 +39,7 @@ protected:
 	bool Cmd_ShowHotSpots(int argc, const char **argv);
 	bool Cmd_ListHotSpots(int argc, const char **argv);
 	bool Cmd_PlaySound(int argc, const char **argv);
+	bool Cmd_PlayAudio(int argc, const char **argv);
 	bool Cmd_ShowCodes(int argc, const char **argv);
 	bool Cmd_DumpFile(int argc, const char **argv);
 	bool Cmd_ShowQuote(int argc, const char **argv);
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 982f880..246a785 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -27,6 +27,7 @@
 #include "common/savefile.h"
 #include "common/str-array.h"
 #include "common/serializer.h"
+#include "mads/audio.h"
 #include "mads/scene.h"
 #include "mads/game_data.h"
 #include "mads/globals.h"
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index cb84f4d..29db804 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -88,6 +88,7 @@ void MADSEngine::initialise() {
 	_font = new Font();
 	_screen.init();
 	_sound = new SoundManager(this, _mixer);
+	_audio = new AudioPlayer(_mixer, getGameID());
 	_game = Game::init(this);
 
 	_screen.empty();
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index d6a2a84..61d61a2 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -98,6 +98,7 @@ public:
 	Resources *_resources;
 	ScreenSurface _screen;
 	SoundManager *_sound;
+	AudioPlayer *_audio;
 	bool _easyMouse;
 	bool _invObjectsAnimated;
 	bool _textWindowStill;
diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index e5b9efe..9d58579 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -17,6 +17,7 @@ MODULE_OBJS := \
 	action.o \
 	animation.o \
 	assets.o \
+	audio.o \
 	compression.o \
 	debugger.o \
 	detection.o \


Commit: 83a1ce6e29fdc0f5a51bc7d912b227f40eacd164
    https://github.com/scummvm/scummvm/commit/83a1ce6e29fdc0f5a51bc7d912b227f40eacd164
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-04-28T03:02:07+03:00

Commit Message:
MADS: Implement scene 366

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index fe915ed..278a262 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -148,6 +148,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene359(vm);
 	case 360:
 		return new Scene360(vm);
+	case 366:
+		return new Scene366(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 1213cd8..2368e0b 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -4800,5 +4800,38 @@ void Scene360::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene366::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene366::enter() {
+	_scene->_userInterface.setup(kInputLimitedSentences);
+	_game._player._visible = false;
+	sceneEntrySound();
+}
+
+void Scene366::actions() {
+	if (_action.isAction(0x2D5, 0x2D4))
+		_scene->_nextSceneId = 302;
+	else if (_action.isAction(VERB_OPEN, 0x2D3)) {
+		if (_game._visitedScenes.exists(316))
+			_vm->_dialogs->show(0x8F04);	// 366, 12
+		else
+			_vm->_dialogs->show(0x8F05);	// 366, 13
+		_scene->_nextSceneId = 316;
+	} else if (_action.isAction(0xD3, 0x2D3)) {
+		if (_game._visitedScenes.exists(321))
+			_vm->_dialogs->show(0x8F03);	// 366, 11
+		else
+			_vm->_dialogs->show(0x8F02);	// 366, 10
+	} else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 7f2996e..84cf4ce 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -461,6 +461,19 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene366: public Scene3xx {
+public:
+	Scene366(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions() {}
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 1e3061d3bb5a6df2b2daf379af67d45bf313fbc3
    https://github.com/scummvm/scummvm/commit/1e3061d3bb5a6df2b2daf379af67d45bf313fbc3
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-04-28T03:30:33+03:00

Commit Message:
MADS: Bugfixes for Nebular scene 102

This fixes the binoculars, the refrigerator and partly fixes the
ladder/hatchway

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 54db1d3..ab1b2d1 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -654,7 +654,7 @@ void Scene102::enter() {
 	_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 4, 0, 1, 0);
 	_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 3, 0, 0, 5);
 
-	if (!_game._objects.isInRoom(OBJ_BINOCULARS))
+	if (_game._objects.isInRoom(OBJ_BINOCULARS))
 		_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 24, 0, 0, 24);
 	else
 		_scene->_hotspots.activate(0x27, false);
@@ -798,7 +798,7 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(0x122) && !_fridgeOpenedFl) {
+	if (_action._activeAction._objectNameId == 0x122 && !_fridgeOpenedFl) {
 		switch (_game._trigger) {
 		case 0:
 			_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 6, 1, 0, 0);
@@ -970,7 +970,7 @@ void Scene102::actions() {
 		return;
 	}
 
-	if ((_action.isAction(0xC7) || _action.isAction(0xA3)) && (_action.isAction(VERB_LOOK) || _action.isAction(0x50) || _action.isAction(0x4F))) {
+	if ((_action._activeAction._objectNameId == 0xC7 || _action._activeAction._objectNameId == 0xA3) && (_action.isAction(VERB_LOOK) || _action.isAction(0x50) || _action.isAction(0x4F))) {
 		if (_game._objects.isInInventory(OBJ_REBREATHER)) {
 			if (!_action.isAction(0x50) && !_action.isAction(0x4F)) {
 				_vm->_dialogs->show(0x27F7);
@@ -984,7 +984,7 @@ void Scene102::actions() {
 		}
 	}
 
-	if ( (_action.isAction(0xC7) || _action.isAction(0xA3)) && (_action.isAction(0x50) || _action.isAction(0x4F)) ) {
+	if ((_action._activeAction._objectNameId == 0xC7 || _action._activeAction._objectNameId == 0xA3) && (_action.isAction(0x50) || _action.isAction(0x4F)) ) {
 		switch (_game._trigger) {
 		case 0:
 			_scene->loadAnimation(formAnimName('A', -1), 1);


Commit: 5bb66bdd5b2adc0c11da235ddcf02966f38c4411
    https://github.com/scummvm/scummvm/commit/5bb66bdd5b2adc0c11da235ddcf02966f38c4411
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-28T07:07:56+02:00

Commit Message:
MADS: Implement case 361

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 278a262..31d139d 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -148,6 +148,9 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene359(vm);
 	case 360:
 		return new Scene360(vm);
+	case 361:
+		return new Scene361(vm);
+
 	case 366:
 		return new Scene366(vm);
 
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 2368e0b..1d5867e 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -4800,6 +4800,390 @@ void Scene360::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene361::setup() {
+	if (_scene->_currentSceneId == 391)
+		_globals[kSexOfRex] = REX_MALE;
+
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene361::handleRexAction() {
+	switch (_game._trigger) {
+	case 0:
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 50, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 3, -2);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
+
+		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 15, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, 4);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+		break;
+
+	case 1: {
+		int seqIdx = _globals._sequenceIndexes[1];
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 4);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[1], seqIdx);
+		}
+		break;
+
+	case 2: {
+		int seqIdx = _globals._sequenceIndexes[2];
+		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 4, 10);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], seqIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+		}
+		break;
+
+	case 3: {
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 3);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+
+		int seqIdx = _globals._sequenceIndexes[2];
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 11);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(167, 100));
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], seqIdx);
+		_scene->_sequences.addTimer(15, 4);
+		}
+		break;
+
+	case 4:
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 2);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+
+		_scene->_sequences.setDone(_globals._sequenceIndexes[2]);
+		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 12, 14);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(167, 100));
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 5);
+		break;
+
+	case 5: {
+		int seqIdx = _globals._sequenceIndexes[2];
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 15);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(167, 100));
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], seqIdx);
+		_scene->_sequences.addTimer(15, 6);
+		}
+		break;
+
+	case 6:
+		_scene->_sequences.setDone(_globals._sequenceIndexes[2]);
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+		_scene->_sequences.addTimer(48, 7);
+		break;
+
+	case 7:
+		_scene->_nextSceneId = 313;
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene361::handleRoxAction() {
+	switch (_game._trigger) {
+	case 0:
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 18, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 2, 4);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
+
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 18, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], -1, 3);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+		break;
+
+	case 1: {
+		int tmpIdx = _globals._sequenceIndexes[1];
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 4);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[1], tmpIdx);
+		}
+		break;
+
+	case 2: {
+		int tmpIdx = _globals._sequenceIndexes[4];
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 4, 8);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], tmpIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+		}
+		break;
+
+	case 3: {
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 3);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+
+		int tmpIdx = _globals._sequenceIndexes[4];
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 9, 10);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(167, 100));
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], tmpIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 4);
+		}
+		break;
+
+	case 4: {
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 2);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+
+		int tmpIdx = _globals._sequenceIndexes[4];
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 11, 15);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(167, 100));
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], tmpIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 5);
+		}
+		break;
+
+	case 5: {
+		int tmpIdx = _globals._sequenceIndexes[4];
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 16);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(167, 100));
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], tmpIdx);
+		_scene->_sequences.addTimer(48, 6);
+		}
+		break;
+
+	case 6:
+		_scene->_sequences.setDone(_globals._sequenceIndexes[4]);
+
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+		_scene->_sequences.addTimer(48, 7);
+		break;
+
+	case 7:
+		_scene->_nextSceneId = 313;
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene361::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(Resources::formatName(307, 'X', 0, EXT_SS, ""));
+
+	if (_globals[kSexOfRex] == REX_MALE) {
+		_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RXCL_8");
+		_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RXCL_2");
+	} else
+		_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*ROXCL_8");
+
+	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
+
+	if (_scene->_priorSceneId == 391) {
+		_globals[kSexOfRex] = REX_MALE;
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_game._player._facing = FACING_SOUTH;
+		_game._player._playerPos = Common::Point(166, 101);
+		_scene->_sequences.addTimer(120, 70);
+	} else if (_scene->_priorSceneId == 360)
+		_game._player._playerPos = Common::Point(302, 145);
+	else if (_scene->_priorSceneId == 320) {
+		_game._player._playerPos = Common::Point(129, 113);
+		_game._player._facing = FACING_SOUTH;
+	} else if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(13, 145);
+
+	_game.loadQuoteSet(0xFB, 0xFC, 0);
+
+	if (_scene->_priorSceneId == 320)
+		_scene->_kernelMessages.setQuoted(_scene->_kernelMessages.addQuote(0xFB, 0, 0x78), 4, true);
+
+	sceneEntrySound();
+}
+
+void Scene361::step() {
+	if (_game._trigger >= 70) {
+		switch (_game._trigger) {
+		case 70:
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 2);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addTimer(15, 71);
+			break;
+
+		case 71:
+			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addTimer(15, 72);
+			break;
+
+		case 72:
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 3);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+
+			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 3);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addTimer(15, 73);
+			break;
+
+		case 73:
+			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 4, 5);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 74);
+			break;
+
+		case 74: {
+			int seqIdx = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 6);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], seqIdx);
+			_scene->_sequences.addTimer(15, 75);
+			}
+			break;
+
+		case 75:
+			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 7);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addTimer(15, 76);
+			break;
+
+		case 76:
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 2);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+
+			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 8);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addTimer(15, 77);
+			break;
+
+		case 77:
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
+
+			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 9);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addTimer(15, 78);
+			break;
+
+		case 78:
+			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 10, -2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 79);
+			break;
+
+		case 79:
+			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[3]);
+			_game._player._stepEnabled = true;
+			_game._player._visible = true;
+			break;
+
+		default:
+			break;
+		}
+	}
+}
+
+void Scene361::preActions() {
+	if (_action.isAction(0x1AD, 0x2B9))
+		_game._player._walkOffScreenSceneId = 360;
+
+	if (_action.isAction(0x1AD, 0x2BA))
+		_game._player._walkOffScreenSceneId = 354;
+}
+
+void Scene361::actions() {
+	if (_action._lookFlag)
+		_vm->_dialogs->show(0x8D17);
+	else if (_action.isAction(0x21F, 0x1E4)) {
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.addQuote(0xFC, 120, 0);
+	} else if (_action.isAction(0x2F7, 0x11)) {
+		if (_globals[kSexOfRex] == REX_FEMALE)
+			handleRoxAction();
+		else
+			handleRexAction();
+	} else if (_action.isAction(VERB_LOOK, 0x1E4))
+		_vm->_dialogs->show(0x8D0E);
+	else if (_action.isAction(VERB_LOOK, 0x18D))
+		_vm->_dialogs->show(0x8D0F);
+	else if (_action.isAction(VERB_LOOK, 0x220) || _action.isAction(0x155, 0x220))
+		_vm->_dialogs->show(0x8D10);
+	else if (_action.isAction(VERB_LOOK, 0x208) || _action.isAction(0x155, 0x208))
+		_vm->_dialogs->show(0x8D11);
+	else if (_action.isAction(VERB_TAKE, 0x208))
+		_vm->_dialogs->show(0x8D12);
+	else if (_action.isAction(VERB_LOOK, 0x2F8) || _action.isAction(0x155, 0x2F8))
+		_vm->_dialogs->show(0x8D13);
+	else if (_action.isAction(VERB_TAKE, 0x2F8))
+		_vm->_dialogs->show(0x8D14);
+	else if (_action.isAction(VERB_LOOK, 0x2BA))
+		_vm->_dialogs->show(0x8D15);
+	else if (_action.isAction(VERB_LOOK, 0x2B9))
+		_vm->_dialogs->show(0x8D16);
+	else if (_action.isAction(VERB_LOOK, 0x11))
+		_vm->_dialogs->show(0x8D18);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene366::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 84cf4ce..b2819d5 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -462,6 +462,22 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene361: public Scene3xx {
+private:
+	void handleRexAction();
+	void handleRoxAction();
+
+public:
+	Scene361(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 class Scene366: public Scene3xx {
 public:
 	Scene366(MADSEngine *vm) : Scene3xx(vm) {}
@@ -474,6 +490,7 @@ public:
 	virtual void postActions() {};
 };
 
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 464627f0432d6038ee6afd6af632a8a34d1d89d8
    https://github.com/scummvm/scummvm/commit/464627f0432d6038ee6afd6af632a8a34d1d89d8
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-28T07:08:23+02:00

Commit Message:
MADS: Fix a couple of warnings

Changed paths:
    engines/mads/audio.cpp
    engines/mads/game_data.cpp



diff --git a/engines/mads/audio.cpp b/engines/mads/audio.cpp
index 0a9637b..1c61e13 100644
--- a/engines/mads/audio.cpp
+++ b/engines/mads/audio.cpp
@@ -92,7 +92,7 @@ void AudioPlayer::playSound(int soundIndex, bool loop) {
 		return;
 	}
 
-	if (soundIndex < 0 || soundIndex > _dsrEntries.size() - 1) {
+	if (soundIndex < 0 || soundIndex > (int)_dsrEntries.size() - 1) {
 		warning("Invalid sound index: %i (max %i), not playing sound", soundIndex, _dsrEntries.size() - 1);
 		return;
 	}
diff --git a/engines/mads/game_data.cpp b/engines/mads/game_data.cpp
index 9211bbf..72137cf 100644
--- a/engines/mads/game_data.cpp
+++ b/engines/mads/game_data.cpp
@@ -47,7 +47,7 @@ bool VisitedScenes::exists(int sceneId) {
 }
 
 void VisitedScenes::synchronize(Common::Serializer &s) {
-	int count = size();
+	uint count = size();
 	int v = 0;
 	s.syncAsUint16LE(count);
 


Commit: ff7f30af9906500a53747770d0343d0d9fd4c072
    https://github.com/scummvm/scummvm/commit/ff7f30af9906500a53747770d0343d0d9fd4c072
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-28T07:20:24+02:00

Commit Message:
MADS: Implement scene 387

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 31d139d..87a7a96 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -150,9 +150,10 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene360(vm);
 	case 361:
 		return new Scene361(vm);
-
 	case 366:
 		return new Scene366(vm);
+	case 387:
+		return new Scene387(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 1d5867e..9558edb 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -5217,5 +5217,32 @@ void Scene366::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene387::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene387::enter() {
+	_scene->_userInterface.setup(kInputLimitedSentences);
+	_game._player._visible = false;
+
+	sceneEntrySound();
+}
+
+void Scene387::actions() {
+	if (_action.isAction(0x2D5, 0x2D4))
+		_scene->_nextSceneId = 313;
+	else if (_action.isAction(0xD3, 0x2D3))
+		_vm->_dialogs->show(0x9736);
+	else if (_action.isAction(VERB_OPEN, 0x2D3))
+		_vm->_dialogs->show(0x9737);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index b2819d5..24b1aef 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -490,6 +490,17 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene387: public Scene3xx {
+public:
+	Scene387(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions() {}
+	virtual void actions();
+	virtual void postActions() {};
+};
 
 } // End of namespace Nebular
 } // End of namespace MADS


Commit: 396905d90512f265fd95a87208d2295265e500e3
    https://github.com/scummvm/scummvm/commit/396905d90512f265fd95a87208d2295265e500e3
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-28T21:23:43+02:00

Commit Message:
MADS: Implement scene 388

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 87a7a96..77a7a22 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -154,6 +154,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene366(vm);
 	case 387:
 		return new Scene387(vm);
+	case 388:
+		return new Scene388(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 9558edb..4db8083 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -5244,5 +5244,68 @@ void Scene387::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene388::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene388::enter() {
+	_scene->_userInterface.setup(kInputLimitedSentences);
+
+	if (_globals[kAfterHavoc])
+		_scene->_hotspots.activate(0x303, false);
+	else {
+		_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('b', 0));
+		_globals._sequenceIndexes[0] = _scene->_sequences.startCycle(_globals._spriteIndexes[0], false, 1);
+	}
+
+	_game._player._visible = false;
+	_vm->_palette->setEntry(252, 63, 30, 20);
+	_vm->_palette->setEntry(253, 45, 15, 12);
+	_game.loadQuoteSet(0x154, 0x155, 0x156, 0x157, 0x158, 0);
+
+	sceneEntrySound();
+}
+
+void Scene388::actions() {
+	if (_action.isAction(0x2D5, 0x2D4))
+		_scene->_nextSceneId = 313;
+	else if (_action.isAction(VERB_TALKTO, 0x303)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(160, 136), 0x1110, 32, 1, 120, _game.getQuote(0x154));
+			break;
+
+		case 1:
+			_scene->_kernelMessages.add(Common::Point(82, 38), 0xFDFC, 0, 0, 300, _game.getQuote(0x156));
+			_scene->_kernelMessages.add(Common::Point(82, 52), 0xFDFC, 0, 0, 300, _game.getQuote(0x157));
+			_scene->_kernelMessages.add(Common::Point(82, 66), 0xFDFC, 0, 2, 300, _game.getQuote(0x158));
+			break;
+
+		case 2:
+			_game._player._stepEnabled = true;
+			_scene->_kernelMessages.add(Common::Point(160, 136), 0x1110, 32, 0, 120, _game.getQuote(0x155));
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(0xD3, 0x2D3)) {
+		if (_globals[kAfterHavoc])
+			_vm->_dialogs->show(0x979B);
+		else
+			_vm->_dialogs->show(0x979A);
+	} else if (_action.isAction(VERB_OPEN, 0x2D3))
+		_vm->_dialogs->show(0x979C);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 24b1aef..4de4fc1 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -502,6 +502,18 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene388: public Scene3xx {
+public:
+	Scene388(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions() {}
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 5be9157dce4b6ab479f76ecab4086c0ee75d7958
    https://github.com/scummvm/scummvm/commit/5be9157dce4b6ab479f76ecab4086c0ee75d7958
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-28T22:21:45+02:00

Commit Message:
MADS: Implement scene 389

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 77a7a22..d3caa19 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -156,6 +156,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene387(vm);
 	case 388:
 		return new Scene388(vm);
+	case 389:
+		return new Scene389(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 4db8083..5d84a32 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -5307,5 +5307,85 @@ void Scene388::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene389::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene389::enter() {
+	_scene->_userInterface.setup(kInputLimitedSentences);
+	_monsterTime = 0;
+	_circularQuoteId = 0x159;
+
+	if (_globals[kAfterHavoc])
+		_scene->_hotspots.activate(0x304, false);
+	else {
+		_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('m', -1));
+		_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 6, 0, 0, 0);
+		warning("TODO: sub71704(1, 88, 177, 19, 17, 0xD, 2, 0xFDFC, 0x3C, 0xF7, 0xF8, 0xF9, 0);");
+	}
+
+	_vm->_palette->setEntry(252, 63, 37, 26);
+	_vm->_palette->setEntry(253, 45, 24, 17);
+	_game._player._visible = false;
+	_game.loadQuoteSet(0xF7, 0xF8, 0xF9, 0x159, 0x15A, 0x15B, 0);
+
+	sceneEntrySound();
+}
+
+void Scene389::step() {
+	warning("TODO: sub7178C()");
+
+	if (_scene->_frameStartTime >= _monsterTime) {
+		warning("sub717B2(20, (sub7176C() << 2) + 1);");
+		_monsterTime = _scene->_frameStartTime + 2;
+	}
+}
+
+void Scene389::actions() {
+	if (_action.isAction(0x2D5, 0x2D4))
+		_scene->_nextSceneId = 313;
+	else if (_action.isAction(VERB_TALKTO, 0x304)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_scene->_kernelMessages.add(Common::Point(160, 136), 0x1110, 32, 1, 120, _game.getQuote(_circularQuoteId));
+			_circularQuoteId++;
+			if (_circularQuoteId > 0x15B)
+				_circularQuoteId = 0x159;
+
+			break;
+
+		case 1:
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(0xD3, 0x2D3)) {
+		if (_globals[kAfterHavoc]) {
+			if (_game._difficulty != DIFFICULTY_HARD) {
+				if (_game._objects[OBJ_SECURITY_CARD]._roomNumber == 359)
+					_vm->_dialogs->show(0x97FF);
+				else
+					_vm->_dialogs->show(0x9800);
+			} else
+				_vm->_dialogs->show(0x9800);
+		} else
+			_vm->_dialogs->show(0x97FE);
+	} else if (_action.isAction(VERB_OPEN, 0x2D3)) {
+		if (_globals[kAfterHavoc])
+			_vm->_dialogs->show(0x9802);
+		else
+			_vm->_dialogs->show(0x9801);
+	} else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 4de4fc1..d05c5e8 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -514,6 +514,23 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene389: public Scene3xx {
+private:
+	uint32 _monsterTime;
+
+	int _circularQuoteId;
+
+public:
+	Scene389(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {}
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 04b809a7a2fd3bfc8b7d45b8876d286fb98f7b3f
    https://github.com/scummvm/scummvm/commit/04b809a7a2fd3bfc8b7d45b8876d286fb98f7b3f
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-28T22:32:44+02:00

Commit Message:
MADS: Implement scene 390

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index d3caa19..7b9e476 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -158,6 +158,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene388(vm);
 	case 389:
 		return new Scene389(vm);
+	case 390:
+		return new Scene390(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 5d84a32..2d4022f 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -5387,5 +5387,33 @@ void Scene389::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene390::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene390::enter() {
+	_scene->_userInterface.setup(kInputLimitedSentences);
+	_game._player._visible = false;
+
+	sceneEntrySound();
+}
+
+void Scene390::actions() {
+	if (_action.isAction(0x2D5, 0x2D4))
+		_scene->_nextSceneId = 313;
+	else if (_action.isAction(0xD3, 0x2D3))
+		_vm->_dialogs->show(0x9862);
+	else if (_action.isAction(VERB_OPEN, 0x2D3))
+		_vm->_dialogs->show(0x9863);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index d05c5e8..3b997a2 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -531,6 +531,18 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene390: public Scene3xx {
+public:
+	Scene390(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions() {}
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: aac3206ec824bb6be8943c7afeff474fb0a2183f
    https://github.com/scummvm/scummvm/commit/aac3206ec824bb6be8943c7afeff474fb0a2183f
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-28T22:43:00+02:00

Commit Message:
MADS: Implement scene 391

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 7b9e476..caa72b1 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -160,6 +160,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene389(vm);
 	case 390:
 		return new Scene390(vm);
+	case 391:
+		return new Scene391(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 2d4022f..a5d37b4 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -5412,6 +5412,44 @@ void Scene390::actions() {
 	_action._inProgress = false;
 }
 
+/*------------------------------------------------------------------------*/
+
+void Scene391::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene391::enter() {
+	_scene->_userInterface.setup(kInputLimitedSentences);
+	_game._player._visible = false;
+	sceneEntrySound();
+}
+
+void Scene391::actions() {
+	if (_action.isAction(0x2D5, 0x2D4))
+		_scene->_nextSceneId = 313;
+	else if (_action.isAction(VERB_OPEN, 0x2D3)) {
+		if (_globals[kKickedIn391Grate])
+			_vm->_dialogs->show(0x98C9);
+		else {
+			_vm->_dialogs->show(0x98C8);
+			_globals[kKickedIn391Grate] = true;
+		}
+
+		if (_globals[kAfterHavoc])
+			_scene->_nextSceneId = 361;
+		else
+			_scene->_nextSceneId = 311;
+	} else if (_action.isAction(0xD3, 0x2D3)) {
+		if (_globals[kAfterHavoc])
+			_vm->_dialogs->show(0x98C7);
+		else
+			_vm->_dialogs->show(0x98C6);
+	} else
+		return;
+
+	_action._inProgress = false;
+}
 
 /*------------------------------------------------------------------------*/
 
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 3b997a2..111eade 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -543,6 +543,18 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene391: public Scene3xx {
+public:
+	Scene391(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions() {}
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: be75349346e943542dfc0f77933a771b2181ba16
    https://github.com/scummvm/scummvm/commit/be75349346e943542dfc0f77933a771b2181ba16
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-28T23:07:33+02:00

Commit Message:
MADS: Refactor a bit scene 389, implement scene 399

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index caa72b1..f012a68 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -162,6 +162,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene390(vm);
 	case 391:
 		return new Scene391(vm);
+	case 399:
+		return new Scene399(vm);
 
 	// Scene group #8
 	case 804:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index a5d37b4..62f30d2 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -5365,12 +5365,9 @@ void Scene389::actions() {
 		}
 	} else if (_action.isAction(0xD3, 0x2D3)) {
 		if (_globals[kAfterHavoc]) {
-			if (_game._difficulty != DIFFICULTY_HARD) {
-				if (_game._objects[OBJ_SECURITY_CARD]._roomNumber == 359)
-					_vm->_dialogs->show(0x97FF);
-				else
-					_vm->_dialogs->show(0x9800);
-			} else
+			if ((_game._difficulty != DIFFICULTY_HARD) && (_game._objects[OBJ_SECURITY_CARD]._roomNumber == 359))
+				_vm->_dialogs->show(0x97FF);
+			else
 				_vm->_dialogs->show(0x9800);
 		} else
 			_vm->_dialogs->show(0x97FE);
@@ -5453,5 +5450,40 @@ void Scene391::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene399::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene399::enter() {
+	_scene->_userInterface.setup(kInputLimitedSentences);
+	_game._player._visible = false;
+	sceneEntrySound();
+}
+
+void Scene399::actions() {
+	if (_action.isAction(0x2D5, 0x2D4))
+		_scene->_nextSceneId = 313;
+	else if (_action.isAction(0xD3, 0x2D3)) {
+		if (_globals[kAfterHavoc]) {
+			if ((_game._difficulty != DIFFICULTY_HARD) && (_game._objects[OBJ_SECURITY_CARD]._roomNumber == 359))
+				_vm->_dialogs->show(0x97FF);
+			else
+				_vm->_dialogs->show(0x9800);
+		} else
+			_vm->_dialogs->show(0x97FE);
+	} else if (_action.isAction(VERB_OPEN, 0x2D3)) {
+		if (_globals[kAfterHavoc])
+			_vm->_dialogs->show(0x9802);
+		else
+			_vm->_dialogs->show(0x9801);
+	} else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 111eade..45d0c9a 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -555,6 +555,17 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene399: public Scene3xx {
+public:
+	Scene399(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions() {}
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 487a9d4069281fa2bc1b4d2dcf0bb95007879884
    https://github.com/scummvm/scummvm/commit/487a9d4069281fa2bc1b4d2dcf0bb95007879884
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-29T00:01:00+02:00

Commit Message:
MADS: Add scene4xx common functions

Changed paths:
  A engines/mads/nebular/nebular_scenes4.cpp
  A engines/mads/nebular/nebular_scenes4.h
    engines/mads/module.mk
    engines/mads/nebular/nebular_scenes.cpp



diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 9d58579..5fe0c90 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -13,6 +13,7 @@ MODULE_OBJS := \
 	nebular/nebular_scenes1.o \
 	nebular/nebular_scenes2.o \
 	nebular/nebular_scenes3.o \
+	nebular/nebular_scenes4.o \
 	nebular/nebular_scenes8.o \
 	action.o \
 	animation.o \
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index f012a68..19b4f9f 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -31,6 +31,7 @@
 #include "mads/nebular/nebular_scenes1.h"
 #include "mads/nebular/nebular_scenes2.h"
 #include "mads/nebular/nebular_scenes3.h"
+#include "mads/nebular/nebular_scenes4.h"
 #include "mads/nebular/nebular_scenes8.h"
 
 namespace MADS {
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
new file mode 100644
index 0000000..da40d9b
--- /dev/null
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -0,0 +1,97 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/scene.h"
+#include "mads/nebular/nebular_scenes.h"
+#include "mads/nebular/nebular_scenes4.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+void Scene4xx::setAAName() {
+	_game._aaName = Resources::formatAAName(4);
+}
+
+void Scene4xx::setPlayerSpritesPrefix() {
+	_vm->_sound->command(5);
+	Common::String oldName = _game._player._spritesPrefix;
+
+	if ((_scene->_nextSceneId == 403) || (_scene->_nextSceneId == 409))
+		_game._player._spritesPrefix = "";
+	else if (_globals[kSexOfRex] == REX_FEMALE)
+		_game._player._spritesPrefix = "ROX";
+	else
+		_game._player._spritesPrefix = "RXM";
+
+	_game._player._scalingVelocity = true;
+
+	if (oldName != _game._player._spritesPrefix)
+		_game._player._spritesChanged = true;
+
+	_vm->_palette->setEntry(16, 10, 63, 63);
+	_vm->_palette->setEntry(17, 10, 45, 45);
+}
+
+void Scene4xx::sceneEntrySound() {
+	if (!_vm->_musicFlag) {
+		_vm->_sound->command(2);
+		return;
+	}
+
+	switch (_scene->_nextSceneId) {
+	case 401:
+		_vm->_sound->startQueuedCommands();
+		if (_scene->_priorSceneId == 402)
+			_vm->_sound->command(12, 64);
+		else
+			_vm->_sound->command(12, 1);
+		break;
+
+	case 402:
+		_vm->_sound->startQueuedCommands();
+		_vm->_sound->command(12, 127);
+		break;
+
+	case 405:
+	case 407:
+	case 409:
+	case 410:
+	case 413:
+		_vm->_sound->command(10);
+		break;
+
+	case 408:
+		_vm->_sound->command(52);
+		break;
+
+	default:
+		break;
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+} // End of namespace Nebular
+} // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes4.h b/engines/mads/nebular/nebular_scenes4.h
new file mode 100644
index 0000000..4de6c38
--- /dev/null
+++ b/engines/mads/nebular/nebular_scenes4.h
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_NEBULAR_SCENES4_H
+#define MADS_NEBULAR_SCENES4_H
+
+#include "common/scummsys.h"
+#include "mads/game.h"
+#include "mads/scene.h"
+#include "mads/nebular/nebular_scenes.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+class Scene4xx : public NebularScene {
+protected:
+	/**
+	 * Plays an appropriate sound when entering a scene
+	 */
+	void setAAName();
+
+	/**
+	 * Updates the prefix used for getting player sprites for the scene
+	 */
+	void setPlayerSpritesPrefix();
+
+	void sceneEntrySound();
+
+public:
+	Scene4xx(MADSEngine *vm) : NebularScene(vm) {}
+};
+
+} // End of namespace Nebular
+} // End of namespace MADS
+
+#endif /* MADS_NEBULAR_SCENES4_H */


Commit: ad93617aa7d9dd01a6fa6bb20e162ed916665b51
    https://github.com/scummvm/scummvm/commit/ad93617aa7d9dd01a6fa6bb20e162ed916665b51
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-04-29T04:01:49+03:00

Commit Message:
MADS: Add stubs for all of the missing Rex Nebular scenes

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 19b4f9f..8b73961 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -166,9 +166,141 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 399:
 		return new Scene399(vm);
 
+	// Scene group #4
+	case 401:
+		// TODO
+	case 402:
+		// TODO
+	case 403:
+		// TODO
+	case 405:
+		// TODO
+	case 406:
+		// TODO
+	case 407:
+		// TODO
+	case 408:
+		// TODO
+	case 409:
+		// TODO
+	case 410:
+		// TODO
+	case 411:
+		// TODO
+	case 413:
+		// TODO
+		// Fall-through for unimplemented scenes in group #4
+		error("Invalid scene %d called", scene._nextSceneId);
+
+	// Scene group #5
+	case 501:
+		// TODO
+	case 502:
+		// TODO
+	case 503:
+		// TODO
+	case 504:
+		// TODO
+	case 505:
+		// TODO
+	case 506:
+		// TODO
+	case 507:
+		// TODO
+	case 508:
+		// TODO
+	case 511:
+		// TODO
+	case 512:
+		// TODO
+	case 513:
+		// TODO
+	case 515:
+		// TODO
+	case 551:
+		// TODO
+		// Fall-through for unimplemented scenes in group #5
+		error("Invalid scene %d called", scene._nextSceneId);
+
+	// Scene group #6
+	case 601:
+		// TODO
+	case 602:
+		// TODO
+	case 603:
+		// TODO
+	case 604:
+		// TODO
+	case 605:
+		// TODO
+	case 607:
+		// TODO
+	case 608:
+		// TODO
+	case 609:
+		// TODO
+	case 610:
+		// TODO
+	case 611:
+		// TODO
+	case 612:
+		// TODO
+	case 620:
+		// TODO
+		// Fall-through for unimplemented scenes in group #6
+		error("Invalid scene %d called", scene._nextSceneId);
+
+	// Scene group #7
+	case 701:
+		// TODO
+	case 702:
+		// TODO
+	case 703:
+		// TODO
+	case 704:
+		// TODO
+	case 705:
+		// TODO
+	case 706:
+		// TODO
+	case 707:
+		// TODO
+	case 708:
+		// TODO
+	case 710:
+		// TODO
+	case 711:
+		// TODO
+	case 751:
+		// TODO
+	case 752:
+		// TODO
+		// Fall-through for unimplemented scenes in group #7
+		error("Invalid scene %d called", scene._nextSceneId);
+
 	// Scene group #8
+	case 801:
+		// TODO
+	case 802:
+		// TODO
+	case 803:
+		// TODO
+		// Fall-through for unimplemented scenes in group #8
+		error("Invalid scene %d called", scene._nextSceneId);
 	case 804:
 		return new Scene804(vm);
+	case 805:
+		// TODO
+	case 806:
+		// TODO
+	case 807:
+		// TODO
+	case 808:
+		// TODO
+	case 810:
+		// TODO
+		// Fall-through for unimplemented scenes in group #8
+		error("Invalid scene %d called", scene._nextSceneId);
 
 	default:
 		error("Invalid scene %d called", scene._nextSceneId);


Commit: 82933592ff152138a539864fde80705d391bc25e
    https://github.com/scummvm/scummvm/commit/82933592ff152138a539864fde80705d391bc25e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-28T21:33:31-04:00

Commit Message:
MADS: Fix original engine bug with highlighted hotspots between scenes

Changed paths:
    engines/mads/scene.cpp



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 545ee03..f4b2cb1 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -184,7 +184,8 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	_spritesCount = _sprites.size();
 
 	_userInterface.setup(_vm->_game->_screenObjects._inputMode);
-
+	
+	_vm->_game->_screenObjects._category = CAT_NONE;
 	_vm->_events->showCursor();
 
 	warning("TODO: inventory_anim_allocate");
@@ -608,7 +609,7 @@ void Scene::updateCursor() {
 	Player &player = _vm->_game->_player;
 
 	CursorType cursorId = CURSOR_ARROW;
-	if (_action._interAwaiting == 1 && !_vm->_events->_rightMousePressed &&
+	if (_action._interAwaiting == AWAITING_COMMAND && !_vm->_events->_rightMousePressed &&
 		_vm->_game->_screenObjects._category == CAT_HOTSPOT) {
 		int idx = _vm->_game->_screenObjects._selectedObject -
 			_userInterface._categoryIndexes[CAT_HOTSPOT - 1];


Commit: 5c56c57b96206d7cfb76398de08aeb946fd875b5
    https://github.com/scummvm/scummvm/commit/5c56c57b96206d7cfb76398de08aeb946fd875b5
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-28T21:57:05-04:00

Commit Message:
MADS: Fix class hierarchy for scene group 3

Changed paths:
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 62f30d2..12917d6 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -234,6 +234,12 @@ void Scene3xx::handleForceField(ForceField *force, int *sprites) {
 
 /*------------------------------------------------------------------------*/
 
+void Scene300s::preActions() {
+	_game._player._needToWalk = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene301::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -5200,17 +5206,18 @@ void Scene366::actions() {
 		_scene->_nextSceneId = 302;
 	else if (_action.isAction(VERB_OPEN, 0x2D3)) {
 		if (_game._visitedScenes.exists(316))
-			_vm->_dialogs->show(0x8F04);	// 366, 12
+			_vm->_dialogs->show(36612);
 		else
-			_vm->_dialogs->show(0x8F05);	// 366, 13
+			_vm->_dialogs->show(36613);
 		_scene->_nextSceneId = 316;
 	} else if (_action.isAction(0xD3, 0x2D3)) {
 		if (_game._visitedScenes.exists(321))
-			_vm->_dialogs->show(0x8F03);	// 366, 11
+			_vm->_dialogs->show(36611);
 		else
-			_vm->_dialogs->show(0x8F02);	// 366, 10
-	} else
+			_vm->_dialogs->show(36610);
+	} else {
 		return;
+	}
 
 	_action._inProgress = false;
 }
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 45d0c9a..f931dae 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -60,6 +60,15 @@ protected:
 
 public:
 	Scene3xx(MADSEngine *vm) : NebularScene(vm) {}
+
+	virtual void actions() {}
+};
+
+class Scene300s : public Scene3xx {
+public:
+	Scene300s(MADSEngine *vm) : Scene3xx(vm) {}
+
+	virtual void preActions();
 };
 
 class Scene301: public Scene3xx {
@@ -69,9 +78,6 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
-	virtual void actions() {};
-	virtual void postActions() {};
 };
 
 class Scene302: public Scene3xx {
@@ -84,9 +90,6 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
-	virtual void actions() {};
-	virtual void postActions() {};
 };
 
 class Scene303: public Scene3xx {
@@ -96,9 +99,6 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
-	virtual void actions() {};
-	virtual void postActions() {};
 };
 
 class Scene304: public Scene3xx {
@@ -111,9 +111,6 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
-	virtual void actions() {};
-	virtual void postActions() {};
 };
 
 class Scene307: public Scene3xx {
@@ -150,9 +147,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene308: public Scene3xx {
@@ -165,9 +160,6 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
-	virtual void actions() {};
-	virtual void postActions() {};
 };
 
 class Scene309: public Scene3xx {
@@ -183,9 +175,6 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
-	virtual void actions() {};
-	virtual void postActions() {};
 };
 
 class Scene310: public Scene3xx {
@@ -198,9 +187,6 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
-	virtual void actions() {};
-	virtual void postActions() {};
 };
 
 class Scene311: public Scene3xx {
@@ -213,9 +199,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene313: public Scene3xx {
@@ -224,10 +208,7 @@ public:
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene316: public Scene3xx {
@@ -243,7 +224,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene318: public Scene3xx {
@@ -279,7 +259,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene319: public Scene3xx {
@@ -306,12 +285,10 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
-class Scene320: public Scene3xx {
+class Scene320: public Scene300s {
 private:
 	void setRightView(int view);
 	void setLeftView(int view);
@@ -327,14 +304,12 @@ private:
 	int _rightItemId;
 
 public:
-	Scene320(MADSEngine *vm) : Scene3xx(vm) {}
+	Scene320(MADSEngine *vm) : Scene300s(vm) {}
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene321: public Scene3xx {
@@ -344,9 +319,6 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
-	virtual void actions() {};
-	virtual void postActions() {};
 };
 
 class Scene351: public Scene3xx {
@@ -356,9 +328,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene352: public Scene3xx {
@@ -381,10 +351,8 @@ public:
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene353: public Scene3xx {
@@ -393,10 +361,7 @@ public:
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene354: public Scene3xx {
@@ -405,10 +370,8 @@ public:
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene357: public Scene3xx {
@@ -417,10 +380,8 @@ public:
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene358: public Scene3xx {
@@ -429,10 +390,8 @@ public:
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene359: public Scene3xx {
@@ -444,10 +403,8 @@ public:
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene360: public Scene3xx {
@@ -456,10 +413,8 @@ public:
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene361: public Scene3xx {
@@ -475,98 +430,79 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
-class Scene366: public Scene3xx {
+class Scene366: public Scene300s {
 public:
-	Scene366(MADSEngine *vm) : Scene3xx(vm) {}
+	Scene366(MADSEngine *vm) : Scene300s(vm) {}
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
-	virtual void preActions() {}
 	virtual void actions();
-	virtual void postActions() {};
 };
 
-class Scene387: public Scene3xx {
+class Scene387: public Scene300s {
 public:
-	Scene387(MADSEngine *vm) : Scene3xx(vm) {}
+	Scene387(MADSEngine *vm) : Scene300s(vm) {}
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
-	virtual void preActions() {}
 	virtual void actions();
-	virtual void postActions() {};
 };
 
-class Scene388: public Scene3xx {
+class Scene388: public Scene300s {
 public:
-	Scene388(MADSEngine *vm) : Scene3xx(vm) {}
+	Scene388(MADSEngine *vm) : Scene300s(vm) {}
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
-	virtual void preActions() {}
 	virtual void actions();
-	virtual void postActions() {};
 };
 
-class Scene389: public Scene3xx {
+class Scene389: public Scene300s {
 private:
 	uint32 _monsterTime;
 
 	int _circularQuoteId;
 
 public:
-	Scene389(MADSEngine *vm) : Scene3xx(vm) {}
+	Scene389(MADSEngine *vm) : Scene300s(vm) {}
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {}
 	virtual void actions();
-	virtual void postActions() {};
 };
 
-class Scene390: public Scene3xx {
+class Scene390: public Scene300s {
 public:
-	Scene390(MADSEngine *vm) : Scene3xx(vm) {}
+	Scene390(MADSEngine *vm) : Scene300s(vm) {}
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
-	virtual void preActions() {}
 	virtual void actions();
-	virtual void postActions() {};
 };
 
-class Scene391: public Scene3xx {
+class Scene391: public Scene300s {
 public:
-	Scene391(MADSEngine *vm) : Scene3xx(vm) {}
+	Scene391(MADSEngine *vm) : Scene300s(vm) {}
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
-	virtual void preActions() {}
 	virtual void actions();
-	virtual void postActions() {};
 };
 
-class Scene399: public Scene3xx {
+class Scene399: public Scene300s {
 public:
-	Scene399(MADSEngine *vm) : Scene3xx(vm) {}
+	Scene399(MADSEngine *vm) : Scene300s(vm) {}
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
-	virtual void preActions() {}
 	virtual void actions();
-	virtual void postActions() {};
 };
+
 } // End of namespace Nebular
+
 } // End of namespace MADS
 
 #endif /* MADS_NEBULAR_SCENES3_H */


Commit: d2e93c2f0ef37c4ee4f9d1d0ebd9017f824e485d
    https://github.com/scummvm/scummvm/commit/d2e93c2f0ef37c4ee4f9d1d0ebd9017f824e485d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-28T22:01:05-04:00

Commit Message:
MADS: Hook up scene 321 to scene factory

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 8b73961..712acb1 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -132,7 +132,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene319(vm);
 	case 320:
 		return new Scene320(vm);
-
+	case 321:
+		return new Scene321(vm);
 	case 351:
 		return new Scene351(vm);
 	case 352:


Commit: 4f435d5e1c7096c22890332da89b4c574b542d7b
    https://github.com/scummvm/scummvm/commit/4f435d5e1c7096c22890332da89b4c574b542d7b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-28T22:05:16-04:00

Commit Message:
MADS: Removed redundant method definitions from scene classes

Changed paths:
    engines/mads/nebular/nebular_scenes1.h
    engines/mads/nebular/nebular_scenes2.h
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/nebular/nebular_scenes8.h



diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index ee98179..7a42156 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -146,7 +146,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene106 : public Scene1xx {
@@ -165,7 +164,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene107 : public Scene1xx {
@@ -180,7 +178,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene108 : public Scene1xx {
@@ -189,10 +186,8 @@ public:
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene109 : public Scene1xx {
@@ -215,7 +210,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene110 : public Scene1xx {
@@ -230,7 +224,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene111 : public Scene1xx {
@@ -248,7 +241,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene112 : public Scene1xx {
@@ -258,12 +250,11 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions() {};
-	virtual void postActions() {};
 };
 
 } // End of namespace Nebular
+
 } // End of namespace MADS
 
 #endif /* MADS_NEBULAR_SCENES1_H */
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 45fe790..886f7cf 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -58,9 +58,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene202: public Scene2xx {
@@ -84,7 +82,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 
 	void setRandomKernelMessage();
 };
@@ -100,7 +97,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene205: public Scene2xx {
@@ -113,9 +109,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene207: public Scene2xx {
@@ -134,7 +128,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene208: public Scene2xx {
@@ -152,7 +145,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene209: public Scene2xx {
@@ -200,7 +192,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene210: public Scene2xx {
@@ -239,7 +230,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene211: public Scene2xx {
@@ -255,7 +245,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene212: public Scene2xx {
@@ -266,7 +255,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene214: public Scene2xx {
@@ -280,9 +268,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene215: public Scene2xx {
@@ -292,9 +278,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene216: public Scene2xx {
@@ -304,11 +288,11 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions() {};
-	virtual void postActions() {};
 };
+
 } // End of namespace Nebular
+
 } // End of namespace MADS
 
 #endif /* MADS_NEBULAR_SCENES2_H */
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 5a283d5..145dbdc 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -306,15 +306,6 @@ void Scene804::step() {
 	}
 }
 
-void Scene804::preActions() {
-}
-
-void Scene804::actions() {
-}
-
-void Scene804::postActions() {
-}
-
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes8.h b/engines/mads/nebular/nebular_scenes8.h
index e854fef..2fb1abf 100644
--- a/engines/mads/nebular/nebular_scenes8.h
+++ b/engines/mads/nebular/nebular_scenes8.h
@@ -67,16 +67,9 @@ public:
 	Scene804(MADSEngine *vm) : Scene8xx(vm), _throttleCounter(0) {}
 
 	virtual void setup();
-
 	virtual void enter();
-
 	virtual void step();
-
-	virtual void preActions();
-
-	virtual void actions();
-
-	virtual void postActions();
+	virtual void actions() {};
 };
 
 } // End of namespace Nebular


Commit: cd74c7eac5d5c8f2c6a00b339f510c77b63a2942
    https://github.com/scummvm/scummvm/commit/cd74c7eac5d5c8f2c6a00b339f510c77b63a2942
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-28T22:36:49-04:00

Commit Message:
MADS: Further workarounds for player data being accessed during cutscenes

Changed paths:
    engines/mads/player.cpp



diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 3b727b3..2049042 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -202,7 +202,9 @@ void Player::selectSeries() {
 	}
 
 	// If the user isn't to be present (such as for a cutscene), exit immediately
-	if ((_spritesStart + _spritesIdx) < 0)
+	// WORKAROUND: Original didn't do a secondary check for the sprite set being
+	// present, but it's needed to prevent invalid reads during cutscenes
+	if ((_spritesStart + _spritesIdx) < 0 || !_spriteSetsPresent[_spritesIdx])
 		return;
 
 	SpriteAsset &spriteSet = *scene._sprites[_spritesStart + _spritesIdx];
@@ -223,7 +225,8 @@ void Player::selectSeries() {
 }
 
 void Player::updateFrame() {
-	if ((_spritesStart + _spritesIdx) < 0)
+	// WORKAROUND: Prevent character info being referenced when not present
+	if ((_spritesStart + _spritesIdx) < 0 || !_spriteSetsPresent[_spritesStart + _spritesIdx])
 		return;
 
 	Scene &scene = _vm->_game->_scene;
@@ -497,7 +500,7 @@ void Player::idle() {
 		return;
 	}
 
-	if ((_spritesStart + _spritesIdx) < 0)
+	if ((_spritesStart + _spritesIdx) < 0 || !_spriteSetsPresent[_spritesStart + _spritesIdx])
 		return;
 
 	SpriteAsset &spriteSet = *scene._sprites[_spritesStart + _spritesIdx];


Commit: 60e78c9f1d779b4e9829e12f1a326e760c036273
    https://github.com/scummvm/scummvm/commit/60e78c9f1d779b4e9829e12f1a326e760c036273
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-29T07:08:41+02:00

Commit Message:
MADS: Implement scene 401

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes4.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 712acb1..525f18f 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -169,7 +169,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 
 	// Scene group #4
 	case 401:
-		// TODO
+		return new Scene401(vm);
 	case 402:
 		// TODO
 	case 403:
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index da40d9b..050c10a 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -93,5 +93,135 @@ void Scene4xx::sceneEntrySound() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene401::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene401::enter() {
+	if (_scene->_priorSceneId != -2)
+		_northFl = false;
+
+	_timer = 0;
+
+	if (_scene->_priorSceneId == 402) {
+		_game._player._playerPos = Common::Point(203, 115);
+		_game._player._facing = FACING_WEST;
+	} else if (_scene->_priorSceneId == 354) {
+		_game._player._playerPos = Common::Point(149, 90);
+		_game._player._facing = FACING_SOUTH;
+		_northFl = true;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(142, 131);
+		_game._player._facing = FACING_NORTH;
+	}
+
+	_game.loadQuoteSet(0x1D4, 0);
+	sceneEntrySound();
+}
+
+void Scene401::step() {
+	if (_game._trigger == 70) {
+		_scene->_nextSceneId = 354;
+		_scene->_reloadSceneFlag = true;
+	}
+
+	if (_game._trigger == 80) {
+		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+		_game._player._stepEnabled = true;
+		_game._player._visible = true;
+		_northFl  = false;
+		_game._player.walk(Common::Point(149, 110), FACING_SOUTH);
+	}
+
+	if (_scene->_frameStartTime >= _timer) {
+		int dist = 64 - ((_vm->hypotenuse(_game._player._playerPos.x - 219, _game._player._playerPos.y - 115) * 64) / 120);
+		
+		if (dist > 64)
+			dist = 64;
+		else if (dist < 1)
+			dist = 1;
+
+		_vm->_sound->command(12, dist);
+		_timer = _scene->_frameStartTime + _game._player._ticksAmount;
+	}
+
+}
+
+void Scene401::preActions() {
+	if (_action.isAction(0x1AD, 0x2B4)) {
+		_game._player.walk(Common::Point(149, 89), FACING_NORTH); 
+		_northFl = false;
+	}           
+
+	if (_action.isAction(0x1AD, 0x2B3) && !_northFl)
+		_game._player._walkOffScreenSceneId = 405;
+
+	if (_action.isAction(VERB_TAKE))
+		_game._player._needToWalk = false;
+
+	if (_game._player._needToWalk && _northFl) {
+		if (_globals[kSexOfRex] == REX_MALE)
+			_destPos = Common::Point(148, 94);
+		else
+			_destPos = Common::Point(149, 99);
+
+		_game._player.walk(_destPos, FACING_SOUTH); 
+	}
+}
+
+void Scene401::actions() {
+	if ((_game._player._playerPos == _destPos) && _northFl) {
+		if (_globals[kSexOfRex] == REX_MALE) {
+			_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;  
+			_vm->_sound->command(21);
+			_scene->loadAnimation(formAnimName('s', 1), 70);
+			_globals[kHasBeenScanned] = true;
+			_vm->_sound->command(22);
+			int idx = _scene->_kernelMessages.add(Common::Point(153, 46), 0x1110, 32, 0, 60, _game.getQuote(0x1D4));
+			_scene->_kernelMessages.setQuoted(idx, 4, true);
+		}
+
+		if (_globals[kSexOfRex] == REX_FEMALE) {
+			_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;  
+			_vm->_sound->command(21);
+			_scene->loadAnimation(formAnimName('s', 2), 80);
+			_vm->_sound->command(23);
+			_globals[kHasBeenScanned] = true;
+		}
+	}
+
+	if (_action.isAction(0x242, 0x241)) {
+		if (!_northFl)
+			_scene->_nextSceneId = 402;
+	} else if (_action.isAction(0x1AD, 0x2B4))
+		_scene->_nextSceneId = 354;
+	else if (_action.isAction(VERB_LOOK, 0x1F3)) {
+		if (_globals[kHasBeenScanned])
+			_vm->_dialogs->show(40111);
+		else
+			_vm->_dialogs->show(40110);
+	} else if (_action.isAction(VERB_LOOK, 0x241))
+		_vm->_dialogs->show(40112);
+	else if (_action.isAction(VERB_LOOK, 0x244))
+		_vm->_dialogs->show(40113);
+	else if (_action.isAction(VERB_LOOK, 0x2B3))
+		_vm->_dialogs->show(40114);
+	else if (_action.isAction(VERB_LOOK, 0x2B4))
+		_vm->_dialogs->show(40115);
+	else if (_action._lookFlag)
+		_vm->_dialogs->show(40116);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes4.h b/engines/mads/nebular/nebular_scenes4.h
index 4de6c38..4e29753 100644
--- a/engines/mads/nebular/nebular_scenes4.h
+++ b/engines/mads/nebular/nebular_scenes4.h
@@ -50,6 +50,23 @@ public:
 	Scene4xx(MADSEngine *vm) : NebularScene(vm) {}
 };
 
+class Scene401: public Scene4xx {
+private:
+	bool _northFl;
+	Common::Point _destPos;
+	uint32 _timer;
+
+public:
+	Scene401(MADSEngine *vm) : Scene4xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: a770419abcf109ca45b047f2bb361887632db00c
    https://github.com/scummvm/scummvm/commit/a770419abcf109ca45b047f2bb361887632db00c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-04-29T12:56:51+03:00

Commit Message:
MADS: Add an isCursorVisible() method

This will probably be used by the menu class, but it's nice to have nonetheless

Changed paths:
    engines/mads/events.cpp
    engines/mads/events.h



diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index ac03dd5..6ec1640 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -77,6 +77,10 @@ void EventsManager::hideCursor() {
 	CursorMan.showMouse(false);
 }
 
+bool EventsManager::isCursorVisible() {
+	return CursorMan.isVisible();
+}
+
 void EventsManager::waitCursor() {
 	CursorType cursorId = (CursorType)MIN(_cursorSprites->getCount(), (int)CURSOR_WAIT);
 	_newCursorId = cursorId;
diff --git a/engines/mads/events.h b/engines/mads/events.h
index 529581c..6428108 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -104,6 +104,11 @@ public:
 	void hideCursor();
 
 	/**
+	 * Returns if the mouse cursor is visible
+	 */
+	bool isCursorVisible();
+
+	/**
 	 * Shows the wait cursor
 	 */
 	void waitCursor();


Commit: dccc4510e82a7df9c8d3082a7914f6259382df14
    https://github.com/scummvm/scummvm/commit/dccc4510e82a7df9c8d3082a7914f6259382df14
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-29T21:53:54-04:00

Commit Message:
MADS: Fix for highlighting and using dynamic hotspots

Changed paths:
    engines/mads/action.cpp
    engines/mads/hotspots.cpp
    engines/mads/hotspots.h
    engines/mads/screen.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 03c0c1e..e278ffb 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -168,7 +168,7 @@ void MADSAction::set() {
 						verbId = scene._hotspots[_hotspotId]._verbId;
 					} else {
 						// Get the verb Id from the scene object
-						verbId = scene._dynamicHotspots[_hotspotId - scene._hotspots.size()]._vocabId;
+						verbId = scene._dynamicHotspots[_hotspotId - scene._hotspots.size()]._verbId;
 					}
 
 					if (verbId > 0) {
@@ -191,7 +191,7 @@ void MADSAction::set() {
 					_action._objectNameId = scene._hotspots[_hotspotId]._vocabId;
 				} else {
 					// Get name from temporary scene hotspot
-					_action._objectNameId = scene._dynamicHotspots[_hotspotId - scene._hotspots.size()]._vocabId;
+					_action._objectNameId = scene._dynamicHotspots[_hotspotId - scene._hotspots.size()]._descId;
 				}
 				appendVocab(_action._objectNameId);
 			}
diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
index 47d8204..02617e9 100644
--- a/engines/mads/hotspots.cpp
+++ b/engines/mads/hotspots.cpp
@@ -29,7 +29,7 @@ DynamicHotspot::DynamicHotspot() {
 	_seqIndex = 0;
 	_facing = FACING_NONE;
 	_descId = 0;
-	_vocabId = 0;
+	_verbId = 0;
 	_articleNumber = 0;
 	_cursor = CURSOR_NONE;
 }
@@ -47,7 +47,7 @@ DynamicHotspots::DynamicHotspots(MADSEngine *vm) : _vm(vm) {
 	_count = 0;
 }
 
-int DynamicHotspots::add(int descId, int vocabId, int seqIndex, const Common::Rect &bounds) {
+int DynamicHotspots::add(int descId, int verbId, int seqIndex, const Common::Rect &bounds) {
 	// Find a free slot
 	uint idx = 0;
 	while ((idx < _entries.size()) && _entries[idx]._active)
@@ -61,7 +61,7 @@ int DynamicHotspots::add(int descId, int vocabId, int seqIndex, const Common::Re
 	_entries[idx]._bounds = bounds;
 	_entries[idx]._feetPos = Common::Point(-3, 0);
 	_entries[idx]._facing = FACING_NONE;
-	_entries[idx]._vocabId = vocabId;
+	_entries[idx]._verbId = verbId;
 	_entries[idx]._articleNumber = 6;
 	_entries[idx]._cursor = CURSOR_NONE;
 
diff --git a/engines/mads/hotspots.h b/engines/mads/hotspots.h
index a6b991e..9e1cb44 100644
--- a/engines/mads/hotspots.h
+++ b/engines/mads/hotspots.h
@@ -39,7 +39,7 @@ public:
 	Common::Point _feetPos;
 	Facing _facing;
 	int _descId;
-	int _vocabId;
+	int _verbId;
 	int _articleNumber;
 	CursorType _cursor;
 
@@ -60,7 +60,7 @@ public:
 
 	Common::Array<MADS::DynamicHotspot>::size_type size() const { return _entries.size(); }
 	DynamicHotspot &operator[](uint idx) { return _entries[idx]; }
-	int add(int descId, int vocabId, int seqIndex, const Common::Rect &bounds);
+	int add(int descId, int verbId, int seqIndex, const Common::Rect &bounds);
 	int setPosition(int index, const Common::Point &pos, Facing facing);
 	int setCursor(int index, CursorType cursor);
 	void remove(int index);
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index cb914e4..ea73d41 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -378,7 +378,7 @@ void ScreenObjects::elementHighlighted() {
 	int index;
 	int indexEnd = -1;
 	int var8 = 0;
-	//int uiCount;
+	int uiCount;
 
 	switch (userInterface._category) {
 	case CAT_COMMAND:
@@ -445,8 +445,8 @@ void ScreenObjects::elementHighlighted() {
 		break;
 
 	default:
-		//uiCount = size() - _uiCount;
-		index = scene._hotspots.size();
+		uiCount = size() - _uiCount;
+		index = uiCount + scene._hotspots.size();
 		indexEnd = index - 1;
 		varA = 0;
 		topIndex = 0;


Commit: 16d46fda7cb0fcdc1e3243f58dbe99c02511676a
    https://github.com/scummvm/scummvm/commit/16d46fda7cb0fcdc1e3243f58dbe99c02511676a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-29T22:35:15-04:00

Commit Message:
MADS: Fix for on-screen text no longer being removed

Changed paths:
    engines/mads/messages.h



diff --git a/engines/mads/messages.h b/engines/mads/messages.h
index 7aabf91..a6d3928 100644
--- a/engines/mads/messages.h
+++ b/engines/mads/messages.h
@@ -55,7 +55,7 @@ public:
 	int _numTicks;
 	uint32 _frameTimer2;
 	uint32 _frameTimer;
-	uint32 _timeout;
+	int32 _timeout;
 	int _trigger;
 	TriggerMode _abortMode;
 	ActionDetails _actionDetails;


Commit: 9d2bcbd499783d83fb85f1235774514e5db8c45b
    https://github.com/scummvm/scummvm/commit/9d2bcbd499783d83fb85f1235774514e5db8c45b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-04-30T22:41:57+03:00

Commit Message:
MADS: Fix a crash when trying to pick up objects that can't be picked

Changed paths:
    engines/mads/nebular/game_nebular.cpp



diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 34eb6f1..b36de8f 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -619,7 +619,7 @@ void GameNebular::unhandledAction() {
 			_vm->_dialogs->show(0x15);
 	} else if (action.isAction(VERB_TAKE)) {
 		int objId = _vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId);
-		if (_vm->_game->_objects.isInInventory(objId))
+		if (objId >= 0 && _vm->_game->_objects.isInInventory(objId))
 			_vm->_dialogs->show(0x10);
 		else if (randVal <= 333)
 			_vm->_dialogs->show(0x8);


Commit: c37c45370c888e608184cdb5f145fbc5d2048b54
    https://github.com/scummvm/scummvm/commit/c37c45370c888e608184cdb5f145fbc5d2048b54
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-04-30T22:43:00+03:00

Commit Message:
MADS: Fix a bug in scene 102

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index ab1b2d1..4e63ba2 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -977,7 +977,7 @@ void Scene102::actions() {
 				_action._inProgress = false;
 				return;
 			}
-		} else if (_action.isAction(VERB_LOOK) || (_game._difficulty == DIFFICULTY_IMPOSSIBLE)) {
+		} else if (_action.isAction(VERB_LOOK) || (_game._difficulty != DIFFICULTY_IMPOSSIBLE)) {
 			_vm->_dialogs->show(0x27EE);
 			_action._inProgress = false;
 			return;


Commit: 521e0394f68267b1ff466e2eb81c00540ff9ece1
    https://github.com/scummvm/scummvm/commit/521e0394f68267b1ff466e2eb81c00540ff9ece1
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-04-30T22:52:02+03:00

Commit Message:
MADS: Check for sane object IDs when checking for inventory objects

This avoids crashes in cases where the default excuse is shown, for
objects that can't be operated

Changed paths:
    engines/mads/inventory.cpp
    engines/mads/nebular/game_nebular.cpp



diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index abd281d..a6459c7 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -108,11 +108,11 @@ void InventoryObjects::setRoom(int objectId, int sceneNumber) {
 }
 
 bool InventoryObjects::isInRoom(int objectId) const {
-	return (*this)[objectId]._roomNumber == _vm->_game->_scene._currentSceneId;
+	return objectId >= 0 && (*this)[objectId]._roomNumber == _vm->_game->_scene._currentSceneId;
 }
 
 bool InventoryObjects::isInInventory(int objectId) const {
-	return (*this)[objectId]._roomNumber == PLAYER_INVENTORY;
+	return objectId >= 0 && (*this)[objectId]._roomNumber == PLAYER_INVENTORY;
 }
 
 void InventoryObjects::addToInventory(int objectId) {
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index b36de8f..34eb6f1 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -619,7 +619,7 @@ void GameNebular::unhandledAction() {
 			_vm->_dialogs->show(0x15);
 	} else if (action.isAction(VERB_TAKE)) {
 		int objId = _vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId);
-		if (objId >= 0 && _vm->_game->_objects.isInInventory(objId))
+		if (_vm->_game->_objects.isInInventory(objId))
 			_vm->_dialogs->show(0x10);
 		else if (randVal <= 333)
 			_vm->_dialogs->show(0x8);


Commit: e24292a72fd97062407f97100fd747161d4dbd56
    https://github.com/scummvm/scummvm/commit/e24292a72fd97062407f97100fd747161d4dbd56
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-04-30T23:53:33+02:00

Commit Message:
MADS: Implement scene 402

Changed paths:
    engines/mads/animation.h
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes4.h



diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 5faa478..894fbae 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -141,7 +141,6 @@ private:
 	Common::Array<SpriteAsset *> _spriteSets;
 	Font *_font;
 
-	int _currentFrame;
 	bool _freeFlag;
 	bool _skipLoad;
 	int _unkIndex;
@@ -180,6 +179,7 @@ public:
 	Common::Array<AnimUIEntry> _uiEntries;
 	Common::Array<AnimMessage> _messages;
 	bool _resetFlag;
+	int _currentFrame;
 	int _oldFrameEntry;
 
 	static Animation *init(MADSEngine *vm, Scene *scene);
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 525f18f..d511413 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -171,7 +171,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 401:
 		return new Scene401(vm);
 	case 402:
-		// TODO
+		return new Scene402(vm);
 	case 403:
 		// TODO
 	case 405:
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index 050c10a..aec1bf4 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -136,7 +136,7 @@ void Scene401::step() {
 
 	if (_scene->_frameStartTime >= _timer) {
 		int dist = 64 - ((_vm->hypotenuse(_game._player._playerPos.x - 219, _game._player._playerPos.y - 115) * 64) / 120);
-		
+
 		if (dist > 64)
 			dist = 64;
 		else if (dist < 1)
@@ -150,9 +150,9 @@ void Scene401::step() {
 
 void Scene401::preActions() {
 	if (_action.isAction(0x1AD, 0x2B4)) {
-		_game._player.walk(Common::Point(149, 89), FACING_NORTH); 
+		_game._player.walk(Common::Point(149, 89), FACING_NORTH);
 		_northFl = false;
-	}           
+	}
 
 	if (_action.isAction(0x1AD, 0x2B3) && !_northFl)
 		_game._player._walkOffScreenSceneId = 405;
@@ -166,7 +166,7 @@ void Scene401::preActions() {
 		else
 			_destPos = Common::Point(149, 99);
 
-		_game._player.walk(_destPos, FACING_SOUTH); 
+		_game._player.walk(_destPos, FACING_SOUTH);
 	}
 }
 
@@ -175,7 +175,7 @@ void Scene401::actions() {
 		if (_globals[kSexOfRex] == REX_MALE) {
 			_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 			_game._player._stepEnabled = false;
-			_game._player._visible = false;  
+			_game._player._visible = false;
 			_vm->_sound->command(21);
 			_scene->loadAnimation(formAnimName('s', 1), 70);
 			_globals[kHasBeenScanned] = true;
@@ -187,7 +187,7 @@ void Scene401::actions() {
 		if (_globals[kSexOfRex] == REX_FEMALE) {
 			_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 			_game._player._stepEnabled = false;
-			_game._player._visible = false;  
+			_game._player._visible = false;
 			_vm->_sound->command(21);
 			_scene->loadAnimation(formAnimName('s', 2), 80);
 			_vm->_sound->command(23);
@@ -222,6 +222,2086 @@ void Scene401::actions() {
 }
 
 /*------------------------------------------------------------------------*/
+void Scene402::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+
+	_scene->addActiveVocab(0x30E);
+	_scene->addActiveVocab(0x306);
+	_scene->addActiveVocab(0x72);
+	_scene->addActiveVocab(0x27);
+	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(0x5C);
+	_scene->addActiveVocab(0x4);
+	_scene->addActiveVocab(0x124);
+	_scene->addActiveVocab(0xD1);
+}
+
+void Scene402::setDialogNode(int node) {
+	if (node > 0)
+		_bartenderDialogNode = node;
+
+	_game._player._stepEnabled = true;
+
+	switch (node) {
+	case 0:
+		_scene->_userInterface.setup(kInputBuildingSentences);
+		_conversationFl = false;
+		_bartenderDialogNode = 0;
+		break;
+
+	case 1:
+		_dialog1.start();
+		_bartenderDialogNode = 1;
+		break;
+
+	case 2:
+		_dialog2.start();
+		_bartenderDialogNode = 2;
+		break;
+
+	case 3:
+		_dialog3.start();
+		_bartenderDialogNode = 3;
+		break;
+
+	case 4:
+		_dialog4.start();
+		_bartenderDialogNode = 4;
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene402::handleConversation1() {
+	switch (_action._activeAction._verbId) {
+	case 0x214: {
+		int quoteId = 0;
+		int quotePosX = 0;
+		switch (_vm->getRandomNumber(1, 3)) {
+		case 1:
+			quoteId = 0x1E4;
+			_bartenderCurrentQuestion = 4;
+			quotePosX = 205;
+			break;
+
+		case 2:
+			quoteId = 0x1E5;
+			_bartenderCurrentQuestion = 5;
+			quotePosX = 203;
+			break;
+
+		case 3:
+			quoteId = 0x1E6;
+			_bartenderCurrentQuestion = 6;
+			quotePosX = 260;
+			break;
+
+		default:
+			break;
+		}
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(quotePosX, 41), 0xFDFC, 0, 0, 9999999, _game.getQuote(quoteId));
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(1, 100);
+		_talkTimer = 120;
+		setDialogNode(2);
+		}
+		break;
+
+	case 0x215:
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(260, 41), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1EC));
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(1, 100);
+		_talkTimer = 120;
+		_bartenderCurrentQuestion = 1;
+		setDialogNode(3);
+		break;
+
+	case 0x237:
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(208, 41), 0xFDFC, 0, 0, 100, _game.getQuote(0x1FD));
+		setDialogNode(0);
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(1, 100);
+		_talkTimer = 1120;
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene402::handleConversation2() {
+	switch (_action._activeAction._verbId) {
+	case 0x216:
+		_dialog2.write(0x216, false);
+		_dialog2.write(0x21D, true);
+		break;
+
+	case 0x219:
+		_dialog2.write(0x219, false);
+		_dialog2.write(0x220, true);
+		break;
+
+	case 0x21A:
+		_dialog2.write(0x21A, false);
+		_dialog2.write(0x223, true);
+		break;
+
+	case 0x21B:
+		_dialog2.write(0x21B, false);
+		_dialog2.write(0x224, true);
+		break;
+
+	case 0x21D:
+		_dialog2.write(0x21D, false);
+		_dialog2.write(0x227, true);
+		break;
+
+	case 0x220:
+		_dialog2.write(0x220, false);
+		_dialog2.write(0x22A, true);
+		break;
+
+	case 0x223:
+		_dialog2.write(0x223, false);
+		_dialog2.write(0x22D, true);
+		break;
+
+	case 0x224:
+		_dialog2.write(0x224, false);
+		_dialog2.write(0x230, true);
+		break;
+
+	case 0x227:
+		_dialog2.write(0x227, false);
+		break;
+
+	case 0x22A:
+		_dialog2.write(0x22A, false);
+		break;
+
+	case 0x22D:
+		_dialog2.write(0x22D, false);
+		break;
+
+	case 0x230:
+		_dialog2.write(0x230, false);
+		break;
+
+	case 0x21C:
+		setDialogNode(0);
+		break;
+
+	default:
+		break;
+
+	}
+
+	if (_action._activeAction._verbId != 0x21C) {
+		switch (_vm->getRandomNumber(1, 3)) {
+		case 1:
+			_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+			_scene->_sequences.addTimer(1, 100);
+			_talkTimer = 180;
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(198, 27), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1E7));
+			_scene->_kernelMessages.add(Common::Point(201, 41), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1E8));
+			_bartenderCurrentQuestion = 7;
+			break;
+
+		case 2:
+			_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+			_scene->_sequences.addTimer(1, 100);
+			_talkTimer = 180;
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(220, 27), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1E9));
+			_scene->_kernelMessages.add(Common::Point(190, 41), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1EA));
+			_bartenderCurrentQuestion = 8;
+			break;
+
+		case 3:
+			_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+			_scene->_sequences.addTimer(1, 100);
+			_talkTimer = 150;
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(196, 41), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1EB));
+			_bartenderCurrentQuestion = 9;
+			break;
+
+		default:
+			break;
+		}
+		_dialog2.start();
+	} else {
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(208, 41), 0xFDFC, 0, 0, 100, _game.getQuote(0x1FD));
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(1, 100);
+		_talkTimer = 1120;
+	}
+}
+
+void Scene402::handleConversation3() {
+	switch (_action._activeAction._verbId) {
+	case 0x233:
+	case 0x234:
+	case 0x235:
+	case 0x236:
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(1, 86);
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(188, 27), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1ED));
+		_scene->_kernelMessages.add(Common::Point(199, 41), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1EE));
+		setDialogNode(4);
+		_bartenderCurrentQuestion = 2;
+		break;
+
+	case 0x237:
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(208, 41), 0xFDFC, 0, 0, 100, _game.getQuote(0x1FD));
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(1, 100);
+		_talkTimer = 1120;
+		setDialogNode(0);
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene402::handleConversation4() {
+	switch (_action._activeAction._verbId) {
+	case 0x238:
+		_scene->_kernelMessages.reset();
+		setDialogNode(0);
+		_game._player._stepEnabled = false;
+		_scene->_kernelMessages.add(Common::Point(196, 13), 0xFDFC, 0, 0, 180, _game.getQuote(0x1F0));
+		_scene->_kernelMessages.add(Common::Point(184, 27), 0xFDFC, 0, 0, 180, _game.getQuote(0x1F1));
+		_scene->_kernelMessages.add(Common::Point(200, 41), 0xFDFC, 0, 0, 180, _game.getQuote(0x1F2));
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(1, 100);
+		_talkTimer = 1100;
+		_dialog4.write(0x238, false);
+		_bartenderMode = 22;
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(100, 95);
+		_refuseAlienLiquor = true;
+		break;
+
+	case 0x239:
+		_game._player._stepEnabled = false;
+		_roxMode = 21;
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(1, 92);
+		_scene->_userInterface.setup(kInputBuildingSentences);
+		_conversationFl = false;
+		break;
+
+	case 0x23A:
+		setDialogNode(0);
+		_game._player._stepEnabled = false;
+		_scene->_kernelMessages.add(Common::Point(193, 27), 0xFDFC, 0, 0, 150, _game.getQuote(0x1F4));
+		_scene->_kernelMessages.add(Common::Point(230, 41), 0xFDFC, 0, 0, 150, _game.getQuote(0x1F5));
+		_dialog4.write(0x23A, false);
+		_globals[kHasSaidTimer] = true;
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(1, 100);
+		_talkTimer = 1100;
+		_bartenderMode = 22;
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(100, 95);
+		_refuseAlienLiquor = true;
+		break;
+
+	case 0x23D:
+		setDialogNode(0);
+		_game._player._stepEnabled = false;
+		_scene->_kernelMessages.add(Common::Point(153, 27), 0xFDFC, 0, 0, 150, _game.getQuote(0x1F6));
+		_scene->_kernelMessages.add(Common::Point(230, 41), 0xFDFC, 0, 0, 150, _game.getQuote(0x1F7));
+		_dialog4.write(0x23D, false);
+		_globals[kHasSaidBinocs] = true;
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(1, 100);
+		_talkTimer = 1100;
+		_bartenderMode = 22;
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(100, 95);
+		_refuseAlienLiquor = true;
+		break;
+
+	case 0x23E:
+		_scene->_kernelMessages.reset();
+		setDialogNode(0);
+		_game._player._stepEnabled = false;
+		_scene->_kernelMessages.add(Common::Point(205, 41), 0xFDFC, 0, 0, 100, _game.getQuote(0x1F8));
+		_bartenderMode = 22;
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(1, 100);
+		_talkTimer = 1050;
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(50, 95);
+		_refuseAlienLiquor = true;
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene402::handleDialogs() {
+	if (_game._trigger == 0) {
+		_scene->_kernelMessages.reset();
+		_game._player._stepEnabled = false;
+		Common::String curQuote = _game.getQuote(_action._activeAction._verbId);
+		if (_vm->_font->getWidth(curQuote, _scene->_textSpacing) > 200) {
+			Common::String subQuote1, subQuote2;
+			_game.splitQuote(curQuote, subQuote1, subQuote2);
+			_scene->_kernelMessages.add(Common::Point(230, 42), 0x1110, 32, 0, 140, subQuote1);
+			_scene->_kernelMessages.add(Common::Point(230, 56), 0x1110, 32, 0, 140, subQuote2);
+			_scene->_sequences.addTimer(160, 120);
+		} else {
+			_scene->_kernelMessages.add(Common::Point(230, 56), 0x1110, 32, 1, 140, curQuote);
+			_scene->_sequences.addTimer(160, 120);
+		}
+	} else if (_game._trigger == 120) {
+		_game._player._stepEnabled = true;
+		switch (_bartenderDialogNode) {
+		case 1:
+			handleConversation1();
+			break;
+
+		case 2:
+			handleConversation2();
+			break;
+
+		case 3:
+			handleConversation3();
+			break;
+
+		case 4:
+			handleConversation4();
+			break;
+
+		default:
+			break;
+		}
+	}
+}
+
+void Scene402::enter() {
+	_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('n', -1));
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 2));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 1));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('g', 0));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('g', 1));
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('a', 0));
+	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('a', 1));
+	_globals._spriteIndexes[15] = _scene->_sprites.addSprites(formAnimName('x', 5));
+	_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('x', 4));
+	_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('b', 0));
+	_globals._spriteIndexes[10] = _scene->_sprites.addSprites(formAnimName('b', 1));
+	_globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('b', 2));
+	_globals._spriteIndexes[12] = _scene->_sprites.addSprites(formAnimName('b', 3));
+	_globals._spriteIndexes[13] = _scene->_sprites.addSprites(formAnimName('c', 0));
+	_globals._spriteIndexes[14] = _scene->_sprites.addSprites(formAnimName('l', 0));
+	_globals._spriteIndexes[16] = _scene->_sprites.addSprites(formAnimName('h', 0));
+	_globals._spriteIndexes[17] = _scene->_sprites.addSprites(formAnimName('z', 0));
+	_globals._spriteIndexes[18] = _scene->_sprites.addSprites(formAnimName('z', 1));
+	_globals._spriteIndexes[19] = _scene->_sprites.addSprites(formAnimName('z', 2));
+	_globals._spriteIndexes[20] = _scene->_sprites.addSprites(formAnimName('x', 6));
+	_globals._spriteIndexes[21] = _scene->_sprites.addSprites("*ROXRC_9");
+	_globals._spriteIndexes[22] = _scene->_sprites.addSprites("*ROXCL_8");
+
+	if (_scene->_priorSceneId == 401) {
+		_game._player._playerPos = Common::Point(160, 150);
+		_game._player._facing = FACING_NORTH;
+		_roxOnStool = false;
+		_bartenderDialogNode = 1;
+		_conversationFl = false;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(160, 150);
+		_game._player._facing = FACING_NORTH;
+		_game._objects.addToInventory(OBJ_CREDIT_CHIP);
+		_game._objects.addToInventory(OBJ_BINOCULARS);
+		_game._objects.addToInventory(OBJ_TIMER_MODULE);
+		_roxOnStool = false;
+		_bartenderDialogNode = 1;
+		_conversationFl = false;
+	}
+
+	_game.loadQuoteSet(0x1D7, 0x1D8, 0x1D9, 0x1DA, 0x1DB, 0x1DC, 0x1DD, 0x1DE, 0x1DF, 0x1E2, 0x1E3, 0x1E6, 0x1E5, 0x1E7,
+		0x1E8, 0x1E9, 0x1EA, 0x1EF, 0x1F0, 0x1F1, 0x1F2, 0x1F3, 0x1F4, 0x1F5, 0x1F6, 0x1F7, 0x1F8, 0x1F9, 0x1FA, 0x1FB,
+		0x1FC, 0x1EB, 0x1EC, 0x1ED, 0x1EE, 0x1E4, 0x1FD, 0x1E0, 0x1E1, 0x1FE, 0x1FF, 0x200, 0x201, 0x202, 0x203, 0x204,
+		0x205, 0x206, 0x207, 0x208, 0x209, 0x20A, 0x20B, 0x20C, 0x20F, 0x20D, 0x20E, 0x210, 0x211, 0x212, 0x213, 0x214,
+		0x215, 0x237, 0x216, 0x219, 0x21A, 0x21B, 0x21C, 0x21D, 0x220, 0x223, 0x224, 0x227, 0x22A, 0x22D, 0x230, 0x233,
+		0x234, 0x235, 0x236, 0x238, 0x239, 0x23A, 0x23D, 0x23E, 0x23F, 0);
+
+	_vm->_palette->setEntry(250, 47, 41, 40);
+	_vm->_palette->setEntry(251, 50, 63, 55);
+	_vm->_palette->setEntry(252, 38, 34, 25);
+	_vm->_palette->setEntry(253, 45, 41, 35);
+
+	_dialog1.setup(0x60, 0x214, 0x215, 0x237, 0);
+	_dialog2.setup(0x61, 0x216, 0x219, 0x21A, 0x21B, 0x21D, 0x220, 0x223, 0x224, 0x227, 0x22A, 0x22D, 0x230, 0x21C, 0);
+	_dialog3.setup(0x62, 0x233, 0x234, 0x235, 0x236, 0x237, -1);
+	_dialog4.setup(0x63, 0x238, 0x239, 0x23A, 0x23D, 0x23E, 0);
+
+	if (!_game._visitedScenes._sceneRevisited) {
+		_dialog2.set(0x61, 0x216, 0x219, 0x21A, 0x21B, 0x21C, 0);
+		_dialog4.set(0x63, 0x238, 0x23E, 0);
+		_dialog1.set(0x60, 0x214, 0x215, 0x237, 0);
+	}
+
+	if (_game._objects.isInInventory(OBJ_CREDIT_CHIP))
+		_dialog4.write(0x239, true);
+	else
+		_dialog4.write(0x239, false);
+
+	if (_game._objects.isInInventory(OBJ_BINOCULARS) && !_globals[kHasSaidBinocs])
+		_dialog4.write(0x23D, true);
+	else
+		_dialog4.write(0x23D, false);
+
+	if (_game._objects.isInInventory(OBJ_TIMER_MODULE) && !_globals[kHasSaidTimer])
+		_dialog4.write(0x23A, true);
+	else
+		_dialog4.write(0x23A, false);
+
+	if (_dialog2.read(0) <= 1)
+		_dialog1.write(0x214, false);
+
+	if (_conversationFl) {
+		switch (_bartenderDialogNode) {
+		case 0:
+			_scene->_userInterface.setup(kInputBuildingSentences);
+			_bartenderDialogNode = 1;
+			break;
+
+		case 1:
+			_dialog1.start();
+			break;
+
+		case 2:
+			_dialog2.start();
+			break;
+
+		case 3:
+			_dialog3.start();
+			break;
+
+		case 4:
+			_dialog4.start();
+			break;
+
+		default:
+			break;
+		}
+
+		switch (_bartenderCurrentQuestion) {
+		case 1:
+			_scene->_kernelMessages.add(Common::Point(260, 41), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1EC));
+			break;
+
+		case 2:
+			_scene->_kernelMessages.add(Common::Point(188, 27), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1ED));
+			_scene->_kernelMessages.add(Common::Point(199, 41), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1EE));
+			break;
+
+		case 3:
+			_scene->_kernelMessages.add(Common::Point(177, 41), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1EF));
+			break;
+
+		case 4:
+			_scene->_kernelMessages.add(Common::Point(205, 41), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1E4));
+			break;
+
+		case 5:
+			_scene->_kernelMessages.add(Common::Point(203, 41), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1E5));
+			break;
+
+		case 6:
+			_scene->_kernelMessages.add(Common::Point(260, 41), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1E6));
+			break;
+
+		case 7:
+			_scene->_kernelMessages.add(Common::Point(198, 27), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1E7));
+			_scene->_kernelMessages.add(Common::Point(201, 41), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1E8));
+			break;
+
+		case 8:
+			_scene->_kernelMessages.add(Common::Point(220, 27), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1E9));
+			_scene->_kernelMessages.add(Common::Point(190, 41), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1EA));
+			break;
+
+		case 9:
+			_scene->_kernelMessages.add(Common::Point(196, 41), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1EB));
+			break;
+
+		case 10:
+			_scene->_kernelMessages.add(Common::Point(198, 27), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1E2));
+			_scene->_kernelMessages.add(Common::Point(199, 41), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1E3));
+			break;
+
+		default:
+			break;
+		}
+	}
+
+	_firstTalkToGirlInChair = false;
+	_lightOn = false;
+	_blowingSmoke = false;
+	_leftWomanMoving = false;
+	_rightWomanMoving = false;
+	_ginnyLooking = false;
+	_beatCounter = 0;
+	_waitingGinnyMove = false;
+	_bigBeatFl = true;
+	_bartenderHandsHips = false;
+	_bartenderSteady = true;
+	_bartenderLooksLeft = false;
+	_activeTeleporter = false;
+	_activeArrows = false;
+	_activeArrow1 = false;
+	_activeArrow2 = false;
+	_activeArrow3 = false;
+	_cutSceneReady = false;
+	_cutSceneNeeded = false;
+	_helgaReady = true;
+	_bartenderReady = true;
+	_drinkTimer = 0;
+	_bartenderTalking = false;
+	_bartenderCalled = false;
+	_helgaTalkMode = 0;
+	_rexMode = 0;
+	_refuseAlienLiquor = false;
+
+	_scene->loadAnimation(Resources::formatName(402, 'd', 1, EXT_AA, ""));
+	_scene->_activeAnimation->_resetFlag = true;
+
+	_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1);
+
+	_globals._sequenceIndexes[13] = _scene->_sequences.startCycle(_globals._spriteIndexes[13], false, 2);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+
+	if (!_game._objects.isInInventory(OBJ_REPAIR_LIST)) {
+		_globals._sequenceIndexes[14] = _scene->_sequences.startCycle(_globals._spriteIndexes[14], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[14], 7);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[14], Common::Point(210, 80));
+		int idx = _scene->_dynamicHotspots.add(0x124, 0xD1, _globals._sequenceIndexes[14], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(0, 0), FACING_NONE);
+	}
+
+	{
+		_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
+		int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
+	}
+
+	if (!_game._objects.isInRoom(OBJ_ALIEN_LIQUOR) && !_game._objects.isInInventory(OBJ_CREDIT_CHIP)) {
+		_globals._sequenceIndexes[15] = _scene->_sequences.startCycle(_globals._spriteIndexes[15], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[15], 8);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[15], Common::Point(250, 80));
+		int idx = _scene->_dynamicHotspots.add(0x5C, 0x4, _globals._sequenceIndexes[15], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(0, 0), FACING_NONE);
+	}
+
+	_globals._sequenceIndexes[20] = _scene->_sequences.startCycle(_globals._spriteIndexes[20], false, 1);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[20], 7);
+	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[20], Common::Point(234, 72));
+
+	if (_globals[kBottleDisplayed]) {
+		_globals._sequenceIndexes[8] = _scene->_sequences.startCycle(_globals._spriteIndexes[8], false, 4);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 7);
+	}
+
+	if (_roxOnStool) {
+		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 11);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 5);
+		_game._player._visible = false;
+	}
+
+	sceneEntrySound();
+}
+
+void Scene402::step() {
+	if (_game._trigger == 104) {
+		_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
+		_game._player._visible = true;
+		_scene->_sequences.remove(_globals._sequenceIndexes[15]);
+		_game._objects.addToInventory(OBJ_CREDIT_CHIP);
+		_vm->_dialogs->showItem(OBJ_CREDIT_CHIP, 40242);
+		_game._player._stepEnabled = true;
+	}
+
+	if ((_vm->getRandomNumber(1, 1500) == 1) && (!_activeTeleporter) && (_game._player._playerPos.x < 150)) {
+		_vm->_sound->command(30);
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 13, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 1, 11);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 14);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 48);
+		_activeTeleporter = true;
+		_globals[kSomeoneHasExploded] = true;
+	}
+
+	if (_game._trigger == 48)
+		_activeTeleporter = false;
+
+	if (_game._trigger == 100) {
+		_bartenderReady = false;
+		if (_bartenderHandsHips) {
+			_scene->_sequences.remove(_globals._sequenceIndexes[10]);
+			_bartenderHandsHips = false;
+		} else if (_bartenderLooksLeft) {
+			_scene->_sequences.remove(_globals._sequenceIndexes[11]);
+			_bartenderLooksLeft = false;
+		} else if (_bartenderSteady) {
+			_scene->_sequences.remove(_globals._sequenceIndexes[9]);
+			_bartenderSteady = false;
+		}
+
+		if (!_bartenderTalking) {
+			_globals._sequenceIndexes[10] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[10], false, 7, 0, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 3, 4);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 8);
+			int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[10], Common::Rect(0, 0, 0, 0));
+			_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
+			_bartenderTalking = true;
+			if (_talkTimer > 1000)
+				_scene->_sequences.addTimer(_talkTimer - 1000, 101);
+			else
+				_scene->_sequences.addTimer(_talkTimer, 101);
+		}
+	}
+
+	if ((_game._trigger == 101) && _bartenderTalking) {
+		_scene->_sequences.remove(_globals._sequenceIndexes[10]);
+		_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
+		int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
+		_bartenderSteady = true;
+		_bartenderTalking = false;
+		if (_talkTimer < 1000)
+			_bartenderReady = true;
+	}
+
+	if (_game._trigger == 28)
+		_game._player._stepEnabled = true;
+
+	switch (_game._trigger) {
+	case 92:
+		_game._player._stepEnabled = false;
+		_scene->_sequences.remove(_globals._sequenceIndexes[6]);
+		_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[7], 1, 2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 5);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 93);
+		break;
+
+	case 93: {
+		int seqIdx = _globals._sequenceIndexes[7];
+		switch (_roxMode) {
+		case 20:
+			_vm->_sound->command(57);
+			_scene->_sequences.remove(_globals._sequenceIndexes[15]);
+			_game._objects.addToInventory(OBJ_CREDIT_CHIP);
+			_vm->_dialogs->showItem(OBJ_CREDIT_CHIP, 40242);
+			break;
+
+		case 22:
+			_vm->_sound->command(57);
+			_scene->_sequences.remove(_globals._sequenceIndexes[8]);
+			_game._objects.addToInventory(OBJ_ALIEN_LIQUOR);
+			_globals[kBottleDisplayed] = false;
+			_vm->_dialogs->showItem(OBJ_ALIEN_LIQUOR, 40241);
+			break;
+
+		case 21:
+			_globals._sequenceIndexes[15] = _scene->_sequences.startCycle(_globals._spriteIndexes[15], false, 1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[15], 8);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[15], Common::Point(250, 80));
+			break;
+
+		default:
+			break;
+		}
+		_globals._sequenceIndexes[7] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[7], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[7], 1, 3);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 5);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[7], seqIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 94);
+
+		if (_roxMode == 21) {
+			if (_game._objects.isInInventory(OBJ_CREDIT_CHIP))
+				_game._objects.setRoom (OBJ_CREDIT_CHIP, NOWHERE);
+
+			_bartenderMode = 20;
+			_scene->_sequences.addTimer(60, 95);
+		}
+		}
+		break;
+
+	case 94: {
+		int seqIdx = _globals._sequenceIndexes[7];
+		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 11);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 5);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[6], seqIdx);
+		if (_roxMode == 22) {
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(230, 56), 0x1110, 32, 0, 120, _game.getQuote(0x23F));
+			_bartenderMode = 21;
+			_globals[kHasPurchased] = true;
+			_scene->_sequences.addTimer(140, 95);
+		} else if (_roxMode == 20)
+			_game._player._stepEnabled = true;
+
+		}
+		break;
+	}
+
+	switch (_game._trigger) {
+	case 95:
+		_bartenderReady = false;
+		_game._player._stepEnabled = false;
+		if (_bartenderHandsHips || _bartenderTalking) {
+			_scene->_sequences.remove(_globals._sequenceIndexes[10]);
+			_bartenderHandsHips = false;
+			_bartenderTalking = false;
+		}
+
+		if (_bartenderLooksLeft) {
+			_scene->_sequences.remove(_globals._sequenceIndexes[11]);
+			_bartenderLooksLeft = false;
+		}
+
+		if (_bartenderSteady) {
+			_scene->_sequences.remove(_globals._sequenceIndexes[9]);
+			_bartenderSteady = false;
+		}
+		_globals._sequenceIndexes[12] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[12], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[12], 1, 4);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[12], 8);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_EXPIRE, 0, 96);
+		break;
+
+	case 96: {
+		int seqIdx = _globals._sequenceIndexes[12];
+		_globals._sequenceIndexes[12] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[12], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[12], 6, 7);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[12], 8);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[12], seqIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_EXPIRE, 0, 97);
+		}
+		break;
+
+	case 97: {
+		int seqIdx = _globals._sequenceIndexes[12];
+		switch (_bartenderMode) {
+		case 20:
+			_scene->_sequences.remove(_globals._sequenceIndexes[15]);
+			break;
+
+		case 21: {
+			_globals._sequenceIndexes[15] = _scene->_sequences.startCycle(_globals._spriteIndexes[15], false, 1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[15], 8);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[15], Common::Point(250, 80));
+			int idx = _scene->_dynamicHotspots.add(0x5C, 0x4, _globals._sequenceIndexes[15], Common::Rect(0, 0, 0, 0));
+			_scene->_dynamicHotspots.setPosition(idx, Common::Point(0, 0), FACING_NONE);
+			}
+			break;
+
+		case 22:
+			_scene->_sequences.remove(_globals._sequenceIndexes[8]);
+			_globals[kBottleDisplayed] = false;
+			break;
+
+		default:
+			break;
+		}
+
+		_globals._sequenceIndexes[12] = _scene->_sequences.startCycle(_globals._spriteIndexes[12], false, 6);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[12], seqIdx);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[12], 8);
+		_scene->_sequences.addTimer(10, 98);
+		}
+		break;
+
+	case 98:
+		_scene->_sequences.remove(_globals._sequenceIndexes[12]);
+		_globals._sequenceIndexes[12] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[12], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[12], 1, 4);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[12], 8);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_EXPIRE, 0, 99);
+		break;
+
+	case 99: {
+		int seqIdx = _globals._sequenceIndexes[12];
+		_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
+		_bartenderSteady = true;
+		int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[9], seqIdx);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
+		if (_bartenderMode == 20) {
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(210, 41), 0xFDFC, 0, 0, 100, _game.getQuote(0x1F3));
+			_scene->_sequences.addTimer(5, 100);
+			_talkTimer = 180;
+			_roxMode = 22;
+			_scene->_sequences.addTimer(65, 92);
+		} else if ((_bartenderMode == 21) || (_bartenderMode == 22)) {
+			_game._player._stepEnabled = true;
+			_bartenderReady = true;
+		}
+
+		}
+		break;
+	}
+
+	switch (_game._trigger) {
+	case 86:
+		_bartenderReady = false;
+		_game._player._stepEnabled = false;
+		if ((_bartenderHandsHips) || (_bartenderTalking)) {
+			_scene->_sequences.remove(_globals._sequenceIndexes[10]);
+			_bartenderHandsHips = false;
+			_bartenderTalking = false;
+		} else if (_bartenderLooksLeft) {
+			_scene->_sequences.remove(_globals._sequenceIndexes[11]);
+			_bartenderLooksLeft = false;
+		} else if (_bartenderSteady) {
+			_scene->_sequences.remove(_globals._sequenceIndexes[9]);
+			_bartenderSteady = false;
+		}
+		_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[9], 1, 9);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 87);
+		break;
+
+	case 87: {
+		int seqIdx = _globals._sequenceIndexes[9];
+		_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 9);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[9], seqIdx);
+		_scene->_sequences.addTimer(10, 89);
+
+		_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 1, 4);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 7);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 88);
+		}
+		break;
+
+	case 88:
+		_globals._sequenceIndexes[8] = _scene->_sequences.startCycle(_globals._spriteIndexes[8], false, 4);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 7);
+		_globals[kBottleDisplayed] = true;
+		break;
+
+	case 89:
+		_scene->_sequences.remove(_globals._sequenceIndexes[9]);
+		_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
+		_scene->_sequences.addTimer(10, 90);
+		break;
+
+	case 90:
+		_scene->_sequences.remove(_globals._sequenceIndexes[9]);
+		_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 5);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
+		_scene->_sequences.addTimer(10, 91);
+		break;
+
+	case 91: {
+		_scene->_sequences.remove(_globals._sequenceIndexes[9]);
+		_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
+		int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
+		_bartenderSteady = true;
+		_game._player._stepEnabled = true;
+		_bartenderReady = true;
+		}
+		break;
+	}
+
+	if (!_waitingGinnyMove && !_ginnyLooking) {
+		_waitingGinnyMove = true;
+		++ _beatCounter;
+		if (_beatCounter >= 20) {
+			_ginnyLooking = true;
+			_beatCounter = 0;
+			_scene->_sequences.addTimer(60, 54);
+		} else {
+			_scene->_sequences.addTimer(30, 75);
+		}
+	}
+
+	switch (_game._trigger) {
+	case 75:
+		_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+		_bigBeatFl = !_bigBeatFl;
+
+		if (_bigBeatFl) {
+			_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 5);
+			_scene->_sequences.addTimer(8, 130);
+		} else {
+			_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 5);
+			_scene->_sequences.addTimer(8, 53);
+		}
+
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1);
+		break;
+
+	case 130:
+		_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 6);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1);
+		_scene->_sequences.addTimer(8, 131);
+		break;
+
+	case 131:
+		_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 5);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1);
+		_scene->_sequences.addTimer(8, 53);
+		break;
+
+	case 53:
+		if (_bigBeatFl) {
+			_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+			_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
+		} else {
+			_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+			_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
+		}
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1);
+		_waitingGinnyMove = false;
+		break;
+	}
+
+	if ((_game._trigger == 54) && _ginnyLooking) {
+		++_beatCounter;
+		if (_beatCounter >= 10) {
+			_ginnyLooking = false;
+			_waitingGinnyMove = false;
+			_beatCounter = 0;
+			_bigBeatFl = true;
+		} else {
+			_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+			_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, _vm->getRandomNumber(1, 4));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1);
+			_scene->_sequences.addTimer(60, 54);
+		}
+	}
+
+	if (_bartenderReady) {
+		if (_vm->getRandomNumber(1, 250) == 1) {
+			if (_bartenderLooksLeft) {
+				_scene->_sequences.remove(_globals._sequenceIndexes[11]);
+				_bartenderLooksLeft = false;
+			} else if (_bartenderHandsHips) {
+				_scene->_sequences.remove(_globals._sequenceIndexes[10]);
+				_bartenderHandsHips = false;
+			} else if (_bartenderSteady) {
+				_scene->_sequences.remove(_globals._sequenceIndexes[9]);
+				_bartenderSteady = false;
+			}
+
+			switch (_vm->getRandomNumber(1, 3)) {
+			case 1: {
+				_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[10], false, 4);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 8);
+				int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[10], Common::Rect(0, 0, 0, 0));
+				_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
+				_bartenderHandsHips = true;
+				}
+				break;
+
+			case 2: {
+				_globals._sequenceIndexes[11] = _scene->_sequences.startCycle(_globals._spriteIndexes[11], false, 2);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[11], 8);
+				int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[11], Common::Rect(0, 0, 0, 0));
+				_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
+				_bartenderLooksLeft = true;
+				}
+				break;
+
+			case 3: {
+				_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
+				int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
+				_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
+				_bartenderSteady = true;
+				}
+				break;
+
+			default:
+				break;
+			}
+		}
+	}
+
+	if (_game._trigger == 76) {
+		int seqIdx = _globals._sequenceIndexes[6];
+		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 11);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 5);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[6], seqIdx);
+		if (!_globals[kBeenThruHelgaScene]) {
+			_game._player._stepEnabled = false;
+			_cutSceneNeeded = true;
+		} else {
+			_game._player._stepEnabled = true;
+		}
+		_roxOnStool = true;
+	}
+
+	switch (_game._trigger) {
+	case 77:
+		_game._player._stepEnabled = false;
+		_scene->_sequences.remove(_globals._sequenceIndexes[6]);
+		_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[7], 10, 12);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 5);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 78);
+		break;
+
+	case 78: {
+		_vm->_sound->command(57);
+		int seqIdx = _globals._sequenceIndexes[7];
+		_game._objects.addToInventory(OBJ_REPAIR_LIST);
+		_scene->_sequences.remove(_globals._sequenceIndexes[14]);
+		_globals._sequenceIndexes[7] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[7], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[7], 10, 12);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 5);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[7], seqIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 79);
+		}
+		break;
+
+	case 79: {
+		int seqIdx = _globals._sequenceIndexes[7];
+		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 11);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 5);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[6], seqIdx);
+		_scene->_sequences.addTimer(20, 180);
+		}
+		break;
+
+	case 180:
+		_vm->_dialogs->showItem(OBJ_REPAIR_LIST, 40240);
+		_game._player._stepEnabled = true;
+		break;
+
+	default:
+		break;
+	}
+
+	if (_cutSceneNeeded && _cutSceneReady) {
+		_cutSceneNeeded = false;
+		_scene->_sequences.addTimer(20, 55);
+		_helgaReady = false;
+		_bartenderReady = false;
+	}
+
+	if (_vm->getRandomNumber(1, 25) == 1) {
+		if (_lightOn) {
+			_scene->_sequences.remove(_globals._sequenceIndexes[0]);
+			_lightOn = false;
+		} else {
+			_globals._sequenceIndexes[0] = _scene->_sequences.startCycle(_globals._spriteIndexes[0], false, 1);
+			_lightOn = true;
+		}
+	}
+
+	if (!_blowingSmoke) {
+		if (_vm->getRandomNumber(1, 300) == 1) {
+			_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 14);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 30);
+			_blowingSmoke = true;
+		}
+	}
+
+	switch (_game._trigger) {
+	case 30:
+		_globals._sequenceIndexes[1] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[1], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 5);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1],SEQUENCE_TRIGGER_EXPIRE, 0, 31);
+		break;
+
+	case 31:
+		_blowingSmoke = false;
+		break;
+	}
+
+	if (!_leftWomanMoving) {
+		if (_vm->getRandomNumber(1, 1000) == 1) {
+			switch (_vm->getRandomNumber(1, 2)) {
+			case 1:
+				_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 12, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 8);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 33);
+				_leftWomanMoving = true;
+				break;
+
+			case 2:
+				_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
+				_scene->_sequences.addTimer(12, 35);
+				_leftWomanMoving = true;
+				break;
+
+			default:
+				break;
+			}
+		}
+	}
+
+	switch (_game._trigger) {
+	case 33: {
+		int seqIdx = _globals._sequenceIndexes[2];
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 9);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], seqIdx);
+		_scene->_sequences.addTimer(_vm->getRandomNumber(60, 250), 34);
+		}
+		break;
+
+	case 34:
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+		_globals._sequenceIndexes[2] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[2], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 8);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 38);
+		break;
+
+	case 35:
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 2);
+		_scene->_sequences.addTimer(_vm->getRandomNumber(60, 300), 36);
+		break;
+
+	case 36:
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
+		_scene->_sequences.addTimer(12, 37);
+		break;
+
+	case 37:
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+		_leftWomanMoving = false;
+		break;
+
+	case 38:
+		_leftWomanMoving = false;
+		break;
+
+	default:
+		break;
+	}
+
+	if (!_rightWomanMoving) {
+		if (_vm->getRandomNumber(1, 300) == 1) {
+			switch (_vm->getRandomNumber(1, 4)) {
+			case 1:
+				_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 4);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 32);
+				_rightWomanMoving = true;
+				break;
+
+			case 2:
+				_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 2, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 4, 5);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 32);
+				_rightWomanMoving = true;
+				break;
+
+			case 3:
+				_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 2, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 4, 5);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 32);
+				_rightWomanMoving = true;
+				break;
+
+			case 4:
+				_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 2, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 3, 4);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 32);
+				_rightWomanMoving = true;
+				break;
+
+			default:
+				break;
+			}
+		}
+	}
+
+	if (_game._trigger == 32)
+		_rightWomanMoving = false;
+
+	if (_scene->_activeAnimation->getCurrentFrame() == 1) {
+		switch (_vm->getRandomNumber(1, 50)) {
+		case 1:
+			_scene->_activeAnimation->setCurrentFrame(2);
+			break;
+
+		case 2:
+			_scene->_activeAnimation->setCurrentFrame(7);
+			break;
+
+		case 3:
+			_scene->_activeAnimation->setCurrentFrame(11);
+			break;
+
+		default:
+			_scene->_activeAnimation->setCurrentFrame(0);
+			break;
+		}
+	}
+
+	if ((_scene->_activeAnimation->getCurrentFrame() == 4) && (_drinkTimer < 10)) {
+		++ _drinkTimer;
+		_scene->_activeAnimation->setCurrentFrame(3);
+	}
+
+	if (_drinkTimer == 10) {
+		_drinkTimer = 0;
+		_scene->_activeAnimation->setCurrentFrame(4);
+		_scene->_activeAnimation->_currentFrame = 5;
+	}
+
+
+	switch (_scene->_activeAnimation->getCurrentFrame()) {
+	case 6:
+	case 10:
+	case 14:
+		_scene->_activeAnimation->setCurrentFrame(0);
+		break;
+
+	default:
+		break;
+	}
+
+	switch (_game._trigger) {
+	case 39:
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(89, 67), 0xFDFC, 32, 0, 120, _game.getQuote(0x1D8));
+		_scene->_sequences.addTimer(150, 40);
+		break;
+
+	case 40:
+		_scene->_kernelMessages.add(Common::Point(89, 67), 0xFDFC, 32, 0, 120, _game.getQuote(0x1D9));
+		_scene->_sequences.addTimer(150, 41);
+		break;
+
+	case 41:
+		_scene->_kernelMessages.add(Common::Point(89, 67), 0xFDFC, 32, 0, 120, _game.getQuote(0x1DA));
+		_game._player._stepEnabled = true;
+		break;
+
+	case 42:
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(89, 67), 0xFDFC, 32, 0, 120, _game.getQuote(0x1DC));
+		_scene->_sequences.addTimer(150, 43);
+		break;
+
+	case 43:
+		_scene->_kernelMessages.add(Common::Point(89, 67), 0xFDFC, 32, 0, 120, _game.getQuote(0x1DD));
+		_game._player._stepEnabled = true;
+		break;
+
+	case 44:
+		_game._player._stepEnabled = true;
+		break;
+
+	default:
+		break;
+	}
+
+	switch (_game._trigger) {
+	case 55:
+		if (_bartenderHandsHips) {
+			_scene->_sequences.remove(_globals._sequenceIndexes[10]);
+			_bartenderHandsHips = false;
+			_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
+			int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
+			_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
+			_bartenderSteady = true;
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
+		} else if (_bartenderLooksLeft) {
+			_scene->_sequences.remove(_globals._sequenceIndexes[11]);
+			_bartenderLooksLeft = false;
+			_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
+			int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
+			_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
+			_bartenderSteady = true;
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
+		}
+		_game._player._stepEnabled = false;
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(180, 47), 0xFBFA, 0, 0, 100, _game.getQuote(0x1FE));
+		_scene->_sequences.addTimer(120, 56);
+		break;
+
+	case 56:
+		_scene->_sequences.remove(_globals._sequenceIndexes[13]);
+		_globals._sequenceIndexes[13] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[13], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], 2, 5);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 57);
+		break;
+
+	case 57: {
+		int seqIdx = _globals._sequenceIndexes[13];
+		_scene->_sequences.remove(_globals._sequenceIndexes[20]);
+		_globals._sequenceIndexes[13] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[13], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], 6, 9);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[13], seqIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 58);
+		}
+		break;
+
+	case 58: {
+		int seqIdx = _globals._sequenceIndexes[13];
+		_globals._sequenceIndexes[13] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[13], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], 5, 9);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[13], seqIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 59);
+		}
+		break;
+
+	case 59: {
+		int seqIdx = _globals._sequenceIndexes[13];
+		_globals._sequenceIndexes[13] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[13], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], 1, 4);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[13], seqIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 60);
+		_globals._sequenceIndexes[20] = _scene->_sequences.startCycle(_globals._spriteIndexes[20], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[20], 8);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[20], Common::Point(234, 72));
+		}
+		break;
+
+	case 60: {
+		int seqIdx = _globals._sequenceIndexes[13];
+		_globals._sequenceIndexes[13] = _scene->_sequences.startCycle(_globals._spriteIndexes[13], false, 2);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[13], seqIdx);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		_scene->_sequences.addTimer(10, 61);
+		}
+		break;
+
+	case 61:
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(181, 33), 0xFBFA, 0, 0, 130, _game.getQuote(0x1FF));
+		_scene->_kernelMessages.add(Common::Point(171, 47), 0xFBFA, 0, 0, 130, _game.getQuote(0x200));
+		_scene->_sequences.addTimer(150, 63);
+		_scene->_sequences.remove(_globals._sequenceIndexes[13]);
+		_globals._sequenceIndexes[13] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[13], false, 30, 4, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], 10, 11);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 62);
+		break;
+
+	case 62: {
+		int seqIdx = _globals._sequenceIndexes[13];
+		_globals._sequenceIndexes[13] = _scene->_sequences.startCycle(_globals._spriteIndexes[13], false, 2);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[13], seqIdx);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		}
+		break;
+
+	case 63:
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(160, 33), 0xFBFA, 0, 0, 130, _game.getQuote(0x201));
+		_scene->_kernelMessages.add(Common::Point(165, 47), 0xFBFA, 0, 0, 130, _game.getQuote(0x202));
+		_scene->_sequences.addTimer(150, 64);
+		break;
+
+	case 64:
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(210, 27), 0xFDFC, 0, 0, 130, _game.getQuote(0x1E0));
+		_scene->_kernelMessages.add(Common::Point(198, 41), 0xFDFC, 0, 0, 130, _game.getQuote(0x1E1));
+		_scene->_sequences.addTimer(150, 65);
+		_scene->_sequences.addTimer(1, 100);
+		_talkTimer = 1130;
+		break;
+
+	case 65:
+		_vm->_sound->command(30);
+		_globals._sequenceIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[16], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[16], 1, 6);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[16], 9);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[16], SEQUENCE_TRIGGER_EXPIRE, 0, 66);
+		break;
+
+	case 66: {
+		int seqIdx = _globals._sequenceIndexes[16];
+		_globals._sequenceIndexes[16] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[16], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[16], 7, 37);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[16], 9);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[16], seqIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[16], SEQUENCE_TRIGGER_EXPIRE, 0, 68);
+
+		_scene->_sequences.remove(_globals._sequenceIndexes[13]);
+		_globals._sequenceIndexes[13] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[13], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], 12, 13);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 67);
+		}
+		break;
+
+	case 67: {
+		int seqIdx = _globals._sequenceIndexes[13];
+		_globals._sequenceIndexes[13] = _scene->_sequences.startCycle(_globals._spriteIndexes[13], false, 13);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[13], seqIdx);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		}
+		break;
+
+	case 68:
+		_scene->_sequences.remove(_globals._sequenceIndexes[13]);
+		_globals._sequenceIndexes[13] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[13], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], 12, 13);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 69);
+		break;
+
+	case 69: {
+		int seqIdx = _globals._sequenceIndexes[13];
+		_globals._sequenceIndexes[13] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[13], false, 25, 4, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], 10, 11);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[13], seqIdx);
+
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(179, 33), 0xFBFA, 0, 0, 130, _game.getQuote(0x203));
+		_scene->_kernelMessages.add(Common::Point(167, 47), 0xFBFA, 0, 0, 130, _game.getQuote(0x204));
+		_scene->_sequences.addTimer(150, 71);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
+		}
+		break;
+
+	case 70:
+		_globals._sequenceIndexes[13] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[13], false, 25, 4, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], 10, 12);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 72);
+		break;
+
+	case 71:
+		_scene->_sequences.addTimer(210, 73);
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(168, 33), 0xFBFA, 0, 0, 180, _game.getQuote(0x205));
+		_scene->_kernelMessages.add(Common::Point(151, 47), 0xFBFA, 0, 0, 180, _game.getQuote(0x206));
+		if (!_game._objects.isInInventory(OBJ_REPAIR_LIST))
+			_activeArrows = true;
+		break;
+
+	case 72: {
+		int seqIdx = _globals._sequenceIndexes[13];
+		_globals._sequenceIndexes[13] = _scene->_sequences.startCycle(_globals._spriteIndexes[13], false, 2);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[13], seqIdx);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		}
+		break;
+
+	case 73:
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(177, 33), 0xFBFA, 0, 0, 150, _game.getQuote(0x207));
+		_scene->_kernelMessages.add(Common::Point(172, 47), 0xFBFA, 0, 0, 150, _game.getQuote(0x208));
+		_bartenderSteady = true;
+		_game._player._stepEnabled = true;
+		_helgaReady = true;
+		_bartenderReady = true;
+		_globals[kBeenThruHelgaScene] = true;
+		_activeArrows = false;
+		break;
+
+	default:
+		break;
+	}
+
+	if (_helgaReady) {
+		int rndVal = _vm->getRandomNumber(1, 1000);
+		if (rndVal < 6)
+			switch (rndVal) {
+			case 1:
+				_cutSceneReady = false;
+				_helgaReady = false;
+				_scene->_sequences.remove(_globals._sequenceIndexes[13]);
+				_globals._sequenceIndexes[13] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[13], false, 10, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], 2, 5);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 82);
+				break;
+
+			case 2:
+				_cutSceneReady = false;
+				_helgaReady = false;
+				_scene->_sequences.remove(_globals._sequenceIndexes[13]);
+				_globals._sequenceIndexes[13] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[13], false, 15, 2, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], 11, 13);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 26);
+				break;
+
+			case 3:
+				_cutSceneReady = false;
+				_helgaReady = false;
+				_scene->_sequences.remove(_globals._sequenceIndexes[13]);
+				_globals._sequenceIndexes[13] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[13], false, 10, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], 10, 11);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 26);
+				break;
+
+			case 4:
+				_cutSceneReady = false;
+				_helgaReady = false;
+				_scene->_sequences.remove(_globals._sequenceIndexes[13]);
+				_globals._sequenceIndexes[13] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[13], false, 15, 2, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], 14, 15);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 26);
+				break;
+
+			case 5:
+				_cutSceneReady = false;
+				_helgaReady = false;
+				_scene->_sequences.remove(_globals._sequenceIndexes[13]);
+				_globals._sequenceIndexes[13] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[13], false, 10, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], 16, 19);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
+				break;
+
+			default:
+				break;
+			}
+		}
+
+	if (_game._trigger == 80) {
+		int seqIdx = _globals._sequenceIndexes[13];
+		_globals._sequenceIndexes[13] = _scene->_sequences.startCycle(_globals._spriteIndexes[13], false, 19);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[13], seqIdx);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		_scene->_sequences.addTimer(_vm->getRandomNumber(60, 120), 81);
+	}
+
+	if (_game._trigger == 81) {
+		_scene->_sequences.remove(_globals._sequenceIndexes[13]);
+		_globals._sequenceIndexes[13] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[13], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], 16, 19);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 26);
+	}
+
+	if (_game._trigger == 26) {
+		int seqIdx = _globals._sequenceIndexes[13];
+		_globals._sequenceIndexes[13] = _scene->_sequences.startCycle(_globals._spriteIndexes[13], false, 2);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[13], seqIdx);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		_cutSceneReady = true;
+
+		if (!_cutSceneNeeded)
+			_helgaReady = true;
+	}
+
+	if (_game._trigger == 82) {
+		_scene->_sequences.remove(_globals._sequenceIndexes[20]);
+		int seqIdx = _globals._sequenceIndexes[13];
+		_globals._sequenceIndexes[13] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[13], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], 6, 9);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[13], seqIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 83);
+	}
+
+	if (_game._trigger == 83) {
+		int seqIdx = _globals._sequenceIndexes[13];
+		_globals._sequenceIndexes[13] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[13], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], 5, 9);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[13], seqIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 84);
+	}
+
+	if (_game._trigger == 84) {
+		int seqIdx = _globals._sequenceIndexes[13];
+		_globals._sequenceIndexes[13] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[13], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], 1, 4);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[13], seqIdx);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 85);
+
+		_globals._sequenceIndexes[20] = _scene->_sequences.startCycle(_globals._spriteIndexes[20], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[20], 8);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[20], Common::Point(234, 72));
+	}
+
+	if (_game._trigger == 85) {
+		int seqIdx = _globals._sequenceIndexes[13];
+		_globals._sequenceIndexes[13] = _scene->_sequences.startCycle(_globals._spriteIndexes[13], false, 2);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[13], seqIdx);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		_cutSceneReady = true;
+		if (!_cutSceneNeeded)
+			_helgaReady = true;
+	}
+
+	if (_game._trigger == 102) {
+		_scene->_sequences.remove(_globals._sequenceIndexes[6]);
+		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+		_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[7], 14, 18);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 5);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 103);
+	} else if (_game._trigger == 103) {
+		_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
+		_roxOnStool = false;
+		_game._player._facing = FACING_SOUTH;
+		_game._player.selectSeries();
+		_game._player._visible = true;
+		_game._player._stepEnabled = true;
+		_game._player._readyToWalk = true;
+	}
+
+	if (_activeArrows) {
+		if (!_activeArrow1) {
+			_globals._sequenceIndexes[17] = _scene->_sequences.startCycle(_globals._spriteIndexes[17], false, 1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[17], 1);
+			_scene->_sequences.addTimer(_vm->getRandomNumber(10, 15), 49);
+			_activeArrow1 = true;
+		}
+
+		if (!_activeArrow2) {
+			_globals._sequenceIndexes[18] = _scene->_sequences.startCycle(_globals._spriteIndexes[18], false, 1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[18], 1);
+			_scene->_sequences.addTimer(_vm->getRandomNumber(10, 15), 50);
+			_activeArrow2 = true;
+		}
+
+		if (!_activeArrow3) {
+			_globals._sequenceIndexes[19] = _scene->_sequences.startCycle(_globals._spriteIndexes[19], false, 1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[19], 1);
+			_scene->_sequences.addTimer(_vm->getRandomNumber(10, 15), 51);
+			_activeArrow3 = true;
+		}
+	}
+
+	if (_game._trigger == 49) {
+		_scene->_sequences.remove(_globals._sequenceIndexes[17]);
+		_scene->_sequences.addTimer(_vm->getRandomNumber(10, 15), 45);
+	}
+
+	if (_game._trigger == 45)
+		_activeArrow1 = false;
+
+	if (_game._trigger == 50) {
+		_scene->_sequences.remove(_globals._sequenceIndexes[18]);
+		_scene->_sequences.addTimer(_vm->getRandomNumber(10, 15), 46);
+	}
+
+	if (_game._trigger == 46)
+		_activeArrow2 = false;
+
+	if (_game._trigger == 51) {
+		_scene->_sequences.remove(_globals._sequenceIndexes[19]);
+		_scene->_sequences.addTimer(_vm->getRandomNumber(10, 15), 47);
+	}
+
+	if (_game._trigger == 47)
+		_activeArrow3 = false;
+}
+
+void Scene402::preActions() {
+	if (_action.isAction(0x30B, 0x24A) && (_game._player._prepareWalkPos.x != 248))
+		_game._player.walk(Common::Point(232, 112), FACING_EAST);
+
+	if (_action.isAction(VERB_WALKTO, 0x309))
+		_game._player._needToWalk = _game._player._readyToWalk;
+
+	if (!_roxOnStool && _action.isAction(VERB_TAKE, 0x5C) && !_game._objects.isInInventory(OBJ_CREDIT_CHIP))
+		_game._player.walk(Common::Point(246, 108), FACING_NORTH);
+
+	if (_action.isAction(VERB_TAKE))
+		_game._player._needToWalk = false;
+
+	if (_action.isAction(VERB_TAKE, 0x5C) && !_roxOnStool)
+		_game._player._needToWalk = true;
+
+	if (_roxOnStool) {
+		if (_action.isAction(VERB_LOOK) || _action.isAction(0x24A) || _action.isAction(VERB_TALKTO))
+			_game._player._needToWalk = false;
+
+		if (_action.isAction(VERB_TAKE, 0x124) || _action.isAction(VERB_TAKE, 0x5C))
+			_game._player._needToWalk = false;
+
+		if (_action.isAction(VERB_TALKTO, 0x30A) || _action.isAction(VERB_TALKTO, 0x30C))
+			_game._player._needToWalk = _game._player._readyToWalk;
+
+		if (_game._player._needToWalk) {
+			_game._player._facing = FACING_SOUTH;
+			_game._player._readyToWalk = false;
+			_game._player._stepEnabled = false;
+			_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+			_scene->_sequences.addTimer(1, 102);
+		}
+	}
+
+	if (_action.isAction(VERB_TAKE, 0x124) && !_roxOnStool && !_game._objects.isInInventory(OBJ_REPAIR_LIST))
+		_game._player.walk(Common::Point(191, 99), FACING_NORTHEAST);
+
+	if (_action.isAction(VERB_TALKTO, 0x30E) && !_roxOnStool)
+		_game._player.walk(Common::Point(228, 83), FACING_SOUTH);
+
+	if (_action.isAction(VERB_TALKTO, 0x3AA) && !_roxOnStool)
+		_game._player.walk(Common::Point(208, 102), FACING_NORTHEAST);
+}
+
+void Scene402::actions() {
+	if (_action.isAction(VERB_TAKE, 0x124) && _game._objects.isInRoom(OBJ_REPAIR_LIST) && _roxOnStool) {
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(1, 77);
+		_game._player._needToWalk = false;
+	} else if (_action.isAction(VERB_TAKE, 0x124) && _game._objects.isInRoom(OBJ_REPAIR_LIST) && !_roxOnStool) {
+		if (_game._trigger == 0) {
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_globals._sequenceIndexes[21] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[21], false, 7, 2, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[21], 1, 2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[21]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[21], SEQUENCE_TRIGGER_SPRITE, 2, 165);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[21], SEQUENCE_TRIGGER_EXPIRE, 0, 166);
+		} else if (_game._trigger == 165) {
+			_scene->_sequences.remove(_globals._sequenceIndexes[14]);
+			_game._objects.addToInventory(OBJ_REPAIR_LIST);
+		}
+	} else if (_game._trigger == 166) {
+		_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
+		_game._player._visible = true;
+		_scene->_sequences.addTimer(20, 167);
+	} else if (_game._trigger == 167) {
+		_vm->_dialogs->showItem(OBJ_REPAIR_LIST, 40240);
+		_game._player._stepEnabled = true;
+	} else if (_game._screenObjects._inputMode == 1)
+		handleDialogs();
+	else if (_action.isAction(0x242, 0x2B3))
+		_scene->_nextSceneId = 401;
+	else if (_action.isAction(0x2B5, 0x248))
+		;  // just... nothing
+	else if (_action.isAction(VERB_TALKTO, 0x3AA)) {
+		switch (_game._trigger) {
+		case 0: {
+			_game._player._stepEnabled = false;
+			int random = _vm->getRandomNumber(1, 3);
+			if (_helgaTalkMode == 0)
+				random = 1;
+
+			int centerFlag;
+			Common::Point centerPos;
+			if (_roxOnStool) {
+				centerFlag = 0;
+				centerPos = Common::Point(230, 56);
+			} else {
+				centerFlag = 2;
+				centerPos = Common::Point(0, 0);
+			}
+
+			switch (random) {
+			case 1:
+				_scene->_kernelMessages.add(centerPos, 0x1110, 32 | centerFlag, 0, 90, _game.getQuote(0x211));
+				_scene->_sequences.addTimer(110, 25);
+				break;
+
+			case 2:
+				_scene->_kernelMessages.add(centerPos, 0x1110, 32 | centerFlag, 0, 90, _game.getQuote(0x212));
+				_scene->_sequences.addTimer(110, 25);
+				break;
+
+			case 3:
+				_scene->_kernelMessages.add(centerPos, 0x1110, 32 | centerFlag, 0, 90, _game.getQuote(0x213));
+				_scene->_sequences.addTimer(110, 25);
+				break;
+
+			default:
+				break;
+		}
+		}
+		break;
+
+		case 25:
+			switch (_helgaTalkMode) {
+			case 0:
+				_game._player._stepEnabled = false;
+				_helgaTalkMode = 1;
+				_scene->_kernelMessages.add(Common::Point(177, 33), 0xFBFA, 0, 0, 130, _game.getQuote(0x209));
+				_scene->_kernelMessages.add(Common::Point(182, 47), 0xFBFA, 0, 0, 130, _game.getQuote(0x20A));
+				_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+				_scene->_sequences.addTimer(130, 28);
+				break;
+
+			case 1:
+				_game._player._stepEnabled = false;
+				_helgaTalkMode = 2;
+				_scene->_kernelMessages.add(Common::Point(157, 47), 0xFBFA, 0, 0, 100, _game.getQuote(0x20B));
+				_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+				_scene->_sequences.addTimer(100, 28);
+				break;
+
+			case 2:
+				_game._player._stepEnabled = false;
+				_helgaTalkMode = 3;
+				_scene->_kernelMessages.add(Common::Point(172, 47), 0xFBFA, 0, 0, 100, _game.getQuote(0x20C));
+				_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+				_scene->_sequences.addTimer(100, 28);
+				break;
+
+			case 3:
+				_game._player._stepEnabled = true;
+				break;
+
+			default:
+				break;
+			}
+			break;
+		}
+	} else if (_action.isAction(VERB_TALKTO, 0x30A) && !_firstTalkToGirlInChair) {
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x1D7));
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(150, 39);
+		_game._player._stepEnabled = false;
+		_firstTalkToGirlInChair = true;
+	} else if (_action.isAction(VERB_TALKTO, 0x30A) && _firstTalkToGirlInChair) {
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x1DB));
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(150, 42);
+		_game._player._stepEnabled = false;
+	} else if (_action.isAction(VERB_TALKTO, 0x30C) || _action.isAction(VERB_WALKTO, 0x30C)) {
+		_scene->_kernelMessages.add(Common::Point(102, 48), 0xFBFA, 0, 0, 120, _game.getQuote(0x1DE));
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(120, 44);
+		_game._player._stepEnabled = false;
+	} else if (_action.isAction(0x30B, 0x24A) && (_game._player._targetPos.x == 248)){
+		_scene->_kernelMessages.add(Common::Point(0, -14), 0x1110, 34, 0, 120, _game.getQuote(0x20D));
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x20E));
+	} else if (_action.isAction(0x30B, 0x24A) && !_roxOnStool && (_game._player._targetPos.x != 248)) {
+		_game._player._visible = false;
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 7, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 1, 11);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 5);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 76);
+		_game._player._stepEnabled = false;
+	} else if (_action.isAction(VERB_TAKE, 0x5C) && !_game._objects.isInInventory(OBJ_CREDIT_CHIP) && _roxOnStool) {
+		_roxMode = 20;
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(1, 92);
+	} else if (_action.isAction(VERB_TAKE, 0x5C) && !_game._objects.isInInventory(OBJ_CREDIT_CHIP) && !_roxOnStool) {
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_globals._sequenceIndexes[22] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[22], false, 7, 2, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[22], 1, 2);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[22], Common::Point(_game._player._playerPos.x, _game._player._playerPos.y + 1));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[22], 5);
+		_scene->_sequences.setScale(_globals._sequenceIndexes[22], 88);
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[22], SEQUENCE_TRIGGER_EXPIRE, 0, 104);
+	} else if (_action.isAction(VERB_TALKTO, 0x30E)) {
+		switch (_game._trigger) {
+		case 0: {
+			int centerFlag;
+			Common::Point centerPos;
+			if (_roxOnStool) {
+				centerFlag = 0;
+				centerPos = Common::Point(230, 56);
+			} else {
+				centerFlag = 2;
+				centerPos = Common::Point(0, 0);
+			}
+
+			_game._player._stepEnabled = false;
+			int quoteId;
+			if (_bartenderCalled) {
+				quoteId = 0x210;
+			} else {
+				quoteId = 0x20F;
+				_bartenderCalled = true;
+			}
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(centerPos, 0x1110, 32 | centerFlag, 0, 90, _game.getQuote(quoteId));
+			_scene->_sequences.addTimer(110, 29);
+			_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+			_scene->_sequences.addTimer(90, 28);
+			}
+			break;
+
+		case 29:
+			_scene->_kernelMessages.reset();
+			if (!_roxOnStool) {
+				if (_game._objects.isInRoom(OBJ_ALIEN_LIQUOR)) {
+					_scene->_kernelMessages.add(Common::Point(177, 41), 0xFDFC, 0, 0, 120, _game.getQuote(0x1DF));
+					_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+					_scene->_sequences.addTimer(1, 100);
+					_talkTimer = 120;
+				} else if (_rexMode == 0) {
+					_scene->_kernelMessages.add(Common::Point(175, 13), 0xFDFC, 0, 0, 180, _game.getQuote(0x1F9));
+					_scene->_kernelMessages.add(Common::Point(184, 27), 0xFDFC, 0, 0, 180, _game.getQuote(0x1FA));
+					_scene->_kernelMessages.add(Common::Point(200, 41), 0xFDFC, 0, 0, 180, _game.getQuote(0x1FB));
+					_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+					_scene->_sequences.addTimer(1, 100);
+					_talkTimer = 180;
+					_rexMode = 1;
+				} else if (_rexMode == 1) {
+					_scene->_kernelMessages.add(Common::Point(205, 41), 0xFDFC, 0, 0, 120, _game.getQuote(0x1FC));
+					_game._player._stepEnabled = true;
+					_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+					_scene->_sequences.addTimer(1, 100);
+					_talkTimer = 120;
+					_rexMode = 3;
+				} else {
+					_game._player._stepEnabled = true;
+				}
+			} else {
+				if (_game._objects.isInRoom(OBJ_ALIEN_LIQUOR)) {
+					if (!_refuseAlienLiquor) {
+						_scene->_kernelMessages.reset();
+						_scene->_kernelMessages.add(Common::Point(198, 27), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1E2));
+						_scene->_kernelMessages.add(Common::Point(199, 41), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1E3));
+						_bartenderCurrentQuestion = 10;
+						_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+						_scene->_sequences.addTimer(1, 100);
+						_talkTimer = 120;
+						_conversationFl = true;
+						_bartenderDialogNode = 1;
+						if (_dialog2.read(0) <= 1)
+							_dialog1.write(0x214, false);
+
+						_dialog1.start();
+					} else {
+						_scene->_kernelMessages.add(Common::Point(177, 41), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x1EF));
+						_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+						_scene->_sequences.addTimer(1, 100);
+						_talkTimer = 120;
+						_bartenderCurrentQuestion = 3;
+						_conversationFl = true;
+						_bartenderDialogNode = 1;
+						if (_dialog2.read(0) <= 1)
+							_dialog1.write(0x214, false);
+
+						_dialog1.start();
+						_game._player._stepEnabled = true;
+					}
+				} else {
+					if (_rexMode == 0) {
+						_scene->_kernelMessages.add(Common::Point(175, 13), 0xFDFC, 0, 0, 180, _game.getQuote(0x1F9));
+						_scene->_kernelMessages.add(Common::Point(184, 27), 0xFDFC, 0, 0, 180, _game.getQuote(0x1FA));
+						_scene->_kernelMessages.add(Common::Point(200, 41), 0xFDFC, 0, 0, 180, _game.getQuote(0x1FB));
+						_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+						_scene->_sequences.addTimer(1, 100);
+						_talkTimer = 180;
+						_rexMode = 1;
+					} else if (_rexMode == 1) {
+						_scene->_kernelMessages.add(Common::Point(205, 41), 0xFDFC, 0, 0, 120, _game.getQuote(0x1FC));
+						_game._player._stepEnabled = true;
+						_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+						_scene->_sequences.addTimer(1, 100);
+						_talkTimer = 120;
+						_rexMode = 3;
+					} else {
+						_game._player._stepEnabled = true;
+					}
+				}
+			}
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x248))
+		_vm->_dialogs->show(40210);
+	else if (_action.isAction(VERB_LOOK, 0x16C)) {
+		if (_globals[kSomeoneHasExploded])
+			_vm->_dialogs->show(40212);
+		else
+			_vm->_dialogs->show(40211);
+	} else if (_action.isAction(VERB_LOOK, 0x241))
+		_vm->_dialogs->show(40213);
+	else if (_action.isAction(VERB_LOOK, 0x30E))
+		_vm->_dialogs->show(40214);
+	else if (_action.isAction(VERB_LOOK, 0x30C))
+		_vm->_dialogs->show(40215);
+	else if (_action.isAction(VERB_LOOK, 0x309))
+		_vm->_dialogs->show(40216);
+	else if (_action.isAction(VERB_LOOK, 0x30A))
+		_vm->_dialogs->show(40217);
+	else if (_action.isAction(VERB_LOOK, 0x3AA))
+		_vm->_dialogs->show(40218);
+	else if (_action.isAction(VERB_LOOK, 0x2B3))
+		_vm->_dialogs->show(40219);
+	else if (_action._lookFlag)
+		_vm->_dialogs->show(40220);
+	else if (_action.isAction(VERB_LOOK, 0x2B8))
+		_vm->_dialogs->show(40221);
+	else if (_action.isAction(VERB_PUSH, 0x3AA) || _action.isAction(VERB_PULL, 0x3AA))
+		_vm->_dialogs->show(40222);
+	else if (_action.isAction(VERB_TALKTO, 0x2B8))
+		_vm->_dialogs->show(40223);
+	else if (_action.isAction(VERB_TALKTO, 0x309))
+		_vm->_dialogs->show(40224);
+	else if (_action.isAction(VERB_LOOK, 0x249))
+		_vm->_dialogs->show(40225);
+	else if (_action.isAction(VERB_LOOK, 0x160))
+		_vm->_dialogs->show(40226);
+	else if (_action.isAction(VERB_TAKE, 0x160))
+		_vm->_dialogs->show(40227);
+	else if (_action.isAction(VERB_LOOK, 0x244))
+		_vm->_dialogs->show(40228);
+	else if (_action.isAction(VERB_TAKE, 0x244))
+		_vm->_dialogs->show(40229);
+	else if (_action.isAction(VERB_LOOK, 0x24A))
+		_vm->_dialogs->show(40230);
+	else if (_action.isAction(VERB_TAKE, 0x24A))
+		_vm->_dialogs->show(40231);
+	else if (_action.isAction(VERB_LOOK, 0x3B))
+		_vm->_dialogs->show(40232);
+	else if (_action.isAction(VERB_TAKE, 0x3B))
+		_vm->_dialogs->show(40233);
+	else if (_action.isAction(VERB_LOOK, 0x24E))
+		_vm->_dialogs->show(40234);
+	else if (_action.isAction(VERB_LOOK, 0x247))
+		_vm->_dialogs->show(40235);
+	else if (_action.isAction(VERB_LOOK, 0x174))
+		_vm->_dialogs->show(40236);
+	else if (_action.isAction(VERB_LOOK, 0x10E))
+		_vm->_dialogs->show(40237);
+	else if (_action.isAction(VERB_TAKE, 0x10E))
+		_vm->_dialogs->show(40238);
+	else if (_action.isAction(VERB_LOOK, 0x124) && _game._objects.isInRoom(OBJ_REPAIR_LIST))
+		_vm->_dialogs->show(40239);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
 
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes4.h b/engines/mads/nebular/nebular_scenes4.h
index 4e29753..4293408 100644
--- a/engines/mads/nebular/nebular_scenes4.h
+++ b/engines/mads/nebular/nebular_scenes4.h
@@ -67,6 +67,67 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene402: public Scene4xx {
+private:
+	bool _lightOn;
+	bool _blowingSmoke;
+	bool _leftWomanMoving;
+	bool _rightWomanMoving;
+	bool _firstTalkToGirlInChair;
+	bool _waitingGinnyMove;
+	bool _ginnyLooking;
+	bool _bigBeatFl;
+	bool _roxOnStool;
+	bool _bartenderSteady;
+	bool _bartenderHandsHips;
+	bool _bartenderLooksLeft;
+	bool _bartenderReady;
+	bool _bartenderTalking;
+	bool _bartenderCalled;
+	bool _conversationFl;
+	bool _activeTeleporter;
+	bool _activeArrows;
+	bool _activeArrow1;
+	bool _activeArrow2;
+	bool _activeArrow3;
+	bool _cutSceneReady;
+	bool _cutSceneNeeded;
+	bool _helgaReady;
+	bool _refuseAlienLiquor;
+
+	int _drinkTimer;
+	int _beatCounter;
+	int _bartenderMode;
+	int _bartenderDialogNode;
+	int _bartenderCurrentQuestion;
+	int _helgaTalkMode;
+	int _roxMode;
+	int _rexMode;
+	int _talkTimer;
+
+	Conversation _dialog1;
+	Conversation _dialog2;
+	Conversation _dialog3;
+	Conversation _dialog4;
+ 
+	void setDialogNode(int node);
+	void handleConversation1();
+	void handleConversation2();
+	void handleConversation3();
+	void handleConversation4();
+	void handleDialogs();
+	
+public:
+	Scene402(MADSEngine *vm) : Scene4xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: b7776bdbddba57a5503dcbf3fcb63cf44dfdb5cb
    https://github.com/scummvm/scummvm/commit/b7776bdbddba57a5503dcbf3fcb63cf44dfdb5cb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-30T21:28:49-04:00

Commit Message:
MADS: Fixes for using items on other items

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index e278ffb..0a0e79c 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -151,7 +151,7 @@ void MADSAction::set() {
 				}
 			}
 
-			// Handling for if a hotspot has been selected/highlighted
+			// Add in any necessary article if necessary
 			if ((_hotspotId >= 0) && (_selectedRow >= 0) && (_articleNumber > 0) && (_verbType == VERB_THAT)) {
 				flag = true;
 
@@ -159,6 +159,7 @@ void MADSAction::set() {
 				_statusText += " ";
 			}
 
+			// Handling for hotspot
 			if (_hotspotId >= 0) {
 				if (_selectedRow < 0) {
 					int verbId;
@@ -197,8 +198,19 @@ void MADSAction::set() {
 			}
 		}
 
+		if (_secondObject >= 0) {
+			if (_secondObjectSource == CAT_INV_LIST || _secondObjectSource == CAT_INV_ANIM) {
+				InventoryObject &invObject = _vm->_game->_objects.getItem(_hotspotId);
+				_action._indirectObjectId = invObject._descId;
+			} else if (_secondObject < (int)scene._hotspots.size()) {
+				_action._indirectObjectId = scene._hotspots[_hotspotId]._vocabId;
+			} else {
+				_action._indirectObjectId = scene._hotspots[_hotspotId - scene._hotspots.size()]._vocabId;
+			}
+		}
+
 		if ((_hotspotId >= 0) && (_articleNumber > 0) && !flag) {
-			if (_articleNumber == -1) {
+			if (_articleNumber == 0xff) {
 				if (_secondObject >= 0) {
 					int articleNum = 0;
 
@@ -212,7 +224,6 @@ void MADSAction::set() {
 					}
 
 					_statusText += kArticleList[articleNum];
-					_statusText += " ";
 				}
 			} else if ((_articleNumber == VERB_LOOK) || (_vm->getGameID() != GType_RexNebular) ||
 				(scene._vocabStrings[_action._indirectObjectId] != kFenceStr)) {
@@ -472,7 +483,6 @@ void MADSAction::checkActionAtMousePos() {
 		case CAT_INV_LIST:
 		case CAT_HOTSPOT:
 		case CAT_INV_ANIM:
-			// TODO: We may not need a separate ActionMode2 enum
 			_mainObjectSource = userInterface._category;
 			_hotspotId = _pickedWord;
 			break;
diff --git a/engines/mads/action.h b/engines/mads/action.h
index c588a42..6e51e12 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -62,7 +62,7 @@ enum VerbType { VERB_ONLY, VERB_THIS, VERB_THAT };
 
 enum PrepType {
 	PREP_NONE, PREP_WITH, PREP_TO, PREP_AT, PREP_FROM, PREP_ON, PREP_IN, 
-	PREP_UNDER, PREP_BEHIND, PREP_RELATIONAL = -1
+	PREP_UNDER, PREP_BEHIND, PREP_RELATIONAL = 0xff
 };
 
 enum ScrCategory {


Commit: 7a34dcf83d8dc80520e28cf6f698512d129af3bb
    https://github.com/scummvm/scummvm/commit/7a34dcf83d8dc80520e28cf6f698512d129af3bb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-04-30T21:43:16-04:00

Commit Message:
MADS: Further fix for using items on objects

Changed paths:
    engines/mads/action.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 0a0e79c..cfd84bf 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -200,12 +200,12 @@ void MADSAction::set() {
 
 		if (_secondObject >= 0) {
 			if (_secondObjectSource == CAT_INV_LIST || _secondObjectSource == CAT_INV_ANIM) {
-				InventoryObject &invObject = _vm->_game->_objects.getItem(_hotspotId);
+				InventoryObject &invObject = _vm->_game->_objects.getItem(_secondObject);
 				_action._indirectObjectId = invObject._descId;
 			} else if (_secondObject < (int)scene._hotspots.size()) {
-				_action._indirectObjectId = scene._hotspots[_hotspotId]._vocabId;
+				_action._indirectObjectId = scene._hotspots[_secondObject]._vocabId;
 			} else {
-				_action._indirectObjectId = scene._hotspots[_hotspotId - scene._hotspots.size()]._vocabId;
+				_action._indirectObjectId = scene._hotspots[_secondObject - scene._hotspots.size()]._vocabId;
 			}
 		}
 


Commit: 0da6934b701e6b9fd278128ab441a215f4413c25
    https://github.com/scummvm/scummvm/commit/0da6934b701e6b9fd278128ab441a215f4413c25
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-01T12:15:42+02:00

Commit Message:
MADS: Implement scene 405

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes4.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index d511413..6422b6f 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -172,10 +172,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene401(vm);
 	case 402:
 		return new Scene402(vm);
-	case 403:
-		// TODO
 	case 405:
-		// TODO
+		return new Scene405(vm);
 	case 406:
 		// TODO
 	case 407:
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index aec1bf4..d1c5aca 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -130,7 +130,7 @@ void Scene401::step() {
 		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
 		_game._player._stepEnabled = true;
 		_game._player._visible = true;
-		_northFl  = false;
+		_northFl = false;
 		_game._player.walk(Common::Point(149, 110), FACING_SOUTH);
 	}
 
@@ -2004,7 +2004,7 @@ void Scene402::actions() {
 	else if (_action.isAction(0x242, 0x2B3))
 		_scene->_nextSceneId = 401;
 	else if (_action.isAction(0x2B5, 0x248))
-		;  // just... nothing
+		; // just... nothing
 	else if (_action.isAction(VERB_TALKTO, 0x3AA)) {
 		switch (_game._trigger) {
 		case 0: {
@@ -2303,5 +2303,172 @@ void Scene402::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene405::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene405::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 1));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*ROXCL_8");
+
+	if (_scene->_priorSceneId == 401) {
+		_game._player._playerPos = Common::Point(23, 123);
+		_game._player._facing = FACING_EAST;
+	} else if (_scene->_priorSceneId == 406) {
+		_game._player._playerPos = Common::Point(300, 128);
+		_game._player._facing = FACING_WEST;
+	} else if (_scene->_priorSceneId == 408) {
+		_game._player._playerPos = Common::Point(154, 109);
+		_game._player._facing = FACING_SOUTH;
+	} else if (_scene->_priorSceneId == 413) {
+		_game._player._playerPos = Common::Point(284, 109);
+		_game._player._facing = FACING_SOUTH;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(23, 123);
+		_game._player._facing = FACING_EAST;
+	}
+
+	if (_globals[kArmoryDoorOpen])
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
+	else
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+
+	if (_scene->_roomChanged) {
+		_globals[kArmoryDoorOpen] = false;
+		_game._objects.addToInventory(OBJ_SECURITY_CARD);
+	}
+
+	_game.loadQuoteSet(0x24F, 0);
+	sceneEntrySound();
+}
+
+void Scene405::step() {
+	if (_game._trigger == 80) {
+		_scene->_sequences.addTimer (20, 81);
+		_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
+		_game._player._visible = true;
+	}
+
+	if (_game._trigger == 81) {
+		_game._player._stepEnabled = true;
+		_vm->_dialogs->show(40525);
+	}
+
+	if (_game._trigger == 70) {
+		_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount ;
+		_game._player._visible = true;
+		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 6, 1, 0, 0);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
+		_vm->_sound->command(19);
+	}
+
+	if (_game._trigger == 71) {
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+		_globals[kArmoryDoorOpen] = false;
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+		_game._player._stepEnabled = true;
+	}
+
+	if (_game._trigger == 75) {
+		_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount ;
+		_game._player._visible = true;
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[1], false, 6, 1, 0, 0);
+		_globals[kArmoryDoorOpen] = true;
+		_game._player._stepEnabled = true;
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle (_globals._spriteIndexes[2],
+			false, 1);
+		_vm->_sound->command(19);
+	}
+}
+
+void Scene405::preActions() {
+	if (_action.isAction(VERB_TAKE))
+		_game._player._needToWalk = false;
+
+	if (_action.isAction(0x1AD, 0x2BA))
+		_game._player._walkOffScreenSceneId = 401;
+
+	if (_action.isAction(0x1AD, 0x2B9))
+		_game._player._walkOffScreenSceneId = 406;
+
+	if (_action.isAction(VERB_CLOSE, 0x259) && _globals[kArmoryDoorOpen])
+		_game._player.walk(Common::Point(212, 113), FACING_NORTH);
+}
+
+void Scene405::actions() {
+	if (_action.isAction(0x18B, 0x6E))
+		_scene->_nextSceneId = 413;
+	else if (_action.isAction(0x18B, 0x259) && _globals[kArmoryDoorOpen])
+		_scene->_nextSceneId = 408;
+	else if (_action.isAction(0x18B, 0x259) && !_globals[kArmoryDoorOpen])
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 60, _game.getQuote(0x24F));
+	else if (_action.isAction(VERB_PUT, 0x131, 0x251) && !_globals[kArmoryDoorOpen]) {
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 7, 2, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 2);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 75);
+		Common::Point msgPos = Common::Point(_game._player._playerPos.x, _game._player._playerPos.y + 1);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], msgPos);
+		_scene->_sequences.setScale(_globals._sequenceIndexes[3], 87);
+	} else if ((_action.isAction(VERB_PUT, 0x131, 0x251) || _action.isAction(VERB_CLOSE, 0x259)) && _globals[kArmoryDoorOpen]) {
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 7, 2, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 2);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], _game._player._playerPos);
+		_scene->_sequences.setScale(_globals._sequenceIndexes[3], 87);
+	} else if (_action.isAction(VERB_PUT, 0x251)) {
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 7, 2, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 2);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], _game._player._playerPos);
+		_scene->_sequences.setScale(_globals._sequenceIndexes[3], 87);
+	} else if (_action.isAction(VERB_LOOK, 0x31A))
+		_vm->_dialogs->show(40510);
+	else if (_action.isAction(VERB_TAKE, 0x31A))
+		_vm->_dialogs->show(40511);
+	else if (_action.isAction(VERB_LOOK, 0x254))
+		_vm->_dialogs->show(40512);
+	else if (_action.isAction(VERB_LOOK, 0x258) || _action.isAction(VERB_LOOK, 0x252))
+		_vm->_dialogs->show(40513);
+	else if (_action.isAction(VERB_LOOK, 0xCD))
+		_vm->_dialogs->show(40514);
+	else if (_action.isAction(VERB_LOOK, 0x251))
+		_vm->_dialogs->show(40515);
+	else if (_action.isAction(VERB_LOOK, 0x2B9))
+		_vm->_dialogs->show(40516);
+	else if (_action.isAction(VERB_LOOK, 0x2BA))
+		_vm->_dialogs->show(40517);
+	else if (_action.isAction(VERB_LOOK, 0xE2))
+		_vm->_dialogs->show(40518);
+	else if (_action.isAction(VERB_LOOK, 0x204) || _action._lookFlag)
+		_vm->_dialogs->show(40519);
+	else if (_action.isAction(VERB_LOOK, 0x259)) {
+		if (_globals[kArmoryDoorOpen])
+			_vm->_dialogs->show(40521);
+		else
+			_vm->_dialogs->show(40520);
+	} else if (_action.isAction(VERB_LOOK, 0x6E))
+		_vm->_dialogs->show(40522);
+	else if (_action.isAction(VERB_LOOK, 0x250))
+		_vm->_dialogs->show(40523);
+	else if (_action.isAction(VERB_LOOK, 0x257))
+		_vm->_dialogs->show(40524);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes4.h b/engines/mads/nebular/nebular_scenes4.h
index 4293408..38803fe 100644
--- a/engines/mads/nebular/nebular_scenes4.h
+++ b/engines/mads/nebular/nebular_scenes4.h
@@ -128,6 +128,18 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene405: public Scene4xx {
+public:
+	Scene405(MADSEngine *vm) : Scene4xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 57bf0673d70311da7b2bddda91f4a0566c51c340
    https://github.com/scummvm/scummvm/commit/57bf0673d70311da7b2bddda91f4a0566c51c340
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-01T09:16:48-04:00

Commit Message:
MADS: Default game to impossible difficulty by default

Changed paths:
    engines/mads/game.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 2c2f636..1435681 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -59,7 +59,7 @@ Game *Game::init(MADSEngine *vm) {
 Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm), 
 		_scene(vm), _screenObjects(vm), _player(vm) {
 	_sectionNumber = _priorSectionNumber = 0;
-	_difficulty = DIFFICULTY_HARD;
+	_difficulty = DIFFICULTY_IMPOSSIBLE;
 	_loadGameSlot = -1;
 	_saveFile = nullptr;
 	_statusFlag = 0;


Commit: 88cf2c7caab3ce74460a980640b9fe832f4fba5f
    https://github.com/scummvm/scummvm/commit/88cf2c7caab3ce74460a980640b9fe832f4fba5f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-01T09:17:10-04:00

Commit Message:
MADS: Fix actions being triggered at the end of animation sequences

Changed paths:
    engines/mads/animation.cpp
    engines/mads/animation.h
    engines/mads/scene.cpp
    engines/mads/scene.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 874ce69..bfcbe16 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -318,7 +318,7 @@ void Animation::preLoad(const Common::String &resName, int level) {
 	// doesn't need to be preloaded
 }
 
-void Animation::startAnimation(int abortTimers) {
+void Animation::startAnimation(int endTrigger) {
 	_messageCtr = 0;
 	_skipLoad = true;
 
@@ -338,9 +338,9 @@ void Animation::startAnimation(int abortTimers) {
 	_currentFrame = 0;
 	_oldFrameEntry = 0;
 	_nextFrameTimer = _vm->_game->_scene._frameStartTime;
-	_trigger = abortTimers;
+	_trigger = endTrigger;
 	_triggerMode = _vm->_game->_triggerSetupMode;
-	_vm->_game->_scene._action._activeAction = _actionDetails;
+	_actionDetails = _vm->_game->_scene._action._activeAction;
 
 	for (int idx = 0; idx < _header._messagesCount; ++idx) {
 		_messages[idx]._kernelMsgIndex = -1;
@@ -559,7 +559,7 @@ void Animation::update() {
 
 			if (_triggerMode != SEQUENCE_TRIGGER_DAEMON) {
 				// Copy the noun list
-				scene._action._action = _actionDetails;
+				scene._action._activeAction = _actionDetails;
 			}
 		}
 	}
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 894fbae..aab1743 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -202,7 +202,7 @@ public:
 	/**
 	 * Setups up a loaded animation for playback
 	 */
-	void startAnimation(int abortTimers);
+	void startAnimation(int endTrigger);
 
 	/**
 	 * Update the animation
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index f4b2cb1..5c86e45 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -594,7 +594,7 @@ void Scene::checkKeyboard() {
 	}
 }
 
-void Scene::loadAnimation(const Common::String &resName, int abortTimers) {
+void Scene::loadAnimation(const Common::String &resName, int trigger) {
 	assert(_activeAnimation == nullptr);
 	MSurface depthSurface;
 	UserInterface interfaceSurface(_vm);
@@ -602,7 +602,7 @@ void Scene::loadAnimation(const Common::String &resName, int abortTimers) {
 	_activeAnimation = Animation::init(_vm, this);
 	_activeAnimation->load(interfaceSurface, depthSurface, resName, 
 		_vm->_dithering ? ANIMFLAG_DITHER : 0, nullptr, nullptr);
-	_activeAnimation->startAnimation(abortTimers);
+	_activeAnimation->startAnimation(trigger);
 }
 
 void Scene::updateCursor() {
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 48b01b2..3661bd6 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -204,7 +204,7 @@ public:
 	/**
 	 * Load an animation
 	 */
-	void loadAnimation(const Common::String &resName, int abortTimers = 0);
+	void loadAnimation(const Common::String &resName, int trigger = 0);
 
 	/**
 	 * Returns a vocab entry


Commit: 1ed814259972ac5ea75087e62f8bf9289f2d9f35
    https://github.com/scummvm/scummvm/commit/1ed814259972ac5ea75087e62f8bf9289f2d9f35
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-01T15:29:43+02:00

Commit Message:
MADS: Add scene 406

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes4.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 6422b6f..edee1d9 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -175,7 +175,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 405:
 		return new Scene405(vm);
 	case 406:
-		// TODO
+		return new Scene406(vm);
 	case 407:
 		// TODO
 	case 408:
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index d1c5aca..f6f3b41 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -2346,7 +2346,7 @@ void Scene405::enter() {
 
 void Scene405::step() {
 	if (_game._trigger == 80) {
-		_scene->_sequences.addTimer (20, 81);
+		_scene->_sequences.addTimer(20, 81);
 		_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
 		_game._player._visible = true;
 	}
@@ -2470,5 +2470,212 @@ void Scene405::actions() {
 	_action._inProgress = false;
 }
 
+/*------------------------------------------------------------------------*/
+
+void Scene406::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene406::enter() {
+	_game._player._visible = true;
+	if (_scene->_priorSceneId == 405) {
+		_game._player._playerPos = Common::Point(15, 129);
+		_game._player._facing = FACING_EAST;
+	} else if (_scene->_priorSceneId == 407) {
+		_game._player._playerPos = Common::Point(270, 127);
+		_game._player._facing = FACING_WEST;
+	} else if (_scene->_priorSceneId == 410) {
+		_game._player._playerPos = Common::Point(30, 108);
+		_game._player._facing = FACING_SOUTH;
+	} else if (_scene->_priorSceneId == 411) {
+		_game._player._playerPos = Common::Point(153, 108);
+		_game._player._facing = FACING_SOUTH;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(15, 129);
+		_game._player._facing = FACING_EAST;
+	}
+
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*ROXCL_8");
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 1));
+
+	if (_scene->_roomChanged) {
+		_globals[kStorageDoorOpen] = false;
+		_game._objects.addToInventory(OBJ_SECURITY_CARD);
+	}
+
+	if (!_globals[kStorageDoorOpen])
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+
+	if (_scene->_priorSceneId != 411)
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+	else {
+		_game._player._stepEnabled = false;
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 3, 1, 0, 0);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 90);
+		_vm->_sound->command(19);
+	}
+
+	_game.loadQuoteSet(0x24F, 0);
+	_hitStorageDoor = false;
+	sceneEntrySound();
+}
+
+void Scene406::step() {
+	if (_game._trigger == 90) {
+		_game._player._stepEnabled = true;
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+	}
+
+	if (_game._trigger == 80)
+		_scene->_nextSceneId = 411;
+
+	if (_game._trigger == 100) {
+		_vm->_dialogs->show(40622);
+		_hitStorageDoor = true;
+	}
+
+	if (_game._trigger == 110) {
+		_scene->_sequences.addTimer(20, 111);
+		_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
+		_game._player._visible = true;
+	}
+
+	if (_game._trigger == 111) {
+		_game._player._stepEnabled = true;
+		_vm->_dialogs->show(40613);
+	}
+
+	if (_game._trigger == 70) {
+		_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
+		_game._player._visible = true;
+		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 4, 1, 0, 0);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
+		_vm->_sound->command(19);
+	}
+
+	if (_game._trigger == 71) {
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+		_globals[kStorageDoorOpen] = false;
+		_game._player._stepEnabled = true;
+	}
+
+	if (_game._trigger == 75) {
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[1], false, 4, 1, 0, 0);
+		_globals[kStorageDoorOpen] = true;
+		_game._player._stepEnabled = true;
+		_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
+		_game._player._visible = true;
+		_vm->_sound->command(19);
+	}
+}
+
+void Scene406::preActions() {
+	if (_action.isAction(0x1AD, 0x2BA))
+		_game._player._walkOffScreenSceneId = 405;
+
+	if (_action.isAction(0x1AD, 0x2B9))
+		_game._player._walkOffScreenSceneId = 407;
+
+	if (_action.isAction(VERB_TAKE))
+		_game._player._needToWalk = false;
+
+	if (_action.isAction(VERB_LOOK, 0x244) || _action.isAction(VERB_LOOK, 0x25C))
+		_game._player._needToWalk = true;
+}
+
+void Scene406::actions() {
+	if (_action.isAction(0x18B, 0x6E) && (_game._player._targetPos.x> 100)) {
+		_game._player._stepEnabled = false;
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[3], false, 3, 1, 0, 0);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
+		_vm->_sound->command(19);
+	} else if (_action.isAction(0x18B, 0x6E) && _globals[kStorageDoorOpen] && (_game._player._targetPos.x < 100))
+		_scene->_nextSceneId = 410;
+	else if (_action.isAction(0x18B, 0x6E) && !_globals[kStorageDoorOpen] && (_game._player._targetPos.x < 100)) {
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 60, _game.getQuote(0x24F));
+		if (!_hitStorageDoor) {
+			_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+			_scene->_sequences.addTimer(80, 100);
+		}
+	} else if (_action.isAction(VERB_PUT, 0x131, 0x251) && !_globals[kStorageDoorOpen]) {
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 7, 2, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 2);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 75);
+		Common::Point msgPos = Common::Point(_game._player._playerPos.x, _game._player._playerPos.y + 1);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], msgPos);
+		_scene->_sequences.setScale(_globals._sequenceIndexes[2], 87);
+	} else if (_action.isAction(VERB_PUT, 0x131, 0x251) && _globals[kStorageDoorOpen]) {
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 7, 2, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 2);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
+		Common::Point msgPos = Common::Point(_game._player._playerPos.x, _game._player._playerPos.y + 1);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], msgPos);
+		_scene->_sequences.setScale(_globals._sequenceIndexes[2], 87);
+	} else if (_action.isAction(VERB_PUT, 0x251)) {
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 7, 2, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 2);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 110);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], _game._player._playerPos);
+		_scene->_sequences.setScale(_globals._sequenceIndexes[2], 87);
+	} else if (_action.isAction(VERB_LOOK, 0x25C))
+		_vm->_dialogs->show(40610);
+	else if (_action.isAction(VERB_TAKE, 0x25C))
+		_vm->_dialogs->show(40611);
+	else if (_action.isAction(VERB_LOOK, 0x251))
+		_vm->_dialogs->show(40612);
+	else if (_action.isAction(VERB_LOOK, 0x25B))
+		_vm->_dialogs->show(40614);
+	else if (_action.isAction(VERB_TAKE, 0x25B))
+		_vm->_dialogs->show(40615);
+	else if (_action.isAction(VERB_LOOK, 0x2B9))
+		_vm->_dialogs->show(40616);
+	else if (_action.isAction(VERB_LOOK, 0x2BA))
+		_vm->_dialogs->show(40617);
+	else if (_action.isAction(VERB_LOOK, 0x204) || _action._lookFlag)
+		_vm->_dialogs->show(40618);
+	else if (_action.isAction(VERB_LOOK, 0x18D))
+		_vm->_dialogs->show(40619);
+	else if (_action.isAction(VERB_LOOK, 0x6E)) {
+		if (_globals[kStorageDoorOpen])
+			_vm->_dialogs->show(40621);
+		else
+			_vm->_dialogs->show(40620);
+	} else if (_action.isAction(VERB_LOOK, 0xE2))
+		_vm->_dialogs->show(40623);
+	else if (_action.isAction(VERB_LOOK, 0x47A))
+		_vm->_dialogs->show(40624);
+	else if (_action.isAction(VERB_TAKE, 0x47A))
+		_vm->_dialogs->show(40625);
+	else if (_action.isAction(VERB_LOOK, 0x2F))
+		_vm->_dialogs->show(40626);
+	else if (_action.isAction(VERB_TAKE, 0x2F))
+		_vm->_dialogs->show(40627);
+	else if (_action.isAction(VERB_LOOK, 0x244))
+		_vm->_dialogs->show(40628);
+	else if (_action.isAction(VERB_TAKE, 0x244))
+		_vm->_dialogs->show(40629);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes4.h b/engines/mads/nebular/nebular_scenes4.h
index 38803fe..02115d7 100644
--- a/engines/mads/nebular/nebular_scenes4.h
+++ b/engines/mads/nebular/nebular_scenes4.h
@@ -140,6 +140,21 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene406: public Scene4xx {
+private:
+	bool _hitStorageDoor;
+
+public:
+	Scene406(MADSEngine *vm) : Scene4xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 0350cc79b3db9eb3e35314730f6e067bc6693c82
    https://github.com/scummvm/scummvm/commit/0350cc79b3db9eb3e35314730f6e067bc6693c82
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-01T18:20:10+02:00

Commit Message:
MADS: Implement scene 407

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes4.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index edee1d9..e25f39c 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -177,7 +177,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 406:
 		return new Scene406(vm);
 	case 407:
-		// TODO
+		return new Scene407(vm);
 	case 408:
 		// TODO
 	case 409:
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index f6f3b41..1335bd6 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -2677,5 +2677,113 @@ void Scene406::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene407::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene407::enter() {
+	if (_scene->_priorSceneId != -2)
+		_fromNorth = false;
+
+	if (_scene->_priorSceneId == 318) {
+		_game._player._playerPos = Common::Point(172, 92);
+		_game._player._facing = FACING_SOUTH;
+		_fromNorth = true;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(172, 132);
+		_game._player._facing = FACING_NORTH;
+	}
+
+	_game.loadQuoteSet(0x250, 0);
+	sceneEntrySound();
+}
+
+void Scene407::step() {
+	if (_game._trigger == 70) {
+		_scene->_nextSceneId = 318;
+		_scene->_reloadSceneFlag = true;
+	}
+
+	if (_game._trigger == 80) {
+		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+		_game._player._stepEnabled = true;
+		_game._player._visible = true;
+		_fromNorth = false;
+		_game._player.walk(Common::Point(173, 104), FACING_SOUTH);
+	}
+}
+
+void Scene407::preActions() {
+	if (_action.isAction(VERB_TAKE))
+		_game._player._needToWalk = false;
+
+	if (_action.isAction(VERB_LOOK, 0x6E))
+		_game._player._needToWalk = true;
+
+	if (_action.isAction(0x1AD, 0x2B4)) {
+		_game._player.walk(Common::Point(172, 91), FACING_NORTH);
+		_fromNorth = false;
+	}
+
+	if (_game._player._needToWalk && _fromNorth) {
+		if (_globals[kSexOfRex] == REX_MALE)
+			destPos = Common::Point(171, 95);
+		else
+			destPos = Common::Point(173, 96);
+
+		_game._player.walk(destPos, FACING_SOUTH);
+	}
+}
+
+void Scene407::actions() {
+	if ((_game._player._playerPos == destPos) && _fromNorth) {
+		if (_globals[kSexOfRex] == REX_MALE) {
+			_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_vm->_sound->command(21);
+			_scene->loadAnimation(formAnimName('s', 1), 70);
+			_globals[kHasBeenScanned] = true;
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 60, _game.getQuote(60));
+			_vm->_sound->command(22);
+		}
+
+		if (_globals[kSexOfRex] == REX_FEMALE) {
+			_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_vm->_sound->command(21);
+			_scene->loadAnimation(formAnimName('s', 2), 80);
+			_vm->_sound->command(23);
+			_globals[kHasBeenScanned] = true;
+		}
+	}
+
+	if (_action.isAction(0x1AD, 0x2B3) && !_fromNorth)
+		_scene->_nextSceneId = 406;
+	else if (_action.isAction(0x1AD, 0x2B4))
+		_scene->_nextSceneId = 318;
+	else if (_action.isAction(VERB_LOOK, 0x1F3)) {
+		if (_globals[kHasBeenScanned])
+			_vm->_dialogs->show(40711);
+		else
+			_vm->_dialogs->show(40710);
+	} else if (_action.isAction(VERB_LOOK, 0x6E))
+		_vm->_dialogs->show(40712);
+	else if (_action.isAction(VERB_LOOK, 0x2B3))
+		_vm->_dialogs->show(40713);
+	else if (_action.isAction(VERB_LOOK, 0x2B4))
+		_vm->_dialogs->show(40714);
+	else if (_action._lookFlag)
+		_vm->_dialogs->show(40715);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes4.h b/engines/mads/nebular/nebular_scenes4.h
index 02115d7..e105547 100644
--- a/engines/mads/nebular/nebular_scenes4.h
+++ b/engines/mads/nebular/nebular_scenes4.h
@@ -155,6 +155,21 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene407: public Scene4xx {
+private:
+	bool _fromNorth;
+	Common::Point destPos;
+
+public:
+	Scene407(MADSEngine *vm) : Scene4xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: b9a1b5376188c2e75d6aa2dba0fceba17fe3b2a6
    https://github.com/scummvm/scummvm/commit/b9a1b5376188c2e75d6aa2dba0fceba17fe3b2a6
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-01T19:15:28+02:00

Commit Message:
MADS: Implement scene 408

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes4.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index e25f39c..ab1256a 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -179,7 +179,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 407:
 		return new Scene407(vm);
 	case 408:
-		// TODO
+		return new Scene408(vm);
 	case 409:
 		// TODO
 	case 410:
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index 1335bd6..9b0c5af 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -2785,5 +2785,159 @@ void Scene407::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene408::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x167);
+	_scene->addActiveVocab(0xD);
+}
+
+void Scene408::enter() {
+	_game._player._playerPos = Common::Point(137, 150);
+	_game._player._facing = FACING_NORTH;
+
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites("*ROXRC_7");
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('m', -1));
+
+	if (_game._objects.isInRoom(OBJ_TARGET_MODULE)) {
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 3);
+		int idx = _scene->_dynamicHotspots.add(0x167, 0xD, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(283, 128), FACING_NORTHEAST);
+	}
+	sceneEntrySound();
+}
+
+void Scene408::preActions() {
+	if ((_action.isAction(VERB_TAKE) && !_action.isAction(0x167)) || _action.isAction(VERB_PULL, 0x47B) || _action.isAction(VERB_OPEN, 0x265))
+		_game._player._needToWalk = false;
+
+	if ((_action.isAction(VERB_LOOK, 0x167) && _game._objects.isInRoom(0x17)) || _action.isAction(VERB_LOOK, 0x263))
+		_game._player._needToWalk = true;
+}
+
+void Scene408::actions() {
+	if (_action.isAction(0x242, 0x2B3)) {
+		_scene->_nextSceneId = 405;
+		_vm->_sound->command(58);
+	} else if (_action.isAction(VERB_TAKE, 0x167) && (_game._objects.isInRoom(OBJ_TARGET_MODULE) || _game._trigger)) {
+		switch (_game._trigger) {
+		case (0):
+			_vm->_sound->command(57);
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], true, 7, 2, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[1]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_SPRITE, 2, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+
+		case 1:
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_game._objects.addToInventory(OBJ_TARGET_MODULE);
+			_vm->_dialogs->showItem(OBJ_TARGET_MODULE, 40847);
+			break;
+
+		case 2:
+			_game._player._priorTimer = _game._player._ticksAmount + _scene->_frameStartTime;
+			_game._player._visible = true;
+			_scene->_sequences.addTimer(20, 3);
+			break;
+
+		case 3:
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x2BC))
+		_vm->_dialogs->show(40810);
+	else if (_action.isAction(VERB_TAKE, 0x2BC) || _action.isAction(VERB_TAKE, 0x261) || _action.isAction(VERB_TAKE, 0x25F))
+		_vm->_dialogs->show(40811);
+	else if (_action.isAction(VERB_LOOK, 0x2BE))
+		_vm->_dialogs->show(40812);
+	else if (_action.isAction(VERB_TAKE, 0x2BE))
+		_vm->_dialogs->show(40813);
+	else if (_action.isAction(VERB_LOOK, 0x2C2))
+		_vm->_dialogs->show(40814);
+	else if (_action.isAction(VERB_TAKE, 0x2C2))
+		_vm->_dialogs->show(40815);
+	else if (_action.isAction(VERB_TAKE, 0x47B) || _action.isAction(VERB_PULL, 0x47B))
+		_vm->_dialogs->show(40816);
+	else if (_action.isAction(VERB_LOOK, 0x26D))
+		_vm->_dialogs->show(40817);
+	else if (_action.isAction(VERB_TAKE, 0x26D))
+		_vm->_dialogs->show(40818);
+	else if (_action.isAction(VERB_LOOK, 0x2BB))
+		_vm->_dialogs->show(40819);
+	else if (_action.isAction(VERB_TAKE, 0x2BB))
+		_vm->_dialogs->show(40820);
+	else if (_action.isAction(VERB_LOOK, 0x269))
+		_vm->_dialogs->show(40821);
+	else if (_action.isAction(VERB_TAKE, 0x269))
+		_vm->_dialogs->show(40822);
+	else if (_action.isAction(VERB_LOOK, 0x263)) {
+		if (_game._objects.isInRoom(OBJ_TARGET_MODULE))
+			_vm->_dialogs->show(40823);
+		else
+			_vm->_dialogs->show(40824);
+	} else if (_action.isAction(VERB_TAKE, 0x263))
+		_vm->_dialogs->show(40825);
+	else if (_action.isAction(VERB_LOOK, 0x2BF))
+		_vm->_dialogs->show(40826);
+	else if (_action.isAction(VERB_TAKE, 0x2BF))
+		_vm->_dialogs->show(40827);
+	else if (_action.isAction(VERB_LOOK, 0x7B))
+		_vm->_dialogs->show(40828);
+	else if (_action.isAction(VERB_OPEN, 0x7B) || _action.isAction(VERB_PULL, 0x7B))
+		_vm->_dialogs->show(40829);
+	else if (_action.isAction(VERB_LOOK, 0x26B))
+		_vm->_dialogs->show(40830);
+	else if (_action.isAction(VERB_TAKE, 0x26B))
+		_vm->_dialogs->show(40831);
+	else if (_action.isAction(VERB_LOOK, 0x2C1))
+		_vm->_dialogs->show(40832);
+	else if (_action.isAction(VERB_TAKE, 0x2C1))
+		_vm->_dialogs->show(40833);
+	else if (_action.isAction(VERB_LOOK, 0x2BD))
+		_vm->_dialogs->show(40834);
+	else if (_action.isAction(VERB_TAKE, 0x2BD))
+		_vm->_dialogs->show(40835);
+	else if (_action.isAction(VERB_LOOK, 0x261))
+		_vm->_dialogs->show(40836);
+	else if (_action.isAction(VERB_LOOK, 0x25F))
+		_vm->_dialogs->show(40837);
+	else if (_action.isAction(VERB_LOOK, 0x2C0))
+		_vm->_dialogs->show(40838);
+	else if (_action.isAction(VERB_LOOK, 0x47C))
+		_vm->_dialogs->show(40839);
+	else if (_action.isAction(VERB_TAKE, 0x47C))
+		_vm->_dialogs->show(40840);
+	else if (_action.isAction(VERB_LOOK, 0x265))
+		_vm->_dialogs->show(40841);
+	else if (_action.isAction(VERB_TAKE, 0x265))
+		_vm->_dialogs->show(40842);
+	else if (_action.isAction(VERB_OPEN, 0x265))
+		_vm->_dialogs->show(40843);
+	else if (_action.isAction(VERB_LOOK, 0x2B3))
+		_vm->_dialogs->show(40844);
+	else if (_action._lookFlag)
+		_vm->_dialogs->show(40845);
+	else if (_action.isAction(VERB_LOOK, 0x167) && _game._objects.isInRoom(OBJ_TARGET_MODULE))
+		_vm->_dialogs->show(40846);
+	else if (_action.isAction(VERB_LOOK, 0x26C))
+		_vm->_dialogs->show(40848);
+	else if (_action.isAction(VERB_OPEN, 0x263))
+		_vm->_dialogs->show(40849);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes4.h b/engines/mads/nebular/nebular_scenes4.h
index e105547..77d34d7 100644
--- a/engines/mads/nebular/nebular_scenes4.h
+++ b/engines/mads/nebular/nebular_scenes4.h
@@ -170,6 +170,18 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene408: public Scene4xx {
+public:
+	Scene408(MADSEngine *vm) : Scene4xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: c5aa86f9651e9518a56e7714561e4569f1be785d
    https://github.com/scummvm/scummvm/commit/c5aa86f9651e9518a56e7714561e4569f1be785d
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-01T23:58:02+02:00

Commit Message:
MADS: Implement scene 410

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes4.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index ab1256a..a3cfe8b 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -183,7 +183,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 409:
 		// TODO
 	case 410:
-		// TODO
+		return new Scene410(vm);
 	case 411:
 		// TODO
 	case 413:
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index 9b0c5af..93ab7dd 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -2939,5 +2939,167 @@ void Scene408::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene410::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene410::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('y', -1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*ROXRC_7");
+
+	if (_game._objects.isInRoom(OBJ_CHARGE_CASES))
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+	else
+		_scene->_hotspots.activate(0x48, false);
+
+	if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(155, 150);
+		_game._player._facing = FACING_NORTH;
+	}
+
+	sceneEntrySound();
+
+	_scene->loadAnimation(Resources::formatName(410, 'r', -1, EXT_AA, ""));
+	_scene->_activeAnimation->_resetFlag = true;
+}
+
+void Scene410::step() {
+	if (_scene->_activeAnimation->getCurrentFrame() == 1) {
+		if (_vm->getRandomNumber(1, 30) == 1)
+			_scene->_activeAnimation->setCurrentFrame(2);
+		else
+			_scene->_activeAnimation->setCurrentFrame(0);
+	}
+
+	if (_scene->_activeAnimation->getCurrentFrame() == 9) {
+		if (_vm->getRandomNumber(1, 30) == 1)
+			_scene->_activeAnimation->setCurrentFrame(10);
+		else
+			_scene->_activeAnimation->setCurrentFrame(8);
+	}
+
+	if (_scene->_activeAnimation->getCurrentFrame() == 5) {
+		if (_vm->getRandomNumber(1, 30) == 1)
+			_scene->_activeAnimation->setCurrentFrame(6);
+		else
+			_scene->_activeAnimation->setCurrentFrame(4);
+	}
+
+	if (_scene->_activeAnimation->getCurrentFrame() == 3) {
+		if (_vm->getRandomNumber(1, 2) == 1)
+			_scene->_activeAnimation->setCurrentFrame(4);
+		else // == 2
+			_scene->_activeAnimation->setCurrentFrame(8);
+	}
+}
+
+void Scene410::preActions() {
+	if (_action.isAction(VERB_TAKE) && !_action.isAction(0x48))
+		_game._player._needToWalk = false;
+
+	if (_action.isAction(VERB_LOOK, 0x48) && _game._objects.isInRoom(OBJ_CHARGE_CASES))
+		_game._player._needToWalk = true;
+
+	if (_action.isAction(VERB_OPEN, 0x278) || _action.isAction(VERB_OPEN, 0x214))
+		_game._player._needToWalk = false;
+
+	if (_action.isAction(VERB_LOOK, 0x272))
+		_game._player._needToWalk = true;
+}
+
+void Scene410::actions() {
+	if (_action.isAction(0x242, 0x2B3))
+		_scene->_nextSceneId = 406;
+	else if (_action.isAction(VERB_TAKE, 0x48) && (_game._objects.isInRoom(OBJ_CHARGE_CASES) || _game._trigger)) {
+		switch (_game._trigger) {
+		case (0):
+			_vm->_sound->command(57);
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;  
+			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 7, 2, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 3);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 3, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+
+		case 1:
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_scene->_hotspots.activate(0x48, false);
+			_game._objects.addToInventory(OBJ_CHARGE_CASES);
+			_vm->_dialogs->showItem(OBJ_CHARGE_CASES, 41032);
+			break;
+
+		case 2:
+			_game._player._priorTimer = _game._player._ticksAmount + _scene->_frameStartTime;
+			_game._player._visible = true;
+			_scene->_sequences.addTimer(20, 3);
+			break;
+
+		case 3:
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x276))
+		_vm->_dialogs->show(41010);
+	else if (_action.isAction(VERB_TAKE, 0x276))
+		_vm->_dialogs->show(41011);
+	else if (_action.isAction(VERB_OPEN, 0x276))
+		_vm->_dialogs->show(41012);
+	else if (_action.isAction(VERB_LOOK, 0x270))
+		_vm->_dialogs->show(41013);
+	else if (_action.isAction(VERB_TAKE, 0x270))
+		_vm->_dialogs->show(41014);
+	else if (_action.isAction(VERB_LOOK, 0x265) || _action.isAction(VERB_OPEN, 0x265)) {
+		if (_game._objects.isInRoom(OBJ_CHARGE_CASES))
+			_vm->_dialogs->show(41015);
+		else
+			_vm->_dialogs->show(41016);
+	} else if (_action.isAction(VERB_LOOK, 0x26E))
+		_vm->_dialogs->show(41017);
+	else if (_action.isAction(VERB_TAKE, 0x26E))
+		_vm->_dialogs->show(41018);
+	else if (_action.isAction(VERB_LOOK, 0x278))
+		_vm->_dialogs->show(41019);
+	else if (_action.isAction(VERB_LOOK, 0x214))
+		_vm->_dialogs->show(41019);
+	else if (_action.isAction(VERB_OPEN, 0x278))
+		_vm->_dialogs->show(41020);
+	else if (_action.isAction(VERB_OPEN, 0x214))
+		_vm->_dialogs->show(41020);
+	else if (_action.isAction(VERB_LOOK, 0x277))
+		_vm->_dialogs->show(41021);
+	else if (_action.isAction(VERB_TAKE, 0x277))
+		_vm->_dialogs->show(41022);
+	else if (_action.isAction(VERB_LOOK, 0x272))
+		_vm->_dialogs->show(41023);
+	else if (_action.isAction(VERB_TAKE, 0x272))
+		_vm->_dialogs->show(41024);
+	else if (_action.isAction(VERB_LOOK, 0x48) && _game._objects.isInRoom(OBJ_CHARGE_CASES))
+		_vm->_dialogs->show(41025);
+	else if (_action.isAction(VERB_LOOK, 0x2C3))
+		_vm->_dialogs->show(41027);
+	else if (_action.isAction(VERB_LOOK, 0x47D))
+		_vm->_dialogs->show(41028);
+	else if (_action.isAction(VERB_LOOK, 0x275))
+		_vm->_dialogs->show(41029);
+	else if (_action.isAction(VERB_TAKE, 0x275))
+		_vm->_dialogs->show(41030);
+	else if (_action.isAction(VERB_THROW, 0x275))
+		_vm->_dialogs->show(41031);
+	else if (_action._lookFlag)
+		_vm->_dialogs->show(41033);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes4.h b/engines/mads/nebular/nebular_scenes4.h
index 77d34d7..2b96b7e 100644
--- a/engines/mads/nebular/nebular_scenes4.h
+++ b/engines/mads/nebular/nebular_scenes4.h
@@ -182,6 +182,18 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene410: public Scene4xx {
+public:
+	Scene410(MADSEngine *vm) : Scene4xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 8c58a046dbae7c07b06b21c4b42d3b5206841569
    https://github.com/scummvm/scummvm/commit/8c58a046dbae7c07b06b21c4b42d3b5206841569
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-01T20:54:17-04:00

Commit Message:
MADS: Fix palette corruption when playing animations

Changed paths:
    engines/mads/animation.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index bfcbe16..32f4320 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -333,7 +333,7 @@ void Animation::startAnimation(int endTrigger) {
 	}
 
 	if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE)
-		_vm->_palette->refreshHighColors();
+		_vm->_palette->refreshSceneColors();
 
 	_currentFrame = 0;
 	_oldFrameEntry = 0;
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 4e63ba2..54973b7 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -1601,7 +1601,7 @@ void Scene104::step() {
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
 				_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 0));
-				_vm->_palette->refreshHighColors();
+				_vm->_palette->refreshSceneColors();
 				_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], mirrorFl, 7, 1, 0, 0);
 				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(198, 143));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
@@ -1631,7 +1631,7 @@ void Scene104::step() {
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
 				_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 1));
-				_vm->_palette->refreshHighColors();
+				_vm->_palette->refreshSceneColors();
 				_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 1, 0, 0);
 				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(198, 143));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 4);
@@ -1670,7 +1670,7 @@ void Scene104::step() {
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
 				_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('a', 2));
-				_vm->_palette->refreshHighColors();
+				_vm->_palette->refreshSceneColors();
 				_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 8, 1, 0, 0);
 				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(198, 143));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 4);
@@ -1794,7 +1794,7 @@ void Scene105::step() {
 			_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('m', 3));
 			_vm->_sound->command(33);
 			_scene->clearSequenceList();
-			_vm->_palette->refreshHighColors();
+			_vm->_palette->refreshSceneColors();
 
 			_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 6, 1, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[0], 8);
@@ -2426,7 +2426,7 @@ void Scene109::step() {
 		_beforeEatingRex = true;
 		_scene->_sprites.remove(_globals._spriteIndexes[6]);
 		_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('H', 0));
-		_vm->_palette->refreshHighColors();
+		_vm->_palette->refreshSceneColors();
 	}
 
 	if (_game._player._moving && (_scene->_rails.getNext() > 0) && _globals[kHoovicAlive] && !_globals[kHoovicSated] && !_hungryFl && !_beforeEatingRex) {
@@ -2523,7 +2523,7 @@ void Scene109::actions() {
 							break;
 						}
 
-						_vm->_palette->refreshHighColors();
+						_vm->_palette->refreshSceneColors();
 						break;
 
 					case 1:
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index d9a46a9..51de276 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -523,12 +523,12 @@ void Palette::unlock() {
 	_lockFl = false;
 }
 
-void Palette::refreshHighColors() {
+void Palette::refreshSceneColors() {
 	int val = 18;
 	if (_vm->_game->_scene._cyclingActive)
 		val += _vm->_game->_scene._totalCycleColors;
 
-	setPalette(_mainPalette, val, 256 - val);
+	setPalette(_mainPalette + (val * 3), val, 256 - val);
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 0d808ce..d1c7c1d 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -255,7 +255,7 @@ public:
 	void lock();
 	void unlock();
 
-	void refreshHighColors();
+	void refreshSceneColors();
 };
 
 } // End of namespace MADS


Commit: d888938d9b6d2e393eeac3a1b2551ccc8d36f49e
    https://github.com/scummvm/scummvm/commit/d888938d9b6d2e393eeac3a1b2551ccc8d36f49e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-02T04:22:21+03:00

Commit Message:
MADS: Add a sanity check in MADSAction::set()

Changed paths:
    engines/mads/action.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index cfd84bf..f1e27d7 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -226,7 +226,7 @@ void MADSAction::set() {
 					_statusText += kArticleList[articleNum];
 				}
 			} else if ((_articleNumber == VERB_LOOK) || (_vm->getGameID() != GType_RexNebular) ||
-				(scene._vocabStrings[_action._indirectObjectId] != kFenceStr)) {
+				(_action._indirectObjectId >= 0 && scene._vocabStrings[_action._indirectObjectId] != kFenceStr)) {
 				// Write out the article
 				_statusText += kArticleList[_articleNumber];
 			} else {


Commit: 92ab7e87a0e0afc9db1612b4c7d16597fe6499a0
    https://github.com/scummvm/scummvm/commit/92ab7e87a0e0afc9db1612b4c7d16597fe6499a0
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-02T04:22:22+03:00

Commit Message:
MADS: sub70C52 is setMotion

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/sequence.h



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 54973b7..7d8b077 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -2141,7 +2141,7 @@ void Scene107::enter() {
 		_globals._spriteIndexes[0] = _scene->_sprites.addSprites(Resources::formatName(105, 'R', 1, EXT_SS, ""));
 		_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], true, 4, 0, 0, 0);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[0], Common::Point(270, 150));
-		_scene->_sequences.sub70C52(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_SPRITE, -200, 0);
+		_scene->_sequences.setMotion(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_SPRITE, -200, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[0], 2);
 		_scene->_dynamicHotspots.add(218, 348, _globals._sequenceIndexes[0], Common::Rect(0, 0, 0, 0));
 	}
@@ -2386,7 +2386,7 @@ void Scene109::enter() {
 		_globals._sequenceIndexes[10] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[10], true, 4, 0, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 5);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(126, 39));
-		_scene->_sequences.sub70C52(_globals._sequenceIndexes[10], 0, 200, 0);
+		_scene->_sequences.setMotion(_globals._sequenceIndexes[10], 0, 200, 0);
 		_scene->_sequences.setScale(_globals._sequenceIndexes[10], 80);
 		_game._player._stepEnabled = false;
 	}
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 88b3f94..a62ad6b 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -4285,7 +4285,7 @@ void Scene211::enter() {
 		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(202, 126));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 8);
-		_scene->_sequences.sub70C52(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, -200, 0);
+		_scene->_sequences.setMotion(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, -200, 0);
 		_scene->_dynamicHotspots.add(324, 13, _globals._sequenceIndexes[2], Common::Rect(1, 1, 1 + 41, 1 + 10));
 	}
 
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 12917d6..09b3152 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -220,7 +220,7 @@ void Scene3xx::handleForceField(ForceField *force, int *sprites) {
 			force->_seqId[id] = _scene->_sequences.addSpriteCycle(sprites[spriteId], mirror, 2, 0, 0, 0);
 			_scene->_sequences.setDepth(force->_seqId[id], 8);
 			_scene->_sequences.setMsgPosition(force->_seqId[id], Common::Point(posX, posY));
-			_scene->_sequences.sub70C52(force->_seqId[id], 2, speedX, speedY);
+			_scene->_sequences.setMotion(force->_seqId[id], 2, speedX, speedY);
 			_scene->_sequences.addSubEntry(force->_seqId[id], SEQUENCE_TRIGGER_EXPIRE, 0, 150 + id);
 			if (spriteId == 2)
 				force->_horizontal++;
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index 5f052e9..1975900 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -126,7 +126,7 @@ public:
 	void setScale(int spriteIdx, int scale);
 	void setMsgLayout(int seqIndex);
 	void setDone(int seqIndex);
-	void sub70C52(int seqIndex, int flags, int deltaX, int deltaY) { warning("TODO: sub70C52()"); }
+	void setMotion(int seqIndex, int flags, int deltaX, int deltaY) { warning("TODO: setMotion()"); }
 };
 
 } // End of namespace MADS


Commit: b5949010a61e3d12f22ea762ed8d09cc1a79b850
    https://github.com/scummvm/scummvm/commit/b5949010a61e3d12f22ea762ed8d09cc1a79b850
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-01T22:36:36-04:00

Commit Message:
MADS: Implemented more savegame synchronization

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/game_data.cpp
    engines/mads/game_data.h
    engines/mads/globals.h
    engines/mads/hotspots.cpp
    engines/mads/hotspots.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/game_nebular.h
    engines/mads/nebular/globals_nebular.cpp
    engines/mads/nebular/globals_nebular.h
    engines/mads/player.cpp
    engines/mads/resources.cpp
    engines/mads/resources.h
    engines/mads/scene.cpp
    engines/mads/scene_data.h
    engines/mads/screen.cpp
    engines/mads/screen.h
    engines/mads/user_interface.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index f1e27d7..48393e1 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -24,6 +24,7 @@
 #include "mads/mads.h"
 #include "mads/action.h"
 #include "mads/inventory.h"
+#include "mads/resources.h"
 #include "mads/scene.h"
 #include "mads/staticres.h"
 
@@ -35,6 +36,18 @@ void ActionDetails::synchronize(Common::Serializer &s) {
 	s.syncAsUint16LE(_indirectObjectId);
 }
 
+void ActionSavedFields::synchronize(Common::Serializer &s) {
+	s.syncAsByte(_commandError);
+	s.syncAsSint16LE(_commandSource);
+	s.syncAsSint16LE(_command);
+	s.syncAsSint16LE(_mainObject);
+	s.syncAsSint16LE(_secondObject);
+	s.syncAsSint16LE(_mainObjectSource);
+	s.syncAsSint16LE(_secondObjectSource);
+	s.syncAsSint16LE(_articleNumber);
+	s.syncAsSint16LE(_lookFlag);
+}
+
 /*------------------------------------------------------------------------*/
 
 MADSAction::MADSAction(MADSEngine *vm) : _vm(vm) {
@@ -645,4 +658,31 @@ void MADSAction::leftClick() {
 	}
 }
 
+void MADSAction::synchronize(Common::Serializer &s) {
+	_action.synchronize(s);
+	_activeAction.synchronize(s);
+	s.syncAsSint16LE(_articleNumber);
+	s.syncAsByte(_lookFlag);
+	s.syncAsByte(_textChanged);
+	s.syncAsSint16LE(_selectedRow);
+	s.syncAsSint16LE(_selectedAction);
+	s.syncAsSint16LE(_statusTextIndex);
+	s.syncAsSint16LE(_hotspotId);
+	_savedFields.synchronize(s);
+	synchronizeString(s, _sentence);
+
+	s.syncAsSint16LE(_verbType);
+	s.syncAsSint16LE(_prepType);
+	s.syncAsSint16LE(_commandSource);
+	s.syncAsSint16LE(_mainObjectSource);
+	s.syncAsSint16LE(_secondObject);
+	s.syncAsSint16LE(_secondObjectSource);
+	s.syncAsSint16LE(_recentCommandSource);
+	s.syncAsSint16LE(_recentCommand);
+	s.syncAsSint16LE(_interAwaiting);
+	s.syncAsSint16LE(_pickedWord);
+	s.syncAsByte(_pointEstablished);
+	s.syncAsByte(_inProgress);
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/action.h b/engines/mads/action.h
index 6e51e12..ac6c35c 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -78,6 +78,9 @@ struct ActionDetails {
 	int _objectNameId;
 	int _indirectObjectId;
 
+	/**
+	 * Synchronize the action details
+	 */
 	void synchronize(Common::Serializer &s);
 };
 
@@ -91,6 +94,11 @@ struct ActionSavedFields {
 	int _secondObjectSource;
 	int _articleNumber;
 	int _lookFlag;
+
+	/**
+	* Synchronize the saved action details
+	*/
+	void synchronize(Common::Serializer &s);
 };
 
 class MADSAction {
@@ -117,11 +125,11 @@ public:
 	PrepType _prepType;
 	ScrCategory _commandSource;
 	ScrCategory _mainObjectSource;
-	int16 _secondObject;
+	int _secondObject;
 	ScrCategory _secondObjectSource;
 	ScrCategory _recentCommandSource;
 	bool _pointEstablished;
-	int16 _recentCommand;
+	int  _recentCommand;
 	InterAwaiting _interAwaiting;
 	bool _inProgress;
 	int _pickedWord;
@@ -154,6 +162,11 @@ public:
 	* Execute a click within the scene
 	*/
 	void leftClick();
+
+	/**
+	* Synchronize the saved action details
+	*/
+	void synchronize(Common::Serializer &s);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 1435681..4b8805d 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -59,8 +59,8 @@ Game *Game::init(MADSEngine *vm) {
 Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm), 
 		_scene(vm), _screenObjects(vm), _player(vm) {
 	_sectionNumber = _priorSectionNumber = 0;
-	_difficulty = DIFFICULTY_IMPOSSIBLE;
 	_loadGameSlot = -1;
+	_lastSave = -1;
 	_saveFile = nullptr;
 	_statusFlag = 0;
 	_sectionHandler = nullptr;
@@ -452,24 +452,26 @@ void Game::handleKeypress(const Common::Event &event) {
 
 void Game::synchronize(Common::Serializer &s, bool phase1) {
 	if (phase1) {
-		s.syncAsUint16LE(_scene._nextSceneId);
-		s.syncAsUint16LE(_scene._priorSceneId);
+		s.syncAsSint16LE(_fx);
+		s.syncAsSint16LE(_trigger);
+		s.syncAsUint16LE(_triggerSetupMode);
+		s.syncAsUint16LE(_triggerMode);
+		synchronizeString(s, _aaName);
+		s.syncAsSint16LE(_lastSave);
+
+		_scene.synchronize(s);
+		_objects.synchronize(s);
 		_visitedScenes.synchronize(s);
+		_player.synchronize(s);
+		_screenObjects.synchronize(s);
 
 		if (s.isLoading()) {
 			_sectionNumber = _scene._nextSceneId / 100;
 			_currentSectionNumber = _sectionNumber;
-			_scene._frameStartTime = _vm->_events->getFrameCounter();
-
-			_player._spritesLoaded = false;
-			_player._spritesChanged = true;
 		}
 	} else {
-		s.syncAsByte(_difficulty);
-		
-		_scene.synchronize(s);
-		_objects.synchronize(s);
-		_player.synchronize(s);
+		// Load scene specific data for the loaded scene
+		_scene._sceneLogic->synchronize(s);
 	}
 }
 
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 246a785..5ae670d 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -43,10 +43,6 @@ enum {
 	PLAYER_INVENTORY = 2
 };
 
-enum Difficulty {
-	DIFFICULTY_HARD = 1, DIFFICULTY_REALLY_HARD = 2, DIFFICULTY_IMPOSSIBLE = 3
-};
-
 enum KernelMode {
 	KERNEL_GAME_LOAD = 0, KERNEL_SECTION_PRELOAD = 1, KERNEL_SECTION_INIT = 2,
 	KERNEL_ROOM_PRELOAD = 3, KERNEL_ROOM_INIT = 4, KERNEL_ACTIVE_CODE = 5
@@ -92,6 +88,7 @@ protected:
 	bool _vocabEmergency;
 	bool _anyEmergency;
 	int _loadGameSlot;
+	int _lastSave;
 	Common::String _saveName;
 	Common::InSaveFile *_saveFile;
 
@@ -136,7 +133,6 @@ public:
 public:
 	Player _player;
 	ScreenObjects _screenObjects;
-	Difficulty _difficulty;
 	int _sectionNumber;
 	int _priorSectionNumber;
 	int _currentSectionNumber;
diff --git a/engines/mads/game_data.cpp b/engines/mads/game_data.cpp
index 72137cf..4a9d02c 100644
--- a/engines/mads/game_data.cpp
+++ b/engines/mads/game_data.cpp
@@ -47,22 +47,8 @@ bool VisitedScenes::exists(int sceneId) {
 }
 
 void VisitedScenes::synchronize(Common::Serializer &s) {
-	uint count = size();
-	int v = 0;
-	s.syncAsUint16LE(count);
-
-	if (s.isSaving()) {
-		for (uint i = 0; i < size(); ++i) {
-			v = (*this)[i];
-			s.syncAsSint16LE(v);
-		}
-	} else {
-		clear();
-		for (uint i = 0; i < count; ++i) {
-			s.syncAsSint16LE(v);
-			push_back(v);
-		}
-	}
+	SynchronizedList:synchronize(s);
+	s.syncAsByte(_sceneRevisited);
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/game_data.h b/engines/mads/game_data.h
index 1a8791e..6ea59d6 100644
--- a/engines/mads/game_data.h
+++ b/engines/mads/game_data.h
@@ -25,13 +25,14 @@
 
 #include "common/scummsys.h"
 #include "common/array.h"
+#include "mads/resources.h"
 
 namespace MADS {
 
 class MADSEngine;
 class Game;
 
-class VisitedScenes: public Common::Array<int> {
+class VisitedScenes: public SynchronizedList {
 public:
 	/**
 	 * Stores true when a previously visited scene is revisited
diff --git a/engines/mads/globals.h b/engines/mads/globals.h
index fa7a630..e44e97f 100644
--- a/engines/mads/globals.h
+++ b/engines/mads/globals.h
@@ -48,7 +48,7 @@ public:
 	/**
 	 * Synchronize the globals data
 	 */
-	void synchronize(Common::Serializer &s);
+	virtual void synchronize(Common::Serializer &s);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
index 02617e9..560726b 100644
--- a/engines/mads/hotspots.cpp
+++ b/engines/mads/hotspots.cpp
@@ -34,6 +34,10 @@ DynamicHotspot::DynamicHotspot() {
 	_cursor = CURSOR_NONE;
 }
 
+void DynamicHotspot::synchronize(Common::Serializer &s) {
+
+}
+
 /*------------------------------------------------------------------------*/
 
 DynamicHotspots::DynamicHotspots(MADSEngine *vm) : _vm(vm) {
@@ -142,6 +146,20 @@ void DynamicHotspots::refresh() {
 	}
 }
 
+void DynamicHotspots::synchronize(Common::Serializer &s) {
+	int count = _entries.size();
+	s.syncAsSint16LE(count);
+
+	if (s.isSaving()) {
+		for (int i = 0; i < count; ++i)
+			_entries[i].synchronize(s);
+	} else {
+		DynamicHotspot rec;
+		rec.synchronize(s);
+		_entries.push_back(rec);
+	}
+}
+
 /*------------------------------------------------------------------------*/
 
 Hotspot::Hotspot() {
diff --git a/engines/mads/hotspots.h b/engines/mads/hotspots.h
index 9e1cb44..5fd910e 100644
--- a/engines/mads/hotspots.h
+++ b/engines/mads/hotspots.h
@@ -43,7 +43,15 @@ public:
 	int _articleNumber;
 	CursorType _cursor;
 
+	/**
+	 * Constructor
+	 */
 	DynamicHotspot();
+
+	/**
+	 * Synchronize the data
+	 */
+	void synchronize(Common::Serializer &s);
 };
 
 #define DYNAMIC_HOTSPOTS_SIZE 8
@@ -67,6 +75,11 @@ public:
 	void clear();
 	void reset();
 	void refresh();
+
+	/**
+	* Synchronize the data
+	*/
+	void synchronize(Common::Serializer &s);
 };
 
 class Hotspot {
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 34eb6f1..ce3f086 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -38,6 +38,7 @@ namespace Nebular {
 GameNebular::GameNebular(MADSEngine *vm): Game(vm) {
 	_surface = new MSurface(MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT);
 	_storyMode = STORYMODE_NAUGHTY;
+	_difficulty = DIFFICULTY_IMPOSSIBLE;
 }
 
 ProtectionResult GameNebular::checkCopyProtection() {
@@ -749,6 +750,8 @@ void GameNebular::synchronize(Common::Serializer &s, bool phase1) {
 
 	if (!phase1) {
 		_globals.synchronize(s);
+		s.syncAsByte(_storyMode);
+		s.syncAsByte(_difficulty);
 	}
 }
 
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index 0e2d564..ab82cf6 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -34,6 +34,10 @@ namespace Nebular {
 
 enum StoryMode { STORYMODE_NAUGHTY = 1, STORYMODE_NICE = 2 };
 
+enum Difficulty {
+	DIFFICULTY_HARD = 1, DIFFICULTY_REALLY_HARD = 2, DIFFICULTY_IMPOSSIBLE = 3
+};
+
 enum InventoryObject { OBJ_NONE = -1, OBJ_BINOCULARS = 0,
 	OBJ_BURGER = 1, OBJ_DEAD_FISH = 2, OBJ_STUFFED_FISH = 3, OBJ_REBREATHER = 4,
 	OBJ_TIMER_MODULE = 5, OBJ_BIG_LEAVES = 6, OBJ_POISON_DARTS = 7, OBJ_PLANT_STALK = 8,
@@ -65,6 +69,7 @@ protected:
 public:
 	NebularGlobals _globals;
 	StoryMode _storyMode;
+	Difficulty _difficulty;
 
 	virtual Globals &globals() { return _globals; }
 
diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp
index 4144797..d839d29 100644
--- a/engines/mads/nebular/globals_nebular.cpp
+++ b/engines/mads/nebular/globals_nebular.cpp
@@ -39,6 +39,16 @@ NebularGlobals::NebularGlobals(): Globals() {
 	_timebombTimer = 0;
 }
 
+void NebularGlobals::synchronize(Common::Serializer &s) {
+	Globals::synchronize(s);
+
+	s.syncAsUint32BE(_timebombClock);
+	s.syncAsUint32LE(_timebombTimer);
+	_spriteIndexes.synchronize(s);
+	_sequenceIndexes.synchronize(s);
+}
+
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index 56fbc1b..9a7873f 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -26,6 +26,7 @@
 #include "common/scummsys.h"
 #include "common/array.h"
 #include "mads/game.h"
+#include "mads/resources.h"
 
 namespace MADS {
 
@@ -281,28 +282,20 @@ enum {
 
 class NebularGlobals: public Globals {
 public:
-	Common::Array<int> _spriteIndexes;
-	Common::Array<int> _sequenceIndexes;
+	SynchronizedList _spriteIndexes;
+	SynchronizedList _sequenceIndexes;
 	
 	int _timebombClock, _timebombTimer;
-	/*
-	int _v0;
-	uint32 _frameTime;
-	int _v2;
-	int _v3;
-	int _v4;
-	int _v5;
-	int _v6;
-	uint32 _v7;
-	int _v8;
-	int _abortVal;
-	int _v84262, _v84264, _v84266, _v84268;
-	*/
 public:
 	/**
 	 * Constructor
 	 */
 	NebularGlobals();
+
+	/**
+	* Synchronize the globals data
+	*/
+	virtual void synchronize(Common::Serializer &s);
 };
 
 } // End of namespace Nebular
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 2049042..0c9a496 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -695,71 +695,70 @@ void Player::releasePlayerSprites() {
 }
 
 void Player::synchronize(Common::Serializer &s) {
-	s.syncAsByte(_visible);
-	s.syncAsByte(_priorVisible);
-	s.syncAsByte(_beenVisible);
 	s.syncAsByte(_moving);
-	s.syncAsByte(_stepEnabled);
 	s.syncAsSint16LE(_playerPos.x);
 	s.syncAsSint16LE(_playerPos.y);
 	s.syncAsSint16LE(_targetPos.x);
 	s.syncAsSint16LE(_targetPos.y);
-	s.syncAsSint16LE(_posChange.x);
-	s.syncAsSint16LE(_posChange.y);
-	s.syncAsSint16LE(_posDiff.x);
-	s.syncAsSint16LE(_posDiff.y);
 	s.syncAsSint16LE(_xDirection);
 	s.syncAsSint16LE(_yDirection);
-	s.syncAsUint16LE(_facing);
+	s.syncAsSint16LE(_posDiff.x);
+	s.syncAsSint16LE(_posDiff.y);
+	s.syncAsSint16LE(_posChange.x);
+	s.syncAsSint16LE(_posChange.y);
 	s.syncAsUint16LE(_targetFacing);
-	s.syncAsByte(_spritesChanged);
-	s.syncAsByte(_walkAnywhere);
-	s.syncAsByte(_walkOffScreen);
+	s.syncAsSint16LE(_special);
+	s.syncAsByte(_forceRefresh);
 	s.syncAsSint16LE(_ticksAmount);
-	s.syncAsSint16LE(_centerOfGravity);
+	s.syncAsByte(_walkAnywhere);
 	s.syncAsUint16LE(_walkOffScreenSceneId);
+	s.syncAsByte(_walkOffScreen);
 	s.syncAsByte(_needToWalk);
 	s.syncAsByte(_readyToWalk);
 	s.syncAsUint16LE(_prepareWalkFacing);
 	s.syncAsSint16LE(_prepareWalkPos.x);
 	s.syncAsSint16LE(_prepareWalkPos.y);
+	s.syncAsByte(_stepEnabled);
+	s.syncAsByte(_visible);
+	s.syncAsByte(_priorVisible);
 
-	s.syncAsByte(_mirror);
-	s.syncAsUint16LE(_frameCount);
+	s.syncAsSint16LE(_spritesStart);
+	for (int i = 0; i < 8; ++i)
+		s.syncAsByte(_spriteSetsPresent[i]);
+
+	s.syncAsByte(_facing);
+	s.syncAsByte(_turnToFacing);
+	s.syncAsSint16LE(_spritesIdx);
+	s.syncAsSint16LE(_frameNumber);
+	s.syncAsSint16LE(_currentDepth);
+	s.syncAsSint16LE(_currentScale);
 	s.syncAsSint16LE(_frameListIndex);
-	s.syncAsSint16LE(_distAccum);
-	s.syncAsSint16LE(_pixelAccum);
-	s.syncAsSint16LE(_deltaDistance);
-	
+
 	for (int i = 0; i < 12; ++i) {
 		s.syncAsSint16LE(_stopWalkerList[i]);
 		s.syncAsSint16LE(_stopWalkerTrigger[i]);
 	}
+
 	s.syncAsSint16LE(_stopWalkerIndex);
-	s.syncAsSint16LE(_totalDistance);
-	s.syncAsSint16LE(_frameNumber);
-	s.syncAsSint16LE(_special);
-	s.syncAsSint16LE(_velocity);
-	s.syncAsSint16LE(_scalingVelocity);
 	s.syncAsSint16LE(_upcomingTrigger);
 	s.syncAsSint16LE(_trigger);
-	s.syncAsSint16LE(_currentDepth);
-	s.syncAsSint16LE(_currentScale);
-
-	int count;
-	char ch;
-	if (s.isSaving()) {
-		count = _spritesPrefix.size();
-		s.syncAsUint16LE(count);
-		s.syncBytes((byte *)_spritesPrefix.c_str(), count);
-	} else {
-		s.syncAsSint16LE(count);
-		_spritesPrefix.clear();
-		for (int i = 0; i < count; ++i) {
-			s.syncAsByte(ch);
-			_spritesPrefix += ch;
-		}			
-	}
+	s.syncAsSint16LE(_scalingVelocity);
+	s.syncAsSint16LE(_pixelAccum);
+	s.syncAsSint16LE(_distAccum);
+	s.syncAsSint16LE(_deltaDistance);
+	s.syncAsSint16LE(_totalDistance);
+	s.syncAsSint16LE(_velocity);
+	s.syncAsUint16LE(_frameCount);
+	synchronizeString(s, _spritesPrefix);
+	s.syncAsUint32LE(_priorTimer);
+	s.syncAsSint16LE(_numSprites);
+	s.syncAsByte(_loadsFirst);
+	s.syncAsByte(_loadedFirst);
+	s.syncAsByte(_spritesLoaded);
+	s.syncAsByte(_spritesChanged);
+	s.syncAsByte(_beenVisible);
+	s.syncAsSint16LE(_centerOfGravity);
+	s.syncAsByte(_mirror);
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/resources.cpp b/engines/mads/resources.cpp
index b6caed7..f060944 100644
--- a/engines/mads/resources.cpp
+++ b/engines/mads/resources.cpp
@@ -384,4 +384,45 @@ void File::openFile(const Common::String &filename) {
 		error("Could not open file - %s", filename.c_str());
 }
 
+/*------------------------------------------------------------------------*/
+
+void SynchronizedList::synchronize(Common::Serializer &s) {
+	int v;
+	int count = size();
+	s.syncAsUint16LE(count);
+
+	if (s.isSaving()) {
+		for (int idx = 0; idx < count; ++idx) {
+			v = (*this)[idx];
+			s.syncAsSint32LE(v);
+		}
+	} else {
+		clear();
+		reserve(count);
+		for (int idx = 0; idx < count; ++idx) {
+			s.syncAsSint32LE(v);
+			push_back(v);
+		}
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+void synchronizeString(Common::Serializer &s, Common::String &str) {
+	int len = str.size();
+	char c;
+	s.syncAsUint16LE(len);
+
+	if (s.isSaving()) {
+		s.syncBytes((byte *)str.c_str(), len);
+	} else {
+		str.clear();
+		for (int i = 0; i < len; ++i) {
+			s.syncAsByte(c);
+			str += c;
+		}
+	}
+}
+
+
 } // End of namespace MADS
diff --git a/engines/mads/resources.h b/engines/mads/resources.h
index 3d5d582..7d56138 100644
--- a/engines/mads/resources.h
+++ b/engines/mads/resources.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "common/file.h"
+#include "common/serializer.h"
 #include "common/str.h"
 
 namespace MADS {
@@ -75,6 +76,19 @@ public:
 	void openFile(const Common::String &filename);
 };
 
+class SynchronizedList : public Common::Array<int> {
+public:
+	/**
+	 * Synchronize the list
+	 */
+	void synchronize(Common::Serializer &s);
+};
+
+/**
+* Synchronize string support method
+*/
+void synchronizeString(Common::Serializer &s, Common::String &str);
+
 } // End of namespace MADS
 
 #endif /* MADS_RESOURCES_H */
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 5c86e45..e53061c 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -705,10 +705,14 @@ void Scene::freeAnimation() {
 }
 
 void Scene::synchronize(Common::Serializer &s) {
-	_action._activeAction.synchronize(s);
+	_action.synchronize(s);
 	_rails.synchronize(s);
 	_userInterface.synchronize(s);
-	_sceneLogic->synchronize(s);
+	s.syncAsByte(_reloadSceneFlag);
+	s.syncAsByte(_roomChanged);
+	s.syncAsUint16LE(_nextSceneId);
+	s.syncAsUint16LE(_priorSceneId);
+	_dynamicHotspots.synchronize(s);
 }
 
 } // End of namespace MADS
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 9b1825f..c295ae0 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "common/array.h"
+#include "common/serializer.h"
 #include "common/str.h"
 #include "common/str-array.h"
 #include "common/rect.h"
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index ea73d41..640617e 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -529,6 +529,11 @@ void ScreenObjects::setActive(ScrCategory category, int descId, bool active) {
 	}
 }
 
+void ScreenObjects::synchronize(Common::Serializer &s) {
+	s.syncAsSint16LE(_selectedObject);
+	s.syncAsSint16LE(_category);
+}
+
 /*------------------------------------------------------------------------*/
 
 ScreenSurface::ScreenSurface() {
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index ba01cbc..4ad5820 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -189,6 +189,11 @@ public:
 	 * @param active		Whether to set item as active or not
 	 */
 	void setActive(ScrCategory category, int descId, bool active);
+
+	/**
+	 * Synchronize the data
+	 */
+	void synchronize(Common::Serializer &s);
 };
 
 class ScreenSurface : public MSurface {
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 194fda0..8208c14 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -1092,6 +1092,9 @@ void UserInterface::synchronize(Common::Serializer &s) {
 	if (s.isLoading()) {
 		_selectedInvIndex = invObjects._inventoryList.empty() ? -1 : 0;
 	}
+
+	for (int i = 0; i < 8; ++i)
+		s.syncAsSint16LE(_categoryIndexes[i]);
 }
 
 } // End of namespace MADS


Commit: e258419a3e21f274839fdd39796bb9a75652ef99
    https://github.com/scummvm/scummvm/commit/e258419a3e21f274839fdd39796bb9a75652ef99
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-01T22:42:47-04:00

Commit Message:
MADS: Add some further savegame loading logic

Changed paths:
    engines/mads/game.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 4b8805d..36b0c31 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -466,8 +466,11 @@ void Game::synchronize(Common::Serializer &s, bool phase1) {
 		_screenObjects.synchronize(s);
 
 		if (s.isLoading()) {
+			_scene._userInterface._selectedInvIndex = -1;
+			_currentSectionNumber = -2;
+			_scene._currentSceneId = -2;
 			_sectionNumber = _scene._nextSceneId / 100;
-			_currentSectionNumber = _sectionNumber;
+			_scene._frameStartTime = _vm->_events->getFrameCounter();
 		}
 	} else {
 		// Load scene specific data for the loaded scene


Commit: dbbd7feab727e463f4aed0e9b496aaca99efddcd
    https://github.com/scummvm/scummvm/commit/dbbd7feab727e463f4aed0e9b496aaca99efddcd
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-03T00:01:52+02:00

Commit Message:
MADS: Implement scene 411

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes4.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index a3cfe8b..b48109d 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -180,14 +180,15 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene407(vm);
 	case 408:
 		return new Scene408(vm);
-	case 409:
-		// TODO
 	case 410:
 		return new Scene410(vm);
 	case 411:
-		// TODO
+		return new Scene411(vm);
 	case 413:
 		// TODO
+
+	case 409:
+		// TODO
 		// Fall-through for unimplemented scenes in group #4
 		error("Invalid scene %d called", scene._nextSceneId);
 
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index 93ab7dd..77f2d46 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -2375,7 +2375,7 @@ void Scene405::step() {
 		_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount ;
 		_game._player._visible = true;
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
-		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[1], false, 6, 1, 0, 0);
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 1, 0, 0);
 		_globals[kArmoryDoorOpen] = true;
 		_game._player._stepEnabled = true;
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle (_globals._spriteIndexes[2],
@@ -2564,7 +2564,7 @@ void Scene406::step() {
 
 	if (_game._trigger == 75) {
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
-		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[1], false, 4, 1, 0, 0);
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 4, 1, 0, 0);
 		_globals[kStorageDoorOpen] = true;
 		_game._player._stepEnabled = true;
 		_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
@@ -2592,7 +2592,7 @@ void Scene406::actions() {
 		_game._player._stepEnabled = false;
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
-		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[3], false, 3, 1, 0, 0);
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 3, 1, 0, 0);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
 		_vm->_sound->command(19);
 	} else if (_action.isAction(0x18B, 0x6E) && _globals[kStorageDoorOpen] && (_game._player._targetPos.x < 100))
@@ -3101,5 +3101,752 @@ void Scene410::actions() {
 
 /*------------------------------------------------------------------------*/
 
+bool Scene411::addIngredient() {
+	bool retVal = false;
+
+	switch (_newIngredient) {
+	case OBJ_LECITHIN:
+		if (_globals[kIngredientList + _globals[kNextIngredient]] == 1)
+	        retVal = true;
+
+		_badThreshold = 1;
+		break;
+
+	case OBJ_ALIEN_LIQUOR:
+		if (_globals[kIngredientList + _globals[kNextIngredient]] == 0)
+			retVal = true;
+
+		_badThreshold = 0;
+		break;
+
+	case OBJ_FORMALDEHYDE:
+		if (_globals[kIngredientList + _globals[kNextIngredient]] == 3)
+			retVal = true;
+
+		_badThreshold = 3;
+		break;
+
+	case OBJ_PETROX:
+		if (_globals[kIngredientList + _globals[kNextIngredient]] == 2)
+			retVal = true;
+
+		_badThreshold = 2;
+		break;
+
+	default:
+		break;
+	}
+
+	if (!retVal && (_globals[kNextIngredient] == 0))
+		_globals[kBadFirstIngredient] = _badThreshold;
+
+	if (_globals[kNextIngredient] == 0)
+		retVal = true;
+
+	return(retVal);
+}
+
+bool Scene411::addQuantity() {
+	bool retVal = false;
+
+	if (_globals[kIngredientQuantity + _globals[kNextIngredient]] == _newQuantity)
+		retVal = true;
+
+	if (!retVal && (_globals[kNextIngredient] == 0))
+		_globals[kBadFirstIngredient] = _badThreshold;
+
+	if (_globals[kNextIngredient] == 0)
+		retVal = true;
+
+	return(retVal);
+}
+
+int Scene411::computeQuoteAndQuantity() {
+	int quoteId;
+	int quantity;
+
+	switch (_action._activeAction._verbId) {
+	case 0x252:
+		quoteId = 0x26F;
+		quantity = 0;
+		break;
+
+	case 0x253:
+		quoteId = 0x271;
+		quantity = 0;
+		break;
+
+	case 0x254:
+		quoteId = 0x270;
+		quantity = 0;
+		break;
+
+	case 0x255:
+		quoteId = 0x272;
+		quantity = 0;
+		break;
+
+	case 0x256:
+		quoteId = 0x267;
+		quantity = 2;
+		break;
+
+	case 0x257:
+		quoteId = 0x269;
+		quantity = 2;
+		break;
+
+	case 0x258:
+		quoteId = 0x268;
+		quantity = 2;
+		break;
+
+	case 0x259:
+		quoteId = 0x26A;
+		quantity = 2;
+		break;
+
+	case 0x25A:
+		quoteId = 0x26B;
+		quantity = 3;
+		break;
+
+	case 0x25B:
+		quoteId = 0x26D;
+		quantity = 3;
+		break;
+
+	case 0x25C:
+		quoteId = 0x26C;
+		quantity = 3;
+		break;
+
+	case 0x25D:
+		quoteId = 0x26E;
+		quantity = 3;
+		break;
+
+	case 0x25E:
+		quoteId = 0x263;
+		quantity = 1;
+		break;
+
+	case 0x25F:
+		quoteId = 0x265;
+		quantity = 1;
+		break;
+
+	case 0x260:
+		quoteId = 0x264;
+		quantity = 1;
+		break;
+
+	case 0x261:
+		quoteId = 0x266;
+		quantity = 1;
+		break;
+
+	default:
+		quoteId = 0;
+		quantity = 0;
+		break;
+	}
+
+	_scene->_kernelMessages.add(Common::Point(202, 82), 0x1110, 32, 0, 120, _game.getQuote(quoteId));
+	return quantity;
+} 
+
+void Scene411::handleKettleAction() {
+	switch (_globals[kNextIngredient]) {
+	case (1):
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4],
+			false, 15, 0, 0, 0);
+		break;
+
+	case (2):
+		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4],
+			false, 6, 0, 0, 0);
+		break;
+
+	case (3):
+		_makeMushroomCloud = true;
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene411::handleDialog() {
+	if ((_action._activeAction._verbId != 0x262) && (_game._trigger == 0)) {
+		if (_game._objects.isInInventory(_newIngredient)) {
+			switch (_newIngredient) {
+			case OBJ_FORMALDEHYDE:
+				_resetFrame = 17;
+				break;
+
+			case OBJ_PETROX:
+				_resetFrame = 55;
+				break;
+
+			case OBJ_LECITHIN:
+				_resetFrame = 36;
+				break;
+
+			default:
+				_resetFrame = 112;
+				break;
+			}
+
+			_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
+			_game._player._visible = false;
+			_game._player._stepEnabled = false;
+			_scene->_activeAnimation->setCurrentFrame(_resetFrame);
+		}
+		_scene->_kernelMessages.reset();
+		_newQuantity = computeQuoteAndQuantity ();
+
+		if ((_globals[kNextIngredient] == 1) && (_globals[kBadFirstIngredient] > -1))
+			_killRox = true;
+		else if (addIngredient() && addQuantity()) {
+			handleKettleAction();
+			_globals[kNextIngredient]++;
+		} else
+			_killRox = true;
+
+		_scene->_userInterface.setup(kInputBuildingSentences);
+	} else if (_action._activeAction._verbId == 0x262)
+		_scene->_userInterface.setup(kInputBuildingSentences);
+}
+
+void Scene411::giveToRex(int object) {
+	switch (object) {
+	case (0):
+		_game._objects.addToInventory(OBJ_ALIEN_LIQUOR);
+		break;
+
+	case (1):
+		_game._objects.addToInventory(OBJ_LECITHIN);
+		break;
+
+	case (2):
+		_game._objects.addToInventory(OBJ_PETROX);
+		break;
+
+	case (3):
+		_game._objects.addToInventory(OBJ_FORMALDEHYDE);
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene411::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(0x306);
+	_scene->addActiveVocab(0x2D6);
+	_scene->addActiveVocab(0x2D7);
+	_scene->addActiveVocab(0x3A9);
+}
+
+void Scene411::enter() {
+	if (_scene->_priorSceneId == 411) {
+		if ((_globals[kNextIngredient] == 1) && (_globals[kBadFirstIngredient] > -1))
+			giveToRex(_globals[kBadFirstIngredient]);
+		else if (_globals[kNextIngredient] > 0) {
+			for (int i = 0; i < _globals[kNextIngredient]; i ++)
+				giveToRex(_globals[kIngredientList + i]);
+		}
+		_globals[kNextIngredient] = 0;
+		_globals[kBadFirstIngredient] = -1;
+	}
+
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 1));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('c', 0));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('f', 0));
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('f', 1));
+	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('f', 2));
+	_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('c', 1));
+	_globals._spriteIndexes[10] = _scene->_sprites.addSprites(formAnimName('a', 6));
+	_globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('a', 1));
+	_globals._spriteIndexes[8] = _scene->_sprites.addSprites("*ROXRC_9");
+
+	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 0, 0, 0);
+	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 50, 0, 0, 0);
+
+	_game.loadQuoteSet(0x252, 0x25E, 0x25A, 0x256,  0x253, 0x25F, 0x25B, 0x257,  0x254, 0x260, 0x25C, 0x258, 0x255,
+		0x261, 0x25D, 0x259, 0x262, 0x267, 0x263, 0x26B, 0x26F, 0x268, 0x264, 0x26C, 0x270, 0x26A, 0x266, 0x26E,
+		0x272, 0x269, 0x265, 0x26D, 0x271, 0);
+
+	_dialog1.setup(0x5B, 0x252, 0x25E, 0x25A, 0x256,  0x262, -1);
+	_dialog2.setup(0x5C, 0x253, 0x25F, 0x25B, 0x257,  0x262, -1);
+	_dialog3.setup(0x5D, 0x254, 0x260, 0x25C, 0x258,  0x262, -1);
+	_dialog4.setup(0x5E, 0x255, 0x261, 0x25D, 0x259,  0x262, -1);
+
+	warning("TODO: Replace the next line by: if ((_globals[kNextIngredient] >= 4) && (!object_get_folder(OBJ_CHARGE_CASES, 3))) {");
+	if (_globals[kNextIngredient] >= 4) {
+		_scene->_hotspots.activate(0x3AB, false);
+		_scene->_hotspots.activate(0x30D, true);
+	} else {
+		_scene->_hotspots.activate(0x30D, false);
+		_scene->_hotspots.activate(0x3AB, true);
+	}
+
+	warning("TODO: Replace the next line by: if ((!_globals[kNextIngredient] >= 4) && (object_get_folder(OBJ_CHARGE_CASES, 3))) {");
+	if (!(_globals[kNextIngredient] >= 4))
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], true, 6);
+	else if (true) {
+		warning("TODO: The previous if was: else if (!object_get_folder(OBJ_CHARGE_CASES, 3)) {");
+		switch (_globals[kNextIngredient]) {
+		case 1:
+			_vm->_sound->command(53);
+			break;
+
+		case 2:
+			_vm->_sound->command(53);
+			_vm->_sound->command(54);
+			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 15, 0, 0, 0);
+			break;
+
+		case 3:
+			_vm->_sound->command(53);
+			_vm->_sound->command(54);
+			_vm->_sound->command(55);
+			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6, 0, 0, 0);
+			break;
+
+		case (4):
+			_vm->_sound->command(53);
+			_vm->_sound->command(54);
+			_vm->_sound->command(55);
+			_vm->_sound->command(56);
+			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6, 0, 0, 0);
+			break;
+
+		default:
+			_vm->_sound->command(10);
+			break;
+		}
+	}
+
+	warning("TODO: Replace the next if by: if ((_globals[kNextIngredient] >= 4) && (object_get_folder(OBJ_CHARGE_CASES, 3))) {");
+	if (_globals[kNextIngredient] >= 4) {
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], true, 6);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
+	}
+
+	if (_game._objects.isInRoom(OBJ_FORMALDEHYDE)) {
+		_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 1);
+		int idx = _scene->_dynamicHotspots.add(0x2D6, VERB_WALKTO, _globals._sequenceIndexes[7], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(206, 145), FACING_SOUTHEAST);
+	} 
+
+	if (_game._objects.isInRoom(OBJ_PETROX)) {
+		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 8);
+		int idx = _scene->_dynamicHotspots.add(0x2D7, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(186, 112), FACING_NORTHEAST);
+	} 
+
+	if (_game._objects.isInRoom(OBJ_LECITHIN)) {
+		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 8);
+		int idx = _scene->_dynamicHotspots.add(0x3A9, VERB_WALKTO, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(220, 121), FACING_NORTHEAST);
+	} 
+
+	if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(60, 146);
+		_game._player._facing = FACING_NORTHEAST;
+	}
+
+	sceneEntrySound();
+
+	if (_scene->_roomChanged) {
+		_game._objects.addToInventory(OBJ_ALIEN_LIQUOR);
+		_game._objects.addToInventory(OBJ_CHARGE_CASES);
+		_game._objects.addToInventory(OBJ_TAPE_PLAYER);
+		_game._objects.addToInventory(OBJ_AUDIO_TAPE);
+	}
+
+	_scene->loadAnimation(formAnimName('a', -1));
+	_scene->_activeAnimation->setCurrentFrame(128);
+
+	_makeMushroomCloud = false;
+	_killRox = false;
+}
+
+void Scene411::step() {
+	if (_scene->_activeAnimation != nullptr) {
+		if (_curAnimationFrame != _scene->_activeAnimation->getCurrentFrame()) {
+			_curAnimationFrame = _scene->_activeAnimation->getCurrentFrame();
+			_resetFrame = -1;
+
+			switch (_curAnimationFrame) {
+			case 16:
+				_game._player._stepEnabled = true;
+				_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
+				_game._player._visible = true;
+				_resetFrame = 128;
+				break;
+
+			case 35:
+			case 54:
+			case 71:
+			case 127:
+				if (_killRox) {
+					_resetFrame = 72;  
+				} else {
+					_resetFrame = 0;  
+					_game._objects.removeFromInventory(_newIngredient, NOWHERE);
+					switch (_globals[kNextIngredient]) {
+					case 1:
+						_vm->_sound->command(53);
+						break;
+
+					case 2:
+						_vm->_sound->command(54);
+						break;
+
+					case 3:
+						_vm->_sound->command(55);
+						break;
+
+					case 4:
+						_vm->_sound->command(56);
+						break;
+
+					default:
+						break;
+					}
+				}
+				break;
+
+			case (22):
+			case (41):
+			case (59):
+			case (115):
+				if (_makeMushroomCloud) {
+					_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 5, 1, 0, 0);
+					_makeMushroomCloud = false;
+					_scene->_hotspots.activate(0x3AB, false);
+					_scene->_hotspots.activate(0x30D, true);
+				}
+				break;
+
+			case 111:
+				_resetFrame = 111;
+				_scene->_reloadSceneFlag = true;
+				break;
+
+			case 129:
+				_resetFrame = 128;
+				break;
+
+			default:
+				break;
+			}
+
+			if ((_resetFrame >= 0) && (_resetFrame != _scene->_activeAnimation->getCurrentFrame())) {
+				_scene->_activeAnimation->setCurrentFrame(_resetFrame);
+				_curAnimationFrame = _resetFrame;
+			}
+		}
+	}
+
+	if (_scene->_activeAnimation->getCurrentFrame() == 86)
+		_vm->_sound->command(59);
+}
+
+void Scene411::preActions() {
+	if (_action.isAction(VERB_LOOK, 0x2D7) && (_game._objects.isInRoom(OBJ_PETROX)))
+		_game._player._needToWalk = true;
+
+	if (_action.isAction(VERB_LOOK, 0x3A9) && (_game._objects.isInRoom(OBJ_LECITHIN)))
+		_game._player._needToWalk = true;
+
+	if (_action.isAction(VERB_LOOK, 0x2D6) && (_game._objects.isInRoom(OBJ_FORMALDEHYDE)))
+		_game._player._needToWalk = true;
+
+	if (_action.isAction(VERB_LOOK, 0x3AB) || _action.isAction(VERB_LOOK, 0x30D) || _action.isAction(VERB_LOOK, 0x47F) ||
+		_action.isAction(VERB_LOOK, 0x24D) || _action.isAction(VERB_LOOK, 0x216) || _action.isAction(VERB_PUT, 0x216) ||
+		_action.isAction(VERB_LOOK, 0x284) || _action.isAction(VERB_LOOK, 0x285))
+		_game._player._needToWalk = true;
+
+	if (_action.isAction(VERB_PULL, 0x280) || _action.isAction(VERB_PUSH, 0x280))
+		_game._player._needToWalk = false;
+}
+
+void Scene411::actions() {
+	if (_game._screenObjects._inputMode != 1) {
+		handleDialog();
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(0x242, 0x2B3)) {
+		_scene->_nextSceneId = 406;
+		_vm->_sound->command(10);
+		_action._inProgress = false;
+		return;
+	}           
+
+	warning("TODO: add the following condition to the if statement: (!object_get_folder(OBJ_CHARGE_CASES, 3)) &&");
+	if ((_globals[kNextIngredient] >= 4) && (_action.isAction(VERB_TAKE, 0x3AB) || _action.isAction(VERB_PUT, 0x48, 0x3AB)) &&
+		(_game._objects.isInInventory(OBJ_CHARGE_CASES))) {
+		switch (_game._trigger) {
+		case 0:
+			_vm->_sound->command(10);
+			_vm->_sound->command(57);
+			_game._player._stepEnabled  = false;
+			_game._player._visible    = false;
+			_globals._sequenceIndexes[10] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[10], false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 1, 6);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 3);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_EXPIRE, 0, 110);
+			break;
+
+		case 110: {
+			int idx = _globals._sequenceIndexes[10];
+			_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[10], false, 6);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 3);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[10], idx);
+			_scene->_sequences.addTimer(180, 111);
+			}
+			break;
+
+		case 111:
+			_scene->_hotspots.activate(0x30D, true);
+			_scene->_hotspots.activate(0x3AB, false);
+			_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+			_scene->_sequences.remove(_globals._sequenceIndexes[10]);
+
+			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], true, 6);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
+
+			_globals._sequenceIndexes[10] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[10], false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 1, 6);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 3);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_EXPIRE, 0, 112);
+			// No break on purpose
+		case 112:
+			_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			warning("TODO: InventoryObjects_setData(OBJ_CHARGE_CASES, 3, true);");
+			_vm->_dialogs->showItem(OBJ_CHARGE_CASES, 41142);
+			break;
+		}
+		_action._inProgress = false;
+		return;
+	} else if (!_game._objects.isInInventory(OBJ_CHARGE_CASES) && _action.isAction(VERB_TAKE, 0x3AB)) {
+		_vm->_dialogs->show(41143);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_TAKE, 0x2D7) && (_game._objects.isInRoom(OBJ_PETROX) || _game._trigger)) {
+		switch (_game._trigger) {
+		case (0):
+			_vm->_sound->command(57);
+			_game._player._stepEnabled  = false;
+			_game._player._visible    = false;  
+			_globals._sequenceIndexes[8] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[8], false, 7, 2, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 1, 2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[8]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_SPRITE, 2, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+
+		case 1:
+			_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+			_game._objects.addToInventory(OBJ_PETROX);
+			_vm->_dialogs->showItem(OBJ_PETROX, 41120);
+			break;
+
+		case 2:
+			_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
+			_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
+			_game._player._visible   = true;
+			_scene->_sequences.addTimer(20, 3);
+			break;
+
+		case 3:
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_TAKE, 0x3A9) && (_game._objects.isInRoom(OBJ_LECITHIN) || _game._trigger)) {
+		switch (_game._trigger) {
+		case (0):
+			_vm->_sound->command(57);
+			_game._player._stepEnabled  = false;
+			_game._player._visible    = false;  
+			_globals._sequenceIndexes[8] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[8], false, 7, 2, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 1, 2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[8]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_SPRITE, 2, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+
+		case 1:
+			_scene->_sequences.remove(_globals._sequenceIndexes[6]);
+			_game._objects.addToInventory(OBJ_LECITHIN);
+			_vm->_dialogs->showItem(OBJ_LECITHIN, 41124);
+			break;
+
+		case 2:
+			_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
+			_game._player._visible   = true;
+			_scene->_sequences.addTimer(20, 3);
+			break;
+
+		case 3:
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_TAKE, 0x2D6) && _game._objects.isInRoom(OBJ_FORMALDEHYDE) && (_game._trigger == 0)) {
+		_vm->_sound->command(57);
+		_game._player._stepEnabled  = false;
+		_game._player._visible    = false;  
+		_globals._sequenceIndexes[11] = _scene->_sequences.startCycle(_globals._spriteIndexes[11], false, 2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[11], 1);
+		_scene->_sequences.addTimer(20, 100);
+		_scene->_sequences.remove(_globals._sequenceIndexes[7]);
+		_game._objects.addToInventory(OBJ_FORMALDEHYDE);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_game._trigger == 100) {
+		_scene->_sequences.remove(_globals._sequenceIndexes[11]);
+		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+		_game._player._visible   = true;
+		_game._player._stepEnabled = true;
+		_scene->_sequences.addTimer(20, 10);
+	}
+
+	if (_game._trigger == 10)
+		_vm->_dialogs->showItem(OBJ_FORMALDEHYDE, 41124);
+
+	if (_action.isAction(VERB_PUT, 0x30D)) {
+		if (_action.isAction(0x2D7) || _action.isAction(0x2D6) || _action.isAction(0x3A9) || _action.isAction(0x306)) {
+			_newIngredient = _game._objects.getIdFromDesc(_action._activeAction._objectNameId);
+			switch (_newIngredient) {
+			case (OBJ_ALIEN_LIQUOR):
+				_dialog1.start();
+				break;
+
+			case (OBJ_FORMALDEHYDE):
+				_dialog3.start();
+				break;
+
+			case (OBJ_PETROX):
+				_dialog4.start();
+				break;
+
+			case (OBJ_LECITHIN):
+				_dialog2.start();
+				break;
+
+			default:
+				break;
+			}
+		}
+	}
+
+
+	if (_action.isAction(VERB_LOOK, 0xE2))
+		_vm->_dialogs->show(41110);
+	else if (_action.isAction(VERB_LOOK, 0x287))
+		_vm->_dialogs->show(41111);
+	else if (_action.isAction(VERB_LOOK, 0x27B))
+		_vm->_dialogs->show(41112);
+	else if (_action.isAction(VERB_LOOK, 0x280))
+		_vm->_dialogs->show(41113);
+	else if (_action.isAction(VERB_PUSH, 0x280) || _action.isAction(VERB_PULL, 0x280))
+		_vm->_dialogs->show(41114);
+	else if (_action.isAction(VERB_LOOK, 0x283))
+		_vm->_dialogs->show(41115);
+	else if (_action.isAction(VERB_TAKE, 0x283))
+		_vm->_dialogs->show(41116);
+	else if (_action.isAction(VERB_LOOK, 0x285))
+		_vm->_dialogs->show(41117);
+	else if (_action.isAction(VERB_LOOK, 0x284))
+		_vm->_dialogs->show(41118);
+	else if (_action.isAction(VERB_LOOK, 0x2D7) && _game._objects.isInRoom(OBJ_PETROX))
+		_vm->_dialogs->show(41119);
+	else if (_action.isAction(VERB_LOOK, 0x24D))
+		_vm->_dialogs->show(41121);
+	else if ((_action.isAction(VERB_LOOK, 0x2D6)) && (_game._objects.isInRoom(OBJ_FORMALDEHYDE)))
+		_vm->_dialogs->show(41122);
+	else if ((_action.isAction(VERB_LOOK, 0x3A9)) && (_game._objects.isInRoom(OBJ_LECITHIN)))
+		_vm->_dialogs->show(41123);
+	else if (_action.isAction(VERB_LOOK, 0x30D)) {
+		if (_globals[kNextIngredient] > 0) {
+			warning("TODO: the if statement should be: if ((_globals[kNextIngredient] > 0) && !object_get_folder(OBJ_CHARGE_CASES, 3))");
+			_vm->_dialogs->show(41126);
+		} else if (_globals[kNextIngredient] == 0) {
+			warning("TODO: the if statement should be: else if ((_globals[kNextIngredient] == 0) || object_get_folder(OBJ_CHARGE_CASES, 3)) {");
+			_vm->_dialogs->show(41125);
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x3AB)) {
+		warning("TODO: The if statement should be if (_action.isAction(VERB_LOOK, 0x3AB) && !object_get_folder(OBJ_CHARGE_CASES, 3)) {");
+		_vm->_dialogs->show(41127);
+	} else if (_action.isAction(VERB_TAKE, 0x30D))
+		_vm->_dialogs->show(41128);
+	else if (_action.isAction(VERB_LOOK, 0x59))
+		_vm->_dialogs->show(41129);
+	else if (_action.isAction(VERB_LOOK, 0x47F))
+		_vm->_dialogs->show(41130);
+	else if (_action.isAction(VERB_LOOK, 0x2B3))
+		_vm->_dialogs->show(41131);
+	else if (_action._lookFlag)
+		_vm->_dialogs->show(41132);
+	else if (_action.isAction(VERB_LOOK, 0x27C))
+		_vm->_dialogs->show(41133);
+	else if (_action.isAction(VERB_LOOK, 0x218))
+		_vm->_dialogs->show(41134);
+	else if (_action.isAction(VERB_LOOK, 0x282))
+		_vm->_dialogs->show(41135);
+	else if (_action.isAction(VERB_LOOK, 0x10C))
+		_vm->_dialogs->show(41136);
+	else if (_action.isAction(VERB_LOOK, 0x216))
+		_vm->_dialogs->show(41137);
+	else if (_action.isAction(VERB_PUT, 0x216))
+		_vm->_dialogs->show(41138);
+	else if (_action.isAction(VERB_TAKE, 0x284))
+		_vm->_dialogs->show(41139);
+	else if (_action.isAction(VERB_LOOK, 0x47E))
+		_vm->_dialogs->show(41140);
+	else if (_action.isAction(VERB_TAKE, 0x47E))
+		_vm->_dialogs->show(41141);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes4.h b/engines/mads/nebular/nebular_scenes4.h
index 2b96b7e..2540c5e 100644
--- a/engines/mads/nebular/nebular_scenes4.h
+++ b/engines/mads/nebular/nebular_scenes4.h
@@ -194,6 +194,42 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene411: public Scene4xx {
+private:
+	int _curAnimationFrame;
+	int _newIngredient;
+	int _newQuantity;
+	int _resetFrame;
+	int _badThreshold;
+
+	bool _killRox;
+	bool _makeMushroomCloud;
+
+	Conversation _dialog1;
+	Conversation _dialog2;
+	Conversation _dialog3;
+	Conversation _dialog4;
+
+	void giveToRex(int object);
+	void handleDialog();
+	void handleKettleAction();
+
+	int computeQuoteAndQuantity();
+
+	bool addQuantity();
+	bool addIngredient();
+
+public:
+	Scene411(MADSEngine *vm) : Scene4xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: a54aeaccce5d3db455a0017ce302065b29e6c215
    https://github.com/scummvm/scummvm/commit/a54aeaccce5d3db455a0017ce302065b29e6c215
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-02T21:29:33-04:00

Commit Message:
MADS: Misc savegame fixes and added meta query info

Changed paths:
    engines/mads/detection.cpp
    engines/mads/events.cpp
    engines/mads/events.h
    engines/mads/game.cpp
    engines/mads/game_data.cpp
    engines/mads/mads.cpp



diff --git a/engines/mads/detection.cpp b/engines/mads/detection.cpp
index 49253f0..971acde 100644
--- a/engines/mads/detection.cpp
+++ b/engines/mads/detection.cpp
@@ -31,6 +31,7 @@
 #include "common/system.h"
 #include "graphics/colormasks.h"
 #include "graphics/surface.h"
+#include "mads/events.h"
 #include "mads/game.h"
 
 #define MAX_SAVES 99
@@ -168,10 +169,16 @@ SaveStateDescriptor MADSMetaEngine::querySaveMetaInfos(const char *target, int s
 	Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(filename);
 
 	if (f) {
+		MADS::MADSSavegameHeader header;
+		MADS::Game::readSavegameHeader(f, header);
 		delete f;
 
 		// Create the return descriptor
-		SaveStateDescriptor desc(slot, "");
+		SaveStateDescriptor desc(slot, header._saveName);
+		desc.setThumbnail(header._thumbnail);
+		desc.setSaveDate(header._year, header._month, header._day);
+		desc.setSaveTime(header._hour, header._minute);
+		desc.setPlayTime(header._totalFrames * GAME_FRAME_TIME);
 
 		return desc;
 	}
diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 6ec1640..5d6a16f 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -28,9 +28,6 @@
 #include "mads/events.h"
 #include "mads/scene.h"
 
-#define GAME_FRAME_RATE 50
-#define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE) 
-
 namespace MADS {
 
 EventsManager::EventsManager(MADSEngine *vm) {
diff --git a/engines/mads/events.h b/engines/mads/events.h
index 6428108..5f9a899 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -34,6 +34,9 @@ namespace MADS {
 enum CursorType { CURSOR_NONE = 0, CURSOR_ARROW = 1, CURSOR_WAIT = 2, CURSOR_GO_DOWN = 3, 
 	CURSOR_GO_UP = 4, CURSOR_GO_LEFT = 5, CURSOR_GO_RIGHT = 6 };
 
+#define GAME_FRAME_RATE 50
+#define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE) 
+
 class MADSEngine;
 
 class EventsManager {
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 36b0c31..a63fec4 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -519,7 +519,7 @@ const char *const SAVEGAME_STR = "MADS";
 
 bool Game::readSavegameHeader(Common::InSaveFile *in, MADSSavegameHeader &header) {
 	char saveIdentBuffer[SAVEGAME_STR_SIZE + 1];
-	header._thumbnail = NULL;
+	header._thumbnail = nullptr;
 
 	// Validate the header Id
 	in->read(saveIdentBuffer, SAVEGAME_STR_SIZE + 1);
@@ -558,7 +558,8 @@ void Game::writeSavegameHeader(Common::OutSaveFile *out, MADSSavegameHeader &hea
 	out->writeByte(MADS_SAVEGAME_VERSION);
 
 	// Write savegame name
-	out->write(header._saveName.c_str(), header._saveName.size() + 1);
+	out->write(header._saveName.c_str(), header._saveName.size());
+	out->writeByte('\0');
 
 	// Get the active palette
 	uint8 thumbPalette[256 * 3];
diff --git a/engines/mads/game_data.cpp b/engines/mads/game_data.cpp
index 4a9d02c..0e2dcec 100644
--- a/engines/mads/game_data.cpp
+++ b/engines/mads/game_data.cpp
@@ -47,7 +47,7 @@ bool VisitedScenes::exists(int sceneId) {
 }
 
 void VisitedScenes::synchronize(Common::Serializer &s) {
-	SynchronizedList:synchronize(s);
+	SynchronizedList::synchronize(s);
 	s.syncAsByte(_sceneRevisited);
 }
 
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 29db804..a099f59 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -122,13 +122,15 @@ int MADSEngine::hypotenuse(int xv, int yv) {
 }
 
 bool MADSEngine::canLoadGameStateCurrently() {
-	return !_game->_winStatus && !_game->globals()[5]
-		&& _dialogs->_pendingDialog == DIALOG_NONE;
+	return !_game->_winStatus && !_game->globals()[5] 
+		&& _dialogs->_pendingDialog == DIALOG_NONE
+		&& _events->_cursorId == CURSOR_ARROW;
 }
 
 bool MADSEngine::canSaveGameStateCurrently() {
 	return !_game->_winStatus && !_game->globals()[5]
-		&& _dialogs->_pendingDialog == DIALOG_NONE;
+		&& _dialogs->_pendingDialog == DIALOG_NONE
+		&& _events->_cursorId == CURSOR_ARROW;
 }
 
 /**


Commit: 5e455e489fe252b9833db03e2186a46d79fec9a0
    https://github.com/scummvm/scummvm/commit/5e455e489fe252b9833db03e2186a46d79fec9a0
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-03T13:02:02+02:00

Commit Message:
MADS: Implement scene 413

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes4.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index b48109d..0a92cd3 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -185,7 +185,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 411:
 		return new Scene411(vm);
 	case 413:
-		// TODO
+		return new Scene413(vm);
 
 	case 409:
 		// TODO
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index 77f2d46..9d20c68 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -3016,7 +3016,7 @@ void Scene410::actions() {
 		case (0):
 			_vm->_sound->command(57);
 			_game._player._stepEnabled = false;
-			_game._player._visible = false;  
+			_game._player._visible = false;
 			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 7, 2, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 3);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
@@ -3107,7 +3107,7 @@ bool Scene411::addIngredient() {
 	switch (_newIngredient) {
 	case OBJ_LECITHIN:
 		if (_globals[kIngredientList + _globals[kNextIngredient]] == 1)
-	        retVal = true;
+	 retVal = true;
 
 		_badThreshold = 1;
 		break;
@@ -3254,7 +3254,7 @@ int Scene411::computeQuoteAndQuantity() {
 
 	_scene->_kernelMessages.add(Common::Point(202, 82), 0x1110, 32, 0, 120, _game.getQuote(quoteId));
 	return quantity;
-} 
+}
 
 void Scene411::handleKettleAction() {
 	switch (_globals[kNextIngredient]) {
@@ -3379,14 +3379,14 @@ void Scene411::enter() {
 	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 0, 0, 0);
 	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 50, 0, 0, 0);
 
-	_game.loadQuoteSet(0x252, 0x25E, 0x25A, 0x256,  0x253, 0x25F, 0x25B, 0x257,  0x254, 0x260, 0x25C, 0x258, 0x255,
+	_game.loadQuoteSet(0x252, 0x25E, 0x25A, 0x256, 0x253, 0x25F, 0x25B, 0x257, 0x254, 0x260, 0x25C, 0x258, 0x255,
 		0x261, 0x25D, 0x259, 0x262, 0x267, 0x263, 0x26B, 0x26F, 0x268, 0x264, 0x26C, 0x270, 0x26A, 0x266, 0x26E,
 		0x272, 0x269, 0x265, 0x26D, 0x271, 0);
 
-	_dialog1.setup(0x5B, 0x252, 0x25E, 0x25A, 0x256,  0x262, -1);
-	_dialog2.setup(0x5C, 0x253, 0x25F, 0x25B, 0x257,  0x262, -1);
-	_dialog3.setup(0x5D, 0x254, 0x260, 0x25C, 0x258,  0x262, -1);
-	_dialog4.setup(0x5E, 0x255, 0x261, 0x25D, 0x259,  0x262, -1);
+	_dialog1.setup(0x5B, 0x252, 0x25E, 0x25A, 0x256, 0x262, -1);
+	_dialog2.setup(0x5C, 0x253, 0x25F, 0x25B, 0x257, 0x262, -1);
+	_dialog3.setup(0x5D, 0x254, 0x260, 0x25C, 0x258, 0x262, -1);
+	_dialog4.setup(0x5E, 0x255, 0x261, 0x25D, 0x259, 0x262, -1);
 
 	warning("TODO: Replace the next line by: if ((_globals[kNextIngredient] >= 4) && (!object_get_folder(OBJ_CHARGE_CASES, 3))) {");
 	if (_globals[kNextIngredient] >= 4) {
@@ -3445,21 +3445,21 @@ void Scene411::enter() {
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 1);
 		int idx = _scene->_dynamicHotspots.add(0x2D6, VERB_WALKTO, _globals._sequenceIndexes[7], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(206, 145), FACING_SOUTHEAST);
-	} 
+	}
 
 	if (_game._objects.isInRoom(OBJ_PETROX)) {
 		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 8);
 		int idx = _scene->_dynamicHotspots.add(0x2D7, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(186, 112), FACING_NORTHEAST);
-	} 
+	}
 
 	if (_game._objects.isInRoom(OBJ_LECITHIN)) {
 		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 8);
 		int idx = _scene->_dynamicHotspots.add(0x3A9, VERB_WALKTO, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(220, 121), FACING_NORTHEAST);
-	} 
+	}
 
 	if (_scene->_priorSceneId != -2) {
 		_game._player._playerPos = Common::Point(60, 146);
@@ -3501,9 +3501,9 @@ void Scene411::step() {
 			case 71:
 			case 127:
 				if (_killRox) {
-					_resetFrame = 72;  
+					_resetFrame = 72;
 				} else {
-					_resetFrame = 0;  
+					_resetFrame = 0;
 					_game._objects.removeFromInventory(_newIngredient, NOWHERE);
 					switch (_globals[kNextIngredient]) {
 					case 1:
@@ -3595,7 +3595,7 @@ void Scene411::actions() {
 		_vm->_sound->command(10);
 		_action._inProgress = false;
 		return;
-	}           
+	}
 
 	warning("TODO: add the following condition to the if statement: (!object_get_folder(OBJ_CHARGE_CASES, 3)) &&");
 	if ((_globals[kNextIngredient] >= 4) && (_action.isAction(VERB_TAKE, 0x3AB) || _action.isAction(VERB_PUT, 0x48, 0x3AB)) &&
@@ -3604,8 +3604,8 @@ void Scene411::actions() {
 		case 0:
 			_vm->_sound->command(10);
 			_vm->_sound->command(57);
-			_game._player._stepEnabled  = false;
-			_game._player._visible    = false;
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
 			_globals._sequenceIndexes[10] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[10], false, 8, 1, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 1, 6);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 3);
@@ -3655,8 +3655,8 @@ void Scene411::actions() {
 		switch (_game._trigger) {
 		case (0):
 			_vm->_sound->command(57);
-			_game._player._stepEnabled  = false;
-			_game._player._visible    = false;  
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
 			_globals._sequenceIndexes[8] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[8], false, 7, 2, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 1, 2);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[8]);
@@ -3673,7 +3673,7 @@ void Scene411::actions() {
 		case 2:
 			_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
 			_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
-			_game._player._visible   = true;
+			_game._player._visible = true;
 			_scene->_sequences.addTimer(20, 3);
 			break;
 
@@ -3692,8 +3692,8 @@ void Scene411::actions() {
 		switch (_game._trigger) {
 		case (0):
 			_vm->_sound->command(57);
-			_game._player._stepEnabled  = false;
-			_game._player._visible    = false;  
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
 			_globals._sequenceIndexes[8] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[8], false, 7, 2, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 1, 2);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[8]);
@@ -3709,7 +3709,7 @@ void Scene411::actions() {
 
 		case 2:
 			_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
-			_game._player._visible   = true;
+			_game._player._visible = true;
 			_scene->_sequences.addTimer(20, 3);
 			break;
 
@@ -3726,8 +3726,8 @@ void Scene411::actions() {
 
 	if (_action.isAction(VERB_TAKE, 0x2D6) && _game._objects.isInRoom(OBJ_FORMALDEHYDE) && (_game._trigger == 0)) {
 		_vm->_sound->command(57);
-		_game._player._stepEnabled  = false;
-		_game._player._visible    = false;  
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
 		_globals._sequenceIndexes[11] = _scene->_sequences.startCycle(_globals._spriteIndexes[11], false, 2);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[11], 1);
 		_scene->_sequences.addTimer(20, 100);
@@ -3740,7 +3740,7 @@ void Scene411::actions() {
 	if (_game._trigger == 100) {
 		_scene->_sequences.remove(_globals._sequenceIndexes[11]);
 		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
-		_game._player._visible   = true;
+		_game._player._visible = true;
 		_game._player._stepEnabled = true;
 		_scene->_sequences.addTimer(20, 10);
 	}
@@ -3848,5 +3848,150 @@ void Scene411::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene413::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene413::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('a', 2));
+	_rexDeath = false;
+
+	if (_scene->_priorSceneId == 405) {
+		_game._player._playerPos = Common::Point(142, 146);
+		_game._player._facing = FACING_NORTH;
+		_game._player._visible = true;
+	} else if (_scene->_priorSceneId != -2) {
+		if (_globals[kSexOfRex] == REX_MALE) {
+			_scene->loadAnimation(Resources::formatName(413, 'd', 1, EXT_AA, ""), 78);
+			_vm->_sound->command(30);
+			_game._player._visible = false;
+			_game._player._stepEnabled = false;
+			_rexDeath = true;
+		} else if (!_globals[kTeleporterCommand]) {
+			_game._player._playerPos = Common::Point(136, 117);
+			_game._player.walk(Common::Point(141, 130), FACING_SOUTH);
+			_game._player._facing = FACING_SOUTH;
+			_game._player._visible = true;
+		}
+	}
+
+	if ((_globals[kTeleporterCommand]) && (!_rexDeath)) {
+		switch (_globals[kTeleporterCommand]) {
+		case 1:
+			_vm->_sound->command(30);
+			_game._player._visible = false;
+			_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 7, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 19);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 8);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 76);
+			break;
+
+		case 2:
+			_game._player._visible = false;
+			_vm->_sound->command(30);
+			_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 7, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 20);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 8);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 77);
+			break;
+
+		case 3:
+		case 4:
+			_game._player._playerPos = Common::Point(136, 117);
+			_game._player._facing = FACING_SOUTH;
+			_game._player.walk(Common::Point(141, 130), FACING_SOUTH);
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+		_globals[kTeleporterCommand] = 0;
+	}
+
+	_canMove = true;
+	sceneEntrySound();
+}
+
+void Scene413::step() {
+	if (_scene->_activeAnimation->getCurrentFrame() == 38)
+		_scene->_activeAnimation->setCurrentFrame(37);
+
+	if ((_scene->_activeAnimation->getCurrentFrame() == 21) && _canMove) {
+		_vm->_sound->command(27);
+		_canMove = false;
+	}
+
+	if (_game._trigger == 76) {
+		_game._player._playerPos = Common::Point(136, 117);
+		_game._player.walk(Common::Point(141, 130), FACING_SOUTH);
+		_game._player._facing = FACING_SOUTH;
+		_game._player.selectSeries();
+		_game._player._visible = true;
+		_game._player._stepEnabled = true;
+	}
+
+	if (_game._trigger == 77) {
+		_globals[kTeleporterCommand] = TELEPORTER_BEAM_IN;
+		_scene->_nextSceneId = _globals[kTeleporterDestination];
+		_scene->_reloadSceneFlag = true;
+	}
+
+	if (_game._trigger == 78) {
+		_scene->_reloadSceneFlag = true;
+		_scene->_nextSceneId = _scene->_priorSceneId;
+		_globals[kTeleporterCommand] = TELEPORTER_NONE;
+	}
+}
+
+void Scene413::preActions() {
+	if (_action.isAction(VERB_TAKE) || _action.isAction(VERB_PUT, 0x319))
+		_game._player._needToWalk = false;
+
+	if (_action.isAction(VERB_LOOK, 0x2C4) || _action.isAction(VERB_LOOK, 0x1CC)
+	 || _action.isAction(VERB_LOOK, 0x289) || _action.isAction(VERB_LOOK, 0x10E)) {
+		_game._player._needToWalk = true;
+	}
+}
+
+void Scene413::actions() {
+	if (_action.isAction(0x188, 0x16C)) {
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_scene->_nextSceneId = 409;
+	} else if (_action.isAction(0x188, 0x2B3))
+		_scene->_nextSceneId = 405;
+	else if (_action.isAction(VERB_LOOK, 0x2C4))
+		_vm->_dialogs->show(41310);
+	else if (_action.isAction(VERB_TAKE, 0x2C4))
+		_vm->_dialogs->show(41311);
+	else if (_action.isAction(VERB_LOOK, 0x319))
+		_vm->_dialogs->show(41312);
+	else if (_action.isAction(VERB_PUT, 0x319))
+		_vm->_dialogs->show(41313);
+	else if (_action.isAction(VERB_LOOK, 0x16C))
+		_vm->_dialogs->show(41314);
+	else if (_action.isAction(VERB_LOOK, 0x1CC))
+		_vm->_dialogs->show(41315);
+	else if (_action.isAction(VERB_LOOK, 0x2B3))
+		_vm->_dialogs->show(41316);
+	else if (_action.isAction(VERB_LOOK, 0x289))
+		_vm->_dialogs->show(41317);
+	else if (_action.isAction(VERB_LOOK, 0x10E))
+		_vm->_dialogs->show(41318);
+	else if (_action.isAction(VERB_TAKE, 0x10E))
+		_vm->_dialogs->show(41319);
+	else if (_action._lookFlag)
+		_vm->_dialogs->show(41320);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes4.h b/engines/mads/nebular/nebular_scenes4.h
index 2540c5e..2010931 100644
--- a/engines/mads/nebular/nebular_scenes4.h
+++ b/engines/mads/nebular/nebular_scenes4.h
@@ -230,6 +230,22 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene413: public Scene4xx {
+private:
+	int _rexDeath;
+	int _canMove;
+
+public:
+	Scene413(MADSEngine *vm) : Scene4xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 84159c59efe95c682d4d727f48e93b08a93860da
    https://github.com/scummvm/scummvm/commit/84159c59efe95c682d4d727f48e93b08a93860da
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-03T11:09:28-04:00

Commit Message:
MADS: Savegames are now working

Changed paths:
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/globals.cpp
    engines/mads/mads.cpp
    engines/mads/nebular/game_nebular.cpp
    engines/mads/player.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index a63fec4..862ecf9 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -273,6 +273,7 @@ void Game::sectionLoop() {
 			Common::Serializer s(_saveFile, nullptr);
 			synchronize(s, false);
 			delete _saveFile;
+			_saveFile = nullptr;
 		}
 
 		// Set player data
@@ -464,14 +465,6 @@ void Game::synchronize(Common::Serializer &s, bool phase1) {
 		_visitedScenes.synchronize(s);
 		_player.synchronize(s);
 		_screenObjects.synchronize(s);
-
-		if (s.isLoading()) {
-			_scene._userInterface._selectedInvIndex = -1;
-			_currentSectionNumber = -2;
-			_scene._currentSceneId = -2;
-			_sectionNumber = _scene._nextSceneId / 100;
-			_scene._frameStartTime = _vm->_events->getFrameCounter();
-		}
 	} else {
 		// Load scene specific data for the loaded scene
 		_scene._sceneLogic->synchronize(s);
@@ -494,8 +487,18 @@ void Game::loadGame(int slotNumber) {
 		delete header._thumbnail;
 	}
 
-	// Load the initial data such as what scene needs to be loaded up
+	// Load most of the savegame data with the exception of scene specific info
 	synchronize(s, true);
+
+	// Set up section/scene and other initial states for post-load
+	_scene._userInterface._selectedInvIndex = -1;
+	_currentSectionNumber = -2;
+	_scene._currentSceneId = -2;
+	_sectionNumber = _scene._nextSceneId / 100;
+	_scene._frameStartTime = _vm->_events->getFrameCounter();
+
+	_player._spritesLoaded = false;
+	_player._spritesChanged = true;
 }
 
 void Game::saveGame(int slotNumber, const Common::String &saveName) {
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 5ae670d..358a266 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -87,7 +87,6 @@ protected:
 	bool _quoteEmergency;
 	bool _vocabEmergency;
 	bool _anyEmergency;
-	int _loadGameSlot;
 	int _lastSave;
 	Common::String _saveName;
 	Common::InSaveFile *_saveFile;
@@ -149,6 +148,7 @@ public:
 	Common::String _aaName;
 	int _winStatus;
 	int _widepipeCtr;
+	int _loadGameSlot;
 public:
 	virtual ~Game();
 
diff --git a/engines/mads/globals.cpp b/engines/mads/globals.cpp
index de15ba9..2343dd9 100644
--- a/engines/mads/globals.cpp
+++ b/engines/mads/globals.cpp
@@ -31,9 +31,9 @@ void Globals::reset() {
 }
 
 void Globals::synchronize(Common::Serializer &s) {
-	int count = 0;
-	int16 v;
+	int count = _data.size();
 	s.syncAsUint16LE(count);
+	int16 v;
 
 	if (s.isSaving()) {
 		for (int idx = 0; idx < count; ++idx) {
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index a099f59..9587efa 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -124,13 +124,13 @@ int MADSEngine::hypotenuse(int xv, int yv) {
 bool MADSEngine::canLoadGameStateCurrently() {
 	return !_game->_winStatus && !_game->globals()[5] 
 		&& _dialogs->_pendingDialog == DIALOG_NONE
-		&& _events->_cursorId == CURSOR_ARROW;
+		&& _events->_cursorId != CURSOR_WAIT;
 }
 
 bool MADSEngine::canSaveGameStateCurrently() {
 	return !_game->_winStatus && !_game->globals()[5]
 		&& _dialogs->_pendingDialog == DIALOG_NONE
-		&& _events->_cursorId == CURSOR_ARROW;
+		&& _events->_cursorId != CURSOR_WAIT;
 }
 
 /**
@@ -142,7 +142,9 @@ Common::String MADSEngine::generateSaveName(int slot) {
 }
 
 Common::Error MADSEngine::loadGameState(int slot) {
-	_game->loadGame(slot);
+	_game->_loadGameSlot = slot;
+	_game->_scene._currentSceneId = -1;
+	_game->_currentSectionNumber = -1;
 	return Common::kNoError;
 }
 
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index ce3f086..546fdbe 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -748,7 +748,7 @@ void GameNebular::step() {
 void GameNebular::synchronize(Common::Serializer &s, bool phase1) {
 	Game::synchronize(s, phase1);
 
-	if (!phase1) {
+	if (phase1) {
 		_globals.synchronize(s);
 		s.syncAsByte(_storyMode);
 		s.syncAsByte(_difficulty);
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 0c9a496..20d5490 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -690,6 +690,7 @@ void Player::releasePlayerSprites() {
 		} while (--spriteEnd >= _spritesStart);
 	}
 
+	_numSprites = 0;
 	_spritesLoaded = false;
 	_spritesChanged = true;
 }
@@ -722,7 +723,6 @@ void Player::synchronize(Common::Serializer &s) {
 	s.syncAsByte(_visible);
 	s.syncAsByte(_priorVisible);
 
-	s.syncAsSint16LE(_spritesStart);
 	for (int i = 0; i < 8; ++i)
 		s.syncAsByte(_spriteSetsPresent[i]);
 
@@ -751,7 +751,6 @@ void Player::synchronize(Common::Serializer &s) {
 	s.syncAsUint16LE(_frameCount);
 	synchronizeString(s, _spritesPrefix);
 	s.syncAsUint32LE(_priorTimer);
-	s.syncAsSint16LE(_numSprites);
 	s.syncAsByte(_loadsFirst);
 	s.syncAsByte(_loadedFirst);
 	s.syncAsByte(_spritesLoaded);


Commit: 800ff80c52523fd044df3aa879caddb8a617134c
    https://github.com/scummvm/scummvm/commit/800ff80c52523fd044df3aa879caddb8a617134c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-03T13:20:29-04:00

Commit Message:
MADS: Default to first inventory item after loading a savegame

Changed paths:
    engines/mads/game.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 862ecf9..65790d3 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -491,12 +491,15 @@ void Game::loadGame(int slotNumber) {
 	synchronize(s, true);
 
 	// Set up section/scene and other initial states for post-load
-	_scene._userInterface._selectedInvIndex = -1;
 	_currentSectionNumber = -2;
 	_scene._currentSceneId = -2;
 	_sectionNumber = _scene._nextSceneId / 100;
 	_scene._frameStartTime = _vm->_events->getFrameCounter();
 
+	// Default the selected inventory item to the first one, if the player has any
+	_scene._userInterface._selectedInvIndex = _objects._inventoryList.size() > 0 ? 0 : -1;
+
+	// Set player sprites sets flags
 	_player._spritesLoaded = false;
 	_player._spritesChanged = true;
 }


Commit: 9cd7e8b886c2c72d659cd3439ae4f004126393de
    https://github.com/scummvm/scummvm/commit/9cd7e8b886c2c72d659cd3439ae4f004126393de
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-03T13:47:04-04:00

Commit Message:
MADS: Maintain inventory ordering in savegames

Changed paths:
    engines/mads/inventory.cpp
    engines/mads/inventory.h



diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index a6459c7..fecb1b3 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -47,10 +47,22 @@ void InventoryObject::synchronize(Common::Serializer &s) {
 
 void InventoryObjects::load() {
 	File f("*OBJECTS.DAT");
+	int count = f.readUint16LE();
 	Common::Serializer s(&f, nullptr);
 
 	// Load the objects data
-	synchronize(s);
+	reserve(count);
+	for (int i = 0; i < count; ++i) {
+		InventoryObject obj;
+		obj.synchronize(s);
+		push_back(obj);
+
+		// If it's for the player's inventory, add the index to the inventory list
+		if (obj._roomNumber == PLAYER_INVENTORY) {
+			_inventoryList.push_back(i);
+			assert(_inventoryList.size() <= 32);
+		}
+	}
 }
 
 void InventoryObjects::synchronize(Common::Serializer &s) {
@@ -61,23 +73,22 @@ void InventoryObjects::synchronize(Common::Serializer &s) {
 		// Store the data for each object in the inventory lsit
 		for (int idx = 0; idx < count; ++idx)
 			(*this)[idx].synchronize(s);
+
+		// Synchronize the player's inventory
+		_inventoryList.synchronize(s);
 	} else {
 		clear();
-		_inventoryList.clear();
-		reserve(count);
 
 		// Read in each object
+		reserve(count);
 		for (int i = 0; i < count; ++i) {
 			InventoryObject obj;
 			obj.synchronize(s);
 			push_back(obj);
-
-			// If it's for the player's inventory, add the index to the inventory list
-			if (obj._roomNumber == PLAYER_INVENTORY) {
-				_inventoryList.push_back(i);
-				assert(_inventoryList.size() <= 32);
-			}
 		}
+
+		// Synchronize the player's inventory
+		_inventoryList.synchronize(s);
 	}
 }
 
diff --git a/engines/mads/inventory.h b/engines/mads/inventory.h
index 5e3ecd6..f3c63f8 100644
--- a/engines/mads/inventory.h
+++ b/engines/mads/inventory.h
@@ -60,7 +60,7 @@ private:
 	MADSEngine *_vm;
 
 public:
-	Common::Array<int> _inventoryList;
+	SynchronizedList _inventoryList;
 
 	/** 
 	 * Constructor


Commit: d38e1aa5006266dedf5e7de6382df8c321009ee7
    https://github.com/scummvm/scummvm/commit/d38e1aa5006266dedf5e7de6382df8c321009ee7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-03T14:18:33-04:00

Commit Message:
MADS: Reorganise Nebular dialog methods

Changed paths:
    engines/mads/nebular/dialogs_nebular.cpp



diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 98e05ad..dc7d432 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -33,90 +33,6 @@ namespace MADS {
 
 namespace Nebular {
 
-CopyProtectionDialog::CopyProtectionDialog(MADSEngine *vm, bool priorAnswerWrong):
-		TextDialog(vm, FONT_INTERFACE, Common::Point(-1, -1), 32) {
-	getHogAnusEntry(_hogEntry);
-
-	if (priorAnswerWrong) {
-		addLine("ANSWER INCORRECT!", true);
-		wordWrap("\n");
-		addLine("(But we'll give you another chance!)");
-	} else {
-		addLine("REX NEBULAR version 8.43", true);
-		wordWrap("\n");
-		addLine("(Copy Protection, for your convenience)");
-	}
-	wordWrap("\n");
-
-	wordWrap("Now comes the part that everybody hates.  But if we don't");
-	wordWrap("do this, nasty rodent-like people will pirate this game");
-	wordWrap("and a whole generation of talented designers, programmers,");
-	wordWrap("artists, and playtesters will go hungry, and will wander");
-	wordWrap("aimlessly through the land at night searching for peace.");
-	wordWrap("So let's grit our teeth and get it over with.  Just get");
-	
-	Common::String line = "out your copy of ";
-	line += _hogEntry._bookId == 103 ? "the GAME MANUAL" : "REX'S LOGBOOK";
-	line += ".  See!  That was easy.  ";
-	wordWrap(line);
-
-	line = Common::String::format("Next, just turn to page %d. On line %d, find word number %d, ",
-		_hogEntry._pageNum, _hogEntry._lineNum, _hogEntry._wordNum);
-	wordWrap(line);
-
-	wordWrap("and type it on the line below (we',27h,'ve even given you");
-	wordWrap("first letter as a hint).  As soon as you do that, we can get");
-	wordWrap("right into this really COOL adventure game!\n");
-	wordWrap("\n");
-	wordWrap("                    ");
-	addInput();
-	wordWrap("\n");
-}
-
-bool CopyProtectionDialog::show() {
-	draw();
-	_vm->_events->showCursor();
-
-	// TODO: Replace with text input
-	while (!_vm->shouldQuit() && !_vm->_events->isKeyPressed() &&
-			!_vm->_events->_mouseClicked) {
-		_vm->_events->delay(1);
-	}
-
-	_vm->_events->_pendingKeys.clear();
-	return true;
-}
-
-bool CopyProtectionDialog::getHogAnusEntry(HOGANUS &entry) {
-	File f;
-	f.open("*HOGANUS.DAT");
-
-	// Read in the total number of entries, and randomly pick an entry to use
-	int numEntries = f.readUint16LE();
-	int entryIndex = _vm->getRandomNumber(1, numEntries);
-
-	// Read in the encrypted entry
-	f.seek(28 * entryIndex + 2);
-	byte entryData[28];
-	f.read(entryData, 28);
-
-	// Decrypt it
-	for (int i = 0; i < 28; ++i)
-		entryData[i] = ~entryData[i];
-
-	// Fill out the fields
-	entry._bookId = entryData[0];
-	entry._pageNum = READ_LE_UINT16(&entryData[2]);
-	entry._lineNum = READ_LE_UINT16(&entryData[4]);
-	entry._wordNum = READ_LE_UINT16(&entryData[6]);
-	entry._word = Common::String((char *)&entryData[8]);
-
-	f.close();
-	return true;
-}
-
-/*------------------------------------------------------------------------*/
-
 bool DialogsNebular::show(int msgId) {
 	MADSAction &action = _vm->_game->_scene._action;
 	Common::StringArray msg = _vm->_game->getMessage(msgId);
@@ -330,6 +246,91 @@ void DialogsNebular::showDialog() {
 
 /*------------------------------------------------------------------------*/
 
+CopyProtectionDialog::CopyProtectionDialog(MADSEngine *vm, bool priorAnswerWrong) :
+TextDialog(vm, FONT_INTERFACE, Common::Point(-1, -1), 32) {
+	getHogAnusEntry(_hogEntry);
+
+	if (priorAnswerWrong) {
+		addLine("ANSWER INCORRECT!", true);
+		wordWrap("\n");
+		addLine("(But we'll give you another chance!)");
+	}
+	else {
+		addLine("REX NEBULAR version 8.43", true);
+		wordWrap("\n");
+		addLine("(Copy Protection, for your convenience)");
+	}
+	wordWrap("\n");
+
+	wordWrap("Now comes the part that everybody hates.  But if we don't");
+	wordWrap("do this, nasty rodent-like people will pirate this game");
+	wordWrap("and a whole generation of talented designers, programmers,");
+	wordWrap("artists, and playtesters will go hungry, and will wander");
+	wordWrap("aimlessly through the land at night searching for peace.");
+	wordWrap("So let's grit our teeth and get it over with.  Just get");
+
+	Common::String line = "out your copy of ";
+	line += _hogEntry._bookId == 103 ? "the GAME MANUAL" : "REX'S LOGBOOK";
+	line += ".  See!  That was easy.  ";
+	wordWrap(line);
+
+	line = Common::String::format("Next, just turn to page %d. On line %d, find word number %d, ",
+		_hogEntry._pageNum, _hogEntry._lineNum, _hogEntry._wordNum);
+	wordWrap(line);
+
+	wordWrap("and type it on the line below (we',27h,'ve even given you");
+	wordWrap("first letter as a hint).  As soon as you do that, we can get");
+	wordWrap("right into this really COOL adventure game!\n");
+	wordWrap("\n");
+	wordWrap("                    ");
+	addInput();
+	wordWrap("\n");
+}
+
+bool CopyProtectionDialog::show() {
+	draw();
+	_vm->_events->showCursor();
+
+	// TODO: Replace with text input
+	while (!_vm->shouldQuit() && !_vm->_events->isKeyPressed() &&
+		!_vm->_events->_mouseClicked) {
+		_vm->_events->delay(1);
+	}
+
+	_vm->_events->_pendingKeys.clear();
+	return true;
+}
+
+bool CopyProtectionDialog::getHogAnusEntry(HOGANUS &entry) {
+	File f;
+	f.open("*HOGANUS.DAT");
+
+	// Read in the total number of entries, and randomly pick an entry to use
+	int numEntries = f.readUint16LE();
+	int entryIndex = _vm->getRandomNumber(1, numEntries);
+
+	// Read in the encrypted entry
+	f.seek(28 * entryIndex + 2);
+	byte entryData[28];
+	f.read(entryData, 28);
+
+	// Decrypt it
+	for (int i = 0; i < 28; ++i)
+		entryData[i] = ~entryData[i];
+
+	// Fill out the fields
+	entry._bookId = entryData[0];
+	entry._pageNum = READ_LE_UINT16(&entryData[2]);
+	entry._lineNum = READ_LE_UINT16(&entryData[4]);
+	entry._wordNum = READ_LE_UINT16(&entryData[6]);
+	entry._word = Common::String((char *)&entryData[8]);
+
+	f.close();
+	return true;
+}
+
+/*------------------------------------------------------------------------*/
+
 ScreenDialog::DialogLine::DialogLine() {
 	_state = 0;
 	_textDisplayIndex = -1;
@@ -503,7 +504,6 @@ finish:
 	++_lineIndex;
 }
 
-
 void ScreenDialog::initVars() {
 	_v1 = -1;
 	_selectedLine = -1;


Commit: f9b52398bdd621d4466a845c6d49f9f27e7a4482
    https://github.com/scummvm/scummvm/commit/f9b52398bdd621d4466a845c6d49f9f27e7a4482
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-04T03:48:36+03:00

Commit Message:
MADS: Add a sanity check in DynamicHotspots::remove()

Fixes a crash when loading outside the hut

Changed paths:
    engines/mads/hotspots.cpp



diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
index 560726b..0853f66 100644
--- a/engines/mads/hotspots.cpp
+++ b/engines/mads/hotspots.cpp
@@ -97,7 +97,7 @@ int DynamicHotspots::setCursor(int index, CursorType cursor) {
 void DynamicHotspots::remove(int index) {
 	Scene &scene = _vm->_game->_scene;
 
-	if (_entries[index]._active) {
+	if (index >= 0 && _entries[index]._active) {
 		if (_entries[index]._seqIndex >= 0)
 			scene._sequences[_entries[index]._seqIndex]._dynamicHotspotIndex = -1;
 		_entries[index]._active = false;


Commit: 27982c850a66cf1db10078b9ac576170b8c34bf5
    https://github.com/scummvm/scummvm/commit/27982c850a66cf1db10078b9ac576170b8c34bf5
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-04T03:52:13+03:00

Commit Message:
MADS: Fix several logic bugs in scenes 102, 109 and 212

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 48393e1..ab4a112 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -385,6 +385,14 @@ bool MADSAction::isAction(int verbId, int objectNameId, int indirectObjectId) {
 	return true;
 }
 
+bool MADSAction::isObject(int objectNameId) {
+	return _activeAction._objectNameId == objectNameId;
+}
+
+bool MADSAction::isTarget(int objectNameId) {
+	return _activeAction._indirectObjectId == objectNameId;
+}
+
 void MADSAction::checkActionAtMousePos() {
 	Scene &scene = _vm->_game->_scene;
 	UserInterface &userInterface = scene._userInterface;
diff --git a/engines/mads/action.h b/engines/mads/action.h
index ac6c35c..24521d0 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -151,7 +151,9 @@ public:
 
 	void checkAction();
 	bool isAction(int verbId, int objectNameId = 0, int indirectObjectId = 0);
-	
+	bool isObject(int objectNameId);
+	bool isTarget(int objectNameId);
+
 	/**
 	 * Check the result of the current action on the sentence
 	 * with the provision that the action is not yet complete.
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 7d8b077..5629dc0 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -798,7 +798,7 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action._activeAction._objectNameId == 0x122 && !_fridgeOpenedFl) {
+	if (_action.isObject(0x122) && !_fridgeOpenedFl) {
 		switch (_game._trigger) {
 		case 0:
 			_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 6, 1, 0, 0);
@@ -970,7 +970,7 @@ void Scene102::actions() {
 		return;
 	}
 
-	if ((_action._activeAction._objectNameId == 0xC7 || _action._activeAction._objectNameId == 0xA3) && (_action.isAction(VERB_LOOK) || _action.isAction(0x50) || _action.isAction(0x4F))) {
+	if ((_action.isObject(0xC7) || _action.isObject(0xA3)) && (_action.isAction(VERB_LOOK) || _action.isAction(0x50) || _action.isAction(0x4F))) {
 		if (_game._objects.isInInventory(OBJ_REBREATHER)) {
 			if (!_action.isAction(0x50) && !_action.isAction(0x4F)) {
 				_vm->_dialogs->show(0x27F7);
@@ -984,7 +984,7 @@ void Scene102::actions() {
 		}
 	}
 
-	if ((_action._activeAction._objectNameId == 0xC7 || _action._activeAction._objectNameId == 0xA3) && (_action.isAction(0x50) || _action.isAction(0x4F)) ) {
+	if ((_action.isObject(0xC7) || _action.isObject(0xA3)) && (_action.isAction(0x50) || _action.isAction(0x4F)) ) {
 		switch (_game._trigger) {
 		case 0:
 			_scene->loadAnimation(formAnimName('A', -1), 1);
@@ -2470,8 +2470,8 @@ void Scene109::preActions() {
 		_game._player._walkOffScreenSceneId = 108;
 
 	if ((_action.isAction(VERB_THROW) || _action.isAction(VERB_GIVE) || _action.isAction(VERB_PUT))
-	&& (_action.isAction(0x146) || _action.isAction(0x178))
-	&& (_action.isAction(0x65) || _action.isAction(0x157) || _action.isAction(0x35))) {
+	&& (_action.isObject(0x146) || _action.isObject(0x178))
+	&& (_action.isObject(0x65) || _action.isObject(0x157) || _action.isObject(0x35))) {
 		int idx = _game._objects.getIdFromDesc(_action._activeAction._objectNameId);
 		if ((idx >= 0) && _game._objects.isInInventory(idx)) {
 			_game._player._prepareWalkPos = Common::Point(106, 38);
@@ -2482,7 +2482,7 @@ void Scene109::preActions() {
 	}
 
 	if ((_action.isAction(0x15A, 0x178) || _action.isAction(0x15C, 0x146))
-	&& (!_globals[kHoovicAlive] || _globals[kHoovicSated]) && (_action.isAction(0x178)))
+	&& (!_globals[kHoovicAlive] || _globals[kHoovicSated]) && (_action.isObject(0x178)))
 		_game._player._walkOffScreenSceneId = 110;
 
 	_hungryFl = false;
@@ -2495,8 +2495,8 @@ void Scene109::actions() {
 		return;
 	}
 
-	if ((_action.isAction(VERB_THROW) || _action.isAction(VERB_GIVE)) && ((_action.isAction(0x146) || _action.isAction(0x178)))) {
-		if (_action.isAction(0x65) || _action.isAction(0x157) || _action.isAction(0x35)) {
+	if ((_action.isAction(VERB_THROW) || _action.isAction(VERB_GIVE)) && (_action.isTarget(0x146) || _action.isTarget(0x178))) {
+		if (_action.isObject(0x65) || _action.isObject(0x157) || _action.isObject(0x35)) {
 			_throwingObjectId = _game._objects.getIdFromDesc(_action._activeAction._objectNameId);
 			if (_throwingObjectId >= 0) {
 				if ((_game._objects.isInInventory(_throwingObjectId) && _globals[kHoovicAlive]) || _rexThrowingObject) {
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index a62ad6b..2ead2c0 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -4551,7 +4551,7 @@ void Scene212::preActions() {
 void Scene212::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(0x52D9);
-	else if (_action.isAction(0x18C) && (_action.isAction(0x82) || _action.isAction(0xE8)))
+	else if (_action.isAction(0x18C) && (_action.isObject(0x82) || _action.isObject(0xE8)))
 		_scene->_nextSceneId = 208;
 	else if (_action.isAction(0x18C, 0x3F))
 		_scene->_nextSceneId = 111;


Commit: 0023e99621ba91ba87e4241e2a1ef6f97da4e7c0
    https://github.com/scummvm/scummvm/commit/0023e99621ba91ba87e4241e2a1ef6f97da4e7c0
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-04T03:54:54+03:00

Commit Message:
MADS: Fix bugs in SpriteSets::remove()

This fixes several crashes when sprites get erased, like for example in
death animations

Changed paths:
    engines/mads/sprites.cpp



diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index f187295..36cbdbe 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -399,17 +399,21 @@ void SpriteSets::clear() {
 
 void SpriteSets::remove(int idx) {
 	if (idx >= 0) {
-		delete (*this)[idx];
-
 		if (idx < ((int)size() - 1)) {
+			delete (*this)[idx];
 			(*this)[idx] = nullptr;
 		} else {
-			do {
+			while (size() > 0 && (*this)[size() - 1] == nullptr) {
+				delete (*this)[size() - 1];
 				remove_at(size() - 1);
-			} while (size() > 0 && (*this)[size() - 1] == nullptr);
+			}
 		}
 
-		--_assetCount;
+		if (_assetCount > 0)
+			--_assetCount;
+		else
+			// FIXME: This is needed, otherwise scene sprites are not cleared in this case
+			clear();
 	}
 }
 


Commit: e5e5bdd7f1445cbbeaf1bebdd84d80ef5e665593
    https://github.com/scummvm/scummvm/commit/e5e5bdd7f1445cbbeaf1bebdd84d80ef5e665593
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-04T03:56:26+03:00

Commit Message:
MADS: Add a FIXME for scene 109

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 5629dc0..f68a613 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -2436,7 +2436,8 @@ void Scene109::step() {
 		_hungryFl = true;
 	}
 
-	if (_eatingFirstFish && (_scene->_sequences[_globals._sequenceIndexes[10]]._msgPos.x >= 178)) {
+	// FIXME: The fish animation never moves, so x is never updated and the scene freezes
+	if (_eatingFirstFish /*&& (_scene->_sequences[_globals._sequenceIndexes[10]]._msgPos.x >= 178)*/) {
 		_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 4, 1, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 4);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_SPRITE, 29, 72);


Commit: 17b253a2519c021b36cd9f4ed00af9e051369068
    https://github.com/scummvm/scummvm/commit/17b253a2519c021b36cd9f4ed00af9e051369068
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-04T09:42:50+02:00

Commit Message:
MADS: Add synchronize in scene 401 and 402

Changed paths:
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes4.h
    engines/mads/user_interface.h



diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index 9d20c68..7b50460 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -98,6 +98,15 @@ void Scene401::setup() {
 	setAAName();
 }
 
+void Scene401::synchronize(Common::Serializer &s) {
+	Scene4xx::synchronize(s);
+
+	s.syncAsByte(_northFl);
+	s.syncAsSint16LE(_destPos.x);
+	s.syncAsSint16LE(_destPos.y);
+	s.syncAsUint32LE(_timer);
+}
+
 void Scene401::enter() {
 	if (_scene->_priorSceneId != -2)
 		_northFl = false;
@@ -237,6 +246,51 @@ void Scene402::setup() {
 	_scene->addActiveVocab(0xD1);
 }
 
+void Scene402::synchronize(Common::Serializer &s) {
+	Scene4xx::synchronize(s);
+
+	s.syncAsByte(_lightOn);
+	s.syncAsByte(_blowingSmoke);
+	s.syncAsByte(_leftWomanMoving);
+	s.syncAsByte(_rightWomanMoving);
+	s.syncAsByte(_firstTalkToGirlInChair);
+	s.syncAsByte(_waitingGinnyMove);
+	s.syncAsByte(_ginnyLooking);
+	s.syncAsByte(_bigBeatFl);
+	s.syncAsByte(_roxOnStool);
+	s.syncAsByte(_bartenderSteady);
+	s.syncAsByte(_bartenderHandsHips);
+	s.syncAsByte(_bartenderLooksLeft);
+	s.syncAsByte(_bartenderReady);
+	s.syncAsByte(_bartenderTalking);
+	s.syncAsByte(_bartenderCalled);
+	s.syncAsByte(_conversationFl);
+	s.syncAsByte(_activeTeleporter);
+	s.syncAsByte(_activeArrows);
+	s.syncAsByte(_activeArrow1);
+	s.syncAsByte(_activeArrow2);
+	s.syncAsByte(_activeArrow3);
+	s.syncAsByte(_cutSceneReady);
+	s.syncAsByte(_cutSceneNeeded);
+	s.syncAsByte(_helgaReady);
+	s.syncAsByte(_refuseAlienLiquor);
+
+	s.syncAsSint16LE(_drinkTimer);
+	s.syncAsSint16LE(_beatCounter);
+	s.syncAsSint16LE(_bartenderMode);
+	s.syncAsSint16LE(_bartenderDialogNode);
+	s.syncAsSint16LE(_bartenderCurrentQuestion);
+	s.syncAsSint16LE(_helgaTalkMode);
+	s.syncAsSint16LE(_roxMode);
+	s.syncAsSint16LE(_rexMode);
+	s.syncAsSint16LE(_talkTimer);
+
+	_dialog1.synchronize(s);
+	_dialog2.synchronize(s);
+	_dialog3.synchronize(s);
+	_dialog4.synchronize(s);
+}
+
 void Scene402::setDialogNode(int node) {
 	if (node > 0)
 		_bartenderDialogNode = node;
diff --git a/engines/mads/nebular/nebular_scenes4.h b/engines/mads/nebular/nebular_scenes4.h
index 2010931..c48d027 100644
--- a/engines/mads/nebular/nebular_scenes4.h
+++ b/engines/mads/nebular/nebular_scenes4.h
@@ -58,6 +58,7 @@ private:
 
 public:
 	Scene401(MADSEngine *vm) : Scene4xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -119,6 +120,7 @@ private:
 	
 public:
 	Scene402(MADSEngine *vm) : Scene4xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 9948278..04a8d09 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -128,6 +128,12 @@ public:
 	 * Starts the conversation
 	 */
 	void start();
+
+	/**
+	 * Synchronize the conversation
+	 */
+	void synchronize(Common::Serializer &s) { warning("TODO: Synchronize Conversation"); };
+
 };
 
 class UserInterface : public MSurface {


Commit: 68671d77c2028d41b6b848eb5bf6f40cc2c36f7a
    https://github.com/scummvm/scummvm/commit/68671d77c2028d41b6b848eb5bf6f40cc2c36f7a
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-04T14:03:39+03:00

Commit Message:
MADS: Fix a bug in SequenceList::scan()

This resolves the FIXME in SpriteSets::remove()

Changed paths:
    engines/mads/sequence.cpp
    engines/mads/sprites.cpp



diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index b46b5c0..cbe0471 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -410,7 +410,7 @@ void SequenceList::scan() {
 	Scene &scene = _vm->_game->_scene;
 
 	for (uint i = 0; i < _entries.size(); ++i) {
-		if (!_entries[i]._active && (_entries[i]._spritesIndex != -1)) {
+		if (_entries[i]._active && (_entries[i]._spritesIndex != -1)) {
 			int idx = scene._spriteSlots.add();
 			setSpriteSlot(i, scene._spriteSlots[idx]);
 		}
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 36cbdbe..7bd8407 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -404,16 +404,12 @@ void SpriteSets::remove(int idx) {
 			(*this)[idx] = nullptr;
 		} else {
 			while (size() > 0 && (*this)[size() - 1] == nullptr) {
-				delete (*this)[size() - 1];
 				remove_at(size() - 1);
 			}
 		}
 
 		if (_assetCount > 0)
 			--_assetCount;
-		else
-			// FIXME: This is needed, otherwise scene sprites are not cleared in this case
-			clear();
 	}
 }
 


Commit: dfb53b180f294eeb9cf912dad54e949a87e379a9
    https://github.com/scummvm/scummvm/commit/dfb53b180f294eeb9cf912dad54e949a87e379a9
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-04T14:03:39+03:00

Commit Message:
MADS: Sprites aren't always cleared properly - add a FIXME

Changed paths:
    engines/mads/player.cpp



diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 20d5490..aea73bb 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -693,6 +693,12 @@ void Player::releasePlayerSprites() {
 	_numSprites = 0;
 	_spritesLoaded = false;
 	_spritesChanged = true;
+
+	// FIXME: Find out why this occurs
+	if (scene._sprites.size() > 0) {
+		warning("Player::releasePlayerSprites(): leftover sprites remain, clearing list");
+		scene._sprites.clear();
+	}
 }
 
 void Player::synchronize(Common::Serializer &s) {


Commit: 8a4bb1d48ca84fe573c073f3d31ca13fa8bc7c4c
    https://github.com/scummvm/scummvm/commit/8a4bb1d48ca84fe573c073f3d31ca13fa8bc7c4c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-04T14:03:39+03:00

Commit Message:
MADS: Add enums for some magic numbers in Nebular scene group 2

Changed paths:
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index a227b76..851e599 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -39,16 +39,14 @@ enum {
 };
 
 enum Noun {
-	NOUN_D              = 0xD,
 	NOUN_BLOWGUN		= 0x29,
 	NOUN_BOMB           = 0x2A,
 	NOUN_BOMBS          = 0x2B,
-	NOUN_2C             = 0x2C,
+	NOUN_BONE           = 0x2C,
 	NOUN_BURGER			= 0x35,
 	NOUN_CHAIR			= 0x47,
 	NOUN_CHICKEN        = 0x49,
 	NOUN_CHICKEN_BOMB   = 0x4A,
-	NOUN_4E             = 0x4E,
 	NOUN_DEAD_FISH		= 0x65,
 	NOUN_DOOR			= 0x6E,
 	NOUN_EAT			= 0x75,
@@ -64,7 +62,7 @@ enum Noun {
 	NOUN_INSERT			= 0x0B6,
 	NOUN_INSPECT		= 0x0B7,
 	NOUN_JUNGLE			= 0x0B8,
-	NOUN_C7             = 0x0C7,
+	NOUN_LADDER         = 0x0C7,
 	NOUN_LIFE_SUPPORT_SECTION  = 0x0CC,
 	NOUN_LOG			= 0x0D0,
 	NOUN_LOOK_AT		= 0x0D1,
@@ -74,7 +72,7 @@ enum Noun {
 	NOUN_OUTER_HULL		= 0x0F8,
 	NOUN_OUTSIDE		= 0x0F9,
 	NOUN_PEER_THROUGH	= 0x103,
-	NOUN_10D            = 0x10D,
+	NOUN_PIRANHA        = 0x10D,
 	NOUN_PLANT_STALK	= 0x10F,
 	NOUN_READ			= 0x11F,
 	NOUN_REFRIDGERATOR	= 0x122,
@@ -83,8 +81,8 @@ enum Noun {
 	NOUN_SHIELD_MODULATOR	= 0x137,
 	NOUN_SHOOT			= 0x13A,
 	NOUN_SIT_IN			= 0x13F,
-	NOUN_140            = 0x140,
-	NOUN_1C9            = 0x1C9,
+	NOUN_SKULL          = 0x140,
+	NOUN_BROKEN_LADDER  = 0x1C9,
 	NOUN_SMELL			= 0x147,
 	NOUN_STUFFED_FISH	= 0x157,
 	NOUN_15F            = 0x15F,
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 2ead2c0..deded5c 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -30,6 +30,15 @@ namespace MADS {
 
 namespace Nebular {
 
+// Scene 2xx verbs
+enum {
+	VERB_WALK_THROUGH = 0x18B,
+	VERB_WALK_TOWARDS = 0x18C,
+	VERB_CLIMB_DOWN = 0x4E,
+	VERB_WALK_DOWN = 0x1AD
+
+};
+
 void Scene2xx::setAAName() {
 	int idx = (_scene->_nextSceneId == 216) ? 4 : 2;
 	_game._aaName = Resources::formatAAName(idx);
@@ -123,7 +132,7 @@ void Scene201::setup() {
 
 	_scene->addActiveVocab(NOUN_15F);
 	_scene->addActiveVocab(NOUN_487);
-	_scene->addActiveVocab(NOUN_D);
+	_scene->addActiveVocab(VERB_WALKTO);
 }
 
 void Scene201::enter() {
@@ -280,7 +289,7 @@ void Scene201::step() {
 
 void Scene201::actions() {
 	if (_action._lookFlag == false) {
-		if (_action.isAction(0x18C, 0x83))
+		if (_action.isAction(VERB_WALK_TOWARDS, 0x83))
 			_scene->_nextSceneId = 202;
 		else if ((_action.isAction(0x50, 0x156)) || (_action.isAction(0x188, 0x16C)) || (_action.isAction(0x188, 0x1B6))) {
 			if (_game._trigger == 0) {
@@ -330,12 +339,12 @@ void Scene202::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 
-	_scene->addActiveVocab(NOUN_C7);
-	_scene->addActiveVocab(NOUN_4E);
-	_scene->addActiveVocab(NOUN_D);
-	_scene->addActiveVocab(NOUN_2C);
-	_scene->addActiveVocab(NOUN_140);
-	_scene->addActiveVocab(NOUN_1C9);
+	_scene->addActiveVocab(NOUN_LADDER);
+	_scene->addActiveVocab(VERB_CLIMB_DOWN);
+	_scene->addActiveVocab(VERB_WALKTO);
+	_scene->addActiveVocab(NOUN_BONE);
+	_scene->addActiveVocab(NOUN_SKULL);
+	_scene->addActiveVocab(NOUN_BROKEN_LADDER);
 }
 
 void Scene202::enter() {
@@ -358,14 +367,14 @@ void Scene202::enter() {
 	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 0);
 	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(149, 113));
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 10);
-	int idx = _scene->_dynamicHotspots.add(320, 13, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+	int idx = _scene->_dynamicHotspots.add(NOUN_BONE, VERB_WALKTO, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
 	_scene->_dynamicHotspots.setPosition(idx, Common::Point(153, 97), FACING_SOUTH);
 
 	if (!(_globals[kBone202Status] & 1)) {
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(130, 108));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
-		idx = _scene->_dynamicHotspots.add(44, 13, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		idx = _scene->_dynamicHotspots.add(NOUN_BONE, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(132, 97), FACING_SOUTH);
 	}
 
@@ -373,7 +382,7 @@ void Scene202::enter() {
 		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 0, 0, 0);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[6], Common::Point(166, 110));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 10);
-		idx = _scene->_dynamicHotspots.add(44, 13, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
+		idx = _scene->_dynamicHotspots.add(NOUN_BONE, VERB_WALKTO, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(165, 99), FACING_SOUTH);
 	}
 
@@ -391,8 +400,8 @@ void Scene202::enter() {
 	if (_globals[kLadderBroken]) {
 		_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 0, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 6);
-		_scene->_hotspots.activate(199, false);
-		idx = _scene->_dynamicHotspots.add(457, 13, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+		_scene->_hotspots.activate(NOUN_LADDER, false);
+		idx = _scene->_dynamicHotspots.add(NOUN_BROKEN_LADDER, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(246, 124), FACING_NORTH);
 	}
 
@@ -529,8 +538,8 @@ void Scene202::step() {
 	case 93: {
 		_globals[kLadderBroken] = -1;
 		_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 0, 0, 0);
-		_scene->_hotspots.activate(199, false);
-		int idx = _scene->_dynamicHotspots.add(457, 13, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+		_scene->_hotspots.activate(NOUN_LADDER, false);
+		int idx = _scene->_dynamicHotspots.add(NOUN_BROKEN_LADDER, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(246, 124), FACING_NORTH);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[11], _globals._sequenceIndexes[5]);
 		_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[11]);
@@ -709,7 +718,7 @@ void Scene202::preActions() {
 	if (player._readyToWalk)
 		_scene->_kernelMessages.reset();
 
-	if (!_ladderTopFl && (_action.isAction(0x4E, 0xC7) || !player._readyToWalk)) {
+	if (!_ladderTopFl && (_action.isAction(0x4E, NOUN_LADDER) || !player._readyToWalk)) {
 		if (_game._trigger == 0) {
 			_vm->_sound->command(29);
 			player._readyToWalk = false;
@@ -741,12 +750,12 @@ void Scene202::preActions() {
 
 void Scene202::actions() {
 	if (_action._lookFlag == false) {
-		if (_action.isAction(0x4E, 0xC7)) {
+		if (_action.isAction(0x4E, NOUN_LADDER)) {
 			_action._inProgress = false;
 			return;
-		} else if (_action.isAction(0x18C, 0x83)) {
+		} else if (_action.isAction(VERB_WALK_TOWARDS, 0x83)) {
 			_scene->_nextSceneId = 203;
-		} else if (_action.isAction(0x18C, 0x82)) {
+		} else if (_action.isAction(VERB_WALK_TOWARDS, 0x82)) {
 			if (_globals[kMeteorologistStatus] != 2) {
 				if (_scene->_activeAnimation)
 					_globals[kMeteorologistStatus] = 1;
@@ -796,7 +805,7 @@ void Scene202::actions() {
 					return;
 				}
 			}
-		} else if ((_action.isAction(0x50, 0xC7)) && (_globals[kLadderBroken] == 0)) {
+		} else if ((_action.isAction(0x50, NOUN_LADDER)) && (_globals[kLadderBroken] == 0)) {
 			switch (_game._trigger) {
 			case 0:
 				_vm->_sound->command(29);
@@ -804,7 +813,7 @@ void Scene202::actions() {
 				_game._player._visible = false;
 				_game._player._stepEnabled = false;
 
-				_ladderHotspotId = _scene->_dynamicHotspots.add(199, 79, -1, Common::Rect(241, 68, 241 + 12, 68 + 54));
+				_ladderHotspotId = _scene->_dynamicHotspots.add(NOUN_LADDER, 79, -1, Common::Rect(241, 68, 241 + 12, 68 + 54));
 				_scene->_dynamicHotspots.setPosition(_ladderHotspotId, Common::Point(246, 124), FACING_NORTH);
 				_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 1);
@@ -1055,7 +1064,7 @@ void Scene203::step() {
 }
 
 void Scene203::preActions() {
-	if (_rhotundaEatFl && !_action.isAction(0x18C, 0x83)) {
+	if (_rhotundaEatFl && !_action.isAction(VERB_WALK_TOWARDS, 0x83)) {
 		_game._player.walk(Common::Point(158, 136), FACING_SOUTH);
 		_action._inProgress = false;
 		return;
@@ -1068,9 +1077,9 @@ void Scene203::preActions() {
 void Scene203::actions() {
 	if (_action._savedFields._lookFlag) {
 		_vm->_dialogs->show(0x4F53);
-	} else if (_action.isAction(0x18C, 0x83)) {
+	} else if (_action.isAction(VERB_WALK_TOWARDS, 0x83)) {
 		_scene->_nextSceneId = 208;
-	} else if (_action.isAction(0x18C, 0x82)) {
+	} else if (_action.isAction(VERB_WALK_TOWARDS, 0x82)) {
 		_scene->_nextSceneId = 202;
 	} else if (_action.isAction(VERB_LOOK, 0x142)) {
 		_vm->_dialogs->show(0x4F4D);
@@ -1095,9 +1104,9 @@ void Scene203::actions() {
 void Scene205::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(NOUN_D);
+	_scene->addActiveVocab(VERB_WALKTO);
 	_scene->addActiveVocab(NOUN_CHICKEN);
-	_scene->addActiveVocab(NOUN_10D);
+	_scene->addActiveVocab(NOUN_PIRANHA);
 }
 
 void Scene205::enter() {
@@ -1228,9 +1237,9 @@ void Scene207::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 	_scene->addActiveVocab(0x185);
-	_scene->addActiveVocab(NOUN_D);
+	_scene->addActiveVocab(VERB_WALKTO);
 	_scene->addActiveVocab(0x14D);
-	_scene->addActiveVocab(NOUN_D);
+	_scene->addActiveVocab(VERB_WALKTO);
 }
 
 void Scene207::enter() {
@@ -1337,10 +1346,10 @@ void Scene207::step() {
 }
 
 void Scene207::preActions() {
-	if (_action.isAction(0x1AD, 0x1AE))
+	if (_action.isAction(VERB_WALK_DOWN, 0x1AE))
 		_game._player._walkOffScreenSceneId = 211;
 
-	if (_action.isAction(0x18C, 0x1AB))
+	if (_action.isAction(VERB_WALK_TOWARDS, 0x1AB))
 		_game._player._walkOffScreenSceneId = 208;
 
 	if ((_action.isAction(VERB_WALKTO)) || (_action.isAction(VERB_LOOK))) {
@@ -1355,7 +1364,7 @@ void Scene207::preActions() {
 void Scene207::actions() {
 	if (_action._savedFields._lookFlag) {
 		_vm->_dialogs->show(0x50E7);
-	} else if (_action.isAction(0x18B, 0x70)) {
+	} else if (_action.isAction(VERB_WALK_THROUGH, 0x70)) {
 		_scene->_nextSceneId = 214;
 	} else {
 		if ((_game._player._playerPos.x > 150) && (_game._player._playerPos.x < 189) &&
@@ -1416,7 +1425,7 @@ void Scene208::setup() {
 	_scene->addActiveVocab(0x1A8);
 	_scene->addActiveVocab(0x1A9);
 	_scene->addActiveVocab(0x1AA);
-	_scene->addActiveVocab(NOUN_D);
+	_scene->addActiveVocab(VERB_WALKTO);
 }
 
 void Scene208::updateTrap() {
@@ -1531,10 +1540,10 @@ void Scene208::preActions() {
 	if (_action.isAction(VERB_LOOK) && player._readyToWalk)
 		player._needToWalk = true;
 
-	if (_action.isAction(0x18C, 0x9B))
+	if (_action.isAction(VERB_WALK_TOWARDS, 0x9B))
 		player._walkOffScreenSceneId = 209;
 
-	if (_action.isAction(0x18C, 0xF6))
+	if (_action.isAction(VERB_WALK_TOWARDS, 0xF6))
 		player._walkOffScreenSceneId = 207;
 }
 
@@ -1610,7 +1619,7 @@ void Scene208::subAction(int mode) {
 }
 
 void Scene208::actions() {
-	if (_action.isAction(0x18C, 0x19F)) {
+	if (_action.isAction(VERB_WALK_TOWARDS, 0x19F)) {
 		if (_globals[kRhotundaStatus])
 			_scene->_nextSceneId = 203;
 		else if (_game._trigger == 0) {
@@ -1620,7 +1629,7 @@ void Scene208::actions() {
 		} else if (_game._trigger == 1) {
 			_scene->_nextSceneId = 203;
 		}
-	} else if (_action.isAction(0x18C, 0x83)) {
+	} else if (_action.isAction(VERB_WALK_TOWARDS, 0x83)) {
 		_scene->_nextSceneId = 212;
 	} else if (_action.isAction(VERB_TAKE, 0x1AA) && (!_globals[kLeavesStatus] || _game._trigger)) {
 		subAction(1);
@@ -2946,7 +2955,7 @@ void Scene209::step() {
 }
 
 void Scene209::preActions() {
-	if (_action.isAction(0x18C, 0x84))
+	if (_action.isAction(VERB_WALK_TOWARDS, 0x84))
 		_game._player._walkOffScreenSceneId = 208;
 
 	if (_globals[36] == 1) {
@@ -2974,7 +2983,7 @@ void Scene209::actions() {
 		return;
 	}
 
-	if (_action.isAction(0x18C, 0x1A2)) {
+	if (_action.isAction(VERB_WALK_TOWARDS, 0x1A2)) {
 		_scene->_nextSceneId = 203;
 		_action._inProgress = false;
 		return;
@@ -3287,7 +3296,7 @@ void Scene210::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 	_scene->addActiveVocab(0x70);
-	_scene->addActiveVocab(0x18B);
+	_scene->addActiveVocab(VERB_WALK_THROUGH);
 }
 
 void Scene210::handleConversations() {
@@ -4090,7 +4099,7 @@ void Scene210::step() {
 void Scene210::preActions() {
 	_stopWalking = false;
 
-	if (_action.isAction(0x1AD, 0x1C1))
+	if (_action.isAction(VERB_WALK_DOWN, 0x1C1))
 		_game._player._walkOffScreenSceneId = 211;
 }
 
@@ -4166,9 +4175,9 @@ void Scene210::actions() {
 			_shouldMoveHead = false;
 			break;
 		}
-	} else if (_action.isAction(0x1AD, 0x1BF) || _action.isAction(0x18C, 0x1C0)) {
+	} else if (_action.isAction(VERB_WALK_DOWN, 0x1BF) || _action.isAction(VERB_WALK_TOWARDS, 0x1C0)) {
 		_scene->_nextSceneId = 205;
-	} else if (_action.isAction(0x18B, 0x70)) {
+	} else if (_action.isAction(VERB_WALK_THROUGH, 0x70)) {
 		_scene->_nextSceneId = 215;
 	} else if ((_action.isAction(VERB_PULL, 0x5F) || _action.isAction(VERB_OPEN, 0x5F)) && !_globals[kCurtainOpen]) {
 		switch (_game._trigger) {
@@ -4460,18 +4469,18 @@ void Scene211::step() {
 }
 
 void Scene211::preActions() {
-	if (_action.isAction(0x1AD, 0x1B2) && _game._objects.isInInventory(OBJ_BINOCULARS) && (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY)
+	if (_action.isAction(VERB_WALK_DOWN, 0x1B2) && _game._objects.isInInventory(OBJ_BINOCULARS) && (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY)
 	&& (_scene->_customDest.x <= 52) && (_scene->_customDest.y >= 132))
 		_game._player.walk(Common::Point(52, 132), FACING_WEST);
 
-	if (_action.isAction(0x1AD, 0x1AE)) {
+	if (_action.isAction(VERB_WALK_DOWN, 0x1AE)) {
 		if (_game._objects.isInInventory(OBJ_BINOCULARS) && (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY))
 			_game._player.walk(Common::Point(52, 132), FACING_WEST);
 		else
 			_game._player._walkOffScreenSceneId = 210;
 	}
 
-	if (_action.isAction(0x1AD, 0x1B1))
+	if (_action.isAction(VERB_WALK_DOWN, 0x1B1))
 		_game._player._walkOffScreenSceneId = 207;
 }
 
@@ -4544,16 +4553,16 @@ void Scene212::step() {
 }
 
 void Scene212::preActions() {
-	if (_action.isAction(0x18B, 0x41))
+	if (_action.isAction(VERB_WALK_THROUGH, 0x41))
 		_game._player._walkOffScreenSceneId = 111;
 }
 
 void Scene212::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(0x52D9);
-	else if (_action.isAction(0x18C) && (_action.isObject(0x82) || _action.isObject(0xE8)))
+	else if (_action.isAction(VERB_WALK_TOWARDS) && (_action.isObject(0x82) || _action.isObject(0xE8)))
 		_scene->_nextSceneId = 208;
-	else if (_action.isAction(0x18C, 0x3F))
+	else if (_action.isAction(VERB_WALK_TOWARDS, 0x3F))
 		_scene->_nextSceneId = 111;
 	else if (_action.isAction(VERB_LOOK, 0x19C))
 		_vm->_dialogs->show(0x52D1);


Commit: 356e0655cc5094c50a92fbd334a32a918c05b82e
    https://github.com/scummvm/scummvm/commit/356e0655cc5094c50a92fbd334a32a918c05b82e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-04T14:37:12+03:00

Commit Message:
MADS: Clean up the Rex object IDs a bit

Changed paths:
    engines/mads/nebular/game_nebular.h



diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index ab82cf6..0c859fa 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -38,20 +38,61 @@ enum Difficulty {
 	DIFFICULTY_HARD = 1, DIFFICULTY_REALLY_HARD = 2, DIFFICULTY_IMPOSSIBLE = 3
 };
 
-enum InventoryObject { OBJ_NONE = -1, OBJ_BINOCULARS = 0,
-	OBJ_BURGER = 1, OBJ_DEAD_FISH = 2, OBJ_STUFFED_FISH = 3, OBJ_REBREATHER = 4,
-	OBJ_TIMER_MODULE = 5, OBJ_BIG_LEAVES = 6, OBJ_POISON_DARTS = 7, OBJ_PLANT_STALK = 8,
-	OBJ_BLOWGUN = 9, OBJ_TWINKIFRUIT = 10, OBJ_BONE = 11, OBJ_CHICKEN = 12,
-	OBJ_SCALPEL = 13, OBJ_AUDIO_TAPE = 14, OBJ_CREDIT_CHIP = 15, OBJ_SECURITY_CARD = 16,
-	OBJ_CHARGE_CASES = 17, OBJ_ESTROTOXIN = 18, OBJ_BOMB = 19, OBJ_TIMEBOMB = 20,
-	OBJ_REPAIR_LIST = 21, OBJ_ALIEN_LIQUOR = 22, OBJ_TARGET_MODULE = 23, OBJ_SHIELD_MODULATOR = 24,
-	OBJ_TAPE_PLAYER = 25, OBJ_PHONE_CELLS = 26, OBJ_PENLIGHT = 27, OBJ_DURAFAIL_CELLS = 28,
-	OBJ_FAKE_ID = 29, OBJ_ID_CARD = 30, OBJ_POLYCEMENT = 31, OBJ_FISHING_LINE = 33,
-	OBJ_PADLOCK_KEY = 34, OBJ_DOOR_KEY = 35, OBJ_REARVIEW_MIRROR = 36, OBJ_COMPACT_CASE = 37,
-	OBJ_DETONATORS = 39, OBJ_BOTTLE = 40, OBJ_CHICKEN_BOMB = 41, OBJ_VASE = 42,
-	OBJ_REMOTE = 43, OBJ_COMPUTER_GAME = 44, OBJ_PHONE_HANDSET = 45, OBJ_BONES = 46,
-	OBJ_GUARDS_ARM = 47, OBJ_LOG = 48, OBJ_BOMBS = 49, OBJ_NOTE = 50,
-	OBJ_COMBINATION = 51, OBJ_FORMALDEHYDE = 52, OBJ_PETROX = 53, OBJ_LECITHIN = 54
+enum InventoryObject {
+	OBJ_NONE = -1,
+	OBJ_BINOCULARS = 0,
+	OBJ_BURGER = 1,
+	OBJ_DEAD_FISH = 2,
+	OBJ_STUFFED_FISH = 3,
+	OBJ_REBREATHER = 4,
+	OBJ_TIMER_MODULE = 5,
+	OBJ_BIG_LEAVES = 6,
+	OBJ_POISON_DARTS = 7,
+	OBJ_PLANT_STALK = 8,
+	OBJ_BLOWGUN = 9,
+	OBJ_TWINKIFRUIT = 10,
+	OBJ_BONE = 11,
+	OBJ_CHICKEN = 12,
+	OBJ_SCALPEL = 13,
+	OBJ_AUDIO_TAPE = 14,
+	OBJ_CREDIT_CHIP = 15,
+	OBJ_SECURITY_CARD = 16,
+	OBJ_CHARGE_CASES = 17,
+	OBJ_ESTROTOXIN = 18,
+	OBJ_BOMB = 19,
+	OBJ_TIMEBOMB = 20,
+	OBJ_REPAIR_LIST = 21,
+	OBJ_ALIEN_LIQUOR = 22,
+	OBJ_TARGET_MODULE = 23,
+	OBJ_SHIELD_MODULATOR = 24,
+	OBJ_TAPE_PLAYER = 25,
+	OBJ_PHONE_CELLS = 26,
+	OBJ_PENLIGHT = 27,
+	OBJ_DURAFAIL_CELLS = 28,
+	OBJ_FAKE_ID = 29,
+	OBJ_ID_CARD = 30,
+	OBJ_POLYCEMENT = 31,
+	OBJ_FISHING_LINE = 33,
+	OBJ_PADLOCK_KEY = 34,
+	OBJ_DOOR_KEY = 35,
+	OBJ_REARVIEW_MIRROR = 36,
+	OBJ_COMPACT_CASE = 37,
+	OBJ_DETONATORS = 39,
+	OBJ_BOTTLE = 40,
+	OBJ_CHICKEN_BOMB = 41,
+	OBJ_VASE = 42,
+	OBJ_REMOTE = 43,
+	OBJ_COMPUTER_GAME = 44,
+	OBJ_PHONE_HANDSET = 45,
+	OBJ_BONES = 46,
+	OBJ_GUARDS_ARM = 47,
+	OBJ_LOG = 48,
+	OBJ_BOMBS = 49,
+	OBJ_NOTE = 50,
+	OBJ_COMBINATION = 51,
+	OBJ_FORMALDEHYDE = 52,
+	OBJ_PETROX = 53,
+	OBJ_LECITHIN = 54
 };
 
 class GameNebular: public Game {


Commit: d730abf16fa6b41d9f4d620ea4e6c709980ccb44
    https://github.com/scummvm/scummvm/commit/d730abf16fa6b41d9f4d620ea4e6c709980ccb44
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-04T14:38:17+03:00

Commit Message:
MADS: Replace some more magic values for inventory items and actions

Changed paths:
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes3.cpp



diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 851e599..a4481ba 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -89,6 +89,7 @@ enum Noun {
 	NOUN_TIMEBOMB       = 0x171,
 	NOUN_VIEW_SCREEN    = 0x180,
 	NOUN_WALK_THROUGH	= 0x18B,
+	NOUN_PILE_OF_LEAVES = 0x1AA,
 	NOUN_CAPTIVE_CREATURE = 0x1C3,
 	NOUN_NATIVE_WOMAN	= 0x1DC,
 	NOUN_ALCOHOL		= 0x310,
@@ -96,7 +97,7 @@ enum Noun {
 	NOUN_DROP			= 0x3AD,
 	NOUN_DASH			= 0x3AE,
 	NOUN_SPLASH			= 0x3AF,
-	NOUN_487            = 0x487
+	NOUN_BIRDS          = 0x487
 };
 
 class SceneFactory {
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index deded5c..1e5079c 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -34,9 +34,9 @@ namespace Nebular {
 enum {
 	VERB_WALK_THROUGH = 0x18B,
 	VERB_WALK_TOWARDS = 0x18C,
-	VERB_CLIMB_DOWN = 0x4E,
-	VERB_WALK_DOWN = 0x1AD
+	VERB_WALK_DOWN = 0x1AD,
 
+	VERB_CLIMB_DOWN = 0x4E
 };
 
 void Scene2xx::setAAName() {
@@ -131,7 +131,7 @@ void Scene201::setup() {
 	setAAName();
 
 	_scene->addActiveVocab(NOUN_15F);
-	_scene->addActiveVocab(NOUN_487);
+	_scene->addActiveVocab(NOUN_BIRDS);
 	_scene->addActiveVocab(VERB_WALKTO);
 }
 
@@ -148,7 +148,7 @@ void Scene201::enter() {
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 8);
 	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(185, 46));
 
-	int idx = _scene->_dynamicHotspots.add(1159, 209, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+	int idx = _scene->_dynamicHotspots.add(NOUN_BIRDS, 209, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 	_scene->_dynamicHotspots.setPosition(idx, Common::Point(186, 81), FACING_NORTH);
 
 	if ((_scene->_priorSceneId == 202) || (_scene->_priorSceneId == -1)) {
@@ -1424,7 +1424,7 @@ void Scene208::setup() {
 	setAAName();
 	_scene->addActiveVocab(0x1A8);
 	_scene->addActiveVocab(0x1A9);
-	_scene->addActiveVocab(0x1AA);
+	_scene->addActiveVocab(NOUN_PILE_OF_LEAVES);
 	_scene->addActiveVocab(VERB_WALKTO);
 }
 
@@ -1578,27 +1578,27 @@ void Scene208::subAction(int mode) {
 	case 2: {
 		switch (mode) {
 		case 1:
-			_game._objects.addToInventory(6);
+			_game._objects.addToInventory(OBJ_BIG_LEAVES);
 			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 			_globals[kLeavesStatus] = 1;
 			break;
 		case 2:
-			_game._objects.setRoom(6, 1);
+			_game._objects.setRoom(OBJ_BIG_LEAVES, 1);
 			_globals[kLeavesStatus] = 2;
 			updateTrap();
 			break;
 		case 3:
 			_scene->_sequences.remove(_globals._sequenceIndexes[3]);
 			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
-			_game._objects.removeFromInventory(10, 1);
+			_game._objects.removeFromInventory(OBJ_TWINKIFRUIT, 1);
 			_vm->_sound->command(34);
 			break;
 		case 4:
-			_game._objects.removeFromInventory(1, 1);
+			_game._objects.removeFromInventory(OBJ_BURGER, 1);
 			_vm->_sound->command(33);
 			break;
 		case 5:
-			_game._objects.removeFromInventory(2, 1);
+			_game._objects.removeFromInventory(OBJ_DEAD_FISH, 1);
 			_vm->_sound->command(33);
 			break;
 		}
@@ -1631,13 +1631,13 @@ void Scene208::actions() {
 		}
 	} else if (_action.isAction(VERB_WALK_TOWARDS, 0x83)) {
 		_scene->_nextSceneId = 212;
-	} else if (_action.isAction(VERB_TAKE, 0x1AA) && (!_globals[kLeavesStatus] || _game._trigger)) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_PILE_OF_LEAVES) && (!_globals[kLeavesStatus] || _game._trigger)) {
 		subAction(1);
 		if (_game._player._stepEnabled)
 			_vm->_dialogs->showItem(OBJ_BIG_LEAVES, 0x326, 0);
 	} else if (_action.isAction(VERB_PUT, 0x23, 0x19E) && (_globals[kLeavesStatus] == 1 || _game._trigger)) {
 		subAction(2);
-	} else if (_action.isAction(VERB_PUT, 0x17A, 0x1A9)) {
+	} else if (_action.isAction(VERB_PUT, OBJ_TWINKIFRUIT, 0x1A9)) {
 		subAction(3);
 		if (_game._player._stepEnabled) {
 			_game._player._stepEnabled = false;
@@ -1670,7 +1670,7 @@ void Scene208::actions() {
 		_vm->_dialogs->show(0x5147);
 	} else if (_action.isAction(VERB_LOOK, 0x19E)) {
 		_vm->_dialogs->show(0x5148);
-	} else if (_action.isAction(VERB_LOOK, 0x1AA)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_PILE_OF_LEAVES)) {
 		_vm->_dialogs->show(0x5149);
 	} else if (_action.isAction(VERB_LOOK, 0x1A9)) {
 		if (_game._difficulty == DIFFICULTY_IMPOSSIBLE)
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 09b3152..c699907 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -3798,13 +3798,13 @@ void Scene351::actions() {
 			case 1:
 				_scene->_hotspots.activate(0x5C, false);
 				_scene->_sequences.remove(_globals._sequenceIndexes[1]);
-				_game._objects.addToInventory(0xF);
+				_game._objects.addToInventory(OBJ_CREDIT_CHIP);
 				break;
 
 			case 2:
 				_game._player._visible = true;
 				_game._player._stepEnabled = true;
-				_vm->_dialogs->showItem(0xF, 0x32F);
+				_vm->_dialogs->showItem(OBJ_CREDIT_CHIP, 0x32F);
 				break;
 			}
 		}
@@ -4147,7 +4147,7 @@ void Scene352::actions() {
 
 			case 1:
 				_scene->_sequences.remove(_globals._sequenceIndexes[2]);
-				_game._objects.addToInventory(0x2F);
+				_game._objects.addToInventory(OBJ_GUARDS_ARM);
 				_scene->changeVariant(1);
 				break;
 


Commit: 5f2ca95771241f657b02cdbcb5c17c1038776c77
    https://github.com/scummvm/scummvm/commit/5f2ca95771241f657b02cdbcb5c17c1038776c77
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-04T15:34:10+03:00

Commit Message:
MADS: Replace some more article magic numbers with their enum

Changed paths:
    engines/mads/action.cpp
    engines/mads/hotspots.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index ab4a112..3367521 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -62,7 +62,7 @@ MADSAction::MADSAction(MADSEngine *vm) : _vm(vm) {
 	_savedFields._mainObject = 0;
 	_savedFields._secondObject = 0;
 	_savedFields._secondObjectSource = 0;
-	_savedFields._articleNumber = 0;
+	_savedFields._articleNumber = PREP_NONE;
 	_savedFields._lookFlag = false;
 }
 
@@ -223,7 +223,7 @@ void MADSAction::set() {
 		}
 
 		if ((_hotspotId >= 0) && (_articleNumber > 0) && !flag) {
-			if (_articleNumber == 0xff) {
+			if (_articleNumber == PREP_RELATIONAL) {
 				if (_secondObject >= 0) {
 					int articleNum = 0;
 
diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
index 0853f66..ca05ad6 100644
--- a/engines/mads/hotspots.cpp
+++ b/engines/mads/hotspots.cpp
@@ -66,7 +66,7 @@ int DynamicHotspots::add(int descId, int verbId, int seqIndex, const Common::Rec
 	_entries[idx]._feetPos = Common::Point(-3, 0);
 	_entries[idx]._facing = FACING_NONE;
 	_entries[idx]._verbId = verbId;
-	_entries[idx]._articleNumber = 6;
+	_entries[idx]._articleNumber = PREP_IN;
 	_entries[idx]._cursor = CURSOR_NONE;
 
 	++_count;


Commit: 2e5fcc1460bca88338c70142ba31246f6dc15421
    https://github.com/scummvm/scummvm/commit/2e5fcc1460bca88338c70142ba31246f6dc15421
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-04T15:35:13+03:00

Commit Message:
MADS: Replace some magic values in scene 208 with their enums

Changed paths:
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index a4481ba..0c39899 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -89,6 +89,8 @@ enum Noun {
 	NOUN_TIMEBOMB       = 0x171,
 	NOUN_VIEW_SCREEN    = 0x180,
 	NOUN_WALK_THROUGH	= 0x18B,
+	NOUN_HUGE_LEGS      = 0x1A8,
+	NOUN_LEAF_COVERED_PIT  = 0x1A9,
 	NOUN_PILE_OF_LEAVES = 0x1AA,
 	NOUN_CAPTIVE_CREATURE = 0x1C3,
 	NOUN_NATIVE_WOMAN	= 0x1DC,
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 1e5079c..5f64ebc 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1422,8 +1422,8 @@ void Scene207::actions() {
 void Scene208::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x1A8);
-	_scene->addActiveVocab(0x1A9);
+	_scene->addActiveVocab(NOUN_HUGE_LEGS);
+	_scene->addActiveVocab(NOUN_LEAF_COVERED_PIT);
 	_scene->addActiveVocab(NOUN_PILE_OF_LEAVES);
 	_scene->addActiveVocab(VERB_WALKTO);
 }
@@ -1432,7 +1432,7 @@ void Scene208::updateTrap() {
 	if (_globals[kRhotundaStatus] == 1) {
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 0, 0, 24);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
-		int idx = _scene->_dynamicHotspots.add(424, 13, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_HUGE_LEGS, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(100, 146), FACING_NORTH);
 		_scene->_hotspots.activate(414, false);
 		return;
@@ -1442,7 +1442,7 @@ void Scene208::updateTrap() {
 	case 0: {
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 15);
-		int idx = _scene->_dynamicHotspots.add(426, 13, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_PILE_OF_LEAVES, VERB_WALKTO, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(60, 152), FACING_NORTH);
 		}
 		break;
@@ -1450,9 +1450,9 @@ void Scene208::updateTrap() {
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 15);
 		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
 		_scene->_hotspots.activate(414, false);
-		int idx = _scene->_dynamicHotspots.add(425, 13, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_LEAF_COVERED_PIT, VERB_WALKTO, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(100, 146), FACING_NORTH);
-		_scene->_dynamicHotspots[idx]._articleNumber = 5;
+		_scene->_dynamicHotspots[idx]._articleNumber = PREP_ON;
 		}
 		break;
 	}
@@ -1637,19 +1637,19 @@ void Scene208::actions() {
 			_vm->_dialogs->showItem(OBJ_BIG_LEAVES, 0x326, 0);
 	} else if (_action.isAction(VERB_PUT, 0x23, 0x19E) && (_globals[kLeavesStatus] == 1 || _game._trigger)) {
 		subAction(2);
-	} else if (_action.isAction(VERB_PUT, OBJ_TWINKIFRUIT, 0x1A9)) {
+	} else if (_action.isAction(VERB_PUT, OBJ_TWINKIFRUIT, NOUN_LEAF_COVERED_PIT)) {
 		subAction(3);
 		if (_game._player._stepEnabled) {
 			_game._player._stepEnabled = false;
 			_rhotundaTurnFl = true;
 			_game._player.walk(Common::Point(20, 148), FACING_EAST);
 		}
-	} else if (_action.isAction(VERB_PUT, 0x35, 0x1A9)) {
+	} else if (_action.isAction(VERB_PUT, 0x35, NOUN_LEAF_COVERED_PIT)) {
 		subAction(4);
 		if (_game._player._stepEnabled) {
 			_vm->_dialogs->show(0x514C);
 		}
-	} else if (_action.isAction(VERB_PUT, 0x65, 0x1A9)) {
+	} else if (_action.isAction(VERB_PUT, 0x65, NOUN_LEAF_COVERED_PIT)) {
 		subAction(5);
 		if (_game._player._stepEnabled) {
 			_vm->_dialogs->show(0x514C);
@@ -1672,18 +1672,18 @@ void Scene208::actions() {
 		_vm->_dialogs->show(0x5148);
 	} else if (_action.isAction(VERB_LOOK, NOUN_PILE_OF_LEAVES)) {
 		_vm->_dialogs->show(0x5149);
-	} else if (_action.isAction(VERB_LOOK, 0x1A9)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_LEAF_COVERED_PIT)) {
 		if (_game._difficulty == DIFFICULTY_IMPOSSIBLE)
 			_vm->_dialogs->show(0x514A);
 		else
 			_vm->_dialogs->show(0x514B);
 	} else if (_action.isAction(VERB_LOOK, 0x174) || _action.isAction(VERB_LOOK, 0x175)) {
 		_vm->_dialogs->show(0x514D);
-	} else if (_action.isAction(VERB_TAKE, 0x1A9)) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_LEAF_COVERED_PIT)) {
 		_vm->_dialogs->show(0x514E);
-	} else if (_action.isAction(VERB_LOOK, 0x1A8)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_HUGE_LEGS)) {
 		_vm->_dialogs->show(0x514F);
-	} else if (_action.isAction(VERB_TAKE, 0x1A8) || _action.isAction(0xA, 0x1A8)) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_HUGE_LEGS) || _action.isAction(0xA, NOUN_HUGE_LEGS)) {
 		_vm->_dialogs->show(0x5150);
 	} else if (_action._savedFields._lookFlag == 0) {
 		return;


Commit: 9966afbb8f215b1ba8dfaf752355060b1d7b1092
    https://github.com/scummvm/scummvm/commit/9966afbb8f215b1ba8dfaf752355060b1d7b1092
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-04T15:59:00+03:00

Commit Message:
MADS: More naming for scene 208

Changed paths:
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 0c39899..85b2405 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -39,6 +39,7 @@ enum {
 };
 
 enum Noun {
+	NOUN_BIG_LEAVES     = 0x23,
 	NOUN_BLOWGUN		= 0x29,
 	NOUN_BOMB           = 0x2A,
 	NOUN_BOMBS          = 0x2B,
@@ -87,8 +88,10 @@ enum Noun {
 	NOUN_STUFFED_FISH	= 0x157,
 	NOUN_15F            = 0x15F,
 	NOUN_TIMEBOMB       = 0x171,
+	NOUN_TWINKIFRUIT    = 0x17A,
 	NOUN_VIEW_SCREEN    = 0x180,
 	NOUN_WALK_THROUGH	= 0x18B,
+	NOUN_DEEP_PIT       = 0x19E,
 	NOUN_HUGE_LEGS      = 0x1A8,
 	NOUN_LEAF_COVERED_PIT  = 0x1A9,
 	NOUN_PILE_OF_LEAVES = 0x1AA,
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 5f64ebc..44fac5a 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1635,21 +1635,21 @@ void Scene208::actions() {
 		subAction(1);
 		if (_game._player._stepEnabled)
 			_vm->_dialogs->showItem(OBJ_BIG_LEAVES, 0x326, 0);
-	} else if (_action.isAction(VERB_PUT, 0x23, 0x19E) && (_globals[kLeavesStatus] == 1 || _game._trigger)) {
+	} else if (_action.isAction(VERB_PUT, NOUN_BIG_LEAVES, NOUN_DEEP_PIT) && (_globals[kLeavesStatus] == 1 || _game._trigger)) {
 		subAction(2);
-	} else if (_action.isAction(VERB_PUT, OBJ_TWINKIFRUIT, NOUN_LEAF_COVERED_PIT)) {
+	} else if (_action.isAction(VERB_PUT, NOUN_TWINKIFRUIT, NOUN_LEAF_COVERED_PIT)) {
 		subAction(3);
 		if (_game._player._stepEnabled) {
 			_game._player._stepEnabled = false;
 			_rhotundaTurnFl = true;
 			_game._player.walk(Common::Point(20, 148), FACING_EAST);
 		}
-	} else if (_action.isAction(VERB_PUT, 0x35, NOUN_LEAF_COVERED_PIT)) {
+	} else if (_action.isAction(VERB_PUT, NOUN_BURGER, NOUN_LEAF_COVERED_PIT)) {
 		subAction(4);
 		if (_game._player._stepEnabled) {
 			_vm->_dialogs->show(0x514C);
 		}
-	} else if (_action.isAction(VERB_PUT, 0x65, NOUN_LEAF_COVERED_PIT)) {
+	} else if (_action.isAction(VERB_PUT, NOUN_DEAD_FISH, NOUN_LEAF_COVERED_PIT)) {
 		subAction(5);
 		if (_game._player._stepEnabled) {
 			_vm->_dialogs->show(0x514C);
@@ -1668,7 +1668,7 @@ void Scene208::actions() {
 		_vm->_dialogs->show(0x5146);
 	} else if (_action.isAction(VERB_LOOK, 0x9B)) {
 		_vm->_dialogs->show(0x5147);
-	} else if (_action.isAction(VERB_LOOK, 0x19E)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_DEEP_PIT)) {
 		_vm->_dialogs->show(0x5148);
 	} else if (_action.isAction(VERB_LOOK, NOUN_PILE_OF_LEAVES)) {
 		_vm->_dialogs->show(0x5149);
@@ -1683,7 +1683,7 @@ void Scene208::actions() {
 		_vm->_dialogs->show(0x514E);
 	} else if (_action.isAction(VERB_LOOK, NOUN_HUGE_LEGS)) {
 		_vm->_dialogs->show(0x514F);
-	} else if (_action.isAction(VERB_TAKE, NOUN_HUGE_LEGS) || _action.isAction(0xA, NOUN_HUGE_LEGS)) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_HUGE_LEGS) || _action.isAction(VERB_PULL, NOUN_HUGE_LEGS)) {
 		_vm->_dialogs->show(0x5150);
 	} else if (_action._savedFields._lookFlag == 0) {
 		return;


Commit: f894b3f1269203793214a750cbd5a9ae022d2d8c
    https://github.com/scummvm/scummvm/commit/f894b3f1269203793214a750cbd5a9ae022d2d8c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-04T19:22:31+02:00

Commit Message:
MADS: Implement scene 409, first try of Teleporter implementation

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes4.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 0a92cd3..da568ce 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -180,6 +180,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene407(vm);
 	case 408:
 		return new Scene408(vm);
+	case 409:
+		return new Scene409(vm);
 	case 410:
 		return new Scene410(vm);
 	case 411:
@@ -187,11 +189,6 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 413:
 		return new Scene413(vm);
 
-	case 409:
-		// TODO
-		// Fall-through for unimplemented scenes in group #4
-		error("Invalid scene %d called", scene._nextSceneId);
-
 	// Scene group #5
 	case 501:
 		// TODO
@@ -353,6 +350,272 @@ void SceneInfoNebular::loadCodes(MSurface &depthSurface, Common::SeekableReadStr
 		Common::fill(destP, endP, 0);
 }
 
+/*------------------------------------------------------------------------*/
+
+int SceneTeleporter::teleporterAddress(int code, bool working) {
+	int limit = working ? 6 : 10;
+
+	for (int i = 0; i < limit; i++) {
+		if (code == _globals[kTeleporterCode + i])
+			return _globals[kTeleporterRoom + i];
+	}
+
+	return -1;
+}
+
+Common::Point SceneTeleporter::teleporterComputeLocation() {
+	Common::Point result;
+
+	switch (_buttonTyped) {
+	case 0:
+		result = Common::Point(179, 200);
+		break;
+
+	case 1:
+		result = Common::Point(166, 170);
+		break;
+
+	case 2:
+		result = Common::Point(179, 170);
+		break;
+
+	case 3:
+		result = Common::Point(192, 170);
+		break;
+
+	case 4:
+		result = Common::Point(166, 180);
+		break;
+
+	case 5:
+		result = Common::Point(179, 180);
+		break;
+
+	case 6:
+		result = Common::Point(192, 180);
+		break;
+
+	case 7:
+		result = Common::Point(166, 190);
+		break;
+
+	case 8:
+		result = Common::Point(179, 190);
+		break;
+
+	case 9:
+		result = Common::Point(192, 190);
+		break;
+
+	case 10:
+		result = Common::Point(194, 200);
+		break;
+
+	case 11:
+		result = Common::Point(164, 200);
+		break;
+
+	default:
+		error("teleporterComputeLocation() - Unexpected button pressed");
+	}
+
+	return result;
+}
+
+void SceneTeleporter::teleporterHandleKey() {
+	switch (_game._trigger) {
+	case 0: {
+		_game._player._stepEnabled = false;
+		Common::Point msgPos = teleporterComputeLocation();
+		_handSequenceId = _scene->_sequences.startReverseCycle(_handSpriteId, false, 4, 2, 0, 0);
+		_scene->_sequences.setMsgPosition(_handSequenceId, msgPos);
+		_scene->_sequences.setDepth(_handSequenceId, 2);
+		_scene->_sequences.addSubEntry(_handSequenceId, SEQUENCE_TRIGGER_LOOP, 0, 1);
+		_scene->_sequences.addSubEntry(_handSequenceId, SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+
+		if (_globals[kMeteorologistWatch] == 0)
+			_vm->_events->hideCursor();
+
+		}
+		break;
+
+	case 1:
+		_scene->_sequences.addSubEntry(_handSequenceId, SEQUENCE_TRIGGER_SPRITE, 3, 3);
+		if (_buttonTyped <= 9) {
+			if (_digitCount < 4) {
+				_curCode *= 10;
+				_curCode += _buttonTyped;
+				_digitCount++;
+				_msgText = "";
+				_msgText.format("%d", _curCode);
+				if (_digitCount < 4)
+					_msgText += "_";
+
+				if (_scene->_currentSceneId != 711)
+					_vm->_sound->command(32);
+			}
+		} else if (_buttonTyped == 11) {
+			_digitCount = 0;
+			_curCode = 0;
+			_msgText = "_";
+			if (_scene->_currentSceneId != 711)
+				_vm->_sound->command(33);
+		} else if (_digitCount == 4) {
+			if (_scene->_currentSceneId != 711)
+				_finishedCodeCounter = 1;
+
+			if (teleporterAddress(_curCode, true) > 0) {
+				_vm->_palette->setEntry(252, 0, 63, 0);
+				if (_scene->_currentSceneId != 711)
+					_vm->_sound->command(34);
+			} else {
+				_vm->_palette->setEntry(252, 63, 0, 0);
+				if (_scene->_currentSceneId != 711)
+					_vm->_sound->command(35);
+			}
+		}
+
+		if (_scene->_currentSceneId != 711) {
+			if (_curMessageId >= 0)
+				_scene->_kernelMessages.remove(_curMessageId);
+			_curMessageId = _scene->_kernelMessages.add(Common::Point(143, 61), 0xFDFC, 16, 0, 9999999, _msgText);
+		}
+		break;
+
+	case 2:
+		if (_finishedCodeCounter == 1) {
+			_finishedCodeCounter++;
+
+			if (_globals[kMeteorologistWatch] != 0)
+				_scene->_nextSceneId = 202;
+			else {
+				_vm->_events->showCursor();
+				int destination = teleporterAddress(_curCode, true);
+
+				if (destination > 0) {
+					_globals[kTeleporterCommand] = 2;
+					_scene->_nextSceneId = _teleporterSceneId;
+					_globals[kTeleporterDestination] = destination;
+				} else {
+					_globals[kTeleporterCommand] = 4;
+					_scene->_nextSceneId = _teleporterSceneId;
+				}
+			}
+		} else if (_globals[kMeteorologistWatch] != 0)
+			_scene->_sequences.addTimer(30, 230 + _meteorologistCurPlace);
+
+		break;
+
+	case 3:
+		if (!_finishedCodeCounter) {
+			if (_globals[kMeteorologistWatch] == 0) {
+				_game._player._stepEnabled = true;
+				_vm->_events->showCursor();
+			}
+		}
+		break;
+
+	default:
+		break;
+	}
+}
+
+void SceneTeleporter::teleporterEnter() {
+	_game._player._visible   = false;
+	_game._player._stepEnabled = (_globals[kMeteorologistWatch] == 0);
+	_scene->_kernelMessages._talkFont = _vm->_font->getFont(FONT_TELE);
+	_scene->_textSpacing = 0;
+	_curCode   = 0;
+	_digitCount = 0;
+	_finishedCodeCounter       = 0;
+	_curMessageId        = -1;
+	_msgText = "_";
+
+	if (_scene->_priorSceneId == -2)
+		_scene->_priorSceneId = _globals[kTeleporterDestination];
+
+	if (_scene->_priorSceneId < 101)
+		_scene->_priorSceneId = 201;
+
+	_globals[kTeleporterDestination] = _scene->_priorSceneId;
+	_vm->_palette->setEntry(252, 63, 63, 0);
+	_vm->_palette->setEntry(253, 0,  0, 0);
+	_teleporterSceneId = _scene->_priorSceneId;
+	if (_teleporterSceneId == 202)
+		_teleporterSceneId = 201;
+
+	int tmpVal = 0;
+	for (int i = 0; i < 10; i++) {
+		if (_teleporterSceneId == _globals[kTeleporterRoom + i])
+			tmpVal = _globals[kTeleporterRoom + i];
+
+		if (_globals[kTeleporterRoom + i] == 301)
+			_meteorologistNextPlace = _globals[kTeleporterCode + i];
+	}
+
+	Common::String msgText2 = Common::String::format("#%d", tmpVal);
+
+	if (_scene->_currentSceneId != 711) {
+		_scene->_kernelMessages.add(Common::Point(133, 34), 0, 32, 0, 9999999, msgText2);
+		_scene->_kernelMessages.add(Common::Point(143, 61), 0xFDFC, 16, 0, 9999999, _msgText);
+	}
+
+	_meteorologistCurPlace = 0;
+
+	if (_globals[kMeteorologistWatch] != 0)
+		_scene->_sequences.addTimer(30, 230);
+
+	_vm->_sound->command(36);
+}
+
+bool SceneTeleporter::teleporterActions() {
+	bool retVal = false;
+	static int _buttonList[12] = { 0x1D0, 0x1D1, 0x1D2, 0x1D3, 0x1D4, 0x1D5, 0x1D6, 0x1D7, 0x1D8, 0x1D9, 0x1DB, 0x1DA };
+
+	if (_action.isAction(0x11A) || _action.isAction(VERB_PUSH)) {
+		for (int i = 0; i < 12; i++) {
+			if (_action._activeAction._objectNameId == _buttonList[i])
+				_buttonTyped = i;
+		}
+		teleporterHandleKey();
+		retVal = true;
+	}
+
+	if (_action.isAction(0x1CE, 0x1CF)) {
+		_globals[kTeleporterCommand] = 3;
+		_scene->_nextSceneId = _teleporterSceneId;
+		retVal = true;
+	}
+
+	return (retVal);
+}
+
+void SceneTeleporter::teleporterStep() {
+	if ((_globals[kMeteorologistWatch] != 0) && (_game._trigger >= 230)) {
+		int place = _game._trigger - 230;
+		int digit;
+
+		if (place < 4) {
+			digit = _meteorologistNextPlace;
+			for (int i = 0; i < (3 - place); i++)
+				digit = digit / 10;
+
+			digit   = digit % 10;
+		} else {
+			digit   = 10;
+		}
+		_buttonTyped              = digit;
+		_meteorologistCurPlace = place + 1;
+		_game._trigger = -1;
+	}
+
+	if (_game._trigger) {
+		if (_game._trigger == -1)
+			_game._trigger = 0;
+		teleporterHandleKey();
+	}
+}
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 85b2405..2a47af6 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -125,7 +125,7 @@ protected:
 	Common::String formAnimName(char sepChar, int suffixNum);
 
 	/**
-	 * Plays appropriate sound for entering varous rooms
+	 * Plays appropriate sound for entering various rooms
 	 */
 	void lowRoomsEntrySound();
 public:
@@ -150,6 +150,34 @@ protected:
 	SceneInfoNebular(MADSEngine *vm) : SceneInfo(vm) {}
 };
 
+class SceneTeleporter : public NebularScene {
+protected:
+	int _buttonTyped;
+	int _curCode;
+	int _digitCount;
+	int _curMessageId;
+	int _handSpriteId;
+	int _handSequenceId;
+	int _finishedCodeCounter;
+	int _meteorologistNextPlace;
+	int _meteorologistCurPlace;
+	int _teleporterSceneId;
+	Common::String _msgText;
+
+	int teleporterAddress(int code, bool working);
+
+	void teleporterHandleKey();
+	Common::Point teleporterComputeLocation();
+	void teleporterEnter();
+	bool teleporterActions();
+	void teleporterStep();
+
+protected:
+	/**
+	* Constructor
+	*/
+	SceneTeleporter(MADSEngine *vm) : NebularScene(vm) {}
+};
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index 7b50460..980f770 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -2993,6 +2993,63 @@ void Scene408::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene409::setup() {
+	_game._player._spritesPrefix = "";
+
+	// The original is calling Scene4xx::setAAName()
+	_game._aaName = Resources::formatAAName(4);
+}
+
+void Scene409::enter() {
+	_handSpriteId = _scene->_sprites.addSprites("*ROXHAND");
+	teleporterEnter();
+
+	// The original is calling Scene4xx::sceneEntrySound()
+	if (!_vm->_musicFlag)
+		_vm->_sound->command(2);
+	else
+		_vm->_sound->command(10);
+}
+
+void Scene409::step() {
+	teleporterStep();
+}
+
+void Scene409::actions() {
+	if (teleporterActions()) {
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x181))
+		_vm->_dialogs->show(40910);
+	else if (_action.isAction(0x103, 0x181))
+		_vm->_dialogs->show(40910);
+	else if (_action.isAction(VERB_LOOK, 0xC4))
+		_vm->_dialogs->show(40911);
+	else if (_action.isAction(0xB7, 0xC4))
+		_vm->_dialogs->show(40911);
+	else if (_action.isAction(VERB_LOOK, 0x1CC))
+		_vm->_dialogs->show(40912);
+	else if (_action.isAction(VERB_LOOK, 0x1D1) || _action.isAction(VERB_LOOK, 0x1D2)
+		|| _action.isAction(VERB_LOOK, 0x1D3) || _action.isAction(VERB_LOOK, 0x1D4)
+		|| _action.isAction(VERB_LOOK, 0x1D5) || _action.isAction(VERB_LOOK, 0x1D6)
+		|| _action.isAction(VERB_LOOK, 0x1D7) || _action.isAction(VERB_LOOK, 0x1D8)
+		|| _action.isAction(VERB_LOOK, 0x1D9) || _action.isAction(VERB_LOOK, 0x1D0)
+		|| _action.isAction(VERB_LOOK, 0x1DB) || _action.isAction(VERB_LOOK, 0x1DA))
+		_vm->_dialogs->show(40913);
+	else if (_action.isAction(VERB_LOOK, 0x1CF))
+		_vm->_dialogs->show(40914);
+	else if (_action._lookFlag)
+		_vm->_dialogs->show(40914);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene410::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
diff --git a/engines/mads/nebular/nebular_scenes4.h b/engines/mads/nebular/nebular_scenes4.h
index c48d027..1f7b56b 100644
--- a/engines/mads/nebular/nebular_scenes4.h
+++ b/engines/mads/nebular/nebular_scenes4.h
@@ -185,6 +185,18 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene409: public SceneTeleporter {
+public:
+	Scene409(MADSEngine *vm) : SceneTeleporter(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 class Scene410: public Scene4xx {
 public:
 	Scene410(MADSEngine *vm) : Scene4xx(vm) {}


Commit: ff5b97e75af06e07692eb9ddd9da73055997eefe
    https://github.com/scummvm/scummvm/commit/ff5b97e75af06e07692eb9ddd9da73055997eefe
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-04T14:32:58-04:00

Commit Message:
MADS: In progress greyscale fading for picking up inventory items

Changed paths:
    engines/mads/dialogs.h
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/dialogs_nebular.h
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index e4f9bbb..884f7e6 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -181,7 +181,7 @@ public:
 	/**
 	* Show the dialog, and wait until a key or mouse press.
 	*/
-	void show();
+	virtual void show();
 };
 
 class MessageDialog: public TextDialog {
@@ -211,9 +211,9 @@ public:
 	virtual ~Dialogs() {}
 
 	virtual void showDialog() = 0;
-	virtual void showItem(int objectId, int messageId, int arg = 0) = 0;
+	virtual void showItem(int objectId, int messageId, int speech = 0) = 0;
 
-	virtual bool show(int msgId) = 0;
+	virtual bool show(int messageId, int objectId = -1) = 0;
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index dc7d432..9dd20ca 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -33,9 +33,9 @@ namespace MADS {
 
 namespace Nebular {
 
-bool DialogsNebular::show(int msgId) {
+bool DialogsNebular::show(int messageId, int objectId) {
 	MADSAction &action = _vm->_game->_scene._action;
-	Common::StringArray msg = _vm->_game->getMessage(msgId);
+	Common::StringArray msg = _vm->_game->getMessage(messageId);
 	Common::String title;
 	Common::String commandText;
 	Common::String valStr;
@@ -76,7 +76,11 @@ bool DialogsNebular::show(int msgId) {
 						if (centerFlag) {
 							crFlag = true;
 						} else {
-							dialog = new TextDialog(_vm, FONT_INTERFACE, _defaultPosition, _dialogWidth);
+							if (objectId == -1) {
+								dialog = new TextDialog(_vm, FONT_INTERFACE, _defaultPosition, _dialogWidth);
+							} else {
+								dialog = new PictureDialog(_vm, _defaultPosition, _dialogWidth, objectId);
+							}
 							dialog->wordWrap(dialogText);
 							dialog->incNumLines();
 						}
@@ -128,7 +132,11 @@ bool DialogsNebular::show(int msgId) {
 		}
 
 		if (!dialog) {
-			dialog = new TextDialog(_vm, FONT_INTERFACE, _defaultPosition, _dialogWidth);
+			if (objectId == -1) {
+				dialog = new TextDialog(_vm, FONT_INTERFACE, _defaultPosition, _dialogWidth);
+			} else {
+				dialog = new PictureDialog(_vm, _defaultPosition, _dialogWidth, objectId);
+			}
 		}
 
 		if (centerFlag) {
@@ -158,8 +166,11 @@ bool DialogsNebular::show(int msgId) {
 	return result;
 }
 
-void DialogsNebular::showItem(int objectId, int messageId, int arg) {
-	show(messageId);
+void DialogsNebular::showItem(int objectId, int messageId, int speech) {
+	// MADS engine doesn't currently support speech
+	assert(!speech);
+
+	show(messageId, objectId);
 #if 0
 	Scene &scene = _vm->_game->_scene;
 	byte highPalette[8 * 3];
@@ -170,15 +181,6 @@ void DialogsNebular::showItem(int objectId, int messageId, int arg) {
 	greyScale[0] = greyScale[1] = greyScale[2] = 0xFFFF;
 	Common::String setName = Common::String::format("*OBJ%.3d.SS", objectId);
 
-	// Turn off cycling if active
-	bool cyclingActive = scene._cyclingActive;
-	scene._cyclingActive = false;
-
-	// Make a copy of the current screen surface
-	byte *savedSurface = new byte[MADS_SCREEN_WIDTH * MADS_SCREEN_HEIGHT];
-	Common::copy(_vm->_screen.getData(), _vm->_screen.getData() +
-		MADS_SCREEN_WIDTH * MADS_SCREEN_HEIGHT, savedSurface);
-	
 
 
 	delete[] savedSurface;
@@ -287,7 +289,7 @@ TextDialog(vm, FONT_INTERFACE, Common::Point(-1, -1), 32) {
 	wordWrap("\n");
 }
 
-bool CopyProtectionDialog::show() {
+void CopyProtectionDialog::show() {
 	draw();
 	_vm->_events->showCursor();
 
@@ -298,7 +300,6 @@ bool CopyProtectionDialog::show() {
 	}
 
 	_vm->_events->_pendingKeys.clear();
-	return true;
 }
 
 bool CopyProtectionDialog::getHogAnusEntry(HOGANUS &entry) {
@@ -331,6 +332,54 @@ bool CopyProtectionDialog::getHogAnusEntry(HOGANUS &entry) {
 
 /*------------------------------------------------------------------------*/
 
+PictureDialog::PictureDialog(MADSEngine *vm, const Common::Point &pos, 
+		int maxChars, int objectId) : 
+		TextDialog(vm, FONT_INTERFACE, pos, maxChars), _objectId(objectId) {
+	Scene &scene = _vm->_game->_scene;
+	Palette &palette = *_vm->_palette;
+
+	// Turn off cycling if active
+	_cyclingActive = scene._cyclingActive;
+	scene._cyclingActive = false;
+
+	// Save palette information
+	Common::copy(&palette._mainPalette[0], &palette._mainPalette[PALETTE_SIZE], &_palette[0]);
+	Common::copy(&palette._palFlags[0], &palette._palFlags[PALETTE_COUNT], &_palFlags[0]);
+	_rgbList.copy(palette._rgbList);
+
+	// Set up palette allocation
+	uint32 *palFlagP = &palette._palFlags[0];
+	for (int idx = 0; idx < PALETTE_COUNT; ++idx, ++palFlagP) {
+		*palFlagP = (idx < PALETTE_RESERVED_LOW_COUNT ||
+			idx >= (PALETTE_COUNT - PALETTE_RESERVED_HIGH_COUNT - 10)) ? 1 : 0;
+	}
+
+	// Reset the flag list
+	palette._rgbList.reset();
+}
+
+PictureDialog::~PictureDialog() {
+	Scene &scene = _vm->_game->_scene;
+	scene._cyclingActive = _cyclingActive;
+}
+
+void PictureDialog::show() {
+	setupPalette();
+
+	TextDialog::show();
+}
+
+void PictureDialog::setupPalette() {
+	Palette &palette = *_vm->_palette;
+	byte map[PALETTE_COUNT];
+
+	int numColors = PALETTE_COUNT - PALETTE_RESERVED_LOW_COUNT - PALETTE_RESERVED_HIGH_COUNT;
+	palette.fadeToGrey(palette._mainPalette, &map[PALETTE_RESERVED_LOW_COUNT],
+		PALETTE_RESERVED_LOW_COUNT, numColors, 248, 8, 1, 16);
+}
+
+/*------------------------------------------------------------------------*/
+
 ScreenDialog::DialogLine::DialogLine() {
 	_state = 0;
 	_textDisplayIndex = -1;
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index b5ee090..fd4d6e7 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -49,9 +49,9 @@ private:
 public:
 	virtual void showDialog();
 
-	virtual void showItem(int objectId, int msgId, int arg);
+	virtual void showItem(int objectId, int messageId, int speech = -1);
 
-	virtual bool show(int id);
+	virtual bool show(int messageId, int objectId = -1);
 };
 
 struct HOGANUS {
@@ -79,7 +79,27 @@ public:
 	/**
 	 * Show the dialog
 	 */
-	bool show();
+	virtual void show();
+};
+
+class PictureDialog : public TextDialog {
+private:
+	int _objectId;
+	bool _cyclingActive;
+	byte _palette[PALETTE_SIZE];
+	uint32 _palFlags[PALETTE_COUNT];
+	RGBList _rgbList;
+
+	/**
+	 * Sets up the palette and fades the screen to gray
+	 */
+	void setupPalette();
+public:
+	PictureDialog(MADSEngine *vm, const Common::Point &pos, int maxChars, int objectId);
+
+	virtual ~PictureDialog();
+
+	virtual void show();
 };
 
 enum DialogTextAlign { ALIGN_CENTER = -1, ALIGN_AT_CENTER = -2, ALIGN_RIGHT = -3 };
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 51de276..ad45562 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -69,7 +69,7 @@ static bool sortHelper(const PaletteUsage::UsageEntry &ue1, const PaletteUsage::
 void PaletteUsage::prioritize(Common::Array<RGB6> &palette) {
 	for (uint i = 0; i < _data->size(); ++i) {
 		RGB6 &palEntry = palette[(*_data)[i]._palIndex];
-		(*_data)[i]._sortValue = rgbMerge(palEntry);
+		(*_data)[i]._sortValue = _vm->_palette->rgbMerge(palEntry);
 	}
 	
 	Common::sort(_data->begin(), _data->end(), sortHelper);
@@ -237,12 +237,6 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 	return rgbIndex;
 }
 
-
-int PaletteUsage::rgbMerge(RGB6 &palEntry) {
-	return ((palEntry.r + 1) / 4 - 1) * 38 + ((palEntry.g + 1) / 4 - 1) * 76 + 
-		((palEntry.b + 1) / 4 - 1) * 14;
-}
-
 void PaletteUsage::transform(Common::Array<RGB6> &palette) {
 	if (!empty()) {
 		for (uint i = 0; i < _data->size(); ++i) {
@@ -336,6 +330,157 @@ int RGBList::scan() {
 	error("RGBList was full");
 }
 
+void RGBList::copy(RGBList &src) {
+	Common::copy(&src._data[0], &src._data[32], &_data[0]);
+}
+
+/*------------------------------------------------------------------------*/
+
+Fader::Fader() {
+	_colorFlags[0] = _colorFlags[1] = _colorFlags[2] = true;
+	_colorFlags[3] = false;
+	_colorValues[0] = _colorValues[1] = 0;
+	_colorValues[2] = _colorValues[3] = 0;
+}
+
+void Fader::fadeToGrey(byte palette[PALETTE_SIZE], byte paletteMap[PALETTE_COUNT],
+		int baseColor, int numColors, int baseGrey, int numGreys,
+		int tickDelay, int steps) {
+	GreyEntry map[PALETTE_COUNT];
+	int intensity;
+	byte palIndex[PALETTE_COUNT][3];
+	bool signs[PALETTE_COUNT][3];
+
+	mapToGreyRamp(palette, baseColor, numColors, baseGrey, numGreys, map);
+
+	for (int palCtr = baseColor; palCtr < (baseColor + numColors); ++palCtr) {
+		int index = palCtr - baseColor;
+		for (int colorCtr = 0; colorCtr < 3; ++colorCtr) {
+			if (_colorFlags[colorCtr]) {
+				int shiftSign = _colorValues[colorCtr];
+				if (shiftSign >= 0) {
+					intensity = map[index]._intensity << shiftSign;
+				} else {
+					intensity = map[index]._intensity >> ABS(shiftSign);
+				}
+			} else {
+				intensity = _colorValues[colorCtr];
+			}
+
+			int diff = intensity - palette[palCtr * 3 + colorCtr];
+			palIndex[palCtr][colorCtr] = (byte)ABS(diff);
+			signs[palCtr][colorCtr] = diff / ABS(diff);
+		}
+	}
+
+	// TODO: More here
+}
+
+static bool greyCompareFunc(const Fader::GreyTableEntry &g1, const Fader::GreyTableEntry &g2) {
+	return g1._list < g2._list;
+}
+
+void Fader::mapToGreyRamp(byte palette[PALETTE_SIZE], int baseColor, int numColors,
+		int baseGrey, int numGreys, GreyEntry *map) {
+	GreyTableEntry greyList[PALETTE_COUNT];
+	byte greyTable[64];
+	byte greyIntensity[64];
+	int intensity, shiftSign;
+
+	getGreyValues(palette, greyList, baseColor, numColors);
+	greyPopularity(greyList, greyTable, numColors);
+	
+	for (int idx = 0; idx < numColors; ++idx) {
+		greyList[idx]._mapping = idx;
+		Common::fill(&map[idx]._accum[0], &map[idx]._accum[3], 0);
+	}
+
+	for (int idx = 0; idx < PALETTE_COUNT; ++idx) {
+		map[idx]._mapColor = (byte)idx;
+	}
+	
+	// Sort the mapping list
+	Common::sort(&greyList[0], &greyList[numColors], greyCompareFunc);
+
+	// Initialise state variables
+	int greySum = 0;
+	int greyScan = 0;
+	int greyMark = 0;
+	int greyColors = 0;
+	int greyAccum = 0;
+	int firstColor = 0;
+
+	for (int greyCtr = 0; greyCtr < 64; greyCtr++) {
+		for (int idx = 0; idx < greyTable[greyCtr]; idx++) {
+			greySum += greyList[greyScan++]._list;
+			++greyColors;
+
+			greyAccum += numGreys;
+			while (greyAccum >= numColors) {
+				greyAccum -= numColors;
+				if (greyColors > 0) {
+					greyIntensity[greyMark] = (byte)(greySum / greyColors);
+				}
+
+				for (int rescan = firstColor; rescan < greyScan; ++rescan) {
+					map[greyList[rescan]._mapping]._intensity = greyIntensity[greyMark];
+					map[greyList[rescan]._mapping]._mapColor = (byte)(greyMark + baseGrey);
+				}
+
+				firstColor = greyScan;
+				greySum = 0;
+				greyColors = 0;
+				++greyMark;
+			}
+		}
+	}
+
+	// Process palette with intensities
+	byte *palP = &palette[baseGrey * 3];
+	for (int greys = 0; greys < numGreys; ++greys) {
+		for (int color = 0; color < 3; ++color) {
+			if (_colorFlags[color]) {
+				shiftSign = (byte)_colorValues[color];
+				if (shiftSign >= 0) {
+					intensity = greyIntensity[greys] << shiftSign;
+				} else {
+					intensity = greyIntensity[greys] >> abs(shiftSign);
+				}
+			} else {
+				intensity = _colorValues[color];
+			}
+			*palP++ = VGA_COLOR_TRANS(intensity);
+		}
+	}
+}
+
+void Fader::getGreyValues(const byte palette[PALETTE_SIZE], 
+		GreyTableEntry greyList[PALETTE_COUNT], int baseColor, int numColors) {
+	const byte *palP = &palette[baseColor * 3];
+	GreyTableEntry *destP = greyList;
+
+	for (int i = 0; i < numColors; ++i, palP += 3, ++destP) {
+		int v = rgbMerge(palP[0], palP[1], palP[2]);
+		destP->_list = v >> 7;
+	}
+}
+
+void Fader::greyPopularity(const GreyTableEntry greyList[PALETTE_COUNT], 
+		byte greyTable[64], int numColors) {
+	Common::fill(&greyTable[0], &greyTable[64], 0);
+	for (int i = 0; i < 64; ++i) {
+		++greyTable[greyList[i]._list];
+	}
+}
+
+int Fader::rgbMerge(RGB6 &palEntry) {
+	return rgbMerge(palEntry.r, palEntry.g, palEntry.b);
+}
+
+int Fader::rgbMerge(byte r, byte g, byte b) {
+	return ((r + 1) / 4 - 1) * 38 + ((g + 1) / 4 - 1) * 76 + ((b + 1) / 4 - 1) * 14;
+}
+
 /*------------------------------------------------------------------------*/
 
 Palette::Palette(MADSEngine *vm) : _vm(vm), _paletteUsage(vm) {
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index d1c7c1d..883f7d7 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -32,6 +32,12 @@ class MADSEngine;
 
 #define PALETTE_USAGE_COUNT 4
 
+#define PALETTE_RESERVED_LOW_COUNT 18
+#define PALETTE_RESERVED_HIGH_COUNT 10
+
+#define PALETTE_COUNT 256
+#define PALETTE_SIZE (256 * 3)
+
 /**
  * Palette mapping options
  */
@@ -62,6 +68,9 @@ struct RGB6 {
 	byte _u2;
 	byte _flags;
 
+	/**
+	 * Load an entry from a stream
+	 */
 	void load(Common::SeekableReadStream *f);
 };
 
@@ -83,8 +92,6 @@ private:
 	MADSEngine *_vm;
 	Common::Array<UsageEntry> *_data;
 
-	int rgbMerge(RGB6 &palEntry);
-
 	int getGamePalFreeIndex(int *palIndex);
 
 	int rgbFactor(byte *palEntry, RGB6 &pal6);
@@ -142,6 +149,11 @@ public:
 	void reset();
 
 	/**
+	 * Copies the data from another instance
+	 */
+	void copy(RGBList &src);
+
+	/**
 	 * Scans for a free slot
 	 */
 	int scan();
@@ -149,10 +161,52 @@ public:
 	bool &operator[](int idx) { return _data[idx]; }
 };
 
-#define PALETTE_COUNT 256
-#define PALETTE_SIZE (256 * 3)
+class Fader {
+public:
+	struct GreyEntry {
+		byte _intensity;
+		byte _mapColor;
+		uint16 _accum[3];
+	};
+
+	struct GreyTableEntry {
+		int _list;
+		int _mapping;
+	};
+private:
+	void mapToGreyRamp(byte palette[PALETTE_SIZE], int baseColor, int numColors,
+		int baseGrey, int numGreys, GreyEntry *map);
+
+	void getGreyValues(const byte palette[PALETTE_SIZE], GreyTableEntry greyList[PALETTE_COUNT],
+		int baseColor, int numColors);
+
+	/**
+	 * Given a grey value list containing grey shades (0-63), creates a 64 byte
+	 * grey table containing the number of grey values for each intensity 
+	 */
+	void greyPopularity(const GreyTableEntry greyList[PALETTE_COUNT], byte greyTable[64], int numColors);
+public:
+	bool _colorFlags[4];
+	int _colorValues[4];
+public:
+	/**
+	 * Constructor
+	 */
+	Fader();
+
+	int rgbMerge(byte r, byte g, byte b);
+
+	int rgbMerge(RGB6 &palEntry);
+
+	/**
+	* Fades the given palette to greyscale
+	*/
+	void fadeToGrey(byte palette[PALETTE_SIZE], byte paletteMap[PALETTE_COUNT],
+		int baseColor, int numColors, int baseGrey, int numGreys,
+		int tickDelay, int steps);
+};
 
-class Palette {
+class Palette: public Fader {
 private:
 	/**
 	 * Initialises the first 16 palette indexes with the equivalent


Commit: 36a1b66c71543749cdf9276bb18f2e85b98a46e9
    https://github.com/scummvm/scummvm/commit/36a1b66c71543749cdf9276bb18f2e85b98a46e9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-04T15:05:31-04:00

Commit Message:
MADS: Fix for scene loading in teleporter scenes

Changed paths:
    engines/mads/assets.cpp
    engines/mads/assets.h
    engines/mads/scene_data.cpp
    engines/mads/sprites.cpp



diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index 46a6d3c..bf9647d 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -205,17 +205,6 @@ MSprite *SpriteAsset::getFrame(int frameIndex) {
 	}
 }
 
-
-void SpriteAsset::drawScaled(int frameNumber, MSurface &depthSurface, MSurface &destSurface,
-		int scale, int depth, const Common::Point &pos) {
-	error("TODO: SpriteAsset::drawScaled - map to frame methods");
-}
-
-void SpriteAsset::depthDraw(MSurface *surface, MSurface *depthSurface, int frameNumber,
-		const Common::Point &pt, int depth) {
-	error("TODO: map depthDraw to frame draw methods");
-}
-
 /*------------------------------------------------------------------------*/
 
 SpriteSetCharInfo::SpriteSetCharInfo(Common::SeekableReadStream *s) {
diff --git a/engines/mads/assets.h b/engines/mads/assets.h
index dfe6db0..874eee7 100644
--- a/engines/mads/assets.h
+++ b/engines/mads/assets.h
@@ -105,11 +105,6 @@ public:
 	byte *getPalette() { return _palette; }
 	int getColorCount() { return _colorCount; }
 	bool isBackground() const { return _isBackground; }
-
-	void drawScaled(int frameNumber, MSurface &depthSurface, MSurface &destSurface,
-		int scale, int depth, const Common::Point &pos);
-	void depthDraw(MSurface *surface, MSurface *depthSurface, int frameNumber, 
-		const Common::Point &pt, int depth);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 646106e..65220ce 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -226,17 +226,15 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 	Common::Array<SpriteAsset *> spriteSets;
 	Common::Array<int> usageList;
 
-	if (flags & 1) {
-		for (uint i = 0; i < setNames.size(); ++i) {
-			Common::String setResName;
-			if (sceneFlag || resName.hasPrefix("*"))
-				setResName += "*";
-			setResName += setNames[i];
-
-			SpriteAsset *sprites = new SpriteAsset(_vm, setResName, flags);
-			spriteSets.push_back(sprites);
-			usageList.push_back(sprites->_usageIndex); 
-		}
+	for (uint i = 0; i < setNames.size(); ++i) {
+		Common::String setResName;
+		if (sceneFlag || resName.hasPrefix("*"))
+			setResName += "*";
+		setResName += setNames[i];
+
+		SpriteAsset *sprites = new SpriteAsset(_vm, setResName, flags);
+		spriteSets.push_back(sprites);
+		usageList.push_back(sprites->_usageIndex); 
 	}
 
 	_vm->_palette->_paletteUsage.updateUsage(usageList, _usageIndex);
@@ -246,8 +244,9 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 		SpriteAsset *asset = spriteSets[si._spriteSetIndex];
 		assert(asset && _depthStyle != 2);
 
-		asset->drawScaled(asset->getCount(), depthSurface, bgSurface,
-			si._scale, si._depth, si._position);
+		MSprite *spr = asset->getFrame(asset->getCount() - 1);
+		bgSurface.copyFrom(spr, si._position, si._depth, &depthSurface, si._scale, 
+			spr->getTransparencyIndex());
 	}
 
 	// Free the sprite sets
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 7bd8407..432a0e1 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -258,8 +258,8 @@ void SpriteSlots::drawBackground() {
 				if (spriteSlot._depth <= 1) {
 					frame->copyTo(&scene._backgroundSurface, frame->getTransparencyIndex());
 				} else if (scene._depthStyle == 0) {
-					asset->depthDraw(&scene._backgroundSurface, &scene._depthSurface, spriteSlot._frameNumber,
-						pt, spriteSlot._depth);
+					scene._backgroundSurface.copyFrom(frame, pt, spriteSlot._depth, &scene._backgroundSurface,
+						100, frame->getTransparencyIndex());
 				} else {
 					error("Unsupported depth style");
 				}


Commit: bc774144aaa170e20dc9e328eff47f719ba05214
    https://github.com/scummvm/scummvm/commit/bc774144aaa170e20dc9e328eff47f719ba05214
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-04T21:46:36+02:00

Commit Message:
MADS: Implement scene 213

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index da568ce..795477d 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -95,7 +95,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene211(vm);
 	case 212:
 		return new Scene212(vm);
-
+	case 213:
+		return new Scene213(vm);
 	case 214:
 		return new Scene214(vm);
 	case 215:
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 44fac5a..9b36dbb 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -4588,6 +4588,66 @@ void Scene212::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene213::setup() {
+	_game._player._spritesPrefix = "";
+
+	// The original is calling Scene2xx::setAAName()
+	_game._aaName = Resources::formatAAName(2);
+}
+
+void Scene213::enter() {
+	if (_globals[kMeteorologistWatch] != 0)
+		_handSpriteId = _scene->_sprites.addSprites("*METHAND", false);
+	else if (_globals[kSexOfRex] == REX_MALE)
+		_handSpriteId = _scene->_sprites.addSprites("*REXHAND", false);
+	else
+		_handSpriteId = _scene->_sprites.addSprites("*ROXHAND", false);
+
+	teleporterEnter();
+
+	// The original is calling Scene2xx::sceneEntrySound()
+		if (_vm->_musicFlag) {
+			if (_globals[kMeteorologistWatch] == 0)
+				_vm->_sound->command(1);
+			else
+				_vm->_sound->command(9);
+		} else
+			_vm->_sound->command(2);
+}
+
+void Scene213::step() {
+	teleporterStep();
+}
+
+void Scene213::actions() {
+	if (teleporterActions()) {
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x59))
+		_vm->_dialogs->show(21301);
+	else if (_action.isAction(VERB_LOOK, 0xC4) || _action.isAction (0xB7, 0xC4))
+		_vm->_dialogs->show(21302);
+	else if (_action.isAction(VERB_LOOK, 0x1CC))
+		_vm->_dialogs->show(21303);
+	else if (_action.isAction(VERB_LOOK, 0x181) || _action.isAction(0x103, 0x181))
+		_vm->_dialogs->show(21304);
+	else if (_action.isAction(VERB_LOOK, 0x1CF))
+		_vm->_dialogs->show(21305);
+	else if (_action.isAction(VERB_LOOK, 0x1D0) || _action.isAction(VERB_LOOK, 0x1D1)
+	 || _action.isAction(VERB_LOOK, 0x1D2) || _action.isAction(VERB_LOOK, 0x1D3)
+	 || _action.isAction(VERB_LOOK, 0x1D4) || _action.isAction(VERB_LOOK, 0x1D5)
+	 || _action.isAction(VERB_LOOK, 0x1D6) || _action.isAction(VERB_LOOK, 0x1D7)
+	 || _action.isAction(VERB_LOOK, 0x1D8) || _action.isAction(VERB_LOOK, 0x1D9)
+	 || _action.isAction(VERB_LOOK, 0x1DB) || _action.isAction(VERB_LOOK, 0x7A)
+	 || _action.isAction(VERB_LOOK, 0x1DA))
+		_vm->_dialogs->show(21306);
+	else
+		return;
+
+	_action._inProgress = false;
+}
 
 /*------------------------------------------------------------------------*/
 
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 886f7cf..2f3512a 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -257,6 +257,17 @@ public:
 	virtual void actions();
 };
 
+class Scene213: public SceneTeleporter {
+public:
+	Scene213(MADSEngine *vm) : SceneTeleporter(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+};
+
 class Scene214: public Scene2xx {
 private:
 	uint32 _devilTime;


Commit: e46e25b1028457f760a0694f937c72135c216a0e
    https://github.com/scummvm/scummvm/commit/e46e25b1028457f760a0694f937c72135c216a0e
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-04T22:40:33+02:00

Commit Message:
MADS: Remove optional parameters in scene213

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 9b36dbb..c4f5fe3 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -4597,11 +4597,11 @@ void Scene213::setup() {
 
 void Scene213::enter() {
 	if (_globals[kMeteorologistWatch] != 0)
-		_handSpriteId = _scene->_sprites.addSprites("*METHAND", false);
+		_handSpriteId = _scene->_sprites.addSprites("*METHAND");
 	else if (_globals[kSexOfRex] == REX_MALE)
-		_handSpriteId = _scene->_sprites.addSprites("*REXHAND", false);
+		_handSpriteId = _scene->_sprites.addSprites("*REXHAND");
 	else
-		_handSpriteId = _scene->_sprites.addSprites("*ROXHAND", false);
+		_handSpriteId = _scene->_sprites.addSprites("*ROXHAND");
 
 	teleporterEnter();
 


Commit: 18ffdf9fd0dd8755b576192d087936512d66f6d1
    https://github.com/scummvm/scummvm/commit/18ffdf9fd0dd8755b576192d087936512d66f6d1
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-04T22:41:00+02:00

Commit Message:
MADS: Implement scene 322

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 795477d..95f7cab 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -135,6 +135,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene320(vm);
 	case 321:
 		return new Scene321(vm);
+	case 322:
+		return new Scene322(vm);
 	case 351:
 		return new Scene351(vm);
 	case 352:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index c699907..b8d07d9 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -3680,6 +3680,67 @@ void Scene321::step() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene322::setup() {
+	_game._player._spritesPrefix = "";
+	// The original is calling scene3xx_setAAName()
+	_game._aaName = Resources::formatAAName(4);
+}
+
+void Scene322::enter() {
+	if (_globals[kSexOfRex] == REX_MALE)
+		_handSpriteId = _scene->_sprites.addSprites("*REXHAND");
+	else
+		_handSpriteId = _scene->_sprites.addSprites("*ROXHAND");
+
+	teleporterEnter();
+
+	// The original is using scene3xx_sceneEntrySound()
+	if (!_vm->_musicFlag)
+		_vm->_sound->command(2);
+	else
+		_vm->_sound->command(10);
+}
+
+void Scene322::step() {
+	teleporterStep();
+}
+
+void Scene322::actions() {
+	if (_action._lookFlag) {
+		_vm->_dialogs->show(32214);
+		_action._inProgress = false;
+		return;
+	}
+
+	if (teleporterActions()) {
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x181) || _action.isAction(0x103, 0x181))
+		_vm->_dialogs->show(32210);
+	else if (_action.isAction(VERB_LOOK, 0xC4))
+		_vm->_dialogs->show(32211);
+	else if (_action.isAction(VERB_LOOK, 0x1CC))
+		_vm->_dialogs->show(32212);
+	else if (_action.isAction(VERB_LOOK, 0x1D0) || _action.isAction(VERB_LOOK, 0x1D1)
+	 || _action.isAction(VERB_LOOK, 0x1D2) || _action.isAction(VERB_LOOK, 0x1D3)
+	 || _action.isAction(VERB_LOOK, 0x1D4) || _action.isAction(VERB_LOOK, 0x1D5)
+	 || _action.isAction(VERB_LOOK, 0x1D6) || _action.isAction(VERB_LOOK, 0x1D7)
+	 || _action.isAction(VERB_LOOK, 0x1D8) || _action.isAction(VERB_LOOK, 0x1D9)
+	 || _action.isAction(VERB_LOOK, 0x1DB) || _action.isAction(VERB_LOOK, 0x7A)
+	 || _action.isAction(VERB_LOOK, 0x1DA))
+		_vm->_dialogs->show(32213);
+	else if (_action.isAction(VERB_LOOK, 0x1CF))
+		_vm->_dialogs->show(32214);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene351::setup() {
 	if (_scene->_currentSceneId == 391)
 		_globals[kSexOfRex] = REX_MALE;
@@ -4626,9 +4687,9 @@ void Scene359::enter() {
 	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(Resources::formatName(307, 'X', 0, EXT_SS, ""));
 
 	if (_globals[kSexOfRex] == REX_MALE)
-		_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RXMBD_2", false);
+		_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RXMBD_2");
 	else
-		_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*ROXBD_2", false);
+		_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*ROXBD_2");
 
 	_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
 	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(127, 78));
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index f931dae..d40b363 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -321,6 +321,16 @@ public:
 	virtual void step();
 };
 
+class Scene322: public SceneTeleporter {
+public:
+	Scene322(MADSEngine *vm) : SceneTeleporter(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void actions();
+};
+
 class Scene351: public Scene3xx {
 public:
 	Scene351(MADSEngine *vm) : Scene3xx(vm) {}


Commit: 5d1c0ef9189575552807d7939d3d39caf00be0d7
    https://github.com/scummvm/scummvm/commit/5d1c0ef9189575552807d7939d3d39caf00be0d7
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-04T23:19:26+02:00

Commit Message:
MADS: Implement scene 5xx ancestor

Changed paths:
  A engines/mads/nebular/nebular_scenes5.cpp
  A engines/mads/nebular/nebular_scenes5.h
    engines/mads/module.mk



diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 5fe0c90..04739b0 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -14,6 +14,7 @@ MODULE_OBJS := \
 	nebular/nebular_scenes2.o \
 	nebular/nebular_scenes3.o \
 	nebular/nebular_scenes4.o \
+	nebular/nebular_scenes5.o \
 	nebular/nebular_scenes8.o \
 	action.o \
 	animation.o \
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
new file mode 100644
index 0000000..b6684c8
--- /dev/null
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -0,0 +1,96 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/scene.h"
+#include "mads/nebular/nebular_scenes.h"
+#include "mads/nebular/nebular_scenes5.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+void Scene5xx::setAAName() {
+	_game._aaName = Resources::formatAAName(5);
+}
+
+void Scene5xx::setPlayerSpritesPrefix() {
+	_vm->_sound->command(5);
+
+	Common::String oldName = _game._player._spritesPrefix;
+
+	if ((_scene->_nextSceneId == 502) || (_scene->_nextSceneId == 504) || (_scene->_nextSceneId == 505) || (_scene->_nextSceneId == 515))
+		_game._player._spritesPrefix = "";
+	else if (_globals[kSexOfRex] == REX_MALE)
+		_game._player._spritesPrefix = "RXM";
+	else if ((_scene->_nextSceneId == 501) || (_scene->_nextSceneId == 503) || (_scene->_nextSceneId == 551))
+		_game._player._spritesPrefix = "ROX";
+
+	_game._player._scalingVelocity = true;
+
+	if ((_scene->_nextSceneId == 512) || (_scene->_nextSceneId == 507))
+		_game._player._scalingVelocity = false;
+
+	if (oldName != _game._player._spritesPrefix)
+		_game._player._spritesChanged = true;
+
+	_vm->_palette->setEntry(16, 10, 63, 63);
+	_vm->_palette->setEntry(17, 10, 45, 45);
+}
+
+void Scene5xx::sceneEntrySound() {
+	if (!_vm->_musicFlag) {
+		_vm->_sound->command(2);
+		return;
+	}
+
+	switch (_scene->_nextSceneId) {
+	case 501:
+	case 502:
+	case 504:
+	case 505:
+	case 506:
+	case 507:
+	case 508:
+	case 511:
+	case 512:
+	case 513:
+	case 515:
+	case 551:
+		if (_scene->_priorSceneId == 503)
+			_vm->_sound->command(38);
+		else
+			_vm->_sound->command(29);
+		break;
+	case 503:
+		_vm->_sound->command(41);
+		break;
+	default:
+		break;
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+} // End of namespace Nebular
+} // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
new file mode 100644
index 0000000..4efbc4a
--- /dev/null
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_NEBULAR_SCENES5_H
+#define MADS_NEBULAR_SCENES5_H
+
+#include "common/scummsys.h"
+#include "mads/game.h"
+#include "mads/scene.h"
+#include "mads/nebular/nebular_scenes.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+class Scene5xx : public NebularScene {
+protected:
+	/**
+	 * Plays an appropriate sound when entering a scene
+	 */
+	void setAAName();
+
+	/**
+	 * Updates the prefix used for getting player sprites for the scene
+	 */
+	void setPlayerSpritesPrefix();
+
+	void sceneEntrySound();
+
+public:
+	Scene5xx(MADSEngine *vm) : NebularScene(vm) {}
+};
+
+} // End of namespace Nebular
+} // End of namespace MADS
+
+#endif /* MADS_NEBULAR_SCENES5_H */


Commit: 622f6eb7275912022c161ff22d74a5f4c28b77b3
    https://github.com/scummvm/scummvm/commit/622f6eb7275912022c161ff22d74a5f4c28b77b3
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-04T23:43:36+02:00

Commit Message:
MADS: Implement scene 502

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes5.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 95f7cab..0574ba9 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -193,9 +193,9 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new Scene413(vm);
 
 	// Scene group #5
-	case 501:
-		// TODO
 	case 502:
+		return new Scene502(vm);
+	case 501:
 		// TODO
 	case 503:
 		// TODO
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index b6684c8..eb1aa42 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -92,5 +92,62 @@ void Scene5xx::sceneEntrySound() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene502::setup() {
+	_game._player._spritesPrefix = "";
+	// The original is using Scene5xx_setAAName()
+	_game._aaName = Resources::formatAAName(5);
+}
+
+void Scene502::enter() {
+	if (_globals[kSexOfRex] == REX_MALE)
+		_handSpriteId = _scene->_sprites.addSprites("*REXHAND");
+	else
+		_handSpriteId = _scene->_sprites.addSprites("*ROXHAND");
+
+	teleporterEnter();
+
+	// The original uses scene5xx_sceneEntrySound
+	if (!_vm->_musicFlag)
+		_vm->_sound->command(2);
+	else if (_scene->_priorSceneId == 503)
+		_vm->_sound->command(38);
+	else
+		_vm->_sound->command(29);
+}
+
+void Scene502::step() {
+	teleporterStep();
+}
+
+void Scene502::actions() {
+	if (teleporterActions()) {
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x181) || _action.isAction(0x103, 0x181))
+		_vm->_dialogs->show(50210);
+	else if (_action.isAction(VERB_LOOK, 0xC4))
+		_vm->_dialogs->show(50211);
+	else if (_action.isAction(VERB_LOOK, 0x1CC))
+		_vm->_dialogs->show(50212);
+	else if (_action.isAction(VERB_LOOK, 0x1D0) || _action.isAction(VERB_LOOK, 0x1D1)
+	  || _action.isAction(VERB_LOOK, 0x1D2) || _action.isAction(VERB_LOOK, 0x1D3)
+	  || _action.isAction(VERB_LOOK, 0x1D4) || _action.isAction(VERB_LOOK, 0x1D5)
+	  || _action.isAction(VERB_LOOK, 0x1D6) || _action.isAction(VERB_LOOK, 0x1D7)
+	  || _action.isAction(VERB_LOOK, 0x1D8) || _action.isAction(VERB_LOOK, 0x1D9)
+	  || _action.isAction(VERB_LOOK, 0x1DB) || _action.isAction(VERB_LOOK, 0x7A)
+	  || _action.isAction(VERB_LOOK, 0x1DA))
+		_vm->_dialogs->show(50213);
+	else if (_action.isAction(VERB_LOOK, 0x1CF) || _action._lookFlag)
+		_vm->_dialogs->show(50214);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
index 4efbc4a..2748f24 100644
--- a/engines/mads/nebular/nebular_scenes5.h
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -50,6 +50,18 @@ public:
 	Scene5xx(MADSEngine *vm) : NebularScene(vm) {}
 };
 
+class Scene502: public SceneTeleporter {
+public:
+	Scene502(MADSEngine *vm) : SceneTeleporter(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: c892d8c725ee20fa3aef4aab29cc89da734bee23
    https://github.com/scummvm/scummvm/commit/c892d8c725ee20fa3aef4aab29cc89da734bee23
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-04T18:42:34-04:00

Commit Message:
MADS: Implemented remainder of fadeToGrey

Changed paths:
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 9dd20ca..8ef6400 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -359,8 +359,15 @@ PictureDialog::PictureDialog(MADSEngine *vm, const Common::Point &pos,
 }
 
 PictureDialog::~PictureDialog() {
+	// Restore cycling flag
 	Scene &scene = _vm->_game->_scene;
+	Palette &palette = *_vm->_palette;
 	scene._cyclingActive = _cyclingActive;
+
+	// Restore palette information
+	Common::copy(&_palette[0], &_palette[PALETTE_SIZE], &palette._mainPalette[0]);
+	Common::copy(&_palFlags[0], &_palFlags[PALETTE_COUNT], &palette._palFlags[0]);
+	palette._rgbList.copy(_rgbList);
 }
 
 void PictureDialog::show() {
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index ad45562..f8430e8 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -336,14 +336,23 @@ void RGBList::copy(RGBList &src) {
 
 /*------------------------------------------------------------------------*/
 
-Fader::Fader() {
+Fader::Fader(MADSEngine *vm): _vm(vm) {
 	_colorFlags[0] = _colorFlags[1] = _colorFlags[2] = true;
 	_colorFlags[3] = false;
 	_colorValues[0] = _colorValues[1] = 0;
 	_colorValues[2] = _colorValues[3] = 0;
 }
 
-void Fader::fadeToGrey(byte palette[PALETTE_SIZE], byte paletteMap[PALETTE_COUNT],
+
+void Fader::setPalette(const byte *colors, uint start, uint num) {
+	g_system->getPaletteManager()->setPalette(colors, start, num);
+}
+
+void Fader::grabPalette(byte *colors, uint start, uint num) {
+	g_system->getPaletteManager()->grabPalette(colors, start, num);
+}
+
+void Fader::fadeToGrey(byte palette[PALETTE_SIZE], byte *paletteMap,
 		int baseColor, int numColors, int baseGrey, int numGreys,
 		int tickDelay, int steps) {
 	GreyEntry map[PALETTE_COUNT];
@@ -373,7 +382,30 @@ void Fader::fadeToGrey(byte palette[PALETTE_SIZE], byte paletteMap[PALETTE_COUNT
 		}
 	}
 
-	// TODO: More here
+	for (int stepCtr = 0; stepCtr < steps; ++stepCtr) {
+		for (int palCtr = baseColor; palCtr < (baseColor + numColors); ++palCtr) {
+			int index = palCtr - baseColor;
+			for (int colorCtr = 0; colorCtr < 3; ++colorCtr) {
+				map[index]._accum[colorCtr] += palIndex[palCtr][colorCtr];
+				/* map[index].accum[color] += pal_color(temp_pal, palCtr, color); */
+				while (map[index]._accum[colorCtr] >= steps) {
+					map[index]._accum[colorCtr] -= steps;
+					palette[palCtr * 3 + colorCtr] = signs[palCtr][colorCtr];
+				}
+			}
+		}
+
+		setFullPalette(palette);
+
+		// TODO: Adjust waiting
+		_vm->_events->waitForNextFrame();
+	}
+
+	if (paletteMap != nullptr) {
+		for (int palCtr = 0; palCtr < numColors; palCtr++) {
+			paletteMap[palCtr] = map[palCtr]._mapColor;
+		}
+	}
 }
 
 static bool greyCompareFunc(const Fader::GreyTableEntry &g1, const Fader::GreyTableEntry &g2) {
@@ -483,9 +515,7 @@ int Fader::rgbMerge(byte r, byte g, byte b) {
 
 /*------------------------------------------------------------------------*/
 
-Palette::Palette(MADSEngine *vm) : _vm(vm), _paletteUsage(vm) {
-	reset();
-
+Palette::Palette(MADSEngine *vm) : Fader(vm), _paletteUsage(vm) {
 	_lockFl = false;
 	_lowRange = 0;
 	_highRange = 0;
@@ -493,11 +523,6 @@ Palette::Palette(MADSEngine *vm) : _vm(vm), _paletteUsage(vm) {
 	Common::fill(&_palFlags[0], &_palFlags[PALETTE_COUNT], 0);
 }
 
-void Palette::setPalette(const byte *colors, uint start, uint num) {
-	g_system->getPaletteManager()->setPalette(colors, start, num);
-	reset();
-}
-
 void Palette::setEntry(byte palIndex, byte r, byte g, byte b) {
 	_mainPalette[palIndex * 3] = VGA_COLOR_TRANS(r);
 	_mainPalette[palIndex * 3 + 1] = VGA_COLOR_TRANS(g);
@@ -506,12 +531,6 @@ void Palette::setEntry(byte palIndex, byte r, byte g, byte b) {
 	setPalette((const byte *)&_mainPalette[palIndex * 3], palIndex, 1);
 }
 
-
-void Palette::grabPalette(byte *colors, uint start, uint num) {
-	g_system->getPaletteManager()->grabPalette(colors, start, num);
-	reset();
-}
-
 uint8 Palette::palIndexFromRgb(byte r, byte g, byte b, byte *paletteData) {
 	byte index = 0;
 	int32 minDist = 0x7fffffff;
@@ -537,9 +556,6 @@ uint8 Palette::palIndexFromRgb(byte r, byte g, byte b, byte *paletteData) {
 	return (uint8)index;
 }
 
-void Palette::reset() {
-}
-
 void Palette::setGradient(byte *palette, int start, int count, int rgbValue1, int rgbValue2) {
 	int rgbCtr = 0;
 	int rgbCurrent = rgbValue2;
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 883f7d7..1beadd4 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -185,6 +185,8 @@ private:
 	 * grey table containing the number of grey values for each intensity 
 	 */
 	void greyPopularity(const GreyTableEntry greyList[PALETTE_COUNT], byte greyTable[64], int numColors);
+protected:
+	MADSEngine *_vm;
 public:
 	bool _colorFlags[4];
 	int _colorValues[4];
@@ -192,7 +194,31 @@ public:
 	/**
 	 * Constructor
 	 */
-	Fader();
+	Fader(MADSEngine *vm);
+
+	/**
+	* Sets a new palette
+	*/
+	void setPalette(const byte *colors, uint start, uint num);
+
+	/**
+	* Returns a subset of the currently loaded palette
+	*/
+	void grabPalette(byte *colors, uint start, uint num);
+
+	/**
+	* Gets the entire palette at once
+	*/
+	void getFullPalette(byte palette[PALETTE_SIZE]) {
+		grabPalette(&palette[0], 0, PALETTE_COUNT);
+	}
+
+	/**
+	* Sets the entire palette at once
+	*/
+	void setFullPalette(byte palette[PALETTE_SIZE]) {
+		setPalette(&palette[0], 0, PALETTE_COUNT);
+	}
 
 	int rgbMerge(byte r, byte g, byte b);
 
@@ -201,7 +227,7 @@ public:
 	/**
 	* Fades the given palette to greyscale
 	*/
-	void fadeToGrey(byte palette[PALETTE_SIZE], byte paletteMap[PALETTE_COUNT],
+	void fadeToGrey(byte palette[PALETTE_SIZE], byte *paletteMap,
 		int baseColor, int numColors, int baseGrey, int numGreys,
 		int tickDelay, int steps);
 };
@@ -213,10 +239,6 @@ private:
 	 * standard VGA palette
 	 */
 	void initVGAPalette(byte *palette);
-protected:
-	MADSEngine *_vm;
-
-	void reset();
 public:
 	byte _mainPalette[PALETTE_SIZE];
 	byte _cyclingPalette[PALETTE_SIZE];
@@ -238,35 +260,11 @@ public:
 	virtual ~Palette() {}
 
 	/**
-	 * Sets a new palette
-	 */
-	void setPalette(const byte *colors, uint start, uint num);
-
-	/**
-	 * Set a palette entry
-	 */
+	* Set a palette entry
+	*/
 	void setEntry(byte palIndex, byte r, byte g, byte b);
 
 	/**
-	 * Returns a subset of the currently loaded palette
-	 */
-	void grabPalette(byte *colors, uint start, uint num);
-	
-	/**
-	 * Gets the entire palette at once
-	 */
-	void getFullPalette(byte palette[PALETTE_SIZE]) {
-		grabPalette(&palette[0], 0, PALETTE_COUNT);
-	}
-
-	/**
-	 * Sets the entire palette at once
-	 */
-	void setFullPalette(byte palette[PALETTE_SIZE]) {
-		setPalette(&palette[0], 0, PALETTE_COUNT);
-	}
-
-	/**
 	 * Returns the palette index in the palette that most closely matches the
 	 * specified RGB pair
 	 */


Commit: 24b79dc5f1486e4cb208b95a8bc18f31ab50de4c
    https://github.com/scummvm/scummvm/commit/24b79dc5f1486e4cb208b95a8bc18f31ab50de4c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-04T18:42:45-04:00

Commit Message:
MADS: Fix gcc warnings

Changed paths:
    engines/mads/dragonsphere/dragonsphere_scenes.h
    engines/mads/dragonsphere/game_dragonsphere.h
    engines/mads/globals.h



diff --git a/engines/mads/dragonsphere/dragonsphere_scenes.h b/engines/mads/dragonsphere/dragonsphere_scenes.h
index 596a59e..cf42dab 100644
--- a/engines/mads/dragonsphere/dragonsphere_scenes.h
+++ b/engines/mads/dragonsphere/dragonsphere_scenes.h
@@ -35,7 +35,7 @@ namespace MADS {
 namespace Dragonsphere {
 
 enum Noun {
-	NOUN_LOOK_AT		= 0x0D1,
+	NOUN_LOOK_AT		= 0x0D1
 	// TODO
 };
 
diff --git a/engines/mads/dragonsphere/game_dragonsphere.h b/engines/mads/dragonsphere/game_dragonsphere.h
index dd96146..2bfcde1 100644
--- a/engines/mads/dragonsphere/game_dragonsphere.h
+++ b/engines/mads/dragonsphere/game_dragonsphere.h
@@ -43,6 +43,7 @@ enum InventoryObject { OBJ_NONE = -1
 class DragonsphereGlobals: public Globals {
 public:
 	DragonsphereGlobals() {}
+	virtual ~DragonsphereGlobals() {}
 };
 
 class GameDragonsphere: public Game {
diff --git a/engines/mads/globals.h b/engines/mads/globals.h
index e44e97f..92e9d96 100644
--- a/engines/mads/globals.h
+++ b/engines/mads/globals.h
@@ -35,6 +35,8 @@ protected:
 public:
 	Globals() {}
 
+	virtual ~Globals() {}
+
 	/**
 	* Square brackets operator for accessing flags
 	*/


Commit: 8ebb16e98a6bd23849d2f4fe7df57ac89b6b2cb0
    https://github.com/scummvm/scummvm/commit/8ebb16e98a6bd23849d2f4fe7df57ac89b6b2cb0
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-04T18:46:18-04:00

Commit Message:
MADS: Further gcc compilation fixes

Changed paths:
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes5.h
    engines/mads/phantom/phantom_scenes.h



diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 8ef6400..e6e3151 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -243,6 +243,8 @@ void DialogsNebular::showDialog() {
 	case DIALOG_GAME_MENU:
 		//GameMenuDialog::show();
 		break;
+	default:
+		break;
 	}
 }
 
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 0574ba9..a449cb6 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -32,6 +32,7 @@
 #include "mads/nebular/nebular_scenes2.h"
 #include "mads/nebular/nebular_scenes3.h"
 #include "mads/nebular/nebular_scenes4.h"
+#include "mads/nebular/nebular_scenes5.h"
 #include "mads/nebular/nebular_scenes8.h"
 
 namespace MADS {
diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
index 2748f24..562cfdf 100644
--- a/engines/mads/nebular/nebular_scenes5.h
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -63,6 +63,7 @@ public:
 };
 
 } // End of namespace Nebular
+
 } // End of namespace MADS
 
 #endif /* MADS_NEBULAR_SCENES5_H */
diff --git a/engines/mads/phantom/phantom_scenes.h b/engines/mads/phantom/phantom_scenes.h
index 6476710..9df8063 100644
--- a/engines/mads/phantom/phantom_scenes.h
+++ b/engines/mads/phantom/phantom_scenes.h
@@ -35,7 +35,7 @@ namespace MADS {
 namespace Phantom {
 
 enum Noun {
-	NOUN_LOOK_AT		= 0x0D1,
+	NOUN_LOOK_AT		= 0x0D1
 	// TODO
 };
 


Commit: e9d76d27a00e4b4760f7b8f442ef69650bae8d5a
    https://github.com/scummvm/scummvm/commit/e9d76d27a00e4b4760f7b8f442ef69650bae8d5a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-04T20:30:52-04:00

Commit Message:
MADS: Fix immediate crashes in new fadeToGrey logic

Changed paths:
    engines/mads/palette.cpp



diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index f8430e8..aa227bf 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -30,6 +30,7 @@
 namespace MADS {
 
 #define VGA_COLOR_TRANS(x) ((x) * 255 / 63)
+#define VGA_COLOR_REV(x) ((x) * 63 / 255)
 
 void RGB6::load(Common::SeekableReadStream *f) {
 	r = VGA_COLOR_TRANS(f->readByte());
@@ -378,7 +379,7 @@ void Fader::fadeToGrey(byte palette[PALETTE_SIZE], byte *paletteMap,
 
 			int diff = intensity - palette[palCtr * 3 + colorCtr];
 			palIndex[palCtr][colorCtr] = (byte)ABS(diff);
-			signs[palCtr][colorCtr] = diff / ABS(diff);
+			signs[palCtr][colorCtr] = (diff == 0) ? 0 : (diff < 0 ? -1 : 1);
 		}
 	}
 
@@ -387,7 +388,6 @@ void Fader::fadeToGrey(byte palette[PALETTE_SIZE], byte *paletteMap,
 			int index = palCtr - baseColor;
 			for (int colorCtr = 0; colorCtr < 3; ++colorCtr) {
 				map[index]._accum[colorCtr] += palIndex[palCtr][colorCtr];
-				/* map[index].accum[color] += pal_color(temp_pal, palCtr, color); */
 				while (map[index]._accum[colorCtr] >= steps) {
 					map[index]._accum[colorCtr] -= steps;
 					palette[palCtr * 3 + colorCtr] = signs[palCtr][colorCtr];
@@ -421,7 +421,7 @@ void Fader::mapToGreyRamp(byte palette[PALETTE_SIZE], int baseColor, int numColo
 
 	getGreyValues(palette, greyList, baseColor, numColors);
 	greyPopularity(greyList, greyTable, numColors);
-	
+
 	for (int idx = 0; idx < numColors; ++idx) {
 		greyList[idx]._mapping = idx;
 		Common::fill(&map[idx]._accum[0], &map[idx]._accum[3], 0);
@@ -489,11 +489,10 @@ void Fader::mapToGreyRamp(byte palette[PALETTE_SIZE], int baseColor, int numColo
 void Fader::getGreyValues(const byte palette[PALETTE_SIZE], 
 		GreyTableEntry greyList[PALETTE_COUNT], int baseColor, int numColors) {
 	const byte *palP = &palette[baseColor * 3];
-	GreyTableEntry *destP = greyList;
 
-	for (int i = 0; i < numColors; ++i, palP += 3, ++destP) {
+	for (int i = 0; i < numColors; ++i, palP += 3) {
 		int v = rgbMerge(palP[0], palP[1], palP[2]);
-		destP->_list = v >> 7;
+		greyList[i]._list = v >> 7;
 	}
 }
 
@@ -501,7 +500,9 @@ void Fader::greyPopularity(const GreyTableEntry greyList[PALETTE_COUNT],
 		byte greyTable[64], int numColors) {
 	Common::fill(&greyTable[0], &greyTable[64], 0);
 	for (int i = 0; i < 64; ++i) {
-		++greyTable[greyList[i]._list];
+		int idx = greyList[i]._list;
+		assert(idx >= 0 && idx < 64);
+		++greyTable[idx];
 	}
 }
 
@@ -510,7 +511,7 @@ int Fader::rgbMerge(RGB6 &palEntry) {
 }
 
 int Fader::rgbMerge(byte r, byte g, byte b) {
-	return ((r + 1) / 4 - 1) * 38 + ((g + 1) / 4 - 1) * 76 + ((b + 1) / 4 - 1) * 14;
+	return VGA_COLOR_REV(r) * 38 + VGA_COLOR_REV(g) * 76 + VGA_COLOR_REV(b) * 14;
 }
 
 /*------------------------------------------------------------------------*/


Commit: 3519208e4e88e3713d33e76630917c4e7785e66c
    https://github.com/scummvm/scummvm/commit/3519208e4e88e3713d33e76630917c4e7785e66c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-05T07:17:32+02:00

Commit Message:
MADS: Add scene 7xx

Changed paths:
  A engines/mads/nebular/nebular_scenes7.cpp
  A engines/mads/nebular/nebular_scenes7.h
    engines/mads/module.mk
    engines/mads/nebular/nebular_scenes.cpp



diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 04739b0..91e8a6b 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -15,6 +15,7 @@ MODULE_OBJS := \
 	nebular/nebular_scenes3.o \
 	nebular/nebular_scenes4.o \
 	nebular/nebular_scenes5.o \
+	nebular/nebular_scenes7.o \
 	nebular/nebular_scenes8.o \
 	action.o \
 	animation.o \
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index a449cb6..6ae9fef 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -33,6 +33,7 @@
 #include "mads/nebular/nebular_scenes3.h"
 #include "mads/nebular/nebular_scenes4.h"
 #include "mads/nebular/nebular_scenes5.h"
+#include "mads/nebular/nebular_scenes7.h"
 #include "mads/nebular/nebular_scenes8.h"
 
 namespace MADS {
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
new file mode 100644
index 0000000..ca9685a
--- /dev/null
+++ b/engines/mads/nebular/nebular_scenes7.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/scene.h"
+#include "mads/nebular/nebular_scenes.h"
+#include "mads/nebular/nebular_scenes7.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+void Scene7xx::setAAName() {
+	_game._aaName = Resources::formatAAName(5);
+}
+
+void Scene7xx::setPlayerSpritesPrefix() {
+	_vm->_sound->command(5);
+
+	Common::String oldName = _game._player._spritesPrefix;
+
+	if ((_scene->_nextSceneId == 703) || (_scene->_nextSceneId == 704) || (_scene->_nextSceneId == 705)
+	 || (_scene->_nextSceneId == 707) || (_scene->_nextSceneId == 710) || (_scene->_nextSceneId == 711))
+		_game._player._spritesPrefix = "";
+	else if (_globals[kSexOfRex] == REX_MALE)
+		_game._player._spritesPrefix = "RXM";
+	else
+		_game._player._spritesPrefix = "ROX";
+
+
+	_game._player._scalingVelocity = true;
+
+	if (oldName != _game._player._spritesPrefix)
+		_game._player._spritesChanged = true;
+
+	_vm->_palette->setEntry(16, 10, 63, 63);
+	_vm->_palette->setEntry(17, 10, 45, 45);
+}
+
+void Scene7xx::sceneEntrySound() {
+	if (!_vm->_musicFlag) {
+		_vm->_sound->command(2);
+		return;
+	}
+
+	switch (_scene->_nextSceneId) {
+	case 701:
+	case 702:
+	case 704:
+	case 705:
+	case 751:
+		_vm->_sound->command(38);
+		break;
+	case 703:
+		if (_globals[kMonsterAlive] == 0)
+			_vm->_sound->command(24);
+		else
+			_vm->_sound->command(27);
+		break;
+	case 706:
+	case 707:
+	case 710:
+	case 711:
+		_vm->_sound->command(25);
+		break;
+	default:
+		break;
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+} // End of namespace Nebular
+} // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes7.h b/engines/mads/nebular/nebular_scenes7.h
new file mode 100644
index 0000000..2816af3
--- /dev/null
+++ b/engines/mads/nebular/nebular_scenes7.h
@@ -0,0 +1,56 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the 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 MADS_NEBULAR_SCENES7_H
+#define MADS_NEBULAR_SCENES7_H
+
+#include "common/scummsys.h"
+#include "mads/game.h"
+#include "mads/scene.h"
+#include "mads/nebular/nebular_scenes.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+class Scene7xx : public NebularScene {
+protected:
+	/**
+	 * Plays an appropriate sound when entering a scene
+	 */
+	void setAAName();
+
+	/**
+	 * Updates the prefix used for getting player sprites for the scene
+	 */
+	void setPlayerSpritesPrefix();
+
+	void sceneEntrySound();
+
+public:
+	Scene7xx(MADSEngine *vm) : NebularScene(vm) {}
+};
+
+} // End of namespace Nebular
+} // End of namespace MADS
+
+#endif /* MADS_NEBULAR_SCENES7_H */


Commit: 6fc91b4369bfc6f6db9db15fafb040e801e14034
    https://github.com/scummvm/scummvm/commit/6fc91b4369bfc6f6db9db15fafb040e801e14034
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-05T18:51:17+02:00

Commit Message:
MADS: Implement scene 707

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes7.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 6ae9fef..6ee696b 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -253,6 +253,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		error("Invalid scene %d called", scene._nextSceneId);
 
 	// Scene group #7
+	case 707:
+		return new Scene707(vm);
 	case 701:
 		// TODO
 	case 702:
@@ -265,8 +267,6 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		// TODO
 	case 706:
 		// TODO
-	case 707:
-		// TODO
 	case 708:
 		// TODO
 	case 710:
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index ca9685a..6692362 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -90,5 +90,56 @@ void Scene7xx::sceneEntrySound() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene707::setup() {
+	_game._player._spritesPrefix = "";
+	// The original calls Scene7xx::setAAName()
+	_game._aaName = Resources::formatAAName(5);
+}
+
+void Scene707::enter() {
+	_handSpriteId = _scene->_sprites.addSprites("*REXHAND");
+	teleporterEnter();
+
+	// The original uses Scene7xx_sceneEntrySound
+	if (!_vm->_musicFlag)
+		_vm->_sound->command(2);
+	else 
+		_vm->_sound->command(25);
+}
+
+void Scene707::step() {
+	teleporterStep();
+}
+
+void Scene707::actions() {
+	if (teleporterActions()) {
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x181) || _action.isAction(0x103, 0x181))
+		_vm->_dialogs->show(70710);
+	else if (_action.isAction(VERB_LOOK, 0xC4))
+		_vm->_dialogs->show(70711);
+	else if (_action.isAction(VERB_LOOK, 0x1CC))
+		_vm->_dialogs->show(70712);
+	else if (_action.isAction(VERB_LOOK, 0x1D0) || _action.isAction(VERB_LOOK, 0x1D1)
+	 || _action.isAction(VERB_LOOK, 0x1D2) || _action.isAction(VERB_LOOK, 0x1D3)
+	 || _action.isAction(VERB_LOOK, 0x1D4) || _action.isAction(VERB_LOOK, 0x1D5)
+	 || _action.isAction(VERB_LOOK, 0x1D6) || _action.isAction(VERB_LOOK, 0x1D7)
+	 || _action.isAction(VERB_LOOK, 0x1D8) || _action.isAction(VERB_LOOK, 0x1D9)
+	 || _action.isAction(VERB_LOOK, 0x1DB) || _action.isAction(VERB_LOOK, 0x7A)
+	 || _action.isAction(VERB_LOOK, 0x1DA))
+		_vm->_dialogs->show(70713);
+	else if (_action.isAction(VERB_LOOK, 0x1CF) || _action._lookFlag)
+		_vm->_dialogs->show(70714);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes7.h b/engines/mads/nebular/nebular_scenes7.h
index 2816af3..1d6c26d 100644
--- a/engines/mads/nebular/nebular_scenes7.h
+++ b/engines/mads/nebular/nebular_scenes7.h
@@ -50,6 +50,18 @@ public:
 	Scene7xx(MADSEngine *vm) : NebularScene(vm) {}
 };
 
+class Scene707: public SceneTeleporter {
+public:
+	Scene707(MADSEngine *vm) : SceneTeleporter(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 2d379e17698dceefcfb96ddfa09b2a2f7ef21161
    https://github.com/scummvm/scummvm/commit/2d379e17698dceefcfb96ddfa09b2a2f7ef21161
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-05T20:07:55+03:00

Commit Message:
MADS: Add initial files for Rex scene group 6

Changed paths:
  A engines/mads/nebular/nebular_scenes6.cpp
  A engines/mads/nebular/nebular_scenes6.h
    engines/mads/module.mk
    engines/mads/nebular/nebular_scenes.cpp



diff --git a/engines/mads/module.mk b/engines/mads/module.mk
index 91e8a6b..61e810e 100644
--- a/engines/mads/module.mk
+++ b/engines/mads/module.mk
@@ -15,6 +15,7 @@ MODULE_OBJS := \
 	nebular/nebular_scenes3.o \
 	nebular/nebular_scenes4.o \
 	nebular/nebular_scenes5.o \
+	nebular/nebular_scenes6.o \
 	nebular/nebular_scenes7.o \
 	nebular/nebular_scenes8.o \
 	action.o \
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 6ee696b..56df10b 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -33,6 +33,7 @@
 #include "mads/nebular/nebular_scenes3.h"
 #include "mads/nebular/nebular_scenes4.h"
 #include "mads/nebular/nebular_scenes5.h"
+#include "mads/nebular/nebular_scenes6.h"
 #include "mads/nebular/nebular_scenes7.h"
 #include "mads/nebular/nebular_scenes8.h"
 
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
new file mode 100644
index 0000000..44f02ed
--- /dev/null
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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/scummsys.h"
+#include "mads/mads.h"
+#include "mads/scene.h"
+#include "mads/nebular/nebular_scenes.h"
+#include "mads/nebular/nebular_scenes6.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+void Scene6xx::setAAName() {
+	_game._aaName = Resources::formatAAName(5);
+}
+
+void Scene6xx::setPlayerSpritesPrefix() {
+	_vm->_sound->command(5);
+	Common::String oldName = _game._player._spritesPrefix;
+
+	_game._player._spritesPrefix = "";
+	// TODO: Scene-specific sprites prefix
+
+	_game._player._scalingVelocity = true;
+
+	if (oldName != _game._player._spritesPrefix)
+		_game._player._spritesChanged = true;
+
+	_vm->_palette->setEntry(16, 10, 63, 63);
+	_vm->_palette->setEntry(17, 10, 45, 45);
+}
+
+void Scene6xx::sceneEntrySound() {
+	if (!_vm->_musicFlag) {
+		_vm->_sound->command(2);
+		return;
+	}
+
+	switch (_scene->_nextSceneId) {
+	// TODO
+	default:
+		break;
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
+} // End of namespace Nebular
+} // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes6.h b/engines/mads/nebular/nebular_scenes6.h
new file mode 100644
index 0000000..19eb278
--- /dev/null
+++ b/engines/mads/nebular/nebular_scenes6.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.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public 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 MADS_NEBULAR_SCENES6_H
+#define MADS_NEBULAR_SCENES6_H
+
+#include "common/scummsys.h"
+#include "mads/game.h"
+#include "mads/scene.h"
+#include "mads/nebular/nebular_scenes.h"
+
+namespace MADS {
+
+namespace Nebular {
+
+class Scene6xx : public NebularScene {
+protected:
+	/**
+	 * Plays an appropriate sound when entering a scene
+	 */
+	void setAAName();
+
+	/**
+	 * Updates the prefix used for getting player sprites for the scene
+	 */
+	void setPlayerSpritesPrefix();
+
+	void sceneEntrySound();
+
+public:
+	Scene6xx(MADSEngine *vm) : NebularScene(vm) {}
+};
+
+} // End of namespace Nebular
+
+} // End of namespace MADS
+
+#endif /* MADS_NEBULAR_SCENES6_H */


Commit: 183dd320963607d7ee1037367c1c86d4b7b77983
    https://github.com/scummvm/scummvm/commit/183dd320963607d7ee1037367c1c86d4b7b77983
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-05T20:15:25+02:00

Commit Message:
MADS: Implement scene 711

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes7.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 56df10b..f192c04 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -256,6 +256,8 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	// Scene group #7
 	case 707:
 		return new Scene707(vm);
+	case 711:
+		return new Scene711(vm);
 	case 701:
 		// TODO
 	case 702:
@@ -272,8 +274,6 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		// TODO
 	case 710:
 		// TODO
-	case 711:
-		// TODO
 	case 751:
 		// TODO
 	case 752:
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 6692362..53b408c 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -141,5 +141,50 @@ void Scene707::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene711::setup() {
+	// The original was calling Scene7xx::setPlayerSpreitesPrefix()
+	_vm->_sound->command(5);
+	Common::String oldName = _game._player._spritesPrefix;
+	_game._player._spritesPrefix = "";
+	_game._player._scalingVelocity = true;
+
+	if (oldName != _game._player._spritesPrefix)
+		_game._player._spritesChanged = true;
+
+	_vm->_palette->setEntry(16, 10, 63, 63);
+	_vm->_palette->setEntry(17, 10, 45, 45);
+
+	// The original was calling Scene7xx::setAAName()
+	_game._aaName = Resources::formatAAName(5);
+
+	_game._player._spritesPrefix = "";
+}
+
+void Scene711::enter() {
+	if (_globals[kSexOfRex] == REX_FEMALE)
+		_handSpriteId = _scene->_sprites.addSprites("*ROXHAND");
+	else
+		_handSpriteId = _scene->_sprites.addSprites("*REXHAND");
+
+	teleporterEnter();
+
+	// The original was using Scene7xx_SceneEntrySound()
+	if (!_vm->_musicFlag)
+		_vm->_sound->command(2);
+	else 
+		_vm->_sound->command(25);
+}
+
+void Scene711::step() {
+	teleporterStep();
+}
+
+void Scene711::actions() {
+	if (teleporterActions())
+		_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes7.h b/engines/mads/nebular/nebular_scenes7.h
index 1d6c26d..080c639 100644
--- a/engines/mads/nebular/nebular_scenes7.h
+++ b/engines/mads/nebular/nebular_scenes7.h
@@ -62,6 +62,18 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene711: public SceneTeleporter {
+public:
+	Scene711(MADSEngine *vm) : SceneTeleporter(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 555f6a3ddac038ae5fa761ad258781340fb6f087
    https://github.com/scummvm/scummvm/commit/555f6a3ddac038ae5fa761ad258781340fb6f087
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-05T20:56:18+02:00

Commit Message:
MADS: Some renaming in scene8xx and scene804, implement scene 807

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/nebular/nebular_scenes8.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index f192c04..e241167 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -282,22 +282,20 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		error("Invalid scene %d called", scene._nextSceneId);
 
 	// Scene group #8
+	case 804:
+		return new Scene804(vm);
+	case 807:
+		return new Scene807(vm);
 	case 801:
 		// TODO
 	case 802:
 		// TODO
 	case 803:
 		// TODO
-		// Fall-through for unimplemented scenes in group #8
-		error("Invalid scene %d called", scene._nextSceneId);
-	case 804:
-		return new Scene804(vm);
 	case 805:
 		// TODO
 	case 806:
 		// TODO
-	case 807:
-		// TODO
 	case 808:
 		// TODO
 	case 810:
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 145dbdc..1ae10ed 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -30,7 +30,7 @@ namespace MADS {
 
 namespace Nebular {
 
-void Scene8xx::setup1() {
+void Scene8xx::setPlayerSpritesPrefix() {
 	_vm->_sound->command(5);
 	if ((_globals[kFromCockpit] && !_globals[kExitShip]) ||
 			_scene->_nextSceneId == 804 || _scene->_nextSceneId == 805 ||
@@ -44,12 +44,14 @@ void Scene8xx::setup1() {
 	_vm->_palette->setEntry(17, 0x0A, 0x2D, 0x2D);
 }
 
-void Scene8xx::setup2() {
+void Scene8xx::setAAName() {
 	_game._aaName = Resources::formatAAName(5);
 }
 
-void Scene8xx::enter1() {
-	if (_vm->_musicFlag) {
+void Scene8xx::sceneEntrySound() {
+	if (!_vm->_musicFlag)
+		_vm->_sound->command(2);
+	else {
 		switch (_scene->_nextSceneId) {
 		case 801:
 		case 802:
@@ -75,8 +77,8 @@ void Scene8xx::enter1() {
 /*------------------------------------------------------------------------*/
 
 void Scene804::setup() {
-	Scene8xx::setup1();
-	Scene8xx::setup2();
+	Scene8xx::setPlayerSpritesPrefix();
+	Scene8xx::setAAName();
 }
 
 void Scene804::enter() {
@@ -130,7 +132,7 @@ void Scene804::enter() {
 
 	_scene->loadAnimation(Resources::formatName(804, 'r', 1, EXT_AA, ""));
 
-	Scene8xx::enter1();
+	Scene8xx::sceneEntrySound();
 
 	if (_globals[kInSpace] && !_globals[kWindowFixed]) {
 		_scene->_userInterface.setup(kInputLimitedSentences);
@@ -306,6 +308,63 @@ void Scene804::step() {
 	}
 }
 
-} // End of namespace Nebular
+/*------------------------------------------------------------------------*/
+
+void Scene807::setup() {
+	_game._player._spritesPrefix = "";
+	// The original was calling Scene8xx::setAAName()
+	_game._aaName = Resources::formatAAName(5);
+}
+
+void Scene807::enter() {
+	if (_globals[kSexOfRex] == REX_FEMALE)
+		_handSpriteId = _scene->_sprites.addSprites("*ROXHAND");
+	else
+		_handSpriteId = _scene->_sprites.addSprites("*REXHAND");
+
+	teleporterEnter();
+
+	// The original uses Scene8xx::SceneEntrySound()
+	if (!_vm->_musicFlag)
+		_vm->_sound->command(2);
+	else
+		_vm->_sound->command(20);
+}
 
+void Scene807::step() {
+	teleporterStep();
+}
+
+void Scene807::actions() {
+	if (teleporterActions()) {
+		_action._inProgress = false;
+		return;
+	}
+
+	if (_action.isAction(VERB_LOOK, 0x181))
+		_vm->_dialogs->show(80710);
+	else if (_action.isAction(0x103, 0x181))
+		_vm->_dialogs->show(80710);
+	else if (_action.isAction(VERB_LOOK, 0xC4) && _action.isAction(0xB7, 0xC4))
+		_vm->_dialogs->show(80711);
+	else if (_action.isAction(VERB_LOOK, 0x1CC))
+		_vm->_dialogs->show(80712);
+	else if (_action.isAction(VERB_LOOK, 0x1D1) || _action.isAction(VERB_LOOK, 0x1D2)
+	 || _action.isAction(VERB_LOOK, 0x1D3) || _action.isAction(VERB_LOOK, 0x1D4)
+	 || _action.isAction(VERB_LOOK, 0x1D5) || _action.isAction(VERB_LOOK, 0x1D6)
+	 || _action.isAction(VERB_LOOK, 0x1D7) || _action.isAction(VERB_LOOK, 0x1D8)
+	 || _action.isAction(VERB_LOOK, 0x1D9) || _action.isAction(VERB_LOOK, 0x1D0)
+	 || _action.isAction(VERB_LOOK, 0x1DB) || _action.isAction(VERB_LOOK, 0x1DA))
+		_vm->_dialogs->show(80713);
+	else if (_action.isAction(VERB_LOOK, 0x1CF) && _action._lookFlag)
+		_vm->_dialogs->show(80714);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
+} // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes8.h b/engines/mads/nebular/nebular_scenes8.h
index 2fb1abf..2c777d8 100644
--- a/engines/mads/nebular/nebular_scenes8.h
+++ b/engines/mads/nebular/nebular_scenes8.h
@@ -37,17 +37,17 @@ protected:
 	/**
 	 * Initial setup code shared by several scenes
 	 */
-	void setup1();
+	void setPlayerSpritesPrefix();
 
 	/**
 	* Initial setup code shared by several scenes
 	*/
-	void setup2();
+	void setAAName();
 
 	/**
 	 * Common scene enter code used by multiple scenes
 	 */
-	void enter1();
+	void sceneEntrySound();
 public:
 	Scene8xx(MADSEngine *vm) : NebularScene(vm) {}
 };
@@ -72,8 +72,19 @@ public:
 	virtual void actions() {};
 };
 
-} // End of namespace Nebular
+class Scene807: public SceneTeleporter {
+public:
+	Scene807(MADSEngine *vm) : SceneTeleporter(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
 
+} // End of namespace Nebular
 } // End of namespace MADS
 
 #endif /* MADS_NEBULAR_SCENES8_H */


Commit: 595f5dcb4f72d5273d2f39b2f060aef9689e1e4d
    https://github.com/scummvm/scummvm/commit/595f5dcb4f72d5273d2f39b2f060aef9689e1e4d
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-05T21:39:57+02:00

Commit Message:
MADS: Implement scene6XX::setPlayerSpritesPrefix and scene6xx::sceneEntrySound

Changed paths:
    engines/mads/nebular/nebular_scenes6.cpp



diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index 44f02ed..2d4ef9e 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -38,14 +38,17 @@ void Scene6xx::setPlayerSpritesPrefix() {
 	_vm->_sound->command(5);
 	Common::String oldName = _game._player._spritesPrefix;
 
-	_game._player._spritesPrefix = "";
-	// TODO: Scene-specific sprites prefix
-
-	_game._player._scalingVelocity = true;
+	if ((_scene->_nextSceneId == 605) || (_scene->_nextSceneId == 620))
+		_game._player._spritesPrefix = "";
+	else if (_globals[kSexOfRex] == REX_MALE)
+		_game._player._spritesPrefix = "RXM";
+	else
+		_game._player._spritesPrefix = "ROX";
 
 	if (oldName != _game._player._spritesPrefix)
 		_game._player._spritesChanged = true;
 
+	_game._player._scalingVelocity = true;
 	_vm->_palette->setEntry(16, 10, 63, 63);
 	_vm->_palette->setEntry(17, 10, 45, 45);
 }
@@ -57,7 +60,22 @@ void Scene6xx::sceneEntrySound() {
 	}
 
 	switch (_scene->_nextSceneId) {
-	// TODO
+	case 601:
+	case 602:
+	case 603:
+	case 604:
+	case 605:
+	case 607:
+	case 608:
+	case 609:
+	case 610:
+	case 612:
+	case 620:
+		_vm->_sound->command(29);
+		break;
+	case 611:
+		_vm->_sound->command(24);
+		break;
 	default:
 		break;
 	}


Commit: 753579172f03c9d6c0a00b6e773d3d6a67514cd1
    https://github.com/scummvm/scummvm/commit/753579172f03c9d6c0a00b6e773d3d6a67514cd1
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-05T21:48:24+02:00

Commit Message:
MADS: Fix code display in Teleporter room

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index e241167..b8b0984 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -450,8 +450,7 @@ void SceneTeleporter::teleporterHandleKey() {
 				_curCode *= 10;
 				_curCode += _buttonTyped;
 				_digitCount++;
-				_msgText = "";
-				_msgText.format("%d", _curCode);
+				_msgText = Common::String::format("%d", _curCode);
 				if (_digitCount < 4)
 					_msgText += "_";
 


Commit: f8380e9654f98700691956c784df57b6f4ac618c
    https://github.com/scummvm/scummvm/commit/f8380e9654f98700691956c784df57b6f4ac618c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-05T20:02:37-04:00

Commit Message:
MADS: Fix teleporter booths to show booth code as 4 digits

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index b8b0984..1c9cd41 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -556,7 +556,7 @@ void SceneTeleporter::teleporterEnter() {
 			_meteorologistNextPlace = _globals[kTeleporterCode + i];
 	}
 
-	Common::String msgText2 = Common::String::format("#%d", tmpVal);
+	Common::String msgText2 = Common::String::format("#%.4d", tmpVal);
 
 	if (_scene->_currentSceneId != 711) {
 		_scene->_kernelMessages.add(Common::Point(133, 34), 0, 32, 0, 9999999, msgText2);


Commit: 13bd409bbff3a88e0bf89e9a069f340aed9f4b44
    https://github.com/scummvm/scummvm/commit/13bd409bbff3a88e0bf89e9a069f340aed9f4b44
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-06T03:26:44+03:00

Commit Message:
MADS: Add a sanity check for color 255

This is used in scene 752

Changed paths:
    engines/mads/msurface.cpp



diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 2c9d093..64b3ae1 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -488,7 +488,8 @@ void MSurface::translate(Common::Array<RGB6> &palette) {
 		byte *pDest = getBasePtr(0, y);
 
 		for (int x = 0; x < this->w; ++x, ++pDest) {
-			*pDest = palette[*pDest]._palIndex;
+			if (*pDest < 255)	// scene 752 has some palette indices of 255
+				*pDest = palette[*pDest]._palIndex;
 		}
 	}
 }


Commit: 3adf1aba77bac2af95d5c7ea414cdcbcbdc35a3c
    https://github.com/scummvm/scummvm/commit/3adf1aba77bac2af95d5c7ea414cdcbcbdc35a3c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-06T03:30:18+03:00

Commit Message:
MADS: Add a sanity check to scene 413

Changed paths:
    engines/mads/nebular/nebular_scenes4.cpp



diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index 980f770..1bb53ed 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -4027,10 +4027,10 @@ void Scene413::enter() {
 }
 
 void Scene413::step() {
-	if (_scene->_activeAnimation->getCurrentFrame() == 38)
+	if (_scene->_activeAnimation && _scene->_activeAnimation->getCurrentFrame() == 38)
 		_scene->_activeAnimation->setCurrentFrame(37);
 
-	if ((_scene->_activeAnimation->getCurrentFrame() == 21) && _canMove) {
+	if (_scene->_activeAnimation && _scene->_activeAnimation->getCurrentFrame() == 21 && _canMove) {
 		_vm->_sound->command(27);
 		_canMove = false;
 	}


Commit: 417536d01c4eb0a1b99fb96a49f83c2f45a59c27
    https://github.com/scummvm/scummvm/commit/417536d01c4eb0a1b99fb96a49f83c2f45a59c27
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-06T03:34:55+03:00

Commit Message:
MADS: Document all game scenes, and allow entering unimplemented scenes

This way, it's possible to enter all scenes for debugging purposes.
Also, this avoids the scene reordering during development. Scenes 708
and 806 have been removed, as they don't exist

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 1c9cd41..06b0f3b 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -51,257 +51,245 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	scene.addActiveVocab(NOUN_ALCOHOL);
 
 	switch (scene._nextSceneId) {
-	// Scene group #1
-	case 101:
+	// Scene group #1 (ship, ocean, cave)
+	case 101:	// Ship, cockpit
 		return new Scene101(vm);
-	case 102:
+	case 102:	// Ship, dining room
 		return new Scene102(vm);
-	case 103:
+	case 103:	// Ship, engine room
 		return new Scene103(vm);
-	case 104:
+	case 104:	// Ocean, northwest cliff
 		return new Scene104(vm);
-	case 105:
+	case 105:	// Ocean, northeast cliff with mine
 		return new Scene105(vm);
-	case 106:
+	case 106:	// Ocean, outside ship
 		return new Scene106(vm);
-	case 107:
+	case 107:	// Ocean, bushes
 		return new Scene107(vm);
-	case 108:
+	case 108:	// Ocean, southwest cliff
 		return new Scene108(vm);
-	case 109:
+	case 109:	// Ocean, tunnel
 		return new Scene109(vm);
-	case 110:
+	case 110:	// Ocean, cave with tunnel
 		return new Scene110(vm);
-	case 111:
+	case 111:	// Cave with pool and opening
 		return new Scene111(vm);
-	case 112:
+	case 112:	// cutscene, looking at view screen
 		return new Scene112(vm);
 
-	// Scene group #2
-	case 201:
+	// Scene group #2 (island)
+	case 201:	// outside teleporter
 		return new Scene201(vm);
-	case 202:
+	case 202:	// village
 		return new Scene202(vm);
-	case 203:
+	case 203:	// tree with Rhotunda (fat woman)
 		return new Scene203(vm);
-	case 205:
+	case 205:	// village
 		return new Scene205(vm);
-	case 207:
+	case 207:	// outside witch doctor's hut
 		return new Scene207(vm);
-	case 208:
+	case 208:	// pit with leaves (trap)
 		return new Scene208(vm);
-	case 209:
+	case 209:	// palm tree and bamboo plant
 		return new Scene209(vm);
-	case 210:
+	case 210:	// outside native woman's hut
 		return new Scene210(vm);
-	case 211:
+	case 211:	// palm tree with monkey
 		return new Scene211(vm);
-	case 212:
+	case 212:	// outside cave
 		return new Scene212(vm);
-	case 213:
+	case 213:	// inside teleporter
 		return new Scene213(vm);
-	case 214:
+	case 214:	// inside witch doctor's hut
 		return new Scene214(vm);
-	case 215:
+	case 215:	// inside native woman's hut
 		return new Scene215(vm);
-	case 216:
+	case 216:	// cutscene, monitor showing Rex and native woman
 		return new Scene216(vm);
 
-	// Scene group #3
-	case 301:
+	// Scene group #3 (women's base, cell block)
+	case 301:	// outside teleporter (before chaos)
 		return new Scene301(vm);
-	case 302:
+	case 302:	// room with statue (before chaos)
 		return new Scene302(vm);
-	case 303:
+	case 303:	// western corridor (before chaos)
 		return new Scene303(vm);
-	case 304:
+	case 304:	// crossing with traffic light (before chaos)
 		return new Scene304(vm);
-	case 307:
+	case 307:	// Rex's cell (before chaos)
 		return new Scene307(vm);
-	case 308:
+	case 308:	// sauropod's cell (before chaos)
 		return new Scene308(vm);
-	case 309:
+	case 309:	// multihand monster's cell (before chaos)
 		return new Scene309(vm);
-	case 310:
+	case 310:	// empty cell (before chaos)
 		return new Scene310(vm);
-	case 311:
+	case 311:	// warden's desk (before chaos)
 		return new Scene311(vm);
-	case 313:
+	case 313:	// air shaft overview
 		return new Scene313(vm);
-	case 316:
+	case 316:	// Gender Bender
 		return new Scene316(vm);
-	case 318:
+	case 318:	// doctor's gurney
 		return new Scene318(vm);
-	case 319:
+	case 319:	// doctor Slache closeup (lying on the gurney)
 		return new Scene319(vm);
-	case 320:
+	case 320:	// warden's desk closeup / monitors
 		return new Scene320(vm);
-	case 321:
+	case 321:	// gender bender sex change sequence
 		return new Scene321(vm);
-	case 322:
+	case 322:	// inside teleporter
 		return new Scene322(vm);
-	case 351:
+	case 351:	// outside teleporter (after chaos)
 		return new Scene351(vm);
-	case 352:
+	case 352:	// room with statue (after chaos)
 		return new Scene352(vm);
-	case 353:
+	case 353:	// western corridor (after chaos)
 		return new Scene353(vm);
-	case 354:
+	case 354:	// crossing with traffic light (after chaos)
 		return new Scene354(vm);
-	case 357:
+	case 357:	// Rex's cell (after chaos)
 		return new Scene357(vm);
-	case 358:
+	case 358:	// sauropod's cell (after chaos)
 		return new Scene358(vm);
-	case 359:
+	case 359:	// multihand monster's cell (after chaos)
 		return new Scene359(vm);
-	case 360:
+	case 360:	// empty cell (after chaos)
 		return new Scene360(vm);
-	case 361:
+	case 361:	// warden's desk (after chaos)
 		return new Scene361(vm);
-	case 366:
+	case 366:	// air shaft ending at Gender Bender
 		return new Scene366(vm);
-	case 387:
+	case 387:	// air shaft ending at cell
 		return new Scene387(vm);
-	case 388:
+	case 388:	// air shaft ending at sauropod's cell
 		return new Scene388(vm);
-	case 389:
+	case 389:	// air shaft ending at multihand monster's cell (before chaos)
 		return new Scene389(vm);
-	case 390:
+	case 390:	// air shaft ending at cell
 		return new Scene390(vm);
-	case 391:
+	case 391:	// air shaft ending at warden's desk
 		return new Scene391(vm);
-	case 399:
+	case 399:	// air shaft ending at multihand monster's cell (after chaos)
 		return new Scene399(vm);
 
-	// Scene group #4
-	case 401:
+	// Scene group #4 (women's base)
+	case 401:	// outside bar
 		return new Scene401(vm);
-	case 402:
+	case 402:	// inside bar
 		return new Scene402(vm);
-	case 405:
+	case 405:	// outside armory
 		return new Scene405(vm);
-	case 406:
+	case 406:	// outside storage room
 		return new Scene406(vm);
-	case 407:
+	case 407:	// eastern corridor
 		return new Scene407(vm);
-	case 408:
+	case 408:	// inside armory
 		return new Scene408(vm);
-	case 409:
+	case 409:	// inside female only teleporter
 		return new Scene409(vm);
-	case 410:
+	case 410:	// inside storage room
 		return new Scene410(vm);
-	case 411:
+	case 411:	// lab
 		return new Scene411(vm);
-	case 413:
+	case 413:	// outside female only teleporter
 		return new Scene413(vm);
 
-	// Scene group #5
-	case 502:
+	// Scene group #5 (men's city, lower floor)
+	case 501:	// outside car
+		return new DummyScene(vm);	// TODO
+	case 502:	// inside male only teleporter
 		return new Scene502(vm);
-	case 501:
-		// TODO
-	case 503:
-		// TODO
-	case 504:
-		// TODO
-	case 505:
-		// TODO
-	case 506:
-		// TODO
-	case 507:
-		// TODO
-	case 508:
-		// TODO
-	case 511:
-		// TODO
-	case 512:
-		// TODO
-	case 513:
-		// TODO
-	case 515:
-		// TODO
-	case 551:
-		// TODO
-		// Fall-through for unimplemented scenes in group #5
-		error("Invalid scene %d called", scene._nextSceneId);
-
-	// Scene group #6
-	case 601:
-		// TODO
-	case 602:
-		// TODO
-	case 603:
-		// TODO
-	case 604:
-		// TODO
-	case 605:
-		// TODO
-	case 607:
-		// TODO
-	case 608:
-		// TODO
-	case 609:
-		// TODO
-	case 610:
-		// TODO
-	case 611:
-		// TODO
-	case 612:
-		// TODO
-	case 620:
-		// TODO
-		// Fall-through for unimplemented scenes in group #6
-		error("Invalid scene %d called", scene._nextSceneId);
-
-	// Scene group #7
-	case 707:
+	case 503:	// guard tower
+		return new DummyScene(vm);	// TODO
+	case 504:	// inside car
+		return new DummyScene(vm);	// TODO
+	case 505:	// car view screen
+		return new DummyScene(vm);	// TODO
+	case 506:	// shopping street
+		return new DummyScene(vm);	// TODO
+	case 507:	// inside software house
+		return new DummyScene(vm);	// TODO
+	case 508:	// laser cannon
+		return new DummyScene(vm);	// TODO
+	case 511:	// outside pleasure dome
+		return new DummyScene(vm);	// TODO
+	case 512:	// inside pleasure dome
+		return new DummyScene(vm);	// TODO
+	case 513:	// outside mall
+		return new DummyScene(vm);	// TODO
+	case 515:	// overview
+		return new DummyScene(vm);	// TODO
+	case 551:	// outside teleporter (with skeleton)
+		return new DummyScene(vm);	// TODO
+
+	// Scene group #6 (men's city, upper floor)
+	case 601:	// outside Bruce's house
+		return new DummyScene(vm);	// TODO
+	case 602:	// Bruce's house, living room
+		return new DummyScene(vm);	// TODO
+	case 603:	// Bruce's house, bedroom
+		return new DummyScene(vm);	// TODO
+	case 604:	// viewport
+		return new DummyScene(vm);	// TODO
+	case 605:	// viewport closeup
+		return new DummyScene(vm);	// TODO
+	case 607:	// outside Abdul's garage
+		return new DummyScene(vm);	// TODO
+	case 608:	// inside Abdul's garage
+		return new DummyScene(vm);	// TODO
+	case 609:	// outside Buckluster video store
+		return new DummyScene(vm);	// TODO
+	case 610:	// inside Buckluster video store
+		return new DummyScene(vm);	// TODO
+	case 611:	// back alley
+		return new DummyScene(vm);	// TODO
+	case 612:	// expressway / maintenance building
+		return new DummyScene(vm);	// TODO
+	case 620:	// cutscene, viewport glass breaking
+		return new DummyScene(vm);	// TODO
+
+	// Scene group #7 (submerged men's city / upper floor)
+	case 701:	// outside elevator (after city is submerged)
+		return new DummyScene(vm);	// TODO
+	case 702:	// outside teleporter (after city is submerged)
+		return new DummyScene(vm);	// TODO
+	case 703:	// water
+		return new DummyScene(vm);	// TODO
+	case 704:	// water, building in the distance
+		return new DummyScene(vm);	// TODO
+	case 705:	// water, outside building
+		return new DummyScene(vm);	// TODO
+	case 706:	// inside building, pedestral room, outside teleporter
+		return new DummyScene(vm);	// TODO
+	case 707:	// teleporter
 		return new Scene707(vm);
-	case 711:
+	case 710:	// looking at pedestral room through binoculars
+		return new DummyScene(vm);	// TODO
+	case 711:	// inside teleporter
 		return new Scene711(vm);
-	case 701:
-		// TODO
-	case 702:
-		// TODO
-	case 703:
-		// TODO
-	case 704:
-		// TODO
-	case 705:
-		// TODO
-	case 706:
-		// TODO
-	case 708:
-		// TODO
-	case 710:
-		// TODO
-	case 751:
-		// TODO
-	case 752:
-		// TODO
-		// Fall-through for unimplemented scenes in group #7
-		error("Invalid scene %d called", scene._nextSceneId);
+	case 751:	// outside elevator (before city is submerged)
+		return new DummyScene(vm);	// TODO
+	case 752:	// outside teleporter (before city is submerged)
+		return new DummyScene(vm);	// TODO
 
 	// Scene group #8
-	case 804:
+	case 801:	// control room, outside teleporter
+		return new DummyScene(vm);	// TODO
+	case 802:	// launch pad with destroyed ship
+		return new DummyScene(vm);	// TODO
+	case 803:	// empty launch pad
+		return new DummyScene(vm);	// TODO
+	case 804:	// ??? (broken animation)
 		return new Scene804(vm);
-	case 807:
-		return new Scene807(vm);
-	case 801:
-		// TODO
-	case 802:
-		// TODO
-	case 803:
-		// TODO
-	case 805:
-		// TODO
-	case 806:
-		// TODO
-	case 808:
-		// TODO
-	case 810:
-		// TODO
-		// Fall-through for unimplemented scenes in group #8
-		error("Invalid scene %d called", scene._nextSceneId);
+	case 805:	// service panel
+		return new DummyScene(vm);	// TODO
+	case 807:	// teleporter
+		return new DummyScene(vm);	// TODO
+	case 808:	// antigrav control
+		return new DummyScene(vm);	// TODO
+	case 810:	// cutscene: Rex's ship leaving the planet
+		return new DummyScene(vm);	// TODO
 
 	default:
 		error("Invalid scene %d called", scene._nextSceneId);
@@ -450,7 +438,8 @@ void SceneTeleporter::teleporterHandleKey() {
 				_curCode *= 10;
 				_curCode += _buttonTyped;
 				_digitCount++;
-				_msgText = Common::String::format("%d", _curCode);
+				_msgText = "";
+				_msgText.format("%d", _curCode);
 				if (_digitCount < 4)
 					_msgText += "_";
 
@@ -556,7 +545,7 @@ void SceneTeleporter::teleporterEnter() {
 			_meteorologistNextPlace = _globals[kTeleporterCode + i];
 	}
 
-	Common::String msgText2 = Common::String::format("#%.4d", tmpVal);
+	Common::String msgText2 = Common::String::format("#%d", tmpVal);
 
 	if (_scene->_currentSceneId != 711) {
 		_scene->_kernelMessages.add(Common::Point(133, 34), 0, 32, 0, 9999999, msgText2);
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 2a47af6..e1fcf1e 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -178,6 +178,22 @@ protected:
 	*/
 	SceneTeleporter(MADSEngine *vm) : NebularScene(vm) {}
 };
+
+// TODO: Temporary, remove once all scenes are implemented properly
+class DummyScene: public NebularScene {
+public:
+	DummyScene(MADSEngine *vm) : NebularScene(vm) {
+		warning("Unimplemented scene");
+	}
+
+	virtual void setup() {}
+	virtual void enter() {}
+	virtual void step() {}
+	virtual void preActions() {}
+	virtual void actions() {}
+	virtual void synchronize(Common::Serializer &s) {}
+};
+
 } // End of namespace Nebular
 
 } // End of namespace MADS


Commit: 2ff16fbc49c0bc44ab06b3a25d7739bf0b394a86
    https://github.com/scummvm/scummvm/commit/2ff16fbc49c0bc44ab06b3a25d7739bf0b394a86
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-06T03:38:21+03:00

Commit Message:
MADS: Restore accidentally reverted code

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 06b0f3b..970acb0 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -438,8 +438,7 @@ void SceneTeleporter::teleporterHandleKey() {
 				_curCode *= 10;
 				_curCode += _buttonTyped;
 				_digitCount++;
-				_msgText = "";
-				_msgText.format("%d", _curCode);
+				_msgText = Common::String::format("%d", _curCode);
 				if (_digitCount < 4)
 					_msgText += "_";
 
@@ -545,7 +544,7 @@ void SceneTeleporter::teleporterEnter() {
 			_meteorologistNextPlace = _globals[kTeleporterCode + i];
 	}
 
-	Common::String msgText2 = Common::String::format("#%d", tmpVal);
+	Common::String msgText2 = Common::String::format("#%.4d", tmpVal);
 
 	if (_scene->_currentSceneId != 711) {
 		_scene->_kernelMessages.add(Common::Point(133, 34), 0, 32, 0, 9999999, msgText2);


Commit: c5878e401ce54713fb179f24a5744666571d2743
    https://github.com/scummvm/scummvm/commit/c5878e401ce54713fb179f24a5744666571d2743
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-06T04:38:24+03:00

Commit Message:
MADS: Fix scene loading for V2 games

Changed paths:
    engines/mads/scene_data.cpp



diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 65220ce..272c828 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -141,7 +141,7 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 	_height = infoStream->readUint16LE();
 
 	// HACK for V2 games (for now)
-	if (_vm->getGameID() != GType_RexNebular && _width == 0) {
+	if (_vm->getGameID() != GType_RexNebular) {
 		_width = 320;
 		_height = 156;
 	}
@@ -226,15 +226,18 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 	Common::Array<SpriteAsset *> spriteSets;
 	Common::Array<int> usageList;
 
-	for (uint i = 0; i < setNames.size(); ++i) {
-		Common::String setResName;
-		if (sceneFlag || resName.hasPrefix("*"))
-			setResName += "*";
-		setResName += setNames[i];
-
-		SpriteAsset *sprites = new SpriteAsset(_vm, setResName, flags);
-		spriteSets.push_back(sprites);
-		usageList.push_back(sprites->_usageIndex); 
+	// TODO: The following isn't quite right for V2 games
+	if (_vm->getGameID() == GType_RexNebular) {
+		for (uint i = 0; i < setNames.size(); ++i) {
+			Common::String setResName;
+			if (sceneFlag || resName.hasPrefix("*"))
+				setResName += "*";
+			setResName += setNames[i];
+
+			SpriteAsset *sprites = new SpriteAsset(_vm, setResName, flags);
+			spriteSets.push_back(sprites);
+			usageList.push_back(sprites->_usageIndex); 
+		}
 	}
 
 	_vm->_palette->_paletteUsage.updateUsage(usageList, _usageIndex);


Commit: d88e165e00cc70540af05c06f4f32b1907bdcc09
    https://github.com/scummvm/scummvm/commit/d88e165e00cc70540af05c06f4f32b1907bdcc09
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-06T04:39:12+03:00

Commit Message:
MADS: Fix loading of V2 hotspots

Changed paths:
    engines/mads/hotspots.cpp
    engines/mads/scene.cpp
    engines/mads/screen.cpp
    engines/mads/user_interface.cpp



diff --git a/engines/mads/hotspots.cpp b/engines/mads/hotspots.cpp
index ca05ad6..d3ce0a9 100644
--- a/engines/mads/hotspots.cpp
+++ b/engines/mads/hotspots.cpp
@@ -182,13 +182,13 @@ Hotspot::Hotspot(Common::SeekableReadStream &f, bool isV2) {
 	_articleNumber = f.readByte();
 	_active = f.readByte() != 0;
 	_cursor = (CursorType)f.readByte();
-	_vocabId = f.readUint16LE();
-	_verbId = f.readUint16LE();
 	if (isV2) {
 		// This looks to be some sort of bitmask. Perhaps it signifies
 		// the valid verbs for this hotspot
 		f.skip(2);		// unknown
 	}
+	_vocabId = f.readUint16LE();
+	_verbId = f.readUint16LE();
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index e53061c..62a0e20 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -477,26 +477,15 @@ void  Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
 	// Copy background for the dirty areas to the screen
 	_dirtyAreas.copy(&_backgroundSurface, &_vm->_screen, _posAdjust);
 
-	// TODO: Remove this HACK when sprites are implemented for V2 games
-	if (_vm->getGameID() != GType_RexNebular) {
-		if (transitionType) {
-			// Fading in the screen
-			_vm->_screen.transition(transitionType, surfaceFlag);
-			_vm->_sound->startQueuedCommands();
-		} else {
-			// Copy dirty areas to the screen
-			_dirtyAreas.copyToScreen(_vm->_screen._offset);
-		}
-		return;
-	}
-
 	// Handle dirty areas for foreground objects
-	_spriteSlots.setDirtyAreas();
+	if (_vm->getGameID() == GType_RexNebular)	// TODO: Implement for V2 games
+		_spriteSlots.setDirtyAreas();
 	_textDisplay.setDirtyAreas2();
 	_dirtyAreas.merge(1, DIRTY_AREAS_SIZE);
 
 	// Draw sprites that have changed
-	_spriteSlots.drawSprites(&_vm->_screen);
+	if (_vm->getGameID() == GType_RexNebular)	// TODO: Implement for V2 games
+		_spriteSlots.drawSprites(&_vm->_screen);
 
 	// Draw text elements onto the view
 	_textDisplay.draw(&_vm->_screen);
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 640617e..f0564c5 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -259,7 +259,7 @@ ScreenObjects::ScreenObjects(MADSEngine *vm) : _vm(vm) {
 }
 
 void ScreenObjects::add(const Common::Rect &bounds, Layer layer, ScrCategory category, int descId) {
-	assert(size() < 100);
+	//assert(size() < 100);
 
 	ScreenObject so;
 	so._bounds = bounds;
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 8208c14..e8eaf3a 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -704,15 +704,12 @@ void UserInterface::loadElements() {
 			CAT_INV_ANIM, 0);
 	}
 
-	// TODO: Implement for V2 games
-	if (_vm->getGameID() == GType_RexNebular) {
-		if (_vm->_game->_screenObjects._inputMode == kInputBuildingSentences || 
-				_vm->_game->_screenObjects._inputMode == kInputLimitedSentences) {
-			_categoryIndexes[CAT_HOTSPOT - 1] = _vm->_game->_screenObjects.size() + 1;
-			for (int hotspotIdx = scene._hotspots.size() - 1; hotspotIdx >= 0; --hotspotIdx) {
-				Hotspot &hs = scene._hotspots[hotspotIdx];
-				_vm->_game->_screenObjects.add(hs._bounds, LAYER_GUI, CAT_HOTSPOT, hotspotIdx);
-			}
+	if (_vm->_game->_screenObjects._inputMode == kInputBuildingSentences || 
+			_vm->_game->_screenObjects._inputMode == kInputLimitedSentences) {
+		_categoryIndexes[CAT_HOTSPOT - 1] = _vm->_game->_screenObjects.size() + 1;
+		for (int hotspotIdx = scene._hotspots.size() - 1; hotspotIdx >= 0; --hotspotIdx) {
+			Hotspot &hs = scene._hotspots[hotspotIdx];
+			_vm->_game->_screenObjects.add(hs._bounds, LAYER_GUI, CAT_HOTSPOT, hotspotIdx);
 		}
 	}
 


Commit: 66593ef302010d5b6e09b17fb2b7a88f2803d455
    https://github.com/scummvm/scummvm/commit/66593ef302010d5b6e09b17fb2b7a88f2803d455
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-06T05:32:21+03:00

Commit Message:
MADS: Index and document all Phantom scenes

Changed paths:
    engines/mads/phantom/game_phantom.cpp
    engines/mads/phantom/game_phantom.h
    engines/mads/phantom/phantom_scenes.cpp
    engines/mads/phantom/phantom_scenes.h



diff --git a/engines/mads/phantom/game_phantom.cpp b/engines/mads/phantom/game_phantom.cpp
index 43dec7c..25da777 100644
--- a/engines/mads/phantom/game_phantom.cpp
+++ b/engines/mads/phantom/game_phantom.cpp
@@ -80,9 +80,6 @@ void GamePhantom::initialiseGlobals() {
 	/* Section #5 variables */
 	// TODO
 
-	/* Section #6 variables */
-	// TODO
-
 	/* Section #9 variables */
 	// TODO
 
@@ -112,15 +109,6 @@ void GamePhantom::setSectionHandler() {
 	case 5:
 		_sectionHandler = new Section5Handler(_vm);
 		break;
-	case 6:
-		_sectionHandler = new Section6Handler(_vm);
-		break;
-	case 7:
-		_sectionHandler = new Section7Handler(_vm);
-		break;
-	case 8:
-		_sectionHandler = new Section8Handler(_vm);
-		break;
 	default:
 		break;
 	}
diff --git a/engines/mads/phantom/game_phantom.h b/engines/mads/phantom/game_phantom.h
index bb574a9..96299fb 100644
--- a/engines/mads/phantom/game_phantom.h
+++ b/engines/mads/phantom/game_phantom.h
@@ -88,9 +88,6 @@ typedef Section1Handler Section2Handler;
 typedef Section1Handler Section3Handler;
 typedef Section1Handler Section4Handler;
 typedef Section1Handler Section5Handler;
-typedef Section1Handler Section6Handler;
-typedef Section1Handler Section7Handler;
-typedef Section1Handler Section8Handler;
 
 } // End of namespace Nebular
 
diff --git a/engines/mads/phantom/phantom_scenes.cpp b/engines/mads/phantom/phantom_scenes.cpp
index 83b664b..dbce014 100644
--- a/engines/mads/phantom/phantom_scenes.cpp
+++ b/engines/mads/phantom/phantom_scenes.cpp
@@ -39,22 +39,114 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	// TODO
 	//scene.addActiveVocab(NOUN_DROP);
 
-	// TODO: Just return a dummy scene for now
-	return new DummyScene(vm);
-
 	switch (scene._nextSceneId) {
-	// Scene group #1
-	case 101:
-	// TODO
-
-	// Scene group #2
-	// TODO
-
-	// Scene group #3
-	// TODO
-
-	// Scene group #8
-	// TODO
+	// Scene group #1 (theater, stage and dressing rooms)
+	case 101:	// seats
+		return new DummyScene(vm);	// TODO
+	case 102:	// music stands
+		return new DummyScene(vm);	// TODO
+	case 103:	// below stage
+		return new DummyScene(vm);	// TODO
+	case 104:	// stage
+		return new DummyScene(vm);	// TODO
+	case 105:	// ground floor, storage room
+		return new DummyScene(vm);	// TODO
+	case 106:	// behind stage
+		return new DummyScene(vm);	// TODO
+	case 107:	// stage right wing
+		return new DummyScene(vm);	// TODO
+	case 108:	// stage left wing
+		return new DummyScene(vm);	// TODO
+	case 109:	// upper floor, staircase
+		return new DummyScene(vm);	// TODO
+	case 110:	// outside dressing rooms 1
+		return new DummyScene(vm);	// TODO
+	case 111:	// outside dressing rooms 2
+		return new DummyScene(vm);	// TODO
+	case 112:	// inside dressing room 1
+		return new DummyScene(vm);	// TODO
+	case 113:	// inside dressing room 2
+		return new DummyScene(vm);	// TODO
+	case 114:	// lower floor, storage room
+		return new DummyScene(vm);	// TODO
+	case 150:	// cutscene
+		return new DummyScene(vm);	// TODO
+
+	// Scene group #2 (theater entrance, offices, balcony)
+	case 201:	// entrance / ticket office
+		return new DummyScene(vm);	// TODO
+	case 202:	// outside offices / paintings room
+		return new DummyScene(vm);	// TODO
+	case 203:	// office
+		return new DummyScene(vm);	// TODO
+	case 204:	// library
+		return new DummyScene(vm);	// TODO
+	case 205:	// upper floor, outside balcony boxes
+		return new DummyScene(vm);	// TODO
+	case 206:	// balcony box #1
+		return new DummyScene(vm);	// TODO
+	case 207:	// balcony box #2
+		return new DummyScene(vm);	// TODO
+	case 208:	// stage and balcony view
+		return new DummyScene(vm);	// TODO
+	case 250:	// cutscene
+		return new DummyScene(vm);	// TODO
+
+	// Scene group #3 (catwalks, chandelier, lake / catacombs entrance)
+	case 301:	// catwalk #1 above stage
+		return new DummyScene(vm);	// TODO
+	case 302:	// catwalk #2 above stage
+		return new DummyScene(vm);	// TODO
+	case 303:	// above chandelier
+		return new DummyScene(vm);	// TODO
+	case 304:	// chandelier
+		return new DummyScene(vm);	// TODO
+	case 305:	// chandelier fight, phantom closeup
+		return new DummyScene(vm);	// TODO
+	case 306:	// chandelier #2
+		return new DummyScene(vm);	// TODO
+	case 307:	// catwalk #3 above stage
+		return new DummyScene(vm);	// TODO
+	case 308:	// hidden staircase behind balcony box
+		return new DummyScene(vm);	// TODO
+	case 309:	// lake and archway
+		return new DummyScene(vm);	// TODO
+	case 310:	// lake
+		return new DummyScene(vm);	// TODO
+
+	// Scene group #4 (labyrinth)
+	case 401:	// labyrinth room, 3 exits
+		return new DummyScene(vm);	// TODO
+	case 403:	// labyrinth room (big), 4 exits + 1 bricked door, left
+		return new DummyScene(vm);	// TODO
+	case 404:	// labyrinth room, 3 exits
+		return new DummyScene(vm);	// TODO
+	case 406:	// labyrinth room, 2 exits
+		return new DummyScene(vm);	// TODO
+	case 407:	// catacomb room / lake
+		return new DummyScene(vm);	// TODO
+	case 408:	// catacomb corridor
+		return new DummyScene(vm);	// TODO
+	case 409:	// catacomb room, door with switch panel
+		return new DummyScene(vm);	// TODO
+	case 410:	// skull switch panel
+		return new DummyScene(vm);	// TODO
+	case 453:	// Labyrinth room (big), 4 exits + 1 bricked door, right
+		return new DummyScene(vm);	// TODO
+	case 456:	// Labyrinth room, 2 exits
+		return new DummyScene(vm);	// TODO
+
+	// Scene group #5 (Phantom's hideout)
+	case 501:	// catacombs, outside phantom's hideout, lake and boat
+		return new DummyScene(vm);	// TODO
+	case 502:	// push panel trap
+		return new DummyScene(vm);	// TODO
+	case 504:	// Phantom's hideout, church organ
+		return new DummyScene(vm);	// TODO
+	case 505:	// Phantom's hideout, sarcophagus
+		return new DummyScene(vm);	// TODO
+	case 506:	// catacomb room with ramp
+		return new DummyScene(vm);	// TODO
 
 	default:
 		error("Invalid scene %d called", scene._nextSceneId);
diff --git a/engines/mads/phantom/phantom_scenes.h b/engines/mads/phantom/phantom_scenes.h
index 9df8063..e4b79fe 100644
--- a/engines/mads/phantom/phantom_scenes.h
+++ b/engines/mads/phantom/phantom_scenes.h
@@ -106,9 +106,11 @@ public:
 };
 
 // TODO: Temporary, remove once implemented properly
-class DummyScene: public Scene1xx {
+class DummyScene: public PhantomScene {
 public:
-	DummyScene(MADSEngine *vm) : Scene1xx(vm) {}
+	DummyScene(MADSEngine *vm) : PhantomScene(vm) {
+		warning("Unimplemented scene");
+	}
 
 	virtual void setup() {}
 	virtual void enter() {}


Commit: add4135d46f48cf3bda3424a11215b893c6b3a33
    https://github.com/scummvm/scummvm/commit/add4135d46f48cf3bda3424a11215b893c6b3a33
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-06T06:16:25+03:00

Commit Message:
MADS: Index and document all Dragonsphere scenes

Changed paths:
    engines/mads/dragonsphere/dragonsphere_scenes.cpp
    engines/mads/dragonsphere/dragonsphere_scenes.h



diff --git a/engines/mads/dragonsphere/dragonsphere_scenes.cpp b/engines/mads/dragonsphere/dragonsphere_scenes.cpp
index fd4fcc1..40c9a89 100644
--- a/engines/mads/dragonsphere/dragonsphere_scenes.cpp
+++ b/engines/mads/dragonsphere/dragonsphere_scenes.cpp
@@ -43,18 +43,145 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	return new DummyScene(vm);
 
 	switch (scene._nextSceneId) {
-	// Scene group #1
-	case 101:
-	// TODO
-
-	// Scene group #2
-	// TODO
-
-	// Scene group #3
-	// TODO
-
-	// Scene group #8
-	// TODO
+	// Scene group #1 (Castle, river and caves)
+	case 101:	// king's bedroom
+		return new DummyScene(vm);	// TODO
+	case 102:	// queen's bedroom
+		return new DummyScene(vm);	// TODO
+	case 103:	// outside king's bedroom
+		return new DummyScene(vm);	// TODO
+	case 104:	// fireplace / bookshelf
+		return new DummyScene(vm);	// TODO
+	case 105:	// dining room
+		return new DummyScene(vm);	// TODO
+	case 106:	// throne room
+		return new DummyScene(vm);	// TODO
+	case 107:	// council chamber
+		return new DummyScene(vm);	// TODO
+	case 108:	// dungeon, cell entrance
+		return new DummyScene(vm);	// TODO
+	case 109:	// cell
+		return new DummyScene(vm);	// TODO
+	case 110:	// outside castle, merchants and well
+		return new DummyScene(vm);	// TODO
+	case 111:	// Dragonsphere closeup
+		return new DummyScene(vm);	// TODO
+	case 112:	// well descend
+		return new DummyScene(vm);	// TODO
+	case 113:	// bottom of well, river and trap door
+		return new DummyScene(vm);	// TODO
+	case 114:	// cave
+		return new DummyScene(vm);	// TODO
+	case 115:	// cave with passageway to west
+		return new DummyScene(vm);	// TODO
+	case 116:	// cave with pedestral
+		return new DummyScene(vm);	// TODO
+	case 117:	// river
+		return new DummyScene(vm);	// TODO
+	case 118:	// castle courtyard and gate
+		return new DummyScene(vm);	// TODO
+	case 119:	// castle stairs
+		return new DummyScene(vm);	// TODO
+	case 120:	// map
+		return new DummyScene(vm);	// TODO
+
+	// Scene group #2 (Slathan ni Patan, land of shapeshifters)
+	case 201:	// guardhouse, entrance to Slathan ni Patan
+		return new DummyScene(vm);	// TODO
+	case 203:	// forest
+		return new DummyScene(vm);	// TODO
+	case 204:	// cave
+		return new DummyScene(vm);	// TODO
+	case 205:	// outside village
+		return new DummyScene(vm);	// TODO
+	case 206:	// village
+		return new DummyScene(vm);	// TODO
+
+	// Scene group #3 (Brynn-Fann, Land of faeries)
+	case 301:	// maze entrance
+		return new DummyScene(vm);	// TODO
+	case 302:	// maze
+		return new DummyScene(vm);	// TODO
+	case 303:	// toads
+		return new DummyScene(vm);	// TODO
+
+	// Scene group #4 (The Desert)
+	case 401:	// desert
+		return new DummyScene(vm);	// TODO
+	case 402:	// desert
+		return new DummyScene(vm);	// TODO
+	case 403:	// desert
+		return new DummyScene(vm);	// TODO
+	case 404:	// desert with dunes
+		return new DummyScene(vm);	// TODO
+	case 405:	// oasis
+		return new DummyScene(vm);	// TODO
+	case 406:	// inside tent
+		return new DummyScene(vm);	// TODO
+	case 407:	// gem sack closeup
+		return new DummyScene(vm);	// TODO
+	case 408:	// spirit plane
+		return new DummyScene(vm);	// TODO
+	case 409:	// spirit plane top down view, disks
+		return new DummyScene(vm);	// TODO
+	case 410:	// snake pit and spirit tree
+		return new DummyScene(vm);	// TODO
+	case 411:	// nest
+		return new DummyScene(vm);	// TODO
+	case 412:	// desert
+		return new DummyScene(vm);	// TODO
+	case 454:	// cutscene
+		return new DummyScene(vm);	// TODO
+
+	// Scene group #5 (The Mountain)
+	case 501:	// base of mountain / wall
+		return new DummyScene(vm);	// TODO
+	case 502:	// base of mountain
+		return new DummyScene(vm);	// TODO
+	case 503:	// waterfall
+		return new DummyScene(vm);	// TODO
+	case 504:	// hermit's cave
+		return new DummyScene(vm);	// TODO
+	case 505:	// rock trees
+		return new DummyScene(vm);	// TODO
+	case 506:	// nest
+		return new DummyScene(vm);	// TODO
+	case 507:	// above nest
+		return new DummyScene(vm);	// TODO
+	case 508:	// ledge, right
+		return new DummyScene(vm);	// TODO
+	case 509:	// ledge, left
+		return new DummyScene(vm);	// TODO
+	case 510:	// nest top down view and pillars
+		return new DummyScene(vm);	// TODO
+	case 511:	// pillars
+		return new DummyScene(vm);	// TODO
+	case 512:	// nest
+		return new DummyScene(vm);	// TODO
+	case 557:	// cutscene
+		return new DummyScene(vm);	// TODO
+
+	// Scene group #6 (The Tower)
+	case 601:	// ??? (tile count mismatch)
+		return new DummyScene(vm);	// TODO
+	case 603:	// eye chamber
+		return new DummyScene(vm);	// TODO
+	case 604:	// room of magic
+		return new DummyScene(vm);	// TODO
+	case 605:	// science room
+		return new DummyScene(vm);	// TODO
+	case 606:	// doorway
+		return new DummyScene(vm);	// TODO
+	case 607:	// prison
+		return new DummyScene(vm);	// TODO
+	case 609:	// stone pedestral chamber
+		return new DummyScene(vm);	// TODO
+	case 612:	// infernal machine room
+		return new DummyScene(vm);	// TODO
+	case 613:	// room with lava floor
+		return new DummyScene(vm);	// TODO
+	case 614:	// sorcerer's room
+		return new DummyScene(vm);	// TODO
 
 	default:
 		error("Invalid scene %d called", scene._nextSceneId);
diff --git a/engines/mads/dragonsphere/dragonsphere_scenes.h b/engines/mads/dragonsphere/dragonsphere_scenes.h
index cf42dab..0c5fea3 100644
--- a/engines/mads/dragonsphere/dragonsphere_scenes.h
+++ b/engines/mads/dragonsphere/dragonsphere_scenes.h
@@ -106,9 +106,11 @@ public:
 };
 
 // TODO: Temporary, remove once implemented properly
-class DummyScene: public Scene1xx {
+class DummyScene: public DragonsphereScene {
 public:
-	DummyScene(MADSEngine *vm) : Scene1xx(vm) {}
+	DummyScene(MADSEngine *vm) : DragonsphereScene(vm) {
+		warning("Unimplemented scene");
+	}
 
 	virtual void setup() {}
 	virtual void enter() {}


Commit: daf4170d74b8dff91818443baa287b5b5176e9b5
    https://github.com/scummvm/scummvm/commit/daf4170d74b8dff91818443baa287b5b5176e9b5
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-06T07:22:53+02:00

Commit Message:
MADS: Implement scene 501

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes5.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 970acb0..08b01fe 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -197,7 +197,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 
 	// Scene group #5 (men's city, lower floor)
 	case 501:	// outside car
-		return new DummyScene(vm);	// TODO
+		return new Scene501(vm);
 	case 502:	// inside male only teleporter
 		return new Scene502(vm);
 	case 503:	// guard tower
@@ -285,7 +285,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 805:	// service panel
 		return new DummyScene(vm);	// TODO
 	case 807:	// teleporter
-		return new DummyScene(vm);	// TODO
+		return new Scene807(vm);
 	case 808:	// antigrav control
 		return new DummyScene(vm);	// TODO
 	case 810:	// cutscene: Rex's ship leaving the planet
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index eb1aa42..db6e6da 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -92,6 +92,371 @@ void Scene5xx::sceneEntrySound() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene501::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x6E);
+	_scene->addActiveVocab(0x18B);
+}
+
+void Scene501::handleSlotActions() {
+	switch (_game._trigger) {
+	case 0:
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		int numTicks, frameIndex;
+		if (_globals[kSexOfRex] == REX_MALE) {
+			_mainSpriteId = _globals._spriteIndexes[4];
+			numTicks = 8;
+			frameIndex = 3;
+		} else {
+			_mainSpriteId = _globals._spriteIndexes[5];
+			numTicks = 10;
+			frameIndex = 2;
+		}
+
+		_mainSequenceId = _scene->_sequences.startReverseCycle(_mainSpriteId, false, numTicks, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_mainSequenceId, 1, frameIndex);
+		_scene->_sequences.setMsgLayout(_mainSequenceId);
+		_vm->_sound->command(10);
+		_scene->_sequences.addSubEntry(_mainSequenceId, SEQUENCE_TRIGGER_SPRITE, frameIndex, 1);
+		_scene->_sequences.addSubEntry(_mainSequenceId, SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+		break;
+
+	case 1:
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 12, 6, 0, 0);
+		break;
+
+	case 2:
+		_scene->_sequences.updateTimeout(-1, _mainSequenceId);
+		_game._player._visible = true;
+		_scene->_sequences.addTimer(15, 3);
+		break;
+
+	case 3:
+		_game._player.walk(Common::Point(282, 110), FACING_NORTH);
+		_scene->_sequences.addTimer(60, 4);
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene501::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('c', 0));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 0));
+
+	if (_globals[kSexOfRex] == REX_MALE) {
+		_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXMRC_9");
+		_globals._spriteIndexes[6] = _scene->_sprites.addSprites("*RXCD_7");
+	} else {
+		_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*ROXRC_9");
+		_globals._spriteIndexes[7] = _scene->_sprites.addSprites("*ROXCD_7");
+	}
+
+	_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+	int idx = _scene->_dynamicHotspots.add(0x6E, 0x18B, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+	_doorHotspotid = _scene->_dynamicHotspots.setPosition(idx,Common::Point(282, 110), FACING_NORTH);
+	_scene->_dynamicHotspots.setCursor(_doorHotspotid, CURSOR_GO_UP);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 7);
+	_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+	_rexPunched = true;
+
+	if (_scene->_priorSceneId == 504) {
+		_game._player._stepEnabled = false;
+		_game._player._playerPos = Common::Point(74, 121);
+		_game._player._facing = FACING_NORTHWEST;
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+		if (_globals[kSexOfRex] == REX_MALE)
+			_scene->loadAnimation(formAnimName('G', 2), 70);
+		else
+			_scene->loadAnimation(formAnimName('R', 2), 70);
+	} else if (_scene->_priorSceneId == 503) {
+		_game._player._playerPos = Common::Point(317, 102);
+		_game._player._facing = FACING_SOUTHWEST;
+		_scene->_sequences.addTimer(15, 80);
+	} else if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(299, 131);
+
+	if (_scene->_roomChanged) {
+		_game._objects.addToInventory(OBJ_FAKE_ID);
+		_game._objects.addToInventory(OBJ_SECURITY_CARD);
+		_game._objects.addToInventory(OBJ_ID_CARD);
+	}
+
+	sceneEntrySound();
+	_game.loadQuoteSet(0x275, 0x276, 0x277, 0);
+
+	if (!_game._visitedScenes._sceneRevisited)
+		_scene->_sequences.addTimer(2, 90);
+}
+
+void Scene501::step() {
+	if (_game._trigger == 90)
+		_vm->_dialogs->show(50127);
+
+	if (_game._trigger >= 80) {
+		switch (_game._trigger) {
+		case 80:
+			_game._player._stepEnabled = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 12, 6, 0, 0);
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 9, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 7);
+			_vm->_sound->command(11);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 81);
+			break;
+
+		case 81:
+			_scene->_dynamicHotspots.remove(_doorHotspotid);
+			_game._player.walk(Common::Point(276, 110), FACING_SOUTHWEST);
+			_scene->_sequences.addTimer(120, 82);
+			break;
+
+		case 82:
+			_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 9, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 7);
+			_vm->_sound->command(12);
+			_doorHotspotid = _scene->_dynamicHotspots.add(0x6E, 0x18B, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+			_scene->_dynamicHotspots.setPosition(_globals._sequenceIndexes[3], Common::Point(282, 110), FACING_NORTH);
+			_scene->_dynamicHotspots.setCursor(_doorHotspotid, CURSOR_GO_UP);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 83);
+			break;
+
+		case 83:
+			_game._player._stepEnabled = true;
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 7);
+			break;
+
+		default:
+			break;
+		}
+	}
+
+	if (_game._trigger >= 70 && _game._trigger <= 73) {
+		switch (_game._trigger) {
+		case 70:
+			_game._player._visible = true;
+			_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+			_scene->_sequences.addTimer(15, 71);
+			break;
+
+		case 71:
+			_game._player.walk(Common::Point(92, 130), FACING_SOUTH);
+			_scene->_sequences.addTimer(30, 72);
+			break;
+
+		case 72:
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 73);
+			break;
+
+		case 73:
+			_game._player._stepEnabled = true;
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+			break;
+
+		default:
+			break;
+		}
+	}
+}
+
+void Scene501::preActions() {
+	if (_action.isAction(0x1AD) && (_action.isAction(0x321) || _action.isAction(0x322)))
+		_game._player._walkOffScreenSceneId = 551;
+}
+
+void Scene501::actions() {
+	if (_action.isAction(0x36A, 0x324)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			break;
+
+		case 1: {
+			int syncIdx = _globals._sequenceIndexes[2];
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], syncIdx);
+			_scene->_sequences.addTimer(15, 2);
+			}
+			break;
+
+		case 2:
+			_game._player._visible = false;
+			if (_globals[kSexOfRex] == REX_MALE)
+				_mainSpriteId = _globals._spriteIndexes[6];
+			else
+				_mainSpriteId = _globals._spriteIndexes[7];
+
+			_mainSequenceId = _scene->_sequences.addSpriteCycle(_mainSpriteId, false, 8, 1, 0, 0);
+			_scene->_sequences.setMsgLayout(_mainSequenceId);
+			_scene->_sequences.addSubEntry(_mainSequenceId, SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+			break;
+
+		case 3: {
+			int syncIdx = _mainSequenceId;
+			_mainSequenceId = _scene->_sequences.startCycle(_mainSpriteId, false, -2);
+			_scene->_sequences.setMsgLayout(_mainSequenceId);
+			_scene->_sequences.updateTimeout(_mainSequenceId, syncIdx);
+			_scene->_sequences.addTimer(30, 4);
+			}
+			break;
+
+		case 4:
+			_scene->_nextSceneId = 504;
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(VERB_PUT, 0x131, 0x251))
+		_vm->_dialogs->show(50113);
+	else if (_action.isAction(VERB_PUT, 0x305, 0x251)) {
+		switch (_game._trigger) {
+		case 0:
+		case 1:
+		case 2:
+		case 3:
+			handleSlotActions();
+			break;
+
+		case 4:
+			if (_globals[kSexOfRex] == REX_MALE) {
+				_game._player._visible = false;
+				_vm->_sound->command(13);
+				_scene->loadAnimation(formAnimName('G', 1), 5);
+			} else {
+				_rexPunched = false;
+				_scene->_kernelMessages.reset();
+				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 6, 120, _game.getQuote(0x277));
+			}
+			break;
+
+		case 5:
+			_game._player._visible = true;
+			_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+			_scene->_sequences.addTimer(30, 6);
+			break;
+
+		case 6:
+			if (_globals[kSexOfRex] == REX_MALE) {
+				if (_rexPunched) {
+					_scene->_kernelMessages.reset();
+					_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x275));
+					_rexPunched = false;
+				} else {
+					_scene->_kernelMessages.reset();
+					_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x276));
+				}
+			}
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(VERB_PUT, 0xB3, 0x251)) {
+		switch (_game._trigger) {
+		case 0:
+		case 1:
+		case 2:
+		case 3:
+			handleSlotActions();
+
+		case 4:
+			_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+			_scene->_dynamicHotspots.remove(_doorHotspotid);
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 9, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 7);
+			_vm->_sound->command(11);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 6);
+			break;
+
+		case 6:
+			_game._player.walk(Common::Point(317, 102), FACING_NORTHEAST);
+			_scene->_sequences.addTimer(120, 7);
+			break;
+
+		case 7: {
+			_vm->_sound->command(12);
+			int syncIdx = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 9, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 7);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], syncIdx);
+			_vm->_sound->command(12);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 8);
+			}
+			break;
+
+		case 8: {
+			int syncIdx = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 7);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], syncIdx);
+			_scene->_nextSceneId = 503;
+			}
+			break;
+
+		default:
+			break;
+		}
+	} else if ((_action._lookFlag) || _action.isAction(VERB_LOOK, 0x31E))
+		_vm->_dialogs->show(50121);
+	else if (_action.isAction(VERB_LOOK, 0x6E))
+		_vm->_dialogs->show(50110);
+	else if (_action.isAction(VERB_LOOK, 0x251))
+		_vm->_dialogs->show(50112);
+	else if (_action.isAction(VERB_LOOK, 0x244))
+		_vm->_dialogs->show(50114);
+	else if (_action.isAction(VERB_TAKE, 0x244))
+		_vm->_dialogs->show(50115);
+	else if (_action.isAction(VERB_LOOK, 0x322))
+		_vm->_dialogs->show(50118);
+	else if (_action.isAction(VERB_LOOK, 0x361) || _action.isAction(VERB_LOOK, 0x360)
+		|| _action.isAction(0x1AD, 0x361) || _action.isAction(0x1AD, 0x360))
+		_vm->_dialogs->show(50119);
+	else if (_action.isAction(VERB_LOOK, 0x323))
+		_vm->_dialogs->show(50120);
+	else if (_action.isAction(VERB_OPEN, 0x6E))
+		_vm->_dialogs->show(50122);
+	else if (_action.isAction(VERB_LOOK, 0x1E6))
+		_vm->_dialogs->show(50123);
+	else if (_action.isAction(VERB_OPEN, 0x1E6))
+		_vm->_dialogs->show(50124);
+	else if (_action.isAction(VERB_LOOK, 0x369))
+		_vm->_dialogs->show(50125);
+	else if (_action.isAction(VERB_LOOK, 0x1FA) || _action.isAction(VERB_LOOK, 0x10C))
+		_vm->_dialogs->show(50126);
+	else if (_action.isAction(VERB_LOOK, 0x324)) {
+		if (!_game._visitedScenes.exists(504))
+			_vm->_dialogs->show(50116);
+		else
+			_vm->_dialogs->show(50117);
+	} else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene502::setup() {
 	_game._player._spritesPrefix = "";
 	// The original is using Scene5xx_setAAName()
@@ -132,12 +497,12 @@ void Scene502::actions() {
 	else if (_action.isAction(VERB_LOOK, 0x1CC))
 		_vm->_dialogs->show(50212);
 	else if (_action.isAction(VERB_LOOK, 0x1D0) || _action.isAction(VERB_LOOK, 0x1D1)
-	  || _action.isAction(VERB_LOOK, 0x1D2) || _action.isAction(VERB_LOOK, 0x1D3)
-	  || _action.isAction(VERB_LOOK, 0x1D4) || _action.isAction(VERB_LOOK, 0x1D5)
-	  || _action.isAction(VERB_LOOK, 0x1D6) || _action.isAction(VERB_LOOK, 0x1D7)
-	  || _action.isAction(VERB_LOOK, 0x1D8) || _action.isAction(VERB_LOOK, 0x1D9)
-	  || _action.isAction(VERB_LOOK, 0x1DB) || _action.isAction(VERB_LOOK, 0x7A)
-	  || _action.isAction(VERB_LOOK, 0x1DA))
+	 || _action.isAction(VERB_LOOK, 0x1D2) || _action.isAction(VERB_LOOK, 0x1D3)
+	 || _action.isAction(VERB_LOOK, 0x1D4) || _action.isAction(VERB_LOOK, 0x1D5)
+	 || _action.isAction(VERB_LOOK, 0x1D6) || _action.isAction(VERB_LOOK, 0x1D7)
+	 || _action.isAction(VERB_LOOK, 0x1D8) || _action.isAction(VERB_LOOK, 0x1D9)
+	 || _action.isAction(VERB_LOOK, 0x1DB) || _action.isAction(VERB_LOOK, 0x7A)
+	 || _action.isAction(VERB_LOOK, 0x1DA))
 		_vm->_dialogs->show(50213);
 	else if (_action.isAction(VERB_LOOK, 0x1CF) || _action._lookFlag)
 		_vm->_dialogs->show(50214);
diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
index 562cfdf..e46207c 100644
--- a/engines/mads/nebular/nebular_scenes5.h
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -50,6 +50,26 @@ public:
 	Scene5xx(MADSEngine *vm) : NebularScene(vm) {}
 };
 
+class Scene501: public Scene5xx{
+private:
+	int _mainSequenceId;
+	int _mainSpriteId;
+	int _doorHotspotid;
+	bool _rexPunched;
+
+	void handleSlotActions();
+
+public:
+	Scene501(MADSEngine *vm) : Scene5xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 class Scene502: public SceneTeleporter {
 public:
 	Scene502(MADSEngine *vm) : SceneTeleporter(vm) {}


Commit: da3d8f746ca9bac36b995621c8b7d3be2068eecf
    https://github.com/scummvm/scummvm/commit/da3d8f746ca9bac36b995621c8b7d3be2068eecf
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-06T22:12:31+02:00

Commit Message:
MADS: Implement scene 503

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes5.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 08b01fe..6660627 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -201,7 +201,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 502:	// inside male only teleporter
 		return new Scene502(vm);
 	case 503:	// guard tower
-		return new DummyScene(vm);	// TODO
+		return new Scene503(vm);
 	case 504:	// inside car
 		return new DummyScene(vm);	// TODO
 	case 505:	// car view screen
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index db6e6da..da8faa0 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -514,5 +514,127 @@ void Scene502::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene503::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x6A);
+	_scene->addActiveVocab(0xD);
+}
+
+void Scene503::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', -1));
+
+	if (_globals[kSexOfRex] == REX_MALE)
+		_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RXMBD_2");
+	else
+		_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*ROXBD_2");
+
+	if (_game._objects[OBJ_DETONATORS]._roomNumber == _scene->_currentSceneId) {
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 9, 0, 0, 0);
+		_detonatorHotspotId = _scene->_dynamicHotspots.add(0x6A, 0xD, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(_detonatorHotspotId, Common::Point(254, 135), FACING_SOUTH);
+	}
+
+	if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(191, 152);
+		_game._player._facing = FACING_NORTHWEST;
+	}
+
+	sceneEntrySound();
+}
+
+void Scene503::actions() {
+	if (_action.isAction(0x32F, 0xF9))
+		_scene->_nextSceneId = 501;
+	else if (_action.isAction(VERB_TAKE, 0x6A)) {
+		if ( _game._trigger || !_game._objects.isInInventory(OBJ_DETONATORS)) {
+			switch (_game._trigger) {
+			case 0:
+				_game._player._stepEnabled   = false;
+				_game._player._visible     = false;  
+				if (_globals[kSexOfRex] == REX_MALE) {
+					_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+					_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 3);
+					_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 3, 1);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				} else {
+					_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], true, 8, 1, 0, 0);
+					_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 4);
+					_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 4, 1);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				}
+				break;
+
+			case 1:
+				_vm->_sound->command(9);
+				_scene->_sequences.remove(_globals._sequenceIndexes[1]);  
+				_scene->_dynamicHotspots.remove(_detonatorHotspotId);
+				_game._objects.addToInventory(OBJ_DETONATORS);
+				_vm->_dialogs->showItem(OBJ_DETONATORS, 50326);
+				break;
+
+			case 2:
+				if (_globals[kSexOfRex] == REX_MALE)
+					_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[2]);
+				else
+					_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[3]);
+
+				_game._player._visible   = true;
+				_game._player._stepEnabled = true;
+				break;
+
+			default:
+				break;
+			}                 
+		}
+	} else if (_action._lookFlag)
+		_vm->_dialogs->show(50328);
+	else if (_action.isAction(VERB_LOOK, 0x36F))
+		_vm->_dialogs->show(50310);
+	else if (_action.isAction(VERB_LOOK, 0x36E))
+		_vm->_dialogs->show(50311);
+	else if (_action.isAction(VERB_TAKE, 0x36E) || _action.isAction(VERB_TAKE, 0x36C))
+		_vm->_dialogs->show(50312);
+	else if (_action.isAction(VERB_LOOK, 0x36D))
+		_vm->_dialogs->show(50313);
+	else if (_action.isAction(VERB_LOOK, 0x36C))
+		_vm->_dialogs->show(50314);
+	else if (_action.isAction(VERB_LOOK, 0x331))
+		_vm->_dialogs->show(50315);
+	else if (_action.isAction(VERB_LOOK, 0x330))
+		_vm->_dialogs->show(50316);
+	else if (_action.isAction(VERB_OPEN, 0x330))
+		_vm->_dialogs->show(50317);
+	else if (_action.isAction(VERB_LOOK, 0x36B))
+		_vm->_dialogs->show(50318);
+	else if (_action.isAction(VERB_LOOK, 0x1E4))
+		_vm->_dialogs->show(50319);
+	else if (_action.isAction(VERB_LOOK, 0xE2))
+		_vm->_dialogs->show(50320);
+	else if (_action.isAction(VERB_LOOK, 0x481))
+		_vm->_dialogs->show(50322);
+	else if (_action.isAction(VERB_LOOK, 0x332)) {
+		if (_game._objects.isInRoom(OBJ_DETONATORS))
+			_vm->_dialogs->show(50323);
+		else
+			_vm->_dialogs->show(50324);
+	} else if (_action.isAction(VERB_LOOK, 0x6A) && (_action._savedFields._mainObjectSource == 4))
+		_vm->_dialogs->show(50325);
+	else if (_action.isAction(VERB_LOOK, 0x32E))
+		_vm->_dialogs->show(50327);
+	else if (_action.isAction(VERB_OPEN, 0x36D))
+		_vm->_dialogs->show(50329);
+	else if (_action.isAction(0xC, 0x36D) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId)))
+		_vm->_dialogs->show(50330);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
index e46207c..0b29c92 100644
--- a/engines/mads/nebular/nebular_scenes5.h
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -82,8 +82,22 @@ public:
 	virtual void postActions() {};
 };
 
-} // End of namespace Nebular
+class Scene503: public Scene5xx{
+private:
+	int _detonatorHotspotId;
+
+public:
+	Scene503(MADSEngine *vm) : Scene5xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
 
+} // End of namespace Nebular
 } // End of namespace MADS
 
 #endif /* MADS_NEBULAR_SCENES5_H */


Commit: b36b6185bee6c4a33dec43d6eb1e13a8bbfef18b
    https://github.com/scummvm/scummvm/commit/b36b6185bee6c4a33dec43d6eb1e13a8bbfef18b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-07T01:09:19+03:00

Commit Message:
MADS: Implement Rex Nebular scene 710

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes7.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 6660627..7aaaa9e 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -265,7 +265,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 707:	// teleporter
 		return new Scene707(vm);
 	case 710:	// looking at pedestral room through binoculars
-		return new DummyScene(vm);	// TODO
+		return new Scene710(vm);
 	case 711:	// inside teleporter
 		return new Scene711(vm);
 	case 751:	// outside elevator (before city is submerged)
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 53b408c..eb67422 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -141,6 +141,49 @@ void Scene707::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene710::setup() {
+	_game._player._spritesPrefix = "";
+	setAAName();
+}
+
+void Scene710::enter() {
+	_game._scene._userInterface.setup(kInputLimitedSentences);
+
+	if (_game._objects[OBJ_VASE]._roomNumber == 706) {
+		_game._globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('g', -1));
+		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
+	}
+
+	_game._player._visible = false;
+	_game._scene._sequences.addTimer(600, 70);
+
+	sceneEntrySound();
+}
+
+void Scene710::step() {
+	if (_game._trigger == 70) {
+		if (_game._globals[kCityFlooded])
+			_game._scene._nextSceneId = 701;
+		else
+			_game._scene._nextSceneId = 751;
+	}
+}
+
+void Scene710::actions() {
+	if (_game._scene._action.isAction(0x46F, 0x27)) {
+		_game._player._stepEnabled = false;
+
+		if (_game._globals[kCityFlooded])
+			_game._scene._nextSceneId = 701;
+		else
+			_game._scene._nextSceneId = 751;
+
+		_action._inProgress = false;
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene711::setup() {
 	// The original was calling Scene7xx::setPlayerSpreitesPrefix()
 	_vm->_sound->command(5);
diff --git a/engines/mads/nebular/nebular_scenes7.h b/engines/mads/nebular/nebular_scenes7.h
index 080c639..0f4947f 100644
--- a/engines/mads/nebular/nebular_scenes7.h
+++ b/engines/mads/nebular/nebular_scenes7.h
@@ -62,6 +62,18 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene710: public Scene7xx {
+public:
+	Scene710(MADSEngine *vm) : Scene7xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 class Scene711: public SceneTeleporter {
 public:
 	Scene711(MADSEngine *vm) : SceneTeleporter(vm) {}


Commit: bd136a1c87b764de58b2e60dd8f14bb3c33dda40
    https://github.com/scummvm/scummvm/commit/bd136a1c87b764de58b2e60dd8f14bb3c33dda40
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-07T04:50:17+03:00

Commit Message:
MADS: Implement Rex Nebular scene 752

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes7.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 7aaaa9e..19c9824 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -271,7 +271,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 751:	// outside elevator (before city is submerged)
 		return new DummyScene(vm);	// TODO
 	case 752:	// outside teleporter (before city is submerged)
-		return new DummyScene(vm);	// TODO
+		return new Scene752(vm);
 
 	// Scene group #8
 	case 801:	// control room, outside teleporter
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index eb67422..54acabf 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -147,15 +147,15 @@ void Scene710::setup() {
 }
 
 void Scene710::enter() {
-	_game._scene._userInterface.setup(kInputLimitedSentences);
+	_scene->_userInterface.setup(kInputLimitedSentences);
 
 	if (_game._objects[OBJ_VASE]._roomNumber == 706) {
-		_game._globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('g', -1));
+		_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('g', -1));
 		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
 	}
 
 	_game._player._visible = false;
-	_game._scene._sequences.addTimer(600, 70);
+	_scene->_sequences.addTimer(600, 70);
 
 	sceneEntrySound();
 }
@@ -163,20 +163,20 @@ void Scene710::enter() {
 void Scene710::step() {
 	if (_game._trigger == 70) {
 		if (_game._globals[kCityFlooded])
-			_game._scene._nextSceneId = 701;
+			_scene->_nextSceneId = 701;
 		else
-			_game._scene._nextSceneId = 751;
+			_scene->_nextSceneId = 751;
 	}
 }
 
 void Scene710::actions() {
-	if (_game._scene._action.isAction(0x46F, 0x27)) {
+	if (_action.isAction(0x46F, 0x27)) {
 		_game._player._stepEnabled = false;
 
 		if (_game._globals[kCityFlooded])
-			_game._scene._nextSceneId = 701;
+			_scene->_nextSceneId = 701;
 		else
-			_game._scene._nextSceneId = 751;
+			_scene->_nextSceneId = 751;
 
 		_action._inProgress = false;
 	}
@@ -229,5 +229,187 @@ void Scene711::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene752::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+
+	_scene->addActiveVocab(0xB3);
+	_scene->addActiveVocab(VERB_WALKTO);
+	_scene->addActiveVocab(0xD1);
+	_scene->addActiveVocab(0x343);
+}
+
+void Scene752::enter() {
+	_globals._spriteIndexes[14] = _scene->_sprites.addSprites(formAnimName('l', -1));
+	_globals._spriteIndexes[12] = _scene->_sprites.addSprites("*RXMBD_8");
+
+	if (_scene->_priorSceneId == 751) {
+		_game._player._playerPos = Common::Point(13, 145);
+		_game._player._facing = FACING_EAST;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(289, 138);
+		_game._player.walk(Common::Point(262, 148), FACING_WEST);
+		_game._player._facing = FACING_WEST;
+		_game._player._visible = true;
+	}
+
+	if (_game._objects[OBJ_ID_CARD]._roomNumber == 752) {
+		_globals._spriteIndexes[13] = _scene->_sprites.addSprites(formAnimName('i', -1));
+		_globals._sequenceIndexes[13] =  _scene->_sequences.startCycle(_globals._spriteIndexes[13], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		int idx = _scene->_dynamicHotspots.add(0xB3, VERB_WALKTO, _globals._sequenceIndexes[13], Common::Rect(0, 0, 0, 0));
+		_cardId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(234, 135), FACING_NORTH);
+	}
+
+	if (_game._globals[kLaserHoleIsThere]) {
+		_globals._sequenceIndexes[14] =  _scene->_sequences.startCycle(_globals._spriteIndexes[14], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[14], 13);
+		int idx = _scene->_dynamicHotspots.add(0x343, 0xD1, _globals._sequenceIndexes[14], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(215, 130), FACING_NORTHWEST);
+	}
+
+	if (_game._globals[kTeleporterCommand]) {
+		switch(_game._globals[kTeleporterCommand]) {
+		case TELEPORTER_BEAM_OUT:
+		case TELEPORTER_WRONG:
+		case TELEPORTER_STEP_OUT:
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			break;
+		default:
+			break;
+		}
+
+		_game._globals[kTeleporterCommand] = TELEPORTER_NONE;
+	}
+
+	if (_globals._timebombTimer > 0)
+		_globals._timebombTimer = 10800 - 600;
+
+	sceneEntrySound();
+}
+
+void Scene752::step() {
+	if (_globals._timebombTimer >= 10800 && _game._globals[kTimebombStatus] == TIMEBOMB_ACTIVATED) {
+		_globals[kTimebombStatus] = TIMEBOMB_DEAD;
+		_globals._timebombTimer = 0;
+		_globals[kCheckDaemonTimebomb] = false;
+		_scene->_nextSceneId = 620;
+	}
+}
+
+void Scene752::preActions() {
+	if (_action.isAction(VERB_WALKTO, 0x4A9)) {
+		_game._player._walkOffScreenSceneId = 751;
+	}
+}
+
+void Scene752::actions() {
+	if (_action.isAction(0x312, 0x22C)) {
+		_action._inProgress = false;
+	} else if (_action.isAction(0x2F9, 0x16C)) {
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_scene->_nextSceneId = 711;
+		_action._inProgress = false;
+	} else if (_action.isAction(VERB_TAKE, 0xB3)) {
+		// Take ID card
+		if (!_game._objects.isInInventory(OBJ_ID_CARD) || _game._trigger) {
+			switch (_game._trigger) {
+			case 0:
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				_globals._sequenceIndexes[12] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[12], false, 5, 2, 0, 0);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[12]);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_SPRITE, 4, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				break;
+			case 1:
+				_vm->_sound->command(0xF);
+				_scene->_sequences.remove(_globals._sequenceIndexes[13]);
+				_game._objects.addToInventory(OBJ_ID_CARD);
+				_scene->_dynamicHotspots.remove(_cardId);
+				_vm->_dialogs->show(OBJ_ID_CARD, 830);
+				break;
+			case 2:
+				_game._player._visible = true;
+				_game._player._stepEnabled = true;
+				break;
+			default:
+				break;
+			}
+
+			_action._inProgress = false;
+		}
+	} else if (_action.isAction(VERB_TAKE, 0x2D) && _action._mainObjectSource == 4) {
+		// Take bones
+		if (!_game._objects.isInInventory(OBJ_BONES) || _game._trigger) {
+			switch (_game._trigger) {
+			case 0:
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				_globals._sequenceIndexes[12] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[12], false, 5, 2, 0, 0);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[12]);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_SPRITE, 4, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				break;
+			case 1:
+				_vm->_sound->command(0xF);
+				if (_game._objects.isInInventory(OBJ_BONE))
+					_game._objects.setRoom(OBJ_BONE, NOWHERE);
+				_game._objects.addToInventory(OBJ_BONES);
+				_vm->_dialogs->show(OBJ_BONES, 75221);
+				break;
+			case 2:
+				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[12]);
+				_game._player._visible = true;
+				_game._player._stepEnabled = true;
+				break;
+			default:
+				break;
+			}
+
+			_action._inProgress = false;
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x38F)) {
+		if (_globals[kLaserHoleIsThere])
+			_vm->_dialogs->show(75212);
+		else
+			_vm->_dialogs->show(75210);
+
+		_action._inProgress = false;
+	} else if (_action.isAction(VERB_LOOK, 0x22C)) {
+		_vm->_dialogs->show(75213);
+		_action._inProgress = false;
+	} else if (_action.isAction(VERB_LOOK, 0x38E)) {
+		_vm->_dialogs->show(75214);
+		_action._inProgress = false;
+	} else if (_action.isAction(VERB_LOOK, 0x128)) {
+		_vm->_dialogs->show(75215);
+		_action._inProgress = false;
+	} else if (_action.isAction(VERB_TAKE, 0x128)) {
+		_vm->_dialogs->show(75216);
+		_action._inProgress = false;
+	} else if (_action.isAction(VERB_LOOK, 0x4A9)) {
+		_vm->_dialogs->show(75217);
+		_action._inProgress = false;
+	} else if (_action.isAction(VERB_LOOK, 0x16C)) {
+		_vm->_dialogs->show(75218);
+		_action._inProgress = false;
+	} else if ((_action.isAction(VERB_LOOK, 0x2D) || _action.isAction(VERB_LOOK, 0xB3)) && _action._mainObjectSource == 4) {
+		if (_game._objects[OBJ_ID_CARD]._roomNumber == 752)
+			_vm->_dialogs->show(75219);
+		else
+			_vm->_dialogs->show(75220);
+		_action._inProgress = false;
+	} else if (_action.isAction(VERB_TAKE, 0x2D) && _action._mainObjectSource == 4) {
+		if (_game._objects.isInInventory(OBJ_BONES))
+			_vm->_dialogs->show(75222);
+		_action._inProgress = false;
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes7.h b/engines/mads/nebular/nebular_scenes7.h
index 0f4947f..546f024 100644
--- a/engines/mads/nebular/nebular_scenes7.h
+++ b/engines/mads/nebular/nebular_scenes7.h
@@ -86,6 +86,21 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene752: public Scene7xx {
+private:
+	int _cardId;
+
+public:
+	Scene752(MADSEngine *vm) : Scene7xx(vm), _cardId(-1) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 0c079f4d6958e295a2c4d666d106c66505d55380
    https://github.com/scummvm/scummvm/commit/0c079f4d6958e295a2c4d666d106c66505d55380
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-06T22:49:57-04:00

Commit Message:
MADS: Fixes for correctly setting up grey fading palette intensities

Changed paths:
    engines/mads/palette.cpp
    engines/mads/palette.h
    engines/mads/staticres.cpp
    engines/mads/staticres.h



diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index aa227bf..6beaad9 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -442,8 +442,8 @@ void Fader::mapToGreyRamp(byte palette[PALETTE_SIZE], int baseColor, int numColo
 	int greyAccum = 0;
 	int firstColor = 0;
 
-	for (int greyCtr = 0; greyCtr < 64; greyCtr++) {
-		for (int idx = 0; idx < greyTable[greyCtr]; idx++) {
+	for (int greyCtr = 0; greyCtr < 64; ++greyCtr) {
+		for (int idx = 0; idx < greyTable[greyCtr]; ++idx) {
 			greySum += greyList[greyScan++]._list;
 			++greyColors;
 
@@ -467,7 +467,7 @@ void Fader::mapToGreyRamp(byte palette[PALETTE_SIZE], int baseColor, int numColo
 		}
 	}
 
-	// Process palette with intensities
+	// Set the palette range of greyscale values to be used
 	byte *palP = &palette[baseGrey * 3];
 	for (int greys = 0; greys < numGreys; ++greys) {
 		for (int color = 0; color < 3; ++color) {
@@ -499,9 +499,8 @@ void Fader::getGreyValues(const byte palette[PALETTE_SIZE],
 void Fader::greyPopularity(const GreyTableEntry greyList[PALETTE_COUNT], 
 		byte greyTable[64], int numColors) {
 	Common::fill(&greyTable[0], &greyTable[64], 0);
-	for (int i = 0; i < 64; ++i) {
+	for (int i = 0; i < numColors; ++i) {
 		int idx = greyList[i]._list;
-		assert(idx >= 0 && idx < 64);
 		++greyTable[idx];
 	}
 }
@@ -645,7 +644,13 @@ void Palette::initVGAPalette(byte *palette) {
 	byte *destP = palette;
 	for (int palIndex = 0; palIndex < 16; ++palIndex) {
 		for (int byteCtr = 2; byteCtr >= 0; --byteCtr)
-			*destP++ = ((DEFAULT_VGA_PALETTE[palIndex] >> (8 * byteCtr)) & 0xff) >> 2;
+			*destP++ = ((DEFAULT_VGA_LOW_PALETTE[palIndex] >> (8 * byteCtr)) & 0xff) >> 2;
+	}
+
+	destP = &palette[0xF0 * 3];
+	for (int palIndex = 0; palIndex < 16; ++palIndex) {
+		for (int byteCtr = 2; byteCtr >= 0; --byteCtr)
+			*destP++ = ((DEFAULT_VGA_HIGH_PALETTE[palIndex] >> (8 * byteCtr)) & 0xff) >> 2;
 	}
 }
 
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 1beadd4..9bf5bfa 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -220,9 +220,15 @@ public:
 		setPalette(&palette[0], 0, PALETTE_COUNT);
 	}
 
-	int rgbMerge(byte r, byte g, byte b);
+	/**
+	* Calculates a merge/hash for a given palette entry
+	*/
+	static int rgbMerge(byte r, byte g, byte b);
 
-	int rgbMerge(RGB6 &palEntry);
+	/**
+	* Calculates a merge/hash for a given palette entry
+	*/
+	static int rgbMerge(RGB6 &palEntry);
 
 	/**
 	* Fades the given palette to greyscale
diff --git a/engines/mads/staticres.cpp b/engines/mads/staticres.cpp
index 396e5a1..189e5f7 100644
--- a/engines/mads/staticres.cpp
+++ b/engines/mads/staticres.cpp
@@ -45,9 +45,14 @@ const char *const kOverStr = "over";
 const char *const kGameReleaseInfoStr = "ScummVM rev: 8.43 14-Sept-92";
 const char *const kGameReleaseTitleStr = "GAME RELASE VERSION INFO";
 
-const uint32 DEFAULT_VGA_PALETTE[16] = {
+const uint32 DEFAULT_VGA_LOW_PALETTE[16] = {
 	0x000000, 0x0000a8, 0x00a800, 0x00a8a8, 0xa80000, 0xa800a8, 0xa85400, 0xa8a8a8,
 	0x545454, 0x5454fc, 0x54fc54, 0x54fcfc, 0xfc5454, 0xfc54fc, 0xfcfc54, 0xfcfcfc
 };
 
+const uint32 DEFAULT_VGA_HIGH_PALETTE[16] = {
+	0x2c402c, 0x2c4030, 0x2c4034, 0x2c403c, 0x2c4040, 0x2c3c40, 0x2c3440, 0x2c3040,
+	0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000
+};
+
 } // End of namespace MADS
diff --git a/engines/mads/staticres.h b/engines/mads/staticres.h
index 0680455..560fd12 100644
--- a/engines/mads/staticres.h
+++ b/engines/mads/staticres.h
@@ -39,7 +39,8 @@ extern const char *const kOverStr;
 extern const char *const kGameReleaseInfoStr;
 extern const char *const kGameReleaseTitleStr;
 
-extern const uint32 DEFAULT_VGA_PALETTE[16];
+extern const uint32 DEFAULT_VGA_LOW_PALETTE[16];
+extern const uint32 DEFAULT_VGA_HIGH_PALETTE[16];
 
 } // End of namespace MADS
 


Commit: b3cc8db37012aaf035a58adf5a3232ea056f5d95
    https://github.com/scummvm/scummvm/commit/b3cc8db37012aaf035a58adf5a3232ea056f5d95
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-07T07:03:52+02:00

Commit Message:
MADS: Rename difficulty constants to match IDB, implement scene 504

Changed paths:
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/game_nebular.h
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes5.h



diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 546fdbe..9d6bf89 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -38,7 +38,7 @@ namespace Nebular {
 GameNebular::GameNebular(MADSEngine *vm): Game(vm) {
 	_surface = new MSurface(MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT);
 	_storyMode = STORYMODE_NAUGHTY;
-	_difficulty = DIFFICULTY_IMPOSSIBLE;
+	_difficulty = DIFFICULTY_EASY;
 }
 
 ProtectionResult GameNebular::checkCopyProtection() {
@@ -212,7 +212,7 @@ void GameNebular::initialiseGlobals() {
 		_globals[kLeavesStatus] = LEAVES_ON_TRAP;
 		break;
 
-	case DIFFICULTY_REALLY_HARD:
+	case DIFFICULTY_MEDIUM:
 		_objects.setRoom(OBJ_PLANT_STALK, NOWHERE);
 
 		_globals[kLeavesStatus] = LEAVES_ON_GROUND;
@@ -220,7 +220,7 @@ void GameNebular::initialiseGlobals() {
 		_globals[kPenlightCellStatus] = FIRST_TIME_CHARGED_DURAFAIL;
 		break;
 
-	case DIFFICULTY_IMPOSSIBLE:
+	case DIFFICULTY_EASY:
 		_objects.setRoom(OBJ_BLOWGUN, NOWHERE);
 		_objects.setRoom(OBJ_NOTE, NOWHERE);
 
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index 0c859fa..e754a11 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -35,7 +35,7 @@ namespace Nebular {
 enum StoryMode { STORYMODE_NAUGHTY = 1, STORYMODE_NICE = 2 };
 
 enum Difficulty {
-	DIFFICULTY_HARD = 1, DIFFICULTY_REALLY_HARD = 2, DIFFICULTY_IMPOSSIBLE = 3
+	DIFFICULTY_HARD = 1, DIFFICULTY_MEDIUM = 2, DIFFICULTY_EASY = 3
 };
 
 enum InventoryObject {
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 19c9824..e7da6cf 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -203,7 +203,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 503:	// guard tower
 		return new Scene503(vm);
 	case 504:	// inside car
-		return new DummyScene(vm);	// TODO
+		return new Scene504(vm);
 	case 505:	// car view screen
 		return new DummyScene(vm);	// TODO
 	case 506:	// shopping street
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index f68a613..08c5b08 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -977,7 +977,7 @@ void Scene102::actions() {
 				_action._inProgress = false;
 				return;
 			}
-		} else if (_action.isAction(VERB_LOOK) || (_game._difficulty != DIFFICULTY_IMPOSSIBLE)) {
+		} else if (_action.isAction(VERB_LOOK) || (_game._difficulty != DIFFICULTY_EASY)) {
 			_vm->_dialogs->show(0x27EE);
 			_action._inProgress = false;
 			return;
@@ -2519,7 +2519,7 @@ void Scene109::actions() {
 							break;
 
 						case OBJ_BURGER:
-							_hoovicDifficultFl = (_game._difficulty == DIFFICULTY_IMPOSSIBLE);
+							_hoovicDifficultFl = (_game._difficulty == DIFFICULTY_EASY);
 							_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('H', (_hoovicDifficultFl ? 3 : 1)));
 							break;
 						}
@@ -2592,7 +2592,7 @@ void Scene109::actions() {
 								case DIFFICULTY_HARD:
 									threshold = 1;
 									break;
-								case DIFFICULTY_REALLY_HARD:
+								case DIFFICULTY_MEDIUM:
 									threshold = 3;
 									break;
 								default:
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index c4f5fe3..46a2a78 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1673,7 +1673,7 @@ void Scene208::actions() {
 	} else if (_action.isAction(VERB_LOOK, NOUN_PILE_OF_LEAVES)) {
 		_vm->_dialogs->show(0x5149);
 	} else if (_action.isAction(VERB_LOOK, NOUN_LEAF_COVERED_PIT)) {
-		if (_game._difficulty == DIFFICULTY_IMPOSSIBLE)
+		if (_game._difficulty == DIFFICULTY_EASY)
 			_vm->_dialogs->show(0x514A);
 		else
 			_vm->_dialogs->show(0x514B);
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index b8d07d9..17c310d 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -2271,7 +2271,7 @@ void Scene316::actions() {
 		_vm->_dialogs->show(0x7B82);
 	else if (_action.isAction(VERB_LOOK, 0x2B9)) {
 		if (!_globals[kAfterHavoc]) {
-			if (_game._difficulty != DIFFICULTY_IMPOSSIBLE)
+			if (_game._difficulty != DIFFICULTY_EASY)
 				_vm->_dialogs->show(0x7B84);
 			else
 				_vm->_dialogs->show(0x7B83);
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index da8faa0..3e888ac 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -550,8 +550,8 @@ void Scene503::actions() {
 		if ( _game._trigger || !_game._objects.isInInventory(OBJ_DETONATORS)) {
 			switch (_game._trigger) {
 			case 0:
-				_game._player._stepEnabled   = false;
-				_game._player._visible     = false;  
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
 				if (_globals[kSexOfRex] == REX_MALE) {
 					_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
 					_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 3);
@@ -569,7 +569,7 @@ void Scene503::actions() {
 
 			case 1:
 				_vm->_sound->command(9);
-				_scene->_sequences.remove(_globals._sequenceIndexes[1]);  
+				_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 				_scene->_dynamicHotspots.remove(_detonatorHotspotId);
 				_game._objects.addToInventory(OBJ_DETONATORS);
 				_vm->_dialogs->showItem(OBJ_DETONATORS, 50326);
@@ -581,13 +581,13 @@ void Scene503::actions() {
 				else
 					_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[3]);
 
-				_game._player._visible   = true;
+				_game._player._visible = true;
 				_game._player._stepEnabled = true;
 				break;
 
 			default:
 				break;
-			}                 
+			}
 		}
 	} else if (_action._lookFlag)
 		_vm->_dialogs->show(50328);
@@ -636,5 +636,202 @@ void Scene503::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene504::setup() {
+	_game._player._spritesPrefix = "";
+	setAAName();
+}
+
+void Scene504::enter() {
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 2));
+
+	for (int i = 0; i < 4; i++)
+		_globals._spriteIndexes[5 + i] = _scene->_sprites.addSprites(formAnimName('m', i));
+
+	if (_globals[kSexOfRex] == REX_MALE)
+		_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('a', 0));
+	else {
+		_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('a', 1));
+		_scene->changeVariant(1);
+	}
+
+	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 1, 0, 0);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 0);
+	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 0);
+	_carFrame = -1;
+
+	if ((_scene->_priorSceneId == 505) && (_globals[kHoverCarDestination] != _globals[kHoverCarLocation])){
+		_carAnimationMode = 1;
+		_scene->loadAnimation(formAnimName('A', -1));
+		_vm->_sound->command(14);
+		_scene->_sequences.addTimer(1, 70);
+		_game._player._stepEnabled = false;
+	} else {
+		_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 3));
+		_carAnimationMode = 1;
+		_scene->loadAnimation(formAnimName('A', -1));
+		if ((_scene->_priorSceneId != -2) && (_scene->_priorSceneId != 505))
+			_globals[kHoverCarLocation] = _scene->_priorSceneId;
+
+		_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, 1);
+	}
+
+	if (_globals[kTimebombTimer] > 10500)
+		_globals[kTimebombTimer] = 10500;
+
+	sceneEntrySound();
+}
+
+void Scene504::step() {
+	if ((_carAnimationMode == 1) && (_scene->_activeAnimation != nullptr)) {
+		if (_scene->_activeAnimation->getCurrentFrame() != _carFrame) {
+			_carFrame = _scene->_activeAnimation->getCurrentFrame();
+			int nextFrame;
+
+			if (_carFrame == 1)
+				nextFrame = 0;
+			else
+				nextFrame = -1;
+
+			if ((nextFrame >= 0) && (nextFrame != _scene->_activeAnimation->getCurrentFrame())) {
+				_scene->_activeAnimation->setCurrentFrame(nextFrame);
+				_carFrame = nextFrame;
+			}
+		}
+	}
+
+
+	if (_game._trigger >= 70) {
+		switch (_game._trigger) {
+		case 70:
+			if (_globals[kHoverCarDestination] != -1) {
+				_game._player._stepEnabled = false;
+				_scene->freeAnimation();
+				_carAnimationMode = 2;
+				if (((_globals[kHoverCarLocation] >= 500 && _globals[kHoverCarLocation] <= 599) &&
+					(_globals[kHoverCarDestination] >= 500 && _globals[kHoverCarDestination] <= 599)) ||
+					((_globals[kHoverCarLocation] >= 600 && _globals[kHoverCarLocation] <= 699) &&
+					(_globals[kHoverCarDestination] >= 600 && _globals[kHoverCarDestination] <= 699))) {
+						_scene->loadAnimation(formAnimName('A', -1), 71);
+				} else if (_globals[kHoverCarLocation] > _globals[kHoverCarDestination])
+					_scene->loadAnimation(formAnimName('C', -1), 71);
+				else
+					_scene->loadAnimation(formAnimName('B', -1), 71);
+			}
+			break;
+
+		case 71:
+			_vm->_sound->command(15);
+			_scene->_nextSceneId = _globals[kHoverCarDestination];
+			break;
+
+		default:
+			break;
+		}
+	}
+
+	if ((_globals[kTimebombTimer] >= 10800) && (_globals[kTimebombStatus] == 1) && (_game._difficulty != 3)) {
+		_globals[kTimebombStatus] = TIMEBOMB_DEAD;
+		_globals[kTimebombTimer] = 0;
+		_globals[kCheckDaemonTimebomb] = false;
+		_scene->_nextSceneId = 620;
+	}
+}
+
+void Scene504::preActions() {
+	_game._player._needToWalk = false;
+}
+
+void Scene504::actions() {
+	if (_action.isAction(0x1CE, 0x324)) {
+		_vm->_sound->command(15);
+		_scene->_nextSceneId = _globals[kHoverCarLocation];
+	} else if (_action.isAction(0xE, 0x380)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_vm->_sound->command(39);
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 13);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			_scene->_sequences.remove(_globals._sequenceIndexes[7]);
+			_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 18, 0, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 14);
+			break;
+
+		case 1: {
+			int syncIdx = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 13);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 6);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], syncIdx);
+			}
+			break;
+
+		case 2:
+			_scene->_sequences.addTimer(10, 3);
+			break;
+
+		case 3:
+			_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+			if (_globals[kSexOfRex] == REX_MALE) {
+				_vm->_sound->command(34);
+				_scene->_sequences.addTimer(60, 4);
+				_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 1);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 14);
+			} else {
+				_vm->_sound->command(40);
+				_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 18, 0, 0, 0);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 14);
+				_scene->_sequences.addTimer(120, 5);
+			}
+			break;
+
+		case 4:
+			_game._player._stepEnabled = true;
+			_globals[kHoverCarDestination] = _globals[kHoverCarLocation];
+			_scene->_nextSceneId = 505;
+			break;
+
+		case 5:
+			_game._player._stepEnabled = true;
+			_scene->_sequences.remove(_globals._sequenceIndexes[8]);
+			_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, 1);
+			_vm->_dialogs->show(50421);
+			break;
+
+		default:
+			break;
+		}
+	} else if ((_action._lookFlag) || _action.isAction(VERB_LOOK, 0x388))
+		_vm->_dialogs->show(50412);
+	else if (_action.isAction(VERB_LOOK, 0x383))
+		_vm->_dialogs->show(50410);
+	else if (_action.isAction(VERB_LOOK, 0x380) || _action.isAction(VERB_LOOK, 0x387))
+		_vm->_dialogs->show(50411);
+	else if (_action.isAction(VERB_LOOK, 0x381))
+		_vm->_dialogs->show(50413);
+	else if (_action.isAction(VERB_LOOK, 0x385))
+		_vm->_dialogs->show(50414);
+	else if (_action.isAction(VERB_LOOK, 0x382))
+		_vm->_dialogs->show(50415);
+	else if (_action.isAction(VERB_LOOK, 0x386) || _action.isAction(0xD3, 0x386))
+		_vm->_dialogs->show(50416);
+	else if (_action.isAction(VERB_LOOK, 0x120))
+		_vm->_dialogs->show(50417);
+	else if (_action.isAction(VERB_TAKE, 0x120))
+		_vm->_dialogs->show(50418);
+	else if (_action.isAction(VERB_LOOK, 0x384))
+		_vm->_dialogs->show(50419);
+	else if (_action.isAction(VERB_TAKE, 0x384))
+		_vm->_dialogs->show(50420);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
index 0b29c92..5336cee 100644
--- a/engines/mads/nebular/nebular_scenes5.h
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -97,6 +97,21 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene504: public Scene5xx{
+private:
+	int _carAnimationMode;
+	int _carFrame;
+
+public:
+	Scene504(MADSEngine *vm) : Scene5xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 8dfddac863cb039f405fac6b1236c0c0e0004354
    https://github.com/scummvm/scummvm/commit/8dfddac863cb039f405fac6b1236c0c0e0004354
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-07T13:25:15+03:00

Commit Message:
MADS: Implement Rex Nebular scene 702 and add some nouns

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes7.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index e7da6cf..5f10788 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -253,7 +253,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 701:	// outside elevator (after city is submerged)
 		return new DummyScene(vm);	// TODO
 	case 702:	// outside teleporter (after city is submerged)
-		return new DummyScene(vm);	// TODO
+		return new Scene702(vm);
 	case 703:	// water
 		return new DummyScene(vm);	// TODO
 	case 704:	// water, building in the distance
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index e1fcf1e..0db8b93 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -40,12 +40,13 @@ enum {
 
 enum Noun {
 	NOUN_BIG_LEAVES     = 0x23,
-	NOUN_BLOWGUN		= 0x29,
+	NOUN_BLOWGUN        = 0x29,
 	NOUN_BOMB           = 0x2A,
 	NOUN_BOMBS          = 0x2B,
 	NOUN_BONE           = 0x2C,
-	NOUN_BURGER			= 0x35,
-	NOUN_CHAIR			= 0x47,
+	NOUN_BONES          = 0x2D,
+	NOUN_BURGER         = 0x35,
+	NOUN_CHAIR          = 0x47,
 	NOUN_CHICKEN        = 0x49,
 	NOUN_CHICKEN_BOMB   = 0x4A,
 	NOUN_DEAD_FISH		= 0x65,
@@ -58,6 +59,7 @@ enum Noun {
 	NOUN_HOTPANTS		= 0x0A7,
 	NOUN_HULL			= 0x0A8,
 	NOUN_HURL			= 0x0A9,
+	NOUN_ID_CARD        = 0x0B3,
 	NOUN_IGNITE			= 0x0B4,
 	NOUN_INFLATE		= 0x0B5,
 	NOUN_INSERT			= 0x0B6,
@@ -78,11 +80,13 @@ enum Noun {
 	NOUN_READ			= 0x11F,
 	NOUN_REFRIDGERATOR	= 0x122,
 	NOUN_ROBO_KITCHEN	= 0x127,
+	NOUN_ROCK           = 0x128,
 	NOUN_SHIELD_ACCESS_PANEL  = 0x135,
 	NOUN_SHIELD_MODULATOR	= 0x137,
 	NOUN_SHOOT			= 0x13A,
 	NOUN_SIT_IN			= 0x13F,
 	NOUN_SKULL          = 0x140,
+	NOUN_TELEPORTER     = 0x16C,
 	NOUN_BROKEN_LADDER  = 0x1C9,
 	NOUN_SMELL			= 0x147,
 	NOUN_STUFFED_FISH	= 0x157,
@@ -97,12 +101,18 @@ enum Noun {
 	NOUN_PILE_OF_LEAVES = 0x1AA,
 	NOUN_CAPTIVE_CREATURE = 0x1C3,
 	NOUN_NATIVE_WOMAN	= 0x1DC,
-	NOUN_ALCOHOL		= 0x310,
+	NOUN_PLATFORM       = 0x22C,
+	NOUN_ALCOHOL        = 0x310,
+	NOUN_SUBMERGED_CITY = 0x313,
+	NOUN_LASER_BEAM     = 0x343,
+	NOUN_CEMENT_BLOCK   = 0x38E,
+	NOUN_CITY           = 0x38F,
 	NOUN_DOLLOP			= 0x3AC,
 	NOUN_DROP			= 0x3AD,
 	NOUN_DASH			= 0x3AE,
 	NOUN_SPLASH			= 0x3AF,
-	NOUN_BIRDS          = 0x487
+	NOUN_BIRDS          = 0x487,
+	NOUN_WEST_END_OF_PLATFORM = 0x4A9
 };
 
 class SceneFactory {
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 54acabf..4ae2925 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -30,6 +30,13 @@ namespace MADS {
 
 namespace Nebular {
 
+// Scene 7xx verbs
+enum {
+	VERB_LOOK_AT = 0xD1,
+	VERB_WALK_ALONG = 0x312,
+	VERB_STEP_INTO = 0x2F9
+};
+
 void Scene7xx::setAAName() {
 	_game._aaName = Resources::formatAAName(5);
 }
@@ -90,6 +97,122 @@ void Scene7xx::sceneEntrySound() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene702::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene702::enter() {
+	_globals._spriteIndexes[12] = _scene->_sprites.addSprites("*RXMBD_8");
+
+	if (_scene->_priorSceneId == 701) {
+		_game._player._playerPos = Common::Point(13, 145);
+		_game._player._facing = FACING_EAST;
+	} else if (_scene->_priorSceneId != -2 && _scene->_priorSceneId != 620) {
+		_game._player._playerPos = Common::Point(289, 138);
+		_game._player.walk(Common::Point(262, 148), FACING_WEST);
+		_game._player._facing = FACING_WEST;
+		_game._player._visible = true;
+	}
+
+	if (_game._globals[kTeleporterCommand]) {
+		switch(_game._globals[kTeleporterCommand]) {
+		case TELEPORTER_BEAM_OUT:
+		case TELEPORTER_WRONG:
+		case TELEPORTER_STEP_OUT:
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			break;
+		default:
+			break;
+		}
+
+		_game._globals[kTeleporterCommand] = TELEPORTER_NONE;
+	}
+
+	sceneEntrySound();
+}
+
+void Scene702::preActions() {
+	if (_action.isAction(VERB_WALKTO, NOUN_WEST_END_OF_PLATFORM)) {
+		_game._player._walkOffScreenSceneId = 701;
+	}
+}
+
+void Scene702::actions() {
+	if (_action.isAction(VERB_WALK_ALONG, NOUN_PLATFORM)) {
+		_action._inProgress = false;
+	} else if (_action.isAction(VERB_STEP_INTO, NOUN_TELEPORTER)) {
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_scene->_nextSceneId = 711;
+		_action._inProgress = false;
+	} else if (_action.isAction(VERB_TAKE, NOUN_BONES) && _action._mainObjectSource == 4) {
+		// Take bones
+		if (!_game._objects.isInInventory(OBJ_BONES) || _game._trigger) {
+			switch (_game._trigger) {
+			case 0:
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				_globals._sequenceIndexes[12] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[12], false, 5, 2, 0, 0);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[12]);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_SPRITE, 4, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				break;
+			case 1:
+				_vm->_sound->command(0xF);
+				if (_game._objects.isInInventory(OBJ_BONE))
+					_game._objects.setRoom(OBJ_BONE, NOWHERE);
+				_game._objects.addToInventory(OBJ_BONES);
+				_vm->_dialogs->show(OBJ_BONES, 70218);
+				break;
+			case 2:
+				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[12]);
+				_game._player._visible = true;
+				_game._player._stepEnabled = true;
+				break;
+			default:
+				break;
+			}
+
+			_action._inProgress = false;
+		}
+	} else if (_action._lookFlag) {
+		_vm->_dialogs->show(70210);
+		_action._inProgress = false;
+	} else if (_action.isAction(VERB_LOOK, NOUN_PLATFORM)) {
+		_vm->_dialogs->show(70211);
+		_action._inProgress = false;
+	} else if (_action.isAction(VERB_LOOK, NOUN_CEMENT_BLOCK)) {
+		_vm->_dialogs->show(70212);
+		_action._inProgress = false;
+	} else if (_action.isAction(VERB_LOOK, NOUN_ROCK)) {
+		_vm->_dialogs->show(70213);
+		_action._inProgress = false;
+	} else if (_action.isAction(VERB_TAKE, NOUN_ROCK)) {
+		_vm->_dialogs->show(70214);
+		_action._inProgress = false;
+	} else if (_action.isAction(VERB_LOOK, NOUN_WEST_END_OF_PLATFORM)) {
+		_vm->_dialogs->show(70215);
+		_action._inProgress = false;
+	} else if (_action.isAction(VERB_LOOK, NOUN_TELEPORTER)) {
+		_vm->_dialogs->show(70216);
+		_action._inProgress = false;
+	} else if (_action.isAction(VERB_LOOK, NOUN_BONES) && _action._mainObjectSource == 4) {
+		_vm->_dialogs->show(70217);
+		_action._inProgress = false;
+	} else if (_action.isAction(VERB_TAKE, NOUN_BONES) && _action._mainObjectSource == 4) {
+		if (_game._objects.isInInventory(OBJ_BONES))
+			_vm->_dialogs->show(70219);
+		_action._inProgress = false;
+	} else if (_action.isAction(VERB_LOOK, NOUN_SUBMERGED_CITY)) {
+		_vm->_dialogs->show(70220);
+		_action._inProgress = false;
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene707::setup() {
 	_game._player._spritesPrefix = "";
 	// The original calls Scene7xx::setAAName()
@@ -233,10 +356,10 @@ void Scene752::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 
-	_scene->addActiveVocab(0xB3);
+	_scene->addActiveVocab(NOUN_ID_CARD);
 	_scene->addActiveVocab(VERB_WALKTO);
-	_scene->addActiveVocab(0xD1);
-	_scene->addActiveVocab(0x343);
+	_scene->addActiveVocab(VERB_LOOK_AT);
+	_scene->addActiveVocab(NOUN_LASER_BEAM);
 }
 
 void Scene752::enter() {
@@ -264,7 +387,7 @@ void Scene752::enter() {
 	if (_game._globals[kLaserHoleIsThere]) {
 		_globals._sequenceIndexes[14] =  _scene->_sequences.startCycle(_globals._spriteIndexes[14], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[14], 13);
-		int idx = _scene->_dynamicHotspots.add(0x343, 0xD1, _globals._sequenceIndexes[14], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_LASER_BEAM, VERB_LOOK_AT, _globals._sequenceIndexes[14], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(215, 130), FACING_NORTHWEST);
 	}
 
@@ -299,20 +422,20 @@ void Scene752::step() {
 }
 
 void Scene752::preActions() {
-	if (_action.isAction(VERB_WALKTO, 0x4A9)) {
+	if (_action.isAction(VERB_WALKTO, NOUN_WEST_END_OF_PLATFORM)) {
 		_game._player._walkOffScreenSceneId = 751;
 	}
 }
 
 void Scene752::actions() {
-	if (_action.isAction(0x312, 0x22C)) {
+	if (_action.isAction(VERB_WALK_ALONG, NOUN_PLATFORM)) {
 		_action._inProgress = false;
-	} else if (_action.isAction(0x2F9, 0x16C)) {
+	} else if (_action.isAction(VERB_STEP_INTO, NOUN_TELEPORTER)) {
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
 		_scene->_nextSceneId = 711;
 		_action._inProgress = false;
-	} else if (_action.isAction(VERB_TAKE, 0xB3)) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_ID_CARD)) {
 		// Take ID card
 		if (!_game._objects.isInInventory(OBJ_ID_CARD) || _game._trigger) {
 			switch (_game._trigger) {
@@ -341,7 +464,7 @@ void Scene752::actions() {
 
 			_action._inProgress = false;
 		}
-	} else if (_action.isAction(VERB_TAKE, 0x2D) && _action._mainObjectSource == 4) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_BONES) && _action._mainObjectSource == 4) {
 		// Take bones
 		if (!_game._objects.isInInventory(OBJ_BONES) || _game._trigger) {
 			switch (_game._trigger) {
@@ -371,38 +494,38 @@ void Scene752::actions() {
 
 			_action._inProgress = false;
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x38F)) {
+	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, NOUN_CITY)) {
 		if (_globals[kLaserHoleIsThere])
 			_vm->_dialogs->show(75212);
 		else
 			_vm->_dialogs->show(75210);
 
 		_action._inProgress = false;
-	} else if (_action.isAction(VERB_LOOK, 0x22C)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_PLATFORM)) {
 		_vm->_dialogs->show(75213);
 		_action._inProgress = false;
-	} else if (_action.isAction(VERB_LOOK, 0x38E)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_CEMENT_BLOCK)) {
 		_vm->_dialogs->show(75214);
 		_action._inProgress = false;
-	} else if (_action.isAction(VERB_LOOK, 0x128)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_ROCK)) {
 		_vm->_dialogs->show(75215);
 		_action._inProgress = false;
-	} else if (_action.isAction(VERB_TAKE, 0x128)) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_ROCK)) {
 		_vm->_dialogs->show(75216);
 		_action._inProgress = false;
-	} else if (_action.isAction(VERB_LOOK, 0x4A9)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_WEST_END_OF_PLATFORM)) {
 		_vm->_dialogs->show(75217);
 		_action._inProgress = false;
-	} else if (_action.isAction(VERB_LOOK, 0x16C)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_TELEPORTER)) {
 		_vm->_dialogs->show(75218);
 		_action._inProgress = false;
-	} else if ((_action.isAction(VERB_LOOK, 0x2D) || _action.isAction(VERB_LOOK, 0xB3)) && _action._mainObjectSource == 4) {
+	} else if ((_action.isAction(VERB_LOOK, NOUN_BONES) || _action.isAction(VERB_LOOK, NOUN_ID_CARD)) && _action._mainObjectSource == 4) {
 		if (_game._objects[OBJ_ID_CARD]._roomNumber == 752)
 			_vm->_dialogs->show(75219);
 		else
 			_vm->_dialogs->show(75220);
 		_action._inProgress = false;
-	} else if (_action.isAction(VERB_TAKE, 0x2D) && _action._mainObjectSource == 4) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_BONES) && _action._mainObjectSource == 4) {
 		if (_game._objects.isInInventory(OBJ_BONES))
 			_vm->_dialogs->show(75222);
 		_action._inProgress = false;
diff --git a/engines/mads/nebular/nebular_scenes7.h b/engines/mads/nebular/nebular_scenes7.h
index 546f024..66a42de 100644
--- a/engines/mads/nebular/nebular_scenes7.h
+++ b/engines/mads/nebular/nebular_scenes7.h
@@ -50,6 +50,18 @@ public:
 	Scene7xx(MADSEngine *vm) : NebularScene(vm) {}
 };
 
+class Scene702: public Scene7xx {
+public:
+	Scene702(MADSEngine *vm) : Scene7xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {}
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 class Scene707: public SceneTeleporter {
 public:
 	Scene707(MADSEngine *vm) : SceneTeleporter(vm) {}


Commit: fdc3424eabaad59ec33f747556a11b282d3f8207
    https://github.com/scummvm/scummvm/commit/fdc3424eabaad59ec33f747556a11b282d3f8207
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-07T21:04:38+03:00

Commit Message:
MADS: Synchronize local scene variables for Rex scene group 1

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 08c5b08..8dca4e9 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -1893,6 +1893,11 @@ void Scene105::actions() {
 	_action._inProgress = false;
 }
 
+void Scene105::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+	s.syncAsByte(_explosionFl);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene106::setup() {
@@ -2100,6 +2105,14 @@ void Scene106::actions() {
 	_action._inProgress = false;
 }
 
+void Scene106::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+	s.syncAsByte(_backToShipFl);
+	s.syncAsByte(_shadowFl);
+	s.syncAsByte(_firstEmergingFl);
+	s.syncAsSint32LE(_msgPosY);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene107::setup() {
@@ -2212,6 +2225,12 @@ void Scene107::actions() {
 	_action._inProgress = false;
 }
 
+void Scene107::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+	s.syncAsByte(_shootingFl);
+}
+
+
 /*------------------------------------------------------------------------*/
 
 void Scene108::setup() {
@@ -2701,6 +2720,17 @@ void Scene109::actions() {
 	_action._inProgress = false;
 }
 
+void Scene109::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+	s.syncAsByte(_rexThrowingObject);
+	s.syncAsByte(_hoovicDifficultFl);
+	s.syncAsByte(_beforeEatingRex);
+	s.syncAsByte(_eatingRex);
+	s.syncAsByte(_hungryFl);
+	s.syncAsByte(_eatingFirstFish);
+	s.syncAsSint32LE(_throwingObjectId);
+	s.syncAsSint32LE(_hoovicTrigger);
+}
 
 /*------------------------------------------------------------------------*/
 
@@ -2824,6 +2854,11 @@ void Scene110::actions() {
 	_action._inProgress = false;
 }
 
+void Scene110::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+	s.syncAsByte(_crabsFl);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene111::setup() {
@@ -2966,6 +3001,14 @@ void Scene111::actions() {
 	_action._inProgress = false;
 }
 
+void Scene111::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+	s.syncAsByte(_stampedFl);
+	s.syncAsByte(_launch1Fl);
+	s.syncAsByte(_launched2Fl);
+	s.syncAsByte(_rexDivingFl);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene112::setup() {
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index 7a42156..38caf15 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -146,6 +146,7 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene106 : public Scene1xx {
@@ -164,6 +165,7 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene107 : public Scene1xx {
@@ -178,6 +180,7 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene108 : public Scene1xx {
@@ -210,6 +213,7 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene110 : public Scene1xx {
@@ -224,6 +228,7 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene111 : public Scene1xx {
@@ -241,6 +246,7 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene112 : public Scene1xx {


Commit: 025c13c2408dc6aebf0ecd54268307ad18ed9e05
    https://github.com/scummvm/scummvm/commit/025c13c2408dc6aebf0ecd54268307ad18ed9e05
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-07T21:24:01+03:00

Commit Message:
MADS: Synchronize local scene variables for Rex scene group 2

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 46a2a78..2b6b7ee 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -333,6 +333,11 @@ void Scene201::actions() {
 	_action._inProgress = false;
 }
 
+void Scene201::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+	s.syncAsByte(_pterodactylFlag);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene202::setup() {
@@ -987,6 +992,26 @@ void Scene202::actions() {
 	_action._inProgress = false;
 }
 
+void Scene202::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+	s.syncAsByte(_activeMsgFl);
+	s.syncAsByte(_ladderTopFl);
+	s.syncAsByte(_waitingMeteoFl);
+	s.syncAsByte(_toStationFl);
+	s.syncAsByte(_toTeleportFl);
+
+	s.syncAsSint32LE(_ladderHotspotId);
+	s.syncAsSint32LE(_lastRoute);
+	s.syncAsSint32LE(_stationCounter);
+	s.syncAsSint32LE(_meteoFrame);
+
+	s.syncAsUint32LE(_meteoClock1);
+	s.syncAsUint32LE(_meteoClock2);
+	s.syncAsUint32LE(_startTime);
+
+	s.syncAsSint32LE(_meteorologistSpecial);
+}
+
 /*****************************************************************************/
 
 void Scene203::setup() {
@@ -1099,6 +1124,12 @@ void Scene203::actions() {
 	_action._inProgress = false;
 }
 
+void Scene203::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+	s.syncAsByte(_rhotundaEat2Fl);
+	s.syncAsByte(_rhotundaEatFl);
+}
+
 /*****************************************************************************/
 
 void Scene205::setup() {
@@ -1231,6 +1262,13 @@ void Scene205::actions() {
 	warning("TODO: Scene205::actions");
 }
 
+void Scene205::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+	s.syncAsUint32LE(_lastFishTime);
+	s.syncAsUint32LE(_chickenTime);
+	s.syncAsByte(_beingKicked);
+}
+
 /*****************************************************************************/
 
 void Scene207::setup() {
@@ -1417,6 +1455,18 @@ void Scene207::actions() {
 	_action._inProgress = false;
 }
 
+void Scene207::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+	s.syncAsByte(_vultureFl);
+	s.syncAsByte(_spiderFl);
+	s.syncAsByte(_eyeFl);
+
+	s.syncAsSint32LE(_spiderHotspotId);
+	s.syncAsSint32LE(_vultureHotspotId);
+	s.syncAsSint32LE(_spiderTime);
+	s.syncAsSint32LE(_vultureTime);
+}
+
 /*****************************************************************************/
 
 void Scene208::setup() {
@@ -1698,6 +1748,14 @@ void Scene208::actions() {
 	_action._inProgress = false;
 }
 
+void Scene208::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+	s.syncAsByte(_rhotundaTurnFl);
+	s.syncAsByte(_boundingFl);
+
+	s.syncAsSint32LE(_rhotundaTime);
+}
+
 /*****************************************************************************/
 
 void Scene209::setup() {
@@ -3290,6 +3348,35 @@ void Scene209::actions() {
 	}
 }
 
+void Scene209::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+	s.syncAsByte(_dodgeFl);
+	s.syncAsByte(_forceDodgeFl);
+	s.syncAsByte(_shouldDodgeFl);
+	s.syncAsByte(_pitchFl);
+	s.syncAsByte(_fallFl);
+	s.syncAsByte(_forceFallFl);
+	s.syncAsByte(_shouldFallFl);
+	s.syncAsByte(_playingAnimFl);
+	s.syncAsByte(_playingDialogFl);
+
+	s.syncAsSint32LE(_pauseMode);
+	s.syncAsSint32LE(_pauseCounterThreshold);
+	s.syncAsSint32LE(_pauseCounter);
+
+	s.syncAsByte(_removeMonkeyFl);
+
+	s.syncAsSint32LE(_monkeyPosition);
+
+	s.syncAsByte(_shootReadyFl);
+	s.syncAsByte(_startShootingInTimerFl);
+	s.syncAsByte(_shootMissedLastFl);
+	s.syncAsByte(_binocularsDroppedFl);
+
+	s.syncAsSint32LE(_dialogAbortVal);
+	s.syncAsSint32LE(_counter);
+}
+
 /*****************************************************************************/
 
 void Scene210::setup() {
@@ -4262,6 +4349,33 @@ void Scene210::actions() {
 	_action._inProgress = false;
 }
 
+void Scene210::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+	s.syncAsSint32LE(_curDialogNode);
+	s.syncAsSint32LE(_nextHandsPlace);
+	s.syncAsSint32LE(_twinkleAnimationType);
+	s.syncAsSint32LE(_twinklesCurrentFrame);
+
+	s.syncAsByte(_shouldTalk);
+	s.syncAsByte(_shouldFaceRex);
+	s.syncAsByte(_shouldMoveHead);
+	s.syncAsByte(_stopWalking);
+	s.syncAsByte(_twinklesTalking);
+	s.syncAsByte(_twinklesTalk2);
+
+	s.syncAsSint32LE(_doorway);
+
+	s.syncString(_subQuote2);
+
+	_conv1.synchronize(s);
+	_conv2.synchronize(s);
+	_conv3.synchronize(s);
+	_conv5.synchronize(s);
+	_conv6.synchronize(s);
+	_conv7.synchronize(s);
+	_conv8.synchronize(s);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene211::setup() {
@@ -4525,6 +4639,16 @@ void Scene211::actions() {
 	_action._inProgress = false;
 }
 
+void Scene211::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+	s.syncAsByte(_ambushFl);
+	s.syncAsByte(_wakeFl);
+
+	s.syncAsSint32LE(_monkeyFrame);
+	s.syncAsSint32LE(_scrollY);
+	s.syncAsUint32LE(_monkeyTime);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene212::setup() {
@@ -4852,6 +4976,13 @@ void Scene214::actions() {
 	_action._inProgress = false;
 }
 
+void Scene214::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+	s.syncAsUint32LE(_devilTime);
+
+	s.syncAsByte(_devilRunningFl);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene215::setup() {
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 2f3512a..e8883b1 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -59,6 +59,7 @@ public:
 	virtual void enter();
 	virtual void step();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene202: public Scene2xx {
@@ -82,6 +83,7 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 
 	void setRandomKernelMessage();
 };
@@ -97,6 +99,7 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene205: public Scene2xx {
@@ -110,6 +113,7 @@ public:
 	virtual void enter();
 	virtual void step();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene207: public Scene2xx {
@@ -128,6 +132,7 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene208: public Scene2xx {
@@ -145,6 +150,7 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene209: public Scene2xx {
@@ -192,6 +198,7 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene210: public Scene2xx {
@@ -230,6 +237,7 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene211: public Scene2xx {
@@ -245,6 +253,7 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene212: public Scene2xx {
@@ -280,6 +289,7 @@ public:
 	virtual void enter();
 	virtual void step();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene215: public Scene2xx {


Commit: 07a022888d7e8c467213aaac23352ba48d6a1bd3
    https://github.com/scummvm/scummvm/commit/07a022888d7e8c467213aaac23352ba48d6a1bd3
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-07T22:35:09+02:00

Commit Message:
MADS: Implement scene 505

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes5.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 5f10788..a946b23 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -205,7 +205,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 504:	// inside car
 		return new Scene504(vm);
 	case 505:	// car view screen
-		return new DummyScene(vm);	// TODO
+		return new Scene505(vm);
 	case 506:	// shopping street
 		return new DummyScene(vm);	// TODO
 	case 507:	// inside software house
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index 3e888ac..41765f2 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -833,5 +833,260 @@ void Scene504::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene505::setup() {
+	_game._player._spritesPrefix = "";
+	setAAName();
+}
+
+void Scene505::enter() {
+	for (int i = 0; i < 9; i++)
+		_globals._spriteIndexes[i] = _scene->_sprites.addSprites(formAnimName('a', i + 1));
+
+	_globals._spriteIndexes[13] = _scene->_sprites.addSprites(formAnimName('b', 1));
+	_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('g', 1));
+	_globals._spriteIndexes[10] = _scene->_sprites.addSprites(formAnimName('g', 0));
+	_globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('t', -1));
+	_globals._spriteIndexes[12] = _scene->_sprites.addSprites(formAnimName('e', -1));
+
+	if (_scene->_priorSceneId != -2)
+		_globals._sequenceIndexes[12] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[12], false, 6, 1, 0, 0);
+
+	_globals._sequenceIndexes[13] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[13], false, 6, 1, 120, 0);
+	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 60);
+	_scene->_sequences.addTimer(30, 62);
+
+	_carLocations[0] = 501;
+	_carLocations[1] = 506;
+	_carLocations[2] = 511;
+	_carLocations[3] = 513;
+	_carLocations[4] = 601;
+	_carLocations[5] = 604;
+	_carLocations[6] = 607;
+	_carLocations[7] = 609;
+	_carLocations[8] = 612;
+
+	_activeCars = false;
+
+	for (int i = 0; i < 9; i++) {
+		if (_globals[kHoverCarLocation] == _carLocations[i]) {
+			_homeSelectedId = i;
+			if (_scene->_priorSceneId != -2)
+				_selectedId = i;
+		}
+	}
+
+	_game._player._visible = false;
+	_game._player._stepEnabled = false;
+	_frame = -1;
+	_scene->loadAnimation(formAnimName('a', -1));
+	_scene->_activeAnimation->setCurrentFrame(86);
+
+	sceneEntrySound();
+	_vm->_sound->command(16);
+}
+
+void Scene505::step() {
+	int resetFrame;
+	if (_frame != _scene->_activeAnimation->getCurrentFrame()) {
+		_frame = _scene->_activeAnimation->getCurrentFrame();
+		resetFrame = -1;
+
+		switch (_frame) {
+		case 4:
+		case 24:
+		case 33:
+		case 53:
+		case 62:
+		case 82:
+			if (_nextButtonId == 0x38A)
+				resetFrame = 4;
+			else if (_nextButtonId == 0x38B)
+				resetFrame = 33;
+			else if (_nextButtonId == 0x2DE)
+				resetFrame = 62;
+
+			break;
+
+		case 15:
+		case 44:
+		case 73: {
+			int this_button;
+			int old_select;
+			_vm->_sound->command(17);
+			old_select = _selectedId;
+			if (_frame == 15) {
+				this_button = 0x38A;
+				_selectedId = (_selectedId + 1) % 9;
+			} else if (_frame == 44) {
+				this_button = 0x38B;
+				_selectedId--;
+				if (_selectedId < 0)
+					_selectedId = 8;
+			} else {
+				this_button = 0x2DE;
+				if ((_globals[kTimebombStatus] == 1) && (_carLocations[_selectedId] == 501))
+					_vm->_dialogs->show(431);
+				else if (_selectedId != _homeSelectedId) {
+					_nextButtonId = 0;
+					_activeCars = true;
+					_game._player._stepEnabled = false;
+					_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+					_scene->_sequences.remove(_globals._sequenceIndexes[0]);
+					_scene->_sequences.remove(_globals._sequenceIndexes[13]);
+					_globals._sequenceIndexes[13] = _scene->_sequences.startReverseCycle (_globals._spriteIndexes[13], false, 6, 1, 0, 0);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 63);
+					_vm->_sound->command(18);
+				}
+			}
+
+			if (_nextButtonId == this_button)
+				_nextButtonId = 0;
+
+			if (old_select != _selectedId) {
+				_scene->_sequences.remove(_globals._sequenceIndexes[11]);
+				_globals._sequenceIndexes[11] = _scene->_sequences.startCycle(_globals._spriteIndexes[11], false, _selectedId + 1);
+				if (old_select != _homeSelectedId)
+					_scene->_sequences.remove(_globals._sequenceIndexes[0]);
+
+				if (_selectedId != _homeSelectedId) {
+					_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[0 + _selectedId], false, 24, 0, 0, 0);
+					_scene->_sequences.setDepth(_globals._sequenceIndexes[0], 1);
+				}
+			}
+			break;
+			}
+
+		case 18:
+		case 19:
+		case 20:
+		case 21:
+		case 22:
+		case 23:
+			if (_nextButtonId == 0x38A)
+				resetFrame = 29 - _frame;
+
+			break;
+
+		case 26:
+		case 55:
+		case 84:
+			if (_nextButtonId != 0)
+				resetFrame = 3;
+
+			break;
+
+		case 27:
+		case 56:
+		case 85:
+			if (_nextButtonId != 0)
+				resetFrame = 2;
+
+			break;
+
+		case 29:
+		case 58:
+		case 87:
+			if (_activeCars)
+				_globals[kHoverCarDestination] = _carLocations[_selectedId];
+
+			if (_nextButtonId == 0x38A)
+				resetFrame = 0;
+			else if (_nextButtonId == 0x38B)
+				resetFrame = 29;
+			else if (_nextButtonId == 0x2DE)
+				resetFrame = 58;
+			else
+				resetFrame = 86;
+			break;
+
+		case 47:
+		case 48:
+		case 49:
+		case 50:
+		case 51:
+		case 52:
+			if (_nextButtonId == 0x38B)
+				resetFrame = 87 - _frame;
+
+			break;
+
+		case 76:
+		case 77:
+		case 78:
+		case 79:
+		case 80:
+		case 81:
+			if (_nextButtonId == 0x2DE)
+				resetFrame = 145 - _frame;
+
+			break;
+
+		default:
+			break;
+		}
+
+		if ((resetFrame >= 0) && (resetFrame != _scene->_activeAnimation->getCurrentFrame())) {
+			_scene->_activeAnimation->setCurrentFrame(resetFrame);
+			_frame = resetFrame;
+		}
+	}
+
+	switch (_game._trigger) {
+	case 60: {
+		_game._player._stepEnabled = true;
+		int syncIdx = _globals._sequenceIndexes[13];
+		_globals._sequenceIndexes[13] = _scene->_sequences.startCycle (_globals._spriteIndexes[13], false, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
+		_scene->_sequences.updateTimeout (_globals._sequenceIndexes[13], syncIdx);
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[_homeSelectedId], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+		_globals._sequenceIndexes[11] = _scene->_sequences.startCycle(_globals._spriteIndexes[11], false, _selectedId + 1);
+
+		if (_selectedId != _homeSelectedId) {
+			_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[0 + _selectedId], false, 24, 0, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[0], 1);
+		}
+		break;
+		}
+
+	case 61:
+		_globals._sequenceIndexes[10] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[10], false, 8, 0, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 8);
+		_scene->_sequences.updateTimeout (_globals._sequenceIndexes[10], _globals._sequenceIndexes[9]);
+		break;
+
+	case 62:
+		_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[9], false, 8, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 61);
+		break;
+
+	case 63:
+		_globals[kHoverCarDestination] = _carLocations[_selectedId];
+		_scene->_nextSceneId = 504;
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene505::actions() {
+	if (_action.isAction(0x11A))
+		_nextButtonId = _action._activeAction._objectNameId;
+	else if (_action.isAction(0x2D5, 0x38C))
+		_scene->_nextSceneId = 504;
+	else if (_action.isAction(VERB_LOOK, 0x180))
+		_vm->_dialogs->show(50510);
+	else if (_action.isAction(VERB_LOOK, 0x59))
+		_vm->_dialogs->show(50511);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
index 5336cee..f29a900 100644
--- a/engines/mads/nebular/nebular_scenes5.h
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -112,6 +112,27 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene505: public Scene5xx{
+private:
+	int _frame;
+	int _nextButtonId;
+	int _homeSelectedId;
+	int _selectedId;
+	int _activeCars;
+
+	int _carLocations[9];
+
+public:
+	Scene505(MADSEngine *vm) : Scene5xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 52a8ca23c66b00fd89e49aaca12e1a094f5eff3f
    https://github.com/scummvm/scummvm/commit/52a8ca23c66b00fd89e49aaca12e1a094f5eff3f
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-07T23:06:49+02:00

Commit Message:
MADS: Implement Scene205::Actions, some polishing

Changed paths:
    engines/mads/nebular/globals_nebular.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index 9a7873f..921c308 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -70,7 +70,7 @@ enum GlobalId {
 	kTeleporterDestination  = 40,
 	kTeleporterUnderstood   = 41,
 	kConv205                = 42,
-	kChickenPpermitted      = 43,
+	kChickenPermitted      = 43,
 	kTwinklesStatus         = 44,
 	kTwinklesApproached     = 45,
 	kConvTwinkles1          = 46,
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 2b6b7ee..1794378 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1180,11 +1180,10 @@ void Scene205::enter() {
 	_beingKicked = false;
 	_game.loadQuoteSet(0x6B, 0x70, 0x71, 0x72, 0x5A, 0x74, 0x75, 0x76, 0x77, 0x78, 0x73, 0x79, 0x7A, 0x7B, 0x7C,
 		0x7D, 0x7E, 0x7F, 0x80, 0xAC, 0xAD, 0xAE, 0x6C, 0x6D, 0x6E, 0x6F, 0x2, 0);
-	warning("TODO: sub71A50(&dialog1, 0x5A, 0x78, 0x74, 0x75, 0x76, 0x77, 0);");
+	_dialog1.setup(0x2A, 0x5A, 0x78, 0x74, 0x75, 0x76, 0x77, 0);
 
 	if (!_game._visitedScenes._sceneRevisited)
-		warning("TODO: sub71B18(&dialog1, 0x5A, 0x74, 0x75, 0x77, 0);");
-
+		_dialog1.set(0x5A, 0x74, 0x75, 0x77, 0);
 
 	_vm->_palette->setEntry(250, 63, 50, 20);
 	_vm->_palette->setEntry(251, 50, 40, 15);
@@ -1220,25 +1219,24 @@ void Scene205::step() {
 		warning("TODO: sub7178C()");
 
 		if (_vm->_game->_scene._frameStartTime >= _chickenTime) {
-			warning("TODO: if (sub717B2(100, 1 + sub7176C()))");
-				_vm->_sound->command(28);
-//			}
-				_chickenTime = _vm->_game->_scene._frameStartTime + 2;
+			warning("TODO: if (sub717B2(100, 1 + sub7176C())) {");
+			_vm->_sound->command(28);
+			//	 }
+			_chickenTime = _vm->_game->_scene._frameStartTime + 2;
 		}
 	}
 
 	if (_vm->_game->_scene._frameStartTime - _lastFishTime > 1300) {
 		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(
 			_globals._spriteIndexes[6], false, 5, 1, 0, 0);
-		int idx = _scene->_dynamicHotspots.add(269, 13, _globals._sequenceIndexes[6], 
+		int idx = _scene->_dynamicHotspots.add(269, 13, _globals._sequenceIndexes[6],
 			Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(49, 86), FACING_NORTH);
 		_lastFishTime = _vm->_game->_scene._frameStartTime;
 	}
 
-	if (_game._trigger == 73) {
+	if (_game._trigger == 73)
 		_scene->_kernelMessages.add(Common::Point(160, 68), 0xFBFA, 32, 0, 60, _game.getQuote(112));
-	}
 
 	if (_game._trigger == 74) {
 		_vm->_sound->command(26);
@@ -1253,13 +1251,164 @@ void Scene205::step() {
 		_scene->_kernelMessages.add(Common::Point(160, 68), 0xFBFA, 32, 72, 180, _game.getQuote(114));
 	}
 
-	if (_game._trigger == 72) {
+	if (_game._trigger == 72)
 		_scene->_nextSceneId = 211;
-	}
+}
+
+void Scene205::handleWomanSpeech(int quote) {
+	_kernelMessage = _scene->_kernelMessages.add(Common::Point(186, 27), 0xFBFA, 0, 0, 9999999, _game.getQuote(quote));
 }
 
 void Scene205::actions() {
-	warning("TODO: Scene205::actions");
+	if (_game._screenObjects._inputMode == 1) {
+		if (_kernelMessage >= 0)
+			_scene->_kernelMessages.remove(_kernelMessage);
+		_kernelMessage = -1;
+
+		if (_game._trigger == 0) {
+			_game._player._stepEnabled = false;
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 18, 1, 120, _game.getQuote(_action._activeAction._verbId));
+		} else {
+			if ((_game._trigger > 1) || (_action._activeAction._verbId != 0x76))
+				_game._player._stepEnabled = true;
+
+			switch (_action._activeAction._verbId) {
+			case 0x5A:
+				handleWomanSpeech(0x7A);
+				_dialog1.write(0x78, true);
+				_dialog1.write(0x5A, false);
+				break;
+
+			case 0x74:
+				handleWomanSpeech(0x7C);
+				_dialog1.write(0x74, false);
+				_dialog1.write(0x76, true);
+				break;
+
+			case 0x75:
+			case 0x78:
+				handleWomanSpeech(0x7B);
+				_dialog1.write(_action._activeAction._verbId, false);
+				_vm->_dialogs->show(20501);
+				break;
+
+			case 0x76:
+				if (_game._trigger == 1) {
+					handleWomanSpeech(0x7D);
+					_scene->_sequences.addTimer(120, 2);
+				} else if (_game._trigger == 2) {
+					handleWomanSpeech(0x7E);
+					_dialog1.write(0x76, false);
+					_globals[kChickenPermitted] = true;
+				}
+				break;
+
+			case 0x77:
+				_scene->_kernelMessages.add(Common::Point(186, 27), 0xFBFA, 0, 0, 120, _game.getQuote(0x7F));
+				_scene->_userInterface.setup(kInputBuildingSentences);
+				break;
+
+			default:
+				break;
+			}
+
+			if (_action._activeAction._verbId != 0x77)
+				_dialog1.start();
+		}
+	} else if (_action._lookFlag)
+		_vm->_dialogs->show(20502);
+	else if (_action.isAction(VERB_LOOK, 0x27, 0x1C8))
+		_vm->_dialogs->show(20518);
+	else if (_action.isAction(VERB_TALKTO, 0x1DC)) {
+		if (_game._trigger == 0) {
+			_game._player._stepEnabled = false;
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 18, 1, 120, _game.getQuote(0x73));
+		} else if (_game._trigger == 1) {
+			_game._player._stepEnabled = true;
+			handleWomanSpeech (0x79);
+			_dialog1.write(0x5A, true);
+			_dialog1.write(0x75, true);
+			_dialog1.start();
+		}
+	} else if (_action.isAction(VERB_GIVE, 0x1DC) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
+		if (_game._trigger == 0) {
+			_game._player._stepEnabled = false;
+			int rndVal = _vm->getRandomNumber(0xAC, 0xAE);
+			_scene->_kernelMessages.add(Common::Point(186, 27), 0xFBFA, 32, 1, 120, _game.getQuote(rndVal));
+		} else if (_game._trigger == 1)
+			_game._player._stepEnabled = true;
+	} else if (_action.isAction(VERB_WALKTO, 0x1C8)) {
+		if (_game._trigger == 0) {
+			_game._player._visible   = false;
+			_game._player._stepEnabled = false;
+			_vm->_palette->lock();
+			_scene->_kernelMessages.reset();
+			warning("TODO: sub70402();");
+
+			_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('a', 0));
+			_vm->_palette->refreshSceneColors();
+			_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[9], -1);
+			_vm->_sound->command(27);
+		} else if (_game._trigger == 1) {
+			if (_scene->_activeAnimation != nullptr)
+				warning("scene->_activeAnimation._spriteSetsCount = 0;");
+
+			_vm->_dialogs->show(20516);
+			_scene->_reloadSceneFlag = true;
+		}
+	} else {
+		if (_action.isAction(0x1AD, 0x1C7))
+			_scene->_nextSceneId = 210;
+
+		if (_action.isAction(VERB_WALKTO, 0x86) || _action.isAction(VERB_WALKTO, 0x1C2)) {
+			if (_game._objects.isInRoom(OBJ_CHICKEN)) {
+				_scene->_kernelMessages.reset();
+				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x6B));
+			}
+		} else if (_action.isAction(VERB_TAKE, 0x1C2) && _globals[kChickenPermitted] && _game._objects.isInRoom(OBJ_CHICKEN)) {
+			_game._objects.addToInventory(OBJ_CHICKEN);
+			_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+			_scene->_hotspots.activate(0x1C2, false);
+			_vm->_dialogs->showItem(OBJ_CHICKEN, 812);
+		} else if (_action.isAction(VERB_TAKE, 0x1C2) && (!_globals[kChickenPermitted]))
+			_scene->_kernelMessages.add(Common::Point(186, 27), 0xFBFA, 32, 0, 120, _game.getQuote(0x80));
+		else if (_action.isAction(VERB_LOOK, 0x1DC))
+			_vm->_dialogs->show(20503);
+		else if (_action.isAction(VERB_LOOK, 0xAA))
+			_vm->_dialogs->show(20504);
+		else if (_action.isAction(VERB_LOOK, 0x49) && (_action._mainObjectSource == 4))
+			_vm->_dialogs->show(20505);
+		else if (_action.isAction(VERB_TAKE, 0x49) && (_action._mainObjectSource == 4))
+			_vm->_dialogs->show(20506);
+		else if (_action.isAction(VERB_LOOK, 0x1C2))
+			_vm->_dialogs->show(20507);
+		else if (_action.isAction(VERB_LOOK, 0x86))
+			_vm->_dialogs->show(20508);
+		else if (_action.isAction(VERB_TAKE, 0x86))
+			_vm->_dialogs->show(20509);
+		else if (_action.isAction(VERB_LOOK, 0x1C5))
+			_vm->_dialogs->show(20510);
+		else if (_action.isAction(VERB_LOOK, 0x1C8))
+			_vm->_dialogs->show(20511);
+		else if (_game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))
+			&& (   _action.isAction(VERB_GIVE, 0x1C5) || _action.isAction(VERB_THROW, 0x1C5)
+			|| _action.isAction(VERB_GIVE, 0x10D) || _action.isAction(VERB_THROW, 0x10D)))
+				_vm->_dialogs->show(20512);
+		else if (_action.isAction(VERB_LOOK, 0x10D))
+			_vm->_dialogs->show(20513);
+		else if (_action.isAction(VERB_LOOK, 0x1C4))
+			_vm->_dialogs->show(20514);
+		else if (_action.isAction(VERB_TAKE, 0x1C4))
+			_vm->_dialogs->show(20515);
+		else if (_action.isAction(VERB_TAKE, 0x1DC))
+			_vm->_dialogs->show(20517);
+		else
+			return;
+	}
+
+	_action._inProgress = false;
 }
 
 void Scene205::synchronize(Common::Serializer &s) {
@@ -2660,7 +2809,7 @@ void Scene209::step() {
 				++_counter;
 			}
 			break;
-	
+
 		case 2:
 			if ((_monkeyPosition == 1) && (_counter < 2)) {
 				_scene->_sequences.addTimer(1, 140);
@@ -2669,7 +2818,7 @@ void Scene209::step() {
 				++_counter;
 			}
 			break;
-	
+
 		case 3:
 			if (_monkeyPosition == 1) {
 				_scene->_sequences.addTimer(1, 145);
@@ -2678,7 +2827,7 @@ void Scene209::step() {
 				_counter = 0;
 			}
 			break;
-	
+
 		case 4:
 			if ((_monkeyPosition == 2) && (_counter < 2)) {
 				_scene->_sequences.addTimer(1, 151);
@@ -2687,7 +2836,7 @@ void Scene209::step() {
 				_playingAnimFl = true;
 			}
 			break;
-	
+
 		case 5:
 			if (_monkeyPosition == 2) {
 				_scene->_sequences.addTimer(1, 161);
@@ -2696,7 +2845,7 @@ void Scene209::step() {
 				_playingAnimFl = true;
 			}
 			break;
-	
+
 		case 6:
 			if (_monkeyPosition == 2) {
 				_scene->_sequences.addTimer(1, 189);
@@ -2712,7 +2861,7 @@ void Scene209::step() {
 				_playingAnimFl = true;
 			}
 			break;
-	
+
 		case 8:
 			if (_monkeyPosition == 3) {
 				_scene->_sequences.addTimer(1, 178);
@@ -2721,7 +2870,7 @@ void Scene209::step() {
 				_counter = 0;
 			}
 			break;
-	
+
 		case 9:
 			if ((_monkeyPosition == 3) && (_game._player._playerPos.x<120)) {
 				_scene->_sequences.addTimer(1, 182);
@@ -2730,7 +2879,7 @@ void Scene209::step() {
 				_playingAnimFl = true;
 			}
 			break;
-	
+
 		case 10:
 			if (_monkeyPosition == 4) {
 				_scene->_sequences.addTimer(1, 196);
@@ -2739,7 +2888,7 @@ void Scene209::step() {
 				_counter = 0;
 			}
 			break;
-	
+
 		case 11:
 			if ((_monkeyPosition == 4) && (_counter < 3)) {
 				_scene->_sequences.addTimer(1, 199);
@@ -2748,7 +2897,7 @@ void Scene209::step() {
 				_playingAnimFl = true;
 			}
 			break;
-	
+
 		case 30:
 			if (_monkeyPosition == 4) {
 				_scene->_sequences.addTimer(1, 246);
@@ -2757,14 +2906,14 @@ void Scene209::step() {
 				_playingAnimFl = true;
 			}
 			break;
-	
+
 		default:
 			if ((randAction >= 12) && (randAction <= 20) && (_monkeyPosition == 2) && (_counter < 5)) {
 				_scene->_sequences.addTimer(1, 155);
 				++_counter;
 				_playingAnimFl = true;
 			}
-		
+
 			if ((randAction >= 21) && (randAction <= 29) && (_monkeyPosition == 3) && (_counter < 3)) {
 				_scene->_sequences.addTimer(1, 171);
 				_playingAnimFl = true;
@@ -3017,7 +3166,7 @@ void Scene209::preActions() {
 		_game._player._walkOffScreenSceneId = 208;
 
 	if (_globals[36] == 1) {
-		if ((_action.isAction(NOUN_SHOOT) || _action.isAction(NOUN_HOSE_DOWN)) && _action.isAction(NOUN_MONKEY) 
+		if ((_action.isAction(NOUN_SHOOT) || _action.isAction(NOUN_HOSE_DOWN)) && _action.isAction(NOUN_MONKEY)
 			&& _action.isAction(NOUN_BLOWGUN) && _game._objects.isInInventory(OBJ_BLOWGUN) && _game._objects.isInInventory(OBJ_POISON_DARTS)) {
 			_game._player._prepareWalkPos = Common::Point(111, 129);
 			_game._player._prepareWalkFacing = FACING_NORTHEAST;
@@ -3164,8 +3313,8 @@ void Scene209::actions() {
 				_dodgeFl = true;
 				_action._inProgress = false;
 				return;
-			} 
-			
+			}
+
 			if (_action.isAction(NOUN_HOSE_DOWN, NOUN_BLOWGUN, NOUN_MONKEY) && !_startShootingInTimerFl) {
 				_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 				_scene->_sequences.addTimer(1, 228);
@@ -3925,7 +4074,7 @@ void Scene210::enter() {
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 5);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
 	} else {
-		int idx = _scene->_dynamicHotspots.add(112, 395, -1, Common::Rect(163, 87, 163 + 19, 87 + 36)); 
+		int idx = _scene->_dynamicHotspots.add(112, 395, -1, Common::Rect(163, 87, 163 + 19, 87 + 36));
 		_doorway = _scene->_dynamicHotspots.setPosition(idx, Common::Point(168, 127), FACING_NORTH);
 		_scene->_dynamicHotspots.setCursor(_doorway, CURSOR_GO_UP);
 	}
@@ -3934,7 +4083,7 @@ void Scene210::enter() {
 		0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE, 0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA,
 		0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC,
 		0xDD, 0xDE, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0);
-	
+
 	_conv1.setup(0x2E, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0);
 
 	if (!_game._visitedScenes._sceneRevisited) {
@@ -4165,7 +4314,7 @@ void Scene210::step() {
 				_shouldTalk = true;
 			} else if ((_twinklesCurrentFrame == 75) && _shouldTalk)
 				reset_frame = 60;
-	
+
 			if ((reset_frame >= 0) && (reset_frame != _scene->_activeAnimation->getCurrentFrame())) {
 				_scene->_activeAnimation->setCurrentFrame(reset_frame);
 				_twinklesCurrentFrame = reset_frame;
@@ -4195,7 +4344,7 @@ void Scene210::actions() {
 		_vm->_dialogs->show(0x5219);
 	} else if (_game._screenObjects._inputMode == 1) {
 		handleConversations();
-	} else if (_action.isAction(VERB_TALKTO, 0x1DC) || 
+	} else if (_action.isAction(VERB_TALKTO, 0x1DC) ||
 		((_game._player._playerPos == Common::Point(214, 150)) && (_game._player._facing == FACING_NORTHWEST) && (_twinkleAnimationType == 1) && _stopWalking)) {
 		switch (_game._trigger) {
 		case 0: {
@@ -4442,7 +4591,7 @@ void Scene211::step() {
 			_monkeyTime = _vm->_game->_scene._frameStartTime + 2;
 		}
 
-		if ((_game._player._playerPos == Common::Point(52, 132)) && (_game._player._facing == FACING_WEST) && !_game._player._moving && 
+		if ((_game._player._playerPos == Common::Point(52, 132)) && (_game._player._facing == FACING_WEST) && !_game._player._moving &&
 			(_game._trigger || !_ambushFl)) {
 			switch (_game._trigger) {
 			case 0:
@@ -4633,7 +4782,7 @@ void Scene211::actions() {
 		_vm->_dialogs->show(0x527A);
 	else if (_action.isAction(VERB_LOOK, 0x129))
 		_vm->_dialogs->show(0x527B);
-	else 
+	else
 		return;
 
 	_action._inProgress = false;
@@ -4704,7 +4853,7 @@ void Scene212::actions() {
 		_vm->_dialogs->show(0x52D7);
 	else if (_action.isAction(VERB_LOOK, 0xE8))
 		_vm->_dialogs->show(0x52D8);
-	else 
+	else
 		return;
 
 	_action._inProgress = false;
@@ -4844,7 +4993,7 @@ void Scene214::step() {
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 9, -2);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 2);
 			_devilTime = _game._player._priorTimer;
-			_devilRunningFl = false; 
+			_devilRunningFl = false;
 			}
 			break;
 		}
@@ -4969,7 +5118,7 @@ void Scene214::actions() {
 			_vm->_dialogs->show(0x53B1);
 		} else {
 			_vm->_dialogs->show(0x53B2);
-		} 
+		}
 	} else
 		return;
 
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index e8883b1..47d5a12 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -106,6 +106,11 @@ class Scene205: public Scene2xx {
 private:
 	uint32 _lastFishTime, _chickenTime;
 	bool _beingKicked;
+	int _kernelMessage;
+	Conversation _dialog1;
+
+	void handleWomanSpeech(int quoteId);
+
 public:
 	Scene205(MADSEngine *vm) : Scene2xx(vm), _lastFishTime(0), _chickenTime(0) {}
 


Commit: 00dd6a5e2a333e460d39dc429d9b00d04bfe68b1
    https://github.com/scummvm/scummvm/commit/00dd6a5e2a333e460d39dc429d9b00d04bfe68b1
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-07T23:21:30+02:00

Commit Message:
MADS: Add recently added fields in Scene205::synchronize()

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 1794378..0736b3d 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1416,6 +1416,9 @@ void Scene205::synchronize(Common::Serializer &s) {
 	s.syncAsUint32LE(_lastFishTime);
 	s.syncAsUint32LE(_chickenTime);
 	s.syncAsByte(_beingKicked);
+	s.syncAsSint16LE(_kernelMessage);
+
+	_dialog1.synchronize(s);
 }
 
 /*****************************************************************************/


Commit: 3fc8cd0a031dfb31c5bbb9966e650a5cce27822e
    https://github.com/scummvm/scummvm/commit/3fc8cd0a031dfb31c5bbb9966e650a5cce27822e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-08T00:52:22+03:00

Commit Message:
MADS: Fix typo in NebularGlobals::synchronize()

Changed paths:
    engines/mads/nebular/globals_nebular.cpp



diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp
index d839d29..2e50794 100644
--- a/engines/mads/nebular/globals_nebular.cpp
+++ b/engines/mads/nebular/globals_nebular.cpp
@@ -42,7 +42,7 @@ NebularGlobals::NebularGlobals(): Globals() {
 void NebularGlobals::synchronize(Common::Serializer &s) {
 	Globals::synchronize(s);
 
-	s.syncAsUint32BE(_timebombClock);
+	s.syncAsUint32LE(_timebombClock);
 	s.syncAsUint32LE(_timebombTimer);
 	_spriteIndexes.synchronize(s);
 	_sequenceIndexes.synchronize(s);


Commit: 35a54a057063a3d04ea448670bd77e78f1cc40a5
    https://github.com/scummvm/scummvm/commit/35a54a057063a3d04ea448670bd77e78f1cc40a5
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-08T01:36:35+03:00

Commit Message:
MADS: Synchronize local scene variables for Rex scene group 3

Changed paths:
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 17c310d..44deeba 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -302,6 +302,11 @@ void Scene302::step() {
 	}
 }
 
+void Scene302::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+	s.syncAsSint32LE(_oldFrame);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene303::setup() {
@@ -455,6 +460,11 @@ void Scene304::step() {
 	}
 }
 
+void Scene304::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+	s.syncAsSint32LE(_explosionSpriteId);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene307::setup() {
@@ -522,13 +532,13 @@ void Scene307::setDialogNode(int node) {
 	case 1:
 		_globals[kMetBuddyBeast] = true;
 		handlePrisonerSpeech(0x10F, 2, 9999999);
-		dialog1.start();
+		_dialog1.start();
 		break;
 
 	case 2:
 		_globals[kMetBuddyBeast] = true;
 		handlePrisonerSpeech(0x111, 2, 9999999);
-		dialog1.start();
+		_dialog1.start();
 		break;
 
 	case 4:
@@ -539,7 +549,7 @@ void Scene307::setDialogNode(int node) {
 	case 5:
 		_globals[kKnowsBuddyBeast] = true;
 		handlePrisonerSpeech(0x117, 2, 9999999);
-		dialog2.start();
+		_dialog2.start();
 		break;
 
 	case 6:
@@ -550,57 +560,57 @@ void Scene307::setDialogNode(int node) {
 	case 7:
 		_globals[kKnowsBuddyBeast] = true;
 		handlePrisonerSpeech(0x124, 10, 9999999);
-		dialog2.write(0x11A, false);
-		dialog2.write(0x11B, true);
-		dialog2.write(0x120, true);
-		dialog2.start();
+		_dialog2.write(0x11A, false);
+		_dialog2.write(0x11B, true);
+		_dialog2.write(0x120, true);
+		_dialog2.start();
 		break;
 
 	case 8:
 		handlePrisonerSpeech(0x12E, 6, 9999999);
-		dialog2.write(0x11A, false);
-		dialog2.write(0x11B, false);
-		dialog2.write(0x11C, true);
-		dialog2.write(0x11D, true);
-		dialog2.write(0x11F, true);
-		dialog2.start();
+		_dialog2.write(0x11A, false);
+		_dialog2.write(0x11B, false);
+		_dialog2.write(0x11C, true);
+		_dialog2.write(0x11D, true);
+		_dialog2.write(0x11F, true);
+		_dialog2.start();
 		break;
 
 	case 9:
 		handlePrisonerSpeech(0x134, 4, 9999999);
-		dialog2.write(0x11D, false);
-		dialog2.start();
+		_dialog2.write(0x11D, false);
+		_dialog2.start();
 		break;
 
 	case 10:
 		handlePrisonerSpeech(0x138, 6, 9999999);
-		dialog2.write(0x11E, false);
-		dialog2.start();
+		_dialog2.write(0x11E, false);
+		_dialog2.start();
 		break;
 
 	case 11:
 		handlePrisonerSpeech(0x13E, 6, 9999999);
-		dialog2.write(0x11F, false);
-		dialog2.write(0x121, true);
-		dialog2.start();
+		_dialog2.write(0x11F, false);
+		_dialog2.write(0x121, true);
+		_dialog2.start();
 		break;
 
 	case 12:
 		handlePrisonerSpeech(0x144, 4, 9999999);
-		dialog2.write(0x11C, false);
-		dialog2.start();
+		_dialog2.write(0x11C, false);
+		_dialog2.start();
 		break;
 
 	case 13:
 		handlePrisonerSpeech(0x148, 7, 9999999);
-		dialog2.write(0x120, false);
-		dialog2.start();
+		_dialog2.write(0x120, false);
+		_dialog2.start();
 		break;
 
 	case 14:
 		handlePrisonerSpeech(0x14F, 3, 9999999);
-		dialog2.write(0x121, false);
-		dialog2.start();
+		_dialog2.write(0x121, false);
+		_dialog2.start();
 		break;
 
 	case 15:
@@ -611,7 +621,7 @@ void Scene307::setDialogNode(int node) {
 	case 16:
 		_globals[kKnowsBuddyBeast] = true;
 		handlePrisonerSpeech(0x10C, 1, 9999999);
-		dialog2.start();
+		_dialog2.start();
 		break;
 
 	default:
@@ -700,13 +710,13 @@ void Scene307::enter() {
 		0x142, 0x143, 0x144, 0x145, 0x146, 0x147, 0x148, 0x149, 0x14A, 0x14B, 0x14C, 0x14D, 0x14E, 0x14F,
 		0x150, 0x151, 0x152, 0x153, 0);
 
-	dialog1.setup(0x3F, 0x113, 0x114, 0x115, -1);
-	dialog2.setup(0x40, 0x11A, 0x11B, 0x11C, 0x11D, 0x11E, 0x11F, 0x120, 0x121, 0x122, 0);
+	_dialog1.setup(0x3F, 0x113, 0x114, 0x115, -1);
+	_dialog2.setup(0x40, 0x11A, 0x11B, 0x11C, 0x11D, 0x11E, 0x11F, 0x120, 0x121, 0x122, 0);
 
 	if (!_game._visitedScenes._sceneRevisited)
-		dialog2.set(0x11A, 0x122, 0);
+		_dialog2.set(0x11A, 0x122, 0);
 	else if (_scene->_priorSceneId == 318)
-		dialog2.write(0x11E, true);
+		_dialog2.write(0x11E, true);
 
 
 	if (_scene->_priorSceneId == -2) {
@@ -826,7 +836,7 @@ void Scene307::step() {
 				_prisonerMessageId++;
 				if (_prisonerMessageId > 0x10A)
 					_prisonerMessageId = 0x104;
-			} else if (_globals[kKnowsBuddyBeast] && (dialog2.read(0) > 1) && (_vm->getRandomNumber(1, 3) == 1)) {
+			} else if (_globals[kKnowsBuddyBeast] && (_dialog2.read(0) > 1) && (_vm->getRandomNumber(1, 3) == 1)) {
 				int idx = _scene->_kernelMessages.add(Common::Point(5, 51), 0xFDFC, 0, 81, 120, _game.getQuote(267));
 				_scene->_kernelMessages.setQuoted(idx, 4, true);
 			}
@@ -1127,6 +1137,30 @@ void Scene307::actions() {
 	_action._inProgress = false;
 }
 
+void Scene307::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+	
+	_forceField.synchronize(s);
+	
+	s.syncAsByte(_afterPeeingFl);
+	s.syncAsByte(_duringPeeingFl);
+	s.syncAsByte(_grateOpenedFl);
+	s.syncAsByte(_activePrisonerFl);
+
+	s.syncAsSint32LE(_animationMode);
+	s.syncAsSint32LE(_prisonerMessageId);
+	s.syncAsSint32LE(_fieldCollisionCounter);
+
+	s.syncAsUint32LE(_lastFrameTime);
+	s.syncAsUint32LE(_guardTime);
+	s.syncAsUint32LE(_prisonerTimer);
+
+	s.syncString(_subQuote2);
+
+	_dialog1.synchronize(s);
+	_dialog2.synchronize(s);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene308::setup() {
@@ -1250,6 +1284,12 @@ void Scene308::step() {
 	}
 }
 
+void Scene308::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+	
+	_forceField.synchronize(s);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene309::setup() {
@@ -1435,6 +1475,18 @@ void Scene309::step() {
 		_scene->_nextSceneId = 308;
 }
 
+void Scene309::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+	
+	_forceField.synchronize(s);
+
+	for (int i = 0; i < 3; ++i)
+		s.syncAsSint32LE(_characterSpriteIndexes[i]);
+	for (int i = 0; i < 3; ++i)
+		s.syncAsSint32LE(_messagesIndexes[i]);
+	s.syncAsSint32LE(_lastFrame);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene310::setup() {
@@ -1468,6 +1520,12 @@ void Scene310::step() {
 		_scene->_nextSceneId = 309;
 }
 
+void Scene310::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+	
+	_forceField.synchronize(s);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene311::setup() {
@@ -1757,6 +1815,12 @@ void Scene311::actions() {
 	_action._inProgress = false;
 }
 
+void Scene311::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+	
+	s.syncAsByte(_checkGuardFl);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene313::setup() {
@@ -2311,41 +2375,41 @@ void Scene318::handleDialog() {
 		_game._player._stepEnabled = true;
 	} else {
 		if (_action._activeAction._verbId < 0x19C)
-			dialog1.write(_action._activeAction._verbId, false);
+			_dialog1.write(_action._activeAction._verbId, false);
 
 		switch (_action._activeAction._verbId) {
 		case 0x191:
 			handleInternDialog(0x19E, 2, 9999999);
-			dialog1.write(0x192, true);
+			_dialog1.write(0x192, true);
 			break;
 
 		case 0x192:
 			handleInternDialog(0x1A0, 5, 9999999);
-			dialog1.write(0x193, true);
+			_dialog1.write(0x193, true);
 			break;
 
 		case 0x193:
 			handleInternDialog(0x1A5, 4, 9999999);
-			dialog1.write(0x194, true);
+			_dialog1.write(0x194, true);
 			break;
 
 		case 0x194:
 			handleInternDialog(0x1A9, 6, 9999999);
-			dialog1.write(0x195, true);
-			dialog1.write(0x196, true);
-			dialog1.write(0x19D, false);
+			_dialog1.write(0x195, true);
+			_dialog1.write(0x196, true);
+			_dialog1.write(0x19D, false);
 			break;
 
 		case 0x195:
 			handleInternDialog(0x1AF, 7, 9999999);
-			if (!dialog1.read(0x196))
-				dialog1.write(0x197, true);
+			if (!_dialog1.read(0x196))
+				_dialog1.write(0x197, true);
 			break;
 
 		case 0x196:
 			handleInternDialog(0x1B6, 5, 9999999);
-			if (!dialog1.read(0x195))
-				dialog1.write(0x197, true);
+			if (!_dialog1.read(0x195))
+				_dialog1.write(0x197, true);
 			break;
 
 		case 0x197:
@@ -2354,7 +2418,7 @@ void Scene318::handleDialog() {
 
 		case 0x198:
 			handleInternDialog(0x1C0, 5, 9999999);
-			dialog1.write(0x19A, true);
+			_dialog1.write(0x19A, true);
 			break;
 
 		case 0x199:
@@ -2363,7 +2427,7 @@ void Scene318::handleDialog() {
 
 		case 0x19A:
 			handleInternDialog(0x1C8, 5, 9999999);
-			dialog1.write(0x19B, true);
+			_dialog1.write(0x19B, true);
 			break;
 
 		case 0x19B:
@@ -2381,7 +2445,7 @@ void Scene318::handleDialog() {
 
 			_dialogFl = false;
 			handleInternDialog(0x1D0, 1, 120);
-			if (dialog1.read(0) || (_action._activeAction._verbId == 0x19D)) {
+			if (_dialog1.read(0) || (_action._activeAction._verbId == 0x19D)) {
 				_explosionFl = true;
 				_internCounter = 3420;
 			}
@@ -2389,7 +2453,7 @@ void Scene318::handleDialog() {
 		}
 
 		if (_action._activeAction._verbId < 0x19C) {
-			dialog1.start();
+			_dialog1.start();
 			_game._player._stepEnabled = true;
 		}
 
@@ -2464,12 +2528,12 @@ void Scene318::enter() {
 	else if (_scene->_priorSceneId != -2)
 		_game._player._playerPos = Common::Point(214, 152);
 
-	dialog1.setup(0x47, 0x191, 0x192, 0x193, 0x194, 0x195, 0x196, 0x197, 0x198, 0x199, 0x19A, 0x19B, 0x19C, 0x19D, 0);
+	_dialog1.setup(0x47, 0x191, 0x192, 0x193, 0x194, 0x195, 0x196, 0x197, 0x198, 0x199, 0x19A, 0x19B, 0x19C, 0x19D, 0);
 
 	if (!_game._visitedScenes._sceneRevisited) {
-		dialog1.set(0x191, 0x198, 0x199, 0x19C, 0);
+		_dialog1.set(0x191, 0x198, 0x199, 0x19C, 0);
 		if (_game._widepipeCtr >= 2)
-			dialog1.write(0x19D, true);
+			_dialog1.write(0x19D, true);
 	}
 
 	if (_scene->_priorSceneId == 307) {
@@ -2514,7 +2578,7 @@ void Scene318::enter() {
 			}
 
 			if (_dialogFl) {
-				dialog1.start();
+				_dialog1.start();
 				_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 8);
 			} else
 				_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
@@ -2709,7 +2773,7 @@ void Scene318::actions() {
 		case 1:
 			_game._player._stepEnabled = true;
 			handleInternDialog(0x18F, 1, 9999999);
-			dialog1.start();
+			_dialog1.start();
 			break;
 
 		case 2: {
@@ -2873,6 +2937,29 @@ void Scene318::actions() {
 	_action._inProgress = false;
 }
 
+void Scene318::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+
+	s.syncAsUint32LE(_dropTimer);
+
+	s.syncAsSint32LE(_lastFrame);
+	s.syncAsSint32LE(_animMode);
+	s.syncAsSint32LE(_internCounter);
+	s.syncAsSint32LE(_counter);
+
+	s.syncAsByte(_dialogFl);
+	s.syncAsByte(_internTalkingFl);
+	s.syncAsByte(_internWalkingFl);
+	s.syncAsByte(_internVisibleFl);
+	s.syncAsByte(_explosionFl);
+
+	s.syncAsUint32LE(_lastFrameCounter);
+
+	s.syncString(_subQuote2);
+
+	_dialog1.synchronize(s);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene319::setup() {
@@ -3333,6 +3420,29 @@ void Scene319::actions() {
 	_action._inProgress = false;
 }
 
+void Scene319::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+
+	_dialog1.synchronize(s);
+	_dialog2.synchronize(s);
+	_dialog3.synchronize(s);
+
+	s.syncAsUint32LE(_animMode);
+	s.syncAsUint32LE(_animFrame);
+	s.syncAsUint32LE(_nextAction1);
+	s.syncAsUint32LE(_nextAction2);
+	s.syncAsUint32LE(_slacheMode);
+	s.syncAsUint32LE(_slacheTopic);
+	s.syncAsUint32LE(_slachePosY);
+
+	s.syncAsByte(_slacheTalkingFl);
+	s.syncAsByte(_slacheReady);
+	s.syncAsByte(_slacheInitFl);
+	
+	s.syncString(_subQuote2);
+}
+
+
 /*------------------------------------------------------------------------*/
 
 void Scene320::setup() {
@@ -3641,6 +3751,19 @@ void Scene320::actions() {
 	_action._inProgress = false;
 }
 
+void Scene320::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+
+	s.syncAsByte(_blinkFl);
+	s.syncAsByte(_flippedFl);
+
+	s.syncAsSint32LE(_buttonId);
+	s.syncAsSint32LE(_lastFrame);
+	s.syncAsSint32LE(_leftItemId);
+	s.syncAsSint32LE(_posX);
+	s.syncAsSint32LE(_rightItemId);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene321::setup() {
@@ -4439,6 +4562,21 @@ void Scene352::actions() {
 		return;
 }
 
+void Scene352::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+
+	s.syncAsByte(_vaultOpenFl);
+	s.syncAsByte(_mustPutArmDownFl);
+	s.syncAsByte(_leaveRoomFl);
+
+	s.syncAsSint32LE(_tapePlayerHotspotIdx);
+	s.syncAsSint32LE(_hotspot1Idx);
+	s.syncAsSint32LE(_hotspot2Idx);
+	s.syncAsSint32LE(_lampHostpotIdx);
+	s.syncAsSint32LE(_commonSequenceIdx);
+	s.syncAsSint32LE(_commonSpriteIndex);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene353::setup() {
@@ -4811,6 +4949,13 @@ void Scene359::actions() {
 	_action._inProgress = false;
 }
 
+void Scene359::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+
+	s.syncAsSint32LE(_cardHotspotId);
+}
+
+
 /*------------------------------------------------------------------------*/
 
 void Scene360::setup() {
@@ -5450,6 +5595,13 @@ void Scene389::actions() {
 	_action._inProgress = false;
 }
 
+void Scene389::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+
+	s.syncAsUint32LE(_monsterTime);
+	s.syncAsSint32LE(_circularQuoteId);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene390::setup() {
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index d40b363..f6d1ab5 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -38,6 +38,15 @@ typedef struct {
 	int _horizontal;
 	int _seqId[40];
 	uint32 _timer;
+
+	void synchronize(Common::Serializer &s) {
+		s.syncAsByte(_flag);
+		s.syncAsSint32LE(_vertical);
+		s.syncAsSint32LE(_horizontal);
+		for (int i = 0; i < 40; ++i)
+			s.syncAsSint32LE(_seqId[i]);
+		s.syncAsUint32LE(_timer);
+	};
 } ForceField;
 
 class Scene3xx : public NebularScene {
@@ -90,6 +99,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene303: public Scene3xx {
@@ -111,6 +121,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene307: public Scene3xx {
@@ -132,7 +143,7 @@ private:
 
 	Common::String _subQuote2;
 
-	Conversation dialog1, dialog2;
+	Conversation _dialog1, _dialog2;
 
 	void handleDialog();
 	void handleRexDialog(int quote);
@@ -148,6 +159,7 @@ public:
 	virtual void enter();
 	virtual void step();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene308: public Scene3xx {
@@ -160,6 +172,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene309: public Scene3xx {
@@ -175,6 +188,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene310: public Scene3xx {
@@ -187,6 +201,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene311: public Scene3xx {
@@ -200,6 +215,7 @@ public:
 	virtual void enter();
 	virtual void step();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene313: public Scene3xx {
@@ -245,7 +261,7 @@ private:
 
 	Common::String _subQuote2;
 
-	Conversation dialog1;
+	Conversation _dialog1;
 
 	void handleDialog();
 	void handleRexDialogs(int quote);
@@ -259,6 +275,7 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene319: public Scene3xx {
@@ -286,6 +303,7 @@ public:
 	virtual void enter();
 	virtual void step();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene320: public Scene300s {
@@ -310,6 +328,7 @@ public:
 	virtual void enter();
 	virtual void step();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene321: public Scene3xx {
@@ -363,6 +382,7 @@ public:
 	virtual void enter();
 	virtual void preActions();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene353: public Scene3xx {
@@ -415,6 +435,7 @@ public:
 	virtual void enter();
 	virtual void preActions();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene360: public Scene3xx {
@@ -482,6 +503,7 @@ public:
 	virtual void enter();
 	virtual void step();
 	virtual void actions();
+	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene390: public Scene300s {


Commit: 189b629b338cb0658507776a71e9a37376ad15bb
    https://github.com/scummvm/scummvm/commit/189b629b338cb0658507776a71e9a37376ad15bb
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-08T01:51:05+03:00

Commit Message:
MADS: Synchronize the remaining local scene variables for Rex scene group 4

Changed paths:
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes4.h



diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index 1bb53ed..91c522c 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -2729,6 +2729,12 @@ void Scene406::actions() {
 	_action._inProgress = false;
 }
 
+void Scene406::synchronize(Common::Serializer &s) {
+	Scene4xx::synchronize(s);
+
+	s.syncAsByte(_hitStorageDoor);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene407::setup() {
@@ -2782,16 +2788,16 @@ void Scene407::preActions() {
 
 	if (_game._player._needToWalk && _fromNorth) {
 		if (_globals[kSexOfRex] == REX_MALE)
-			destPos = Common::Point(171, 95);
+			_destPos = Common::Point(171, 95);
 		else
-			destPos = Common::Point(173, 96);
+			_destPos = Common::Point(173, 96);
 
-		_game._player.walk(destPos, FACING_SOUTH);
+		_game._player.walk(_destPos, FACING_SOUTH);
 	}
 }
 
 void Scene407::actions() {
-	if ((_game._player._playerPos == destPos) && _fromNorth) {
+	if ((_game._player._playerPos == _destPos) && _fromNorth) {
 		if (_globals[kSexOfRex] == REX_MALE) {
 			_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 			_game._player._stepEnabled = false;
@@ -2837,6 +2843,14 @@ void Scene407::actions() {
 	_action._inProgress = false;
 }
 
+void Scene407::synchronize(Common::Serializer &s) {
+	Scene4xx::synchronize(s);
+
+	s.syncAsByte(_fromNorth);
+	s.syncAsSint16LE(_destPos.x);
+	s.syncAsSint16LE(_destPos.y);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene408::setup() {
@@ -3957,6 +3971,24 @@ void Scene411::actions() {
 	_action._inProgress = false;
 }
 
+void Scene411::synchronize(Common::Serializer &s) {
+	Scene4xx::synchronize(s);
+
+	s.syncAsSint32LE(_curAnimationFrame);
+	s.syncAsSint32LE(_newIngredient);
+	s.syncAsSint32LE(_newQuantity);
+	s.syncAsSint32LE(_resetFrame);
+	s.syncAsSint32LE(_badThreshold);
+
+	s.syncAsByte(_killRox);
+	s.syncAsByte(_makeMushroomCloud);
+
+	_dialog1.synchronize(s);
+	_dialog2.synchronize(s);
+	_dialog3.synchronize(s);
+	_dialog4.synchronize(s);
+}
+
 /*------------------------------------------------------------------------*/
 
 void Scene413::setup() {
@@ -4102,6 +4134,13 @@ void Scene413::actions() {
 	_action._inProgress = false;
 }
 
+void Scene413::synchronize(Common::Serializer &s) {
+	Scene4xx::synchronize(s);
+
+	s.syncAsSint32LE(_rexDeath);
+	s.syncAsSint32LE(_canMove);
+}
+
 /*------------------------------------------------------------------------*/
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/nebular_scenes4.h b/engines/mads/nebular/nebular_scenes4.h
index 1f7b56b..f2e8961 100644
--- a/engines/mads/nebular/nebular_scenes4.h
+++ b/engines/mads/nebular/nebular_scenes4.h
@@ -148,6 +148,7 @@ private:
 
 public:
 	Scene406(MADSEngine *vm) : Scene4xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -160,10 +161,11 @@ public:
 class Scene407: public Scene4xx {
 private:
 	bool _fromNorth;
-	Common::Point destPos;
+	Common::Point _destPos;
 
 public:
 	Scene407(MADSEngine *vm) : Scene4xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -236,6 +238,7 @@ private:
 
 public:
 	Scene411(MADSEngine *vm) : Scene4xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -252,6 +255,7 @@ private:
 
 public:
 	Scene413(MADSEngine *vm) : Scene4xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();


Commit: e89b16a5f2cab78b5031337d9a86a70f2cffdc5b
    https://github.com/scummvm/scummvm/commit/e89b16a5f2cab78b5031337d9a86a70f2cffdc5b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-08T02:44:31+03:00

Commit Message:
MADS: Reset the font in KernelMessages::reset()

Fixes the dialog font with the native woman in scene 210, after it gets
set to the interface font in scene 208

Changed paths:
    engines/mads/messages.cpp



diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index 2f59a67..08e86e2 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -137,6 +137,7 @@ void KernelMessages::reset() {
 	for (uint i = 0; i < _entries.size(); ++i)
 		remove(i);
 
+	_talkFont = _vm->_font->getFont(FONT_CONVERSATION);
 	warning("TODO: KernelMessages::reset - sub_20454");
 }
 


Commit: 3600205ba23c813533711e2eeeafd2b4867623bb
    https://github.com/scummvm/scummvm/commit/3600205ba23c813533711e2eeeafd2b4867623bb
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-08T02:52:54+03:00

Commit Message:
MADS: Use the font friendly name in Scene::clearMessageList()

Changed paths:
    engines/mads/scene.cpp



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 62a0e20..609e233 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -104,7 +104,7 @@ void Scene::clearSequenceList() {
 
 void Scene::clearMessageList() {
 	_kernelMessages.clear();
-	_talkFont = "*FONTCONV.FF";
+	_talkFont = FONT_CONVERSATION;
 	_textSpacing  = -1;
 }
 


Commit: ff3b6e4f05bf01073e7d0aa423b80340c86f7132
    https://github.com/scummvm/scummvm/commit/ff3b6e4f05bf01073e7d0aa423b80340c86f7132
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-08T03:05:22+03:00

Commit Message:
MADS: Use friendly name for the deep pit in scene 208

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 0736b3d..26c062c 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1651,7 +1651,7 @@ void Scene208::updateTrap() {
 	case 2: {
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 15);
 		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
-		_scene->_hotspots.activate(414, false);
+		_scene->_hotspots.activate(NOUN_DEEP_PIT, false);
 		int idx = _scene->_dynamicHotspots.add(NOUN_LEAF_COVERED_PIT, VERB_WALKTO, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(100, 146), FACING_NORTH);
 		_scene->_dynamicHotspots[idx]._articleNumber = PREP_ON;


Commit: 056e9b083f25c8c6dfeaf32af84555c421ee1765
    https://github.com/scummvm/scummvm/commit/056e9b083f25c8c6dfeaf32af84555c421ee1765
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-08T03:06:29+03:00

Commit Message:
MADS: Bugfix for using objects on dynamic hotspots

This fixes usage of the twinkifruit on the trap in scene 208

Changed paths:
    engines/mads/action.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 3367521..fd6a90f 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -218,7 +218,7 @@ void MADSAction::set() {
 			} else if (_secondObject < (int)scene._hotspots.size()) {
 				_action._indirectObjectId = scene._hotspots[_secondObject]._vocabId;
 			} else {
-				_action._indirectObjectId = scene._hotspots[_secondObject - scene._hotspots.size()]._vocabId;
+				_action._indirectObjectId = scene._dynamicHotspots[_secondObject - scene._hotspots.size()]._descId;
 			}
 		}
 
@@ -230,10 +230,10 @@ void MADSAction::set() {
 					if ((_secondObjectSource == 2) || (_secondObjectSource == 5)) {
 						InventoryObject &invObject = _vm->_game->_objects.getItem(_hotspotId);
 						articleNum = invObject._article;
-					} else if (_secondObject < (int)scene._hotspots.size()) {
+					} else if (_hotspotId < (int)scene._hotspots.size()) {
 						articleNum = scene._hotspots[_hotspotId]._articleNumber;
 					} else {
-						articleNum = scene._hotspots[_hotspotId - scene._hotspots.size()]._articleNumber;
+						articleNum = scene._dynamicHotspots[_hotspotId - scene._hotspots.size()]._articleNumber;
 					}
 
 					_statusText += kArticleList[articleNum];


Commit: 99ea49fe6189f3e7d66e28be64eaab23dac9aeb4
    https://github.com/scummvm/scummvm/commit/99ea49fe6189f3e7d66e28be64eaab23dac9aeb4
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-08T03:38:05+03:00

Commit Message:
MADS: Add a FIXME in UserInterface::updateInventoryScroller()

Changed paths:
    engines/mads/user_interface.cpp



diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index e8eaf3a..e23ecf4 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -499,7 +499,8 @@ void UserInterface::updateInventoryScroller() {
 
 	if ((
 		(screenObjects._category == CAT_INV_SCROLLER) ||
-		(screenObjects._category != CAT_INV_SCROLLER && _scrollbarOldActive == SCROLLBAR_ELEVATOR)
+		// FIXME: This scrolls the inventory up when selecting verbs or attempting to combine items
+		false/*(screenObjects._category != CAT_INV_SCROLLER && _scrollbarOldActive == SCROLLBAR_ELEVATOR)*/
 	) && (_vm->_events->_mouseStatusCopy || _vm->_easyMouse)) {
 		if ((_vm->_events->_mouseClicked || (_vm->_easyMouse && !_vm->_events->_mouseStatusCopy)) 
 				&& (screenObjects._category == CAT_INV_SCROLLER))


Commit: 7cd467dfab498a229da3f83d95111910f33a0cdd
    https://github.com/scummvm/scummvm/commit/7cd467dfab498a229da3f83d95111910f33a0cdd
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-08T03:47:15+03:00

Commit Message:
MADS: Bugfix for combining the poison darts with the plant stalk

Changed paths:
    engines/mads/nebular/game_nebular.cpp



diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 9d6bf89..b1dcfb09 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -358,10 +358,10 @@ void GameNebular::doObjectAction() {
 		dialogs.show(476);
 	} else if (action.isAction(114, 937)) {
 		dialogs.show(477);
-	} else if (action.isAction(VERB_PUT, 276, NOUN_PLANT_STALK) && _objects.isInRoom(OBJ_POISON_DARTS)
-			&& _objects.isInRoom(OBJ_PLANT_STALK)) {
+	} else if (action.isAction(VERB_PUT, 276, NOUN_PLANT_STALK) && _objects.isInInventory(OBJ_POISON_DARTS)
+			&& _objects.isInInventory(OBJ_PLANT_STALK)) {
 		_objects.addToInventory(OBJ_BLOWGUN);
-		_objects.setRoom(OBJ_PLANT_STALK, PLAYER_INVENTORY);
+		_objects.setRoom(OBJ_PLANT_STALK, NOWHERE);
 		_globals[kBlowgunStatus] = 0;
 		dialogs.showItem(OBJ_BLOWGUN, 809);
 	} else if (action.isAction(VERB_PUT, 276, NOUN_BLOWGUN) && _objects.isInInventory(OBJ_POISON_DARTS)


Commit: 4d98dafc5c777501e55d791a80cfcf01b4e1281d
    https://github.com/scummvm/scummvm/commit/4d98dafc5c777501e55d791a80cfcf01b4e1281d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-08T03:51:51+03:00

Commit Message:
MADS: Use friendly name for global 36 (monkey status)

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 26c062c..0eada01 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -2773,7 +2773,7 @@ void Scene209::enter() {
 	if (_scene->_roomChanged) {
 		_game._objects.addToInventory(OBJ_POISON_DARTS);
 		_game._objects.addToInventory(OBJ_BLOWGUN);
-		_globals[36] = 1;
+		_globals[kMonkeyStatus] = 1;
 	}
 
 	_pitchFl = false;
@@ -2801,7 +2801,7 @@ void Scene209::enter() {
 }
 
 void Scene209::step() {
-	if (!_playingAnimFl && !_pitchFl && !_fallFl && !_dodgeFl && (_pauseMode == 0) && (_globals[36] == 1)) {
+	if (!_playingAnimFl && !_pitchFl && !_fallFl && !_dodgeFl && (_pauseMode == 0) && (_globals[kMonkeyStatus] == 1)) {
 		int randAction = _vm->getRandomNumber(1,50);
 		switch (randAction) {
 		case 1:
@@ -3138,7 +3138,7 @@ void Scene209::step() {
 			_startShootingInTimerFl = false;
 
 			if (_fallFl) {
-				_globals[36] = MONKEY_IS_GONE;
+				_globals[kMonkeyStatus] = MONKEY_IS_GONE;
 				_game._objects.setRoom(OBJ_POISON_DARTS, NOWHERE);
 			}
 			_dodgeFl = false;
@@ -3168,7 +3168,7 @@ void Scene209::preActions() {
 	if (_action.isAction(VERB_WALK_TOWARDS, 0x84))
 		_game._player._walkOffScreenSceneId = 208;
 
-	if (_globals[36] == 1) {
+	if (_globals[kMonkeyStatus] == 1) {
 		if ((_action.isAction(NOUN_SHOOT) || _action.isAction(NOUN_HOSE_DOWN)) && _action.isAction(NOUN_MONKEY)
 			&& _action.isAction(NOUN_BLOWGUN) && _game._objects.isInInventory(OBJ_BLOWGUN) && _game._objects.isInInventory(OBJ_POISON_DARTS)) {
 			_game._player._prepareWalkPos = Common::Point(111, 129);
@@ -3305,7 +3305,7 @@ void Scene209::actions() {
 		return;
 	}
 
-	if (_globals[36] == 1) {
+	if (_globals[kMonkeyStatus] == 1) {
 		if ((_action.isAction(NOUN_SHOOT) || _action.isAction(NOUN_HOSE_DOWN)) && _action.isAction(NOUN_MONKEY)
 			&& _action.isAction(NOUN_BLOWGUN) && _game._objects.isInInventory(OBJ_BLOWGUN) && _game._objects.isInInventory(OBJ_POISON_DARTS)) {
 			if (_action.isAction(NOUN_SHOOT, NOUN_BLOWGUN, NOUN_MONKEY) && !_startShootingInTimerFl) {
@@ -3472,13 +3472,13 @@ void Scene209::actions() {
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x100)) {
-		if (_globals[36] == 1) {
+		if (_globals[kMonkeyStatus] == 1) {
 			if (_monkeyPosition == 1)
 				_vm->_dialogs->show(0x51B5);
 			else
 				_vm->_dialogs->show(0x51B6);
 		} else {
-			if (_globals[36] == 0)
+			if (_globals[kMonkeyStatus] == 0)
 				_vm->_dialogs->show(0x51B5);
 			else
 				_vm->_dialogs->show(0x51B7);


Commit: 2502bd89966f8b6398be4fc0428aaba1831ad530
    https://github.com/scummvm/scummvm/commit/2502bd89966f8b6398be4fc0428aaba1831ad530
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-08T10:47:15+03:00

Commit Message:
MADS: Use friendly names in globals

Changed paths:
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index b1dcfb09..9a4fa97 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -44,7 +44,7 @@ GameNebular::GameNebular(MADSEngine *vm): Game(vm) {
 ProtectionResult GameNebular::checkCopyProtection() {
 	/*
 	// DEBUG: Flag copy protection failure
-	_globals[5] = -1;
+	_globals[kCopyProtectFailed] = -1;
 	
 	if (!ConfMan.getBool("copy_protection"))
 		return true;
@@ -271,7 +271,7 @@ void GameNebular::setSectionHandler() {
 }
 
 void GameNebular::checkShowDialog() {
-	if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globals[5]) {
+	if (_vm->_dialogs->_pendingDialog && _player._stepEnabled && !_globals[kCopyProtectFailed]) {
 		_player.releasePlayerSprites();
 		_vm->_dialogs->showDialog();
 		_vm->_dialogs->_pendingDialog = DIALOG_NONE;
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 8dca4e9..ecc80c8 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -191,7 +191,7 @@ void Scene101::enter() {
 
 	_game.loadQuoteSet(0x31, 0x32, 0x39, 0x36, 0x37, 0x38, 0);
 
-	if (_globals[10]) {
+	if (_globals[kNeedToStandUp]) {
 		_scene->loadAnimation(Resources::formatName(101, 'S', -1, EXT_AA, ""), 71);
 		_game._player._visible = false;
 		_game._player._stepEnabled = false;
@@ -222,7 +222,7 @@ void Scene101::step() {
 		break;
 
 	case 71:
-		_globals[10] = false;
+		_globals[kNeedToStandUp] = false;
 		_game._player._visible = true;
 		_game._player._stepEnabled = true;
 		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 0eada01..b86f9db 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1640,7 +1640,7 @@ void Scene208::updateTrap() {
 		return;
 	}
 
-	switch (_globals[35]) {
+	switch (_globals[kLeavesStatus]) {
 	case 0: {
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 15);


Commit: b7dd01fdefd910c3c0f6291145ceab4060ae1a70
    https://github.com/scummvm/scummvm/commit/b7dd01fdefd910c3c0f6291145ceab4060ae1a70
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-08T11:43:23+03:00

Commit Message:
MADS: Remove trailing whitespace

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h
    engines/mads/animation.cpp
    engines/mads/animation.h
    engines/mads/assets.cpp
    engines/mads/compression.cpp
    engines/mads/compression.h
    engines/mads/debugger.cpp
    engines/mads/dialogs.cpp
    engines/mads/dialogs.h
    engines/mads/dragonsphere/game_dragonsphere.cpp
    engines/mads/events.h
    engines/mads/font.cpp
    engines/mads/font.h
    engines/mads/game.cpp
    engines/mads/globals.cpp
    engines/mads/inventory.cpp
    engines/mads/inventory.h
    engines/mads/mads.cpp
    engines/mads/mads.h
    engines/mads/messages.cpp
    engines/mads/messages.h
    engines/mads/msurface.cpp
    engines/mads/msurface.h
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/globals_nebular.h
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h
    engines/mads/nebular/nebular_scenes4.h
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/nebular/sound_nebular.cpp
    engines/mads/nebular/sound_nebular.h
    engines/mads/palette.cpp
    engines/mads/palette.h
    engines/mads/phantom/game_phantom.cpp
    engines/mads/player.cpp
    engines/mads/rails.cpp
    engines/mads/rails.h
    engines/mads/resources.cpp
    engines/mads/resources.h
    engines/mads/scene.cpp
    engines/mads/scene.h
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h
    engines/mads/screen.cpp
    engines/mads/sequence.cpp
    engines/mads/sequence.h
    engines/mads/sprites.cpp
    engines/mads/sprites.h
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index fd6a90f..88a57d6 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -127,7 +127,7 @@ void MADSAction::set() {
 		// Two 'look' actions in succession, so the action becomes 'Look around'
 		_statusText = kLookAroundStr;
 	} else {
-		if ((_commandSource == CAT_INV_VOCAB) && (_selectedRow >= 0) 
+		if ((_commandSource == CAT_INV_VOCAB) && (_selectedRow >= 0)
 				&& (_verbType == VERB_THAT) && (_prepType == PREP_NONE)) {
 			// Use/to action
 			int invIndex = userInterface._selectedInvIndex;
@@ -276,7 +276,7 @@ void MADSAction::refresh() {
 	}
 
 	if (!_statusText.empty()) {
-		if ((_vm->_game->_screenObjects._inputMode == kInputBuildingSentences) || 
+		if ((_vm->_game->_screenObjects._inputMode == kInputBuildingSentences) ||
 				(_vm->_game->_screenObjects._inputMode == kInputLimitedSentences)) {
 			Font *font = _vm->_font->getFont(FONT_MAIN);
 			int textSpacing = -1;
@@ -436,7 +436,7 @@ void MADSAction::checkActionAtMousePos() {
 					_hotspotId = userInterface._selectedInvIndex;
 					_articleNumber = _prepType;
 
-					if ((_verbType == VERB_THIS && _prepType == PREP_NONE) || 
+					if ((_verbType == VERB_THIS && _prepType == PREP_NONE) ||
 							(_verbType == VERB_THAT && _prepType != PREP_NONE))
 						_interAwaiting = AWAITING_RIGHT_MOUSE;
 					else
diff --git a/engines/mads/action.h b/engines/mads/action.h
index 24521d0..af52d2c 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -29,7 +29,7 @@
 
 namespace MADS {
 
-enum TriggerMode { 
+enum TriggerMode {
 	SEQUENCE_TRIGGER_PARSER = 0,		// Triggers parser
 	SEQUENCE_TRIGGER_DAEMON = 1,		// Triggers step/daemon code
 	SEQUENCE_TRIGGER_PREPARE = 2		// Triggers preparser
@@ -61,7 +61,7 @@ enum {
 enum VerbType { VERB_ONLY, VERB_THIS, VERB_THAT };
 
 enum PrepType {
-	PREP_NONE, PREP_WITH, PREP_TO, PREP_AT, PREP_FROM, PREP_ON, PREP_IN, 
+	PREP_NONE, PREP_WITH, PREP_TO, PREP_AT, PREP_FROM, PREP_ON, PREP_IN,
 	PREP_UNDER, PREP_BEHIND, PREP_RELATIONAL = 0xff
 };
 
diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 32f4320..089e21d 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -26,7 +26,7 @@
 #define FILENAME_SIZE 13
 
 namespace MADS {
-	
+
 void AAHeader::load(Common::SeekableReadStream *f) {
 	_spriteSetsCount = f->readUint16LE();
 	_miscEntriesCount = f->readUint16LE();
@@ -232,7 +232,7 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
 
 		delete frameStream;
 	}
-	
+
 	_miscEntries.clear();
 	_uiEntries.clear();
 	if (_header._miscEntriesCount > 0) {
@@ -255,7 +255,7 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
 
 		delete miscStream;
 	}
-	
+
 	// If the animation specifies a font, then load it for access
 	delete _font;
 	if (_header._flags & ANIMFLAG_CUSTOM_FONT) {
@@ -264,7 +264,7 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
 	} else {
 		_font = nullptr;
 	}
-	
+
 	// Load all the sprite sets for the animation
 	for (uint i = 0; i < _spriteSets.size(); ++i)
 		delete _spriteSets[i];
@@ -398,7 +398,7 @@ void Animation::loadInterface(UserInterface &interfaceSurface, MSurface &depthSu
 	}
 }
 
-bool Animation::hasScroll() const { 
+bool Animation::hasScroll() const {
 	return (_header._scrollPosition.x != 0) || (_header._scrollPosition.x != 0);
 }
 
@@ -452,7 +452,7 @@ void Animation::update() {
 		scene._backgroundSurface.scrollY(_header._scrollPosition.y);
 		scene._spriteSlots.fullRefresh();
 	}
-	
+
 	// Handle any offset adjustment for sprites as of this frame
 	bool paChanged = false;
 	if (scene._posAdjust.x != misc._posAdjust.x) {
@@ -542,7 +542,7 @@ void Animation::update() {
 			_vm->_palette->setEntry(colIndex + 1, me._rgb2[0], me._rgb2[1], me._rgb2[2]);
 
 			// Add a kernel message to display the given text
-			me._kernelMsgIndex = scene._kernelMessages.add(me._pos, colIndex * 0x101 + 0x100, 
+			me._kernelMsgIndex = scene._kernelMessages.add(me._pos, colIndex * 0x101 + 0x100,
 				0, 0, INDEFINITE_TIMEOUT, me._msg);
 			assert(me._kernelMsgIndex >= 0);
 			++_messageCtr;
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index aab1743..3c0c254 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -33,9 +33,9 @@
 
 namespace MADS {
 
-enum AnimFlag { 
+enum AnimFlag {
 	ANIMFLAG_DITHER				= 0x0001,	// Dither to 16 colors
-	ANIMFLAG_CUSTOM_FONT		= 0x0020,	// Load ccustom font 
+	ANIMFLAG_CUSTOM_FONT		= 0x0020,	// Load ccustom font
 	ANIMFLAG_LOAD_BACKGROUND	= 0x0100,	// Load background
 	ANIMFLAG_LOAD_BACKGROUND_ONLY = 0x0200	// Load background only
 };
diff --git a/engines/mads/assets.cpp b/engines/mads/assets.cpp
index bf9647d..1cb174b 100644
--- a/engines/mads/assets.cpp
+++ b/engines/mads/assets.cpp
@@ -40,7 +40,7 @@ SpriteAsset::SpriteAsset(MADSEngine *vm, const Common::String &resourceName, int
 
 	file.close();
 }
-	
+
 SpriteAsset::SpriteAsset(MADSEngine *vm, Common::SeekableReadStream *stream, int flags) :
 		_vm(vm) {
 	load(stream, flags);
@@ -152,8 +152,8 @@ void SpriteAsset::load(Common::SeekableReadStream *stream, int flags) {
 		frame._bounds.setHeight(spriteStream->readUint16LE());
 
 		if (curFrame == 0)
-			debugC(1, kDebugGraphics, "%i frames, x = %i, y = %i, w = %i, h = %i\n", 
-			_frameCount, frame._bounds.left, frame._bounds.top, 
+			debugC(1, kDebugGraphics, "%i frames, x = %i, y = %i, w = %i, h = %i\n",
+			_frameCount, frame._bounds.left, frame._bounds.top,
 			frame._bounds.width(), frame._bounds.height());
 
 		if (_mode == 0) {
diff --git a/engines/mads/compression.cpp b/engines/mads/compression.cpp
index 2190fc4..6563de5 100644
--- a/engines/mads/compression.cpp
+++ b/engines/mads/compression.cpp
@@ -34,7 +34,7 @@ bool MadsPack::isCompressed(Common::SeekableReadStream *stream) {
 	char tempBuffer[8];
 	stream->seek(0);
 	if (stream->read(tempBuffer, 8) == 8) {
-		if (!strncmp(tempBuffer, madsPackString, 8)) 
+		if (!strncmp(tempBuffer, madsPackString, 8))
 			return true;
 	}
 
@@ -58,7 +58,7 @@ void MadsPack::initialise(Common::SeekableReadStream *stream) {
 	stream->seek(14);
 	_count = stream->readUint16LE();
 	_items = new MadsPackEntry[_count];
-	
+
 	byte *headerData = new byte[0xA0];
 	byte *header = headerData;
 	stream->read(headerData, 0xA0);
@@ -77,7 +77,7 @@ void MadsPack::initialise(Common::SeekableReadStream *stream) {
 			// Decompress the entry
 			byte *compressedData = new byte[_items[i].compressedSize];
 			stream->read(compressedData, _items[i].compressedSize);
-			
+
 			FabDecompressor fab;
 			fab.decompress(compressedData, _items[i].compressedSize, _items[i].data, _items[i].size);
 			delete[] compressedData;
@@ -100,7 +100,7 @@ void FabDecompressor::decompress(const byte *srcData, int srcSize, byte *destDat
 	byte copyLen, copyOfsShift, copyOfsMask, copyLenMask;
 	unsigned long copyOfs;
 	byte *destP;
-	
+
 	// Validate that the data starts with the FAB header
 	if (strncmp((const char *)srcData, "FAB", 3) != 0)
 		error("FabDecompressor - Invalid compressed data");
@@ -119,7 +119,7 @@ void FabDecompressor::decompress(const byte *srcData, int srcSize, byte *destDat
 	_srcData = srcData;
 	_srcP = _srcData + 6;
 	_srcSize = srcSize;
-	_bitsLeft = 16;	
+	_bitsLeft = 16;
 	_bitBuffer = READ_LE_UINT16(srcData + 4);
 
 	for (;;) {
diff --git a/engines/mads/compression.h b/engines/mads/compression.h
index aa1f0d9..c752b57 100644
--- a/engines/mads/compression.h
+++ b/engines/mads/compression.h
@@ -54,12 +54,12 @@ public:
 	~MadsPack();
 
 	int getCount() const { return _count; }
-	MadsPackEntry &getItem(int index) const { 
+	MadsPackEntry &getItem(int index) const {
 		assert(index < _count);
 		return _items[index]; }
-	MadsPackEntry &operator[](int index) const { 
+	MadsPackEntry &operator[](int index) const {
 		assert(index < _count);
-		return _items[index]; 
+		return _items[index];
 	}
 	Common::MemoryReadStream *getItemStream(int index) {
 		assert(index < _count);
diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp
index 80a8cb7..3594c83 100644
--- a/engines/mads/debugger.cpp
+++ b/engines/mads/debugger.cpp
@@ -175,7 +175,7 @@ bool Debugger::Cmd_DumpFile(int argc, const char **argv) {
 		} else {
 			outFile.open(argv[1]);
 			byte *data = new byte[inFile.size()];
-			
+
 			inFile.read(data, inFile.size());
 			outFile.write(data, inFile.size());
 
@@ -186,7 +186,7 @@ bool Debugger::Cmd_DumpFile(int argc, const char **argv) {
 			DebugPrintf("File written successfully.\n");
 		}
 	}
-	
+
 	return true;
 }
 
diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index 519b273..e68411a 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -40,7 +40,7 @@ Dialog::~Dialog() {
 
 void Dialog::save(MSurface *s) {
 	_savedSurface = new MSurface(_width, _height);
-	s->copyTo(_savedSurface, 
+	s->copyTo(_savedSurface,
 		Common::Rect(_position.x, _position.y, _position.x + _width, _position.y + _height),
 		Common::Point());
 
@@ -87,7 +87,7 @@ void Dialog::drawContent(const Common::Rect &r, int seed, byte color1, byte colo
 
 	for (int yp = 0; yp < r.height(); ++yp) {
 		byte *destP = _vm->_screen.getBasePtr(r.left, r.top + yp);
-		
+
 		for (int xp = 0; xp < r.width(); ++xp) {
 			uint16 seedAdjust = currSeed;
 			currSeed += 0x181D;
@@ -103,13 +103,13 @@ void Dialog::drawContent(const Common::Rect &r, int seed, byte color1, byte colo
 
 /*------------------------------------------------------------------------*/
 
-TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName, 
+TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName,
 		const Common::Point &pos, int maxChars):
 		Dialog(vm) {
 	_vm = vm;
 	_font = _vm->_font->getFont(fontName);
 	_position = pos;
-	
+
 	_vm->_font->setColors(TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK, TEXTDIALOG_BLACK);
 
 	_innerWidth = (_font->maxWidth() + 1) * maxChars;
@@ -123,8 +123,8 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName,
 	_askXp = 0;
 
 	// Save the high end of the palette, and set up the entries for dialog display
-	Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3], 
-		&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3 + 8 * 3], 
+	Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3],
+		&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3 + 8 * 3],
 		&_cyclingPalette[0]);
 	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_CONTENT1, 2, 0x90, 0x80);
 	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_EDGE, 2, 0x9C, 0x70);
@@ -177,7 +177,7 @@ void TextDialog::wordWrap(const Common::String &line) {
 
 	if (!line.empty()) {
 		const char *srcP = line.c_str();
-		
+
 		do {
 			tempLine = "";
 			bool endWord = false;
@@ -274,11 +274,11 @@ void TextDialog::draw() {
 	Dialog::draw();
 
 	// Draw the text lines
-	int lineYp = _position.y + 5; 
+	int lineYp = _position.y + 5;
 	for (int lineNum = 0; lineNum <= _numLines; ++lineNum) {
 		if (_lineXp[lineNum] == -1) {
 			// Draw a line across the entire dialog
-			_vm->_screen.hLine(_position.x + 2, 
+			_vm->_screen.hLine(_position.x + 2,
 				lineYp + (_font->getHeight() + 1)  / 2,
 				_position.x + _width - 4, TEXTDIALOG_BLACK);
 		} else {
@@ -288,7 +288,7 @@ void TextDialog::draw() {
 			if (_lineXp[lineNum] & 0x40)
 				++yp;
 
-			_font->writeString(&_vm->_screen, _lines[lineNum], 
+			_font->writeString(&_vm->_screen, _lines[lineNum],
 				Common::Point(xp, yp), 1);
 
 			if (_lineXp[lineNum] & 0x80) {
@@ -314,7 +314,7 @@ void TextDialog::drawWithInput() {
 	drawContent(Common::Rect(_position.x + 2, _position.y + 2,
 		_position.x + _width - 2, _position.y + _height - 2), 0,
 		TEXTDIALOG_CONTENT1, TEXTDIALOG_CONTENT2);
-	
+
 	error("TODO: drawWithInput");
 }
 
@@ -342,7 +342,7 @@ void TextDialog::show() {
 
 /*------------------------------------------------------------------------*/
 
-MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...): 
+MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...):
 		TextDialog(vm, FONT_INTERFACE, Common::Point(-1, -1), maxChars) {
 	// Add in passed line list
 	va_list va;
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index 884f7e6..d06611b 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -123,7 +123,7 @@ public:
 	 * @param pos			Position for window top-left
 	 * @param maxChars		Horizontal width of window in characters
 	 */
-	TextDialog(MADSEngine *vm, const Common::String &fontName, const Common::Point &pos, 
+	TextDialog(MADSEngine *vm, const Common::String &fontName, const Common::Point &pos,
 		int maxChars);
 
 	/**
@@ -162,7 +162,7 @@ public:
 	void addInput();
 
 	/**
-	 * Adds a bar line to separate sections of text 
+	 * Adds a bar line to separate sections of text
 	 */
 	void addBarLine();
 
diff --git a/engines/mads/dragonsphere/game_dragonsphere.cpp b/engines/mads/dragonsphere/game_dragonsphere.cpp
index 7d3864e..49c3846 100644
--- a/engines/mads/dragonsphere/game_dragonsphere.cpp
+++ b/engines/mads/dragonsphere/game_dragonsphere.cpp
@@ -44,7 +44,7 @@ ProtectionResult GameDragonsphere::checkCopyProtection() {
 	/*
 	// DEBUG: Flag copy protection failure
 	_globals[5] = -1;
-	
+
 	if (!ConfMan.getBool("copy_protection"))
 		return true;
 
diff --git a/engines/mads/events.h b/engines/mads/events.h
index 5f9a899..3d7504c 100644
--- a/engines/mads/events.h
+++ b/engines/mads/events.h
@@ -31,11 +31,11 @@
 
 namespace MADS {
 
-enum CursorType { CURSOR_NONE = 0, CURSOR_ARROW = 1, CURSOR_WAIT = 2, CURSOR_GO_DOWN = 3, 
+enum CursorType { CURSOR_NONE = 0, CURSOR_ARROW = 1, CURSOR_WAIT = 2, CURSOR_GO_DOWN = 3,
 	CURSOR_GO_UP = 4, CURSOR_GO_LEFT = 5, CURSOR_GO_RIGHT = 6 };
 
 #define GAME_FRAME_RATE 50
-#define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE) 
+#define GAME_FRAME_TIME (1000 / GAME_FRAME_RATE)
 
 class MADSEngine;
 
@@ -154,7 +154,7 @@ public:
 	void initVars();
 
 	/**
-	 * Returns true if there's any pending keys to be processed 
+	 * Returns true if there's any pending keys to be processed
 	 */
 	bool isKeyPressed() const { return !_pendingKeys.empty(); }
 };
diff --git a/engines/mads/font.cpp b/engines/mads/font.cpp
index ba10099..6f2d2b8 100644
--- a/engines/mads/font.cpp
+++ b/engines/mads/font.cpp
@@ -145,7 +145,7 @@ int Font::writeString(MSurface *surface, const Common::String &msg, const Common
 
 	int x = pt.x;
 	int y = pt.y;
-	
+
 	int skipY = 0;
 	if (y < 0) {
 		skipY = -y;
@@ -173,7 +173,7 @@ int Font::writeString(MSurface *surface, const Common::String &msg, const Common
 	while (*text) {
 		char theChar = (*text++) & 0x7F;
 		int charWidth = _charWidths[(byte)theChar];
-		
+
 		if (charWidth > 0) {
 
 			if (xPos + charWidth > xEnd)
@@ -212,7 +212,7 @@ int Font::writeString(MSurface *surface, const Common::String &msg, const Common
 		}
 
 		xPos += charWidth + spaceWidth;
-		
+
 	}
 
 	return xPos;
diff --git a/engines/mads/font.h b/engines/mads/font.h
index 1511b60..1d73328 100644
--- a/engines/mads/font.h
+++ b/engines/mads/font.h
@@ -39,8 +39,8 @@ namespace MADS {
 #define FONT_TELE "*FONTTELE.FF"	// Not in Phantom
 #define FONT_PHAN "*FONTPHAN.FF"	// Phantom only
 
-enum SelectionMode { 
-	SELMODE_UNSELECTED = 0, SELMODE_HIGHLIGHTED = 1, SELMODE_SELECTED = 2 
+enum SelectionMode {
+	SELMODE_UNSELECTED = 0, SELMODE_HIGHLIGHTED = 1, SELMODE_SELECTED = 2
 };
 
 class MADSEngine;
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 65790d3..3f6c8e0 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -56,7 +56,7 @@ Game *Game::init(MADSEngine *vm) {
 	return nullptr;
 }
 
-Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm), 
+Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 		_scene(vm), _screenObjects(vm), _player(vm) {
 	_sectionNumber = _priorSectionNumber = 0;
 	_loadGameSlot = -1;
@@ -106,7 +106,7 @@ void Game::run() {
 
 	_statusFlag = true;
 	int protectionResult = -1;
-	
+
 	if (_loadGameSlot == -1) {
 		protectionResult = checkCopyProtection();
 		switch (protectionResult) {
@@ -203,7 +203,7 @@ void Game::sectionLoop() {
 		_screenObjects._forceRescan = true;
 		_screenObjects._inputMode = kInputBuildingSentences;
 		_scene._userInterface._scrollbarActive = SCROLLBAR_NONE;
-		
+
 		_player._loadsFirst = true;
 
 		_scene._sceneLogic->setup();
@@ -222,7 +222,7 @@ void Game::sectionLoop() {
 		_scene._scenePaletteUsage.push_back(PaletteUsage::UsageEntry(0xF1));
 		_scene._scenePaletteUsage.push_back(PaletteUsage::UsageEntry(0xF2));
 		_vm->_palette->_paletteUsage.load(&_scene._scenePaletteUsage);
-		
+
 		if (!_player._spritesLoaded && _player._loadsFirst) {
 			if (_player.loadSprites(""))
 				_vm->quitGame();
@@ -342,9 +342,9 @@ void Game::initSection(int sectionNumber) {
 		_vm->_palette->setPalette(_vm->_palette->_mainPalette, 0, 4);
 
 	_vm->_events->loadCursors("*CURSOR.SS");
-	
+
 	assert(_vm->_events->_cursorSprites);
-	_vm->_events->setCursor2((_vm->_events->_cursorSprites->getCount() <= 1) ? 
+	_vm->_events->setCursor2((_vm->_events->_cursorSprites->getCount() <= 1) ?
 		CURSOR_ARROW : CURSOR_WAIT);
 }
 
@@ -474,9 +474,9 @@ void Game::synchronize(Common::Serializer &s, bool phase1) {
 void Game::loadGame(int slotNumber) {
 	_saveFile = g_system->getSavefileManager()->openForLoading(
 		_vm->generateSaveName(slotNumber));
-	
+
 	Common::Serializer s(_saveFile, nullptr);
-	
+
 	// Load the savaegame header
 	MADSSavegameHeader header;
 	if (!readSavegameHeader(_saveFile, header))
diff --git a/engines/mads/globals.cpp b/engines/mads/globals.cpp
index 2343dd9..f46ca1e 100644
--- a/engines/mads/globals.cpp
+++ b/engines/mads/globals.cpp
@@ -39,7 +39,7 @@ void Globals::synchronize(Common::Serializer &s) {
 		for (int idx = 0; idx < count; ++idx) {
 			v = _data[idx];
 			s.syncAsSint16LE(v);
-		}	
+		}
 	} else {
 		_data.clear();
 		for (int idx = 0; idx < count; ++idx) {
diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index fecb1b3..d41a55f 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -31,7 +31,7 @@ void InventoryObject::synchronize(Common::Serializer &s) {
 	s.syncAsUint16LE(_roomNumber);
 	s.syncAsByte(_article);
 	s.syncAsByte(_vocabCount);
-	
+
 	for (int i = 0; i < 3; ++i) {
 		s.syncAsByte(_vocabList[i]._verbType);
 		s.syncAsByte(_vocabList[i]._prepType);
@@ -142,7 +142,7 @@ void InventoryObjects::addToInventory(int objectId) {
 
 		(*this)[objectId]._roomNumber = PLAYER_INVENTORY;
 
-		if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE && 
+		if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE &&
 				_vm->_game->_screenObjects._inputMode == kInputBuildingSentences) {
 			userInterface.categoryChanged();
 			userInterface.selectObject(userInterface._selectedInvIndex);
@@ -164,7 +164,7 @@ void InventoryObjects::removeFromInventory(int objectId, int newScene) {
 	int selectedIndex = userInterface._selectedInvIndex;
 	bool noSelection = selectedIndex < 0;
 
-	if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE && 
+	if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE &&
 			_vm->_game->_screenObjects._inputMode == kInputBuildingSentences)
 		userInterface.selectObject(-1);
 
@@ -186,7 +186,7 @@ void InventoryObjects::removeFromInventory(int objectId, int newScene) {
 			newIndex = 0;
 	}
 
-	if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE && 
+	if (_vm->_game->_kernelMode == KERNEL_ACTIVE_CODE &&
 			_vm->_game->_screenObjects._inputMode == kInputBuildingSentences) {
 		userInterface.categoryChanged();
 		userInterface.selectObject(newIndex);
diff --git a/engines/mads/inventory.h b/engines/mads/inventory.h
index f3c63f8..9d79431 100644
--- a/engines/mads/inventory.h
+++ b/engines/mads/inventory.h
@@ -62,7 +62,7 @@ private:
 public:
 	SynchronizedList _inventoryList;
 
-	/** 
+	/**
 	 * Constructor
 	 */
 	InventoryObjects(MADSEngine *vm): _vm(vm) {}
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 9587efa..193346d 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -37,7 +37,7 @@ namespace MADS {
 
 MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :
 		_gameDescription(gameDesc), Engine(syst), _randomSource("MADS") {
-	
+
 	// Initialise fields
 	_easyMouse = true;
 	_invObjectsAnimated = true;
@@ -122,7 +122,7 @@ int MADSEngine::hypotenuse(int xv, int yv) {
 }
 
 bool MADSEngine::canLoadGameStateCurrently() {
-	return !_game->_winStatus && !_game->globals()[5] 
+	return !_game->_winStatus && !_game->globals()[5]
 		&& _dialogs->_pendingDialog == DIALOG_NONE
 		&& _events->_cursorId != CURSOR_WAIT;
 }
diff --git a/engines/mads/mads.h b/engines/mads/mads.h
index 61d61a2..3f325fd 100644
--- a/engines/mads/mads.h
+++ b/engines/mads/mads.h
@@ -137,7 +137,7 @@ public:
 	Common::String generateSaveName(int slot);
 
 	/**
-	 * Handles loading a game via the GMM 
+	 * Handles loading a game via the GMM
 	 */
 	virtual Common::Error loadGameState(int slot);
 
diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index 08e86e2..e498ab9 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -50,9 +50,9 @@ void KernelMessages::clear() {
 	scene._textSpacing = -1;
 }
 
-int KernelMessages::add(const Common::Point &pt, uint fontColor, uint8 flags, 
+int KernelMessages::add(const Common::Point &pt, uint fontColor, uint8 flags,
 		uint8 abortTimers, uint32 timeout, const Common::String &msg) {
-	Scene &scene = _vm->_game->_scene; 
+	Scene &scene = _vm->_game->_scene;
 
 	// Find a free slot
 	uint idx = 0;
@@ -80,7 +80,7 @@ int KernelMessages::add(const Common::Point &pt, uint fontColor, uint8 flags,
 	rec._actionDetails = scene._action._activeAction;
 
 	if (flags & KMSG_PLAYER_TIMEOUT)
-		rec._frameTimer = _vm->_game->_player._ticksAmount + 
+		rec._frameTimer = _vm->_game->_player._ticksAmount +
 			_vm->_game->_player._priorTimer;
 
 	return idx;
@@ -88,7 +88,7 @@ int KernelMessages::add(const Common::Point &pt, uint fontColor, uint8 flags,
 
 int KernelMessages::addQuote(int quoteId, int abortTimers, uint32 timeout) {
 	Common::String quoteStr = _vm->_game->getQuote(quoteId);
-	return add(Common::Point(), 0x1110, KMSG_PLAYER_TIMEOUT | KMSG_CENTER_ALIGN, 
+	return add(Common::Point(), 0x1110, KMSG_PLAYER_TIMEOUT | KMSG_CENTER_ALIGN,
 		abortTimers, timeout, quoteStr);
 }
 
@@ -104,7 +104,7 @@ void KernelMessages::scrollMessage(int msgIndex, int numTicks, bool quoted) {
 	Common::String msg = _entries[msgIndex]._msg;
 
 	if (_entries[msgIndex]._flags & KMSG_PLAYER_TIMEOUT)
-		_entries[msgIndex]._frameTimer2 = _vm->_game->_player._ticksAmount + 
+		_entries[msgIndex]._frameTimer2 = _vm->_game->_player._ticksAmount +
 		_vm->_game->_player._priorTimer;
 
 	_entries[msgIndex]._frameTimer = _entries[msgIndex]._frameTimer2;
@@ -269,7 +269,7 @@ void KernelMessages::processText(int msgIndex) {
 
 	if (msg._textDisplayIndex < 0) {
 		// Need to create a new text display entry for this message
-		int idx = scene._textDisplay.add(x1, y1, msg._color1 | (msg._color2 << 8), 
+		int idx = scene._textDisplay.add(x1, y1, msg._color1 | (msg._color2 << 8),
 			scene._textSpacing, displayMsg, _talkFont);
 		if (idx >= 0)
 			msg._textDisplayIndex = idx;
@@ -330,7 +330,7 @@ void TextDisplayList::reset() {
 		(*this)[i]._active = false;
 }
 
-int TextDisplayList::add(int xp, int yp, uint fontColor, int charSpacing, 
+int TextDisplayList::add(int xp, int yp, uint fontColor, int charSpacing,
 		const Common::String &msg, Font *font) {
 	int usedSlot = -1;
 
@@ -387,7 +387,7 @@ void TextDisplayList::draw(MSurface *s) {
 		if (td._active && (td._expire >= 0)) {
 			td._font->setColors(0xFF, td._color1, td._color2, 0);
 			td._font->writeString(s, td._msg,
-				Common::Point(td._bounds.left, td._bounds.top), 
+				Common::Point(td._bounds.left, td._bounds.top),
 				td._spacing, td._bounds.width());
 		}
 	}
diff --git a/engines/mads/messages.h b/engines/mads/messages.h
index a6d3928..8aa8cd5 100644
--- a/engines/mads/messages.h
+++ b/engines/mads/messages.h
@@ -36,8 +36,8 @@ namespace MADS {
 #define TEXT_DISPLAY_SIZE 40
 
 enum KernelMessageFlags {
-	KMSG_QUOTED = 1, KMSG_PLAYER_TIMEOUT = 2, KMSG_SEQ_ENTRY = 4, KMSG_SCROLL = 8, 
-	KMSG_RIGHT_ALIGN = 0x10, KMSG_CENTER_ALIGN = 0x20, KMSG_EXPIRE = 0x40, 
+	KMSG_QUOTED = 1, KMSG_PLAYER_TIMEOUT = 2, KMSG_SEQ_ENTRY = 4, KMSG_SCROLL = 8,
+	KMSG_RIGHT_ALIGN = 0x10, KMSG_CENTER_ALIGN = 0x20, KMSG_EXPIRE = 0x40,
 	KMSG_ACTIVE = 0x80
 };
 
@@ -74,7 +74,7 @@ public:
 	~KernelMessages();
 
 	void clear();
-	int add(const Common::Point &pt, uint fontColor, uint8 flags, uint8 abortTimers, 
+	int add(const Common::Point &pt, uint fontColor, uint8 flags, uint8 abortTimers,
 		uint32 timeout, const Common::String &msg);
 	int addQuote(int quoteId, int abortTimers, uint32 timeout);
 	void scrollMessage(int msgIndex, int numTicks, bool quoted);
@@ -115,7 +115,7 @@ public:
 	void expire(int idx);
 
 	int add(int xp, int yp, uint fontColor, int charSpacing, const Common::String &, Font *font);
-	
+
 	/**
 	 * Reset all of the text display entries in the list to inactive
 	 */
@@ -126,7 +126,7 @@ public:
 	 * @param surface	Surface
 	 */
 	void draw(MSurface *s);
-	
+
 	/**
 	 * Determine dirty areas for active text areas
 	 */
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 64b3ae1..5d1e948 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -37,10 +37,10 @@ MSurface::MSurface() {
 	_freeFlag = false;
 }
 
-MSurface::MSurface(int width, int height) { 
+MSurface::MSurface(int width, int height) {
 	pixels = nullptr;
 	_freeFlag = false;
-	setSize(width, height); 
+	setSize(width, height);
 }
 
 MSurface::~MSurface() {
@@ -203,7 +203,7 @@ void MSurface::drawSprite(const Common::Point &pt, SpriteInfo &info, const Commo
 		}
 
 	}
-	
+
 	delete[] scaledLineBuf;
 
 }
@@ -212,10 +212,10 @@ void MSurface::empty() {
 	Common::fill(getBasePtr(0, 0), getBasePtr(0, h), 0);
 }
 
-void MSurface::copyFrom(MSurface *src, const Common::Rect &srcBounds, 
+void MSurface::copyFrom(MSurface *src, const Common::Rect &srcBounds,
 		const Common::Point &destPos, int transparentColor) {
-	// Validation of the rectangle and position	
-	int destX = destPos.x, destY = destPos.y;		
+	// Validation of the rectangle and position
+	int destX = destPos.x, destY = destPos.y;
 	if ((destX >= w) || (destY >= h))
 		return;
 
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index 7cf2bbe..060a7ab 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -63,7 +63,7 @@ public:
 	/**
 	 * Helper method for calculating new dimensions when scaling a sprite
 	 */
-	static int scaleValue(int value, int scale, int err);	
+	static int scaleValue(int value, int scale, int err);
 public:
 	/**
 	 * Basic constructor
@@ -128,7 +128,7 @@ public:
 	 * Returns a pointer to the surface data
 	 */
 	byte *getData() { return (byte *)Graphics::Surface::getPixels(); }
-	
+
 	/**
 	 * Returns a pointer to a given position within the surface
 	 */
@@ -168,8 +168,8 @@ public:
 	/**
 	 * Copies the surface to a given destination surface
 	 */
-	void copyTo(MSurface *dest, int transparentColor = -1) { 
-		dest->copyFrom(this, Common::Rect(w, h), Common::Point(), transparentColor);		
+	void copyTo(MSurface *dest, int transparentColor = -1) {
+		dest->copyFrom(this, Common::Rect(w, h), Common::Point(), transparentColor);
 	}
 
 	/**
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index e6e3151..4d34c76 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -46,7 +46,7 @@ bool DialogsNebular::show(int messageId, int objectId) {
 	bool commandFlag = false;
 	bool crFlag = false;
 	TextDialog *dialog = nullptr;
-	_dialogWidth = 17; 
+	_dialogWidth = 17;
 	_capitalizationMode = kUppercase;
 
 	// Loop through the lines of the returned text
@@ -157,7 +157,7 @@ bool DialogsNebular::show(int messageId, int objectId) {
 
 	if (!centerFlag)
 		dialog->incNumLines();
-	
+
 	// Show the dialog
 	_vm->_events->setCursor(CURSOR_ARROW);
 	dialog->show();
@@ -218,7 +218,7 @@ bool DialogsNebular::textNoun(Common::String &dialogText, int nounNum,
 bool DialogsNebular::commandCheck(const char *idStr, Common::String &valStr,
 		const Common::String &command) {
 	uint idLen = strlen(idStr);
-	
+
 	valStr = (command.size() <= idLen) ? "" : Common::String(command.c_str() + idLen);
 
 	// Check whether the command starts with the given Id
@@ -334,8 +334,8 @@ bool CopyProtectionDialog::getHogAnusEntry(HOGANUS &entry) {
 
 /*------------------------------------------------------------------------*/
 
-PictureDialog::PictureDialog(MADSEngine *vm, const Common::Point &pos, 
-		int maxChars, int objectId) : 
+PictureDialog::PictureDialog(MADSEngine *vm, const Common::Point &pos,
+		int maxChars, int objectId) :
 		TextDialog(vm, FONT_INTERFACE, pos, maxChars), _objectId(objectId) {
 	Scene &scene = _vm->_game->_scene;
 	Palette &palette = *_vm->_palette;
@@ -406,7 +406,7 @@ ScreenDialog::DialogLine::DialogLine(const Common::String &s) {
 
 /*------------------------------------------------------------------------*/
 
-ScreenDialog::ScreenDialog(MADSEngine *vm) : _vm(vm), 
+ScreenDialog::ScreenDialog(MADSEngine *vm) : _vm(vm),
 		_savedSurface(MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT) {
 	Game &game = *_vm->_game;
 	Scene &scene = game._scene;
@@ -466,7 +466,7 @@ ScreenDialog::ScreenDialog(MADSEngine *vm) : _vm(vm),
 		MADS_SCREEN_WIDTH, _vm->_screen._offset.y + 157));
 	*/
 
-	game._fx = _vm->_screenFade == SCREEN_FADE_SMOOTH ? 
+	game._fx = _vm->_screenFade == SCREEN_FADE_SMOOTH ?
 		kCenterVertTransition : kTransitionFadeIn;
 	game._trigger = 0;
 	_vm->_events->setCursor(CURSOR_ARROW);
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 9a4fa97..86435c6 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -45,7 +45,7 @@ ProtectionResult GameNebular::checkCopyProtection() {
 	/*
 	// DEBUG: Flag copy protection failure
 	_globals[kCopyProtectFailed] = -1;
-	
+
 	if (!ConfMan.getBool("copy_protection"))
 		return true;
 
@@ -398,7 +398,7 @@ void GameNebular::doObjectAction() {
 				error("TODO: object_get_folder - loc_29B48");
 				messageId = 860;
 			}
-			
+
 			if (id == OBJ_TAPE_PLAYER && _objects[OBJ_AUDIO_TAPE]._roomNumber == OBJ_TAPE_PLAYER)
 				messageId = 867;
 
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index 921c308..fea90c5 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -284,7 +284,7 @@ class NebularGlobals: public Globals {
 public:
 	SynchronizedList _spriteIndexes;
 	SynchronizedList _sequenceIndexes;
-	
+
 	int _timebombClock, _timebombTimer;
 public:
 	/**
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index ecc80c8..c202fe1 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -124,7 +124,7 @@ void Scene101::sayDang() {
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], 17, 17);
 		_scene->_kernelMessages.add(Common::Point(143, 61), 0x1110, 0, 0, 60, _game.getQuote(57));
 		_scene->_sequences.addTimer(120, 73);
-		break; 
+		break;
 
 	case 73:
 		_vm->_dialogs->show(0x2785);
@@ -278,7 +278,7 @@ void Scene101::preActions() {
 		if (_game._player._needToWalk) {
 			switch (_game._trigger) {
 			case 0:
-				_game._player._needToWalk = false;	
+				_game._player._needToWalk = false;
 				_game._player._stepEnabled = false;
 				_scene->_sequences.remove(_globals._sequenceIndexes[11]);
 				_globals._sequenceIndexes[11] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[11], false, 3, 1, 0, 0);
@@ -1248,7 +1248,7 @@ void Scene103::enter() {
 	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 2, 0);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 0);
 
-	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 25);	
+	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 25);
 	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 2, 72);
 	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 1, 37);
 	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 2, 73);
@@ -1267,7 +1267,7 @@ void Scene103::enter() {
 		_globals._sequenceIndexes[10] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[10], false, 6);
 	else
 		_vm->_game->_scene._hotspots.activate(289, false);
-	
+
 	if (_globals[kTurkeyExploded]) {
 		_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[9], -2, -2);
@@ -1325,7 +1325,7 @@ void Scene103::step() {
 	default:
 		break;
 	}
-	
+
 	if (_scene->_frameStartTime >= _updateClock) {
 		pt = _vm->_game->_player._playerPos;
 		dist = _vm->hypotenuse(pt.x - 79, pt.y - 137);
@@ -1471,7 +1471,7 @@ void Scene103::actions() {
 			_sayHiToBinky = false;
 			break;
 		}
-			
+
 		case 2:
 			_scene->_kernelMessages.reset();
 			_scene->_sequences.addTimer(1, 3);
@@ -1868,25 +1868,25 @@ void Scene105::actions() {
 			_vm->_dialogs->showItem(OBJ_DEAD_FISH, 802, 0);
 		}
 	} else if (_action.isAction(VERB_LOOK, 0x195))
-		_vm->_dialogs->show(0x2905); 
+		_vm->_dialogs->show(0x2905);
 	else if (_action.isAction(VERB_LOOK, 0x4D))
-		_vm->_dialogs->show(0x2906); 
+		_vm->_dialogs->show(0x2906);
 	else if (_action.isAction(VERB_LOOK, 0xF0))
-		_vm->_dialogs->show(0x2907); 
+		_vm->_dialogs->show(0x2907);
 	else if (_action.isAction(VERB_LOOK, 0xDD))
-		_vm->_dialogs->show(0x2908); 
+		_vm->_dialogs->show(0x2908);
 	else if (_action.isAction(VERB_TAKE, 0xDD))
-		_vm->_dialogs->show(0x2909); 
+		_vm->_dialogs->show(0x2909);
 	else if (_action.isAction(VERB_LOOK, 0xE0))
-		_vm->_dialogs->show(0x290A); 
+		_vm->_dialogs->show(0x290A);
 	else if (_action.isAction(VERB_LOOK, 0x65))
-		_vm->_dialogs->show(0x290C); 
+		_vm->_dialogs->show(0x290C);
 	else if (_action.isAction(VERB_LOOK, 0x158))
-		_vm->_dialogs->show(0x290D); 
+		_vm->_dialogs->show(0x290D);
 	else if (_action.isAction(VERB_LOOK, 0xF5))
-		_vm->_dialogs->show(0x290E); 
+		_vm->_dialogs->show(0x290E);
 	else if (_action.isAction(VERB_LOOK, 0x129))
-		_vm->_dialogs->show(0x290F); 
+		_vm->_dialogs->show(0x290F);
 	else
 		return;
 
@@ -2289,7 +2289,7 @@ void Scene108::actions() {
 			_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 			_game._objects.addToInventory(OBJ_DEAD_FISH);
 			_globals[kFishIn108] = false;
-			_vm->_dialogs->showItem(OBJ_DEAD_FISH, 10808); 
+			_vm->_dialogs->showItem(OBJ_DEAD_FISH, 10808);
 		}
 	} else if (_action.isAction(0x15D, 0xF4))
 		_scene->_nextSceneId = 107;
@@ -2618,7 +2618,7 @@ void Scene109::actions() {
 									threshold = 50;
 									break;
 								}
-								
+
 								if (_globals[kHoovicFishEaten] >= threshold) {
 									int randVal = _vm->getRandomNumber(83, 84);
 									_scene->_kernelMessages.add(Common::Point(230, 24), 0xFDFC, 0, 0, 120, _game.getQuote(randVal));
@@ -2690,28 +2690,28 @@ void Scene109::actions() {
 		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
 		_game._objects.addToInventory(OBJ_BURGER);
 	} else if (_action.isAction(VERB_LOOK, 0xF0))
-		_vm->_dialogs->show(0x2A95); 
+		_vm->_dialogs->show(0x2A95);
 	else if (_action.isAction(VERB_LOOK, 0x5A))
-		_vm->_dialogs->show(0x2A96); 
+		_vm->_dialogs->show(0x2A96);
 	else if ((_action.isAction(VERB_TAKE) || _action.isAction(VERB_PULL)) && _action.isAction(0x5A))
-		_vm->_dialogs->show(0x2A97); 
+		_vm->_dialogs->show(0x2A97);
 	else if (_action.isAction(VERB_LOOK, 0x129))
-		_vm->_dialogs->show(0x2A98); 
+		_vm->_dialogs->show(0x2A98);
 	else if (_action.isAction(VERB_TAKE, 0x129))
-		_vm->_dialogs->show(0x2A99); 
+		_vm->_dialogs->show(0x2A99);
 	else if (_action.isAction(VERB_LOOK, 0x45))
-		_vm->_dialogs->show(0x2A9A); 
+		_vm->_dialogs->show(0x2A9A);
 	else if (_action.isAction(VERB_LOOK, 0x178)) {
 		if (_globals[kHoovicAlive])
-			_vm->_dialogs->show(0x2A9B); 
+			_vm->_dialogs->show(0x2A9B);
 		else
 			_vm->_dialogs->show(0x2AA1);
 	} else if (_action.isAction(VERB_LOOK, 0x146))
-		_vm->_dialogs->show(0x2A9C); 
+		_vm->_dialogs->show(0x2A9C);
 	else if (_action.isAction(VERB_LOOK, 0xFC))
-		_vm->_dialogs->show(0x2A9F); 
+		_vm->_dialogs->show(0x2A9F);
 	else if (_action.isAction(VERB_PUT, 0x146))
-		_vm->_dialogs->show(0x2A9E); 
+		_vm->_dialogs->show(0x2A9E);
 	else if (_action.isAction(VERB_LOOK, 0x66))
 		_vm->_dialogs->show(0x2AA2);
 	else
@@ -2835,19 +2835,19 @@ void Scene110::actions() {
 	} else if ((_action._lookFlag) || _action.isAction(VERB_LOOK, 0x3F))
 		_vm->_dialogs->show(0x2AF9);
 	else if (_action.isAction(VERB_LOOK, 0x40) || _action.isAction(0xD1, 0x40))
-		_vm->_dialogs->show(0x2AFA); 
+		_vm->_dialogs->show(0x2AFA);
 	else if (_action.isAction(VERB_LOOK, 0x129))
-		_vm->_dialogs->show(0x2AFB); 
+		_vm->_dialogs->show(0x2AFB);
 	else if (_action.isAction(VERB_TAKE, 0x129))
-		_vm->_dialogs->show(0x2AFC); 
+		_vm->_dialogs->show(0x2AFC);
 	else if (_action.isAction(VERB_LOOK, 0x178))
-		_vm->_dialogs->show(0x2AFD); 
+		_vm->_dialogs->show(0x2AFD);
 	else if (_action.isAction(VERB_LOOK, 0x41))
-		_vm->_dialogs->show(0x2AFE); 
+		_vm->_dialogs->show(0x2AFE);
 	else if (_action.isAction(VERB_LOOK, 0x8F))
-		_vm->_dialogs->show(0x2AFF); 
+		_vm->_dialogs->show(0x2AFF);
 	else if (_action.isAction(VERB_TAKE, 0x8F))
-		_vm->_dialogs->show(0x2B00); 
+		_vm->_dialogs->show(0x2B00);
 	else
 		return;
 
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index 38caf15..80df7f9 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -66,7 +66,7 @@ private:
 
 	void sayDang();
 public:
-	Scene101(MADSEngine *vm) : Scene1xx(vm), _sittingFl(false), _panelOpened(false), _messageNum(0), 
+	Scene101(MADSEngine *vm) : Scene1xx(vm), _sittingFl(false), _panelOpened(false), _messageNum(0),
 		_posY(0), _shieldSpriteIdx(0), _chairHotspotId(0), _oldSpecial(0) {}
 
 	virtual void setup();
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 44deeba..78421e6 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -1139,9 +1139,9 @@ void Scene307::actions() {
 
 void Scene307::synchronize(Common::Serializer &s) {
 	Scene3xx::synchronize(s);
-	
+
 	_forceField.synchronize(s);
-	
+
 	s.syncAsByte(_afterPeeingFl);
 	s.syncAsByte(_duringPeeingFl);
 	s.syncAsByte(_grateOpenedFl);
@@ -1286,7 +1286,7 @@ void Scene308::step() {
 
 void Scene308::synchronize(Common::Serializer &s) {
 	Scene3xx::synchronize(s);
-	
+
 	_forceField.synchronize(s);
 }
 
@@ -1477,7 +1477,7 @@ void Scene309::step() {
 
 void Scene309::synchronize(Common::Serializer &s) {
 	Scene3xx::synchronize(s);
-	
+
 	_forceField.synchronize(s);
 
 	for (int i = 0; i < 3; ++i)
@@ -1522,7 +1522,7 @@ void Scene310::step() {
 
 void Scene310::synchronize(Common::Serializer &s) {
 	Scene3xx::synchronize(s);
-	
+
 	_forceField.synchronize(s);
 }
 
@@ -1817,7 +1817,7 @@ void Scene311::actions() {
 
 void Scene311::synchronize(Common::Serializer &s) {
 	Scene3xx::synchronize(s);
-	
+
 	s.syncAsByte(_checkGuardFl);
 }
 
@@ -3438,7 +3438,7 @@ void Scene319::synchronize(Common::Serializer &s) {
 	s.syncAsByte(_slacheTalkingFl);
 	s.syncAsByte(_slacheReady);
 	s.syncAsByte(_slacheInitFl);
-	
+
 	s.syncString(_subQuote2);
 }
 
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index f6d1ab5..b42238d 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -181,7 +181,7 @@ private:
 	int _characterSpriteIndexes[3];
 	int _messagesIndexes[3];
 	int _lastFrame;
-	
+
 public:
 	Scene309(MADSEngine *vm) : Scene3xx(vm) {}
 
diff --git a/engines/mads/nebular/nebular_scenes4.h b/engines/mads/nebular/nebular_scenes4.h
index f2e8961..8ff2ec5 100644
--- a/engines/mads/nebular/nebular_scenes4.h
+++ b/engines/mads/nebular/nebular_scenes4.h
@@ -110,14 +110,14 @@ private:
 	Conversation _dialog2;
 	Conversation _dialog3;
 	Conversation _dialog4;
- 
+
 	void setDialogNode(int node);
 	void handleConversation1();
 	void handleConversation2();
 	void handleConversation3();
 	void handleConversation4();
 	void handleDialogs();
-	
+
 public:
 	Scene402(MADSEngine *vm) : Scene4xx(vm) {}
 	void synchronize(Common::Serializer &s);
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 4ae2925..42ec3f1 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -226,7 +226,7 @@ void Scene707::enter() {
 	// The original uses Scene7xx_sceneEntrySound
 	if (!_vm->_musicFlag)
 		_vm->_sound->command(2);
-	else 
+	else
 		_vm->_sound->command(25);
 }
 
@@ -337,7 +337,7 @@ void Scene711::enter() {
 	// The original was using Scene7xx_SceneEntrySound()
 	if (!_vm->_musicFlag)
 		_vm->_sound->command(2);
-	else 
+	else
 		_vm->_sound->command(25);
 }
 
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 1ae10ed..0be53ef 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -167,7 +167,7 @@ void Scene804::step() {
 		switch (_game._storyMode) {
 		case STORYMODE_NAUGHTY:
 			if (_scene->_activeAnimation->getCurrentFrame() == 81) {
-				_resetFrame = 80; 
+				_resetFrame = 80;
 				_globals[kInSpace] = false;
 				_globals[kBeamIsUp] = true;
 
@@ -177,7 +177,7 @@ void Scene804::step() {
 			}
 			break;
 
-		case STORYMODE_NICE:			 
+		case STORYMODE_NICE:
 			if (_scene->_activeAnimation->getCurrentFrame() == 68) {
 				_resetFrame = 66;
 				_globals[kInSpace] = false;
@@ -240,10 +240,10 @@ void Scene804::step() {
 		case 26:
 		case 28:
 		case 31:
-			_resetFrame = 0; 
+			_resetFrame = 0;
 			break;
 		}
-	} else {   
+	} else {
 		if ((_scene->_activeAnimation->getCurrentFrame() == 36) && (!_throttleGone)) {
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_throttleGone = true;
diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp
index 5f1d805..de6846b 100644
--- a/engines/mads/nebular/sound_nebular.cpp
+++ b/engines/mads/nebular/sound_nebular.cpp
@@ -74,7 +74,7 @@ void AdlibChannel::enable(int flag) {
 		// WORKAROUND: Original set _soundData pointer to flag. Since this seems
 		// just intended to invalidate any prior pointer, I've replaced it with
 		// a simple null pointer
-		_soundData = nullptr; 
+		_soundData = nullptr;
 	}
 }
 
@@ -185,7 +185,7 @@ ASound::ASound(Audio::Mixer *mixer, const Common::String &filename, int dataOffs
 	assert(_opl);
 
 	_opl->init(getRate());
-	_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, 
+	_mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1,
 		Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
 
 	// Initialise the Adlib
@@ -213,7 +213,7 @@ void ASound::adlibInit() {
 	write(4, 0x80);
 }
 
-int ASound::stop() { 
+int ASound::stop() {
 	command0();
 	int result = _pollResult;
 	_pollResult = 0;
@@ -238,7 +238,7 @@ void ASound::noise() {
 	}
 
 	if (_v2) {
-		setFrequency(_channelNum2, (randomVal & _freqMask2) + _freqBase2);		
+		setFrequency(_channelNum2, (randomVal & _freqMask2) + _freqBase2);
 	}
 }
 
@@ -278,7 +278,7 @@ void ASound::resultCheck() {
 }
 
 byte *ASound::loadData(int offset, int size) {
-	// First scan for an existing copy	
+	// First scan for an existing copy
 	Common::List<CachedDataEntry>::iterator i;
 	for (i = _dataCache.begin(); i != _dataCache.end(); ++i) {
 		CachedDataEntry &e = *i;
@@ -392,7 +392,7 @@ void ASound::checkChannels() {
 }
 
 void ASound::pollActiveChannel() {
-	AdlibChannel *chan = _activeChannelPtr; 
+	AdlibChannel *chan = _activeChannelPtr;
 	bool updateFlag = true;
 
 	if (chan->_activeCount) {
@@ -572,7 +572,7 @@ void ASound::pollActiveChannel() {
 						chan->_field1F = *++pSrc;
 						chan->_pSrc += 2;
 						break;
-					
+
 					default:
 						break;
 					}
@@ -624,7 +624,7 @@ void ASound::updateOctave() {
 }
 
 static int _vList1[] = {
-	0x200, 0x21E, 0x23F, 0x261, 0x285, 0x2AB, 
+	0x200, 0x21E, 0x23F, 0x261, 0x285, 0x2AB,
 	0x2D4, 0x2FF, 0x32D, 0x35D, 0x390, 0x3C7
 };
 
@@ -688,7 +688,7 @@ static const int volumeList[] = {
 	0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04,
 	0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
 	0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01,
-	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 
+	0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
 	0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 };
 
@@ -696,7 +696,7 @@ void ASound::updateActiveChannel() {
 	int reg = 0x40 + outputChannels[outputIndexes[_activeChannelNumber * 2]];
 	int portVal = _ports[reg] & 0xFFC0;
 	int newVolume = CLIP(_activeChannelPtr->_volume + _activeChannelPtr->_field1E, 0, 63);
-	
+
 	// Note: Original had a whole block not seeming to be used, since the initialisation
 	// sets a variable to 5660h, and doesn't change it, so the branch is never taken
 	int val = CLIP(newVolume - volumeList[_activeChannelPtr->_fieldD], 0, 63);
@@ -756,7 +756,7 @@ void ASound::processSample() {
 
 	// Write out waveform select
 	write2(8, 0xE0 + _v11, _samplePtr->_waveformSelect & 3);
-	
+
 	// Write out total level & scaling level
 	val = -((_samplePtr->_totalLevel & 0x3F) - 0x3F) | (_samplePtr->_scalingLevel << 6);
 	write2(8, 0x40 + _v11, val);
@@ -813,7 +813,7 @@ int ASound::command0() {
 	_freqMask1 = _freqMask2 = 0;
 	_freqBase1 = _freqBase2 = 0;
 	_v7 = 0;
-	_v8 = 0;	
+	_v8 = 0;
 
 	// Reset Adlib port registers
 	for (int reg = 0x4F; reg >= 0x40; --reg)
@@ -907,21 +907,21 @@ int ASound::command8() {
 
 const ASound1::CommandPtr ASound1::_commandList[42] = {
 	&ASound1::command0, &ASound1::command1, &ASound1::command2, &ASound1::command3,
-	&ASound1::command4, &ASound1::command5, &ASound1::command6, &ASound1::command7, 
+	&ASound1::command4, &ASound1::command5, &ASound1::command6, &ASound1::command7,
 	&ASound1::command8, &ASound1::command9, &ASound1::command10, &ASound1::command11,
 	&ASound1::command12, &ASound1::command13, &ASound1::command14, &ASound1::command15,
-	&ASound1::command16, &ASound1::command17, &ASound1::command18, &ASound1::command19, 
-	&ASound1::command20, &ASound1::command21, &ASound1::command22, &ASound1::command23, 
+	&ASound1::command16, &ASound1::command17, &ASound1::command18, &ASound1::command19,
+	&ASound1::command20, &ASound1::command21, &ASound1::command22, &ASound1::command23,
 	&ASound1::command24, &ASound1::command25, &ASound1::command26, &ASound1::command27,
-	&ASound1::command28, &ASound1::command29, &ASound1::command30, &ASound1::command31, 
+	&ASound1::command28, &ASound1::command29, &ASound1::command30, &ASound1::command31,
 	&ASound1::command32, &ASound1::command33, &ASound1::command34, &ASound1::command35,
-	&ASound1::command36, &ASound1::command37, &ASound1::command38, &ASound1::command39, 
+	&ASound1::command36, &ASound1::command37, &ASound1::command38, &ASound1::command39,
 	&ASound1::command40, &ASound1::command41
 };
 
 ASound1::ASound1(Audio::Mixer *mixer): ASound(mixer, "asound.001", 0x1520) {
 	_cmd23Toggle = false;
-	
+
 	// Load sound samples
 	_soundFile.seek(_dataOffset + 0x12C);
 	for (int i = 0; i < 98; ++i)
@@ -1134,7 +1134,7 @@ int ASound1::command33() {
 
 int ASound1::command34() {
 	int v = getRandomNumber() & 0x20;
-	if (!v) 
+	if (!v)
 		v = 0x60;
 
 	byte *pData = loadData(0xDD0, 22);
diff --git a/engines/mads/nebular/sound_nebular.h b/engines/mads/nebular/sound_nebular.h
index caafdca..44e108f 100644
--- a/engines/mads/nebular/sound_nebular.h
+++ b/engines/mads/nebular/sound_nebular.h
@@ -167,7 +167,7 @@ private:
 
 	void updateChannelState();
 	void updateActiveChannel();
-	
+
 	/**
 	 * Loads up the specified sample
 	 */
@@ -339,12 +339,12 @@ public:
 	 * Main buffer read
 	 */
 	virtual int readBuffer(int16 *buffer, const int numSamples);
-	
+
 	/**
 	 * Mono sound only
 	 */
 	virtual bool isStereo() const { return false; }
-	
+
 	/**
 	 * Data is continuously pushed, so definitive end
 	 */
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 6beaad9..6be9d3d 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -72,7 +72,7 @@ void PaletteUsage::prioritize(Common::Array<RGB6> &palette) {
 		RGB6 &palEntry = palette[(*_data)[i]._palIndex];
 		(*_data)[i]._sortValue = _vm->_palette->rgbMerge(palEntry);
 	}
-	
+
 	Common::sort(_data->begin(), _data->end(), sortHelper);
 }
 
@@ -139,7 +139,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 	}
 
 	Common::sort(palRange.begin(), palRange.end(), rangeSorter);
-	
+
 	int var3A = (flags & 0x4000) ? 0xffff : 0xfffe;
 
 	for (uint palIndex = 0; palIndex < palette.size(); ++palIndex) {
@@ -183,7 +183,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 				(((flags & 0x2000) || (palette[palIndex]._flags & 0x4000)) &&
 				((flags & 0x1000) || (palCount == 0))) ? 0x7fff : 1;
 			int var36 = (palette[palIndex]._flags & 0x80) ? 0 : 2;
-			
+
 			for (int idx = palLow; idx < palIdx; ++idx) {
 				uint32 v = _vm->_palette->_palFlags[idx];
 				if ((v & var3A) && !(v & var36)) {
@@ -225,7 +225,7 @@ int PaletteUsage::process(Common::Array<RGB6> &palette, uint flags) {
 				}
 			}
 		}
-		
+
 		assert(var48);
 		int var52 = (noUsageFlag && palette[palIndex]._u2) ? 2 : 0;
 
@@ -430,7 +430,7 @@ void Fader::mapToGreyRamp(byte palette[PALETTE_SIZE], int baseColor, int numColo
 	for (int idx = 0; idx < PALETTE_COUNT; ++idx) {
 		map[idx]._mapColor = (byte)idx;
 	}
-	
+
 	// Sort the mapping list
 	Common::sort(&greyList[0], &greyList[numColors], greyCompareFunc);
 
@@ -486,7 +486,7 @@ void Fader::mapToGreyRamp(byte palette[PALETTE_SIZE], int baseColor, int numColo
 	}
 }
 
-void Fader::getGreyValues(const byte palette[PALETTE_SIZE], 
+void Fader::getGreyValues(const byte palette[PALETTE_SIZE],
 		GreyTableEntry greyList[PALETTE_COUNT], int baseColor, int numColors) {
 	const byte *palP = &palette[baseColor * 3];
 
@@ -496,7 +496,7 @@ void Fader::getGreyValues(const byte palette[PALETTE_SIZE],
 	}
 }
 
-void Fader::greyPopularity(const GreyTableEntry greyList[PALETTE_COUNT], 
+void Fader::greyPopularity(const GreyTableEntry greyList[PALETTE_COUNT],
 		byte greyTable[64], int numColors) {
 	Common::fill(&greyTable[0], &greyTable[64], 0);
 	for (int i = 0; i < numColors; ++i) {
@@ -590,7 +590,7 @@ void Palette::setSystemPalette() {
 	palData[1 * 3] = palData[1 * 3 + 1] = palData[1 * 3 + 2] = 0x54;
 	palData[2 * 3] = palData[2 * 3 + 1] = palData[2 * 3 + 2] = 0xb4;
 	palData[3 * 3] = palData[3 * 3 + 1] = palData[3 * 3 + 2] = 0xff;
-	
+
 	setPalette(palData, 0, 4);
 }
 
@@ -624,11 +624,11 @@ void Palette::initPalette() {
 		for (int idx = 0; idx < _vm->_game->_player._numSprites; ++idx) {
 			SpriteAsset *asset = _vm->_game->_scene._sprites[
 				_vm->_game->_player._spritesStart + idx];
-			
+
 			uint32 mask = 1;
 			if (asset->_usageIndex)
 				mask <<= asset->_usageIndex;
-			
+
 			palMask = mask;
 		}
 	}
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 9bf5bfa..31c3d1a 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -42,13 +42,13 @@ class MADSEngine;
  * Palette mapping options
  */
 enum {
-	PALFLAG_BACKGROUND		= 0x8000,  // Loading initial background       
-	PALFLAG_RESERVED		= 0x4000,  // Enable mapping reserved colors 
-	PALFLAG_ANY_TO_CLOSEST	= 0x2000,  // Any color can map to closest     
-	PALFLAG_ALL_TO_CLOSEST	= 0x1000,  // Any colors that can map must map 
-	PALFLAG_TOP_COLORS		= 0x0800,  // Allow mapping to high four colors 
-	PALFLAG_DEFINE_RESERVED	= 0x0400,  // Define initial reserved color    
-	PALFLAG_MASK			= 0xfc00   // Mask for all the palette flags   
+	PALFLAG_BACKGROUND		= 0x8000,  // Loading initial background
+	PALFLAG_RESERVED		= 0x4000,  // Enable mapping reserved colors
+	PALFLAG_ANY_TO_CLOSEST	= 0x2000,  // Any color can map to closest
+	PALFLAG_ALL_TO_CLOSEST	= 0x1000,  // Any colors that can map must map
+	PALFLAG_TOP_COLORS		= 0x0800,  // Allow mapping to high four colors
+	PALFLAG_DEFINE_RESERVED	= 0x0400,  // Define initial reserved color
+	PALFLAG_MASK			= 0xfc00   // Mask for all the palette flags
 };
 
 struct PaletteCycle {
@@ -182,7 +182,7 @@ private:
 
 	/**
 	 * Given a grey value list containing grey shades (0-63), creates a 64 byte
-	 * grey table containing the number of grey values for each intensity 
+	 * grey table containing the number of grey values for each intensity
 	 */
 	void greyPopularity(const GreyTableEntry greyList[PALETTE_COUNT], byte greyTable[64], int numColors);
 protected:
@@ -259,7 +259,7 @@ public:
 	 * Constructor
 	 */
 	Palette(MADSEngine *vm);
-	
+
 	/**
 	 * Destructor
 	 */
diff --git a/engines/mads/phantom/game_phantom.cpp b/engines/mads/phantom/game_phantom.cpp
index 25da777..5232322 100644
--- a/engines/mads/phantom/game_phantom.cpp
+++ b/engines/mads/phantom/game_phantom.cpp
@@ -44,7 +44,7 @@ ProtectionResult GamePhantom::checkCopyProtection() {
 	/*
 	// DEBUG: Flag copy protection failure
 	_globals[5] = -1;
-	
+
 	if (!ConfMan.getBool("copy_protection"))
 		return true;
 
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index aea73bb..96e2cd6 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -71,7 +71,7 @@ Player::Player(MADSEngine *vm): _vm(vm) {
 	_frameListIndex = 0;
 	_stopWalkerIndex = 0;
 	_totalDistance = 0;
-	
+
 	Common::fill(&_stopWalkerList[0], &_stopWalkerList[12], 0);
 	Common::fill(&_stopWalkerTrigger[0], &_stopWalkerTrigger[12], 0);
 	Common::fill(&_spriteSetsPresent[0], &_spriteSetsPresent[PLAYER_SPRITES_FILE_COUNT], false);
@@ -273,7 +273,7 @@ void Player::update() {
 
 		int newDepth = 1;
 		int yp = MIN(_playerPos.y, (int16)(MADS_SCENE_HEIGHT - 1));
-		
+
 		for (int idx = 1; idx < 15; ++idx) {
 			if (scene._sceneInfo->_depthList[newDepth] >= yp)
 				newDepth = idx + 1;
@@ -299,11 +299,11 @@ void Player::update() {
 			if (slotIndex >= 0) {
 				// Check if the existing player slot has the same details, and can be re-used
 				SpriteSlot &s2 = scene._spriteSlots[slotIndex];
-				bool equal = (s2._seqIndex == slot._seqIndex) 
+				bool equal = (s2._seqIndex == slot._seqIndex)
 					&& (s2._spritesIndex == slot._spritesIndex)
-					&& (s2._frameNumber == slot._frameNumber) 
+					&& (s2._frameNumber == slot._frameNumber)
 					&& (s2._position == slot._position)
-					&& (s2._depth == slot._depth) 
+					&& (s2._depth == slot._depth)
 					&& (s2._scale == slot._scale);
 
 				if (equal)
@@ -319,7 +319,7 @@ void Player::update() {
 				scene._spriteSlots[slotIndex] = slot;
 			}
 
-			// If changing a scene, check to change the scene when the player 
+			// If changing a scene, check to change the scene when the player
 			// has moved off-screen
 			if (_walkOffScreen) {
 				SpriteAsset *asset = scene._sprites[slot._spritesIndex];
@@ -545,7 +545,7 @@ int Player::getSpriteSlot() {
 	SpriteSlots &spriteSlots = _vm->_game->_scene._spriteSlots;
 
 	for (uint idx = 0; idx < spriteSlots.size(); ++idx) {
-		if (spriteSlots[idx]._seqIndex == PLAYER_SEQ_INDEX && 
+		if (spriteSlots[idx]._seqIndex == PLAYER_SEQ_INDEX &&
 				spriteSlots[idx]._flags >= IMG_STATIC)
 			return idx;
 	}
diff --git a/engines/mads/rails.cpp b/engines/mads/rails.cpp
index 00f7f4c..6beee5a 100644
--- a/engines/mads/rails.cpp
+++ b/engines/mads/rails.cpp
@@ -101,7 +101,7 @@ void Rails::setupRouteNode(int *routeIndexP, int nodeIndex, int flags, int route
 	int subIndex = _nodes.size() - 2;
 
 	int distanceVal = _nodes[nodeIndex]._distances[subIndex];
-	if (distanceVal & flags) {                                                                                                                                                   
+	if (distanceVal & flags) {
 		routeLength += distanceVal & 0x3FFF;
 		if (routeLength < _routeLength) {
 			// Found a new shorter route to destination, so set up the route with the found one
@@ -266,7 +266,7 @@ int Rails::getRouteFlags(const Common::Point &src, const Common::Point &dest) {
 void Rails::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_routeLength);
 	s.syncAsSint16LE(_next);
-	
+
 	int count = _routeIndexes.size();
 	if (s.isSaving()) {
 		for (int i = 0; i < count; ++i)
diff --git a/engines/mads/rails.h b/engines/mads/rails.h
index 4014491..e6cab08 100644
--- a/engines/mads/rails.h
+++ b/engines/mads/rails.h
@@ -51,7 +51,7 @@ public:
 typedef Common::Array<WalkNode> WalkNodeList;
 
 /**
- * This class handles storing the intermediate walk node points for a 
+ * This class handles storing the intermediate walk node points for a
  * given scene, and calculating walking routes between any two positions.
  */
 class Rails {
diff --git a/engines/mads/resources.cpp b/engines/mads/resources.cpp
index f060944..4f5596d 100644
--- a/engines/mads/resources.cpp
+++ b/engines/mads/resources.cpp
@@ -169,10 +169,10 @@ void HagArchive::loadIndex(MADSEngine *vm) {
 			Common::String::format("SECTION%d.HAG", sectionIndex);
 		if (!hagFile.open(filename))
 			error("Could not locate HAG file - %s", filename.c_str());
-	
+
 		// Check for header
 		char headerBuffer[16];
-		if ((hagFile.read(headerBuffer, 16) != 16) || 
+		if ((hagFile.read(headerBuffer, 16) != 16) ||
 				(strncmp(headerBuffer, MADSCONCAT_STRING, 10) != 0))
 			error("Invalid HAG file opened");
 
@@ -269,7 +269,7 @@ ResourceType HagArchive::getResourceType(const Common::String &resourceName) con
 	} else if (resourceName.hasPrefix("SPCHC")) {
 		// SPEECH resource
 		return RESTYPE_SPEECH;
-	} 
+	}
 
 	// Check for a known extension
 	const char *extPos = strchr(resourceName.c_str(), '.');
@@ -360,7 +360,7 @@ Common::String Resources::formatName(int prefix, char asciiCh, int id, EXTTYPE e
 	return result;
 }
 
-Common::String Resources::formatResource(const Common::String &resName, 
+Common::String Resources::formatResource(const Common::String &resName,
 		const Common::String &hagFilename) {
 //	int v1 = 0, v2 = 0;
 
diff --git a/engines/mads/resources.h b/engines/mads/resources.h
index 7d56138..137eb7a 100644
--- a/engines/mads/resources.h
+++ b/engines/mads/resources.h
@@ -37,7 +37,7 @@ enum RESPREFIX {
 };
 
 enum EXTTYPE {
-	EXT_NONE = -1, EXT_SS = 1, EXT_AA = 2, EXT_DAT = 3, EXT_HH = 4, 
+	EXT_NONE = -1, EXT_SS = 1, EXT_AA = 2, EXT_DAT = 3, EXT_HH = 4,
 	EXT_ART = 5, EXT_INT = 6
 };
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 609e233..32956e6 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -32,7 +32,7 @@ namespace MADS {
 
 Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 		_dirtyAreas(_vm),  _dynamicHotspots(vm), _hotspots(vm),
-		_kernelMessages(vm), _sequences(vm), _sprites(vm), _spriteSlots(vm), 
+		_kernelMessages(vm), _sequences(vm), _sprites(vm), _spriteSlots(vm),
 		_textDisplay(vm), _userInterface(vm) {
 	_priorSceneId = 0;
 	_nextSceneId = 0;
@@ -169,11 +169,11 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 		flags |= ANIMFLAG_DITHER;
 	if (_vm->_textWindowStill)
 		flags |= ANIMFLAG_LOAD_BACKGROUND_ONLY;
-		
+
 	_animationData = Animation::init(_vm, this);
 	MSurface depthSurface;
 	_animationData->load(_userInterface, depthSurface, prefix, flags, nullptr, nullptr);
-	
+
 	_vm->_palette->_paletteUsage.load(&_scenePaletteUsage);
 
 	_bandsRange = _sceneInfo->_yBandsEnd - _sceneInfo->_yBandsStart;
@@ -184,7 +184,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 	_spritesCount = _sprites.size();
 
 	_userInterface.setup(_vm->_game->_screenObjects._inputMode);
-	
+
 	_vm->_game->_screenObjects._category = CAT_NONE;
 	_vm->_events->showCursor();
 
@@ -386,7 +386,7 @@ void Scene::doFrame() {
 		_frameStartTime = _vm->_events->getFrameCounter();
 
 	// Handle parser actions as well as game triggers
-	if ((_action._inProgress && !player._moving && !player._needToWalk && 
+	if ((_action._inProgress && !player._moving && !player._needToWalk &&
 			(player._facing == player._turnToFacing) && !_vm->_game->_trigger) ||
 			(_vm->_game->_trigger && (_vm->_game->_triggerMode == SEQUENCE_TRIGGER_PARSER))) {
 		doAction();
@@ -420,7 +420,7 @@ void Scene::doFrame() {
 			if (_vm->_debugger->_showMousePos) {
 				Common::Point pt = _vm->_events->mousePos();
 				Common::String msg = Common::String::format("(%d,%d)", pt.x, pt.y);
-				mouseTextIndex = _kernelMessages.add(Common::Point(5, 5), 
+				mouseTextIndex = _kernelMessages.add(Common::Point(5, 5),
 					0x203, 0, 0, 1, msg);
 			}
 
@@ -504,7 +504,7 @@ void  Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
 }
 
 void Scene::doPreactions() {
-	if (_vm->_game->_screenObjects._inputMode == kInputBuildingSentences || 
+	if (_vm->_game->_screenObjects._inputMode == kInputBuildingSentences ||
 			_vm->_game->_screenObjects._inputMode == kInputLimitedSentences) {
 		_vm->_game->_triggerSetupMode = SEQUENCE_TRIGGER_PREPARE;
 		_action.checkAction();
@@ -533,7 +533,7 @@ void Scene::doAction() {
 			flag = !_action._inProgress;
 		}
 
-		if ((_action._inProgress || _vm->_game->_trigger) && 
+		if ((_action._inProgress || _vm->_game->_trigger) &&
 				(!flag || _action._savedFields._commandError == flag)) {
 			_vm->_game->doObjectAction();
 		}
@@ -589,7 +589,7 @@ void Scene::loadAnimation(const Common::String &resName, int trigger) {
 	UserInterface interfaceSurface(_vm);
 
 	_activeAnimation = Animation::init(_vm, this);
-	_activeAnimation->load(interfaceSurface, depthSurface, resName, 
+	_activeAnimation->load(interfaceSurface, depthSurface, resName,
 		_vm->_dithering ? ANIMFLAG_DITHER : 0, nullptr, nullptr);
 	_activeAnimation->startAnimation(trigger);
 }
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 3661bd6..69a2c0d 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -224,7 +224,7 @@ public:
 	void resetScene();
 
 	/**
-	* Removes all the scene specific sprites fromt the sprites list, 
+	* Removes all the scene specific sprites fromt the sprites list,
 	* leaving any player sprites list in place at the start of the list.
 	*/
 	void removeSprites();
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 272c828..256a517 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -112,7 +112,7 @@ SceneInfo *SceneInfo::init(MADSEngine *vm) {
 void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 		int flags, MSurface &depthSurface, MSurface &bgSurface) {
 	bool sceneFlag = sceneId >= 0;
-	
+
 	// Figure out the resource to use
 	Common::String resourceName;
 	if (sceneFlag) {
@@ -133,7 +133,7 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 		infoStream->skip(6);	// actual scene ID (string)
 		_sceneId = sceneId;
 	}
-	
+
 	// TODO: The following isn't quite right for V2 games (it's all 0)
 	_artFileNum = infoStream->readUint16LE();
 	_depthStyle = infoStream->readUint16LE();
@@ -161,7 +161,7 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 	for (int i = 0; i < 20; ++i) {
 		WalkNode node;
 		node.load(infoStream);
-		
+
 		if (i < nodeCount)
 			_nodes.push_back(node);
 	}
@@ -169,7 +169,7 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 	int spriteSetsCount  = infoStream->readUint16LE();
 	int spriteInfoCount = infoStream->readUint16LE();
 
-	// Load in sprite sets 
+	// Load in sprite sets
 	Common::StringArray setNames;
 	for (int i = 0; i < 10; ++i) {
 		char name[64];
@@ -236,7 +236,7 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 
 			SpriteAsset *sprites = new SpriteAsset(_vm, setResName, flags);
 			spriteSets.push_back(sprites);
-			usageList.push_back(sprites->_usageIndex); 
+			usageList.push_back(sprites->_usageIndex);
 		}
 	}
 
@@ -248,7 +248,7 @@ void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
 		assert(asset && _depthStyle != 2);
 
 		MSprite *spr = asset->getFrame(asset->getCount() - 1);
-		bgSurface.copyFrom(spr, si._position, si._depth, &depthSurface, si._scale, 
+		bgSurface.copyFrom(spr, si._position, si._depth, &depthSurface, si._scale,
 			spr->getTransparencyIndex());
 	}
 
@@ -292,7 +292,7 @@ void SceneInfo::loadPalette(int sceneId, int artFileNum, const Common::String &r
 			_vm->_palette->_paletteUsage.prioritize(artHeader._palette);
 		}
 
-		_usageIndex = _vm->_palette->_paletteUsage.process(artHeader._palette, 
+		_usageIndex = _vm->_palette->_paletteUsage.process(artHeader._palette,
 			(flags & 0xF800) | 0x8000);
 		if (_usageIndex > 0) {
 			_vm->_palette->_paletteUsage.transform(artHeader._palette);
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index c295ae0..83caec5 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -53,7 +53,7 @@ class SpriteSlot;
 #define TEXT_DISPLAY_MAX_SIZE 40
 #define DIRTY_AREAS_SIZE (SPRITE_SLOTS_MAX_SIZE + TEXT_DISPLAY_MAX_SIZE)
 
-enum { 
+enum {
 	SCENEFLAG_DITHER		= 0x01,     // Dither to 16 colors
 	SCENEFLAG_LOAD_SHADOW	= 0x10		// Load hard shadows
 };
@@ -65,7 +65,7 @@ public:
 	PrepType _prepType;
 
 	VerbInit() {}
-	VerbInit(int id, VerbType verbType, PrepType prepType): _id(id), 
+	VerbInit(int id, VerbType verbType, PrepType prepType): _id(id),
 		_verbType(verbType), _prepType(prepType) {}
 };
 
@@ -180,7 +180,7 @@ public:
 	/**
 	 * loads the data
 	 */
-	void load(int sceneId, int variant, const Common::String &resName, int flags, 
+	void load(int sceneId, int variant, const Common::String &resName, int flags,
 		MSurface &depthSurface, MSurface &bgSurface);
 
 	/**
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index f0564c5..09f87f3 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -278,7 +278,7 @@ void ScreenObjects::check(bool scanFlag) {
 	if (!_vm->_events->_mouseButtons || _inputMode != kInputBuildingSentences)
 		_vm->_events->_rightMousePressed = false;
 
-	if ((_vm->_events->_mouseMoved || userInterface._scrollbarActive 
+	if ((_vm->_events->_mouseMoved || userInterface._scrollbarActive
 			|| _v8332A || _forceRescan) && scanFlag) {
 		_category = CAT_NONE;
 		_selectedObject = scanBackwards(_vm->_events->currentPos(), LAYER_GUI);
@@ -386,7 +386,7 @@ void ScreenObjects::elementHighlighted() {
 		indexEnd = 9;
 		varA = 5;
 		topIndex = 0;
-		idxP = !_vm->_events->_rightMousePressed ? &userInterface._highlightedCommandIndex : 
+		idxP = !_vm->_events->_rightMousePressed ? &userInterface._highlightedCommandIndex :
 			&userInterface._selectedActionIndex;
 
 		if (_vm->_events->_rightMousePressed && userInterface._selectedItemVocabIdx >= 0)
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index cbe0471..a7c6ded 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -63,7 +63,7 @@ SequenceEntry::SequenceEntry() {
 #define SEQUENCE_LIST_SIZE 30
 
 SequenceList::SequenceList(MADSEngine *vm) : _vm(vm) {
-	// IMPORTANT: Preallocate timer slots. Note that sprite slots refer to entries 
+	// IMPORTANT: Preallocate timer slots. Note that sprite slots refer to entries
 	// in this list by index, so we can't just add or delete entries later
 	for (int i = 0; i < SEQUENCE_LIST_SIZE; ++i) {
 		SequenceEntry rec;
@@ -369,7 +369,7 @@ void SequenceList::delay(uint32 priorFrameTime, uint32 currentTime) {
 }
 
 void SequenceList::setAnimRange(int seqIndex, int startVal, int endVal) {
-	Scene &scene = _vm->_game->_scene;	
+	Scene &scene = _vm->_game->_scene;
 	SequenceEntry &seqEntry = _entries[seqIndex];
 	SpriteAsset &spriteSet = *scene._sprites[seqEntry._spritesIndex];
 	int numSprites = spriteSet.getCount();
@@ -433,7 +433,7 @@ int SequenceList::addSpriteCycle(int srcSpriteIdx, bool flipped, int numTicks, i
 	Scene &scene = _vm->_game->_scene;
 	MSprite *spriteFrame = scene._sprites[srcSpriteIdx]->getFrame(0);
 	int depth = scene._depthSurface.getDepth(Common::Point(
-		spriteFrame->_offset.x + (spriteFrame->w / 2), 
+		spriteFrame->_offset.x + (spriteFrame->w / 2),
 		spriteFrame->_offset.y + (spriteFrame->h / 2)));
 
 	return add(srcSpriteIdx, flipped, 1, triggerCountdown, timeoutTicks, extraTicks, numTicks, 0, 0,
@@ -450,7 +450,7 @@ int SequenceList::addReverseSpriteCycle(int srcSpriteIdx, bool flipped, int numT
 		spriteFrame->_offset.x + (spriteFrame->w / 2),
 		spriteFrame->_offset.y + (spriteFrame->h / 2)));
 
-	return add(srcSpriteIdx, flipped, asset->getCount(), triggerCountdown, timeoutTicks, extraTicks, 
+	return add(srcSpriteIdx, flipped, asset->getCount(), triggerCountdown, timeoutTicks, extraTicks,
 		numTicks, 0, 0, true, 100, depth - 1, -1, ANIMTYPE_CYCLED, 0, 0);
 }
 
@@ -463,7 +463,7 @@ int SequenceList::startCycle(int srcSpriteIndex, bool flipped, int cycleIndex) {
 	return result;
 }
 
-int SequenceList::startReverseCycle(int srcSpriteIndex, bool flipped, int numTicks, 
+int SequenceList::startReverseCycle(int srcSpriteIndex, bool flipped, int numTicks,
 		int triggerCountdown, int timeoutTicks, int extraTicks) {
 	SpriteAsset *sprites = _vm->_game->_scene._sprites[srcSpriteIndex];
 	MSprite *frame = sprites->getFrame(0);
@@ -508,4 +508,4 @@ void SequenceList::setDone(int seqIndex) {
 	_entries[seqIndex]._timeout = _vm->_game->_player._priorTimer;
 }
 
-} // End of namespace 
+} // End of namespace
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index 1975900..8abef5c 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -32,8 +32,8 @@ namespace MADS {
 
 class SpriteSlot;
 
-enum SequenceTrigger { 
-	SEQUENCE_TRIGGER_EXPIRE = 0,	// Trigger when the sequence finishes 
+enum SequenceTrigger {
+	SEQUENCE_TRIGGER_EXPIRE = 0,	// Trigger when the sequence finishes
 	SEQUENCE_TRIGGER_LOOP = 1,		// Trigger when the sequence loops
 	SEQUENCE_TRIGGER_SPRITE = 2		// Trigger when sequence reaches specific sprite
 };
@@ -103,7 +103,7 @@ public:
 	int add(int spriteListIndex, bool flipped, int frameIndex, int triggerCountdown, int delayTicks,
 		int extraTicks, int numTicks, int msgX, int msgY, bool nonFixed, int scale, int depth,
 		int frameInc, SpriteAnimType animType, int numSprites, int frameStart);
-	
+
 	int addTimer(int timeout, int abortVal);
 	void remove(int seqIndex);
 	void setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot);
@@ -114,13 +114,13 @@ public:
 	void scan();
 	void setDepth(int seqIndex, int depth);
 	void setMsgPosition(int seqIndex, const Common::Point &pt);
-	int addSpriteCycle(int srcSpriteIdx, bool flipped, int numTicks, 
+	int addSpriteCycle(int srcSpriteIdx, bool flipped, int numTicks,
 		int triggerCountdown = 0, int timeoutTicks = 0, int extraTicks = 0);
 	int addReverseSpriteCycle(int srcSpriteIdx, bool flipped, int numTicks,
 		int triggerCountdown = 0, int timeoutTicks = 0, int extraTicks = 0);
 
 	int startCycle(int srcSpriteIdx, bool flipped, int cycleIndex);
-	int startReverseCycle(int srcSpriteIndex, bool flipped, int numTicks, 
+	int startReverseCycle(int srcSpriteIndex, bool flipped, int numTicks,
 		int triggerCountdown = 0, int timeoutTicks = 0, int extraTicks = 0);
 	void updateTimeout(int spriteIdx, int seqIndex);
 	void setScale(int spriteIdx, int scale);
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index 432a0e1..b0506fc 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -58,8 +58,8 @@ MSprite::MSprite(): MSurface() {
 }
 
 MSprite::MSprite(Common::SeekableReadStream *source, const Common::Array<RGB6> &palette,
-		const Common::Rect &bounds): 
-		MSurface(bounds.width(), bounds.height()), 
+		const Common::Rect &bounds):
+		MSurface(bounds.width(), bounds.height()),
 		_offset(Common::Point(bounds.left, bounds.top)) {
 	// Load the sprite data
 	loadSprite(source, palette);
@@ -158,7 +158,7 @@ SpriteSlot::SpriteSlot(SpriteFlags type, int seqIndex) {
 
 bool SpriteSlot::operator==(const SpriteSlotSubset &other) const {
 	return (_spritesIndex == other._spritesIndex) && (_frameNumber == other._frameNumber) &&
-		(_position == other._position) && (_depth == other._depth) && 
+		(_position == other._position) && (_depth == other._depth) &&
 		(_scale == other._scale);
 }
 
@@ -324,7 +324,7 @@ void SpriteSlots::drawSprites(MSurface *s) {
 
 		if ((slot._scale < 100) && (slot._scale != -1)) {
 			// Minimalised drawing
-			s->copyFrom(spr, slot._position, slot._depth, &scene._depthSurface, 
+			s->copyFrom(spr, slot._position, slot._depth, &scene._depthSurface,
 				slot._scale, sprite->getTransparencyIndex());
 		} else {
 			int xp, yp;
@@ -339,7 +339,7 @@ void SpriteSlots::drawSprites(MSurface *s) {
 
 			if (slot._depth > 1) {
 				// Draw the frame with depth processing
-				s->copyFrom(spr, Common::Point(xp, yp), slot._depth, &scene._depthSurface, 
+				s->copyFrom(spr, Common::Point(xp, yp), slot._depth, &scene._depthSurface,
 					100, sprite->getTransparencyIndex());
 			} else {
 				// No depth, so simply draw the image
diff --git a/engines/mads/sprites.h b/engines/mads/sprites.h
index 745e070..f807e73 100644
--- a/engines/mads/sprites.h
+++ b/engines/mads/sprites.h
@@ -180,7 +180,7 @@ public:
 	void deleteTimer(int seqIndex);
 
 	/**
-	 * Add a new slot entry and return it's index 
+	 * Add a new slot entry and return it's index
 	 */
 	int add();
 
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index e23ecf4..4d8ed82 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -148,14 +148,14 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 
 			if (dirtyArea->_textActive) {
 				SpriteAsset *asset = scene._sprites[slot._spritesIndex];
-			
+
 				// Get the frame details
 				int frameNumber = ABS(slot._frameNumber);
 				bool flipped = slot._frameNumber < 0;
 
 				if (slot._segmentId == IMG_SPINNING_OBJECT) {
 					MSprite *sprite = asset->getFrame(frameNumber);
-					sprite->copyTo(&userInterface, slot._position, 
+					sprite->copyTo(&userInterface, slot._position,
 						sprite->getTransparencyIndex());
 				} else {
 					MSprite *sprite = asset->getFrame(frameNumber - 1);
@@ -309,7 +309,7 @@ void Conversation::start() {
 
 /*------------------------------------------------------------------------*/
 
-UserInterface::UserInterface(MADSEngine *vm) : _vm(vm), _dirtyAreas(vm), 
+UserInterface::UserInterface(MADSEngine *vm) : _vm(vm), _dirtyAreas(vm),
 		_uiSlots(vm) {
 	_invSpritesIndex = -1;
 	_invFrameNumber = 1;
@@ -363,7 +363,7 @@ void UserInterface::load(const Common::String &resName) {
 	// Read in the surface data
 	Common::SeekableReadStream *pixelsStream = madsPack.getItemStream(1);
 	pixelsStream->read(_surface.getData(), MADS_SCREEN_WIDTH * MADS_INTERFACE_HEIGHT);
-	delete pixelsStream; 
+	delete pixelsStream;
 }
 
 void UserInterface::setup(InputMode inputMode) {
@@ -418,7 +418,7 @@ void UserInterface::drawTextElements() {
 
 void UserInterface::mergeFrom(MSurface *src, const Common::Rect &srcBounds,
 	const Common::Point &destPos, int transparencyIndex) {
-	// Validation of the rectangle and position	
+	// Validation of the rectangle and position
 	int destX = destPos.x, destY = destPos.y;
 	if ((destX >= w) || (destY >= h))
 		return;
@@ -502,7 +502,7 @@ void UserInterface::updateInventoryScroller() {
 		// FIXME: This scrolls the inventory up when selecting verbs or attempting to combine items
 		false/*(screenObjects._category != CAT_INV_SCROLLER && _scrollbarOldActive == SCROLLBAR_ELEVATOR)*/
 	) && (_vm->_events->_mouseStatusCopy || _vm->_easyMouse)) {
-		if ((_vm->_events->_mouseClicked || (_vm->_easyMouse && !_vm->_events->_mouseStatusCopy)) 
+		if ((_vm->_events->_mouseClicked || (_vm->_easyMouse && !_vm->_events->_mouseStatusCopy))
 				&& (screenObjects._category == CAT_INV_SCROLLER))
 			_scrollbarStrokeType = (ScrollbarActive)screenObjects._spotId;
 
@@ -637,7 +637,7 @@ void UserInterface::writeVocab(ScrCategory category, int id) {
 			break;
 		}
 
-		font->setColorMode((id == 4) || (_scrollbarActive == SCROLLBAR_ELEVATOR) ? 
+		font->setColorMode((id == 4) || (_scrollbarActive == SCROLLBAR_ELEVATOR) ?
 			SELMODE_HIGHLIGHTED : SELMODE_UNSELECTED);
 		font->writeString(this, vocabStr, Common::Point(bounds.left, bounds.top));
 		break;
@@ -705,7 +705,7 @@ void UserInterface::loadElements() {
 			CAT_INV_ANIM, 0);
 	}
 
-	if (_vm->_game->_screenObjects._inputMode == kInputBuildingSentences || 
+	if (_vm->_game->_screenObjects._inputMode == kInputBuildingSentences ||
 			_vm->_game->_screenObjects._inputMode == kInputLimitedSentences) {
 		_categoryIndexes[CAT_HOTSPOT - 1] = _vm->_game->_screenObjects.size() + 1;
 		for (int hotspotIdx = scene._hotspots.size() - 1; hotspotIdx >= 0; --hotspotIdx) {
@@ -878,7 +878,7 @@ void UserInterface::refresh() {
 
 void UserInterface::inventoryAnim() {
 	Scene &scene = _vm->_game->_scene;
-	if (_vm->_game->_screenObjects._inputMode == kInputConversation || 
+	if (_vm->_game->_screenObjects._inputMode == kInputConversation ||
 			_vm->_game->_screenObjects._inputMode == kInputLimitedSentences ||
 			_invSpritesIndex < 0)
 		return;
@@ -984,7 +984,7 @@ void UserInterface::selectObject(int invIndex) {
 		if (maxVocab) {
 			assert(_uiSlots.size() < 50);
 			int vocabHeight = maxVocab * 8;
-			
+
 			Common::Rect bounds(240, 3, 240 + 80, 3 + vocabHeight);
 			_uiSlots.add(bounds);
 			_uiSlots.draw(false, false);
@@ -1028,7 +1028,7 @@ void UserInterface::updateSelection(ScrCategory category, int newIndex, int *idx
 
 		if (oldIndex >= 0) {
 			writeVocab(category, oldIndex);
-			
+
 			if (getBounds(category, oldIndex, bounds))
 				updateRect(bounds);
 		}
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 04a8d09..2fdc80b 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -51,7 +51,7 @@ public:
 	int _spritesIndex;
 	int _frameNumber;
 	Common::Point _position;
-	
+
 	// Only used for IMG_OVERPRINT
 	int _width;
 	int _height;


Commit: 0ab1e9d07bdcf012cc0025bb024329698529bf1d
    https://github.com/scummvm/scummvm/commit/0ab1e9d07bdcf012cc0025bb024329698529bf1d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-08T11:44:13+03:00

Commit Message:
MADS: Replace some magic bomb status values with their friendly name

Changed paths:
    engines/mads/nebular/nebular_scenes5.cpp



diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index 41765f2..9c961e3 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -729,7 +729,7 @@ void Scene504::step() {
 		}
 	}
 
-	if ((_globals[kTimebombTimer] >= 10800) && (_globals[kTimebombStatus] == 1) && (_game._difficulty != 3)) {
+	if ((_globals[kTimebombTimer] >= 10800) && (_globals[kTimebombStatus] == TIMEBOMB_ACTIVATED) && (_game._difficulty != 3)) {
 		_globals[kTimebombStatus] = TIMEBOMB_DEAD;
 		_globals[kTimebombTimer] = 0;
 		_globals[kCheckDaemonTimebomb] = false;
@@ -924,7 +924,7 @@ void Scene505::step() {
 					_selectedId = 8;
 			} else {
 				this_button = 0x2DE;
-				if ((_globals[kTimebombStatus] == 1) && (_carLocations[_selectedId] == 501))
+				if ((_globals[kTimebombStatus] == TIMEBOMB_ACTIVATED) && (_carLocations[_selectedId] == 501))
 					_vm->_dialogs->show(431);
 				else if (_selectedId != _homeSelectedId) {
 					_nextButtonId = 0;


Commit: 98518ef500bdb81ee7608cdebb16325dabd7bdc3
    https://github.com/scummvm/scummvm/commit/98518ef500bdb81ee7608cdebb16325dabd7bdc3
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-08T14:41:45+03:00

Commit Message:
MADS: Bugfix for shooting down the monkey

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index b86f9db..2bb24be 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -3169,8 +3169,8 @@ void Scene209::preActions() {
 		_game._player._walkOffScreenSceneId = 208;
 
 	if (_globals[kMonkeyStatus] == 1) {
-		if ((_action.isAction(NOUN_SHOOT) || _action.isAction(NOUN_HOSE_DOWN)) && _action.isAction(NOUN_MONKEY)
-			&& _action.isAction(NOUN_BLOWGUN) && _game._objects.isInInventory(OBJ_BLOWGUN) && _game._objects.isInInventory(OBJ_POISON_DARTS)) {
+		if ((_action.isAction(NOUN_SHOOT) || _action.isAction(NOUN_HOSE_DOWN)) && _action.isTarget(NOUN_MONKEY)
+			&& _action.isObject(NOUN_BLOWGUN) && _game._objects.isInInventory(OBJ_BLOWGUN) && _game._objects.isInInventory(OBJ_POISON_DARTS)) {
 			_game._player._prepareWalkPos = Common::Point(111, 129);
 			_game._player._prepareWalkFacing = FACING_NORTHEAST;
 			_game._player._needToWalk = true;


Commit: 54549652241aaa3ce2b4b74fad35655c436677ff
    https://github.com/scummvm/scummvm/commit/54549652241aaa3ce2b4b74fad35655c436677ff
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-08T19:01:04+02:00

Commit Message:
MADS: Implement scene 506

Changed paths:
    engines/mads/animation.h
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes5.h



diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 3c0c254..0556c3a 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -210,6 +210,7 @@ public:
 	void update();
 
 	void setNextFrameTimer(int frameNumber);
+	int getNextFrameTimer() const { return _nextFrameTimer; }
 	void setCurrentFrame(int frameNumber);
 	int getCurrentFrame() const { return _currentFrame; }
 
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index a946b23..71489b4 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -207,7 +207,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 505:	// car view screen
 		return new Scene505(vm);
 	case 506:	// shopping street
-		return new DummyScene(vm);	// TODO
+		return new Scene506(vm);
 	case 507:	// inside software house
 		return new DummyScene(vm);	// TODO
 	case 508:	// laser cannon
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index 9c961e3..b6c6611 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -417,7 +417,7 @@ void Scene501::actions() {
 		default:
 			break;
 		}
-	} else if ((_action._lookFlag) || _action.isAction(VERB_LOOK, 0x31E))
+	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x31E))
 		_vm->_dialogs->show(50121);
 	else if (_action.isAction(VERB_LOOK, 0x6E))
 		_vm->_dialogs->show(50110);
@@ -803,7 +803,7 @@ void Scene504::actions() {
 		default:
 			break;
 		}
-	} else if ((_action._lookFlag) || _action.isAction(VERB_LOOK, 0x388))
+	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x388))
 		_vm->_dialogs->show(50412);
 	else if (_action.isAction(VERB_LOOK, 0x383))
 		_vm->_dialogs->show(50410);
@@ -1035,7 +1035,7 @@ void Scene505::step() {
 	case 60: {
 		_game._player._stepEnabled = true;
 		int syncIdx = _globals._sequenceIndexes[13];
-		_globals._sequenceIndexes[13] = _scene->_sequences.startCycle (_globals._spriteIndexes[13], false, -2);
+		_globals._sequenceIndexes[13] = _scene->_sequences.startCycle(_globals._spriteIndexes[13], false, -2);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
 		_scene->_sequences.updateTimeout (_globals._sequenceIndexes[13], syncIdx);
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[_homeSelectedId], false, 1);
@@ -1088,5 +1088,267 @@ void Scene505::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene506::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x242);
+	_scene->addActiveVocab(0x336);
+	_scene->addActiveVocab(0x37D);
+}
+
+void Scene506::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('q', 0));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('q', 1));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('c', -1));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXCD_3");
+
+	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);  
+	int idx = _scene->_dynamicHotspots.add(0x37D, 0x242, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+	int hotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(65, 125), FACING_NORTHWEST);
+	_scene->_dynamicHotspots.setCursor(hotspotId, CURSOR_GO_LEFT);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
+	_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);  
+	idx = _scene->_dynamicHotspots.add(0x336, 0x242, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+	hotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(112, 102), FACING_NORTHWEST);
+	_scene->_dynamicHotspots.setCursor(hotspotId, CURSOR_GO_LEFT);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 13);
+
+	_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -1);  
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 5);
+	_firstDoorFl = true;
+	_actionFl            = false;
+
+	if (_scene->_priorSceneId == 508) {
+		_game._player._playerPos = Common::Point(16, 111);
+		_game._player._facing = FACING_SOUTHEAST;
+		_scene->_sequences.addTimer(15, 80);
+		_game._player._stepEnabled = false;
+	} else if (_scene->_priorSceneId == 507) {
+		_game._player._playerPos = Common::Point(80, 102);
+		_game._player._facing = FACING_SOUTHEAST;
+		_scene->_sequences.addTimer(60, 80);
+		_game._player._stepEnabled = false;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(138, 116);
+		_game._player._facing = FACING_NORTHEAST;
+		_game._player._visible   = false;
+		_game._player._stepEnabled = false;
+		_scene->_sequences.remove (_globals._sequenceIndexes[3]); 
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 5);
+		_scene->loadAnimation(formAnimName('R', 1), 70);
+	}
+	sceneEntrySound();
+}
+
+void Scene506::step() {
+	if (_game._trigger >= 80) {
+		if (_firstDoorFl) {
+			_heroFacing = FACING_SOUTHEAST;
+			if (_scene->_priorSceneId == 507) {
+				_doorPos = Common::Point(112, 102);
+				_doorWord = 0x336;
+			} else {
+				_doorPos = Common::Point(65, 125);
+				_doorWord = 0x37D;
+			}
+		}
+		room_506_door_sequences();
+	}
+
+	if (_game._trigger >= 70) {
+		switch (_game._trigger) {
+		case 70:
+			_game._player._visible = true;
+			_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
+			_scene->_sequences.addTimer(6, 71);
+			break;
+
+		case 71:
+			_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 5);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 72);
+			break;
+
+		case 72:
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 5);
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+	}
+}
+
+void Scene506::room_506_door_sequences() {
+	_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+
+	if (_firstDoorFl) {
+		if (_action.isAction(0x242, 0x336) || ((_scene->_priorSceneId == 507) && !_actionFl)) {
+			_doorDepth = 13;
+			_doorSpriteIdx = _globals._spriteIndexes[2];
+			_doorSequenceIdx = _globals._sequenceIndexes[2];
+			_labDoorFl = false;
+		} else {
+			_doorDepth = 10;
+			_doorSpriteIdx = _globals._spriteIndexes[1];
+			_doorSequenceIdx = _globals._sequenceIndexes[1];
+			_labDoorFl = true;
+		}
+		_firstDoorFl = false;
+	}
+
+	switch (_game._trigger) {
+	case 0:
+	case 80:
+		_game._player._stepEnabled = false;
+		_scene->_sequences.remove(_doorSequenceIdx);
+		_doorSequenceIdx = _scene->_sequences.addSpriteCycle(_doorSpriteIdx, false, 7, 1, 0, 0);
+		_scene->_sequences.setDepth(_doorSequenceIdx, _doorDepth);
+		_scene->changeVariant(1);
+		_scene->_sequences.addSubEntry(_doorSequenceIdx, SEQUENCE_TRIGGER_EXPIRE, 0, 81);
+		break;
+
+
+	case 81:
+		_doorSequenceIdx = _scene->_sequences.startCycle(_doorSpriteIdx, false, -2);
+		_scene->_sequences.setDepth(_doorSequenceIdx, _doorDepth);
+		_game._player._walkAnywhere = true;
+		_game._player.walk(_doorPos, _heroFacing);
+		_scene->_sequences.addTimer(120, 82);
+		break;
+
+	case 82:
+		_scene->_sequences.remove(_doorSequenceIdx);
+		_doorSequenceIdx = _scene->_sequences.startReverseCycle(_doorSpriteIdx, false, 7, 1, 0, 0);
+		_scene->_sequences.setDepth(_doorSequenceIdx, _doorDepth);
+		if (_actionFl)
+			_scene->_sequences.addSubEntry(_doorSequenceIdx, SEQUENCE_TRIGGER_EXPIRE, 0, 84);
+		else
+			_scene->_sequences.addSubEntry(_doorSequenceIdx, SEQUENCE_TRIGGER_EXPIRE, 0, 83);
+
+		break;
+
+	case 83: {
+		_doorSequenceIdx = _scene->_sequences.startCycle(_doorSpriteIdx, false, 1);
+		int idx = _scene->_dynamicHotspots.add(_doorWord, 0x242, _doorSequenceIdx, Common::Rect(0, 0, 0, 0));
+		int hotspotId = _scene->_dynamicHotspots.setPosition(idx, _doorPos, FACING_NORTHWEST);
+		_scene->_dynamicHotspots.setCursor(hotspotId, CURSOR_GO_LEFT);
+		_scene->_sequences.setDepth(_doorSequenceIdx, _doorDepth);
+		_firstDoorFl = true;
+		if (_labDoorFl) {
+			_globals._spriteIndexes[1] = _doorSpriteIdx;
+			_globals._sequenceIndexes[1] = _doorSequenceIdx;
+		} else {
+			_globals._spriteIndexes[2] = _doorSpriteIdx;
+			_globals._sequenceIndexes[2] = _doorSequenceIdx;
+		}
+		_game._player._stepEnabled = true;
+
+			 }
+			 break;
+
+	case 84:
+		_actionFl = false;
+		_game._player._stepEnabled = true;
+		if (_labDoorFl)
+			_scene->_nextSceneId = 508;
+		else
+			_scene->_nextSceneId = 507;
+
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene506::actions() {
+	int temp;
+
+	if (_action.isAction(0x242, 0x37D)) {
+		if (_firstDoorFl) {
+			_heroFacing = FACING_NORTHWEST;
+			_doorPos = Common::Point(16, 111);
+		}
+		_actionFl = true;
+		room_506_door_sequences();
+	} else if (_action.isAction(0x242, 0x336)) {
+		if (_firstDoorFl) {
+			_heroFacing = FACING_NORTHWEST;
+			_doorPos = Common::Point(80, 102);
+		}
+		_actionFl = true;
+		room_506_door_sequences();
+	} else if (_action.isAction(0x36A, 0x324)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 5);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			break;
+
+		case 1:
+			temp = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], temp);
+			_scene->_sequences.addTimer(6, 2);
+			break;
+
+		case 2:
+			_game._player._visible = false;
+			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 10, 1, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+			break;
+
+		case 3:
+			temp = _globals._sequenceIndexes[4];
+			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, -2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], temp);
+			_scene->_nextSceneId = 504;
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x31E))
+		_vm->_dialogs->show(50618);
+	else if (_action.isAction(VERB_LOOK, 0x372))
+		_vm->_dialogs->show(50610);
+	else if (_action.isAction(VERB_LOOK, 0x371))
+		_vm->_dialogs->show(50611);
+	else if (_action.isAction(VERB_LOOK, 0x482))
+		_vm->_dialogs->show(50612);
+	else if (_action.isAction(VERB_LOOK, 0x483))
+		_vm->_dialogs->show(50613);
+	else if (_action.isAction(VERB_TAKE, 0x483))
+		_vm->_dialogs->show(50614);
+	else if (_action.isAction(VERB_LOOK, 0x336))
+		_vm->_dialogs->show(50615);
+	else if (_action.isAction(VERB_LOOK, 0x37D))
+		_vm->_dialogs->show(50616);
+	else if (_action.isAction(VERB_LOOK, 0x360) || _action.isAction(0x1AD, 0x360))
+		_vm->_dialogs->show(50617);
+	else if (_action.isAction(VERB_LOOK, 0x373))
+		_vm->_dialogs->show(50619);
+	else if (_action.isAction(VERB_LOOK, 0x324))
+		_vm->_dialogs->show(50620);
+	else if (_action.isAction(VERB_LOOK, 0x142))
+		_vm->_dialogs->show(50621);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
index f29a900..94647fb 100644
--- a/engines/mads/nebular/nebular_scenes5.h
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -133,6 +133,35 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene506: public Scene5xx{
+private:
+	int _actionFl;             /* Flag to note daemon is running vs. parser */   
+
+	Common::Point _doorPos;
+	Facing _heroFacing;
+
+	int _doorDepth;
+	int _doorSpriteIdx;
+	int _doorSequenceIdx;
+	int _doorWord;
+
+	bool _labDoorFl;
+	bool _firstDoorFl;
+
+	void room_506_door_sequences();
+
+public:
+	Scene506(MADSEngine *vm) : Scene5xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 2cf67c9af2c5378510bb1c203ee2ce8f1ab69898
    https://github.com/scummvm/scummvm/commit/2cf67c9af2c5378510bb1c203ee2ce8f1ab69898
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-09T00:19:00+02:00

Commit Message:
MADS: Implement scene 507

Changed paths:
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes5.h



diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index b6c6611..f832b2e 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -1350,5 +1350,116 @@ void Scene506::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene507::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x106);
+	_scene->addActiveVocab(0xD);
+}
+
+void Scene507::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('p', -1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RXMRD_3");
+
+	if ((_game._difficulty != DIFFICULTY_EASY) && (_game._objects[OBJ_PENLIGHT]._roomNumber == _scene->_currentSceneId)) {
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 9, 0, 0, 0);
+		_penlightHotspotId = _scene->_dynamicHotspots.add(0x106, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(_penlightHotspotId, Common::Point(233, 152), FACING_SOUTHEAST);
+	}
+
+	if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(121, 147);
+		_game._player._facing = FACING_NORTH;
+	}
+
+	sceneEntrySound();
+}
+void Scene507::actions() {
+	if (_action.isAction(0x18B, 0x378))
+		_scene->_nextSceneId = 506;
+	else if (_action.isAction(VERB_TAKE, 0x106)) {
+		if (_game._trigger || !_game._objects.isInInventory(OBJ_PENLIGHT)) {
+			switch (_game._trigger) {
+			case 0:
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 6, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 5);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 5, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				break;
+
+			case 1:
+				_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+				_scene->_dynamicHotspots.remove(_penlightHotspotId);
+				_vm->_sound->command(27);
+				_game._objects.addToInventory(OBJ_PENLIGHT);
+				_vm->_dialogs->showItem(OBJ_PENLIGHT, 50730);
+				break;
+
+			case 2:
+				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[2]);
+				_game._player._visible = true;
+				_game._player._stepEnabled = true;
+				break;
+
+			default:
+				break;
+			}
+		}
+	} else if (_action._lookFlag)
+		_vm->_dialogs->show(50722);
+	else if (_action.isAction(VERB_LOOK, 0x299))
+		_vm->_dialogs->show(50710);
+	else if (_action.isAction(VERB_TAKE, 0x299))
+		_vm->_dialogs->show(50711);
+	else if (_action.isAction(VERB_LOOK, 0x376))
+		_vm->_dialogs->show(50712);
+	else if (_action.isAction(VERB_TAKE, 0x376))
+		_vm->_dialogs->show(50713);
+	else if (_action.isAction(VERB_LOOK, 0x375))
+		_vm->_dialogs->show(50714);
+	else if (_action.isAction(VERB_LOOK, 0x374))
+		_vm->_dialogs->show(50715);
+	else if (_action.isAction(VERB_LOOK, 0x244)) {
+		if (_scene->_customDest.x < 100)
+			_vm->_dialogs->show(50726);
+		else
+			_vm->_dialogs->show(50716);
+	} else if (_action.isAction(VERB_LOOK, 0x2A7))
+		_vm->_dialogs->show(50717);
+	else if (_action.isAction(VERB_LOOK, 0x2A6))
+		_vm->_dialogs->show(50718);
+	else if (_action.isAction(VERB_LOOK, 0x2A0))
+		_vm->_dialogs->show(50719);
+	else if (_action.isAction(VERB_LOOK, 0x377))
+		_vm->_dialogs->show(50720);
+	else if (_action.isAction(VERB_LOOK, 0xFE))
+		_vm->_dialogs->show(50721);
+	else if (_action.isAction(VERB_OPEN, 0x377))
+		_vm->_dialogs->show(50723);
+	else if (_action.isAction(VERB_LOOK, 0x28E))
+		_vm->_dialogs->show(50724);
+	else if (_action.isAction(VERB_LOOK, 0x197))
+		_vm->_dialogs->show(50725);
+	else if (_action.isAction(VERB_LOOK, 0x29F)) {
+		if (_game._objects.isInRoom(OBJ_PENLIGHT))
+			_vm->_dialogs->show(50728);
+		else
+			_vm->_dialogs->show(50727);
+	} else if (_action.isAction(VERB_LOOK, 0x106) && !_game._objects.isInInventory(OBJ_PENLIGHT)) {
+		if (_game._objects.isInRoom(OBJ_PENLIGHT))
+			_vm->_dialogs->show(50729);
+	} else if (_action.isAction(VERB_LOOK, 0x484))
+		_vm->_dialogs->show(50731);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
index 94647fb..369371d 100644
--- a/engines/mads/nebular/nebular_scenes5.h
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -162,6 +162,21 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene507: public Scene5xx{
+private:
+	int _penlightHotspotId;
+
+public:
+	Scene507(MADSEngine *vm) : Scene5xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 214e051c30a6541fbd53af66edd255d304ac149c
    https://github.com/scummvm/scummvm/commit/214e051c30a6541fbd53af66edd255d304ac149c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-09T00:32:18+02:00

Commit Message:
MADS: Implement scene 508

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes5.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 71489b4..2ae5b07 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -209,9 +209,9 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 506:	// shopping street
 		return new Scene506(vm);
 	case 507:	// inside software house
-		return new DummyScene(vm);	// TODO
+		return new Scene507(vm);
 	case 508:	// laser cannon
-		return new DummyScene(vm);	// TODO
+		return new Scene508(vm);
 	case 511:	// outside pleasure dome
 		return new DummyScene(vm);	// TODO
 	case 512:	// inside pleasure dome
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index f832b2e..65498ec 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -1461,5 +1461,264 @@ void Scene507::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene508::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x364);
+	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(0x343);
+}
+
+void Scene508::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('a', 0));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('m', 0));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('h', 0));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('l', 2));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('t', 0));
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites("*RXMRC_9");
+	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('l', 3));
+
+	if (!_game._visitedScenes._sceneRevisited) {
+		_globals[kLaserOn] = false;
+		_chosenObject = 0;
+	}
+
+	if (!_globals[kLaserOn]) {
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 8);
+		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, -2);
+		int idx = _scene->_dynamicHotspots.add(0x343, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(57, 116), FACING_NORTHEAST);
+		_scene->_hotspots.activate(0x342, false);
+		_scene->_hotspots.activate(0x343, false);
+	} else {
+		_scene->changeVariant(1);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 8);
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 11);
+		int idx = _scene->_dynamicHotspots.add(0x343, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(57, 116), FACING_NORTHEAST);
+		_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 15, 0, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 6, 8);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 6);
+		if (_globals[kLaserHoleIsThere]) {
+			_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, -2);
+			_scene->_hotspots.activate(0x342, true);
+			_scene->_hotspots.activate(0x343, true);
+		}
+		_vm->_sound->command(21);
+	}
+	_vm->_sound->command(20);
+
+	if (_scene->_priorSceneId == 515) {
+		_game._player._playerPos = Common::Point(57, 116);
+		_game._player._facing = FACING_NORTHEAST;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(289, 139);
+		_game._player._facing = FACING_WEST;
+	}
+
+	sceneEntrySound();
+	_game.loadQuoteSet(0x273, 0);
+
+	if (_scene->_roomChanged) {
+		_game._objects.addToInventory(OBJ_COMPACT_CASE);
+		_game._objects.addToInventory(OBJ_REARVIEW_MIRROR);
+	}
+}
+
+void Scene508::preActions() {
+	if (_action.isAction(0x32F, 0xF9))
+		_game._player._walkOffScreenSceneId = 506;
+}
+
+void Scene508::handlePedestral() {
+	if (!_globals[kLaserOn])
+		_vm->_dialogs->show(50835);
+
+	if (_globals[kLaserHoleIsThere])
+		_vm->_dialogs->show(50836);
+
+	if (_globals[kLaserOn] && !_globals[kLaserHoleIsThere]) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_globals._sequenceIndexes[6] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[6], false, 9, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 1, 4);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[6]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_SPRITE, 4, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+			break;
+
+		case 1:
+			if (_chosenObject == 2)
+				_game._objects.removeFromInventory(OBJ_COMPACT_CASE, 1);
+			else
+				_game._objects.removeFromInventory(OBJ_REARVIEW_MIRROR, 1);
+
+			_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 6, 1, 0, 0);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+
+		case 2:
+			_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, -2);
+			_scene->_hotspots.activate(0x342, true);
+			_scene->_hotspots.activate(0x343, true);
+			break;
+
+		case 3:
+			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[6]);
+			_game._player._visible = true;
+			_scene->_sequences.addTimer(120, 4);
+			break;
+
+		case 4:
+			_vm->_dialogs->show(50834);
+			_globals[kLaserHoleIsThere] = true;
+			_scene->_nextSceneId = 515;
+			break;
+
+		default:
+			break;
+		}
+	}
+}
+
+void Scene508::actions() {
+	if (_action.isAction(VERB_PULL, 0x2AC)) {
+		if (!_globals[kLaserOn]) {
+			switch (_game._trigger) {
+			case 0:
+				_game._player._stepEnabled = false;
+				_scene->_kernelMessages.reset();
+				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 2, 120, _game.getQuote(0x273));
+				break;
+
+			case 2:
+				_game._player._visible = false;
+				_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+				_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 10, 1, 0, 0);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 7);
+				_scene->_sequences.updateTimeout(_globals._sequenceIndexes[1], -1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+				break;
+
+			case 3:
+				_vm->_sound->command(19);
+				_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 15, 1, 0, 0);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 6);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 4);
+				_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 8);
+				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[1]);
+				_game._player._visible = true;
+				_scene->_sequences.addTimer(15, 5);
+				break;
+
+			case 4:
+				_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 15, 0, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 6, 8);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 6);
+				break;
+
+			case 5:
+				_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+				_scene->loadAnimation(formAnimName('B', 1), 6);
+				break;
+
+			case 6: {
+				_vm->_sound->command(22);
+				_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, -2);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 11);
+				int idx = _scene->_dynamicHotspots.add(0x343, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+				_scene->_dynamicHotspots.setPosition(idx, Common::Point(57, 116), FACING_NORTHEAST);
+				_scene->_kernelMessages.reset();
+				_scene->changeVariant(1);
+				_scene->_sequences.addTimer(30, 7);
+				}
+				break;
+
+			case 7:
+				_globals[kLaserOn] = true;
+				_vm->_dialogs->show(50833);
+				_game._player._stepEnabled = true;
+				break;
+
+			default:
+				break;
+			}
+		} else {
+			_vm->_dialogs->show(50837);
+		}
+	} else if (_action.isAction(0x365, 0x120, 0x343) || _action.isAction(VERB_PUT, 0x120, 0x344) || _action.isAction(VERB_PUT, 0x120, 0x343)) {
+		_chosenObject = 1;
+		handlePedestral();
+	} else if (_action.isAction(VERB_PUT, 0x57, 0x344) || _action.isAction(VERB_PUT, 0x57, 0x343) || _action.isAction(0x365, 0x57, 0x343)) {
+		_chosenObject = 2;
+		handlePedestral();
+	} else if (_action._lookFlag)
+		_vm->_dialogs->show(50822);
+	else if (_action.isAction(VERB_LOOK, 0x485))
+		_vm->_dialogs->show(50810);
+	else if (_action.isAction(VERB_LOOK, 0x364))
+		_vm->_dialogs->show(50811);
+	else if (_action.isAction(VERB_TAKE, 0x364))
+		_vm->_dialogs->show(50812);
+	else if (_action.isAction(VERB_LOOK, 0x37A))
+		_vm->_dialogs->show(50816);
+	else if (_action.isAction(VERB_TAKE, 0x37A))
+		_vm->_dialogs->show(50817);
+	else if (_action.isAction(VERB_LOOK, 0x2AF))
+		_vm->_dialogs->show(50818);
+	else if (_action.isAction(VERB_LOOK, 0xE2)) {
+		if (_globals[kLaserOn])
+			_vm->_dialogs->show(50820);
+		else
+			_vm->_dialogs->show(50819);
+	} else if (_action.isAction(VERB_LOOK, 0x379)) {
+		if (_globals[kLaserOn])
+			_vm->_dialogs->show(50822);
+		else
+			_vm->_dialogs->show(50821);
+	} else if (_action.isAction(VERB_TAKE, 0x379))
+		_vm->_dialogs->show(50823);
+	else if (_action.isAction(VERB_LOOK, 0x2AC)) {
+		if (_globals[kLaserOn])
+			_vm->_dialogs->show(50825);
+		else
+			_vm->_dialogs->show(50824);
+	} else if (_action.isAction(VERB_PUSH, 0x2AC))
+		_vm->_dialogs->show(50826);
+	else if (_action.isAction(VERB_LOOK, 0x343)) {
+		if (_globals[kLaserHoleIsThere])
+			_vm->_dialogs->show(50828);
+		else
+			_vm->_dialogs->show(50827);
+	} else if (_action.isAction(VERB_TAKE, 0x343))
+		_vm->_dialogs->show(50829);
+	else if (_action.isAction(VERB_LOOK, 0x46)) {
+		if (_globals[kLaserHoleIsThere])
+			_vm->_dialogs->show(50831);
+		else
+			_vm->_dialogs->show(50830);
+	} else if (_action.isAction(VERB_LOOK, 0x18D))
+		_vm->_dialogs->show(50832);
+	else if (_action.isAction(VERB_LOOK, 0x344)) {
+		if (!_globals[kLaserOn])
+			_vm->_dialogs->show(50813);
+		else if (!_globals[kLaserHoleIsThere])
+			_vm->_dialogs->show(50814);
+		else
+			_vm->_dialogs->show(50815);
+	} else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
index 369371d..29ec69f 100644
--- a/engines/mads/nebular/nebular_scenes5.h
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -177,6 +177,23 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene508: public Scene5xx{
+private:
+	int _chosenObject;
+
+	void handlePedestral();
+
+public:
+	Scene508(MADSEngine *vm) : Scene5xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: b42bf6342c05eb1a9d5e453169f3dd2721dc0114
    https://github.com/scummvm/scummvm/commit/b42bf6342c05eb1a9d5e453169f3dd2721dc0114
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-09T02:34:53+03:00

Commit Message:
MADS: Remove superfluous empty scene methods

Changed paths:
    engines/mads/dragonsphere/dragonsphere_scenes.h
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes2.h
    engines/mads/nebular/nebular_scenes4.h
    engines/mads/nebular/nebular_scenes5.h
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes7.h
    engines/mads/nebular/nebular_scenes8.h
    engines/mads/phantom/phantom_scenes.h



diff --git a/engines/mads/dragonsphere/dragonsphere_scenes.h b/engines/mads/dragonsphere/dragonsphere_scenes.h
index 0c5fea3..8ce1492 100644
--- a/engines/mads/dragonsphere/dragonsphere_scenes.h
+++ b/engines/mads/dragonsphere/dragonsphere_scenes.h
@@ -114,10 +114,7 @@ public:
 
 	virtual void setup() {}
 	virtual void enter() {}
-	virtual void step() {}
-	virtual void preActions() {}
 	virtual void actions() {}
-	virtual void synchronize(Common::Serializer &s) {}
 };
 
 } // End of namespace Dragonsphere
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 0db8b93..2f9dff7 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -198,10 +198,7 @@ public:
 
 	virtual void setup() {}
 	virtual void enter() {}
-	virtual void step() {}
-	virtual void preActions() {}
 	virtual void actions() {}
-	virtual void synchronize(Common::Serializer &s) {}
 };
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 47d5a12..14a5d75 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -278,7 +278,6 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
 };
 
diff --git a/engines/mads/nebular/nebular_scenes4.h b/engines/mads/nebular/nebular_scenes4.h
index 8ff2ec5..bacab8a 100644
--- a/engines/mads/nebular/nebular_scenes4.h
+++ b/engines/mads/nebular/nebular_scenes4.h
@@ -65,7 +65,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene402: public Scene4xx {
@@ -127,7 +126,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene405: public Scene4xx {
@@ -139,7 +137,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene406: public Scene4xx {
@@ -155,7 +152,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene407: public Scene4xx {
@@ -172,7 +168,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene408: public Scene4xx {
@@ -181,10 +176,8 @@ public:
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene409: public SceneTeleporter {
@@ -194,9 +187,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene410: public Scene4xx {
@@ -208,7 +199,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene411: public Scene4xx {
@@ -245,7 +235,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene413: public Scene4xx {
@@ -262,7 +251,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
index 29ec69f..c67ff9a 100644
--- a/engines/mads/nebular/nebular_scenes5.h
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -67,7 +67,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene502: public SceneTeleporter {
@@ -77,9 +76,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene503: public Scene5xx{
@@ -91,10 +88,7 @@ public:
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene504: public Scene5xx{
@@ -110,7 +104,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene505: public Scene5xx{
@@ -129,9 +122,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene506: public Scene5xx{
@@ -157,9 +148,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene507: public Scene5xx{
@@ -171,10 +160,7 @@ public:
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene508: public Scene5xx{
@@ -188,10 +174,8 @@ public:
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 42ec3f1..476b132 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -54,7 +54,6 @@ void Scene7xx::setPlayerSpritesPrefix() {
 	else
 		_game._player._spritesPrefix = "ROX";
 
-
 	_game._player._scalingVelocity = true;
 
 	if (oldName != _game._player._spritesPrefix)
diff --git a/engines/mads/nebular/nebular_scenes7.h b/engines/mads/nebular/nebular_scenes7.h
index 66a42de..ae5b822 100644
--- a/engines/mads/nebular/nebular_scenes7.h
+++ b/engines/mads/nebular/nebular_scenes7.h
@@ -56,10 +56,8 @@ public:
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {}
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene707: public SceneTeleporter {
@@ -69,9 +67,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene710: public Scene7xx {
@@ -81,9 +77,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene711: public SceneTeleporter {
@@ -93,9 +87,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene752: public Scene7xx {
@@ -110,7 +102,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/nebular_scenes8.h b/engines/mads/nebular/nebular_scenes8.h
index 2c777d8..1ea2959 100644
--- a/engines/mads/nebular/nebular_scenes8.h
+++ b/engines/mads/nebular/nebular_scenes8.h
@@ -79,9 +79,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 } // End of namespace Nebular
diff --git a/engines/mads/phantom/phantom_scenes.h b/engines/mads/phantom/phantom_scenes.h
index e4b79fe..986934f 100644
--- a/engines/mads/phantom/phantom_scenes.h
+++ b/engines/mads/phantom/phantom_scenes.h
@@ -114,10 +114,7 @@ public:
 
 	virtual void setup() {}
 	virtual void enter() {}
-	virtual void step() {}
-	virtual void preActions() {}
 	virtual void actions() {}
-	virtual void synchronize(Common::Serializer &s) {}
 };
 
 } // End of namespace Phantom


Commit: 2ec60606d837bb137f9178b5f3e8517c149fe2b6
    https://github.com/scummvm/scummvm/commit/2ec60606d837bb137f9178b5f3e8517c149fe2b6
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-09T23:37:54+02:00

Commit Message:
MADS: Implement scene 511

Changed paths:
    engines/mads/nebular/game_nebular.h
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes5.h



diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index e754a11..82ddfb5 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -72,6 +72,7 @@ enum InventoryObject {
 	OBJ_FAKE_ID = 29,
 	OBJ_ID_CARD = 30,
 	OBJ_POLYCEMENT = 31,
+	OBJ_FISHING_ROD = 32,
 	OBJ_FISHING_LINE = 33,
 	OBJ_PADLOCK_KEY = 34,
 	OBJ_DOOR_KEY = 35,
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 2ae5b07..b406468 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -213,7 +213,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 508:	// laser cannon
 		return new Scene508(vm);
 	case 511:	// outside pleasure dome
-		return new DummyScene(vm);	// TODO
+		return new Scene511(vm);
 	case 512:	// inside pleasure dome
 		return new DummyScene(vm);	// TODO
 	case 513:	// outside mall
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index 65498ec..109923a 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -933,7 +933,7 @@ void Scene505::step() {
 					_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 					_scene->_sequences.remove(_globals._sequenceIndexes[0]);
 					_scene->_sequences.remove(_globals._sequenceIndexes[13]);
-					_globals._sequenceIndexes[13] = _scene->_sequences.startReverseCycle (_globals._spriteIndexes[13], false, 6, 1, 0, 0);
+					_globals._sequenceIndexes[13] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[13], false, 6, 1, 0, 0);
 					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 63);
 					_vm->_sound->command(18);
 				}
@@ -949,7 +949,7 @@ void Scene505::step() {
 					_scene->_sequences.remove(_globals._sequenceIndexes[0]);
 
 				if (_selectedId != _homeSelectedId) {
-					_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[0 + _selectedId], false, 24, 0, 0, 0);
+					_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0 + _selectedId], false, 24, 0, 0, 0);
 					_scene->_sequences.setDepth(_globals._sequenceIndexes[0], 1);
 				}
 			}
@@ -1037,26 +1037,26 @@ void Scene505::step() {
 		int syncIdx = _globals._sequenceIndexes[13];
 		_globals._sequenceIndexes[13] = _scene->_sequences.startCycle(_globals._spriteIndexes[13], false, -2);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
-		_scene->_sequences.updateTimeout (_globals._sequenceIndexes[13], syncIdx);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[13], syncIdx);
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[_homeSelectedId], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 		_globals._sequenceIndexes[11] = _scene->_sequences.startCycle(_globals._spriteIndexes[11], false, _selectedId + 1);
 
 		if (_selectedId != _homeSelectedId) {
-			_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[0 + _selectedId], false, 24, 0, 0, 0);
+			_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0 + _selectedId], false, 24, 0, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[0], 1);
 		}
 		break;
 		}
 
 	case 61:
-		_globals._sequenceIndexes[10] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[10], false, 8, 0, 0, 0);
+		_globals._sequenceIndexes[10] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[10], false, 8, 0, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 8);
-		_scene->_sequences.updateTimeout (_globals._sequenceIndexes[10], _globals._sequenceIndexes[9]);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[10], _globals._sequenceIndexes[9]);
 		break;
 
 	case 62:
-		_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[9], false, 8, 1, 0, 0);
+		_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 8, 1, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 61);
 		break;
@@ -1102,18 +1102,18 @@ void Scene506::enter() {
 	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('c', -1));
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXCD_3");
 
-	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);  
+	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
 	int idx = _scene->_dynamicHotspots.add(0x37D, 0x242, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 	int hotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(65, 125), FACING_NORTHWEST);
 	_scene->_dynamicHotspots.setCursor(hotspotId, CURSOR_GO_LEFT);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
-	_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);  
+	_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
 	idx = _scene->_dynamicHotspots.add(0x336, 0x242, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
 	hotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(112, 102), FACING_NORTHWEST);
 	_scene->_dynamicHotspots.setCursor(hotspotId, CURSOR_GO_LEFT);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 13);
 
-	_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -1);  
+	_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -1);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 5);
 	_firstDoorFl = true;
 	_actionFl            = false;
@@ -1133,7 +1133,7 @@ void Scene506::enter() {
 		_game._player._facing = FACING_NORTHEAST;
 		_game._player._visible   = false;
 		_game._player._stepEnabled = false;
-		_scene->_sequences.remove (_globals._sequenceIndexes[3]); 
+		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
 		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 5);
 		_scene->loadAnimation(formAnimName('R', 1), 70);
@@ -1720,5 +1720,326 @@ void Scene508::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene511::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x345);
+	_scene->addActiveVocab(0x87);
+	_scene->addActiveVocab(0xD);
+}
+
+void Scene511::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', 0));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXCD_6");
+
+	if (_scene->_priorSceneId != -2)
+		_handingLine = false;
+
+	if (_globals[kBoatRaised]) {
+		_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('b', 0));
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 3);
+		_scene->_hotspots.activate(0x345, false);
+		int idx = _scene->_dynamicHotspots.add(0x345, VERB_WALKTO, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(75, 124), FACING_NORTH);
+		_scene->_hotspots.activate(0x347, false);
+	} else {
+		_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('b', 2));
+		_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('b', 3));
+		_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('b', 1));
+
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 1, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 5);
+
+		_globals._sequenceIndexes[5]  = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 4);
+
+		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6],5);
+
+		_scene->_hotspots.activate(0x347, true);
+		_scene->_hotspots.activate(0x345, true);
+		_scene->changeVariant(1);
+	}
+
+	int frame = 0;
+	if (_globals[kLineStatus] == 2)
+		frame = -1;
+	else if (_globals[kLineStatus] == 3)
+		frame = -2;
+
+	if (_globals[kLineStatus] == 2 || _globals[kLineStatus] == 3) {
+		_globals._spriteIndexes[7]  = _scene->_sprites.addSprites(formAnimName('b', 4));
+		_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, frame);
+		int idx = _scene->_dynamicHotspots.add(0x87, VERB_WALKTO, _globals._sequenceIndexes[7], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(26, 153), FACING_NORTHEAST);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 3);
+		if (_globals[kBoatRaised])
+			_scene->changeVariant(2);
+	}
+
+	_lineFrame      = -1;
+	_lineMoving     = false;
+
+	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+
+	if (_scene->_priorSceneId == 512) {
+		_game._player._playerPos = Common::Point(60, 112);
+		_game._player._facing = FACING_SOUTHEAST;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(55, 152);
+		_game._player._facing = FACING_NORTHWEST;
+		_game._player._visible   = false;
+		_game._player._stepEnabled = false;
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+		_scene->loadAnimation(formAnimName('R', 1), 70);
+	} else if (_handingLine) {
+		_game._player._visible = false;
+		_lineAnimationMode   = 1;
+		_lineAnimationPosition    = 1;
+		_scene->loadAnimation(formAnimName('R', -1));
+		_lineFrame = 2;
+	}
+	sceneEntrySound();
+}
+
+void Scene511::step() {
+	if ((_lineAnimationMode    == 1) && _scene->_activeAnimation) {
+		if (_lineFrame != _scene->_activeAnimation->getCurrentFrame()) {
+			_lineFrame         = _scene->_activeAnimation->getCurrentFrame();
+			int resetFrame               = -1;
+
+			if ((_lineAnimationPosition == 2) && (_lineFrame  == 14))
+				_lineMoving   = false;
+
+			if (_lineAnimationPosition == 1) {
+				if (_lineFrame  == 3) {
+					_lineMoving    = false;
+					resetFrame             = 2;
+				}
+
+				if (_handingLine)
+					resetFrame             = 2;
+			}
+
+			if ((resetFrame >= 0) && (resetFrame != _scene->_activeAnimation->getCurrentFrame())) {
+				_scene->_activeAnimation->setCurrentFrame(resetFrame);
+				_lineFrame = resetFrame;
+			}
+		}
+	}
+
+	switch (_game._trigger) {
+	case 70:
+		_game._player._visible   = true;
+		_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
+		_scene->_sequences.addTimer(6, 71);
+		break;
+
+	case 71:
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 72);
+		break;
+
+	case 72:
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+		_game._player._stepEnabled = true;
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene511::preActions() {
+	if (!_handingLine)
+		return;
+
+	if (_action.isAction(VERB_LOOK) || _action.isAction(0x87) || _action.isAction(VERB_TALKTO))
+		_game._player._needToWalk = false;
+
+	if ((!_action.isAction(0x170, 0x87, 0x345) || !_action.isAction(0x19, 0x87, 0x345)) && _game._player._needToWalk) {
+		if (_game._trigger == 0) {
+			_game._player._readyToWalk = false;
+			_game._player._stepEnabled = false;
+			_scene->freeAnimation ();
+			_lineAnimationMode   = 2;
+			_scene->loadAnimation(formAnimName('R',2), 1);
+		} else if (_game._trigger == 1) {
+			_game._player._visible   = true;
+			_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
+			_game._objects.setRoom(OBJ_FISHING_LINE, 1);
+			_handingLine     = false;
+			_game._player._stepEnabled = true;
+			_game._player._readyToWalk = true;
+		}
+	}
+}
+
+void Scene511::actions() {
+	if (_action.isAction(0x242, 0x372))
+		_scene->_nextSceneId = 512;
+	else if (_action.isAction(0x36A, 0x324)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			break;
+
+		case 1: {
+			int syncIdx = _globals._sequenceIndexes[1];
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[1], syncIdx);
+			_scene->_sequences.addTimer(6, 2);
+			}
+			break;
+
+		case 2:
+			_game._player._visible   = false;
+			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 8, 1, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+			break;
+
+		case 3: {
+			int syncIdx = _globals._sequenceIndexes[4];
+			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, -2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], syncIdx);
+			_scene->_nextSceneId = 504;
+			}
+			break;
+
+		default:
+			break;
+		}
+	} else 	if (_action.isAction(VERB_TAKE, 0x87)) {
+		if (!_globals[kBoatRaised]) {
+			if (_globals[kLineStatus] == 2) {
+				if (_globals[kLineStatus] != 3) {
+					if (_game._trigger == 0) {
+						_game._player._stepEnabled = false;
+						_game._player._visible   = false;
+						_lineAnimationMode   = 1;
+						_lineAnimationPosition    = 1;
+						_lineMoving      = true;
+						_scene->loadAnimation(formAnimName('R', -1), 0);
+						_scene->_sequences.addTimer(1, 1);
+					} else if (_game._trigger == 1) {
+						if (_lineMoving) {
+							_scene->_sequences.addTimer(1, 1);
+						} else {
+							_game._objects.addToInventory(OBJ_FISHING_LINE);
+							_lineMoving      = true;
+							_handingLine     = true;
+							_game._player._stepEnabled = true;
+						}
+					}
+				} else
+					_vm->_dialogs->show(51129);
+			} else
+				return;
+		} else {
+			_vm->_dialogs->show(51130);
+		}
+	} else if (_action.isAction(0x170, 0x87, 0x345) || _action.isAction(0x19, 0x87, 0x345)) {
+		if (_globals[kBoatRaised])
+			_vm->_dialogs->show(51131);
+		else if (_globals[kLineStatus] == 1)
+			_vm->_dialogs->show(51130);
+		else if (!_globals[kBoatRaised] && _handingLine) {
+			if (_globals[kLineStatus] != 3) {
+				if (_game._trigger == 0) {
+					_game._player._stepEnabled = false;
+					_scene->_sequences.remove(_globals._sequenceIndexes[7]);
+					_lineMoving      = true;
+					_lineAnimationPosition    = 2;
+					_scene->_sequences.addTimer(1, 1);
+				} else if (_game._trigger == 1) {
+					if (_lineMoving)
+						_scene->_sequences.addTimer(1, 1);
+					else {
+						_game._player._visible   = true;
+						_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+						_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, -2);
+						_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 4);
+						int idx = _scene->_dynamicHotspots.add(0x87, VERB_WALKTO, _globals._sequenceIndexes[7], Common::Rect(0, 0, 0, 0));
+						_scene->_dynamicHotspots.setPosition(idx, Common::Point(26, 153), FACING_NORTHEAST);
+						_game._objects.removeFromInventory(OBJ_FISHING_LINE, 1);
+						_handingLine     = false;
+						_lineMoving      = true;
+						_globals[kLineStatus]     = 3;
+						_game._player._stepEnabled = true;
+					}
+				}
+			}
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x31E) || _action._lookFlag) {
+		if (_globals[kLineStatus] == 2)
+			_vm->_dialogs->show(51110);
+		else {
+			if (_globals[kLineStatus] == 3)
+				_vm->_dialogs->show(51111);
+			else
+				_vm->_dialogs->show(51112);
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x324))
+		_vm->_dialogs->show(51113);
+	else if (_action.isAction(VERB_LOOK, 0x31D))
+		_vm->_dialogs->show(51114);
+	else if (_action.isAction(0x1AD, 0x322) || _action.isAction(0x1AD, 0x361) || _action.isAction(0x1AD, 0x321))
+		_vm->_dialogs->show(51115);
+	else if (_action.isAction(VERB_LOOK, 0x37B))
+		_vm->_dialogs->show(51116);
+	else if (_action.isAction(VERB_LOOK, 0x34A))
+		_vm->_dialogs->show(51117);
+	else if (_action.isAction(VERB_LOOK, 0x37C))
+		_vm->_dialogs->show(51118);
+	else if (_action.isAction(0x17B, 0xFF, 0x37C) || _action.isAction(0x17B, 0x6F, 0x37C))
+		_vm->_dialogs->show(51119);
+	else if (  (_action.isAction(VERB_PUT) || _action.isAction(VERB_THROW))
+		 && (_action.isAction(0x171) || _action.isAction(0x2A) || _action.isAction(0x2B))
+		 && _action.isAction(0x37C))
+		_vm->_dialogs->show(51120);
+	else if (_action.isAction(VERB_LOOK, 0x372)) {
+		if (_globals[kBoatRaised])
+			_vm->_dialogs->show(51121);
+		else
+			_vm->_dialogs->show(51128);
+	} else if (_action.isAction(VERB_LOOK, 0x349))
+		_vm->_dialogs->show(51122);
+	else if (_action.isAction(VERB_LOOK, 0x87) && (_action._mainObjectSource == 4) && (_globals[kLineStatus] == 2))
+		_vm->_dialogs->show(51126);
+	else if (_action.isAction(VERB_LOOK, 0x87) && (_action._mainObjectSource == 4) && (_globals[kLineStatus] == 3))
+		_vm->_dialogs->show(51133);
+	else if (_action.isAction(VERB_LOOK, 0x2CD))
+		_vm->_dialogs->show(51127);
+	else if (_action.isAction(VERB_LOOK, 0x345))
+		if (_globals[kBoatRaised])
+			_vm->_dialogs->show(51123);
+		else if (_globals[kLineStatus] != 3)
+			_vm->_dialogs->show(51124);
+		else
+			_vm->_dialogs->show(51125);
+	else if (_action.isAction(VERB_LOOK, 0x87) && (_globals[kLineStatus] == 3))
+		_vm->_dialogs->show(51125);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
index c67ff9a..f46e8ee 100644
--- a/engines/mads/nebular/nebular_scenes5.h
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -178,6 +178,26 @@ public:
 	virtual void actions();
 };
 
+class Scene511: public Scene5xx{
+private:
+	bool _handingLine;
+	bool _lineMoving;
+
+	int _lineAnimationMode;
+	int _lineFrame;
+	int _lineAnimationPosition;
+
+public:
+	Scene511(MADSEngine *vm) : Scene5xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: e2f2e31db37be06538ecea78917c64a0b9c65197
    https://github.com/scummvm/scummvm/commit/e2f2e31db37be06538ecea78917c64a0b9c65197
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-09T20:06:35-04:00

Commit Message:
MADS: Changed greyList to use original style insertion sort

Changed paths:
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 6be9d3d..1d3072f 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -359,7 +359,7 @@ void Fader::fadeToGrey(byte palette[PALETTE_SIZE], byte *paletteMap,
 	GreyEntry map[PALETTE_COUNT];
 	int intensity;
 	byte palIndex[PALETTE_COUNT][3];
-	bool signs[PALETTE_COUNT][3];
+	int8 signs[PALETTE_COUNT][3];
 
 	mapToGreyRamp(palette, baseColor, numColors, baseGrey, numGreys, map);
 
@@ -408,13 +408,10 @@ void Fader::fadeToGrey(byte palette[PALETTE_SIZE], byte *paletteMap,
 	}
 }
 
-static bool greyCompareFunc(const Fader::GreyTableEntry &g1, const Fader::GreyTableEntry &g2) {
-	return g1._list < g2._list;
-}
-
 void Fader::mapToGreyRamp(byte palette[PALETTE_SIZE], int baseColor, int numColors,
 		int baseGrey, int numGreys, GreyEntry *map) {
-	GreyTableEntry greyList[PALETTE_COUNT];
+	byte greyList[PALETTE_COUNT];
+	byte greyMapping[PALETTE_COUNT];
 	byte greyTable[64];
 	byte greyIntensity[64];
 	int intensity, shiftSign;
@@ -423,7 +420,7 @@ void Fader::mapToGreyRamp(byte palette[PALETTE_SIZE], int baseColor, int numColo
 	greyPopularity(greyList, greyTable, numColors);
 
 	for (int idx = 0; idx < numColors; ++idx) {
-		greyList[idx]._mapping = idx;
+		greyMapping[idx] = idx;
 		Common::fill(&map[idx]._accum[0], &map[idx]._accum[3], 0);
 	}
 
@@ -431,8 +428,8 @@ void Fader::mapToGreyRamp(byte palette[PALETTE_SIZE], int baseColor, int numColo
 		map[idx]._mapColor = (byte)idx;
 	}
 
-	// Sort the mapping list
-	Common::sort(&greyList[0], &greyList[numColors], greyCompareFunc);
+	// Sort the mapping lists
+	insertionSort(numColors, greyList, greyMapping);
 
 	// Initialise state variables
 	int greySum = 0;
@@ -444,7 +441,7 @@ void Fader::mapToGreyRamp(byte palette[PALETTE_SIZE], int baseColor, int numColo
 
 	for (int greyCtr = 0; greyCtr < 64; ++greyCtr) {
 		for (int idx = 0; idx < greyTable[greyCtr]; ++idx) {
-			greySum += greyList[greyScan++]._list;
+			greySum += greyList[greyScan++];
 			++greyColors;
 
 			greyAccum += numGreys;
@@ -455,8 +452,8 @@ void Fader::mapToGreyRamp(byte palette[PALETTE_SIZE], int baseColor, int numColo
 				}
 
 				for (int rescan = firstColor; rescan < greyScan; ++rescan) {
-					map[greyList[rescan]._mapping]._intensity = greyIntensity[greyMark];
-					map[greyList[rescan]._mapping]._mapColor = (byte)(greyMark + baseGrey);
+					map[greyMapping[rescan]]._intensity = greyIntensity[greyMark];
+					map[greyMapping[rescan]]._mapColor = (byte)(greyMark + baseGrey);
 				}
 
 				firstColor = greyScan;
@@ -487,24 +484,76 @@ void Fader::mapToGreyRamp(byte palette[PALETTE_SIZE], int baseColor, int numColo
 }
 
 void Fader::getGreyValues(const byte palette[PALETTE_SIZE],
-		GreyTableEntry greyList[PALETTE_COUNT], int baseColor, int numColors) {
+		byte greyList[PALETTE_COUNT], int baseColor, int numColors) {
 	const byte *palP = &palette[baseColor * 3];
 
 	for (int i = 0; i < numColors; ++i, palP += 3) {
 		int v = rgbMerge(palP[0], palP[1], palP[2]);
-		greyList[i]._list = v >> 7;
+		greyList[i] = v >> 7;
 	}
 }
 
-void Fader::greyPopularity(const GreyTableEntry greyList[PALETTE_COUNT],
+void Fader::greyPopularity(const byte greyList[PALETTE_COUNT],
 		byte greyTable[64], int numColors) {
 	Common::fill(&greyTable[0], &greyTable[64], 0);
 	for (int i = 0; i < numColors; ++i) {
-		int idx = greyList[i]._list;
+		int idx = greyList[i];
 		++greyTable[idx];
 	}
 }
 
+void Fader::insertionSort(int size, byte *id, byte *value) {
+	bool restartFlag;
+	int endIndex = size - 1;
+
+	do {
+		restartFlag = false;
+		if (endIndex <= 0)
+			break;
+
+		for (int arrIndex = 0; arrIndex < endIndex && !restartFlag; ++arrIndex) {
+			byte *idP = id + arrIndex;
+			byte *valueP = value + arrIndex;
+
+			// Check whether the next index is out of order with the one following it
+			if (*idP > *(idP + 1)) {
+				// Found an incorrect ordering
+				restartFlag = true;
+
+				// Save id/value at current index
+				byte savedId = *idP;
+				byte savedValue = *valueP;
+
+				int moveCount = size - arrIndex - 1;
+				if (moveCount > 0) {
+					Common::copy(idP + 1, idP + moveCount + 2, idP);
+					Common::copy(valueP + 1, valueP + moveCount + 2, valueP);
+				}
+
+				// Scan for insert spot
+				int idx = 0;
+				if (endIndex > 0) {
+					bool breakFlag = false;
+					for (; idx <= endIndex && !breakFlag; ++idx) {
+						breakFlag = savedId < id[idx];
+					}
+				}
+
+				// Set up an insert point for entry
+				moveCount = size - idx - 1;
+				if (moveCount > 0) {
+					Common::copy_backward(id + idx, id + idx + moveCount, id + idx + moveCount + 1);
+					Common::copy_backward(value + idx, value + idx + moveCount, value + idx + moveCount + 1);
+				}
+
+				// Set shifted values at the new position
+				id[idx] = savedId;
+				value[idx] = savedValue;
+			}
+		}
+	} while (restartFlag);
+}
+
 int Fader::rgbMerge(RGB6 &palEntry) {
 	return rgbMerge(palEntry.r, palEntry.g, palEntry.b);
 }
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 31c3d1a..e1f7de8 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -168,23 +168,23 @@ public:
 		byte _mapColor;
 		uint16 _accum[3];
 	};
-
-	struct GreyTableEntry {
-		int _list;
-		int _mapping;
-	};
 private:
 	void mapToGreyRamp(byte palette[PALETTE_SIZE], int baseColor, int numColors,
 		int baseGrey, int numGreys, GreyEntry *map);
 
-	void getGreyValues(const byte palette[PALETTE_SIZE], GreyTableEntry greyList[PALETTE_COUNT],
+	void getGreyValues(const byte palette[PALETTE_SIZE], byte greyList[PALETTE_COUNT],
 		int baseColor, int numColors);
 
 	/**
 	 * Given a grey value list containing grey shades (0-63), creates a 64 byte
 	 * grey table containing the number of grey values for each intensity
 	 */
-	void greyPopularity(const GreyTableEntry greyList[PALETTE_COUNT], byte greyTable[64], int numColors);
+	void greyPopularity(const byte greyList[PALETTE_COUNT], byte greyTable[64], int numColors);
+
+	/**
+	 * Does an insertion sort of a given id/value array pair
+	 */
+	void insertionSort(int size, byte *id, byte *value);
 protected:
 	MADSEngine *_vm;
 public:


Commit: 88ac15d69e550209f1a82d3090e370d2fa7d3153
    https://github.com/scummvm/scummvm/commit/88ac15d69e550209f1a82d3090e370d2fa7d3153
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-09T22:53:37-04:00

Commit Message:
MADS: Greyscale fading now close to the original

Changed paths:
    engines/mads/palette.cpp



diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 1d3072f..e718059 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -377,7 +377,7 @@ void Fader::fadeToGrey(byte palette[PALETTE_SIZE], byte *paletteMap,
 				intensity = _colorValues[colorCtr];
 			}
 
-			int diff = intensity - palette[palCtr * 3 + colorCtr];
+			int diff = intensity - VGA_COLOR_REV(palette[palCtr * 3 + colorCtr]);
 			palIndex[palCtr][colorCtr] = (byte)ABS(diff);
 			signs[palCtr][colorCtr] = (diff == 0) ? 0 : (diff < 0 ? -1 : 1);
 		}
@@ -390,7 +390,10 @@ void Fader::fadeToGrey(byte palette[PALETTE_SIZE], byte *paletteMap,
 				map[index]._accum[colorCtr] += palIndex[palCtr][colorCtr];
 				while (map[index]._accum[colorCtr] >= steps) {
 					map[index]._accum[colorCtr] -= steps;
-					palette[palCtr * 3 + colorCtr] = signs[palCtr][colorCtr];
+
+					byte rgb63 = VGA_COLOR_REV(palette[palCtr * 3 + colorCtr]) +
+						signs[palCtr][colorCtr];
+					palette[palCtr * 3 + colorCtr] = VGA_COLOR_TRANS(rgb63);
 				}
 			}
 		}


Commit: 5edc13bf78a9bc447c83359bd762b7157f0ca8fa
    https://github.com/scummvm/scummvm/commit/5edc13bf78a9bc447c83359bd762b7157f0ca8fa
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-10T09:18:53+02:00

Commit Message:
MADS: Implement scene 512

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes5.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index b406468..17debd5 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -215,7 +215,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 511:	// outside pleasure dome
 		return new Scene511(vm);
 	case 512:	// inside pleasure dome
-		return new DummyScene(vm);	// TODO
+		return new Scene512(vm);
 	case 513:	// outside mall
 		return new DummyScene(vm);	// TODO
 	case 515:	// overview
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index 109923a..9d3bbff 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -2041,5 +2041,299 @@ void Scene511::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene512::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x88);
+	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(0xFF);
+	_scene->addActiveVocab(0x366);
+}
+
+void Scene512::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('r', -1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RXMRC_9");
+	_globals._spriteIndexes[8] = _scene->_sprites.addSprites("*RXMRC_8");
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 1));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('x', 2));
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('x', 3));
+
+	if (_game._objects[OBJ_FISHING_ROD]._roomNumber == _scene->_currentSceneId) {
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 9, 0, 0, 0);
+		_fishingRodHotspotId = _scene->_dynamicHotspots.add(0x88, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(_fishingRodHotspotId, Common::Point(199, 101), FACING_NORTHEAST);
+	}
+
+	if (!_game._visitedScenes._sceneRevisited)
+		_globals[kRegisterOpen] = false;
+
+	_scene->_hotspots.activate(0xFF, false);
+	if (_game._difficulty == DIFFICULTY_EASY) {
+		if (_game._objects[OBJ_PADLOCK_KEY]._roomNumber == _scene->_currentSceneId) {
+			_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 10, 0, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 3);
+			_keyHotspotId = _scene->_dynamicHotspots.add(0xFF, VERB_WALKTO, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
+			_scene->_dynamicHotspots.setPosition(_keyHotspotId, Common::Point(218, 152), FACING_NORTHEAST);
+		}
+		if (_globals[kRegisterOpen]) {
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
+			_scene->_hotspots.activate(0xFF, false);
+		}
+	} else if (_globals[kRegisterOpen]) {
+		if (_game._objects[OBJ_PADLOCK_KEY]._roomNumber == _scene->_currentSceneId) {
+			_scene->_hotspots.activate(0xFF, true);
+			_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, -2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 3);
+		} else {
+			_scene->_hotspots.activate(0xFF, false);
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
+		}
+	} else
+		_scene->_hotspots.activate(0xFF, false);
+
+	if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(144, 152);
+		_game._player._facing = FACING_NORTHEAST;
+	}
+
+	sceneEntrySound();
+}
+
+void Scene512::actions() {
+	if (_action.isAction(0x32F, 0xF9))
+		_scene->_nextSceneId = 511;
+	else if (_action.isAction(VERB_TAKE, 0x88)) {
+		if (_game._trigger || !_game._objects.isInInventory(OBJ_FISHING_ROD)) {
+			switch (_game._trigger) {
+			case 0:
+				_game._player._stepEnabled   = false;
+				_game._player._visible     = false;
+				_globals._sequenceIndexes[2]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 5, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				break;
+
+			case 1:
+				_vm->_sound->command(9);
+				_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+				_scene->_dynamicHotspots.remove(_fishingRodHotspotId);
+				_game._objects.addToInventory(OBJ_FISHING_ROD);
+				_vm->_dialogs->showItem(OBJ_FISHING_ROD, 51217);
+				break;
+
+			case 2:
+				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[2]);
+				_game._player._visible   = true;
+				_game._player._stepEnabled = true;
+				break;
+
+			default:
+				break;
+			}
+		}
+	} else if (_action.isAction(VERB_OPEN, 0x377)) {
+		if (!_globals[kRegisterOpen]) {
+			switch (_game._trigger) {
+			case 0:
+				_vm->_dialogs->show(51236);
+				_game._player._stepEnabled   = false;
+				_game._player._facing = FACING_NORTH;
+				_scene->_sequences.addTimer(15, 1);
+				break;
+
+			case 1:
+				_game._player._visible     = false;
+				_globals._sequenceIndexes[8]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[8], false, 9, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 1, 3);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[8]);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				break;
+
+			case 2:
+				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[8]);
+				_game._player._visible   = true;
+				_scene->_sequences.addTimer(30, 3);
+				break;
+
+			case 3:
+				_game._player._facing = FACING_NORTHEAST;
+				if (!_game._objects.isInRoom(OBJ_PADLOCK_KEY) || (_game._difficulty == DIFFICULTY_EASY)) {
+					_globals._sequenceIndexes[3]  = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+					_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 4);
+				} else {
+					_globals._sequenceIndexes[4]  = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 12, 1, 0, 0);
+					_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 3);
+					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 5);
+				}
+				_vm->_sound->command(23);
+				break;
+
+			case 4:
+				_globals._sequenceIndexes[3]  = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
+				_scene->_sequences.addTimer(60, 6);
+				break;
+
+			case 5:
+				_globals._sequenceIndexes[5]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], false, 14, 0, 0, 0);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 3);
+				_scene->_hotspots.activate(0xFF, true);
+				_scene->_sequences.addTimer(60, 6);
+				break;
+
+			case 6:
+				_globals[kRegisterOpen]   = true;
+				_game._player._stepEnabled = true;
+				break;
+
+			default:
+				break;
+			}
+		} else
+			_vm->_dialogs->show(51239);
+	} else if (_action.isAction(VERB_CLOSE, 0x377) && _globals[kRegisterOpen]) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled   = false;
+			_game._player._visible     = false;
+			_globals._sequenceIndexes[2]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 10, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			break;
+		
+		case 1:
+			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[2]);
+			_game._player._visible   = true;
+			if (!_game._objects.isInRoom(OBJ_PADLOCK_KEY) || _game._difficulty == DIFFICULTY_EASY) {
+				_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+				_globals._sequenceIndexes[3]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			} else {
+				_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+				_globals._sequenceIndexes[4]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 12, 1, 0, 0);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 3);
+				_scene->_hotspots.activate(0xFF, false);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			}
+			break;
+		
+		case 2:
+			_globals[kRegisterOpen]   = false;
+			_game._player._stepEnabled = true;
+			break;
+		
+		default:
+			break;
+		}
+	} else if (_action.isAction(VERB_TAKE, 0xFF)) {
+		if (_game._trigger || !_game._objects.isInInventory(OBJ_PADLOCK_KEY)) {
+			switch (_game._trigger) {
+			case 0:
+				_game._player._stepEnabled   = false;
+				_game._player._visible     = false;
+
+				int endVal;
+				if (_game._player._playerPos == Common::Point(218, 152))
+					endVal = 3;
+				else
+					endVal = 2;
+
+				_globals._sequenceIndexes[2]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 10, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, endVal);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, endVal, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				break;
+			
+			case 1:
+				if (_game._player._playerPos == Common::Point(218, 152)) {
+					_scene->_sequences.remove(_globals._sequenceIndexes[6]);
+					_scene->_dynamicHotspots.remove(_keyHotspotId);
+				} else {
+					_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+					_globals._sequenceIndexes[3]   = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
+					_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
+					_scene->_hotspots.activate(0xFF, false);
+				}
+				_vm->_sound->command(9);
+				_game._objects.addToInventory(OBJ_PADLOCK_KEY);
+				_vm->_dialogs->showItem(OBJ_PADLOCK_KEY, 51226);
+				break;
+			
+			case 2:
+				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[2]);
+				_game._player._visible   = true;
+				_game._player._stepEnabled = true;
+				break;
+				
+			default:
+				break;
+			}
+		}
+	} else if (_action._lookFlag)
+		_vm->_dialogs->show(51225);
+	else if (_action.isAction(VERB_LOOK, 0xFF) && _game._objects.isInRoom(OBJ_PADLOCK_KEY))
+		_vm->_dialogs->show(51215);
+	else if (_action.isAction(VERB_LOOK, 0x88) && (_scene->_activeAnimation->getCurrentFrame() == 4))
+		_vm->_dialogs->show(51216);
+	else if (_action.isAction(VERB_LOOK, 0x354))
+		_vm->_dialogs->show(51218);
+	else if (_action.isAction(VERB_TAKE, 0x354))
+		_vm->_dialogs->show(51219);
+	else if (_action.isAction(VERB_LOOK, 0x349) || _action.isAction(0x103, 0x349))
+		_vm->_dialogs->show(51220);
+	else if (_action.isAction(VERB_LOOK, 0x160))
+		_vm->_dialogs->show(51221);
+	else if (_action.isAction(VERB_LOOK, 0x34E))
+		_vm->_dialogs->show(51222);
+	else if (_action.isAction(VERB_TAKE, 0x34E))
+		_vm->_dialogs->show(51223);
+	else if (_action.isAction(VERB_LOOK, 0xF9))
+		_vm->_dialogs->show(51224);
+	else if (_action.isAction(VERB_LOOK, 0x117))
+		_vm->_dialogs->show(51227);
+	else if (_action.isAction(VERB_TAKE, 0x117))
+		_vm->_dialogs->show(51228);
+	else if (_action.isAction(VERB_LOOK, 0x1BB)) {
+		if (_game._visitedScenes.exists(604))
+			_vm->_dialogs->show(51229);
+		else
+			_vm->_dialogs->show(51230);
+	} if (_action.isAction(VERB_LOOK, 0x47))
+		_vm->_dialogs->show(51231);
+	else if (_action.isAction(VERB_LOOK, 0x347))
+		_vm->_dialogs->show(51232);
+	else if (_action.isAction(VERB_TAKE, 0x347))
+		_vm->_dialogs->show(51233);
+	else if (_action.isAction(VERB_LOOK, 0x2F6))
+		_vm->_dialogs->show(51234);
+	else if (_action.isAction(VERB_LOOK, 0x29F))
+		_vm->_dialogs->show(51235);
+	else if (_action.isAction(VERB_LOOK, 0x486))
+		_vm->_dialogs->show(51237);
+	else if (_action.isAction(VERB_OPEN, 0x486))
+		_vm->_dialogs->show(51238);
+	else if (_action.isAction(VERB_LOOK, 0x377)) {
+		if (!_globals[kRegisterOpen])
+			_vm->_dialogs->show(51212);
+		else if (_game._objects.isInRoom(OBJ_PADLOCK_KEY))
+			_vm->_dialogs->show(51214);
+		else
+			_vm->_dialogs->show(51213);
+	} else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
index f46e8ee..0d1614f 100644
--- a/engines/mads/nebular/nebular_scenes5.h
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -198,6 +198,22 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene512: public Scene5xx{
+private:
+  int _fishingRodHotspotId;
+  int _keyHotspotId;
+
+public:
+	Scene512(MADSEngine *vm) : Scene5xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: be6cedef02abed65fc7e2643d3dc989afee0f488
    https://github.com/scummvm/scummvm/commit/be6cedef02abed65fc7e2643d3dc989afee0f488
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-10T10:46:48+02:00

Commit Message:
MADS: Implement scene 513

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes5.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 17debd5..7d91d7f 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -217,7 +217,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 512:	// inside pleasure dome
 		return new Scene512(vm);
 	case 513:	// outside mall
-		return new DummyScene(vm);	// TODO
+		return new Scene513(vm);
 	case 515:	// overview
 		return new DummyScene(vm);	// TODO
 	case 551:	// outside teleporter (with skeleton)
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index 9d3bbff..cd96e82 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -2335,5 +2335,228 @@ void Scene512::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene513::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x367);
+	_scene->addActiveVocab(0xD);
+}
+
+void Scene513::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', 0));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RXCD_9");
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXMRC_9");
+
+	_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);  
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2);
+
+	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2);  
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+
+	if ((_scene->_priorSceneId == 751) || (_scene->_priorSceneId == 701)) {
+		_game._player._playerPos = Common::Point(296, 147);
+		_game._player._facing = FACING_WEST; 
+		_game._player._stepEnabled = false;
+		_scene->_sequences.addTimer(15, 80);
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(63, 149);            
+		_game._player._facing = FACING_NORTHEAST;
+		_game._player._visible   = false;
+		_game._player._stepEnabled = false;
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+		_scene->loadAnimation(formAnimName('R', 1), 70);
+	} 
+
+	sceneEntrySound();
+
+	if (_scene->_roomChanged)
+		_game._objects.addToInventory(OBJ_SECURITY_CARD);
+
+	_game.loadQuoteSet(0x278, 0);
+}
+
+void Scene513::step() {
+	switch (_game._trigger) {
+	case 80:
+		_game._player._stepEnabled = false;
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+		_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2);
+		_vm->_sound->command(24);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 81);
+		break;      
+
+	case 81:
+		_game._player.walk(Common::Point(265, 152), FACING_WEST);
+		_scene->_sequences.addTimer(120, 82);
+		break;
+
+	case 82:
+		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2);
+		_vm->_sound->command(25);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 83);
+		break; 
+
+	case 83:
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);  
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2);
+		_game._player._stepEnabled = true;
+		break;
+
+	default:
+		break;
+	}
+
+	switch (_game._trigger) {
+	case 70:
+		_game._player._visible   = true;
+		_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
+		_scene->_sequences.addTimer(6, 71);
+		break;
+
+	case 71:
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 72);
+		break; 
+
+	case 72:
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2);  
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+		_game._player._stepEnabled = true;
+		break; 
+
+	default:
+		break;
+	}
+}
+
+void Scene513::actions() {
+	if (_action.isAction(0x36A, 0x324)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);   
+			_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			break;
+
+		case 1: {
+			int syncIdx = _globals._sequenceIndexes[1];
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[1], syncIdx);
+			_scene->_sequences.addTimer(6, 2);
+			}
+			break;
+
+		case 2:
+			_game._player._visible   = false;
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 10, 1, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+			break;
+
+		case 3: {
+			int syncIdx = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], syncIdx); 
+			_scene->_nextSceneId = 504;
+			}
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(VERB_PUT, 0xB3, 0x251) || _action.isAction(VERB_PUT, 0x305, 0x251)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled   = false;
+			_game._player._visible     = false;  
+			_globals._sequenceIndexes[4]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 7, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 1, 2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			break;
+
+		case 1:
+			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[4]);
+			_game._player._visible   = true;
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2);
+			_vm->_sound->command(24);
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x278));
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+
+		case 2:
+			_game._player.walk(Common::Point(296, 147), FACING_WEST); 
+			_scene->_sequences.addTimer(120, 3);
+			break;
+
+		case 3:
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2);
+			_vm->_sound->command(25);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 4);
+			break;
+
+		case 4:
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);  
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2);
+			_game._player._stepEnabled = true;
+			if (_globals[kCityFlooded])
+				_scene->_nextSceneId = 701;
+			else
+				_scene->_nextSceneId = 751;
+
+			break;
+
+		default:
+			break;
+		}
+	} else if ((_action._lookFlag) || _action.isAction(VERB_LOOK, 0x31E))
+		_vm->_dialogs->show(51318);
+	else if (_action.isAction(VERB_LOOK, 0x317))
+		_vm->_dialogs->show(51310);
+	else if (_action.isAction(VERB_LOOK, 0x367))
+		_vm->_dialogs->show(51311);
+	else if (_action.isAction(VERB_LOOK, 0x251))
+		_vm->_dialogs->show(51312);
+	else if (_action.isAction(VERB_LOOK, 0x355))
+		_vm->_dialogs->show(51313);
+	else if (_action.isAction(VERB_LOOK, 0x358))
+		_vm->_dialogs->show(51314);
+	else if (_action.isAction(VERB_LOOK, 0x323))
+		_vm->_dialogs->show(51315);
+	else if (_action.isAction(VERB_LOOK, 0x244))
+		_vm->_dialogs->show(51316);
+	else if (_action.isAction(VERB_LOOK, 0x360) || _action.isAction(0x1AD, 0x360))
+		_vm->_dialogs->show(51317);
+	else if (_action.isAction(VERB_OPEN, 0x367) || _action.isAction(VERB_OPEN, 0x317))
+		_vm->_dialogs->show(51319);
+	else if (_action.isAction(VERB_LOOK, 0x324))
+		_vm->_dialogs->show(51321);
+	else if (_action.isAction(VERB_LOOK, 0x357))
+		_vm->_dialogs->show(51322);
+	else if (_action.isAction(VERB_PUT, 0x131, 0x251))
+		_vm->_dialogs->show(51320);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
index 0d1614f..3bd8a20 100644
--- a/engines/mads/nebular/nebular_scenes5.h
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -214,6 +214,18 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene513: public Scene5xx{
+public:
+	Scene513(MADSEngine *vm) : Scene5xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 9b79267bd7adc1eeaec105d378b146a1402c607f
    https://github.com/scummvm/scummvm/commit/9b79267bd7adc1eeaec105d378b146a1402c607f
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-10T10:53:23+02:00

Commit Message:
MADS: Implement scene 515

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes5.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 7d91d7f..dd34107 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -219,7 +219,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 513:	// outside mall
 		return new Scene513(vm);
 	case 515:	// overview
-		return new DummyScene(vm);	// TODO
+		return new Scene515(vm);
 	case 551:	// outside teleporter (with skeleton)
 		return new DummyScene(vm);	// TODO
 
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index cd96e82..72f94f3 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -2558,5 +2558,27 @@ void Scene513::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene515::setup() {
+	_game._player._spritesPrefix = "";
+	setAAName();
+}
+
+void Scene515::enter() {
+	_game._player._visible   = false;
+	_game._player._stepEnabled = false;
+	_scene->_sequences.addTimer(30, 70);
+
+	sceneEntrySound();
+}
+
+void Scene515::step() {
+	if (_game._trigger == 70)
+		_scene->loadAnimation(formAnimName('A', -1), 71);
+	else if (_game._trigger == 71)
+		_scene->_nextSceneId = 508;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
index 3bd8a20..0fbc62f 100644
--- a/engines/mads/nebular/nebular_scenes5.h
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -226,6 +226,18 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene515: public Scene5xx{
+public:
+	Scene515(MADSEngine *vm) : Scene5xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions() {};
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 600a715661333565e8546dfcafabf5e1da95d340
    https://github.com/scummvm/scummvm/commit/600a715661333565e8546dfcafabf5e1da95d340
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-10T13:24:36+03:00

Commit Message:
MADS: Split verbs from nouns

Changed paths:
    engines/mads/dragonsphere/dragonsphere_scenes.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/phantom/phantom_scenes.h
    engines/mads/scene.cpp



diff --git a/engines/mads/dragonsphere/dragonsphere_scenes.h b/engines/mads/dragonsphere/dragonsphere_scenes.h
index 8ce1492..d6af608 100644
--- a/engines/mads/dragonsphere/dragonsphere_scenes.h
+++ b/engines/mads/dragonsphere/dragonsphere_scenes.h
@@ -35,7 +35,7 @@ namespace MADS {
 namespace Dragonsphere {
 
 enum Noun {
-	NOUN_LOOK_AT		= 0x0D1
+	VERB_LOOK_AT		= 0x0D1
 	// TODO
 };
 
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 86435c6..600c153 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -284,17 +284,17 @@ void GameNebular::doObjectAction() {
 	Dialogs &dialogs = *_vm->_dialogs;
 	int id;
 
-	if (action.isAction(NOUN_SMELL) && scene._currentSceneId > 103 && scene._currentSceneId < 111) {
+	if (action.isAction(VERB_SMELL) && scene._currentSceneId > 103 && scene._currentSceneId < 111) {
 		dialogs.show(440);
-	} else if (action.isAction(NOUN_EAT) && scene._currentSceneId > 103 && scene._currentSceneId < 111) {
+	} else if (action.isAction(VERB_EAT) && scene._currentSceneId > 103 && scene._currentSceneId < 111) {
 		dialogs.show(441);
-	} else if (action.isAction(NOUN_SMELL, NOUN_BURGER)) {
+	} else if (action.isAction(VERB_SMELL, NOUN_BURGER)) {
 		dialogs.show(442);
-	} else if (action.isAction(NOUN_EAT, NOUN_BURGER)) {
+	} else if (action.isAction(VERB_EAT, NOUN_BURGER)) {
 		dialogs.show(443);
-	} else if (action.isAction(NOUN_SMELL, NOUN_STUFFED_FISH)) {
+	} else if (action.isAction(VERB_SMELL, NOUN_STUFFED_FISH)) {
 		dialogs.show(444);
-	} else if (action.isAction(NOUN_EAT, NOUN_STUFFED_FISH)) {
+	} else if (action.isAction(VERB_EAT, NOUN_STUFFED_FISH)) {
 		dialogs.show(445);
 	} else if (action.isAction(401, 289)) {
 		dialogs.show(scene._currentSceneId > 103 && scene._currentSceneId < 111 ? 446 : 447);
@@ -304,7 +304,7 @@ void GameNebular::doObjectAction() {
 		dialogs.show(449);
 	} else if (action.isAction(203, 276)) {
 		dialogs.show(450);
-	} else if (action.isAction(NOUN_EAT, 378)) {
+	} else if (action.isAction(VERB_EAT, 378)) {
 		_objects.setRoom(OBJ_TWINKIFRUIT, PLAYER_INVENTORY);
 		dialogs.show(451);
 	} else if (action.isAction(153, 378)) {
@@ -342,13 +342,13 @@ void GameNebular::doObjectAction() {
 		dialogs.show(466);
 	} 	else if (action.isAction(530, 288)) {
 		dialogs.show(467);
-	} else if (action.isAction(NOUN_EAT, 74)) {
+	} else if (action.isAction(VERB_EAT, 74)) {
 		dialogs.show(469);
 	} else if (action.isAction(50, 381)) {
 		dialogs.show(471);
 	} else if (action.isAction(307, 950)) {
 		dialogs.show(472);
-	} else if (action.isAction(NOUN_READ, NOUN_LOG)) {
+	} else if (action.isAction(VERB_READ, NOUN_LOG)) {
 		dialogs.show(473);
 	} else if (action.isAction(1189, 43)) {
 		dialogs.show(474);
@@ -371,12 +371,12 @@ void GameNebular::doObjectAction() {
 		dialogs.show(434);
 	} else if (action.isAction(1196)) {
 		dialogs.show(479);
-	} else if ((action.isAction(287) || action.isAction(NOUN_LOOK_AT) || action.isAction(VERB_LOOK)) &&
+	} else if ((action.isAction(287) || action.isAction(VERB_LOOK_AT) || action.isAction(VERB_LOOK)) &&
 			action.isAction(936) && _objects.isInInventory(OBJ_NOTE)) {
 		_objects.setRoom(OBJ_NOTE, PLAYER_INVENTORY);
 		_objects.addToInventory(OBJ_COMBINATION);
 		dialogs.showItem(OBJ_COMBINATION, 851);
-	} else if ((action.isAction(VERB_LOOK) || action.isAction(NOUN_READ)) &&
+	} else if ((action.isAction(VERB_LOOK) || action.isAction(VERB_READ)) &&
 			((id = _objects.getIdFromDesc(action._activeAction._objectNameId)) > 0 ||
 			(action._activeAction._indirectObjectId > 0 &&
 			(id = _objects.getIdFromDesc(action._activeAction._indirectObjectId))))) {
@@ -574,13 +574,13 @@ void GameNebular::unhandledAction() {
 		_vm->_dialogs->show(0x2A);
 	else if (action.isAction(0x6C))
 		_vm->_dialogs->show(0x1B3);
-	else if ((action.isAction(NOUN_EAT, NOUN_DEAD_FISH) || action.isAction(NOUN_EAT, NOUN_STUFFED_FISH)) && _vm->_game->_objects.isInInventory(_vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId)))
+	else if ((action.isAction(VERB_EAT, NOUN_DEAD_FISH) || action.isAction(VERB_EAT, NOUN_STUFFED_FISH)) && _vm->_game->_objects.isInInventory(_vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId)))
 		_vm->_dialogs->show(0xC);
-	else if ((action.isAction(NOUN_SMELL, NOUN_DEAD_FISH) || action.isAction(NOUN_SMELL, NOUN_STUFFED_FISH)) && _vm->_game->_objects.isInInventory(_vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId)))
+	else if ((action.isAction(VERB_SMELL, NOUN_DEAD_FISH) || action.isAction(VERB_SMELL, NOUN_STUFFED_FISH)) && _vm->_game->_objects.isInInventory(_vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId)))
 		_vm->_dialogs->show(0xD);
-	else if (action.isAction(NOUN_EAT, NOUN_CHICKEN) && _vm->_game->_objects.isInInventory(OBJ_CHICKEN))
+	else if (action.isAction(VERB_EAT, NOUN_CHICKEN) && _vm->_game->_objects.isInInventory(OBJ_CHICKEN))
 		_vm->_dialogs->show(0x390);
-	else if ((action.isAction(NOUN_SHOOT) || action.isAction(NOUN_HOSE_DOWN)) && action.isAction(NOUN_BLOWGUN)) {
+	else if ((action.isAction(VERB_SHOOT) || action.isAction(VERB_HOSE_DOWN)) && action.isAction(NOUN_BLOWGUN)) {
 		if ((_scene._currentSceneId >= 104) && (_scene._currentSceneId <= 111))
 			_vm->_dialogs->show(0x26);
 		else if (action.isAction(0x10D))
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 2f9dff7..3534613 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -38,6 +38,32 @@ enum {
 	SEX_MALE = 0, SEX_UNKNOWN = 1, SEX_FEMALE = 2
 };
 
+enum Verb {
+	VERB_CLIMB_DOWN     = 0x04E,
+	VERB_EAT			= 0x075,
+	VERB_EXAMINE		= 0x07D,
+	VERB_HOSE_DOWN		= 0x0A6,
+	VERB_IGNITE			= 0x0B4,
+	VERB_INFLATE		= 0x0B5,
+	VERB_INSERT			= 0x0B6,
+	VERB_INSPECT		= 0x0B7,
+	VERB_HURL			= 0x0A9,
+	VERB_LOOK_AT		= 0x0D1,
+	VERB_LOOK_IN		= 0x0D2,
+	VERB_LOOK_THROUGH	= 0x0D3,
+	VERB_PEER_THROUGH	= 0x103,
+	VERB_READ			= 0x11F,
+	VERB_SHOOT          = 0x13A,
+	VERB_SIT_IN         = 0x13F,
+	VERB_SMELL			= 0x147,
+	VERB_WALK_THROUGH   = 0x18B,
+	VERB_WALK_TOWARDS   = 0x18C,
+	VERB_WALK_DOWN      = 0x1AD,
+	VERB_CLIMB_INTO     = 0x2F7,
+	VERB_STEP_INTO      = 0x2F9,
+	VERB_WALK_ALONG     = 0x312,
+};
+
 enum Noun {
 	NOUN_BIG_LEAVES     = 0x23,
 	NOUN_BLOWGUN        = 0x29,
@@ -51,50 +77,34 @@ enum Noun {
 	NOUN_CHICKEN_BOMB   = 0x4A,
 	NOUN_DEAD_FISH		= 0x65,
 	NOUN_DOOR			= 0x6E,
-	NOUN_EAT			= 0x75,
-	NOUN_EXAMINE		= 0x7D,
+	NOUN_FISHING_LINE	= 0x87,
 	NOUN_FRONT_WINDOW	= 0x8E,
 	NOUN_FUZZY_DICE		= 0x91,
-	NOUN_HOSE_DOWN		= 0x0A6,
 	NOUN_HOTPANTS		= 0x0A7,
 	NOUN_HULL			= 0x0A8,
-	NOUN_HURL			= 0x0A9,
 	NOUN_ID_CARD        = 0x0B3,
-	NOUN_IGNITE			= 0x0B4,
-	NOUN_INFLATE		= 0x0B5,
-	NOUN_INSERT			= 0x0B6,
-	NOUN_INSPECT		= 0x0B7,
 	NOUN_JUNGLE			= 0x0B8,
 	NOUN_LADDER         = 0x0C7,
 	NOUN_LIFE_SUPPORT_SECTION  = 0x0CC,
 	NOUN_LOG			= 0x0D0,
-	NOUN_LOOK_AT		= 0x0D1,
-	NOUN_LOOK_IN		= 0x0D2,
-	NOUN_LOOK_THROUGH	= 0x0D3,
 	NOUN_MONKEY			= 0x0E3,
 	NOUN_OUTER_HULL		= 0x0F8,
 	NOUN_OUTSIDE		= 0x0F9,
-	NOUN_PEER_THROUGH	= 0x103,
 	NOUN_PIRANHA        = 0x10D,
 	NOUN_PLANT_STALK	= 0x10F,
-	NOUN_READ			= 0x11F,
 	NOUN_REFRIDGERATOR	= 0x122,
 	NOUN_ROBO_KITCHEN	= 0x127,
 	NOUN_ROCK           = 0x128,
 	NOUN_SHIELD_ACCESS_PANEL  = 0x135,
 	NOUN_SHIELD_MODULATOR	= 0x137,
-	NOUN_SHOOT			= 0x13A,
-	NOUN_SIT_IN			= 0x13F,
 	NOUN_SKULL          = 0x140,
 	NOUN_TELEPORTER     = 0x16C,
 	NOUN_BROKEN_LADDER  = 0x1C9,
-	NOUN_SMELL			= 0x147,
 	NOUN_STUFFED_FISH	= 0x157,
 	NOUN_15F            = 0x15F,
 	NOUN_TIMEBOMB       = 0x171,
 	NOUN_TWINKIFRUIT    = 0x17A,
 	NOUN_VIEW_SCREEN    = 0x180,
-	NOUN_WALK_THROUGH	= 0x18B,
 	NOUN_DEEP_PIT       = 0x19E,
 	NOUN_HUGE_LEGS      = 0x1A8,
 	NOUN_LEAF_COVERED_PIT  = 0x1A9,
@@ -105,6 +115,7 @@ enum Noun {
 	NOUN_ALCOHOL        = 0x310,
 	NOUN_SUBMERGED_CITY = 0x313,
 	NOUN_LASER_BEAM     = 0x343,
+	NOUN_BOAT           = 0x345,
 	NOUN_CEMENT_BLOCK   = 0x38E,
 	NOUN_CITY           = 0x38F,
 	NOUN_DOLLOP			= 0x3AC,
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index c202fe1..f317b28 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -1346,7 +1346,7 @@ void Scene103::step() {
 void Scene103::actions() {
 	if (_action._savedFields._lookFlag) {
 		_vm->_dialogs->show(10322);
-	} else if (_action.isAction(NOUN_WALK_THROUGH, NOUN_DOOR)) {
+	} else if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR)) {
 		switch (_vm->_game->_trigger) {
 		case 0:
 			_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 1);
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 2bb24be..e4c09fa 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -30,15 +30,6 @@ namespace MADS {
 
 namespace Nebular {
 
-// Scene 2xx verbs
-enum {
-	VERB_WALK_THROUGH = 0x18B,
-	VERB_WALK_TOWARDS = 0x18C,
-	VERB_WALK_DOWN = 0x1AD,
-
-	VERB_CLIMB_DOWN = 0x4E
-};
-
 void Scene2xx::setAAName() {
 	int idx = (_scene->_nextSceneId == 216) ? 4 : 2;
 	_game._aaName = Resources::formatAAName(idx);
@@ -3086,14 +3077,14 @@ void Scene209::step() {
 		case 234:
 			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 			_scene->_kernelMessages.reset();
-			if (_action.isAction(NOUN_HOSE_DOWN, NOUN_BLOWGUN, NOUN_MONKEY)) {
+			if (_action.isAction(VERB_HOSE_DOWN, NOUN_BLOWGUN, NOUN_MONKEY)) {
 				_globals._sequenceIndexes[2] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[2], false, 7, 16, 0, 0);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 11, 12);
 				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 12, 239);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 235);
-			} else if (_action.isAction(NOUN_SHOOT, NOUN_BLOWGUN, NOUN_MONKEY)) {
+			} else if (_action.isAction(VERB_SHOOT, NOUN_BLOWGUN, NOUN_MONKEY)) {
 				_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 11, 12);
 				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
@@ -3169,7 +3160,7 @@ void Scene209::preActions() {
 		_game._player._walkOffScreenSceneId = 208;
 
 	if (_globals[kMonkeyStatus] == 1) {
-		if ((_action.isAction(NOUN_SHOOT) || _action.isAction(NOUN_HOSE_DOWN)) && _action.isTarget(NOUN_MONKEY)
+		if ((_action.isAction(VERB_SHOOT) || _action.isAction(VERB_HOSE_DOWN)) && _action.isTarget(NOUN_MONKEY)
 			&& _action.isObject(NOUN_BLOWGUN) && _game._objects.isInInventory(OBJ_BLOWGUN) && _game._objects.isInInventory(OBJ_POISON_DARTS)) {
 			_game._player._prepareWalkPos = Common::Point(111, 129);
 			_game._player._prepareWalkFacing = FACING_NORTHEAST;
@@ -3306,9 +3297,9 @@ void Scene209::actions() {
 	}
 
 	if (_globals[kMonkeyStatus] == 1) {
-		if ((_action.isAction(NOUN_SHOOT) || _action.isAction(NOUN_HOSE_DOWN)) && _action.isAction(NOUN_MONKEY)
+		if ((_action.isAction(VERB_SHOOT) || _action.isAction(VERB_HOSE_DOWN)) && _action.isAction(NOUN_MONKEY)
 			&& _action.isAction(NOUN_BLOWGUN) && _game._objects.isInInventory(OBJ_BLOWGUN) && _game._objects.isInInventory(OBJ_POISON_DARTS)) {
-			if (_action.isAction(NOUN_SHOOT, NOUN_BLOWGUN, NOUN_MONKEY) && !_startShootingInTimerFl) {
+			if (_action.isAction(VERB_SHOOT, NOUN_BLOWGUN, NOUN_MONKEY) && !_startShootingInTimerFl) {
 				_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 				_scene->_sequences.addTimer(1, 231);
 				_startShootingInTimerFl = true;
@@ -3318,7 +3309,7 @@ void Scene209::actions() {
 				return;
 			}
 
-			if (_action.isAction(NOUN_HOSE_DOWN, NOUN_BLOWGUN, NOUN_MONKEY) && !_startShootingInTimerFl) {
+			if (_action.isAction(VERB_HOSE_DOWN, NOUN_BLOWGUN, NOUN_MONKEY) && !_startShootingInTimerFl) {
 				_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 				_scene->_sequences.addTimer(1, 228);
 				_game._player._stepEnabled = false;
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 476b132..3e68471 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -30,13 +30,6 @@ namespace MADS {
 
 namespace Nebular {
 
-// Scene 7xx verbs
-enum {
-	VERB_LOOK_AT = 0xD1,
-	VERB_WALK_ALONG = 0x312,
-	VERB_STEP_INTO = 0x2F9
-};
-
 void Scene7xx::setAAName() {
 	_game._aaName = Resources::formatAAName(5);
 }
diff --git a/engines/mads/phantom/phantom_scenes.h b/engines/mads/phantom/phantom_scenes.h
index 986934f..d93ccfc 100644
--- a/engines/mads/phantom/phantom_scenes.h
+++ b/engines/mads/phantom/phantom_scenes.h
@@ -35,7 +35,7 @@ namespace MADS {
 namespace Phantom {
 
 enum Noun {
-	NOUN_LOOK_AT		= 0x0D1
+	VERB_LOOK_AT		= 0x0D1
 	// TODO
 };
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 32956e6..601acc5 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -369,7 +369,7 @@ void Scene::doFrame() {
 	if (_action._selectedAction && player._stepEnabled && !player._needToWalk &&
 			!_vm->_game->_trigger && !player._trigger) {
 		_action.startAction();
-		if (_action._activeAction._verbId == Nebular::NOUN_LOOK_AT) {
+		if (_action._activeAction._verbId == Nebular::VERB_LOOK_AT) {
 			_action._activeAction._verbId = VERB_LOOK;
 			_action._savedFields._command = false;
 		}


Commit: 5ae5a1aa58987230a75166fdd71ad8cb608ff6b3
    https://github.com/scummvm/scummvm/commit/5ae5a1aa58987230a75166fdd71ad8cb608ff6b3
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-10T13:25:11+03:00

Commit Message:
MADS: Start implementing scene 701

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes7.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index dd34107..a77c123 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -251,7 +251,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 
 	// Scene group #7 (submerged men's city / upper floor)
 	case 701:	// outside elevator (after city is submerged)
-		return new DummyScene(vm);	// TODO
+		return new Scene701(vm);
 	case 702:	// outside teleporter (after city is submerged)
 		return new Scene702(vm);
 	case 703:	// water
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 3e68471..cb9880e 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -89,6 +89,93 @@ void Scene7xx::sceneEntrySound() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene701::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+
+	_scene->addActiveVocab(NOUN_BOAT);
+	_scene->addActiveVocab(VERB_CLIMB_INTO);
+	_scene->addActiveVocab(NOUN_FISHING_LINE);
+	_scene->addActiveVocab(VERB_WALKTO);
+}
+
+void Scene701::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('b', 5));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('b', 0));
+	//_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('b', 1));	// FIXME: Invalid resource?
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RM202A1");
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('b', 8));
+
+	if (_scene->_roomChanged) {
+		_game._objects.addToInventory(OBJ_BINOCULARS);
+		_game._objects.addToInventory(OBJ_TWINKIFRUIT);
+		_game._objects.addToInventory(OBJ_BOMB);
+		_game._objects.addToInventory(OBJ_CHICKEN);
+		_game._objects.addToInventory(OBJ_BONES);
+
+		_globals[kCityFlooded] = true;
+		_globals[kLineStatus] = LINE_TIED;
+		_globals[kBoatRaised] = false;
+	}
+
+	if (_globals[kBoatStatus] == BOAT_UNFLOODED) {
+		if (_globals[kBoatRaised]) {
+			_globals[kBoatStatus] = BOAT_GONE;
+		} else {
+			if (_globals[kLineStatus] == LINE_TIED) {
+				_globals[kBoatStatus] = BOAT_TIED_FLOATING;
+			} else {
+				if (_game._difficulty == DIFFICULTY_HARD) {
+					_globals[kBoatStatus] = BOAT_ADRIFT;
+				} else {
+					_globals[kBoatStatus] = BOAT_TIED;
+				}
+			}
+		}
+	}
+
+	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
+
+	int boatStatus = (_scene->_priorSceneId == 703) ? BOAT_GONE : _globals[kBoatStatus];
+
+	switch (boatStatus) {
+	case BOAT_TIED_FLOATING:
+		_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 20, 0, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 10);
+		break;
+	case BOAT_ADRIFT:
+		_globals._sequenceIndexes[6] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[6], false, 20, 0, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 10);
+		break;
+	case BOAT_TIED:
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 9);
+		break;
+	case BOAT_GONE:
+		_scene->_hotspots.activate(NOUN_BOAT, false);
+		break;
+	default:
+		break;
+	}
+
+	// TODO: Line status
+
+	// TODO
+}
+
+void Scene701::preActions() {
+	// TODO
+}
+
+void Scene701::actions() {
+	// TODO
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene702::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
diff --git a/engines/mads/nebular/nebular_scenes7.h b/engines/mads/nebular/nebular_scenes7.h
index ae5b822..cc82206 100644
--- a/engines/mads/nebular/nebular_scenes7.h
+++ b/engines/mads/nebular/nebular_scenes7.h
@@ -50,6 +50,16 @@ public:
 	Scene7xx(MADSEngine *vm) : NebularScene(vm) {}
 };
 
+class Scene701: public Scene7xx {
+public:
+	Scene701(MADSEngine *vm) : Scene7xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void preActions();
+	virtual void actions();
+};
+
 class Scene702: public Scene7xx {
 public:
 	Scene702(MADSEngine *vm) : Scene7xx(vm) {}


Commit: 4f4106eff4127ee1dd5eb06e514603fe659af143
    https://github.com/scummvm/scummvm/commit/4f4106eff4127ee1dd5eb06e514603fe659af143
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-10T15:18:06+02:00

Commit Message:
MADS: Implement scene 511

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes5.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index a77c123..19ccc62 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -221,7 +221,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 515:	// overview
 		return new Scene515(vm);
 	case 551:	// outside teleporter (with skeleton)
-		return new DummyScene(vm);	// TODO
+		return new Scene551(vm);
 
 	// Scene group #6 (men's city, upper floor)
 	case 601:	// outside Bruce's house
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index 72f94f3..11af55b 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -1116,7 +1116,7 @@ void Scene506::enter() {
 	_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -1);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 5);
 	_firstDoorFl = true;
-	_actionFl            = false;
+	_actionFl = false;
 
 	if (_scene->_priorSceneId == 508) {
 		_game._player._playerPos = Common::Point(16, 111);
@@ -1131,7 +1131,7 @@ void Scene506::enter() {
 	} else if (_scene->_priorSceneId != -2) {
 		_game._player._playerPos = Common::Point(138, 116);
 		_game._player._facing = FACING_NORTHEAST;
-		_game._player._visible   = false;
+		_game._player._visible = false;
 		_game._player._stepEnabled = false;
 		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
 		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
@@ -1751,7 +1751,7 @@ void Scene511::enter() {
 		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 1, 1, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 5);
 
-		_globals._sequenceIndexes[5]  = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
+		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 4);
 
 		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 1);
@@ -1769,7 +1769,7 @@ void Scene511::enter() {
 		frame = -2;
 
 	if (_globals[kLineStatus] == 2 || _globals[kLineStatus] == 3) {
-		_globals._spriteIndexes[7]  = _scene->_sprites.addSprites(formAnimName('b', 4));
+		_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('b', 4));
 		_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, frame);
 		int idx = _scene->_dynamicHotspots.add(0x87, VERB_WALKTO, _globals._sequenceIndexes[7], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(26, 153), FACING_NORTHEAST);
@@ -1778,8 +1778,8 @@ void Scene511::enter() {
 			_scene->changeVariant(2);
 	}
 
-	_lineFrame      = -1;
-	_lineMoving     = false;
+	_lineFrame = -1;
+	_lineMoving = false;
 
 	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
@@ -1790,7 +1790,7 @@ void Scene511::enter() {
 	} else if (_scene->_priorSceneId != -2) {
 		_game._player._playerPos = Common::Point(55, 152);
 		_game._player._facing = FACING_NORTHWEST;
-		_game._player._visible   = false;
+		_game._player._visible = false;
 		_game._player._stepEnabled = false;
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
@@ -1798,8 +1798,8 @@ void Scene511::enter() {
 		_scene->loadAnimation(formAnimName('R', 1), 70);
 	} else if (_handingLine) {
 		_game._player._visible = false;
-		_lineAnimationMode   = 1;
-		_lineAnimationPosition    = 1;
+		_lineAnimationMode = 1;
+		_lineAnimationPosition = 1;
 		_scene->loadAnimation(formAnimName('R', -1));
 		_lineFrame = 2;
 	}
@@ -1807,22 +1807,22 @@ void Scene511::enter() {
 }
 
 void Scene511::step() {
-	if ((_lineAnimationMode    == 1) && _scene->_activeAnimation) {
+	if ((_lineAnimationMode == 1) && _scene->_activeAnimation) {
 		if (_lineFrame != _scene->_activeAnimation->getCurrentFrame()) {
-			_lineFrame         = _scene->_activeAnimation->getCurrentFrame();
-			int resetFrame               = -1;
+			_lineFrame = _scene->_activeAnimation->getCurrentFrame();
+			int resetFrame = -1;
 
-			if ((_lineAnimationPosition == 2) && (_lineFrame  == 14))
-				_lineMoving   = false;
+			if ((_lineAnimationPosition == 2) && (_lineFrame == 14))
+				_lineMoving = false;
 
 			if (_lineAnimationPosition == 1) {
-				if (_lineFrame  == 3) {
-					_lineMoving    = false;
-					resetFrame             = 2;
+				if (_lineFrame == 3) {
+					_lineMoving = false;
+					resetFrame = 2;
 				}
 
 				if (_handingLine)
-					resetFrame             = 2;
+					resetFrame = 2;
 			}
 
 			if ((resetFrame >= 0) && (resetFrame != _scene->_activeAnimation->getCurrentFrame())) {
@@ -1834,7 +1834,7 @@ void Scene511::step() {
 
 	switch (_game._trigger) {
 	case 70:
-		_game._player._visible   = true;
+		_game._player._visible = true;
 		_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
 		_scene->_sequences.addTimer(6, 71);
 		break;
@@ -1869,13 +1869,13 @@ void Scene511::preActions() {
 			_game._player._readyToWalk = false;
 			_game._player._stepEnabled = false;
 			_scene->freeAnimation ();
-			_lineAnimationMode   = 2;
+			_lineAnimationMode = 2;
 			_scene->loadAnimation(formAnimName('R',2), 1);
 		} else if (_game._trigger == 1) {
-			_game._player._visible   = true;
+			_game._player._visible = true;
 			_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
 			_game._objects.setRoom(OBJ_FISHING_LINE, 1);
-			_handingLine     = false;
+			_handingLine = false;
 			_game._player._stepEnabled = true;
 			_game._player._readyToWalk = true;
 		}
@@ -1905,7 +1905,7 @@ void Scene511::actions() {
 			break;
 
 		case 2:
-			_game._player._visible   = false;
+			_game._player._visible = false;
 			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 8, 1, 0, 0);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
@@ -1929,10 +1929,10 @@ void Scene511::actions() {
 				if (_globals[kLineStatus] != 3) {
 					if (_game._trigger == 0) {
 						_game._player._stepEnabled = false;
-						_game._player._visible   = false;
-						_lineAnimationMode   = 1;
-						_lineAnimationPosition    = 1;
-						_lineMoving      = true;
+						_game._player._visible = false;
+						_lineAnimationMode = 1;
+						_lineAnimationPosition = 1;
+						_lineMoving = true;
 						_scene->loadAnimation(formAnimName('R', -1), 0);
 						_scene->_sequences.addTimer(1, 1);
 					} else if (_game._trigger == 1) {
@@ -1940,8 +1940,8 @@ void Scene511::actions() {
 							_scene->_sequences.addTimer(1, 1);
 						} else {
 							_game._objects.addToInventory(OBJ_FISHING_LINE);
-							_lineMoving      = true;
-							_handingLine     = true;
+							_lineMoving = true;
+							_handingLine = true;
 							_game._player._stepEnabled = true;
 						}
 					}
@@ -1962,23 +1962,23 @@ void Scene511::actions() {
 				if (_game._trigger == 0) {
 					_game._player._stepEnabled = false;
 					_scene->_sequences.remove(_globals._sequenceIndexes[7]);
-					_lineMoving      = true;
-					_lineAnimationPosition    = 2;
+					_lineMoving = true;
+					_lineAnimationPosition = 2;
 					_scene->_sequences.addTimer(1, 1);
 				} else if (_game._trigger == 1) {
 					if (_lineMoving)
 						_scene->_sequences.addTimer(1, 1);
 					else {
-						_game._player._visible   = true;
+						_game._player._visible = true;
 						_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
 						_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, -2);
 						_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 4);
 						int idx = _scene->_dynamicHotspots.add(0x87, VERB_WALKTO, _globals._sequenceIndexes[7], Common::Rect(0, 0, 0, 0));
 						_scene->_dynamicHotspots.setPosition(idx, Common::Point(26, 153), FACING_NORTHEAST);
 						_game._objects.removeFromInventory(OBJ_FISHING_LINE, 1);
-						_handingLine     = false;
-						_lineMoving      = true;
-						_globals[kLineStatus]     = 3;
+						_handingLine = false;
+						_lineMoving = true;
+						_globals[kLineStatus] = 3;
 						_game._player._stepEnabled = true;
 					}
 				}
@@ -2007,7 +2007,7 @@ void Scene511::actions() {
 		_vm->_dialogs->show(51118);
 	else if (_action.isAction(0x17B, 0xFF, 0x37C) || _action.isAction(0x17B, 0x6F, 0x37C))
 		_vm->_dialogs->show(51119);
-	else if (  (_action.isAction(VERB_PUT) || _action.isAction(VERB_THROW))
+	else if ( (_action.isAction(VERB_PUT) || _action.isAction(VERB_THROW))
 		 && (_action.isAction(0x171) || _action.isAction(0x2A) || _action.isAction(0x2B))
 		 && _action.isAction(0x37C))
 		_vm->_dialogs->show(51120);
@@ -2109,9 +2109,9 @@ void Scene512::actions() {
 		if (_game._trigger || !_game._objects.isInInventory(OBJ_FISHING_ROD)) {
 			switch (_game._trigger) {
 			case 0:
-				_game._player._stepEnabled   = false;
-				_game._player._visible     = false;
-				_globals._sequenceIndexes[2]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
 				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 5, 1);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
@@ -2127,7 +2127,7 @@ void Scene512::actions() {
 
 			case 2:
 				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[2]);
-				_game._player._visible   = true;
+				_game._player._visible = true;
 				_game._player._stepEnabled = true;
 				break;
 
@@ -2140,14 +2140,14 @@ void Scene512::actions() {
 			switch (_game._trigger) {
 			case 0:
 				_vm->_dialogs->show(51236);
-				_game._player._stepEnabled   = false;
+				_game._player._stepEnabled = false;
 				_game._player._facing = FACING_NORTH;
 				_scene->_sequences.addTimer(15, 1);
 				break;
 
 			case 1:
-				_game._player._visible     = false;
-				_globals._sequenceIndexes[8]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[8], false, 9, 1, 0, 0);
+				_game._player._visible = false;
+				_globals._sequenceIndexes[8] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[8], false, 9, 1, 0, 0);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 1, 3);
 				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[8]);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
@@ -2155,18 +2155,18 @@ void Scene512::actions() {
 
 			case 2:
 				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[8]);
-				_game._player._visible   = true;
+				_game._player._visible = true;
 				_scene->_sequences.addTimer(30, 3);
 				break;
 
 			case 3:
 				_game._player._facing = FACING_NORTHEAST;
 				if (!_game._objects.isInRoom(OBJ_PADLOCK_KEY) || (_game._difficulty == DIFFICULTY_EASY)) {
-					_globals._sequenceIndexes[3]  = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+					_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
 					_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
 					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 4);
 				} else {
-					_globals._sequenceIndexes[4]  = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 12, 1, 0, 0);
+					_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 12, 1, 0, 0);
 					_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 3);
 					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 5);
 				}
@@ -2174,20 +2174,20 @@ void Scene512::actions() {
 				break;
 
 			case 4:
-				_globals._sequenceIndexes[3]  = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
+				_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
 				_scene->_sequences.addTimer(60, 6);
 				break;
 
 			case 5:
-				_globals._sequenceIndexes[5]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], false, 14, 0, 0, 0);
+				_globals._sequenceIndexes[5] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], false, 14, 0, 0, 0);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 3);
 				_scene->_hotspots.activate(0xFF, true);
 				_scene->_sequences.addTimer(60, 6);
 				break;
 
 			case 6:
-				_globals[kRegisterOpen]   = true;
+				_globals[kRegisterOpen] = true;
 				_game._player._stepEnabled = true;
 				break;
 
@@ -2199,9 +2199,9 @@ void Scene512::actions() {
 	} else if (_action.isAction(VERB_CLOSE, 0x377) && _globals[kRegisterOpen]) {
 		switch (_game._trigger) {
 		case 0:
-			_game._player._stepEnabled   = false;
-			_game._player._visible     = false;
-			_globals._sequenceIndexes[2]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 10, 1, 0, 0);
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 10, 1, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 2);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
@@ -2209,15 +2209,15 @@ void Scene512::actions() {
 		
 		case 1:
 			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[2]);
-			_game._player._visible   = true;
+			_game._player._visible = true;
 			if (!_game._objects.isInRoom(OBJ_PADLOCK_KEY) || _game._difficulty == DIFFICULTY_EASY) {
 				_scene->_sequences.remove(_globals._sequenceIndexes[3]);
-				_globals._sequenceIndexes[3]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
+				_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 12, 1, 0, 0);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 			} else {
 				_scene->_sequences.remove(_globals._sequenceIndexes[5]);
-				_globals._sequenceIndexes[4]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 12, 1, 0, 0);
+				_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 12, 1, 0, 0);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 3);
 				_scene->_hotspots.activate(0xFF, false);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
@@ -2225,7 +2225,7 @@ void Scene512::actions() {
 			break;
 		
 		case 2:
-			_globals[kRegisterOpen]   = false;
+			_globals[kRegisterOpen] = false;
 			_game._player._stepEnabled = true;
 			break;
 		
@@ -2236,8 +2236,8 @@ void Scene512::actions() {
 		if (_game._trigger || !_game._objects.isInInventory(OBJ_PADLOCK_KEY)) {
 			switch (_game._trigger) {
 			case 0:
-				_game._player._stepEnabled   = false;
-				_game._player._visible     = false;
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
 
 				int endVal;
 				if (_game._player._playerPos == Common::Point(218, 152))
@@ -2245,7 +2245,7 @@ void Scene512::actions() {
 				else
 					endVal = 2;
 
-				_globals._sequenceIndexes[2]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 10, 1, 0, 0);
+				_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 10, 1, 0, 0);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, endVal);
 				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, endVal, 1);
@@ -2258,7 +2258,7 @@ void Scene512::actions() {
 					_scene->_dynamicHotspots.remove(_keyHotspotId);
 				} else {
 					_scene->_sequences.remove(_globals._sequenceIndexes[5]);
-					_globals._sequenceIndexes[3]   = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
+					_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
 					_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
 					_scene->_hotspots.activate(0xFF, false);
 				}
@@ -2269,7 +2269,7 @@ void Scene512::actions() {
 			
 			case 2:
 				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[2]);
-				_game._player._visible   = true;
+				_game._player._visible = true;
 				_game._player._stepEnabled = true;
 				break;
 				
@@ -2348,10 +2348,10 @@ void Scene513::enter() {
 	_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RXCD_9");
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXMRC_9");
 
-	_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);  
+	_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2); 
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2);
 
-	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2);  
+	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2); 
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 
 	if ((_scene->_priorSceneId == 751) || (_scene->_priorSceneId == 701)) {
@@ -2360,9 +2360,9 @@ void Scene513::enter() {
 		_game._player._stepEnabled = false;
 		_scene->_sequences.addTimer(15, 80);
 	} else if (_scene->_priorSceneId != -2) {
-		_game._player._playerPos = Common::Point(63, 149);            
+		_game._player._playerPos = Common::Point(63, 149); 
 		_game._player._facing = FACING_NORTHEAST;
-		_game._player._visible   = false;
+		_game._player._visible = false;
 		_game._player._stepEnabled = false;
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
@@ -2387,7 +2387,7 @@ void Scene513::step() {
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2);
 		_vm->_sound->command(24);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 81);
-		break;      
+		break; 
 
 	case 81:
 		_game._player.walk(Common::Point(265, 152), FACING_WEST);
@@ -2402,7 +2402,7 @@ void Scene513::step() {
 		break; 
 
 	case 83:
-		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);  
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2); 
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2);
 		_game._player._stepEnabled = true;
 		break;
@@ -2413,7 +2413,7 @@ void Scene513::step() {
 
 	switch (_game._trigger) {
 	case 70:
-		_game._player._visible   = true;
+		_game._player._visible = true;
 		_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
 		_scene->_sequences.addTimer(6, 71);
 		break;
@@ -2426,7 +2426,7 @@ void Scene513::step() {
 		break; 
 
 	case 72:
-		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2);  
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2); 
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 		_game._player._stepEnabled = true;
 		break; 
@@ -2441,7 +2441,7 @@ void Scene513::actions() {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
-			_scene->_sequences.remove(_globals._sequenceIndexes[1]);   
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]); 
 			_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 6, 1, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
@@ -2457,7 +2457,7 @@ void Scene513::actions() {
 			break;
 
 		case 2:
-			_game._player._visible   = false;
+			_game._player._visible = false;
 			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 10, 1, 0, 0);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
@@ -2478,9 +2478,9 @@ void Scene513::actions() {
 	} else if (_action.isAction(VERB_PUT, 0xB3, 0x251) || _action.isAction(VERB_PUT, 0x305, 0x251)) {
 		switch (_game._trigger) {
 		case 0:
-			_game._player._stepEnabled   = false;
-			_game._player._visible     = false;  
-			_globals._sequenceIndexes[4]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 7, 1, 0, 0);
+			_game._player._stepEnabled = false;
+			_game._player._visible = false; 
+			_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 7, 1, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 1, 2);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
@@ -2488,7 +2488,7 @@ void Scene513::actions() {
 
 		case 1:
 			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[4]);
-			_game._player._visible   = true;
+			_game._player._visible = true;
 			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2);
@@ -2511,7 +2511,7 @@ void Scene513::actions() {
 			break;
 
 		case 4:
-			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);  
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2); 
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2);
 			_game._player._stepEnabled = true;
 			if (_globals[kCityFlooded])
@@ -2564,7 +2564,7 @@ void Scene515::setup() {
 }
 
 void Scene515::enter() {
-	_game._player._visible   = false;
+	_game._player._visible = false;
 	_game._player._stepEnabled = false;
 	_scene->_sequences.addTimer(30, 70);
 
@@ -2580,5 +2580,147 @@ void Scene515::step() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene551::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene551::enter() {
+	if (_globals[kSexOfRex] == REX_MALE)
+		_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 0));
+	else
+		_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 1));
+
+	if (_scene->_priorSceneId == 501)
+		_game._player._playerPos = Common::Point(18, 130);
+	else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(124, 119);
+		_game._player._facing = FACING_NORTH;
+	}
+
+	if (_globals[kTeleporterCommand]) {
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+
+		char sepChar;
+		if (_globals[kSexOfRex] == REX_MALE)
+			sepChar = 'e';
+		else
+			sepChar = 'u';
+
+		int suffixNum;
+		int trigger;
+
+		switch (_globals[kTeleporterCommand]) {
+		case 1:
+			suffixNum = 3;
+			trigger = 75;
+			_globals[kTeleporterUnderstood] = true;
+			break;
+
+		case 2:
+			suffixNum = 1;
+			trigger = 80;
+			break;
+
+		case 4:
+			suffixNum = 2;
+			trigger = 90;
+			break;
+
+		default:
+			trigger = 0;
+			suffixNum = 0;
+		}
+
+		_globals[kTeleporterCommand] = 0;
+
+		if (suffixNum > 0)
+			_scene->loadAnimation(formAnimName(sepChar, suffixNum), trigger);
+		else {
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+		}
+	}
+
+	sceneEntrySound();
+}
+
+void Scene551::step() {
+	switch (_game._trigger) {
+	case 75:
+		_game._player._stepEnabled = true;
+		_game._player._visible = true;
+		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+		break;
+
+	case 80:
+		_globals[kTeleporterCommand] = 1;
+		_scene->_nextSceneId = _globals[kTeleporterDestination];
+		_scene->_reloadSceneFlag = true;
+		break;
+
+	case 90:
+		if (_globals[kSexOfRex] == REX_MALE) {
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 8); 
+		} else { 
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 8); 
+		}
+		_vm->_sound->command(28);
+		_scene->_sequences.addTimer(60, 91);
+		break;
+
+	case 91:
+		_scene->_reloadSceneFlag = true;
+		break; 
+
+	default:
+		break;
+	}
+}
+
+void Scene551::preActions() {
+	if (_action.isAction(0x1AD) && (_action.isAction(0x360) || _action.isAction(0x361)))
+		_game._player._walkOffScreenSceneId = 501;
+}
+
+void Scene551::actions() {
+	if (_action.isAction(0x2F9, 0x16C))
+		_scene->_nextSceneId = 502;
+	else if ((_action._lookFlag))
+		_vm->_dialogs->show(55117);
+	else if (_action.isAction(VERB_LOOK, 0x35E))
+		_vm->_dialogs->show(55110);
+	else if (_action.isAction(VERB_LOOK, 0x318))
+		_vm->_dialogs->show(55111);
+	else if (_action.isAction(VERB_WALKTO, 0x318))
+		_vm->_dialogs->show(55112);
+	else if (_action.isAction(VERB_LOOK, 0x323))
+		_vm->_dialogs->show(55113);
+	else if (_action.isAction(VERB_LOOK, 0x16C))
+		_vm->_dialogs->show(55114);
+	else if (_action.isAction(VERB_LOOK, 0x323))
+		_vm->_dialogs->show(55115);
+	else if (_action.isAction(VERB_LOOK, 0x361)) {
+		if (_game._visitedScenes.exists(505))
+			_vm->_dialogs->show(55116);
+		else
+			_vm->_dialogs->show(55115);
+	} else if (_action.isAction(VERB_LOOK, 0x31D))
+		_vm->_dialogs->show(55118);
+	else if (_action.isAction(VERB_LOOK, 0x369))
+		_vm->_dialogs->show(55119);
+	else if (_action.isAction(VERB_LOOK, 0x249))
+		_vm->_dialogs->show(55120);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
index 0fbc62f..9d5e76a 100644
--- a/engines/mads/nebular/nebular_scenes5.h
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -238,6 +238,17 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene551: public Scene5xx{
+public:
+	Scene551(MADSEngine *vm) : Scene5xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 2990034571edac22a606003f76d1619f017f1786
    https://github.com/scummvm/scummvm/commit/2990034571edac22a606003f76d1619f017f1786
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-10T20:58:44+02:00

Commit Message:
MADS: Implement scene 601

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes6.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 19ccc62..a6ea81d 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -225,7 +225,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 
 	// Scene group #6 (men's city, upper floor)
 	case 601:	// outside Bruce's house
-		return new DummyScene(vm);	// TODO
+		return new Scene601(vm);
 	case 602:	// Bruce's house, living room
 		return new DummyScene(vm);	// TODO
 	case 603:	// Bruce's house, bedroom
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index 2d4ef9e..0b2c939 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -83,5 +83,139 @@ void Scene6xx::sceneEntrySound() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene601::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x343);
+	_scene->addActiveVocab(0xD1);
+}
+
+void Scene601::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('c', 0));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RXCD_4");
+
+	if (_globals[kLaserHoleIsThere]) {
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2);
+		_scene->_dynamicHotspots.add(0x343, 0xD1, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+	}
+
+	_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);  
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 3);
+
+	if (_scene->_priorSceneId == 504) {
+		_game._player._playerPos = Common::Point(73, 148);
+		_game._player._facing = FACING_WEST; 
+		_game._player._visible   = false;
+		_game._player._stepEnabled = false;
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]); 
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 3);
+		_scene->loadAnimation(formAnimName('R', 1), 70); 
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(229, 129);
+		_game._player._facing = FACING_SOUTHWEST;
+	}
+
+	sceneEntrySound();
+}
+
+void Scene601::step() {
+	switch (_game._trigger) {
+	case 70:
+		_game._player._visible   = true;
+		_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
+		_scene->_sequences.addTimer(30, 71);
+		break;
+
+	case 71:
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+		_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 6, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 3);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 72);
+		break; 
+
+	case 72:
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);  
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 3);
+		_game._player._stepEnabled = true;
+		break; 
+
+	default:
+		break;
+	}
+}
+
+void Scene601::actions() {
+	if (_action.isAction(0x18B, 0x378))
+		_scene->_nextSceneId = 602;
+	else if (_action.isAction(0x325, 0x324)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);  
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 3);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			break;
+
+		case 1: {
+			int syncIdx = _globals._sequenceIndexes[2];
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);  
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], syncIdx);
+			_scene->_sequences.addTimer(6, 2);
+			}
+			break;
+
+		case 2:
+			_game._player._visible   = false;
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 10, 1, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+			break;
+
+		case 3: {
+			int syncIdx = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], syncIdx); 
+			_scene->_nextSceneId = 504;
+			}
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x31E)) {
+		if (!_globals[kLaserHoleIsThere])
+			_vm->_dialogs->show(60110);
+		else
+			_vm->_dialogs->show(60111);
+	} else if (_action.isAction(VERB_LOOK, 0x324))
+		_vm->_dialogs->show(60112);
+	else if (_action.isAction(VERB_LOOK, 0x32C))
+		_vm->_dialogs->show(60113);
+	else if (_action.isAction(VERB_LOOK, 0x323))
+		_vm->_dialogs->show(60114);
+	else if (_action.isAction(0x1AD, 0x31E))
+		_vm->_dialogs->show(60115);
+	else if (_action.isAction(VERB_LOOK, 0x48E))
+		_vm->_dialogs->show(60116);
+	else if (_action.isAction(VERB_LOOK, 0x378))
+		_vm->_dialogs->show(60117);
+	else if (_action.isAction(VERB_LOOK, 0x18D))
+		_vm->_dialogs->show(60118);
+	else if (_action.isAction(VERB_LOOK, 0x38F))
+		_vm->_dialogs->show(60119);
+	else if (_action.isAction(VERB_LOOK, 0x3C4))
+		_vm->_dialogs->show(60120);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes6.h b/engines/mads/nebular/nebular_scenes6.h
index 19eb278..5aecb13 100644
--- a/engines/mads/nebular/nebular_scenes6.h
+++ b/engines/mads/nebular/nebular_scenes6.h
@@ -50,8 +50,19 @@ public:
 	Scene6xx(MADSEngine *vm) : NebularScene(vm) {}
 };
 
-} // End of namespace Nebular
+class Scene601: public Scene6xx{
+public:
+	Scene601(MADSEngine *vm) : Scene6xx(vm) {}
 
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
+} // End of namespace Nebular
 } // End of namespace MADS
 
 #endif /* MADS_NEBULAR_SCENES6_H */


Commit: 434f33561166ed70442db3a55813176dbe0e4757
    https://github.com/scummvm/scummvm/commit/434f33561166ed70442db3a55813176dbe0e4757
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-11T00:08:34+02:00

Commit Message:
MADS: Implement scene 602

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes6.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index a6ea81d..5b1ad6b 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -227,7 +227,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 601:	// outside Bruce's house
 		return new Scene601(vm);
 	case 602:	// Bruce's house, living room
-		return new DummyScene(vm);	// TODO
+		return new Scene602(vm);
 	case 603:	// Bruce's house, bedroom
 		return new DummyScene(vm);	// TODO
 	case 604:	// viewport
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index 0b2c939..5e78db6 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -217,5 +217,318 @@ void Scene601::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene602::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(0x3D3);
+	_scene->addActiveVocab(0x343);
+}
+
+void Scene602::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('h', -1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 1));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('l', 0));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RXMRC_9");
+
+	if (!_game._visitedScenes._sceneRevisited)
+		_globals[kSafeStatus] = 0;
+
+	if (_globals[kLaserHoleIsThere]) {
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 9); 
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 9); 
+		int idx = _scene->_dynamicHotspots.add(0x343, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(80, 134), FACING_NORTHEAST);
+		_scene->changeVariant(1);
+	} else
+		_scene->_hotspots.activate(0x342, false); 
+
+	if (_globals[kSafeStatus] == 0) { 
+		_lastSpriteIdx = _globals._spriteIndexes[2]; 
+		_cycleIndex    = -1;
+	} else if (_globals[kSafeStatus] == 1) { 
+		_lastSpriteIdx = _globals._spriteIndexes[2]; 
+		_cycleIndex    = -2;
+	} else if (_globals[kSafeStatus] == 3) { 
+		_lastSpriteIdx = _globals._spriteIndexes[3]; 
+		_cycleIndex    = -2;
+	} else {
+		_lastSpriteIdx = _globals._spriteIndexes[3]; 
+		_cycleIndex    = -1;
+	}
+
+	_lastSequenceIdx = _scene->_sequences.startCycle(_lastSpriteIdx, false, _cycleIndex);
+	_scene->_sequences.setDepth(_lastSequenceIdx, 14);
+	int idx = _scene->_dynamicHotspots.add(0x3D3, VERB_WALKTO, _lastSequenceIdx, Common::Rect(0, 0, 0, 0));
+	_scene->_dynamicHotspots.setPosition(idx, Common::Point(185, 113), FACING_NORTHWEST);
+
+	if (_game._objects.isInRoom(OBJ_DOOR_KEY)) {
+		_globals._spriteIndexes[6]  = _scene->_sprites.addSprites(formAnimName('k', -1));
+		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, -1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 15);
+		if (_globals[kSafeStatus] == 0 || _globals[kSafeStatus] == 2)
+			_scene->_hotspots.activate(0x6F, false); 
+	} else
+		_scene->_hotspots.activate(0x6F, false);
+
+	if (_scene->_priorSceneId == 603) {
+		_game._player._playerPos = Common::Point(228, 126);
+		_game._player._facing = FACING_WEST;  
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(50, 127);
+		_game._player._facing = FACING_EAST; 
+	} 
+
+	sceneEntrySound();
+	_game.loadQuoteSet(0x2F1, 0x2F2, 0x2F3, 0);
+
+	if (_scene->_roomChanged) {
+		_game._objects.addToInventory(OBJ_NOTE);
+		_game._objects.addToInventory(OBJ_REARVIEW_MIRROR);
+		_game._objects.addToInventory(OBJ_COMPACT_CASE);
+	}
+}
+
+void Scene602::handleSafeActions() {
+	switch (_game._trigger) {
+	case 0:
+		_game._player._stepEnabled    = false;
+		_game._player._visible      = false;  
+		_globals._sequenceIndexes[5]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], true, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 3);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_SPRITE, 3, 1);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+		break;
+
+	case 1:
+		if (_safeMode == 1 || _safeMode == 3) {
+			if (_globals[kSafeStatus] == 0 && _safeMode == 1) {
+				_scene->_kernelMessages.reset();
+				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x2F1));
+				_scene->_sequences.addTimer(120, 4);
+			} else {
+				_scene->_sequences.remove(_lastSequenceIdx);
+				if (_safeMode == 3)
+					_lastSpriteIdx  = _globals._spriteIndexes[2];
+				else
+					_lastSpriteIdx  = _globals._spriteIndexes[3];
+
+				_lastSequenceIdx = _scene->_sequences.addSpriteCycle(_lastSpriteIdx, false, 12, 1, 0, 0);
+				_scene->_sequences.setDepth(_lastSequenceIdx, 14);
+				if (_game._objects[OBJ_DOOR_KEY]._roomNumber == _scene->_currentSceneId)
+					_scene->_hotspots.activate(0x6F, true); 
+
+				_scene->_sequences.addSubEntry(_lastSequenceIdx,
+					SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			}
+		} else {
+			_scene->_sequences.remove(_lastSequenceIdx);
+			if (_globals[kSafeStatus] == 1)
+				_lastSpriteIdx = _globals._spriteIndexes[2];
+			else
+				_lastSpriteIdx = _globals._spriteIndexes[3];
+
+			_lastSequenceIdx = _scene->_sequences.startReverseCycle(_lastSpriteIdx, false, 12, 1, 0, 0);
+			_scene->_sequences.setDepth(_lastSequenceIdx, 14);
+			if (_game._objects[OBJ_DOOR_KEY]._roomNumber == _scene->_currentSceneId)
+				_scene->_hotspots.activate(0x6F, false); 
+
+			_scene->_sequences.addSubEntry(_lastSequenceIdx, SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+		} 
+		break; 
+
+	case 2: {
+		int synxIdx = _lastSequenceIdx; 
+		_lastSequenceIdx = _scene->_sequences.startCycle(_lastSpriteIdx, false, _cycleIndex);
+		_scene->_sequences.setDepth(_lastSequenceIdx, 14);
+		_scene->_sequences.updateTimeout(_lastSequenceIdx, synxIdx);
+		int idx = _scene->_dynamicHotspots.add(0x3D3, VERB_WALKTO, _lastSequenceIdx, Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(185, 113), FACING_NORTHWEST);
+		if (_safeMode ==  3) {
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x2F3));
+			_scene->_sequences.addTimer(120, 4);
+		} else
+			_scene->_sequences.addTimer(60, 4);
+		break;   
+		}
+
+	case 3:
+		_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[5]);
+		_game._player._visible   = true;
+		break;  
+
+	case 4:
+		if (_safeMode == 1) { 
+			if (_globals[kSafeStatus] == 2)
+				_globals[kSafeStatus] = 3;
+		} else if (_safeMode == 2) { 
+			if (_globals[kSafeStatus] == 3)
+				_globals[kSafeStatus] = 2;
+			else
+				_globals[kSafeStatus] = 0;
+		} else
+			_globals[kSafeStatus]     = 1;
+
+		_game._player._stepEnabled = true;
+		break;
+
+	default:
+		break;
+	}                 
+}  
+
+void Scene602::actions() {
+	if (_action.isAction(0x18B, 0x1F9))
+		_scene->_nextSceneId = 601;
+	else if (_action.isAction(0x18B, 0x70))
+		_scene->_nextSceneId = 603;
+	else if (_action.isAction(VERB_OPEN, 0x3D3) && ((_globals[kSafeStatus] == 0) || (_globals[kSafeStatus] == 2))) {
+		_safeMode = 1;
+		_cycleIndex = -2;
+		handleSafeActions();
+	} else if (_action.isAction(VERB_CLOSE, 0x3D3) && ((_globals[kSafeStatus] == 1) || (_globals[kSafeStatus] == 3))) {
+		_safeMode = 2;
+		_cycleIndex = -1;
+		handleSafeActions();
+	} else if (_action.isAction(0x17B, 0x3A7, 0x3D3)) {
+		if ((_globals[kSafeStatus] == 0) && (_game._difficulty != DIFFICULTY_HARD)) {
+			_safeMode = 3;
+			_cycleIndex = -2;
+			handleSafeActions();
+		} 
+	} else if ((_action.isAction(VERB_PUT, 0x120, 0x343) || _action.isAction(VERB_PUT, 0x57, 0x343)
+		|| _action.isAction(0x365, 0x57, 0x343) || _action.isAction(0x365, 0x120, 0x343)) && (_globals[kSafeStatus] == 0)) { 
+		switch (_game._trigger) {
+		case 0:
+			_vm->_dialogs->show(60230);
+			_game._player._stepEnabled    = false;
+			_game._player._visible      = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[4]);   
+			_scene->_sequences.remove(_lastSequenceIdx);
+			_scene->loadAnimation(formAnimName('L', 1), 1);
+			break;
+
+		case 1: {
+			_game._player._visible = true; 
+			_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
+			_lastSpriteIdx  = _globals._spriteIndexes[3]; 
+			_lastSequenceIdx = _scene->_sequences.startCycle(_lastSpriteIdx, false, -1);
+			_scene->_sequences.setDepth(_lastSequenceIdx, 14);
+			int idx = _scene->_dynamicHotspots.add(0x3D3, VERB_WALKTO, _lastSequenceIdx, Common::Rect(0, 0, 0, 0));
+			_scene->_dynamicHotspots.setPosition(idx, Common::Point(185, 113), FACING_NORTHWEST);
+			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 9); 
+			idx = _scene->_dynamicHotspots.add(0x343, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+			_scene->_dynamicHotspots.setPosition(idx, Common::Point(80, 134), FACING_NORTHEAST);
+			_scene->_sequences.addTimer(60, 2);
+			}
+			break;
+
+		case 2:
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x2F2));
+			_globals[kSafeStatus]        = 2;
+			_game._player._stepEnabled    = true;
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(VERB_TAKE, 0x6F) && (_game._trigger || _game._objects.isInRoom(OBJ_DOOR_KEY))) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled   = false;
+			_game._player._visible     = false;  
+			_globals._sequenceIndexes[5]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], true, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 3);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_SPRITE, 3, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+
+		case 1:
+			_scene->_sequences.remove(_globals._sequenceIndexes[6]);  
+			_scene->_hotspots.activate(0x6F, false);
+			_vm->_sound->command(9);
+			_game._objects.addToInventory(OBJ_DOOR_KEY);
+			break;
+
+		case 2:
+			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[5]);
+			_game._player._visible   = true;
+			_game._player._stepEnabled = true;
+			_vm->_dialogs->showItem(OBJ_DOOR_KEY, 835);
+			break;
+
+		default:
+			break;
+		}                 
+	} else if (_action._lookFlag)
+		_vm->_dialogs->show(60210);
+	else if (_action.isAction(VERB_LOOK, 0x89))
+		_vm->_dialogs->show(60211);
+	else if (_action.isAction(VERB_LOOK, 0x1F9))
+		_vm->_dialogs->show(60212);
+	else if (_action.isAction(VERB_LOOK, 0x160))
+		_vm->_dialogs->show(60213);
+	else if (_action.isAction(VERB_LOOK, 0x47) || _action.isAction(VERB_LOOK, 0x3CA))
+		_vm->_dialogs->show(60214);
+	else if (_action.isAction(VERB_LOOK, 0x492))
+		_vm->_dialogs->show(60215);
+	else if (_action.isAction(VERB_LOOK, 0x3D8))
+		_vm->_dialogs->show(60216);
+	else if (_action.isAction(VERB_LOOK, 0x289))
+		_vm->_dialogs->show(60217);
+	else if (_action.isAction(VERB_LOOK, 0x2F6))
+		_vm->_dialogs->show(60218);
+	else if (_action.isAction(VERB_LOOK, 0x491))
+		_vm->_dialogs->show(60219);
+	else if (_action.isAction(VERB_LOOK, 0x493))
+		_vm->_dialogs->show(60220);
+	else if (_action.isAction(VERB_LOOK, 0x70))
+		_vm->_dialogs->show(60221);
+	else if (_action.isAction(VERB_LOOK, 0x3D3)) {
+		if (_globals[kSafeStatus] == 0)
+			_vm->_dialogs->show(60222);
+		else if (_globals[kSafeStatus] == 1) {
+			if (!_game._objects.isInRoom(OBJ_DOOR_KEY))
+				_vm->_dialogs->show(60223);
+			else
+				_vm->_dialogs->show(60224);
+		} else if (_globals[kSafeStatus] == 2)
+			_vm->_dialogs->show(60234);
+		else if (_game._objects.isInRoom(OBJ_DOOR_KEY))
+			_vm->_dialogs->show(60235);
+		else
+			_vm->_dialogs->show(60236);
+	} else if (_action.isAction(0x17B, 0x6F, 0x3D3) || _action.isAction(0x17B, 0xFF, 0x3D3))
+		_vm->_dialogs->show(60225);
+	else if (_action.isAction(VERB_PULL, 0x3D3))
+		_vm->_dialogs->show(60226);
+	else if (_action.isAction(VERB_PUT, 0x3D8) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId)))
+		_vm->_dialogs->show(60227);
+	else if (_action.isAction(VERB_LOOK, 0x342))
+		_vm->_dialogs->show(60228);
+	else if (_action.isAction(VERB_LOOK, 0x343))
+		_vm->_dialogs->show(60229);
+	else if (_action.isAction(VERB_LOOK, 0x3F5))
+		_vm->_dialogs->show(60231);
+	else if (_action.isAction(VERB_THROW, 0x2A, 0x3D3) || _action.isAction(VERB_THROW, 0x2B, 0x3D3))
+		_vm->_dialogs->show(60232);
+	else if (_action.isAction(VERB_PUT, 0x171))
+		_vm->_dialogs->show(60233);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes6.h b/engines/mads/nebular/nebular_scenes6.h
index 5aecb13..cbf384d 100644
--- a/engines/mads/nebular/nebular_scenes6.h
+++ b/engines/mads/nebular/nebular_scenes6.h
@@ -62,6 +62,26 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene602: public Scene6xx{
+private:
+	int _lastSpriteIdx;
+	int _lastSequenceIdx;
+	int _cycleIndex;
+	int _safeMode;
+
+	void handleSafeActions();
+
+public:
+	Scene602(MADSEngine *vm) : Scene6xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 3f3040063ac0b874a275a3bf44b48a6283b2404b
    https://github.com/scummvm/scummvm/commit/3f3040063ac0b874a275a3bf44b48a6283b2404b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-10T22:28:51-04:00

Commit Message:
MADS: Fix restoring palette after showing picture dialog

Changed paths:
    engines/mads/nebular/dialogs_nebular.cpp



diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 4d34c76..6ddb323 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -368,6 +368,7 @@ PictureDialog::~PictureDialog() {
 
 	// Restore palette information
 	Common::copy(&_palette[0], &_palette[PALETTE_SIZE], &palette._mainPalette[0]);
+	_vm->_palette->setFullPalette(palette._mainPalette);
 	Common::copy(&_palFlags[0], &_palFlags[PALETTE_COUNT], &palette._palFlags[0]);
 	palette._rgbList.copy(_rgbList);
 }


Commit: 1655a0aa90077296b70d03d61157950bee1cc390
    https://github.com/scummvm/scummvm/commit/1655a0aa90077296b70d03d61157950bee1cc390
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-11T11:06:45+02:00

Commit Message:
MADS: Implement scene 603

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes6.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 5b1ad6b..5d937e9 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -229,7 +229,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 602:	// Bruce's house, living room
 		return new Scene602(vm);
 	case 603:	// Bruce's house, bedroom
-		return new DummyScene(vm);	// TODO
+		return new Scene603(vm);
 	case 604:	// viewport
 		return new DummyScene(vm);	// TODO
 	case 605:	// viewport closeup
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index 5e78db6..49246fb 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -530,5 +530,147 @@ void Scene602::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene603::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(0x57);
+	_scene->addActiveVocab(0x3A8);
+}
+
+void Scene603::enter() {
+	if (_game._objects[OBJ_COMPACT_CASE]._roomNumber == _scene->_currentSceneId) {
+		_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXMRD_3");
+		_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', -1));
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+		_compactCaseHotspotId = _scene->_dynamicHotspots.add(0x57, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(_compactCaseHotspotId, Common::Point(250, 152), FACING_SOUTHEAST);
+	}
+
+	if ((_game._difficulty != DIFFICULTY_HARD) && (_game._objects[OBJ_NOTE]._roomNumber == _scene->_currentSceneId)) {
+		_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RXMRC_9");
+		_globals._spriteIndexes[2]  = _scene->_sprites.addSprites(formAnimName('p', -1));
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14);
+		_noteHotspotId = _scene->_dynamicHotspots.add(0x3A8, VERB_WALKTO, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(_noteHotspotId, Common::Point(242, 118), FACING_NORTHEAST);
+	}
+
+	if (_scene->_priorSceneId != -2)
+		_game._player._playerPos = Common::Point(113, 134);
+
+	sceneEntrySound();
+}
+
+void Scene603::actions() {
+	if (_action.isAction(0x18C, 0x3F1))
+		_scene->_nextSceneId = 602;
+	else if (_action.isAction(VERB_TAKE, 0x57)) {
+		if ( _game._trigger || !_game._objects.isInInventory(OBJ_COMPACT_CASE)) {
+			switch (_game._trigger) {
+			case 0:
+				_game._player._stepEnabled   = false;
+				_game._player._visible     = false;  
+				_globals._sequenceIndexes[4]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 8, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 1, 5);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 5, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				break;
+
+			case 1:
+				_vm->_sound->command(9);
+				_scene->_sequences.remove(_globals._sequenceIndexes[1]);  
+				_scene->_dynamicHotspots.remove(_compactCaseHotspotId);
+				_game._objects.addToInventory(OBJ_COMPACT_CASE);
+				_vm->_dialogs->showItem(OBJ_COMPACT_CASE, 60330);
+				break;
+
+			case 2:
+				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[4]);
+				_game._player._visible   = true;
+				_game._player._stepEnabled = true;
+				break;
+
+			default:
+				break;
+			}                 
+		}
+	} else if (_action.isAction(VERB_TAKE, 0x3A8)) {
+		if ( _game._trigger || !_game._objects.isInInventory(OBJ_NOTE)) {
+			if (_game._trigger == 0) {
+				_game._player._stepEnabled   = false;
+				_game._player._visible     = false;  
+				_globals._sequenceIndexes[3]  = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+				_scene->_sequences.addTimer (15, 1);
+			} else if (_game._trigger == 1) {
+				_vm->_sound->command(9);
+				_scene->_sequences.remove(_globals._sequenceIndexes[2]);  
+				_scene->_dynamicHotspots.remove(_noteHotspotId);
+				_game._objects.addToInventory(OBJ_NOTE);
+				_scene->_sequences.remove(_globals._sequenceIndexes[3]); 
+				_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+				_game._player._visible   = true;
+				_game._player._stepEnabled = true;
+			}                 
+		}
+	} else if (_action._lookFlag)
+		_vm->_dialogs->show(60310);
+	else if (_action.isAction(VERB_LOOK, 0x1CB))
+		_vm->_dialogs->show(60311);
+	else if (_action.isAction(VERB_LOOK, 0x3E5))
+		_vm->_dialogs->show(60312);
+	else if (_action.isAction(VERB_TAKE, 0x3E5))
+		_vm->_dialogs->show(60313);
+	else if (_action.isAction(VERB_LOOK, 0x3EE))
+		_vm->_dialogs->show(60314);
+	else if (_action.isAction(VERB_LOOK, 0x3ED))
+		_vm->_dialogs->show(60315);
+	else if (_action.isAction(VERB_LOOK, 0x49D))
+		_vm->_dialogs->show(60316);
+	else if (_action.isAction(VERB_LOOK, 0x2F6))
+		_vm->_dialogs->show(60317);
+	else if (_action.isAction(VERB_LOOK, 0x49E) || _action.isAction(VERB_LOOK, 0x49F) || _action.isAction(VERB_LOOK, 0x3E7))
+		_vm->_dialogs->show(60318);
+	else if (_action.isAction(VERB_LOOK, 0x3DE))
+		_vm->_dialogs->show(60319);
+	else if (_action.isAction(VERB_TAKE, 0x3DE))
+		_vm->_dialogs->show(60320);
+	else if (_action.isAction(VERB_LOOK, 0x3DF))
+		_vm->_dialogs->show(60321);
+	else if (_action.isAction(VERB_TAKE, 0x3DF))
+		_vm->_dialogs->show(60322);
+	else if (_action.isAction(VERB_TAKE, 0x3A8))
+		_vm->_dialogs->show(60323);
+	else if (_action.isAction(VERB_LOOK, 0x3A8)) {
+		if (_game._objects[OBJ_NOTE]._roomNumber == _scene->_currentSceneId)
+			_vm->_dialogs->show(60324);
+	} else if (_action.isAction(VERB_LOOK, 0x3E3)) {
+		if (_game._objects[OBJ_NOTE]._roomNumber == _scene->_currentSceneId)
+			_vm->_dialogs->show(60326);
+		else
+			_vm->_dialogs->show(60325);
+	} else if (_action.isAction(VERB_LOOK, 0x3EA)) {
+		if (_game._objects[OBJ_COMPACT_CASE]._roomNumber == _scene->_currentSceneId)
+			_vm->_dialogs->show(60327);
+		else
+			_vm->_dialogs->show(60328);
+	} else if (_action.isAction(VERB_LOOK, 0x57) && (_action._mainObjectSource == 4))
+		_vm->_dialogs->show(60329);
+	// For the next two checks, the second part of the check wasn't surrounded par parenthesis, which was obviously wrong
+	else if (_action.isAction(VERB_LOOK) && (_action.isAction(0x31) || _action.isAction(0x3EA) || _action.isAction(0x3E8)))
+		_vm->_dialogs->show(60331);
+	else if (_action.isAction(VERB_TAKE) && (_action.isAction(0x31) || _action.isAction(0x3EA) || _action.isAction(0x3E8)))
+		_vm->_dialogs->show(60332);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes6.h b/engines/mads/nebular/nebular_scenes6.h
index cbf384d..cf69f59 100644
--- a/engines/mads/nebular/nebular_scenes6.h
+++ b/engines/mads/nebular/nebular_scenes6.h
@@ -82,6 +82,22 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene603: public Scene6xx{
+private:
+	int _compactCaseHotspotId;
+	int _noteHotspotId;
+
+public:
+	Scene603(MADSEngine *vm) : Scene6xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: bbeb24aaabbea33c54dc8ff6926fd161740f5c25
    https://github.com/scummvm/scummvm/commit/bbeb24aaabbea33c54dc8ff6926fd161740f5c25
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-11T18:57:35+02:00

Commit Message:
MADS: Implement scene 604

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes6.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 5d937e9..d729202 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -231,7 +231,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 603:	// Bruce's house, bedroom
 		return new Scene603(vm);
 	case 604:	// viewport
-		return new DummyScene(vm);	// TODO
+		return new Scene604(vm);
 	case 605:	// viewport closeup
 		return new DummyScene(vm);	// TODO
 	case 607:	// outside Abdul's garage
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index 49246fb..6482eb1 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -100,18 +100,18 @@ void Scene601::enter() {
 		_scene->_dynamicHotspots.add(0x343, 0xD1, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 	}
 
-	_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);  
+	_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 3);
 
 	if (_scene->_priorSceneId == 504) {
 		_game._player._playerPos = Common::Point(73, 148);
-		_game._player._facing = FACING_WEST; 
-		_game._player._visible   = false;
+		_game._player._facing = FACING_WEST;
+		_game._player._visible = false;
 		_game._player._stepEnabled = false;
-		_scene->_sequences.remove(_globals._sequenceIndexes[2]); 
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 3);
-		_scene->loadAnimation(formAnimName('R', 1), 70); 
+		_scene->loadAnimation(formAnimName('R', 1), 70);
 	} else if (_scene->_priorSceneId != -2) {
 		_game._player._playerPos = Common::Point(229, 129);
 		_game._player._facing = FACING_SOUTHWEST;
@@ -123,7 +123,7 @@ void Scene601::enter() {
 void Scene601::step() {
 	switch (_game._trigger) {
 	case 70:
-		_game._player._visible   = true;
+		_game._player._visible = true;
 		_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
 		_scene->_sequences.addTimer(30, 71);
 		break;
@@ -133,13 +133,13 @@ void Scene601::step() {
 		_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 6, 1, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 3);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 72);
-		break; 
+		break;
 
 	case 72:
-		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);  
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 3);
 		_game._player._stepEnabled = true;
-		break; 
+		break;
 
 	default:
 		break;
@@ -153,7 +153,7 @@ void Scene601::actions() {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
-			_scene->_sequences.remove(_globals._sequenceIndexes[2]);  
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 1, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 3);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
@@ -161,14 +161,14 @@ void Scene601::actions() {
 
 		case 1: {
 			int syncIdx = _globals._sequenceIndexes[2];
-			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);  
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], syncIdx);
 			_scene->_sequences.addTimer(6, 2);
 			}
 			break;
 
 		case 2:
-			_game._player._visible   = false;
+			_game._player._visible = false;
 			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 10, 1, 0, 0);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
@@ -178,7 +178,7 @@ void Scene601::actions() {
 			int syncIdx = _globals._sequenceIndexes[3];
 			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
-			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], syncIdx); 
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], syncIdx);
 			_scene->_nextSceneId = 504;
 			}
 			break;
@@ -237,27 +237,27 @@ void Scene602::enter() {
 
 	if (_globals[kLaserHoleIsThere]) {
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
-		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 9); 
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 9);
 		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
-		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 9); 
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 9);
 		int idx = _scene->_dynamicHotspots.add(0x343, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(80, 134), FACING_NORTHEAST);
 		_scene->changeVariant(1);
 	} else
-		_scene->_hotspots.activate(0x342, false); 
-
-	if (_globals[kSafeStatus] == 0) { 
-		_lastSpriteIdx = _globals._spriteIndexes[2]; 
-		_cycleIndex    = -1;
-	} else if (_globals[kSafeStatus] == 1) { 
-		_lastSpriteIdx = _globals._spriteIndexes[2]; 
-		_cycleIndex    = -2;
-	} else if (_globals[kSafeStatus] == 3) { 
-		_lastSpriteIdx = _globals._spriteIndexes[3]; 
-		_cycleIndex    = -2;
+		_scene->_hotspots.activate(0x342, false);
+
+	if (_globals[kSafeStatus] == 0) {
+		_lastSpriteIdx = _globals._spriteIndexes[2];
+		_cycleIndex = -1;
+	} else if (_globals[kSafeStatus] == 1) {
+		_lastSpriteIdx = _globals._spriteIndexes[2];
+		_cycleIndex = -2;
+	} else if (_globals[kSafeStatus] == 3) {
+		_lastSpriteIdx = _globals._spriteIndexes[3];
+		_cycleIndex = -2;
 	} else {
-		_lastSpriteIdx = _globals._spriteIndexes[3]; 
-		_cycleIndex    = -1;
+		_lastSpriteIdx = _globals._spriteIndexes[3];
+		_cycleIndex = -1;
 	}
 
 	_lastSequenceIdx = _scene->_sequences.startCycle(_lastSpriteIdx, false, _cycleIndex);
@@ -266,21 +266,21 @@ void Scene602::enter() {
 	_scene->_dynamicHotspots.setPosition(idx, Common::Point(185, 113), FACING_NORTHWEST);
 
 	if (_game._objects.isInRoom(OBJ_DOOR_KEY)) {
-		_globals._spriteIndexes[6]  = _scene->_sprites.addSprites(formAnimName('k', -1));
+		_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('k', -1));
 		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, -1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 15);
 		if (_globals[kSafeStatus] == 0 || _globals[kSafeStatus] == 2)
-			_scene->_hotspots.activate(0x6F, false); 
+			_scene->_hotspots.activate(0x6F, false);
 	} else
 		_scene->_hotspots.activate(0x6F, false);
 
 	if (_scene->_priorSceneId == 603) {
 		_game._player._playerPos = Common::Point(228, 126);
-		_game._player._facing = FACING_WEST;  
+		_game._player._facing = FACING_WEST;
 	} else if (_scene->_priorSceneId != -2) {
 		_game._player._playerPos = Common::Point(50, 127);
-		_game._player._facing = FACING_EAST; 
-	} 
+		_game._player._facing = FACING_EAST;
+	}
 
 	sceneEntrySound();
 	_game.loadQuoteSet(0x2F1, 0x2F2, 0x2F3, 0);
@@ -295,9 +295,9 @@ void Scene602::enter() {
 void Scene602::handleSafeActions() {
 	switch (_game._trigger) {
 	case 0:
-		_game._player._stepEnabled    = false;
-		_game._player._visible      = false;  
-		_globals._sequenceIndexes[5]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], true, 12, 1, 0, 0);
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_globals._sequenceIndexes[5] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], true, 12, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 3);
 		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_SPRITE, 3, 1);
@@ -313,14 +313,14 @@ void Scene602::handleSafeActions() {
 			} else {
 				_scene->_sequences.remove(_lastSequenceIdx);
 				if (_safeMode == 3)
-					_lastSpriteIdx  = _globals._spriteIndexes[2];
+					_lastSpriteIdx = _globals._spriteIndexes[2];
 				else
-					_lastSpriteIdx  = _globals._spriteIndexes[3];
+					_lastSpriteIdx = _globals._spriteIndexes[3];
 
 				_lastSequenceIdx = _scene->_sequences.addSpriteCycle(_lastSpriteIdx, false, 12, 1, 0, 0);
 				_scene->_sequences.setDepth(_lastSequenceIdx, 14);
 				if (_game._objects[OBJ_DOOR_KEY]._roomNumber == _scene->_currentSceneId)
-					_scene->_hotspots.activate(0x6F, true); 
+					_scene->_hotspots.activate(0x6F, true);
 
 				_scene->_sequences.addSubEntry(_lastSequenceIdx,
 					SEQUENCE_TRIGGER_EXPIRE, 0, 2);
@@ -335,52 +335,52 @@ void Scene602::handleSafeActions() {
 			_lastSequenceIdx = _scene->_sequences.startReverseCycle(_lastSpriteIdx, false, 12, 1, 0, 0);
 			_scene->_sequences.setDepth(_lastSequenceIdx, 14);
 			if (_game._objects[OBJ_DOOR_KEY]._roomNumber == _scene->_currentSceneId)
-				_scene->_hotspots.activate(0x6F, false); 
+				_scene->_hotspots.activate(0x6F, false);
 
 			_scene->_sequences.addSubEntry(_lastSequenceIdx, SEQUENCE_TRIGGER_EXPIRE, 0, 2);
-		} 
-		break; 
+		}
+		break;
 
 	case 2: {
-		int synxIdx = _lastSequenceIdx; 
+		int synxIdx = _lastSequenceIdx;
 		_lastSequenceIdx = _scene->_sequences.startCycle(_lastSpriteIdx, false, _cycleIndex);
 		_scene->_sequences.setDepth(_lastSequenceIdx, 14);
 		_scene->_sequences.updateTimeout(_lastSequenceIdx, synxIdx);
 		int idx = _scene->_dynamicHotspots.add(0x3D3, VERB_WALKTO, _lastSequenceIdx, Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(185, 113), FACING_NORTHWEST);
-		if (_safeMode ==  3) {
+		if (_safeMode == 3) {
 			_scene->_kernelMessages.reset();
 			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x2F3));
 			_scene->_sequences.addTimer(120, 4);
 		} else
 			_scene->_sequences.addTimer(60, 4);
-		break;   
+		break;
 		}
 
 	case 3:
 		_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[5]);
-		_game._player._visible   = true;
-		break;  
+		_game._player._visible = true;
+		break;
 
 	case 4:
-		if (_safeMode == 1) { 
+		if (_safeMode == 1) {
 			if (_globals[kSafeStatus] == 2)
 				_globals[kSafeStatus] = 3;
-		} else if (_safeMode == 2) { 
+		} else if (_safeMode == 2) {
 			if (_globals[kSafeStatus] == 3)
 				_globals[kSafeStatus] = 2;
 			else
 				_globals[kSafeStatus] = 0;
 		} else
-			_globals[kSafeStatus]     = 1;
+			_globals[kSafeStatus] = 1;
 
 		_game._player._stepEnabled = true;
 		break;
 
 	default:
 		break;
-	}                 
-}  
+	}
+}
 
 void Scene602::actions() {
 	if (_action.isAction(0x18B, 0x1F9))
@@ -400,29 +400,29 @@ void Scene602::actions() {
 			_safeMode = 3;
 			_cycleIndex = -2;
 			handleSafeActions();
-		} 
+		}
 	} else if ((_action.isAction(VERB_PUT, 0x120, 0x343) || _action.isAction(VERB_PUT, 0x57, 0x343)
-		|| _action.isAction(0x365, 0x57, 0x343) || _action.isAction(0x365, 0x120, 0x343)) && (_globals[kSafeStatus] == 0)) { 
+		|| _action.isAction(0x365, 0x57, 0x343) || _action.isAction(0x365, 0x120, 0x343)) && (_globals[kSafeStatus] == 0)) {
 		switch (_game._trigger) {
 		case 0:
 			_vm->_dialogs->show(60230);
-			_game._player._stepEnabled    = false;
-			_game._player._visible      = false;
-			_scene->_sequences.remove(_globals._sequenceIndexes[4]);   
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 			_scene->_sequences.remove(_lastSequenceIdx);
 			_scene->loadAnimation(formAnimName('L', 1), 1);
 			break;
 
 		case 1: {
-			_game._player._visible = true; 
+			_game._player._visible = true;
 			_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
-			_lastSpriteIdx  = _globals._spriteIndexes[3]; 
+			_lastSpriteIdx = _globals._spriteIndexes[3];
 			_lastSequenceIdx = _scene->_sequences.startCycle(_lastSpriteIdx, false, -1);
 			_scene->_sequences.setDepth(_lastSequenceIdx, 14);
 			int idx = _scene->_dynamicHotspots.add(0x3D3, VERB_WALKTO, _lastSequenceIdx, Common::Rect(0, 0, 0, 0));
 			_scene->_dynamicHotspots.setPosition(idx, Common::Point(185, 113), FACING_NORTHWEST);
 			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
-			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 9); 
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 9);
 			idx = _scene->_dynamicHotspots.add(0x343, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 			_scene->_dynamicHotspots.setPosition(idx, Common::Point(80, 134), FACING_NORTHEAST);
 			_scene->_sequences.addTimer(60, 2);
@@ -432,8 +432,8 @@ void Scene602::actions() {
 		case 2:
 			_scene->_kernelMessages.reset();
 			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x2F2));
-			_globals[kSafeStatus]        = 2;
-			_game._player._stepEnabled    = true;
+			_globals[kSafeStatus] = 2;
+			_game._player._stepEnabled = true;
 			break;
 
 		default:
@@ -442,9 +442,9 @@ void Scene602::actions() {
 	} else if (_action.isAction(VERB_TAKE, 0x6F) && (_game._trigger || _game._objects.isInRoom(OBJ_DOOR_KEY))) {
 		switch (_game._trigger) {
 		case 0:
-			_game._player._stepEnabled   = false;
-			_game._player._visible     = false;  
-			_globals._sequenceIndexes[5]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], true, 8, 1, 0, 0);
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_globals._sequenceIndexes[5] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], true, 8, 1, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 3);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_SPRITE, 3, 1);
@@ -452,7 +452,7 @@ void Scene602::actions() {
 			break;
 
 		case 1:
-			_scene->_sequences.remove(_globals._sequenceIndexes[6]);  
+			_scene->_sequences.remove(_globals._sequenceIndexes[6]);
 			_scene->_hotspots.activate(0x6F, false);
 			_vm->_sound->command(9);
 			_game._objects.addToInventory(OBJ_DOOR_KEY);
@@ -460,14 +460,14 @@ void Scene602::actions() {
 
 		case 2:
 			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[5]);
-			_game._player._visible   = true;
+			_game._player._visible = true;
 			_game._player._stepEnabled = true;
 			_vm->_dialogs->showItem(OBJ_DOOR_KEY, 835);
 			break;
 
 		default:
 			break;
-		}                 
+		}
 	} else if (_action._lookFlag)
 		_vm->_dialogs->show(60210);
 	else if (_action.isAction(VERB_LOOK, 0x89))
@@ -550,7 +550,7 @@ void Scene603::enter() {
 
 	if ((_game._difficulty != DIFFICULTY_HARD) && (_game._objects[OBJ_NOTE]._roomNumber == _scene->_currentSceneId)) {
 		_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RXMRC_9");
-		_globals._spriteIndexes[2]  = _scene->_sprites.addSprites(formAnimName('p', -1));
+		_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('p', -1));
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14);
 		_noteHotspotId = _scene->_dynamicHotspots.add(0x3A8, VERB_WALKTO, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
@@ -570,9 +570,9 @@ void Scene603::actions() {
 		if ( _game._trigger || !_game._objects.isInInventory(OBJ_COMPACT_CASE)) {
 			switch (_game._trigger) {
 			case 0:
-				_game._player._stepEnabled   = false;
-				_game._player._visible     = false;  
-				_globals._sequenceIndexes[4]  = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 8, 1, 0, 0);
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 8, 1, 0, 0);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 1, 5);
 				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 5, 1);
@@ -581,7 +581,7 @@ void Scene603::actions() {
 
 			case 1:
 				_vm->_sound->command(9);
-				_scene->_sequences.remove(_globals._sequenceIndexes[1]);  
+				_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 				_scene->_dynamicHotspots.remove(_compactCaseHotspotId);
 				_game._objects.addToInventory(OBJ_COMPACT_CASE);
 				_vm->_dialogs->showItem(OBJ_COMPACT_CASE, 60330);
@@ -589,32 +589,32 @@ void Scene603::actions() {
 
 			case 2:
 				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[4]);
-				_game._player._visible   = true;
+				_game._player._visible = true;
 				_game._player._stepEnabled = true;
 				break;
 
 			default:
 				break;
-			}                 
+			}
 		}
 	} else if (_action.isAction(VERB_TAKE, 0x3A8)) {
 		if ( _game._trigger || !_game._objects.isInInventory(OBJ_NOTE)) {
 			if (_game._trigger == 0) {
-				_game._player._stepEnabled   = false;
-				_game._player._visible     = false;  
-				_globals._sequenceIndexes[3]  = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
 				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
-				_scene->_sequences.addTimer (15, 1);
+				_scene->_sequences.addTimer(15, 1);
 			} else if (_game._trigger == 1) {
 				_vm->_sound->command(9);
-				_scene->_sequences.remove(_globals._sequenceIndexes[2]);  
+				_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 				_scene->_dynamicHotspots.remove(_noteHotspotId);
 				_game._objects.addToInventory(OBJ_NOTE);
-				_scene->_sequences.remove(_globals._sequenceIndexes[3]); 
+				_scene->_sequences.remove(_globals._sequenceIndexes[3]);
 				_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
-				_game._player._visible   = true;
+				_game._player._visible = true;
 				_game._player._stepEnabled = true;
-			}                 
+			}
 		}
 	} else if (_action._lookFlag)
 		_vm->_dialogs->show(60310);
@@ -672,5 +672,272 @@ void Scene603::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene604::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x468);
+	_scene->addActiveVocab(VERB_WALKTO);
+	_scene->addActiveVocab(0x171);
+}
+
+void Scene604::enter() {
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('c', 0));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXCD_9");
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(Resources::formatName(620, 'b', 0, EXT_SS, ""));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RXMRC_9");
+
+	if (_globals[kTimebombStatus] == 1) {
+		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, -1);
+		_timebombHotspotId = _scene->_dynamicHotspots.add(0x171, VERB_WALKTO, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(_timebombHotspotId, Common::Point(166, 118), FACING_NORTHEAST);
+	}
+
+	if (_scene->_roomChanged)
+		_game._objects.addToInventory(OBJ_TIMEBOMB);
+
+	_vm->_palette->setEntry(252, 63, 37, 26);
+	_vm->_palette->setEntry(253, 45, 24, 17);
+	_animationActiveFl = false;
+
+	if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(72, 149);
+		_game._player._facing = FACING_NORTHEAST;
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+		_scene->loadAnimation(formAnimName('R', 1), 70);
+		_animationActiveFl = true;
+	} else {
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+	}
+
+	_monsterTimer = _scene->_frameStartTime;
+	_monsterActive = false;
+
+	sceneEntrySound();
+	_game.loadQuoteSet(0x2E7, 0x2E8, 0x2E9, 0x2EA, 0x2EB, 0x2EC, 0x2ED, 0x2EE, 0x2EF, 0x2F0, 0);
+}
+
+void Scene604::step() {
+	switch (_game._trigger) {
+	case 70:
+		_game._player._visible = true;
+		_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
+		_scene->_sequences.addTimer(30, 71);
+		break;
+
+	case 71:
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 72);
+		break;
+
+	case 72:
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+		_game._player._stepEnabled = true;
+		_animationActiveFl = false;
+		break;
+
+	default:
+		break;
+	}
+
+	if (_monsterActive && (_scene->_activeAnimation != nullptr)) {
+		if (_scene->_activeAnimation->getCurrentFrame() != _monsterFrame) {
+			_monsterFrame = _scene->_activeAnimation->getCurrentFrame();
+			int nextMonsterFrame = -1;
+
+			switch (_monsterFrame) {
+			case 50:
+			case 137:
+			case 174: {
+				int randVal = _vm->getRandomNumber(1, 1000);
+				if ((randVal <= 450) && (_game._player._special)) {
+					if (_game._player._special == 1)
+						nextMonsterFrame = 50;
+					else if (_game._player._special == 2)
+						nextMonsterFrame = 84;
+					else
+						nextMonsterFrame = 137;
+				} else if (randVal <= 150)
+					nextMonsterFrame = 50;
+				else if (randVal <= 300)
+					nextMonsterFrame = 84;
+				else if (randVal <= 450)
+					nextMonsterFrame = 137;
+				else if (randVal < 750)
+					nextMonsterFrame = 13;
+				else
+					nextMonsterFrame = 114;
+
+				}
+				break;
+
+			case 84:
+				nextMonsterFrame = 14;
+				break;
+
+			default:
+				break;
+			}
+
+			if ((nextMonsterFrame >= 0) && (nextMonsterFrame != _monsterFrame)) {
+				_scene->_activeAnimation->setCurrentFrame(nextMonsterFrame);
+				_monsterFrame = nextMonsterFrame;
+			}
+		}
+	}
+
+	if ((!_monsterActive && !_animationActiveFl) && (_scene->_frameStartTime > (_monsterTimer + 4))) {
+		_monsterTimer = _scene->_frameStartTime;
+		if ((_vm->getRandomNumber(1, 1000) < 25) || !_game._visitedScenes._sceneRevisited) {
+			_monsterActive = true;
+			_scene->freeAnimation();
+			_scene->loadAnimation(formAnimName('m', -1));
+		}
+	}
+}
+
+void Scene604::handleBombActions() {
+	switch (_game._trigger) {
+	case 0:
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_globals._sequenceIndexes[5] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], false, 9, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 3);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+		if (_bombMode == 1)
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_SPRITE, 3, 1);
+		else
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_SPRITE, 3, 2);
+
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+		break;
+
+	case 1:
+		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, -1);
+		_timebombHotspotId = _scene->_dynamicHotspots.add (0x171, VERB_WALKTO, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(_timebombHotspotId, Common::Point(166, 118), FACING_NORTHEAST);
+		_game._objects.setRoom(OBJ_TIMEBOMB, _scene->_currentSceneId);
+		break;
+
+	case 2:
+		_scene->_sequences.remove(_globals._sequenceIndexes[6]);
+		_scene->_dynamicHotspots.remove(_timebombHotspotId);
+		_game._objects.addToInventory(OBJ_TIMEBOMB);
+		break;
+
+	case 3:
+		_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[5]);
+		_game._player._visible = true;
+		_game._player._stepEnabled = true;
+		if (_bombMode == 1) {
+			_vm->_dialogs->show(60421);
+			_globals[kTimebombStatus] = TIMEBOMB_ACTIVATED;
+			_globals[kTimebombTimer] = 0;
+		} else {
+			_vm->_dialogs->show(60423);
+			_globals[kTimebombStatus] = TIMEBOMB_DEACTIVATED;
+			_globals[kTimebombTimer] = 0;
+		}
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene604::actions() {
+	if (_action.isAction(0x325, 0x324)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			break;
+
+		case 1: {
+			int syncIdx = _globals._sequenceIndexes[2];
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], syncIdx);
+			_scene->_sequences.addTimer(6, 2);
+			}
+			break;
+
+		case 2:
+			_game._player._visible = false;
+			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 10, 1, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+			break;
+
+		case 3: {
+			int syncIdx = _globals._sequenceIndexes[4];
+			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, -2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], syncIdx);
+			_scene->_nextSceneId = 504;
+			}
+			break;
+
+		default:
+			break;
+		}
+	} else if ((_action.isAction(VERB_PUT, 0x3F6) || _action.isAction(VERB_PUT, 0x181) || _action.isAction(VERB_THROW, 0x181))
+		&& (_action.isAction(0x2A) || _action.isAction(0x2B)))
+		_vm->_dialogs->show(60420);
+	else if (_action.isAction(VERB_PUT, 0x171, 0x3F6) || _action.isAction(VERB_PUT, 0x171, 0x181)) {
+		_bombMode = 1;
+		if ((_game._difficulty == DIFFICULTY_HARD) || _globals[kWarnedFloodCity])
+			handleBombActions();
+		else if ((_game._objects.isInInventory(OBJ_POLYCEMENT) && _game._objects.isInInventory(OBJ_CHICKEN))
+			 && ((_globals[kLineStatus] == LINE_TIED) || ((_game._difficulty == DIFFICULTY_EASY) && (!_globals[kBoatRaised]))))
+			handleBombActions();
+		else if (_game._difficulty == DIFFICULTY_EASY)
+			_vm->_dialogs->show(60424);
+		else {
+			_vm->_dialogs->show(60425);
+			_globals[kWarnedFloodCity] = true;
+		}
+	} else if (_action.isAction(VERB_TAKE, 0x171)) {
+		if (_game._trigger || !_game._objects.isInInventory(OBJ_TIMEBOMB)) {
+			_bombMode = 2;
+			handleBombActions();
+		}
+	} else if (_action._lookFlag)
+		_vm->_dialogs->show(60411);
+	else if (_action.isAction(VERB_LOOK, 0x181)) {
+		if (_monsterActive) {
+			_vm->_dialogs->show(60413);
+		} else {
+			_vm->_dialogs->show(60412);
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x18D))
+		_vm->_dialogs->show(60414);
+	else if (_action.isAction(VERB_LOOK, 0x3F4))
+		_vm->_dialogs->show(60415);
+	else if (_action.isAction(VERB_LOOK, 0x479))
+		_vm->_dialogs->show(60416);
+	else if (_action.isAction(VERB_LOOK, 0x3F2))
+		_vm->_dialogs->show(60417);
+	else if (_action.isAction(VERB_LOOK, 0x324))
+		_vm->_dialogs->show(60418);
+	else if (_action.isAction(VERB_LOOK, 0x3C4))
+		_vm->_dialogs->show(60419);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes6.h b/engines/mads/nebular/nebular_scenes6.h
index cf69f59..c32daa4 100644
--- a/engines/mads/nebular/nebular_scenes6.h
+++ b/engines/mads/nebular/nebular_scenes6.h
@@ -11,7 +11,7 @@
 
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
 
  * You should have received a copy of the GNU General Public License
@@ -98,6 +98,30 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene604: public Scene6xx{
+private:
+	int _timebombHotspotId;
+	int _bombMode;
+	int _monsterFrame;
+
+	uint32 _monsterTimer;
+
+	bool _monsterActive;
+	bool _animationActiveFl;
+
+	void handleBombActions();
+
+public:
+	Scene604(MADSEngine *vm) : Scene6xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 3b098867961e4d34fc93cac989d3bd5f69f71ed8
    https://github.com/scummvm/scummvm/commit/3b098867961e4d34fc93cac989d3bd5f69f71ed8
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-11T19:14:11+02:00

Commit Message:
MADS: Implement scene 605

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes6.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index d729202..511be8e 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -233,7 +233,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 604:	// viewport
 		return new Scene604(vm);
 	case 605:	// viewport closeup
-		return new DummyScene(vm);	// TODO
+		return new Scene605(vm);
 	case 607:	// outside Abdul's garage
 		return new DummyScene(vm);	// TODO
 	case 608:	// inside Abdul's garage
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index 6482eb1..ebface6 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -939,5 +939,51 @@ void Scene604::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene605::setup() {
+	_game._player._spritesPrefix = "";
+	setAAName();
+}
+
+void Scene605::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('r', -1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('b', -1));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('l', -1));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('p', -1));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('n', -1));
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('f', -1));
+
+	_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 15, 0, 0, 0);
+	_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 17, 0, 0, 0);
+	_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 14, 0, 0, 0);
+	_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 13, 0, 0, 0);
+	_globals._sequenceIndexes[5] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], false, 17, 0, 0, 0);
+	_globals._sequenceIndexes[6] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[6], false, 18, 0, 0, 0);
+
+	_game._player._visible = false;
+	_game._player._stepEnabled = false;
+	_scene->_sequences.addTimer(600, 70);
+	_scene->_userInterface.setup(kInputLimitedSentences);
+	sceneEntrySound();
+	_vm->_sound->command(22);
+}
+
+void Scene605::step() {
+	if (_game._trigger == 70) {
+		_vm->_sound->command(23);
+		if (_globals[kResurrectRoom] >= 700)
+			_vm->_dialogs->show(60598);
+		else
+			_vm->_dialogs->show(60599);
+
+		_scene->_nextSceneId = _globals[kResurrectRoom];
+	}
+}
+
+void Scene605::actions() {
+	return;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes6.h b/engines/mads/nebular/nebular_scenes6.h
index c32daa4..9347b40 100644
--- a/engines/mads/nebular/nebular_scenes6.h
+++ b/engines/mads/nebular/nebular_scenes6.h
@@ -122,6 +122,17 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene605: public Scene6xx{
+public:
+	Scene605(MADSEngine *vm) : Scene6xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: e21534ecc2d39864d2cb3ba67248ad0dadecf72e
    https://github.com/scummvm/scummvm/commit/e21534ecc2d39864d2cb3ba67248ad0dadecf72e
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-11T23:50:52+02:00

Commit Message:
MADS: Implement scene 607

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes6.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 511be8e..7c5700a 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -235,7 +235,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 605:	// viewport closeup
 		return new Scene605(vm);
 	case 607:	// outside Abdul's garage
-		return new DummyScene(vm);	// TODO
+		return new Scene607(vm);
 	case 608:	// inside Abdul's garage
 		return new DummyScene(vm);	// TODO
 	case 609:	// outside Buckluster video store
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index ebface6..46ef066 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -820,7 +820,7 @@ void Scene604::handleBombActions() {
 
 	case 1:
 		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, -1);
-		_timebombHotspotId = _scene->_dynamicHotspots.add (0x171, VERB_WALKTO, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
+		_timebombHotspotId = _scene->_dynamicHotspots.add(0x171, VERB_WALKTO, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(_timebombHotspotId, Common::Point(166, 118), FACING_NORTHEAST);
 		_game._objects.setRoom(OBJ_TIMEBOMB, _scene->_currentSceneId);
 		break;
@@ -985,5 +985,438 @@ void Scene605::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene607::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x471);
+	_scene->addActiveVocab(VERB_WALKTO);
+}
+
+void Scene607::enter() {
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('c', 0));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RXCD_3");
+
+	if (!_game._visitedScenes._sceneRevisited && (_scene->_priorSceneId != 608))
+		_globals[kDogStatus] = 1;
+
+	if ((_scene->_priorSceneId == 608) && (_globals[kDogStatus] < 3))
+		_globals[kDogStatus] = 3;
+
+	_animationActive = 0;
+
+	if ((_globals[kDogStatus] == 1) && (_game._difficulty != DIFFICULTY_EASY)) {
+		_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('g', 3));
+		_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('g', 7));
+		_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('g', 0));
+
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 6);
+		_dogBarking = false;
+		_dogLoop = false;
+		_shopAvailable = false;
+		_dogEatsRex = false;
+		_dogTimer = 0;
+	} else
+		_scene->_hotspots.activate(0x471, false);
+
+	_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+
+	if (_scene->_priorSceneId == 608) { 
+		_game._player._playerPos = Common::Point(297, 50); 
+		_game._player._facing = FACING_SOUTHEAST;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(40, 104);
+		_game._player._facing = FACING_SOUTHEAST; 
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+		_scene->loadAnimation(formAnimName('R', 1), 80);
+	} else if (_globals[kDogStatus] == 2) {
+		_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('g', 3));
+		_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('g', 7));
+		_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('g', 0));
+	} 
+
+	sceneEntrySound();
+
+	if (_scene->_roomChanged)
+		_game._objects.addToInventory(OBJ_BONES); 
+
+	_vm->_palette->setEntry(252, 63, 44, 30);
+	_vm->_palette->setEntry(253, 63, 20, 22);
+	_game.loadQuoteSet(0x2F8, 0x2F7, 0x2F6, 0x2F9, 0x2FA, 0);
+}
+
+void Scene607::step() {
+	if (_globals[kDogStatus] == 2) {
+		int32 diff = _scene->_frameStartTime - _lastFrameTime;
+		if ((diff >= 0) && (diff <= 4))
+			_dogTimer += diff;
+		else
+			_dogTimer++;
+
+		_lastFrameTime = _scene->_frameStartTime;
+	}
+
+	if ((_dogTimer >= 480) && !_dogLoop && !_shopAvailable && (_globals[kDogStatus] == 2) && !_game._player._special) {
+		_vm->_sound->command(14);
+		_dogLoop = true;
+		_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 10, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 91);
+		_dogLoop = false;
+		_dogTimer = 0;
+	}
+
+	if (_game._trigger == 91) { 
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 6);
+		_dogBarking = false;
+		_globals[kDogStatus] = 1;
+		_scene->_hotspots.activate(0x471, true);
+	} 
+
+	if (!_dogEatsRex && (_game._difficulty != DIFFICULTY_EASY) && !_animationActive && (_globals[kDogStatus] == 1)
+	 && !_dogBarking && (_vm->getRandomNumber(1, 50) == 10)) {
+		_dogBarking = true;
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]); 
+		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 5, 8, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 6);
+		_scene->_kernelMessages.reset();
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_SPRITE, 2, 100);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
+		_counter = 0;
+	}
+
+	if ((_game._trigger == 70) && !_dogEatsRex && (_globals[kDogStatus] == 1) && !_animationActive) {
+		int syncIdx = _globals._sequenceIndexes[1];
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 6);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[1], syncIdx);
+		_scene->_kernelMessages.reset();
+		_dogBarking = false;
+	}
+
+	if (_game._trigger == 100) {
+		_counter++;
+		_vm->_sound->command(12);
+
+		if ((_counter >= 1) && (_counter <= 4)) {
+			Common::Point pos(0, 0);
+			switch (_counter) {
+			case 1:
+				pos = Common::Point(237, 5);
+				break;
+
+			case 2:
+				pos = Common::Point(270, 15);
+				break;
+
+			case 3:
+				pos = Common::Point(237, 25);
+				break;
+
+			case 4:
+				pos = Common::Point(270, 36);
+				break;
+
+			default:
+				break;
+			}
+			_scene->_kernelMessages.add(pos, 0xFDFC, 0, 0, 120, _game.getQuote(0x2F9));
+		}
+	}
+
+	if (_game._player._moving && (_game._difficulty != DIFFICULTY_EASY) && !_shopAvailable && (_globals[kDogStatus] == 1) && (_scene->_rails.getNext() > 0)) {
+		_game._player.cancelCommand();
+		_game._player.startWalking(Common::Point(268, 72), FACING_NORTHEAST);
+		_scene->_rails.resetNext();
+	}
+
+	if ((_game._player._special > 0) && (_game._difficulty != DIFFICULTY_EASY) && (_globals[kDogStatus] == 1) && _game._player._stepEnabled)
+		_game._player._stepEnabled = false;
+
+	if ((_game._difficulty != DIFFICULTY_EASY) && (_globals[kDogStatus] == 1) && (_game._player._playerPos == Common::Point(268, 72))
+	 && (_game._trigger || !_dogEatsRex)) {
+		_dogEatsRex = true;
+		switch (_game._trigger) {
+		case 91: 
+		case 0:
+			_animationActive = 1;
+			_game._player._visible = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 10, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], -1, 7); 
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x2FA));
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 60);
+			_scene->_sequences.addTimer(10, 64);
+			break;
+
+		case 60: {
+			int syncIdx = _globals._sequenceIndexes[4];
+			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 5, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 8, 45); 
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], syncIdx);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 61);
+			}
+			break;
+
+		case 61: {
+			int syncIdx = _globals._sequenceIndexes[4];
+			_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 15, 3, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 46, -2); 
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], syncIdx);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 62);
+			}
+			break;
+
+		case 62: {
+			int syncIdx = _globals._sequenceIndexes[4];
+			_animationActive = 2;
+			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, -2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], syncIdx);
+			_scene->_sequences.addTimer(60, 63);
+			}
+			break;
+
+		case 63:
+			_vm->_dialogs->show(60729);
+			_animationActive = 0;
+			_dogEatsRex = false;
+			_scene->_reloadSceneFlag = true;
+			_game._player._stepEnabled = true;
+			break;
+
+		case 64:
+			if (_dogEatsRex && (_animationActive == 1)) {
+				_vm->_sound->command(12);
+				_scene->_sequences.addTimer(10, 64);
+			}
+			break;
+
+		default:
+			break;
+		}
+	}
+
+	switch (_game._trigger) {
+	case 80:
+		_game._player._visible = true;
+		_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
+		_scene->_sequences.addTimer(6, 81);
+		break;
+
+	case 81:
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 82);
+		break; 
+
+	case 82:
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2); 
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+		_game._player._stepEnabled = true;
+		break; 
+
+	default:
+		break;
+	}
+}
+
+void Scene607::handleThrowingBone() {
+	_animationActive = -1;
+	switch (_game._trigger) {
+	case 0:
+		_game._player._stepEnabled = false;
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_game._player._visible = false; 
+		_scene->loadAnimation(formAnimName('D', _animationMode), 1);
+		break;
+
+	case 1:
+		_game._player._visible = true; 
+		_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
+
+		if (_animationMode != 1)
+			_scene->_hotspots.activate(0x471, false);
+		else {
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 6);
+		}
+
+		_dogBarking = false;
+		if (_game._objects.isInInventory(OBJ_BONE)) {
+			_game._objects.setRoom(OBJ_BONE, NOWHERE);
+			if (_animationMode == 1)
+				_globals[kBone202Status] = 0;
+		} else { 
+			_game._objects.setRoom(OBJ_BONES, NOWHERE);
+			_game._objects.addToInventory(OBJ_BONE);
+		}
+
+		_scene->_sequences.addTimer(60, 2);
+		break;
+
+	case 2: {
+		int quoteId = 0x2F8;
+		if (_animationMode == 1)
+			quoteId = 0x2F7; 
+
+		if (_animationMode == 2) {
+			_globals[kDogStatus] = 2;
+			_dogTimer = 0;
+		}
+
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(quoteId));
+		_scene->_sequences.addTimer(60, 3);
+		}
+		break;
+
+	case 3:
+		_game._player._stepEnabled = true;
+		_animationActive = 0;
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene607::preActions() {
+	if (_action.isAction(VERB_TALKTO, 0x471))
+		_game._player._needToWalk = false;
+
+	if (_action.isAction(0x18B, 0x478) && (_globals[kDogStatus] == 2) && (_game._difficulty != DIFFICULTY_EASY)) {
+		_shopAvailable = true;
+		_dogTimer = 0;
+	} 
+
+	if (_action.isAction(VERB_THROW, 0x2D, 0x471) || _action.isAction(VERB_THROW, 0x2C, 0x471))
+		_game._player.walk(Common::Point(193, 100), FACING_NORTHEAST);
+
+	if (_action.isAction(VERB_THROW, 0x2D, 0x2C3) || _action.isAction(VERB_THROW, 0x2C, 0x2C3))
+		_game._player.walk(Common::Point(201, 107), FACING_SOUTHEAST);
+}
+
+void Scene607::actions() {
+	if (_action.isAction(0x18B, 0x478))
+		_scene->_nextSceneId = 608;
+	else if (_action.isAction(0x325, 0x324)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			break;
+
+		case 1: {
+			int syncIdx = _globals._sequenceIndexes[2];
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1); 
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], syncIdx);
+			_scene->_sequences.addTimer(6, 2);
+			}
+			break;
+
+		case 2:
+			_game._player._visible = false;
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 10, 1, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+			break;
+
+		case 3: {
+			int syncIdx = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], syncIdx); 
+			_scene->_nextSceneId = 504;
+			}
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(VERB_THROW, 0x2D, 0x471) || _action.isAction(VERB_THROW, 0x2C, 0x471)) {
+		if (_game._difficulty != DIFFICULTY_EASY) {
+			_animationMode = 1;
+			_scene->_kernelMessages.reset();
+			if (_game._trigger == 0)
+				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x2F6));
+
+			handleThrowingBone();
+		}
+	} else if ((_action.isAction(VERB_THROW, 0x2D, 0x2C3) || _action.isAction(VERB_THROW, 0x2C, 0x2C3)) && (_game._difficulty != DIFFICULTY_EASY)
+		 && ((_globals[kDogStatus] == 1) || _game._trigger)) {
+		_animationMode = 2;
+		if (_game._trigger == 0) {
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x2F6));
+		} 
+		handleThrowingBone();
+	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x31E)) {
+		if ((_globals[kDogStatus] == 1) || (_game._difficulty == DIFFICULTY_EASY))
+			_vm->_dialogs->show(60710);
+		else
+			_vm->_dialogs->show(60711);
+	} else if (_action.isAction(VERB_LOOK, 0x18D))
+		_vm->_dialogs->show(60712);
+	else if (_action.isAction(VERB_LOOK, 0x2C3))
+		_vm->_dialogs->show(60713);
+	else if (_action.isAction(VERB_LOOK, 0x324))
+		_vm->_dialogs->show(60714);
+	else if (_action.isAction(VERB_LOOK, 0x3FB))
+		_vm->_dialogs->show(60715);
+	else if (_action.isAction(VERB_LOOK, 0x1E6) && (_globals[kDogStatus] == 1))
+		_vm->_dialogs->show(60716);
+	else if (_action.isAction(VERB_LOOK, 0x244))
+		_vm->_dialogs->show(60717);
+	else if (_action.isAction(VERB_LOOK, 0x3FD))
+		_vm->_dialogs->show(60718);
+	else if (_action.isAction(VERB_LOOK, 0x3FF))
+		_vm->_dialogs->show(60719);
+	else if (_action.isAction(VERB_LOOK, 0x31D))
+		_vm->_dialogs->show(60720);
+	else if (_action.isAction(VERB_LOOK, 0x3F9))
+		_vm->_dialogs->show(60721);
+	else if (_action.isAction(VERB_LOOK, 0x3FA)) {
+		if (_globals[kDogStatus] == 1)
+			_vm->_dialogs->show(60723);
+		else
+			_vm->_dialogs->show(60722);
+	} else if (_action.isAction(VERB_LOOK, 0x478)) {
+		if (_globals[kDogStatus] == 1)
+			_vm->_dialogs->show(60725);
+		else
+			_vm->_dialogs->show(60724);
+	} else if (_action.isAction(VERB_LOOK, 0x471))
+		_vm->_dialogs->show(60726);
+	else if (_action.isAction(VERB_TALKTO, 0x471))
+		_vm->_dialogs->show(60727);
+	else if (_action.isAction(VERB_LOOK, 0x31F))
+		_vm->_dialogs->show(60728);
+	else if (_action.isAction(0x1AD, 0x31E))
+		_vm->_dialogs->show(60730);
+	else if (_action.isAction(0x3FF) && (_action.isAction(VERB_OPEN) || _action.isAction(VERB_PUSH) || _action.isAction(VERB_PULL)))
+		_vm->_dialogs->show(60731);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes6.h b/engines/mads/nebular/nebular_scenes6.h
index 9347b40..0f7e776 100644
--- a/engines/mads/nebular/nebular_scenes6.h
+++ b/engines/mads/nebular/nebular_scenes6.h
@@ -133,6 +133,33 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene607: public Scene6xx{
+private:
+	uint32 _dogTimer;
+	uint32 _lastFrameTime;
+
+	bool _dogLoop;
+	bool _dogEatsRex;
+	bool _dogBarking;
+	bool _shopAvailable;
+
+	int _animationMode;
+	int _animationActive;
+	int _counter;
+
+	void handleThrowingBone();
+
+public:
+	Scene607(MADSEngine *vm) : Scene6xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 8abcbf3fb08fbca6f0cfdb9eabd22cf56e83b440
    https://github.com/scummvm/scummvm/commit/8abcbf3fb08fbca6f0cfdb9eabd22cf56e83b440
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-11T18:08:31-04:00

Commit Message:
MADS: Refactoring of dialog classes, more implementation of PictureDialog

Changed paths:
    engines/mads/dialogs.cpp
    engines/mads/dialogs.h
    engines/mads/msurface.cpp
    engines/mads/msurface.h
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/dialogs_nebular.h



diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index e68411a..3ea47c4 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -34,22 +34,20 @@ Dialog::Dialog(MADSEngine *vm): _vm(vm), _savedSurface(nullptr),
 }
 
 Dialog::~Dialog() {
-	restore(&_vm->_screen);
 }
 
-
-void Dialog::save(MSurface *s) {
+void Dialog::save() {
 	_savedSurface = new MSurface(_width, _height);
-	s->copyTo(_savedSurface,
+	_vm->_screen.copyTo(_savedSurface,
 		Common::Rect(_position.x, _position.y, _position.x + _width, _position.y + _height),
 		Common::Point());
 
 	_vm->_screen.copyRectToScreen(getBounds());
 }
 
-void Dialog::restore(MSurface *s) {
+void Dialog::restore() {
 	if (_savedSurface) {
-		_savedSurface->copyTo(s, _position);
+		_savedSurface->copyTo(&_vm->_screen, _position);
 		delete _savedSurface;
 		_savedSurface = nullptr;
 
@@ -58,8 +56,11 @@ void Dialog::restore(MSurface *s) {
 }
 
 void Dialog::draw() {
+	// Calculate the dialog positioning
+	calculateBounds();
+
 	// Save the screen portion the dialog will overlap
-	save(&_vm->_screen);
+	save();
 
 	// Draw the dialog
 	// Fill entire content of dialog
@@ -82,6 +83,9 @@ void Dialog::draw() {
 		TEXTDIALOG_CONTENT1, TEXTDIALOG_CONTENT2);
 }
 
+void Dialog::calculateBounds() {
+}
+
 void Dialog::drawContent(const Common::Rect &r, int seed, byte color1, byte color2) {
 	uint16 currSeed = seed ? seed : 0xB78E;
 
@@ -259,16 +263,7 @@ void TextDialog::draw() {
 		--_numLines;
 
 	// Figure out the size and position for the dialog
-	_height = (_font->getHeight() + 1) * (_numLines + 1) + 10;
-	if (_position.x == -1)
-		_position.x = 160 - (_width / 2);
-	if (_position.y == -1)
-		_position.y = 100 - (_height / 2);
-
-	if ((_position.x + _width) > _vm->_screen.getWidth())
-		_position.x = _vm->_screen.getWidth() - (_position.x + _width);
-	if ((_position.y + _height) > _vm->_screen.getHeight())
-		_position.y = _vm->_screen.getHeight() - (_position.y + _height);
+	calculateBounds();
 
 	// Draw the underlying dialog
 	Dialog::draw();
@@ -305,6 +300,19 @@ void TextDialog::draw() {
 	_vm->_screen.copyRectToScreen(getBounds());
 }
 
+void TextDialog::calculateBounds() {
+	_height = (_font->getHeight() + 1) * (_numLines + 1) + 10;
+	if (_position.x == -1)
+		_position.x = 160 - (_width / 2);
+	if (_position.y == -1)
+		_position.y = 100 - (_height / 2);
+
+	if ((_position.x + _width) > _vm->_screen.getWidth())
+		_position.x = _vm->_screen.getWidth() - (_position.x + _width);
+	if ((_position.y + _height) > _vm->_screen.getHeight())
+		_position.y = _vm->_screen.getHeight() - (_position.y + _height);
+}
+
 void TextDialog::drawWithInput() {
 	//int innerWidth = _innerWidth;
 	//int lineHeight = _font->getHeight() + 1;
@@ -325,6 +333,7 @@ void TextDialog::restorePalette() {
 }
 
 void TextDialog::show() {
+	// Draw the dialog
 	draw();
 	_vm->_events->showCursor();
 
@@ -338,6 +347,9 @@ void TextDialog::show() {
 		_vm->_events->waitForNextFrame();
 		_vm->_events->_pendingKeys.clear();
 	}
+
+	// Restore the background
+	restore();
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index d06611b..aa63576 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -40,15 +40,13 @@ protected:
 
 	/**
 	 * Save the section of the passed surface the dialog will cover.
-	 * @param s		Screen surface to save
 	 */
-	void save(MSurface *s);
+	virtual void save();
 
 	/**
 	 * Restore saved dialog surface
-	 * @param s		Screen surface to restore to.
 	 */
-	void restore(MSurface *s);
+	virtual void restore();
 
 	/**
 	 * Draws the content of a dialog with a gravelly alternating color.
@@ -59,6 +57,11 @@ protected:
 	 * Draw the dialog
 	 */
 	virtual void draw();
+
+	/**
+	 * Calculate bounds for the dialog
+	 */
+	virtual void calculateBounds();
 public:
 	/**
 	 * Constructor
@@ -115,6 +118,11 @@ protected:
 	Common::String _lines[TEXT_DIALOG_MAX_LINES];
 	int _lineXp[TEXT_DIALOG_MAX_LINES];
 	byte _cyclingPalette[8 * 3];
+
+	/**
+	 * Calculate the bounds for the dialog
+	 */
+	virtual void calculateBounds();
 public:
 	/**
 	 * Constructor
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 5d1e948..4fae799 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -494,6 +494,16 @@ void MSurface::translate(Common::Array<RGB6> &palette) {
 	}
 }
 
+void MSurface::translate(byte map[PALETTE_COUNT]) {
+	for (int y = 0; y < this->h; ++y) {
+		byte *pDest = getBasePtr(0, y);
+
+		for (int x = 0; x < this->w; ++x, ++pDest) {
+				*pDest = map[*pDest];
+		}
+	}
+}
+
 MSurface *MSurface::flipHorizontal() const {
 	MSurface *dest = new MSurface(this->w, this->h);
 
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index 060a7ab..fbd9270 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -205,6 +205,11 @@ public:
 	void translate(Common::Array<RGB6> &palette);
 
 	/**
+	* Translates the pixels of an image used the passed palette with RGB mapping
+	*/
+	void translate(byte map[PALETTE_COUNT]);
+
+	/**
 	 * Create a new surface which is a flipped horizontal copy of the current one
 	 */
 	MSurface *flipHorizontal() const;
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 6ddb323..2e020f3 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -171,20 +171,6 @@ void DialogsNebular::showItem(int objectId, int messageId, int speech) {
 	assert(!speech);
 
 	show(messageId, objectId);
-#if 0
-	Scene &scene = _vm->_game->_scene;
-	byte highPalette[8 * 3];
-	Common::copy(&_vm->_palette->_mainPalette[0x2E8], &_vm->_palette->_mainPalette[PALETTE_SIZE],
-		&highPalette[0]);
-	byte *depthP = scene._depthSurface.getData();
-	byte greyScale[3];
-	greyScale[0] = greyScale[1] = greyScale[2] = 0xFFFF;
-	Common::String setName = Common::String::format("*OBJ%.3d.SS", objectId);
-
-
-
-	delete[] savedSurface;
-#endif
 }
 
 Common::String DialogsNebular::getVocab(int vocabId) {
@@ -211,7 +197,7 @@ Common::String DialogsNebular::getVocab(int vocabId) {
 
 bool DialogsNebular::textNoun(Common::String &dialogText, int nounNum,
 		const Common::String &valStr) {
-	warning("TODO: textNoun");
+	error("TODO: textNoun");
 	return false;
 }
 
@@ -337,12 +323,25 @@ bool CopyProtectionDialog::getHogAnusEntry(HOGANUS &entry) {
 PictureDialog::PictureDialog(MADSEngine *vm, const Common::Point &pos,
 		int maxChars, int objectId) :
 		TextDialog(vm, FONT_INTERFACE, pos, maxChars), _objectId(objectId) {
-	Scene &scene = _vm->_game->_scene;
-	Palette &palette = *_vm->_palette;
-
 	// Turn off cycling if active
+	Scene &scene = _vm->_game->_scene;
 	_cyclingActive = scene._cyclingActive;
 	scene._cyclingActive = false;
+}
+
+PictureDialog::~PictureDialog() {
+	// Restore cycling flag
+	Scene &scene = _vm->_game->_scene;
+	scene._cyclingActive = _cyclingActive;
+}
+
+void PictureDialog::save() {
+	Palette &palette = *_vm->_palette;
+	byte map[PALETTE_COUNT];
+
+	// Save the entire screen
+	_savedSurface = new MSurface(MADS_SCREEN_WIDTH, MADS_SCREEN_HEIGHT);
+	_vm->_screen.copyTo(_savedSurface);
 
 	// Save palette information
 	Common::copy(&palette._mainPalette[0], &palette._mainPalette[PALETTE_SIZE], &_palette[0]);
@@ -358,34 +357,43 @@ PictureDialog::PictureDialog(MADSEngine *vm, const Common::Point &pos,
 
 	// Reset the flag list
 	palette._rgbList.reset();
-}
 
-PictureDialog::~PictureDialog() {
-	// Restore cycling flag
-	Scene &scene = _vm->_game->_scene;
-	Palette &palette = *_vm->_palette;
-	scene._cyclingActive = _cyclingActive;
+	// Fade the screen to grey
+	int numColors = PALETTE_COUNT - PALETTE_RESERVED_LOW_COUNT - PALETTE_RESERVED_HIGH_COUNT;
+	palette.fadeToGrey(palette._mainPalette, &map[PALETTE_RESERVED_LOW_COUNT],
+		PALETTE_RESERVED_LOW_COUNT, numColors, 248, 8, 1, 16);
 
-	// Restore palette information
-	Common::copy(&_palette[0], &_palette[PALETTE_SIZE], &palette._mainPalette[0]);
-	_vm->_palette->setFullPalette(palette._mainPalette);
-	Common::copy(&_palFlags[0], &_palFlags[PALETTE_COUNT], &palette._palFlags[0]);
-	palette._rgbList.copy(_rgbList);
-}
+	// Remap the greyed out screen to use the small greyscale range
+	// at the top end of the palette
+	_vm->_screen.translate(map);
 
-void PictureDialog::show() {
-	setupPalette();
+	// Load the inventory picture
+	Common::String setName = Common::String::format("*OB%.3d.SS", _objectId);
+	SpriteAsset *asset = new SpriteAsset(_vm, setName, 0x8000);
+	palette.setFullPalette(palette._mainPalette);
 
-	TextDialog::show();
+	// Draw the inventory picture
+	MSprite *frame = asset->getFrame(0);
+	frame->copyTo(&_vm->_screen, Common::Point(160 - frame->w / 2, 6),
+		frame->getTransparencyIndex());
+	_vm->_screen.copyRectToScreen(_vm->_screen.getBounds());
 }
 
-void PictureDialog::setupPalette() {
-	Palette &palette = *_vm->_palette;
-	byte map[PALETTE_COUNT];
+void PictureDialog::restore() {
+	if (_savedSurface) {
+		_savedSurface->copyTo(&_vm->_screen);
+		delete _savedSurface;
+		_savedSurface = nullptr;
 
-	int numColors = PALETTE_COUNT - PALETTE_RESERVED_LOW_COUNT - PALETTE_RESERVED_HIGH_COUNT;
-	palette.fadeToGrey(palette._mainPalette, &map[PALETTE_RESERVED_LOW_COUNT],
-		PALETTE_RESERVED_LOW_COUNT, numColors, 248, 8, 1, 16);
+		_vm->_screen.copyRectToScreen(_vm->_screen.getBounds());
+
+		// Restore palette information
+		Palette &palette = *_vm->_palette;
+		Common::copy(&_palette[0], &_palette[PALETTE_SIZE], &palette._mainPalette[0]);
+		_vm->_palette->setFullPalette(palette._mainPalette);
+		Common::copy(&_palFlags[0], &_palFlags[PALETTE_COUNT], &palette._palFlags[0]);
+		palette._rgbList.copy(_rgbList);
+	}
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index fd4d6e7..60a2151 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -89,17 +89,14 @@ private:
 	byte _palette[PALETTE_SIZE];
 	uint32 _palFlags[PALETTE_COUNT];
 	RGBList _rgbList;
+protected:
+	virtual void save();
 
-	/**
-	 * Sets up the palette and fades the screen to gray
-	 */
-	void setupPalette();
+	virtual void restore();
 public:
 	PictureDialog(MADSEngine *vm, const Common::Point &pos, int maxChars, int objectId);
 
 	virtual ~PictureDialog();
-
-	virtual void show();
 };
 
 enum DialogTextAlign { ALIGN_CENTER = -1, ALIGN_AT_CENTER = -2, ALIGN_RIGHT = -3 };


Commit: 991096d01ed0befa2b56beea4091de9d04aafaac
    https://github.com/scummvm/scummvm/commit/991096d01ed0befa2b56beea4091de9d04aafaac
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-12T00:21:33+02:00

Commit Message:
MADS: Implement scene 620

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes6.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 7c5700a..4cbcb81 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -247,7 +247,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 612:	// expressway / maintenance building
 		return new DummyScene(vm);	// TODO
 	case 620:	// cutscene, viewport glass breaking
-		return new DummyScene(vm);	// TODO
+		return new Scene620(vm);
 
 	// Scene group #7 (submerged men's city / upper floor)
 	case 701:	// outside elevator (after city is submerged)
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index 46ef066..8cda6ed 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -1418,5 +1418,57 @@ void Scene607::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene620::setup() {
+	_game._player._spritesPrefix = "";
+	setAAName();
+}
+
+void Scene620::enter() {
+	_globals._spriteIndexes[1]  = _scene->_sprites.addSprites(formAnimName('b', 0));
+	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
+	_game._player._stepEnabled = false;
+	_game._player._visible   = false;
+	_scene->_sequences.addTimer(30, 70);
+	_scene->_userInterface.setup(kInputLimitedSentences);
+	sceneEntrySound();
+}
+
+void Scene620::step() {
+	switch (_game._trigger) {
+	case 70: 
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_scene->loadAnimation(formAnimName('E', -1), 71);
+		break;
+
+	case 71:
+		if (_scene->_priorSceneId == 751) {
+			_globals[kCityFlooded] = true;
+			_globals[kTeleporterRoom + 5] = 0;
+			_scene->_nextSceneId = 701;
+		} else if (_scene->_priorSceneId == 752) { 
+			_globals[kCityFlooded] = true;
+			_globals[kTeleporterRoom + 5] = 0;
+			_scene->_nextSceneId = 702;
+		} else if (_scene->_priorSceneId < 501 || _scene->_priorSceneId > 752) {
+			_globals[kCityFlooded] = true;
+			_globals[kTeleporterRoom + 5] = 0;
+			_scene->_nextSceneId = _scene->_priorSceneId;
+		} else if (_scene->_priorSceneId >= 501 && _scene->_priorSceneId <= 612) {
+			_globals[kResurrectRoom] = _globals[kHoverCarLocation];
+			_game._objects.addToInventory(OBJ_TIMEBOMB);  
+			_globals[kTimebombStatus] = 0;
+			_globals[kTimebombTimer] = 0;
+			_scene->_nextSceneId = 605;
+		}
+		_game._player._stepEnabled = true;
+		break;
+
+	default:
+		break;
+	}
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes6.h b/engines/mads/nebular/nebular_scenes6.h
index 0f7e776..69db9eb 100644
--- a/engines/mads/nebular/nebular_scenes6.h
+++ b/engines/mads/nebular/nebular_scenes6.h
@@ -160,6 +160,18 @@ public:
 	virtual void actions();
 	virtual void postActions() {};
 };
+
+class Scene620: public Scene6xx{
+public:
+	Scene620(MADSEngine *vm) : Scene6xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions() {};
+	virtual void postActions() {};
+};
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: 5e13514d28df811dfcd4f1829b327ce8606ed5ee
    https://github.com/scummvm/scummvm/commit/5e13514d28df811dfcd4f1829b327ce8606ed5ee
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-11T19:56:31-04:00

Commit Message:
MADS: Fix hiding the status text when doing actions

Changed paths:
    engines/mads/action.cpp
    engines/mads/nebular/dialogs_nebular.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 88a57d6..e959395 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -75,6 +75,7 @@ void MADSAction::clear() {
 	_articleNumber = 0;
 	_lookFlag = false;
 	_pointEstablished = 0;
+	_statusText.clear();
 	_selectedRow = -1;
 	_hotspotId = -1;
 	_secondObject = -1;
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 2e020f3..8b6418e 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -393,6 +393,8 @@ void PictureDialog::restore() {
 		_vm->_palette->setFullPalette(palette._mainPalette);
 		Common::copy(&_palFlags[0], &_palFlags[PALETTE_COUNT], &palette._palFlags[0]);
 		palette._rgbList.copy(_rgbList);
+
+		_vm->_dialogs->_defaultPosition.y = -1;
 	}
 }
 


Commit: 604bca43de0c19e64689ce6e12ad3f854549100c
    https://github.com/scummvm/scummvm/commit/604bca43de0c19e64689ce6e12ad3f854549100c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-11T22:41:01-04:00

Commit Message:
MADS: Implement the dialog textNoun method

Changed paths:
    engines/mads/dialogs.h
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/dialogs_nebular.h



diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index aa63576..078415b 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -220,7 +220,7 @@ public:
 
 	virtual void showDialog() = 0;
 	virtual void showItem(int objectId, int messageId, int speech = 0) = 0;
-
+	virtual Common::String getVocab(int vocabId) = 0;
 	virtual bool show(int messageId, int objectId = -1) = 0;
 };
 
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 8b6418e..ff2249a 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -195,10 +195,49 @@ Common::String DialogsNebular::getVocab(int vocabId) {
 	return vocab;
 }
 
-bool DialogsNebular::textNoun(Common::String &dialogText, int nounNum,
-		const Common::String &valStr) {
-	error("TODO: textNoun");
-	return false;
+bool DialogsNebular::textNoun(Common::String &dest, int nounId, const Common::String &source) {
+	// Ensure the destination has parameter specifications
+	if (!source.hasPrefix(":"))
+		return false;
+
+	// Extract the first (singular) result value
+	Common::String param1 = Common::String(source.c_str() + 1);
+	Common::String param2;
+	const char *sepChar = strchr(source.c_str() + 1, ':');
+	if (sepChar) {
+		param1 = Common::String(source.c_str() + 1, sepChar);
+
+		// Get the second, plural form
+		param2 = Common::String(sepChar + 1);
+	}
+
+	// Get the vocab to use
+	MADSAction &action = _vm->_game->_scene._action;
+	Common::String vocab = _vm->_dialogs->getVocab(action._activeAction._verbId);
+	Common::String *str;
+
+	if (vocab.hasSuffix("s") || vocab.hasSuffix("S")) {
+		str = &param2;
+	} else {
+		str = &param1;
+
+		if (param1 == "a ") {
+			switch (toupper(vocab[0])) {
+			case 'A':
+			case 'E':
+			case 'I':
+			case 'O':
+			case 'U':
+				param1 = "an ";
+				break;
+			default:
+				break;
+			}
+		}
+	}
+
+	dest += *str;
+	return true;
 }
 
 bool DialogsNebular::commandCheck(const char *idStr, Common::String &valStr,
diff --git a/engines/mads/nebular/dialogs_nebular.h b/engines/mads/nebular/dialogs_nebular.h
index 60a2151..643d440 100644
--- a/engines/mads/nebular/dialogs_nebular.h
+++ b/engines/mads/nebular/dialogs_nebular.h
@@ -41,9 +41,9 @@ private:
 
 	DialogsNebular(MADSEngine *vm): Dialogs(vm) {}
 
-	Common::String getVocab(int vocabId);
+	virtual Common::String getVocab(int vocabId);
 
-	bool textNoun(Common::String &dialogText, int nounNum, const Common::String &valStr);
+	bool textNoun(Common::String &dest, int nounId, const Common::String &source);
 
 	bool commandCheck(const char *idStr, Common::String &valStr, const Common::String &command);
 public:


Commit: a0fcbeeb4faa8a12c2b68a6887ebbdae2b356239
    https://github.com/scummvm/scummvm/commit/a0fcbeeb4faa8a12c2b68a6887ebbdae2b356239
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-11T23:26:54-04:00

Commit Message:
MADS: Dialog positioning and UI shading fix for picture dialog

Changed paths:
    engines/mads/nebular/dialogs_nebular.cpp



diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index ff2249a..63b0edf 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -390,8 +390,13 @@ void PictureDialog::save() {
 	// Set up palette allocation
 	uint32 *palFlagP = &palette._palFlags[0];
 	for (int idx = 0; idx < PALETTE_COUNT; ++idx, ++palFlagP) {
-		*palFlagP = (idx < PALETTE_RESERVED_LOW_COUNT ||
-			idx >= (PALETTE_COUNT - PALETTE_RESERVED_HIGH_COUNT - 10)) ? 1 : 0;
+		if (idx < PALETTE_RESERVED_LOW_COUNT ||
+			idx >= (PALETTE_COUNT - PALETTE_RESERVED_HIGH_COUNT - 10)) {
+			*palFlagP = 1;
+			map[idx] = idx;
+		} else {
+			*palFlagP = 0;
+		}
 	}
 
 	// Reset the flag list
@@ -413,6 +418,8 @@ void PictureDialog::save() {
 
 	// Draw the inventory picture
 	MSprite *frame = asset->getFrame(0);
+	_position.y = frame->h + 12;
+
 	frame->copyTo(&_vm->_screen, Common::Point(160 - frame->w / 2, 6),
 		frame->getTransparencyIndex());
 	_vm->_screen.copyRectToScreen(_vm->_screen.getBounds());


Commit: 24243d57e6a3b6fc291b754339aa60e98a76592e
    https://github.com/scummvm/scummvm/commit/24243d57e6a3b6fc291b754339aa60e98a76592e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-11T23:57:01-04:00

Commit Message:
MADS: Fix dialog colors for PictureDialog class

Changed paths:
    engines/mads/dialogs.cpp
    engines/mads/dialogs.h
    engines/mads/nebular/dialogs_nebular.cpp



diff --git a/engines/mads/dialogs.cpp b/engines/mads/dialogs.cpp
index 3ea47c4..b1a0b53 100644
--- a/engines/mads/dialogs.cpp
+++ b/engines/mads/dialogs.cpp
@@ -31,6 +31,14 @@ namespace MADS {
 
 Dialog::Dialog(MADSEngine *vm): _vm(vm), _savedSurface(nullptr),
 		_position(Common::Point(-1, -1)), _width(0), _height(0) {
+	TEXTDIALOG_CONTENT1 = 0XF8;
+	TEXTDIALOG_CONTENT2 = 0XF9;
+	TEXTDIALOG_EDGE = 0XFA;
+	TEXTDIALOG_BACKGROUND = 0XFB;
+	TEXTDIALOG_FC = 0XFC;
+	TEXTDIALOG_FD = 0XFD;
+	TEXTDIALOG_FE = 0XFE;
+	TEXTDIALOG_BLACK = 0;
 }
 
 Dialog::~Dialog() {
@@ -52,6 +60,10 @@ void Dialog::restore() {
 		_savedSurface = nullptr;
 
 		_vm->_screen.copyRectToScreen(getBounds());
+
+		Common::copy(&_dialogPalette[0], &_dialogPalette[8 * 3],
+			&_vm->_palette->_mainPalette[248 * 3]);
+		_vm->_palette->setPalette(_vm->_palette->_mainPalette, 248, 8);
 	}
 }
 
@@ -62,6 +74,8 @@ void Dialog::draw() {
 	// Save the screen portion the dialog will overlap
 	save();
 
+	setDialogPalette();
+
 	// Draw the dialog
 	// Fill entire content of dialog
 	Common::Rect bounds = getBounds();
@@ -83,6 +97,20 @@ void Dialog::draw() {
 		TEXTDIALOG_CONTENT1, TEXTDIALOG_CONTENT2);
 }
 
+void Dialog::setDialogPalette() {
+	// Save the high end of the palette, and set up the entries for dialog display
+	Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3],
+		&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3 + 8 * 3],
+		&_dialogPalette[0]);
+	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_CONTENT1, 2, 0x90, 0x80);
+	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_EDGE, 2, 0x9C, 0x70);
+	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FC, 2, 0x90, 0x80);
+	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FE, 1, 0xDC, 0xDC);
+
+	_vm->_palette->setPalette(_vm->_palette->_mainPalette + (TEXTDIALOG_CONTENT1 * 3),
+		TEXTDIALOG_CONTENT1, 8);
+}
+
 void Dialog::calculateBounds() {
 }
 
@@ -125,22 +153,9 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName,
 	Common::fill(&_lineXp[0], &_lineXp[TEXT_DIALOG_MAX_LINES], 0);
 	_askLineNum = -1;
 	_askXp = 0;
-
-	// Save the high end of the palette, and set up the entries for dialog display
-	Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3],
-		&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3 + 8 * 3],
-		&_cyclingPalette[0]);
-	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_CONTENT1, 2, 0x90, 0x80);
-	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_EDGE, 2, 0x9C, 0x70);
-	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FC, 2, 0x90, 0x80);
-	Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FE, 1, 0xDC, 0xDC);
-
-	_vm->_palette->setPalette(_vm->_palette->_mainPalette + (TEXTDIALOG_CONTENT1 * 3),
-		TEXTDIALOG_CONTENT1, 8);
 }
 
 TextDialog::~TextDialog() {
-	restorePalette();
 }
 
 void TextDialog::addLine(const Common::String &line, bool underline) {
@@ -326,12 +341,6 @@ void TextDialog::drawWithInput() {
 	error("TODO: drawWithInput");
 }
 
-void TextDialog::restorePalette() {
-	Common::copy(&_cyclingPalette[0], &_cyclingPalette[8 * 3],
-		&_vm->_palette->_mainPalette[248 * 3]);
-	_vm->_palette->setPalette(_vm->_palette->_mainPalette, 248, 8);
-}
-
 void TextDialog::show() {
 	// Draw the dialog
 	draw();
diff --git a/engines/mads/dialogs.h b/engines/mads/dialogs.h
index 078415b..6de6ea7 100644
--- a/engines/mads/dialogs.h
+++ b/engines/mads/dialogs.h
@@ -31,27 +31,24 @@
 namespace MADS {
 
 class Dialog {
+private:
+	void setDialogPalette();
 protected:
 	MADSEngine *_vm;
 	MSurface *_savedSurface;
 	Common::Point _position;
 	int _width;
 	int _height;
-
-	/**
-	 * Save the section of the passed surface the dialog will cover.
-	 */
-	virtual void save();
-
-	/**
-	 * Restore saved dialog surface
-	 */
-	virtual void restore();
-
-	/**
-	 * Draws the content of a dialog with a gravelly alternating color.
-	 */
-	void drawContent(const Common::Rect &r, int seed, byte color1, byte color2);
+	byte _dialogPalette[8 * 3];
+
+	int TEXTDIALOG_CONTENT1;
+	int TEXTDIALOG_CONTENT2;
+	int TEXTDIALOG_EDGE;
+	int TEXTDIALOG_BACKGROUND;
+	int TEXTDIALOG_FC;
+	int TEXTDIALOG_FD;
+	int TEXTDIALOG_FE;
+	int TEXTDIALOG_BLACK;
 protected:
 	/**
 	 * Draw the dialog
@@ -62,6 +59,21 @@ protected:
 	 * Calculate bounds for the dialog
 	 */
 	virtual void calculateBounds();
+
+	/**
+	* Save the section of the passed surface the dialog will cover.
+	*/
+	virtual void save();
+
+	/**
+	* Restore saved dialog surface
+	*/
+	virtual void restore();
+
+	/**
+	* Draws the content of a dialog with a gravelly alternating color.
+	*/
+	void drawContent(const Common::Rect &r, int seed, byte color1, byte color2);
 public:
 	/**
 	 * Constructor
@@ -82,17 +94,6 @@ public:
 	}
 };
 
-enum {
-	TEXTDIALOG_CONTENT1 = 0XF8,
-	TEXTDIALOG_CONTENT2 = 0XF9,
-	TEXTDIALOG_EDGE = 0XFA,
-	TEXTDIALOG_BACKGROUND = 0XFB,
-	TEXTDIALOG_FC = 0XFC,
-	TEXTDIALOG_FD = 0XFD,
-	TEXTDIALOG_FE = 0XFE,
-	TEXTDIALOG_BLACK = 0
-};
-
 #define TEXT_DIALOG_MAX_LINES 20
 
 class TextDialog: protected Dialog {
@@ -117,7 +118,6 @@ protected:
 	int _askLineNum;
 	Common::String _lines[TEXT_DIALOG_MAX_LINES];
 	int _lineXp[TEXT_DIALOG_MAX_LINES];
-	byte _cyclingPalette[8 * 3];
 
 	/**
 	 * Calculate the bounds for the dialog
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 63b0edf..df423f9 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -416,13 +416,23 @@ void PictureDialog::save() {
 	SpriteAsset *asset = new SpriteAsset(_vm, setName, 0x8000);
 	palette.setFullPalette(palette._mainPalette);
 
-	// Draw the inventory picture
+	// Get the inventory frame, and adjust the dialog position to allow for it
 	MSprite *frame = asset->getFrame(0);
 	_position.y = frame->h + 12;
 
+	// Draw the inventory picture
 	frame->copyTo(&_vm->_screen, Common::Point(160 - frame->w / 2, 6),
 		frame->getTransparencyIndex());
 	_vm->_screen.copyRectToScreen(_vm->_screen.getBounds());
+
+	// Adjust the dialog colours to use
+	TEXTDIALOG_CONTENT1 -= 10;
+	TEXTDIALOG_CONTENT2 -= 10;
+	TEXTDIALOG_EDGE -= 10;
+	TEXTDIALOG_BACKGROUND -= 10;
+	TEXTDIALOG_FC -= 10;
+	TEXTDIALOG_FD -= 10;
+	TEXTDIALOG_FE -= 10;
 }
 
 void PictureDialog::restore() {


Commit: 8e728a04e893ebb9efe249715506289f2088ab16
    https://github.com/scummvm/scummvm/commit/8e728a04e893ebb9efe249715506289f2088ab16
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-12T18:56:34+02:00

Commit Message:
MADS: Implement scene 608

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes6.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 4cbcb81..fa2c4a3 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -237,7 +237,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 607:	// outside Abdul's garage
 		return new Scene607(vm);
 	case 608:	// inside Abdul's garage
-		return new DummyScene(vm);	// TODO
+		return new Scene608(vm);
 	case 609:	// outside Buckluster video store
 		return new DummyScene(vm);	// TODO
 	case 610:	// inside Buckluster video store
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index 8cda6ed..6c228c1 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -1022,12 +1022,12 @@ void Scene607::enter() {
 	_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
 
-	if (_scene->_priorSceneId == 608) { 
-		_game._player._playerPos = Common::Point(297, 50); 
+	if (_scene->_priorSceneId == 608) {
+		_game._player._playerPos = Common::Point(297, 50);
 		_game._player._facing = FACING_SOUTHEAST;
 	} else if (_scene->_priorSceneId != -2) {
 		_game._player._playerPos = Common::Point(40, 104);
-		_game._player._facing = FACING_SOUTHEAST; 
+		_game._player._facing = FACING_SOUTHEAST;
 		_game._player._visible = false;
 		_game._player._stepEnabled = false;
 		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
@@ -1038,12 +1038,12 @@ void Scene607::enter() {
 		_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('g', 3));
 		_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('g', 7));
 		_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('g', 0));
-	} 
+	}
 
 	sceneEntrySound();
 
 	if (_scene->_roomChanged)
-		_game._objects.addToInventory(OBJ_BONES); 
+		_game._objects.addToInventory(OBJ_BONES);
 
 	_vm->_palette->setEntry(252, 63, 44, 30);
 	_vm->_palette->setEntry(253, 63, 20, 22);
@@ -1071,18 +1071,18 @@ void Scene607::step() {
 		_dogTimer = 0;
 	}
 
-	if (_game._trigger == 91) { 
+	if (_game._trigger == 91) {
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 6);
 		_dogBarking = false;
 		_globals[kDogStatus] = 1;
 		_scene->_hotspots.activate(0x471, true);
-	} 
+	}
 
 	if (!_dogEatsRex && (_game._difficulty != DIFFICULTY_EASY) && !_animationActive && (_globals[kDogStatus] == 1)
 	 && !_dogBarking && (_vm->getRandomNumber(1, 50) == 10)) {
 		_dogBarking = true;
-		_scene->_sequences.remove(_globals._sequenceIndexes[1]); 
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 5, 8, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 6);
 		_scene->_kernelMessages.reset();
@@ -1143,13 +1143,13 @@ void Scene607::step() {
 	 && (_game._trigger || !_dogEatsRex)) {
 		_dogEatsRex = true;
 		switch (_game._trigger) {
-		case 91: 
+		case 91:
 		case 0:
 			_animationActive = 1;
 			_game._player._visible = false;
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 10, 1, 0, 0);
-			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], -1, 7); 
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], -1, 7);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
 			_scene->_kernelMessages.reset();
 			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x2FA));
@@ -1160,7 +1160,7 @@ void Scene607::step() {
 		case 60: {
 			int syncIdx = _globals._sequenceIndexes[4];
 			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 5, 1, 0, 0);
-			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 8, 45); 
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 8, 45);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], syncIdx);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 61);
@@ -1170,7 +1170,7 @@ void Scene607::step() {
 		case 61: {
 			int syncIdx = _globals._sequenceIndexes[4];
 			_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 15, 3, 0, 0);
-			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 46, -2); 
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 46, -2);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], syncIdx);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 62);
@@ -1219,13 +1219,13 @@ void Scene607::step() {
 		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 1, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 82);
-		break; 
+		break;
 
 	case 82:
-		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2); 
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
 		_game._player._stepEnabled = true;
-		break; 
+		break;
 
 	default:
 		break;
@@ -1238,12 +1238,12 @@ void Scene607::handleThrowingBone() {
 	case 0:
 		_game._player._stepEnabled = false;
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
-		_game._player._visible = false; 
+		_game._player._visible = false;
 		_scene->loadAnimation(formAnimName('D', _animationMode), 1);
 		break;
 
 	case 1:
-		_game._player._visible = true; 
+		_game._player._visible = true;
 		_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
 
 		if (_animationMode != 1)
@@ -1258,7 +1258,7 @@ void Scene607::handleThrowingBone() {
 			_game._objects.setRoom(OBJ_BONE, NOWHERE);
 			if (_animationMode == 1)
 				_globals[kBone202Status] = 0;
-		} else { 
+		} else {
 			_game._objects.setRoom(OBJ_BONES, NOWHERE);
 			_game._objects.addToInventory(OBJ_BONE);
 		}
@@ -1269,7 +1269,7 @@ void Scene607::handleThrowingBone() {
 	case 2: {
 		int quoteId = 0x2F8;
 		if (_animationMode == 1)
-			quoteId = 0x2F7; 
+			quoteId = 0x2F7;
 
 		if (_animationMode == 2) {
 			_globals[kDogStatus] = 2;
@@ -1299,7 +1299,7 @@ void Scene607::preActions() {
 	if (_action.isAction(0x18B, 0x478) && (_globals[kDogStatus] == 2) && (_game._difficulty != DIFFICULTY_EASY)) {
 		_shopAvailable = true;
 		_dogTimer = 0;
-	} 
+	}
 
 	if (_action.isAction(VERB_THROW, 0x2D, 0x471) || _action.isAction(VERB_THROW, 0x2C, 0x471))
 		_game._player.walk(Common::Point(193, 100), FACING_NORTHEAST);
@@ -1323,7 +1323,7 @@ void Scene607::actions() {
 
 		case 1: {
 			int syncIdx = _globals._sequenceIndexes[2];
-			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1); 
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], syncIdx);
 			_scene->_sequences.addTimer(6, 2);
 			}
@@ -1340,7 +1340,7 @@ void Scene607::actions() {
 			int syncIdx = _globals._sequenceIndexes[3];
 			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
-			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], syncIdx); 
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], syncIdx);
 			_scene->_nextSceneId = 504;
 			}
 			break;
@@ -1363,7 +1363,7 @@ void Scene607::actions() {
 		if (_game._trigger == 0) {
 			_scene->_kernelMessages.reset();
 			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x2F6));
-		} 
+		}
 		handleThrowingBone();
 	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x31E)) {
 		if ((_globals[kDogStatus] == 1) || (_game._difficulty == DIFFICULTY_EASY))
@@ -1418,16 +1418,976 @@ void Scene607::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene608::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(0x115);
+	_scene->addActiveVocab(0x324);
+	_scene->addActiveVocab(0x471);
+}
+
+void Scene608::resetDogVariables() {
+	_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
+	int idx = _scene->_dynamicHotspots.add(0x471, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+	_scene->_dynamicHotspots.setPosition(idx, Common::Point(194, 142), FACING_EAST);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 4);
+	_dogBarkingFl = false;
+	_dogFirstEncounter = false;
+}
+
+void Scene608::restoreAnimations() {
+	_scene->freeAnimation();
+	_carMode = 0;
+	_game._player._stepEnabled = true;
+	if (_throwMode == 6)
+		_dogSquashFl = true;
+
+	if (_globals[kCarStatus] == 0) {
+		_scene->_sequences.remove(_globals._sequenceIndexes[6]);
+		_scene->_sequences.remove(_globals._sequenceIndexes[7]);
+		_scene->loadAnimation(formAnimName('A', -1));
+	} else {
+		_scene->_sequences.remove(_globals._sequenceIndexes[8]);
+		_scene->_sequences.remove(_globals._sequenceIndexes[6]);
+		_scene->_sequences.remove(_globals._sequenceIndexes[7]);
+		_scene->loadAnimation(formAnimName('A', -1));
+		_scene->_activeAnimation->setCurrentFrame(6);
+	}
+}
+
+void Scene608::setCarAnimations() {
+	_scene->freeAnimation();
+	if (_globals[kCarStatus] == 0) {
+		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 1);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[6], Common::Point(143, 98));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 6);
+		_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, 1);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[7], Common::Point(141, 67));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 15);
+	} else {
+		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 1);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[6], Common::Point(143, 128));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 6);
+		_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, 1);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[7], Common::Point(141, 97));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 15);
+		_globals._sequenceIndexes[8] = _scene->_sequences.startCycle(_globals._spriteIndexes[8], false, 1);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[8], Common::Point(144, 126));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 5);
+	}
+}
+
+void Scene608::handleThrowingBone() {
+	switch (_game._trigger) {
+	case 0:
+		_game._player._stepEnabled = false;
+		setCarAnimations();
+		_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+		_animationMode = -1;
+		_game._player._visible = false;
+		_carMode = _throwMode;
+		if (_throwMode == 4)
+			_scene->loadAnimation(formAnimName('X', 2), 1);
+		else if (_throwMode == 5)
+			_scene->loadAnimation(formAnimName('X', 1), 1);
+		else
+			_scene->loadAnimation(formAnimName('X', 3), 1);
+		break;
+
+	case 1:
+		_nextTrigger = 1;
+		_scene->_sequences.addTimer(1, 2);
+		break;
+
+	case 2:
+		if (_nextTrigger != 2)
+			_scene->_sequences.addTimer(1, 2);
+		else {
+			if (_game._objects.isInInventory(OBJ_BONE))
+				_game._objects.setRoom(OBJ_BONE, NOWHERE);
+			else {
+				_game._objects.setRoom(OBJ_BONES, NOWHERE);
+				_game._objects.addToInventory(OBJ_BONE);
+			}
+			_scene->_sequences.addTimer(60, 3);
+		}
+		break;
+
+	case 3:
+		if (_throwMode != 6) {
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x304));
+			_scene->_sequences.addTimer(120, 4);
+		} else
+			restoreAnimations();
+		break;
+
+	case 4:
+		restoreAnimations();
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene608::enter() {
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RXMRD_7");
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RXMRC_9");
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('c', 2));
+	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('c', 0));
+	_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('c', 1));
+
+	if (_game._objects.isInRoom(OBJ_POLYCEMENT)) {
+		_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('g', -1));
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+		int idx = _scene->_dynamicHotspots.add(0x115, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_polycementHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(249, 129), FACING_NORTHEAST);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 6);
+	}
+
+	if (_game._objects.isInRoom(OBJ_REARVIEW_MIRROR)) {
+		_globals._spriteIndexes[12] = _scene->_sprites.addSprites(formAnimName('m', -1));
+		_globals._sequenceIndexes[12] = _scene->_sequences.startCycle(_globals._spriteIndexes[12], false, 1);
+		int idx = _scene->_dynamicHotspots.add(0x120, VERB_WALKTO, _globals._sequenceIndexes[12], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(71, 113), FACING_NORTHEAST);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[12], 15);
+	}
+
+	if (_game._difficulty == DIFFICULTY_HARD) {
+		_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('g', 0));
+		_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('g', 1));
+		_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('g', 2));
+		_globals._spriteIndexes[10] = _scene->_sprites.addSprites(formAnimName('h', 2));
+		_globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('h', 3));
+		_rexBeingEaten = false;
+
+		if (!_game._visitedScenes._sceneRevisited) {
+			_globals[kDogStatus] = 3;
+			_dogActiveFl = true;
+		} else
+			_dogActiveFl = (_globals[kDogStatus] != 4);
+	} else {
+		_globals[kDogStatus] = 4;
+		_dogActiveFl = false;
+	}
+
+	_dogSquashFl = false;
+	_buttonPressedonTimeFl = false;
+	_dogWindowTimer = 0;
+	_dogRunTimer = 0;
+	_dogHitWindow = false;
+	_checkFl = false;
+	_dogUnderCar = false;
+	_dogYelping = false;
+
+
+	if (!_game._visitedScenes._sceneRevisited)
+		_globals[kCarStatus] = 0;
+
+	_animationMode = 0;
+	_carMoveMode = 0;
+	_carFrame = -1;
+
+	if (_globals[kCarStatus] == 0) {
+		_carMode = 0;
+		_dogDeathMode = 0;
+		_resetPositionsFl = false;
+		int idx = _scene->_dynamicHotspots.add(0x324, VERB_WALKTO, -1, Common::Rect(99, 69, 99 + 82, 69 + 25));
+		_carHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(96, 132), FACING_NORTHEAST);
+		_scene->loadAnimation(formAnimName('A', -1));
+	} else if (_globals[kCarStatus] == 3) {
+		_carMode = 0;
+		_dogDeathMode = 0;
+		_resetPositionsFl = false;
+		int idx = _scene->_dynamicHotspots.add(0x324, VERB_WALKTO, -1, Common::Rect(100, 100, 100 + 82, 100 + 25));
+		_carHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(96, 132), FACING_NORTHEAST);
+		_scene->loadAnimation(formAnimName('A', -1));
+		_scene->_activeAnimation->setCurrentFrame(6);
+	} else if (_globals[kCarStatus] == 1) {
+		_carMode = 2;
+		_dogDeathMode = 0;
+		_resetPositionsFl = false;
+		int idx = _scene->_dynamicHotspots.add(0x324, VERB_WALKTO, -1, Common::Rect(99, 69, 99 + 82, 69 + 25));
+		_carHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(96, 132), FACING_NORTHEAST);
+		_scene->loadAnimation(formAnimName('C', -1));
+	} else if (_globals[kCarStatus] == 2) {
+		_carMode = 1;
+		_dogDeathMode = 2;
+		_resetPositionsFl = true;
+		int idx = _scene->_dynamicHotspots.add(0x324, VERB_WALKTO, -1, Common::Rect(99, 69, 99 + 82, 69 + 25));
+		_carHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(96, 132), FACING_NORTHEAST);
+		_scene->loadAnimation(formAnimName('B', -1));
+	} else {
+		_carMode = 3;
+		_dogDeathMode = 2;
+		_resetPositionsFl = true;
+		int idx = _scene->_dynamicHotspots.add(0x324, VERB_WALKTO, -1, Common::Rect(100, 100, 100 + 82, 100 + 25));
+		_carHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(96, 132), FACING_NORTHEAST);
+		_scene->loadAnimation(formAnimName('D', -1));
+	}
+
+	_vm->_palette->setEntry(252, 63, 44, 30);
+	_vm->_palette->setEntry(253, 63, 20, 22);
+
+	if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(46, 132);
+		_game._player._facing = FACING_EAST;
+		if (_game._difficulty == DIFFICULTY_HARD) {
+			if (!_game._visitedScenes._sceneRevisited)
+				_dogFirstEncounter = true;
+			else if (_dogActiveFl)
+				resetDogVariables();
+		}
+	} else if ((_game._difficulty == DIFFICULTY_HARD) && !_dogFirstEncounter && _dogActiveFl) {
+		if (!_dogUnderCar)
+			resetDogVariables();
+		else {
+			_globals._sequenceIndexes[10] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[10], false, 9, 0, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 10, 11);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 6);
+		}
+	}
+
+	sceneEntrySound();
+
+	if (_scene->_roomChanged)
+		_game._objects.addToInventory(OBJ_BONES);
+
+	_game.loadQuoteSet(0x2FB, 0x2FC, 0x2FE, 0x2FD, 0x2FF, 0x300, 0x301, 0x302, 0x303, 0x304, 0);
+}
+
+void Scene608::step() {
+	if (_dogFirstEncounter) {
+		long diff = _scene->_frameStartTime - _dogTimer1;
+		if ((diff >= 0) && (diff <= 1))
+			_dogWindowTimer += diff;
+		else
+			_dogWindowTimer++;
+
+		_dogTimer1 = _scene->_frameStartTime;
+	}
+
+	if (_dogActiveFl && (_dogWindowTimer >= 2) && !_dogHitWindow) {
+		_dogHitWindow = true;
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 11, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
+		_vm->_sound->command(14);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
+		_dogWindowTimer = 0;
+	}
+
+	if (_game._trigger == 70)
+		resetDogVariables();
+
+	if ((_game._difficulty == DIFFICULTY_HARD) && !_animationMode && _dogActiveFl && !_dogFirstEncounter && !_dogUnderCar) {
+		if (!_dogBarkingFl) {
+			if (_vm->getRandomNumber(1, 50) == 10) {
+				_dogBarkingFl = true;
+				_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+				_globals._sequenceIndexes[5] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], false, 5, 8, 0, 0);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 4);
+				int idx = _scene->_dynamicHotspots.add(0x471, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+				_scene->_dynamicHotspots.setPosition(idx, Common::Point(194, 142), FACING_EAST);
+				_barkCount = 0;
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_SPRITE, 2, 100);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 60);
+			}
+		} else if (_game._trigger == 60) {
+			int syncIdx = _globals._sequenceIndexes[5];
+			_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 6);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[5], syncIdx);
+			_scene->_kernelMessages.reset();
+			_dogBarkingFl = false;
+		}
+	}
+
+	if ((_game._trigger == 100) && _dogBarkingFl) {
+		_vm->_sound->command(12);
+		_barkCount++;
+
+		if ((_barkCount >= 1) && (_barkCount <= 4)) {
+			Common::Point _barkPos(0, 0);
+			switch (_barkCount) {
+			case 1:
+				_barkPos = Common::Point(197, 66);
+				break;
+
+			case 2:
+				_barkPos = Common::Point(230, 76);
+				break;
+
+			case 3:
+				_barkPos = Common::Point(197, 86);
+				break;
+
+			case 4:
+				_barkPos = Common::Point(230, 97);
+				break;
+
+			default:
+				break;
+			}
+			_scene->_kernelMessages.add(_barkPos, 0xFDFC, 0, 0, 120, _game.getQuote(0x2FB));
+		}
+	}
+
+	if (_dogSquashFl && !_dogFirstEncounter && _dogUnderCar && _dogActiveFl) {
+		long diff = _scene->_frameStartTime - _dogTimer2;
+		if ((diff >= 0) && (diff <= 4))
+			_dogRunTimer += diff;
+		else
+			_dogRunTimer++;
+
+		_dogTimer2 = _scene->_frameStartTime;
+	}
+
+	// CHECKME: _checkFl is always false?
+	if (_dogRunTimer >= 480 && !_checkFl && !_buttonPressedonTimeFl && !_dogFirstEncounter && _dogUnderCar && _dogActiveFl) {
+		_checkFl = true;
+		_dogSquashFl = false;
+		_dogSafeFl = true;
+		_checkFl = false;
+		_dogRunTimer = 0;
+	} else {
+		_dogSafeFl = false;
+		if (_game._player._moving && (_game._difficulty == DIFFICULTY_HARD) && _dogActiveFl && (_scene->_rails.getNext() > 0) && _dogUnderCar)
+			_dogSafeFl = true;
+	}
+
+	if (_dogActiveFl && _dogSafeFl && !_buttonPressedonTimeFl) {
+		_dogDeathMode = 0;
+		_globals[kCarStatus] = 0;
+		_carMode = 0;
+		_scene->_sequences.remove(_globals._sequenceIndexes[10]);
+		_dogUnderCar = false;
+		_dogYelping = false;
+		_scene->_kernelMessages.reset();
+		_globals._sequenceIndexes[11] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 6, 1, 0, 0);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[11], SEQUENCE_TRIGGER_EXPIRE, 0, 92);
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x2FF));
+	}
+
+	if (_game._trigger == 92) {
+		resetDogVariables();
+		_animationMode = 0;
+	}
+
+	if ((_carMode == 4) && (_scene->_activeAnimation != nullptr)) {
+		if (_scene->_activeAnimation->getCurrentFrame() != _carFrame) {
+			_carFrame = _scene->_activeAnimation->getCurrentFrame();
+			int nextFrame = -1;
+
+			if (_carFrame == 10) {
+				_game._player._visible = true;
+				_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
+			}
+
+			if (_carFrame == 56) {
+				resetDogVariables();
+				_animationMode = 0;
+				_nextTrigger = 2;
+			}
+
+			if ((nextFrame >= 0) && (nextFrame != _scene->_activeAnimation->getCurrentFrame())) {
+				_scene->_activeAnimation->setCurrentFrame(nextFrame);
+				_carFrame = nextFrame;
+			}
+		}
+	}
+
+	if ((_carMode == 5) && (_scene->_activeAnimation != nullptr)) {
+		if (_scene->_activeAnimation->getCurrentFrame() != _carFrame) {
+			_carFrame = _scene->_activeAnimation->getCurrentFrame();
+			int nextFrame = -1;
+
+			if (_carFrame == 10) {
+				_game._player._visible = true;
+				_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
+			}
+
+			if (_carFrame == 52) {
+				resetDogVariables();
+				_animationMode = 0;
+				_nextTrigger = 2;
+			}
+
+			if ((nextFrame >= 0) && (nextFrame != _scene->_activeAnimation->getCurrentFrame())) {
+				_scene->_activeAnimation->setCurrentFrame(nextFrame);
+				_carFrame = nextFrame;
+			}
+		}
+	}
+
+
+	if ((_carMode == 6) && (_scene->_activeAnimation != nullptr)) {
+		if (_scene->_activeAnimation->getCurrentFrame() != _carFrame) {
+			_carFrame = _scene->_activeAnimation->getCurrentFrame();
+			int nextFrame = -1;
+
+			if (_carFrame == 11) {
+				_game._player._visible = true;
+				_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
+			}
+
+			if (_carFrame == 41) {
+				_globals._sequenceIndexes[10] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[10], false, 9, 0, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 10, 11);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 6);
+				_dogUnderCar = true;
+				_nextTrigger = 2;
+			}
+
+
+			if ((nextFrame >= 0) && (nextFrame != _scene->_activeAnimation->getCurrentFrame())) {
+				_scene->_activeAnimation->setCurrentFrame(nextFrame);
+				_carFrame = nextFrame;
+			}
+		}
+	}
+
+	if (_dogUnderCar) {
+		if (!_dogYelping) {
+			if (_vm->getRandomNumber(1, 50) == 10) {
+				_dogYelping = true;
+				_barkCount = 0;
+				_scene->_sequences.addTimer(12, 110);
+				_scene->_sequences.addTimer(22, 111);
+				_scene->_sequences.addTimer(120, 112);
+			}
+			_scene->_kernelMessages.reset();
+		}
+	} else
+		_dogYelping = false;
+
+	if (_game._trigger == 110) {
+		_vm->_sound->command(12);
+		_scene->_kernelMessages.add(Common::Point(150, 97), 0xFDFC, 0, 0, 60, _game.getQuote(0x303));
+	}
+
+	if (_game._trigger == 111) {
+		_vm->_sound->command(12);
+		_scene->_kernelMessages.add(Common::Point(183, 93), 0xFDFC, 0, 0, 60, _game.getQuote(0x303));
+	}
+
+	if (_game._trigger == 112)
+		_dogYelping = false;
+
+	if ((_carMode == 0) && (_scene->_activeAnimation != nullptr)) {
+		if (_scene->_activeAnimation->getCurrentFrame() != _carFrame) {
+			_carFrame = _scene->_activeAnimation->getCurrentFrame();
+			int nextFrame = -1;
+
+			if ((_globals[kCarStatus] == 0) || (_globals[kCarStatus] == 3)) {
+				switch (_carMoveMode) {
+				case 0:
+					if (_globals[kCarStatus] == 0)
+						nextFrame = 0;
+					else
+						nextFrame = 6;
+					break;
+
+				case 1:
+					if (_scene->_activeAnimation->getCurrentFrame() >= 12) {
+						nextFrame = 0;
+						_carMoveMode = 0;
+						_globals[kCarStatus] = 0;
+					}
+					break;
+
+				case 2:
+					if (_scene->_activeAnimation->getCurrentFrame() >= 6) {
+						nextFrame = 6;
+						_carMoveMode = 0;
+						_globals[kCarStatus] = 3;
+					}
+					break;
+
+				default:
+					break;
+				}
+			}
+
+			if ((nextFrame >= 0) && (nextFrame != _scene->_activeAnimation->getCurrentFrame())) {
+				_scene->_activeAnimation->setCurrentFrame(nextFrame);
+				_carFrame = nextFrame;
+			}
+		}
+	}
+
+	if ((_carMode == 2) && (_scene->_activeAnimation != nullptr)) {
+		if (_scene->_activeAnimation->getCurrentFrame() != _carFrame) {
+			_carFrame = _scene->_activeAnimation->getCurrentFrame();
+			int nextFrame = -1;
+
+			if (_carMoveMode == 0)
+				nextFrame = 28;
+			else if (_scene->_activeAnimation->getCurrentFrame() >= 28) {
+				nextFrame = 28;
+				_carMoveMode = 0;
+			}
+
+			if ((nextFrame >= 0) && (nextFrame != _scene->_activeAnimation->getCurrentFrame())) {
+				_scene->_activeAnimation->setCurrentFrame(nextFrame);
+				_carFrame = nextFrame;
+			}
+		}
+	}
+
+	if ((_carMode == 3) && (_scene->_activeAnimation != nullptr)) {
+		if (_scene->_activeAnimation->getCurrentFrame() != _carFrame) {
+			_carFrame = _scene->_activeAnimation->getCurrentFrame();
+			int nextFrame = -1;
+
+			if (_resetPositionsFl) {
+				nextFrame = 0;
+				_carMoveMode = 0;
+			} else if (_carMoveMode == 0)
+				nextFrame = 6;
+			else if (_scene->_activeAnimation->getCurrentFrame() >= 6) {
+				nextFrame = 6;
+				_carMoveMode = 0;
+			}
+
+			if ((nextFrame >= 0) && (nextFrame != _scene->_activeAnimation->getCurrentFrame())) {
+				_scene->_activeAnimation->setCurrentFrame(nextFrame);
+				_carFrame = nextFrame;
+			}
+		}
+	}
+
+
+	if ((_carMode == 1) && (_scene->_activeAnimation != nullptr)) {
+		if (_scene->_activeAnimation->getCurrentFrame() != _carFrame) {
+			_carFrame = _scene->_activeAnimation->getCurrentFrame();
+			int nextFrame = -1;
+
+			if (_resetPositionsFl) {
+				nextFrame = 0;
+				_carMoveMode = 0;
+			} else if (_carMoveMode == 0)
+				nextFrame = 6;
+			else if (_scene->_activeAnimation->getCurrentFrame() >= 6) {
+				nextFrame = 6;
+				_carMoveMode = 0;
+			}
+
+			if ((nextFrame >= 0) && (nextFrame != _scene->_activeAnimation->getCurrentFrame())) {
+				_scene->_activeAnimation->setCurrentFrame(nextFrame);
+				_carFrame = nextFrame;
+			}
+		}
+	}
+
+	if (_game._player._moving && (_game._difficulty == DIFFICULTY_HARD) && _dogActiveFl && (_scene->_rails.getNext() > 0)) {
+		_game._player.cancelCommand();
+		_game._player.startWalking(Common::Point(194, 142), FACING_EAST);
+		_scene->_rails.resetNext();
+		if (_dogUnderCar)
+			_dogSafeFl = true;
+	}
+
+	if (_game._player._special > 0 && (_game._difficulty == DIFFICULTY_HARD) && _dogActiveFl && _game._player._stepEnabled)
+		_game._player._stepEnabled = false;
+
+	if ((_game._difficulty == DIFFICULTY_HARD) && _dogActiveFl && (_game._player._playerPos == Common::Point(194, 142))
+	 && (_game._trigger || !_rexBeingEaten)) {
+		_rexBeingEaten = true;
+		switch (_game._trigger) {
+		case 0:
+			_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+			_animationMode = 1;
+			_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 10, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[9], 1, 2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 5);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
+			_scene->_sequences.addTimer(10, 85);
+			break;
+
+		case 80:
+			_game._player._visible = false;
+			_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 10, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[9], 3, 5);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 5);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[9], -1);
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x2FC));
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 81);
+			break;
+
+		case 81: {
+			int syncIdx = _globals._sequenceIndexes[9];
+			_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 5, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[9], 6, 38);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 5);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[9], syncIdx);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 82);
+			}
+			break;
+
+		case 82: {
+			int syncIdx = _globals._sequenceIndexes[9];
+			_globals._sequenceIndexes[9] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[9], false, 15, 5, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[9], 39, 40);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 5);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[9], syncIdx);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 83);
+			}
+			break;
+
+		case 83: {
+			_animationMode = 2;
+			int syncIdx = _globals._sequenceIndexes[9];
+			_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, -2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 5);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[9], syncIdx);
+			_scene->_sequences.addTimer(60, 84);
+			}
+			break;
+
+		case 84:
+			_rexBeingEaten = false;
+			_animationMode = 0;
+			_scene->_reloadSceneFlag = true;
+			_game._player._stepEnabled = true;
+			break;
+
+		case 85:
+			if (_rexBeingEaten && (_animationMode == 1)) {
+				_vm->_sound->command(12);
+				_scene->_sequences.addTimer(10, 85);
+			}
+			break;
+
+		default:
+			break;
+		}
+	}
+}
+
+void Scene608::preActions() {
+	_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+
+	if ((_action.isAction(VERB_THROW, 0x2C, 0x410) || _action.isAction(VERB_THROW, 0x2D, 0x410)
+		|| _action.isAction(VERB_THROW, 0x2C, 0x411) || _action.isAction(VERB_THROW, 0x2D, 0x411)
+		|| _action.isAction(VERB_THROW, 0x2D, 0x471) || _action.isAction(VERB_THROW, 0x2C, 0x471)) && _dogActiveFl) {
+		_game._player._stepEnabled = false;
+		_game._player.walk(Common::Point(56, 146), FACING_EAST);
+	}
+
+	if ((_action.isAction(VERB_THROW, 0x2D, 0x41D) || _action.isAction(VERB_THROW, 0x2C, 0x41D)
+		|| _action.isAction(VERB_THROW, 0x2D, 0x41E) || _action.isAction(VERB_THROW, 0x2C, 0x41E)) && _dogActiveFl) {
+		_game._player._stepEnabled = false;
+		_game._player.walk(Common::Point(75, 136), FACING_EAST);
+	}
+
+	if (_action.isAction(VERB_PUSH, 0x403) && _dogUnderCar) {
+		_buttonPressedonTimeFl = true;
+		_dogDeathMode = 1;
+	} else
+		_buttonPressedonTimeFl = false;
+}
+
+void Scene608::actions() {
+	if (_action.isAction(0x18B, 0x70))
+		_scene->_nextSceneId = 607;
+	else if (_action.isAction(VERB_PUSH, 0x403)) {
+		_game._player._stepEnabled = true;
+		switch (_game._trigger) {
+		case 0:
+			if ((_globals[kCarStatus] == 0) || (_globals[kCarStatus] == 1) || (_globals[kCarStatus] == 2)) {
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], true, 6, 2, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 2);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			} else
+				_vm->_dialogs->show(60839);
+			break;
+
+		case 1:
+			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[3]);
+			_game._player._visible = true;
+			if (_dogDeathMode == 0)
+				_carMode = 0;
+			else if (_dogDeathMode == 1) {
+				_scene->_kernelMessages.reset();
+				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x300));
+				_globals[kCarStatus] = 1;
+				_carMode = 2;
+				_globals[kDogStatus] = 4;
+				_dogActiveFl = false;
+				_dogUnderCar = false;
+				_scene->_sequences.remove(_globals._sequenceIndexes[10]);
+				_scene->freeAnimation();
+				_scene->loadAnimation(formAnimName('C', -1));
+			} else {
+				_resetPositionsFl = false;
+				_carMode = 1;
+				_scene->freeAnimation();
+				_scene->loadAnimation(formAnimName('B', -1));
+			}
+
+			_carMoveMode = 2;
+			_scene->_sequences.addTimer(1, 2);
+			break;
+
+		case 2:
+			if (_carMoveMode != 0)
+				_scene->_sequences.addTimer(1, 2);
+			else {
+				_scene->_dynamicHotspots.remove(_carHotspotId);
+				int idx = _scene->_dynamicHotspots.add(0x324, VERB_WALKTO, -1, Common::Rect(100, 100, 100 + 82, 100 + 25));
+				_carHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(96, 132), FACING_NORTHEAST);
+				if (_globals[kCarStatus] == 1)
+					_scene->_sequences.addTimer(120, 3);
+				else {
+					if (_dogDeathMode == 0)
+						_globals[kCarStatus] = 3;
+					else {
+						_globals[kCarStatus] = 4;
+						_carMode = 3;
+						_dogDeathMode = 2;
+					}
+					_game._player._stepEnabled = true;
+				}
+			}
+			break;
+
+		case 3:
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x302));
+			_globals[kCarStatus] = 4;
+			_carMode = 3;
+			_dogDeathMode = 2;
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(VERB_PUSH, 0x402)) {
+		switch (_game._trigger) {
+		case 0:
+			if ((_globals[kCarStatus] == 3) || (_globals[kCarStatus] == 4)) {
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], true, 6, 2, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 3);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			} else
+				_vm->_dialogs->show(60840);
+			break;
+		
+		case 1:
+			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[3]);
+			_game._player._visible = true;
+			if (_dogDeathMode == 0)
+				_carMode = 0;
+			else {
+				_carMode = 3;
+				_resetPositionsFl = false;
+				_scene->freeAnimation();
+				_scene->loadAnimation(formAnimName('D', -1));
+			}
+			_carMoveMode = 1;
+			_scene->_sequences.addTimer(1, 2);
+			break;
+		
+		case 2: {
+			if (_carMoveMode != 0)
+				_scene->_sequences.addTimer(1, 2);
+			else if (_dogDeathMode == 0)
+				_globals[kCarStatus] = 0;
+			else if (_dogDeathMode == 2) {
+				_globals[kCarStatus] = 2;
+				_carMode = 3;
+				_dogDeathMode = 2;
+			}
+			_scene->_dynamicHotspots.remove(_carHotspotId);
+			int idx = _scene->_dynamicHotspots.add(0x324, VERB_WALKTO, -1, Common::Rect(99, 69, 99 + 82, 69 + 25));
+			_carHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(96, 132), FACING_NORTHEAST);
+			_game._player._stepEnabled = true;
+			}
+			break;
+			
+		default:
+			break;
+		}
+	} else if (_action.isAction(VERB_THROW, 0x2C, 0x410) || _action.isAction(VERB_THROW, 0x2D, 0x410)
+					|| _action.isAction(VERB_THROW, 0x2D, 0x471) || _action.isAction(VERB_THROW, 0x2C, 0x471)) {
+		_game._player._stepEnabled = true;
+		if (_dogActiveFl) {
+			if (_game._trigger == 0) {
+				_scene->_kernelMessages.reset();
+				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x2FE));
+			}
+			_throwMode = 4;
+			handleThrowingBone();
+		} else
+			_vm->_dialogs->show(60841);
+	} else if (_action.isAction(VERB_THROW, 0x2C, 0x411) || _action.isAction(VERB_THROW, 0x2D, 0x411)) {
+		_game._player._stepEnabled = true;
+		if (_dogActiveFl) {
+			if (_game._trigger == 0) {
+				_scene->_kernelMessages.reset();
+				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x2FD));
+			}
+			_throwMode = 5;
+			handleThrowingBone();
+		} else
+			_vm->_dialogs->show(60841);
+	} else if (_action.isAction(VERB_THROW, 0x2D, 0x41D) || _action.isAction(VERB_THROW, 0x2C, 0x41D)
+					|| _action.isAction(VERB_THROW, 0x2D, 0x41E) || _action.isAction(VERB_THROW, 0x2C, 0x41E)) {
+		_game._player._stepEnabled = true;
+		if ((_globals[kCarStatus] == 0) && _dogActiveFl) {
+			if (_dogActiveFl) {
+				if (_game._trigger == 0) {
+					_scene->_kernelMessages.reset();
+					_scene->_kernelMessages.add(Common::Point(0,0), 0x1110, 34, 0, 120, _game.getQuote(0x301));
+				}
+				_throwMode = 6;
+				handleThrowingBone();
+			} else
+				_vm->_dialogs->show(60841);
+		} else
+			_vm->_dialogs->show(60842);
+	} else if (_action.isAction(VERB_TAKE, 0x115) && (_game._trigger || !_game._objects.isInInventory(OBJ_POLYCEMENT))) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], true, 6, 2, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 4, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+		
+		case 1:
+			_vm->_sound->command(9);
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_scene->_dynamicHotspots.remove(_polycementHotspotId);
+			break;
+		
+		case 2:
+			_game._objects.addToInventory(OBJ_POLYCEMENT);
+			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[2]);
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			_vm->_dialogs->showItem(OBJ_POLYCEMENT, 60833);
+			break;
+		
+		default:
+			break;
+		}
+	} else if (_action.isAction(VERB_TAKE, 0x120) && (_game._trigger || !_game._objects.isInInventory(OBJ_REARVIEW_MIRROR))) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], true, 6, 2, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 2, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+		
+		case 1:
+			_vm->_sound->command(9);
+			_scene->_sequences.remove(_globals._sequenceIndexes[12]);
+			_game._objects.addToInventory(OBJ_REARVIEW_MIRROR);
+			_vm->_dialogs->showItem(OBJ_REARVIEW_MIRROR, 60827);
+			break;
+		
+		case 2:
+			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[2]);
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			break;
+		
+		default:
+			break;
+		}
+	} else if (_action._lookFlag) {
+		if (_game._difficulty != DIFFICULTY_HARD)
+			_vm->_dialogs->show(60810);
+		else if (_globals[kDogStatus] == 4)
+			_vm->_dialogs->show(60812);
+		else
+			_vm->_dialogs->show(60811);
+	} else if (_action.isAction(VERB_LOOK) && (_action.isAction(0x412) || _action.isAction(0x408) || _action.isAction(0x414)
+					|| _action.isAction(0x40D) || _action.isAction(0x41C)))
+		_vm->_dialogs->show(60813);
+	else if (_action.isAction(VERB_TAKE) && (_action.isAction(0x412) || _action.isAction(0x408) || _action.isAction(0x414)
+					|| _action.isAction(0x40D) || _action.isAction(0x41C)))
+		_vm->_dialogs->show(60814);
+	else if (_action.isAction(VERB_LOOK, 0x409) || _action.isAction(VERB_LOOK, 0x411) || _action.isAction(VERB_LOOK, 0x410)) {
+		if (_dogActiveFl)
+			_vm->_dialogs->show(60815);
+		else
+			_vm->_dialogs->show(60816);
+	} else if (_action.isAction(VERB_LOOK, 0x495))
+		_vm->_dialogs->show(60817);
+	else if (_action.isAction(VERB_TAKE, 0x495)) {
+		if (_game._difficulty == DIFFICULTY_HARD)
+			_vm->_dialogs->show(60818);
+		else
+			_vm->_dialogs->show(60819);
+	} else if (_action.isAction(VERB_LOOK, 0x402))
+		_vm->_dialogs->show(60820);
+	else if (_action.isAction(VERB_LOOK, 0x403))
+		_vm->_dialogs->show(60821);
+	else if (_action.isAction(VERB_LOOK, 0x41A))
+		_vm->_dialogs->show(60822);
+	else if (_action.isAction(VERB_LOOK, 0x418))
+		_vm->_dialogs->show(60823);
+	else if (_action.isAction(VERB_LOOK, 0x330)) {
+		if (_game._objects[OBJ_REARVIEW_MIRROR]._roomNumber == _scene->_currentSceneId)
+			_vm->_dialogs->show(60825);
+		else
+			_vm->_dialogs->show(60824);
+	} else if (_action.isAction(VERB_OPEN, 0x330))
+		_vm->_dialogs->show(60826);
+	else if (_action.isAction(VERB_LOOK, 0x120) && (_action._mainObjectSource == 4))
+		_vm->_dialogs->show(60828);
+	else if (_action.isAction(VERB_LOOK, 0x406)) {
+		if (_game._objects[OBJ_POLYCEMENT]._roomNumber == _scene->_currentSceneId)
+			_vm->_dialogs->show(60829);
+		else
+			_vm->_dialogs->show(60830);
+	} else if (_action.isAction(VERB_OPEN, 0x406))
+		_vm->_dialogs->show(60831);
+	else if ((_action.isAction(VERB_LOOK, 0x115)) && (_game._objects.isInRoom(OBJ_POLYCEMENT)))
+		_vm->_dialogs->show(60832);
+	else if (_action.isAction(VERB_LOOK, 0x417) || _action.isAction(VERB_LOOK, 0x40E))
+		_vm->_dialogs->show(60834);
+	else if (_action.isAction(VERB_LOOK, 0x407))
+		_vm->_dialogs->show(60835);
+	else if (_action.isAction(VERB_LOOK, 0x47) || _action.isAction(VERB_LOOK, 0x4A0))
+		_vm->_dialogs->show(60836);
+	else if (_action.isAction(VERB_LOOK, 0x41E))
+		_vm->_dialogs->show(60838);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene620::setup() {
 	_game._player._spritesPrefix = "";
 	setAAName();
 }
 
 void Scene620::enter() {
-	_globals._spriteIndexes[1]  = _scene->_sprites.addSprites(formAnimName('b', 0));
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('b', 0));
 	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
 	_game._player._stepEnabled = false;
-	_game._player._visible   = false;
+	_game._player._visible = false;
 	_scene->_sequences.addTimer(30, 70);
 	_scene->_userInterface.setup(kInputLimitedSentences);
 	sceneEntrySound();
@@ -1435,7 +2395,7 @@ void Scene620::enter() {
 
 void Scene620::step() {
 	switch (_game._trigger) {
-	case 70: 
+	case 70:
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		_scene->loadAnimation(formAnimName('E', -1), 71);
 		break;
@@ -1445,7 +2405,7 @@ void Scene620::step() {
 			_globals[kCityFlooded] = true;
 			_globals[kTeleporterRoom + 5] = 0;
 			_scene->_nextSceneId = 701;
-		} else if (_scene->_priorSceneId == 752) { 
+		} else if (_scene->_priorSceneId == 752) {
 			_globals[kCityFlooded] = true;
 			_globals[kTeleporterRoom + 5] = 0;
 			_scene->_nextSceneId = 702;
@@ -1455,7 +2415,7 @@ void Scene620::step() {
 			_scene->_nextSceneId = _scene->_priorSceneId;
 		} else if (_scene->_priorSceneId >= 501 && _scene->_priorSceneId <= 612) {
 			_globals[kResurrectRoom] = _globals[kHoverCarLocation];
-			_game._objects.addToInventory(OBJ_TIMEBOMB);  
+			_game._objects.addToInventory(OBJ_TIMEBOMB);
 			_globals[kTimebombStatus] = 0;
 			_globals[kTimebombTimer] = 0;
 			_scene->_nextSceneId = 605;
diff --git a/engines/mads/nebular/nebular_scenes6.h b/engines/mads/nebular/nebular_scenes6.h
index 69db9eb..d259eab 100644
--- a/engines/mads/nebular/nebular_scenes6.h
+++ b/engines/mads/nebular/nebular_scenes6.h
@@ -161,6 +161,54 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene608: public Scene6xx{
+private:
+	int _carMode;
+	int _carFrame;
+	int _carMoveMode;
+	int _dogDeathMode;
+	int _carHotspotId;
+	int _barkCount;
+	int _polycementHotspotId;
+	int _animationMode;
+	int _nextTrigger;
+	int _throwMode;
+
+	bool _resetPositionsFl;
+	bool _dogActiveFl;
+	bool _dogBarkingFl;
+	bool _dogFirstEncounter;
+	bool _rexBeingEaten;
+	bool _dogHitWindow;
+	bool _checkFl;
+	bool _dogSquashFl;
+	bool _dogSafeFl;
+	bool _buttonPressedonTimeFl;
+	bool _dogUnderCar;
+	bool _dogYelping;
+
+	long _dogWindowTimer;
+	long _dogRunTimer;
+
+	uint32 _dogTimer1;
+	uint32 _dogTimer2;
+
+	void resetDogVariables();
+	void restoreAnimations();
+	void setCarAnimations();
+	void handleThrowingBone();
+
+public:
+	Scene608(MADSEngine *vm) : Scene6xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 class Scene620: public Scene6xx{
 public:
 	Scene620(MADSEngine *vm) : Scene6xx(vm) {}


Commit: 85c311059c3fe562b688765820066825a47d2f10
    https://github.com/scummvm/scummvm/commit/85c311059c3fe562b688765820066825a47d2f10
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-13T00:15:48+02:00

Commit Message:
MADS: Implement scene 609

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes6.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index fa2c4a3..debc1df 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -239,7 +239,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 608:	// inside Abdul's garage
 		return new Scene608(vm);
 	case 609:	// outside Buckluster video store
-		return new DummyScene(vm);	// TODO
+		return new Scene609(vm);
 	case 610:	// inside Buckluster video store
 		return new DummyScene(vm);	// TODO
 	case 611:	// back alley
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index 6c228c1..f934c42 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -1255,11 +1255,11 @@ void Scene607::handleThrowingBone() {
 
 		_dogBarking = false;
 		if (_game._objects.isInInventory(OBJ_BONE)) {
-			_game._objects.setRoom(OBJ_BONE, NOWHERE);
+			_game._objects.setRoom(OBJ_BONE, 1);
 			if (_animationMode == 1)
 				_globals[kBone202Status] = 0;
 		} else {
-			_game._objects.setRoom(OBJ_BONES, NOWHERE);
+			_game._objects.setRoom(OBJ_BONES, 1);
 			_game._objects.addToInventory(OBJ_BONE);
 		}
 
@@ -1505,9 +1505,9 @@ void Scene608::handleThrowingBone() {
 			_scene->_sequences.addTimer(1, 2);
 		else {
 			if (_game._objects.isInInventory(OBJ_BONE))
-				_game._objects.setRoom(OBJ_BONE, NOWHERE);
+				_game._objects.setRoom(OBJ_BONE, 1);
 			else {
-				_game._objects.setRoom(OBJ_BONES, NOWHERE);
+				_game._objects.setRoom(OBJ_BONES, 1);
 				_game._objects.addToInventory(OBJ_BONE);
 			}
 			_scene->_sequences.addTimer(60, 3);
@@ -2247,7 +2247,7 @@ void Scene608::actions() {
 			if (_dogActiveFl) {
 				if (_game._trigger == 0) {
 					_scene->_kernelMessages.reset();
-					_scene->_kernelMessages.add(Common::Point(0,0), 0x1110, 34, 0, 120, _game.getQuote(0x301));
+					_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x301));
 				}
 				_throwMode = 6;
 				handleThrowingBone();
@@ -2378,6 +2378,329 @@ void Scene608::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene609::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene609::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', 0));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('h', 0));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXCD_9");
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RXMRC_9");
+
+	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2);  
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
+	_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);  
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 9);
+
+	if (!_game._visitedScenes._sceneRevisited)
+		_globals[kBeenInVideoStore] = false;
+
+	if (_scene->_priorSceneId == 611) {
+		_game._player._playerPos = Common::Point(264, 69);
+		_game._player._facing = FACING_SOUTHWEST; 
+	} else if (_scene->_priorSceneId == 610) {
+		_game._player._playerPos = Common::Point(23, 90);
+		_game._player._facing = FACING_EAST;
+		_scene->_sequences.addTimer(60, 60);
+		_game._player._stepEnabled = false;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(86, 136);
+		_game._player._facing = FACING_NORTHEAST;
+		_game._player._visible   = false;
+		_game._player._stepEnabled = false;
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
+		_scene->loadAnimation(formAnimName('R', 1), 70);
+	} 
+
+	if (_scene->_roomChanged) {
+		_game._objects.addToInventory(OBJ_DOOR_KEY);
+		if (_game._difficulty != DIFFICULTY_EASY)
+			_game._objects.addToInventory(OBJ_PENLIGHT);
+	}
+
+	sceneEntrySound();
+	_game.loadQuoteSet(0x305, 0x306, 0x307, 0x308, 0x309, 0);
+}
+
+void Scene609::step() {
+	switch (_game._trigger) {
+	case 60:
+		_game._player._stepEnabled = false;
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 9);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 61);
+		break; 
+
+	case 61:
+		_scene->_hotspots.activate(0x425, false);
+		_game._player.walk(Common::Point(101, 100), FACING_EAST);
+		_scene->_sequences.addTimer(180, 62);
+		break;
+
+	case 62:
+		_scene->_sequences.remove( _globals._sequenceIndexes[2]);
+		_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
+		_scene->_hotspots.activate(0x425, true);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 9);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 63);
+		break; 
+
+	case 63:
+		if (!_globals[kHasTalkedToHermit] && (_game._difficulty != DIFFICULTY_HARD)) {
+			_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 26, 2, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 7);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(287, 73));
+			_scene->_sequences.setScale(_globals._sequenceIndexes[3], 47);
+		}
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);  
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 9);
+		_game._player._stepEnabled = true;
+		break;
+
+	default:
+		break;
+	}
+
+	switch (_game._trigger) {
+	case 70:
+		_game._player._visible   = true;
+		_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
+		_scene->_sequences.addTimer(6, 71);
+		break;
+
+	case 71:
+		if (!_globals[kHasTalkedToHermit]) {
+			_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 26, 2, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 7);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(287, 73));
+			_scene->_sequences.setScale(_globals._sequenceIndexes[3], 47);
+		}
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 72);
+		break; 
+
+	case 72:
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2);  
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
+		_game._player._stepEnabled = true;
+		break; 
+
+	default:
+		break;
+	}
+}
+
+void Scene609::enterStore() {
+	switch (_game._trigger) {
+	case 0:
+		_game._player._stepEnabled = false;
+		if (_videoDoorMode == 2)
+			_scene->_sequences.addTimer(1, 4);
+		else {
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x305));
+			_scene->_sequences.addTimer(120, 1);
+		}
+		break;
+
+	case 1:
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x306));
+		_scene->_sequences.addTimer(60, 2);
+		break;
+
+	case 2:
+		_game._player._visible        = false; 
+		_globals._sequenceIndexes[5] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], true, 11, 2, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 2); 
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+		break;
+
+	case 3:
+		_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[5]); 
+		_game._player._visible         = true;
+		_game._objects.setRoom(OBJ_DOOR_KEY, 1); 
+		_scene->_sequences.addTimer(15, 4);
+		break;  
+
+	case 4:
+		_game._player._visible         = false; 
+		_globals._sequenceIndexes[5]  = _scene->_sequences.startCycle(_globals._spriteIndexes[5], true, 1);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+		_scene->_sequences.addTimer(15, 5);
+		break;
+
+	case 5:
+		_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+		_game._player._visible   = true;
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 9);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 6);
+		break;
+
+	case 6:
+		_scene->_hotspots.activate(0x425, false);
+		if (_videoDoorMode == 1) {
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 180, _game.getQuote(0x307));
+		}
+		_game._player.walk(Common::Point(23, 90), FACING_WEST); 
+		_scene->_sequences.addTimer(180, 7);
+		break;
+
+	case 7:
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]); 
+		_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 9);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 8);
+		break;
+
+	case 8:
+		_scene->_hotspots.activate(0x425, true);
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);  
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 9);
+		_globals[kBeenInVideoStore] = true;
+		_game._player._stepEnabled     = true;
+		_scene->_nextSceneId = 610;
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene609::preActions() {
+	if (_action.isAction(0x17B, 0x6F, 0x425))
+		_game._player.walk(Common::Point(78, 99), FACING_NORTHWEST);
+}
+
+void Scene609::actions() {
+	if (_action.isAction(0x18C, 0x423)) 
+		_scene->_nextSceneId = 611;
+	else if (_action.isAction(0x18B, 0x425)) {
+		if (!_globals[kBeenInVideoStore]) {
+			switch (_game._trigger) {
+			case 0:
+				_game._player._stepEnabled = false;
+				_scene->_kernelMessages.reset();
+				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x308));
+				_scene->_sequences.addTimer(120, 1);
+				break;
+
+			case 1:
+				_game._player._visible         = false;  
+				_globals._sequenceIndexes[5]  = _scene->_sequences.startCycle(_globals._spriteIndexes[5], true, 1);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+				_scene->_sequences.addTimer(30, 2);
+				break;
+
+			case 2:
+				_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+				_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;    
+				_game._player._visible   = true;
+				_scene->_sequences.addTimer(60, 3);
+				break;
+
+			case 3:
+				_scene->_kernelMessages.reset();
+				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x309));
+				_scene->_sequences.addTimer(120, 4);
+				break;
+
+			case 4:
+				_game._player._stepEnabled = true;
+				break;
+
+			default:
+				break;
+			}
+		} else {
+			_videoDoorMode = 2;
+			enterStore();
+		}
+	} else if (_action.isAction(0x17B, 0x6F, 0x425)) {
+		_videoDoorMode = 1;
+		enterStore();
+	} else if (_action.isAction(0x325, 0x324)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);   
+			_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle (_globals._spriteIndexes[1], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			break;
+
+		case 1: {
+			int syncIdx = _globals._sequenceIndexes[1];
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[1], syncIdx);
+			_scene->_sequences.addTimer(6, 2);
+			}
+			break;
+
+		case 2:
+			_game._player._visible   = false;
+			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 10, 1, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+			break;
+
+		case 3: {
+			int syncIdx = _globals._sequenceIndexes[4];
+			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, -2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], syncIdx); 
+			_scene->_nextSceneId = 504;
+			}
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action._lookFlag)
+		_vm->_dialogs->show(60910);
+	else if (_action.isAction(VERB_LOOK, 0x31E))
+		_vm->_dialogs->show(60911);
+	else if (_action.isAction(VERB_LOOK, 0x421))
+		_vm->_dialogs->show(60912);
+	else if (_action.isAction(VERB_LOOK, 0x427))
+		_vm->_dialogs->show(60913);
+	else if (_action.isAction(VERB_LOOK, 0x33A))
+		_vm->_dialogs->show(60914);
+	else if (_action.isAction(VERB_LOOK, 0x2CD))
+		_vm->_dialogs->show(60915);
+	else if (_action.isAction(VERB_LOOK, 0x324))
+		_vm->_dialogs->show(60916);
+	else if (_action.isAction(VERB_LOOK, 0x41F))
+		_vm->_dialogs->show(60917);
+	else if (_action.isAction(VERB_LOOK, 0x425)) {
+		if (!_globals[kBeenInVideoStore])
+			_vm->_dialogs->show(60918);
+		else
+			_vm->_dialogs->show(60919);
+	} else if (_action.isAction(0x1AD, 0x31E))
+		_vm->_dialogs->show(60730);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene620::setup() {
 	_game._player._spritesPrefix = "";
 	setAAName();
diff --git a/engines/mads/nebular/nebular_scenes6.h b/engines/mads/nebular/nebular_scenes6.h
index d259eab..a5fa754 100644
--- a/engines/mads/nebular/nebular_scenes6.h
+++ b/engines/mads/nebular/nebular_scenes6.h
@@ -209,6 +209,23 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene609: public Scene6xx{
+private:
+	int _videoDoorMode;
+
+	void enterStore();
+
+public:
+	Scene609(MADSEngine *vm) : Scene6xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 class Scene620: public Scene6xx{
 public:
 	Scene620(MADSEngine *vm) : Scene6xx(vm) {}


Commit: 59da02fa9a1922d6c7b47ba128c86a37ada66e48
    https://github.com/scummvm/scummvm/commit/59da02fa9a1922d6c7b47ba128c86a37ada66e48
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-12T20:21:33-04:00

Commit Message:
MADS: Hook in the section 1 sound player

Changed paths:
    engines/mads/game.cpp
    engines/mads/sound.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 3f6c8e0..34b229f 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -161,6 +161,7 @@ void Game::gameLoop() {
 		setSectionHandler();
 		_sectionHandler->preLoadSection();
 		initSection(_sectionNumber);
+		_vm->_sound->init(_sectionNumber);
 		_sectionHandler->postLoadSection();
 
 		_scene._spriteSlots.reset();
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index eaac70c..d46516d 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -48,8 +48,14 @@ void SoundManager::init(int sectionNumber) {
 	switch (_vm->getGameID()) {
 	case GType_RexNebular:
 		// TODO: Other Rex Adlib section drivers
-		assert(sectionNumber == 1);
-		_driver = new Nebular::ASound1(_mixer);
+		switch (sectionNumber) {
+		case 1:
+			_driver = new Nebular::ASound1(_mixer);
+			break;
+		default:
+			_driver = nullptr;
+			break;
+		}
 		break;
 
 	default:


Commit: c19cfb5b641e7a4ac92d766a832bb0f98f6db705
    https://github.com/scummvm/scummvm/commit/c19cfb5b641e7a4ac92d766a832bb0f98f6db705
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-13T17:34:09+02:00

Commit Message:
MADS: Implement scene 610

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes6.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index debc1df..da9a917 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -241,7 +241,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 609:	// outside Buckluster video store
 		return new Scene609(vm);
 	case 610:	// inside Buckluster video store
-		return new DummyScene(vm);	// TODO
+		return new Scene610(vm);
 	case 611:	// back alley
 		return new DummyScene(vm);	// TODO
 	case 612:	// expressway / maintenance building
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index f934c42..8ebbd0b 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -2181,7 +2181,7 @@ void Scene608::actions() {
 			} else
 				_vm->_dialogs->show(60840);
 			break;
-		
+
 		case 1:
 			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[3]);
 			_game._player._visible = true;
@@ -2196,7 +2196,7 @@ void Scene608::actions() {
 			_carMoveMode = 1;
 			_scene->_sequences.addTimer(1, 2);
 			break;
-		
+
 		case 2: {
 			if (_carMoveMode != 0)
 				_scene->_sequences.addTimer(1, 2);
@@ -2213,7 +2213,7 @@ void Scene608::actions() {
 			_game._player._stepEnabled = true;
 			}
 			break;
-			
+
 		default:
 			break;
 		}
@@ -2265,13 +2265,13 @@ void Scene608::actions() {
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 4, 1);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 			break;
-		
+
 		case 1:
 			_vm->_sound->command(9);
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_scene->_dynamicHotspots.remove(_polycementHotspotId);
 			break;
-		
+
 		case 2:
 			_game._objects.addToInventory(OBJ_POLYCEMENT);
 			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[2]);
@@ -2279,7 +2279,7 @@ void Scene608::actions() {
 			_game._player._stepEnabled = true;
 			_vm->_dialogs->showItem(OBJ_POLYCEMENT, 60833);
 			break;
-		
+
 		default:
 			break;
 		}
@@ -2294,20 +2294,20 @@ void Scene608::actions() {
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 2, 1);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 			break;
-		
+
 		case 1:
 			_vm->_sound->command(9);
 			_scene->_sequences.remove(_globals._sequenceIndexes[12]);
 			_game._objects.addToInventory(OBJ_REARVIEW_MIRROR);
 			_vm->_dialogs->showItem(OBJ_REARVIEW_MIRROR, 60827);
 			break;
-		
+
 		case 2:
 			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[2]);
 			_game._player._visible = true;
 			_game._player._stepEnabled = true;
 			break;
-		
+
 		default:
 			break;
 		}
@@ -2390,9 +2390,9 @@ void Scene609::enter() {
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXCD_9");
 	_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RXMRC_9");
 
-	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2);  
+	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
-	_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);  
+	_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 9);
 
 	if (!_game._visitedScenes._sceneRevisited)
@@ -2400,7 +2400,7 @@ void Scene609::enter() {
 
 	if (_scene->_priorSceneId == 611) {
 		_game._player._playerPos = Common::Point(264, 69);
-		_game._player._facing = FACING_SOUTHWEST; 
+		_game._player._facing = FACING_SOUTHWEST;
 	} else if (_scene->_priorSceneId == 610) {
 		_game._player._playerPos = Common::Point(23, 90);
 		_game._player._facing = FACING_EAST;
@@ -2409,13 +2409,13 @@ void Scene609::enter() {
 	} else if (_scene->_priorSceneId != -2) {
 		_game._player._playerPos = Common::Point(86, 136);
 		_game._player._facing = FACING_NORTHEAST;
-		_game._player._visible   = false;
+		_game._player._visible = false;
 		_game._player._stepEnabled = false;
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
 		_scene->loadAnimation(formAnimName('R', 1), 70);
-	} 
+	}
 
 	if (_scene->_roomChanged) {
 		_game._objects.addToInventory(OBJ_DOOR_KEY);
@@ -2435,7 +2435,7 @@ void Scene609::step() {
 		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 9);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 61);
-		break; 
+		break;
 
 	case 61:
 		_scene->_hotspots.activate(0x425, false);
@@ -2449,7 +2449,7 @@ void Scene609::step() {
 		_scene->_hotspots.activate(0x425, true);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 9);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 63);
-		break; 
+		break;
 
 	case 63:
 		if (!_globals[kHasTalkedToHermit] && (_game._difficulty != DIFFICULTY_HARD)) {
@@ -2458,7 +2458,7 @@ void Scene609::step() {
 			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(287, 73));
 			_scene->_sequences.setScale(_globals._sequenceIndexes[3], 47);
 		}
-		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);  
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 9);
 		_game._player._stepEnabled = true;
 		break;
@@ -2469,7 +2469,7 @@ void Scene609::step() {
 
 	switch (_game._trigger) {
 	case 70:
-		_game._player._visible   = true;
+		_game._player._visible = true;
 		_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
 		_scene->_sequences.addTimer(6, 71);
 		break;
@@ -2485,13 +2485,13 @@ void Scene609::step() {
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 1, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 72);
-		break; 
+		break;
 
 	case 72:
-		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2);  
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
 		_game._player._stepEnabled = true;
-		break; 
+		break;
 
 	default:
 		break;
@@ -2518,23 +2518,23 @@ void Scene609::enterStore() {
 		break;
 
 	case 2:
-		_game._player._visible        = false; 
+		_game._player._visible = false;
 		_globals._sequenceIndexes[5] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], true, 11, 2, 0, 0);
-		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 2); 
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 2);
 		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
 		break;
 
 	case 3:
-		_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[5]); 
-		_game._player._visible         = true;
-		_game._objects.setRoom(OBJ_DOOR_KEY, 1); 
+		_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[5]);
+		_game._player._visible = true;
+		_game._objects.setRoom(OBJ_DOOR_KEY, 1);
 		_scene->_sequences.addTimer(15, 4);
-		break;  
+		break;
 
 	case 4:
-		_game._player._visible         = false; 
-		_globals._sequenceIndexes[5]  = _scene->_sequences.startCycle(_globals._spriteIndexes[5], true, 1);
+		_game._player._visible = false;
+		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], true, 1);
 		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
 		_scene->_sequences.addTimer(15, 5);
 		break;
@@ -2542,7 +2542,7 @@ void Scene609::enterStore() {
 	case 5:
 		_scene->_sequences.remove(_globals._sequenceIndexes[5]);
 		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
-		_game._player._visible   = true;
+		_game._player._visible = true;
 		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 9);
@@ -2555,12 +2555,12 @@ void Scene609::enterStore() {
 			_scene->_kernelMessages.reset();
 			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 180, _game.getQuote(0x307));
 		}
-		_game._player.walk(Common::Point(23, 90), FACING_WEST); 
+		_game._player.walk(Common::Point(23, 90), FACING_WEST);
 		_scene->_sequences.addTimer(180, 7);
 		break;
 
 	case 7:
-		_scene->_sequences.remove(_globals._sequenceIndexes[2]); 
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 		_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 9);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 8);
@@ -2568,10 +2568,10 @@ void Scene609::enterStore() {
 
 	case 8:
 		_scene->_hotspots.activate(0x425, true);
-		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);  
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 9);
 		_globals[kBeenInVideoStore] = true;
-		_game._player._stepEnabled     = true;
+		_game._player._stepEnabled = true;
 		_scene->_nextSceneId = 610;
 		break;
 
@@ -2586,7 +2586,7 @@ void Scene609::preActions() {
 }
 
 void Scene609::actions() {
-	if (_action.isAction(0x18C, 0x423)) 
+	if (_action.isAction(0x18C, 0x423))
 		_scene->_nextSceneId = 611;
 	else if (_action.isAction(0x18B, 0x425)) {
 		if (!_globals[kBeenInVideoStore]) {
@@ -2599,16 +2599,16 @@ void Scene609::actions() {
 				break;
 
 			case 1:
-				_game._player._visible         = false;  
-				_globals._sequenceIndexes[5]  = _scene->_sequences.startCycle(_globals._spriteIndexes[5], true, 1);
+				_game._player._visible = false;
+				_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], true, 1);
 				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
 				_scene->_sequences.addTimer(30, 2);
 				break;
 
 			case 2:
 				_scene->_sequences.remove(_globals._sequenceIndexes[5]);
-				_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;    
-				_game._player._visible   = true;
+				_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+				_game._player._visible = true;
 				_scene->_sequences.addTimer(60, 3);
 				break;
 
@@ -2636,8 +2636,8 @@ void Scene609::actions() {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
-			_scene->_sequences.remove(_globals._sequenceIndexes[1]);   
-			_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle (_globals._spriteIndexes[1], false, 6, 1, 0, 0);
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 6, 1, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 5);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			break;
@@ -2652,7 +2652,7 @@ void Scene609::actions() {
 			break;
 
 		case 2:
-			_game._player._visible   = false;
+			_game._player._visible = false;
 			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 10, 1, 0, 0);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
@@ -2662,7 +2662,7 @@ void Scene609::actions() {
 			int syncIdx = _globals._sequenceIndexes[4];
 			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, -2);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
-			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], syncIdx); 
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], syncIdx);
 			_scene->_nextSceneId = 504;
 			}
 			break;
@@ -2701,6 +2701,189 @@ void Scene609::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene610::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x108);
+	_scene->addActiveVocab(0xD);
+}
+
+void Scene610::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('p', -1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RXMRC_9");
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 1));
+
+	_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 60, 0, 0, 0);
+	_scene->_sequences.setDepth (_globals._sequenceIndexes[4], 13);
+	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 30, 0, 0, 0);
+	_scene->_sequences.setDepth (_globals._sequenceIndexes[3], 9);
+
+	if (!_game._visitedScenes._sceneRevisited)
+		_cellCharging = false;
+
+	if (_game._objects[OBJ_PHONE_HANDSET]._roomNumber == _scene->_currentSceneId) {
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 9, 0, 0, 0);
+		_handsetHotspotId = _scene->_dynamicHotspots.add(0x108, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(_handsetHotspotId, Common::Point(132, 121), FACING_NORTHWEST);
+		if ((_globals[kHandsetCellStatus] == 2) && (_game._difficulty == DIFFICULTY_HARD) && !_globals[kDurafailRecharged])
+			_globals[kHandsetCellStatus] = 1;
+	}
+
+	if (_scene->_roomChanged && _game._difficulty != DIFFICULTY_EASY)
+		_game._objects.addToInventory(OBJ_PENLIGHT);
+
+	if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(175, 152);
+		_game._player._facing = FACING_NORTHWEST;
+	}
+
+	sceneEntrySound();
+}
+
+void Scene610::step() {
+	if (_cellCharging) {
+		long diff = _scene->_frameStartTime - _lastFrameTimer;
+		if ((diff >= 0) && (diff <= 60))
+			_cellChargingTimer += diff;
+		else
+			_cellChargingTimer++;
+
+		_lastFrameTimer = _scene->_frameStartTime;
+	}
+
+	// CHECKME: _checkVal is always false, could be removed
+	if ((_cellChargingTimer >= 60) && !_checkVal) {
+		_checkVal = true;
+		_globals[kHandsetCellStatus] = 1;
+		_cellCharging = false;
+		_checkVal = false;
+		_cellChargingTimer = 0;
+	}
+}
+
+void Scene610::actions() {
+	if (_action.isAction(0x1CE, 0x427))
+		_scene->_nextSceneId = 609;
+	else if (_action.isAction(VERB_TAKE, 0x108)) {
+		if ( _game._trigger || !_game._objects.isInInventory(OBJ_PHONE_HANDSET)) {
+			switch (_game._trigger) {
+			case 0:
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], true, 8, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 2);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 2, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+				break;
+
+			case 1:
+				_vm->_sound->command(9);
+				_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+				_scene->_dynamicHotspots.remove(_handsetHotspotId);
+				_game._objects.addToInventory(OBJ_PHONE_HANDSET);
+				_vm->_dialogs->showItem(OBJ_PHONE_HANDSET, 61017);
+				break;
+
+			case 2:
+				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[2]);
+				_game._player._visible = true;
+				_game._player._stepEnabled = true;
+				break;
+				
+			default:
+				break;
+			}
+		}
+	} else if (_action.isAction(VERB_PUT, 0x108, 0x42F)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], true, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 2, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+
+		case 1:
+			_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 9, 0, 0, 0);
+			_handsetHotspotId = _scene->_dynamicHotspots.add(0x108, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+			_scene->_dynamicHotspots.setPosition(_handsetHotspotId, Common::Point(132, 121), FACING_NORTHWEST);
+			_game._objects.setRoom(OBJ_PHONE_HANDSET, _scene->_currentSceneId);
+			break;
+
+		case 2:
+			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[2]);
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			if ((_globals[kHandsetCellStatus] == 2) && (_game._difficulty == DIFFICULTY_HARD) && !_globals[kDurafailRecharged])
+				_cellCharging = true;
+
+			_vm->_dialogs->show(61032);
+			break;
+			
+		default:
+			break;
+		}
+	} else if (_action.isAction(VERB_LOOK, 0x442))
+		_vm->_dialogs->show(61010);
+	else if (_action.isAction(VERB_LOOK, 0x44B))
+		_vm->_dialogs->show(61011);
+	else if (_action.isAction(VERB_LOOK, 0x441))
+		_vm->_dialogs->show(61012);
+	else if (_action.isAction(VERB_LOOK, 0x43C))
+		_vm->_dialogs->show(61013);
+	else if (_action.isAction(VERB_LOOK, 0x427))
+		_vm->_dialogs->show(61014);
+	else if (_action._lookFlag)
+		_vm->_dialogs->show(61015);
+	else if (_action.isAction(VERB_LOOK, 0x4A1))
+		_vm->_dialogs->show(61018);
+	else if (_action.isAction(VERB_LOOK, 0x498)) {
+		if (_game._visitedScenes.exists(601))
+			_vm->_dialogs->show(61020);
+		else
+			_vm->_dialogs->show(61019);
+	} else if (_action.isAction(VERB_LOOK, 0x29F))
+		_vm->_dialogs->show(61021);
+	else if (_action.isAction(VERB_LOOK, 0x429))
+		_vm->_dialogs->show(61022);
+	else if (_action.isAction(VERB_LOOK, 0x42D))
+		_vm->_dialogs->show(61023);
+	else if (_action.isAction(VERB_TAKE, 0x42D))
+		_vm->_dialogs->show(61024);
+	else if (_action.isAction(VERB_LOOK, 0x431))
+		_vm->_dialogs->show(61025);
+	else if (_action.isAction(VERB_LOOK, 0x108) && (_action._mainObjectSource == 4))
+		_vm->_dialogs->show(61026);
+	else if (_action.isAction(VERB_LOOK, 0x42F))
+		_vm->_dialogs->show(61027);
+	else if (_action.isAction(VERB_LOOK, 0x42A))
+		_vm->_dialogs->show(61028);
+	else if (_action.isAction(VERB_PUT, 0x42A)
+		&& _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId)))
+		_vm->_dialogs->show(61029);
+	else if ( _action.isAction(0x44F) || _action.isAction(0x444) || _action.isAction(0x430)
+		|| _action.isAction(0x44C) || _action.isAction(0x44D) || _action.isAction(0x446)
+		|| _action.isAction(0x497) || _action.isAction(0x449) || _action.isAction(0x44E)
+		|| _action.isAction(0x450) || _action.isAction(0x42C)) {
+		if (_action.isAction(VERB_LOOK))
+			_vm->_dialogs->show(61030);
+		else if (_action.isAction(VERB_TAKE))
+			_vm->_dialogs->show(61031);
+		else
+			return;
+	} else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene620::setup() {
 	_game._player._spritesPrefix = "";
 	setAAName();
diff --git a/engines/mads/nebular/nebular_scenes6.h b/engines/mads/nebular/nebular_scenes6.h
index a5fa754..10bf2e8 100644
--- a/engines/mads/nebular/nebular_scenes6.h
+++ b/engines/mads/nebular/nebular_scenes6.h
@@ -226,6 +226,27 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene610: public Scene6xx{
+private:
+	int _handsetHotspotId;
+	int _checkVal;
+
+	bool _cellCharging;
+
+	long _cellChargingTimer;
+	uint32 _lastFrameTimer;
+
+public:
+	Scene610(MADSEngine *vm) : Scene6xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 class Scene620: public Scene6xx{
 public:
 	Scene620(MADSEngine *vm) : Scene6xx(vm) {}


Commit: 4033dc5dac2662498defa0ac108625471b3b27ed
    https://github.com/scummvm/scummvm/commit/4033dc5dac2662498defa0ac108625471b3b27ed
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-14T09:19:54-04:00

Commit Message:
MADS: Implemented sound player for scene group 2

Changed paths:
    engines/mads/mads.cpp
    engines/mads/nebular/sound_nebular.cpp
    engines/mads/nebular/sound_nebular.h
    engines/mads/sound.cpp



diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp
index 193346d..bcd8fdb 100644
--- a/engines/mads/mads.cpp
+++ b/engines/mads/mads.cpp
@@ -43,7 +43,7 @@ MADSEngine::MADSEngine(OSystem *syst, const MADSGameDescription *gameDesc) :
 	_invObjectsAnimated = true;
 	_textWindowStill = false;
 	_screenFade = SCREEN_FADE_SMOOTH;
-	_musicFlag = false;
+	_musicFlag = true;
 	_dithering = false;
 
 	_debugger = nullptr;
diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp
index de6846b..5636598 100644
--- a/engines/mads/nebular/sound_nebular.cpp
+++ b/engines/mads/nebular/sound_nebular.cpp
@@ -1202,6 +1202,368 @@ int ASound1::command2627293032() {
 	return (_commandParam > 0x40) ? _commandParam - 0x40 : _commandParam & 0xff00;
 }
 
+
+/*-----------------------------------------------------------------------*/
+
+const ASound2::CommandPtr ASound2::_commandList[44] = {
+	&ASound2::command0, &ASound2::command1, &ASound2::command2, &ASound2::command3,
+	&ASound2::command4, &ASound2::command5, &ASound2::command6, &ASound2::command7,
+	&ASound2::command8, &ASound2::command9, &ASound2::command10, &ASound2::command11,
+	&ASound2::command12, &ASound2::command13, &ASound2::command14, &ASound2::command15,
+	&ASound2::command16, &ASound2::command17, &ASound2::command18, &ASound2::command19,
+	&ASound2::command20, &ASound2::command21, &ASound2::command22, &ASound2::command23,
+	&ASound2::command24, &ASound2::command25, &ASound2::command26, &ASound2::command27,
+	&ASound2::command28, &ASound2::command29, &ASound2::command30, &ASound2::command31,
+	&ASound2::command32, &ASound2::command33, &ASound2::command34, &ASound2::command35,
+	&ASound2::command36, &ASound2::command37, &ASound2::command38, &ASound2::command39,
+	&ASound2::command40, &ASound2::command41, &ASound2::command42, &ASound2::command43
+};
+
+ASound2::ASound2(Audio::Mixer *mixer) : ASound(mixer, "asound.002", 0x15E0) {
+	_command12Param = 0xFD;
+
+	// Load sound samples
+	_soundFile.seek(_dataOffset + 0x144);
+	for (int i = 0; i < 164; ++i)
+		_samples.push_back(AdlibSample(_soundFile));
+}
+
+int ASound2::command(int commandId, int param) {
+	if (commandId > 43)
+		return 0;
+
+	_frameCounter = 0;
+	return (this->*_commandList[commandId])();
+}
+
+int ASound2::command9() {
+	byte *pData1 = loadData(0x1094, 376);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[0].load(pData1);
+		_channels[2].load(loadData(0x123E, 130));
+		
+		command9Randomize();
+		_channels[1].load(loadData(0x120C, 50));
+	}
+	return 0;
+}
+
+void ASound2::command9Randomize() {
+	// Randomization
+	int v;
+	while (((v = getRandomNumber()) & 0x3F) > 36)
+		;
+
+	byte *pData = loadData(0x120C, 50);
+	command9Apply(pData, v + 20, -1);
+	command9Apply(pData + 1, 10 - ((v + 1) / 6), 1);
+}
+
+void ASound2::command9Apply(byte *data, int val, int incr) {
+	data += 8;
+	for (int ctr = 0; ctr < 10; ++ctr, data += 4, val += incr) {
+		*data = val;
+	}
+}
+
+int ASound2::command10() {
+	byte *pData1 = loadData(0x12C0, 60);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[0].load(pData1);
+		_channels[1].load(loadData(0x12FC, 318));
+		_channels[2].load(loadData(0x143A, 110));
+	}
+
+	return 0;
+}
+
+int ASound2::command11() {
+	byte *pData = loadData(0x14A8, 170);
+	if (!isSoundActive(pData)) {
+		playSoundData(pData);
+		playSoundData(loadData(0x1552, 1802));
+		playSoundData(loadData(0x1C5C, 716));
+		playSoundData(loadData(0x1F28, 106));
+	}
+
+	return 0;
+}
+
+int ASound2::command12() {
+	_command12Param += 26;
+	byte v = _command12Param & 0x7f;
+
+	byte *pData = loadData(0x4A5E, 38);
+	pData[5] = pData[20] = v;
+	playSoundData(pData);
+
+	pData = loadData(0x4A84, 30);
+	pData[5] = pData[18] = v;
+	playSoundData(pData);
+
+	return 0;
+}
+
+int ASound2::command13() {
+	playSoundData(loadData(0x4AA2, 20));
+	playSoundData(loadData(0x4AB6, 20));
+
+	return 0;
+}
+
+int ASound2::command14() {
+	playSound(0x4ACA, 40);
+	playSound(0x4AF2, 42);
+
+	return 0;
+}
+
+int ASound2::command15() {
+	byte *pData1 = loadData(0x1F92, 1074);
+	if (!isSoundActive(pData1)) {
+		command1();
+		playSoundData(pData1);
+		playSound(0x23C4, 1050);
+		playSound(0x27DE, 58);
+		playSound(0x2818, 712);
+		playSound(0x2AE0, 256);
+	}
+
+	return 0;
+}
+
+int ASound2::command16() {
+	byte *pData1 = loadData(0x3960, 280);
+	if (!isSoundActive(pData1)) {
+		command1();
+		playSoundData(pData1);
+		playSound(0x3A78, 266);
+		playSound(0x3B72, 322);
+		playSound(0x3CC4, 488);
+		playSound(0x3EAC, 104);
+		playSound(0x3F14, 104);
+	}
+
+	return 0;
+}
+
+int ASound2::command17() {
+	byte *pData1 = loadData(0x3F7C, 432);
+	if (!isSoundActive(pData1)) {
+		command1();
+		playSoundData(pData1);
+		playSound(0x412C, 422);
+		playSound(0x42D2, 424);
+		playSound(0x447A, 418);
+	}
+
+	return 0;
+}
+
+static const int command18_list[16][2] = {
+	{ 0x337C, 28 }, { 0x3398, 26 }, { 0x33B2, 26 }, { 0x33CC, 26 },
+	{ 0x33E6, 56 }, { 0x341E, 46 }, { 0x344C, 56 }, { 0x3484, 22 },
+	{ 0x349A, 38 }, { 0x34C0, 62 }, { 0x34FE, 26 }, { 0x3518, 26 },
+	{ 0x3532, 26 }, { 0x354C, 26 }, { 0x3566, 32 }, { 0x3586, 24 }
+};
+
+int ASound2::command18() {
+	if (_channels[3]._activeCount == 0) {
+		int idx = (getRandomNumber() & 0x1E) >> 1;
+		byte *pData = loadData(command18_list[idx][0], command18_list[idx][1]);
+		_channels[3].load(pData);
+	}
+
+	return 0;
+}
+
+int ASound2::command19() {
+	byte *pData1 = loadData(0x2BE0, 366);
+	if (!isSoundActive(pData1)) {
+		command1();
+		playSoundData(pData1);
+		playSound(0x2D4E, 460);
+		playSound(0x2F1A, 266);
+		playSound(0x3024, 328);
+		playSound(0x316C, 162);
+		playSound(0x320E, 366);
+	}
+
+	return 0;
+}
+
+int ASound2::command20() {
+	playSound(0x4A36, 40);
+
+	return 0;
+}
+
+int ASound2::command21() {
+	playSound(0x49DE, 16);
+	playSound(0x49EE, 16);
+	playSound(0x49FF, 16);
+	
+	return 0;
+}
+
+int ASound2::command22() {
+	playSound(0x4A0E, 24);
+	playSound(0x4A26, 16);
+
+	return 0;
+}
+
+int ASound2::command23() {
+	playSound(0x49B6, 16);
+
+	return 0;
+}
+
+int ASound2::command24() {
+	playSound(0x49C6, 24);
+
+	return 0;
+}
+
+int ASound2::command25() {
+	playSound(0x49AC, 10);
+
+	return 0;
+}
+
+int ASound2::command26() {
+	playSound(0x498A, 14);
+	playSound(0x4998, 20);
+
+	return 0;
+}
+
+int ASound2::command27() {
+	playSound(0x4912, 80);
+	playSound(0x4962, 40);
+
+	return 0;
+}
+
+int ASound2::command28() {
+	playSound(0x48E8, 28);
+	playSound(0x4904, 14);
+
+	return 0;
+}
+
+int ASound2::command29() {
+	playSound(0x48B2, 22);
+
+	return 0;
+}
+
+int ASound2::command30() {
+	playSound(0x4870, 22);
+	playSound(0x4886, 22);
+	playSound(0x489C, 22);
+
+	return 0;
+}
+
+int ASound2::command31() {
+	playSound(0x482E, 22);
+	playSound(0x4844, 22);
+	playSound(0x489C, 22);
+
+	return 0;
+}
+
+int ASound2::command32() {
+	playSound(0x46E8, 10);
+
+	return 0;
+}
+
+int ASound2::command33() {
+	playSound(0x46D8, 16);
+
+	return 0;
+}
+
+int ASound2::command34() {
+	playSound(0x46C8, 16);
+
+	return 0;
+}
+
+int ASound2::command35() {
+	playSound(0x46B2, 22);
+
+	return 0;
+}
+
+int ASound2::command36() {
+	playSound(0x4624, 16);
+
+	return 0;
+}
+
+int ASound2::command37() {
+	playSound(0x4674, 20);
+	playSound(0x4688, 32);
+	playSound(0x46A8, 10);
+
+	return 0;
+}
+
+int ASound2::command38() {
+	byte *pData1 = loadData(0x359E, 202);
+	if (!isSoundActive(pData1)) {
+		command1();
+		playSoundData(pData1);
+		playSound(0x3668, 220);
+		playSound(0x3744, 124);
+		playSound(0x37C0, 162);
+		playSound(0x3862, 78);
+		playSound(0x38B0, 176);
+	}
+
+	return 0;
+}
+
+int ASound2::command39() {
+	byte *pData = loadData(0x466A, 10);
+	pData[6] = (getRandomNumber() & 7) + 85;
+	playSoundData(pData);
+
+	return 0;
+}
+
+int ASound2::command40() {
+	playSound(0x4634, 34);
+	playSound(0x4656, 20);
+
+	return 0;
+}
+
+int ASound2::command41() {
+	playSound(0x48C8, 32);
+
+	return 0;
+}
+
+int ASound2::command42() {
+	playSound(0x46F2, 156);
+	playSound(0x478E, 160);
+
+	return 0;
+}
+
+int ASound2::command43() {
+	playSound(0x4B1C, 40);
+	playSound(0x4B44, 41);
+
+	return 0;
+}
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/sound_nebular.h b/engines/mads/nebular/sound_nebular.h
index 44e108f..3c69c0c 100644
--- a/engines/mads/nebular/sound_nebular.h
+++ b/engines/mads/nebular/sound_nebular.h
@@ -405,6 +405,57 @@ public:
 	virtual int command(int commandId, int param);
 };
 
+class ASound2 : public ASound {
+private:
+	byte _command12Param;
+private:
+	typedef int (ASound2::*CommandPtr)();
+	static const CommandPtr _commandList[44];
+
+	int command9();
+	int command10();
+	int command11();
+	int command12();
+	int command13();
+	int command14();
+	int command15();
+	int command16();
+	int command17();
+	int command18();
+	int command19();
+	int command20();
+	int command21();
+	int command22();
+	int command23();
+	int command24();
+	int command25();
+	int command26();
+	int command27();
+	int command28();
+	int command29();
+	int command30();
+	int command31();
+	int command32();
+	int command33();
+	int command34();
+	int command35();
+	int command36();
+	int command37();
+	int command38();
+	int command39();
+	int command40();
+	int command41();
+	int command42();
+	int command43();
+
+	void command9Randomize();
+	void command9Apply(byte *data, int val, int incr);
+public:
+	ASound2(Audio::Mixer *mixer);
+
+	virtual int command(int commandId, int param);
+};
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index d46516d..3dc53be 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -52,6 +52,9 @@ void SoundManager::init(int sectionNumber) {
 		case 1:
 			_driver = new Nebular::ASound1(_mixer);
 			break;
+		case 2:
+			_driver = new Nebular::ASound2(_mixer);
+			break;
 		default:
 			_driver = nullptr;
 			break;


Commit: 2e221fe34fec279e088f703a925144ea2152a18f
    https://github.com/scummvm/scummvm/commit/2e221fe34fec279e088f703a925144ea2152a18f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-14T22:21:54+03:00

Commit Message:
MADS: Replace some magic values of the monkey status

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index e4c09fa..3943704 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1681,7 +1681,7 @@ void Scene208::enter() {
 
 	_game.loadQuoteSet(0x81, 0x46, 0);
 
-	if ((_scene->_priorSceneId == 207) && (_globals[kMonkeyStatus] == 1)) {
+	if ((_scene->_priorSceneId == 207) && (_globals[kMonkeyStatus] == MONKEY_HAS_BINOCULARS)) {
 		int msgIndex = _scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(129));
 		_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
 	}
@@ -2764,7 +2764,7 @@ void Scene209::enter() {
 	if (_scene->_roomChanged) {
 		_game._objects.addToInventory(OBJ_POISON_DARTS);
 		_game._objects.addToInventory(OBJ_BLOWGUN);
-		_globals[kMonkeyStatus] = 1;
+		_globals[kMonkeyStatus] = MONKEY_HAS_BINOCULARS;
 	}
 
 	_pitchFl = false;
@@ -2792,7 +2792,7 @@ void Scene209::enter() {
 }
 
 void Scene209::step() {
-	if (!_playingAnimFl && !_pitchFl && !_fallFl && !_dodgeFl && (_pauseMode == 0) && (_globals[kMonkeyStatus] == 1)) {
+	if (!_playingAnimFl && !_pitchFl && !_fallFl && !_dodgeFl && (_pauseMode == 0) && (_globals[kMonkeyStatus] == MONKEY_HAS_BINOCULARS)) {
 		int randAction = _vm->getRandomNumber(1,50);
 		switch (randAction) {
 		case 1:
@@ -3159,7 +3159,7 @@ void Scene209::preActions() {
 	if (_action.isAction(VERB_WALK_TOWARDS, 0x84))
 		_game._player._walkOffScreenSceneId = 208;
 
-	if (_globals[kMonkeyStatus] == 1) {
+	if (_globals[kMonkeyStatus] == MONKEY_HAS_BINOCULARS) {
 		if ((_action.isAction(VERB_SHOOT) || _action.isAction(VERB_HOSE_DOWN)) && _action.isTarget(NOUN_MONKEY)
 			&& _action.isObject(NOUN_BLOWGUN) && _game._objects.isInInventory(OBJ_BLOWGUN) && _game._objects.isInInventory(OBJ_POISON_DARTS)) {
 			_game._player._prepareWalkPos = Common::Point(111, 129);
@@ -3296,7 +3296,7 @@ void Scene209::actions() {
 		return;
 	}
 
-	if (_globals[kMonkeyStatus] == 1) {
+	if (_globals[kMonkeyStatus] == MONKEY_HAS_BINOCULARS) {
 		if ((_action.isAction(VERB_SHOOT) || _action.isAction(VERB_HOSE_DOWN)) && _action.isAction(NOUN_MONKEY)
 			&& _action.isAction(NOUN_BLOWGUN) && _game._objects.isInInventory(OBJ_BLOWGUN) && _game._objects.isInInventory(OBJ_POISON_DARTS)) {
 			if (_action.isAction(VERB_SHOOT, NOUN_BLOWGUN, NOUN_MONKEY) && !_startShootingInTimerFl) {
@@ -3463,13 +3463,13 @@ void Scene209::actions() {
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x100)) {
-		if (_globals[kMonkeyStatus] == 1) {
+		if (_globals[kMonkeyStatus] == MONKEY_HAS_BINOCULARS) {
 			if (_monkeyPosition == 1)
 				_vm->_dialogs->show(0x51B5);
 			else
 				_vm->_dialogs->show(0x51B6);
 		} else {
-			if (_globals[kMonkeyStatus] == 0)
+			if (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY)
 				_vm->_dialogs->show(0x51B5);
 			else
 				_vm->_dialogs->show(0x51B7);


Commit: 2c9568c9213aedb064e251c90e0ed8c6d04fce49
    https://github.com/scummvm/scummvm/commit/2c9568c9213aedb064e251c90e0ed8c6d04fce49
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-14T21:43:56+02:00

Commit Message:
MADS: Implement scene 611

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes6.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index da9a917..a4ec04c 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -243,7 +243,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 610:	// inside Buckluster video store
 		return new Scene610(vm);
 	case 611:	// back alley
-		return new DummyScene(vm);	// TODO
+		return new Scene611(vm);
 	case 612:	// expressway / maintenance building
 		return new DummyScene(vm);	// TODO
 	case 620:	// cutscene, viewport glass breaking
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index 8ebbd0b..7006acc 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -2715,9 +2715,9 @@ void Scene610::enter() {
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 1));
 
 	_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 60, 0, 0, 0);
-	_scene->_sequences.setDepth (_globals._sequenceIndexes[4], 13);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 13);
 	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 30, 0, 0, 0);
-	_scene->_sequences.setDepth (_globals._sequenceIndexes[3], 9);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 9);
 
 	if (!_game._visitedScenes._sceneRevisited)
 		_cellCharging = false;
@@ -2791,7 +2791,7 @@ void Scene610::actions() {
 				_game._player._visible = true;
 				_game._player._stepEnabled = true;
 				break;
-				
+
 			default:
 				break;
 			}
@@ -2824,7 +2824,7 @@ void Scene610::actions() {
 
 			_vm->_dialogs->show(61032);
 			break;
-			
+
 		default:
 			break;
 		}
@@ -2884,6 +2884,1381 @@ void Scene610::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene611::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x275);
+	_scene->addActiveVocab(0xD);
+}
+
+void Scene611::handleRatMoves() {
+	_ratPresentFl = false;
+	_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 12, 1, 0, 0);
+	_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 11, -2);
+	_ratTimer = _game._player._priorTimer;
+	_scene->_dynamicHotspots.remove(_ratHotspotId);
+}
+
+void Scene611::handleTrading() {
+	if (_game._objects.isInInventory(OBJ_DURAFAIL_CELLS))
+		_game._objects.setRoom(OBJ_DURAFAIL_CELLS, 1);
+
+	if (_game._objects.isInInventory(OBJ_PHONE_CELLS))
+		_game._objects.setRoom(OBJ_PHONE_CELLS, 1);
+
+	_game._objects.addToInventory(OBJ_FAKE_ID);
+}
+
+void Scene611::setDialogNode(int node) {
+	if (node > 0)
+		_hermitDialogNode = node;
+
+	_game._player._stepEnabled = true;
+
+	switch (node) {
+	case 0:
+		_scene->_userInterface.setup(kInputBuildingSentences);
+		_duringDialogFl = false;
+		_hermitDialogNode = 0;
+		break;
+
+	case 1:
+		_dialog1.start();
+		_duringDialogFl = true;
+		_hermitDialogNode = 1;
+		break;
+
+	case 2:
+		_dialog2.start();
+		_duringDialogFl = true;
+		_hermitDialogNode = 2;
+		break;
+
+	default:
+		break;
+	}
+}
+
+bool Scene611::check2ChargedBatteries() {
+	if ((_game._objects.isInInventory(OBJ_DURAFAIL_CELLS) && !_game._objects.isInInventory(OBJ_PHONE_CELLS))
+		|| (!_game._objects.isInInventory(OBJ_DURAFAIL_CELLS) && _game._objects.isInInventory(OBJ_PHONE_CELLS)))
+		return true;
+
+	return false;
+}
+
+bool Scene611::check4ChargedBatteries() {
+	if (_game._objects.isInInventory(OBJ_DURAFAIL_CELLS) && _game._objects.isInInventory(OBJ_PHONE_CELLS) && _globals[136])
+		return true;
+
+	return false;
+}
+
+void Scene611::handleTalking(int delay) {
+	if (_hermitTalkingFl)
+		_alreadyTalkingFl = true;
+
+	_hermitTalkingFl = true;
+	_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+	_scene->_sequences.addTimer(delay, 100);
+}
+
+void Scene611::handleSubDialog1() {
+	switch (_action._activeAction._verbId) {
+	case 0x287:
+		_stickFingerFl = true;
+		_nextFrame = 34;
+		_hermitMovingFl = false;
+		_hermitMode = 5;
+		displayHermitQuestions(5);
+		_dialog1.write(0x287, false);
+		if (!_dialog1.read(0x288))
+			_dialog1.write(0x28E, true);
+
+		_dialog2.write(0x29C, true);
+		_dialog2.write(0x29D, true);
+		_dialog2.write(0x29E, true);
+		setDialogNode(2);
+		break;
+
+	case 0x288:
+		handleTalking(500);
+		displayHermitQuestions(6);
+		_dialog1.write(0x288, false);
+		_dialog1.write(0x289, true);
+		if (!_dialog1.read(0x287))
+			_dialog1.write(0x28E, true);
+
+		setDialogNode(1);
+		break;
+
+	case 0x289:
+		handleTalking(500);
+		displayHermitQuestions(10);
+		_dialog1.write(0x289, false);
+		_dialog1.write(0x28A, true);
+		_dialog1.write(0x28B, true);
+		setDialogNode(1);
+		break;
+
+	case 0x28A:
+		handleTalking(500);
+		displayHermitQuestions(11);
+		_dialog1.write(0x28A, false);
+		setDialogNode(1);
+		break;
+
+	case 0x28B:
+		handleTalking(500);
+		displayHermitQuestions(12);
+		_dialog1.write(0x28C, true);
+		_dialog1.write(0x28D, true);
+		_dialog1.write(0x28B, false);
+		setDialogNode(1);
+		break;
+
+	case 0x28C:
+		handleTalking(500);
+		displayHermitQuestions(13);
+		_dialog1.write(0x28C, false);
+		setDialogNode(1);
+		break;
+
+	case 0x28D:
+		handleTalking(500);
+		displayHermitQuestions(14);
+		_dialog1.write(0x290, true);
+		_dialog1.write(0x28D, false);
+		_dialog1.write(0x28F, true);
+		setDialogNode(1);
+		break;
+
+	case 0x28E:
+		handleTalking(500);
+		displayHermitQuestions(15);
+		_dialog1.write(0x295, true);
+		_dialog1.write(0x28E, false);
+		setDialogNode(1);
+		break;
+
+	case 0x290:
+		handleTalking(500);
+		displayHermitQuestions(17);
+		_dialog1.write(0x290, false);
+		_dialog1.write(0x28E, false);
+		if (!_dialog1.read(0x28F))
+			_dialog1.write(0x291, true);
+
+		setDialogNode(1);
+		break;
+
+	case 0x291:
+		handleTalking(500);
+		displayHermitQuestions(18);
+		_dialog1.write(0x291, false);
+		if ((!_game._objects.isInInventory(OBJ_DURAFAIL_CELLS)) && (!_game._objects.isInInventory(OBJ_PHONE_CELLS))) {
+			_dialog1.write(0x292, true);
+			_dialog1.write(0x293, true);
+		}
+
+		if ((_game._objects.isInInventory(OBJ_DURAFAIL_CELLS)) || (_game._objects.isInInventory(OBJ_PHONE_CELLS)))
+			_dialog1.write(0x294, true);
+
+		if (!_game._objects.isInInventory(OBJ_DURAFAIL_CELLS) && !_game._objects.isInInventory(OBJ_PHONE_CELLS))
+			_globals[kExecuted_1_11] = true;
+
+		setDialogNode(1);
+		break;
+
+	case 0x28F:
+		handleTalking(500);
+		displayHermitQuestions(16);
+		_dialog1.write(0x28F, false);
+		if (!_dialog1.read(0x290))
+			_dialog1.write(0x291, true);
+
+		setDialogNode(1);
+		break;
+
+	case 0x295:
+		handleTalking(500);
+		displayHermitQuestions(20);
+		_dialog1.write(0x295, false);
+		setDialogNode(1);
+		break;
+
+	case 0x292:
+		handleTalking(500);
+		displayHermitQuestions(19);
+		_dialog1.write(0x292, false);
+		_dialog1.write(0x293, false);
+		setDialogNode(1);
+		break;
+
+	case 0x293: {
+		handleTalking(200);
+		_scene->_kernelMessages.reset();
+
+		Common::String curQuote = _game.getQuote(0x2D1);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y), 0xFDFC, 0, 0, 120, curQuote);
+
+		curQuote = _game.getQuote(0x2D2);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 14), 0xFDFC, 0, 0, 120, curQuote);
+
+		_dialog1.write(0x293, false);
+		setDialogNode(0);
+		}
+		break;
+
+	case 0x294: {
+		bool hermitPleasedFl = false;
+
+		switch (_game._difficulty) {
+		case DIFFICULTY_EASY:
+			hermitPleasedFl = _game._objects.isInInventory(OBJ_DURAFAIL_CELLS) || _game._objects.isInInventory(OBJ_PHONE_CELLS);
+			break;
+
+		case DIFFICULTY_MEDIUM:
+			hermitPleasedFl = _game._objects.isInInventory(OBJ_DURAFAIL_CELLS) && _game._objects.isInInventory(OBJ_PHONE_CELLS);
+			break;
+
+		default: // HARD
+			hermitPleasedFl = check4ChargedBatteries();
+			break;
+		}
+
+		if (hermitPleasedFl) {
+			_hermitDisplayedQuestion = 21;
+			if (!_giveBatteriesFl)
+				setDialogNode(0);
+			else
+				_giveBatteriesFl = false;
+		} else if (((_game._difficulty == DIFFICULTY_MEDIUM) || (_game._difficulty == DIFFICULTY_HARD)) && check2ChargedBatteries()) {
+			_hermitDisplayedQuestion = 22;
+			if (!_giveBatteriesFl)
+				setDialogNode(0);
+			else
+				_giveBatteriesFl = false;
+		} else {
+			_hermitDisplayedQuestion = 23;
+			if (!_giveBatteriesFl)
+				setDialogNode(0);
+			else
+				_giveBatteriesFl = false;
+		}
+		_startTradingFl = true;
+		}
+		break;
+
+	case 0x296: {
+		_scene->_kernelMessages.reset();
+
+		Common::String curQuote = _game.getQuote(0x2E6);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 14), 0xFDFC, 0, 0, 120, curQuote);
+
+		setDialogNode(0);
+		handleTalking(200);
+		}
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene611::handleSubDialog2() {
+	switch (_action._activeAction._verbId) {
+	case 0x29C:
+		displayHermitQuestions(7);
+		setDialogNode(1);
+		handleTalking(500);
+		break;
+
+	case 0x29D:
+		displayHermitQuestions(8);
+		setDialogNode(1);
+		handleTalking(500);
+		break;
+
+	case 0x29E:
+		displayHermitQuestions(9);
+		setDialogNode(1);
+		handleTalking(500);
+		break;
+
+	case 0x29F: {
+		_scene->_kernelMessages.reset();
+		Common::String curQuote = _game.getQuote(0x2A7);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 14), 0xFDFC, 0, 0, 120, curQuote);
+		setDialogNode(0);
+		_dialog2.write(0x29F, false);
+		}
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene611::handleDialog() {
+	if (_game._trigger == 0) {
+		_scene->_kernelMessages.reset();
+		_game._player._stepEnabled = false;
+
+		Common::String curQuote = _game.getQuote(_action._activeAction._verbId);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+
+		if (width > 200) {
+			Common::String subQuote1, subQuote2;
+			_game.splitQuote(curQuote, subQuote1, subQuote2);
+			_scene->_kernelMessages.add(Common::Point(0, -14), 0x1110, 34, 0, 150, subQuote1);
+
+			if (_action._activeAction._verbId == 0x29D)
+				_scene->_kernelMessages.add(Common::Point(-18, 0), 0x1110, 34, 1, 150, subQuote2);
+			else if (_action._activeAction._verbId == 0x28A)
+				_scene->_kernelMessages.add(Common::Point(-10, 0), 0x1110, 34, 1, 150, subQuote2);
+			else
+				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 1, 150, subQuote2);
+
+			_scene->_sequences.addTimer(170, 50);
+		} else {
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 1, 120, curQuote);
+			_scene->_sequences.addTimer(140, 50);
+		}
+	} else if (_game._trigger == 50) {
+		if (_hermitDialogNode == 1)
+			handleSubDialog1();
+		else if (_hermitDialogNode == 2)
+			handleSubDialog2();
+	}
+}
+
+void Scene611::displayHermitQuestions(int question) {
+	_scene->_kernelMessages.reset();
+	_hermitDisplayedQuestion = question;
+
+	switch (question) {
+	case 1: {
+		Common::String curQuote = _game.getQuote(0x281);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x282);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 14), 0xFDFC, 0, 0, 9999999, curQuote);
+		}
+		break;
+
+	case 2: {
+		Common::String curQuote = _game.getQuote(0x283);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x284);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 14), 0xFDFC, 0, 0, 9999999, curQuote);
+		}
+		break;
+
+	case 3: {
+		Common::String curQuote = _game.getQuote(0x285);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 14), 0xFDFC, 0, 0, 9999999, curQuote);
+		}
+		break;
+
+	case 4: {
+		Common::String curQuote = _game.getQuote(0x286);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 14), 0xFDFC, 0, 0, 9999999, curQuote);
+		}
+		break;
+
+	case 5: {
+		Common::String curQuote = _game.getQuote(0x297);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y - 14), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x298);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x299);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 14), 0xFDFC, 0, 0, 9999999, curQuote);
+		}
+		break;
+
+	case 6: {
+		Common::String curQuote = _game.getQuote(0x29A);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x29B);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 14), 0xFDFC, 0, 0, 9999999, curQuote);
+		}
+		break;
+
+	case 7: {
+		Common::String curQuote = _game.getQuote(0x2A0);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 45), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2A1);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 59), 0xFDFC, 0, 0, 9999999, curQuote);
+		}
+		break;
+
+	case 8: {
+		Common::String curQuote = _game.getQuote(0x2A2);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 31), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2A3);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 45), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2A4);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 59), 0xFDFC, 0, 0, 9999999, curQuote);
+		}
+		break;
+
+	case 9: {
+		Common::String curQuote = _game.getQuote(0x2A5);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 45), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2A6);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 59), 0xFDFC, 0, 0, 9999999, curQuote);
+		}
+		break;
+
+	case 10: {
+		Common::String curQuote = _game.getQuote(0x2A8);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 31), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2A9);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 45), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2AA);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 59), 0xFDFC, 0, 0, 9999999, curQuote);
+		 }
+		 break;
+
+	case 11: {
+		Common::String curQuote = _game.getQuote(0x2AB);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 17), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2AC);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 31), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2AD);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 45), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2AE);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 59), 0xFDFC, 0, 0, 9999999, curQuote);
+		 }
+		 break;
+
+	case 12: {
+		Common::String curQuote = _game.getQuote(0x2AF);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 17), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2B0);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 31), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2B1);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 45), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2B2);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 59), 0xFDFC, 0, 0, 9999999, curQuote);
+		 }
+		 break;
+
+	case 13: {
+		Common::String curQuote = _game.getQuote(0x2B3);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 3), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2B4);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 17), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2B5);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 31), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2B6);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 45), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		_scene->_kernelMessages.add(Common::Point(11, _defaultDialogPos.y + 59), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x2B7));
+		_scene->_kernelMessages.add(Common::Point(11, _defaultDialogPos.y + 73), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x2B8));
+		_scene->_kernelMessages.add(Common::Point(11, _defaultDialogPos.y + 87), 0xFDFC, 0, 0, 9999999, _game.getQuote(0x2B9));
+		 }
+		 break;
+
+	case 14: {
+		Common::String curQuote = _game.getQuote(0x2BA);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 17), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2BB);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 31), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2BC);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 45), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2BD);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 59), 0xFDFC, 0, 0, 9999999, curQuote);
+		 }
+		 break;
+
+	case 15: {
+		Common::String curQuote = _game.getQuote(0x2BE);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 17), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2BF);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 31), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2C0);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 45), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2C1);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 59), 0xFDFC, 0, 0, 9999999, curQuote);
+		 }
+		 break;
+
+	case 16: {
+		Common::String curQuote = _game.getQuote(0x2C2);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 3), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2C3);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 17), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2C4);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 31), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2C5);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 45), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2C6);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 59), 0xFDFC, 0, 0, 9999999, curQuote);
+		 }
+		 break;
+
+	case 17: {
+		Common::String curQuote = _game.getQuote(0x2C7);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 17), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2C8);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 31), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2C0);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 45), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2CA);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 59), 0xFDFC, 0, 0, 9999999, curQuote);
+		 }
+		 break;
+
+	case 18: {
+		Common::String curQuote = _game.getQuote(0x2CB);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 31), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2CC);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 45), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2CD);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 59), 0xFDFC, 0, 0, 9999999, curQuote);
+		 }
+		 break;
+
+	case 19: {
+		Common::String curQuote = _game.getQuote(0x2CE);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 31), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2CF);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 45), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2D0);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 59), 0xFDFC, 0, 0, 9999999, curQuote);
+		 }
+		 break;
+
+	case 20: {
+		Common::String curQuote = _game.getQuote(0x2E1);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 3), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2E2);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 17), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2E3);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 31), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2E4);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 45), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2E5);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 59), 0xFDFC, 0, 0, 9999999, curQuote);
+		 }
+		 break;
+
+	case 21: {
+		Common::String curQuote = _game.getQuote(0x2D3);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 3), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2D4);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 17), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2D5);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 31), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2D6);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 45), 0xFDFC, 0, 0, 9999999, curQuote);
+
+		curQuote = _game.getQuote(0x2D7);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 59), 0xFDFC, 0, 0, 9999999, curQuote);
+		 }
+		 break;
+
+	case 22: {
+		Common::String curQuote = _game.getQuote(0x2D8);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 17), 0xFDFC, 0, 0, 700, curQuote);
+
+		curQuote = _game.getQuote(0x2D9);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 31), 0xFDFC, 0, 0, 700, curQuote);
+
+		curQuote = _game.getQuote(0x2DA);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 45), 0xFDFC, 0, 0, 700, curQuote);
+
+		curQuote = _game.getQuote(0x2DB);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 59), 0xFDFC, 0, 0, 700, curQuote);
+		 }
+		 break;
+
+	case 23: {
+		Common::String curQuote = _game.getQuote(0x2DC);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 3), 0xFDFC, 0, 0, 700, curQuote);
+
+		curQuote = _game.getQuote(0x2DD);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 17), 0xFDFC, 0, 0, 700, curQuote);
+
+		curQuote = _game.getQuote(0x2DE);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 31), 0xFDFC, 0, 0, 700, curQuote);
+
+		curQuote = _game.getQuote(0x2DF);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 45), 0xFDFC, 0, 0, 700, curQuote);
+
+		curQuote = _game.getQuote(0x2E0);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 59), 0xFDFC, 0, 0, 700, curQuote);
+		}
+		break;
+
+	default:
+		break;
+	 }
+}
+
+void Scene611::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 1));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RXMRC_9");
+
+	_game.loadQuoteSet(0x279, 0x27A, 0x27B, 0x27C, 0x27D, 0x27E, 0x27F, 0x280, 0x281, 0x282, 0x283, 0x284,
+		0x285, 0x286, 0x287, 0x288, 0x289, 0x28A, 0x28B, 0x28C, 0x28D, 0x28E, 0x28F, 0x290, 0x291, 0x292,
+		0x293, 0x294, 0x295, 0x296, 0x297, 0x298, 0x299, 0x29A, 0x29B, 0x29C, 0x29D, 0x29E, 0x29F, 0x2A0,
+		0x2A1, 0x2A2, 0x2A3, 0x2A4, 0x2A5, 0x2A6, 0x2A7, 0x2A8, 0x2A9, 0x2AA, 0x2AB, 0x2AC, 0x2AD, 0x2AE,
+		0x2AF, 0x2B0, 0x2B1, 0x2B2, 0x2B3, 0x2B4, 0x2B5, 0x2B6, 0x2B7, 0x2B8, 0x2B9, 0x2BA, 0x2BB, 0x2BC,
+		0x2BD, 0x2BE, 0x2BF, 0x2C0, 0x2C1, 0x2C2, 0x2C3, 0x2C4, 0x2C5, 0x2C6, 0x2C7, 0x2C8, 0x2C9, 0x2CA,
+		0x2CB, 0x2CC, 0x2CD, 0x2CE, 0x2CF, 0x2D0, 0x2D1, 0x2D2, 0x2D3, 0x2D4, 0x2D5, 0x2D6, 0x2D7, 0x2D8,
+		0x2D9, 0x2DA, 0x2DB, 0x2DC, 0x2DD, 0x2DE, 0x2DF, 0x2E0, 0x2E1, 0x2E2, 0x2E3, 0x2E4, 0x2E5, 0x2E6,
+		0x323, 0x324, 0);
+
+	_dialog1.setup(0x82, 0x287, 0x288, 0x289, 0x28A, 0x28B, 0x28C, 0x28D, 0x28E, 0x28F, 0x290,
+		0x291, 0x292, 0x293, 0x294, 0x295, 0x296, 0);
+
+	_dialog2.setup(0x83, 0x29C, 0x29D, 0x29E, 0x29F, 0);
+
+	if (!_game._visitedScenes._sceneRevisited) {
+		_dialog1.set(0x82, 0x287, 0x288, 0x296, 0);
+		_dialog2.set(0x83, 0x29F, 0);
+	}
+
+	_vm->_palette->setEntry(252, 51, 51, 47);
+	_vm->_palette->setEntry(253, 37, 37, 37);
+
+	_ratPresentFl = false;
+	_seenRatFl = true;
+	_eyesRunningFl = false;
+	_shouldRemoveEyes = false;
+	_randVal = 0;
+	_defaultDialogPos = Common::Point(264, 43);
+	_giveBatteriesFl = false;
+	_resetBatterieText = false;
+	_alreadyTalkingFl = false;
+	_startTradingFl = false;
+
+	if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(22, 132);
+		_game._player._facing = FACING_EAST;
+		_duringDialogFl = false;
+	}
+
+	if (!_globals[kHasTalkedToHermit]) {
+		_scene->loadAnimation(Resources::formatName(611, 'h', -1, EXT_AA, ""), 0);
+		_scene->loadAnimation(Resources::formatName(203, 'a', -1, EXT_AA, ""), 81);
+		_nextFrame = 47;
+		_hermitMode = 1;
+		_hermitTalkingFl = false;
+		_hermitMovingFl = true;
+		_check1Fl = true;
+		_stickFingerFl = false;
+	} else {
+		_hermitMode = 0;
+		_scene->_hotspots.activate(0x45A, false);
+	}
+
+	// CHECKME: The last line of the block looks extremely useless
+	if (_globals[kExecuted_1_11]) {
+		_dialog1.write(0x294, true);
+		_dialog1.write(0x292, false);
+		_globals[kExecuted_1_11] = true;
+	}
+
+	if (_duringDialogFl) {
+		_game._player._playerPos = Common::Point(237, 129);
+		_game._player._facing = FACING_NORTHEAST;
+
+		switch (_hermitDialogNode) {
+	case 0:
+		_scene->_userInterface.setup(kInputBuildingSentences);
+		_hermitDialogNode = 1;
+		break;
+
+	case 1:
+		_dialog1.start();
+		break;
+
+	case 2:
+		_dialog2.start();
+		break;
+
+	default:
+		break;
+		}
+		displayHermitQuestions(_hermitDisplayedQuestion);
+	}
+
+	sceneEntrySound();
+}
+
+void Scene611::step() {
+	if (_seenRatFl && (_vm->getRandomNumber(1, 100) == 10)) {
+		_seenRatFl = false;
+		_scene->_sequences.addTimer(1, 80);
+	}
+
+	if (_game._trigger == 80) {
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 8);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+		_ratPresentFl = true;
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 81);
+	} else if (_game._trigger == 81) {
+		int syncId = _globals._sequenceIndexes[1];
+		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 20, 0, 0, 0);
+		int idx = _scene->_dynamicHotspots.add(0x275, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_ratHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(272, 154), FACING_SOUTHEAST);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 9, 10);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[1], syncId);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+		_ratTimer = _game._player._priorTimer;
+	}
+
+	if (_ratPresentFl && ((_game._player._priorTimer - _ratTimer) > 1200))
+		handleRatMoves();
+
+	if (!_eyesRunningFl) {
+		_randVal = _vm->getRandomNumber(1, 30);
+		_eyesRunningFl = true;
+		_scene->_sequences.addTimer(1, 70);
+	}
+
+	if (_game._trigger == 70) {
+		switch (_randVal) {
+		case 2:
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_shouldRemoveEyes = true;
+			_scene->_sequences.addTimer(60, 71);
+			break;
+
+		case 6:
+			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 12, 3, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 2, 4);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
+			break;
+
+		case 7:
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 5);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_shouldRemoveEyes = true;
+			_scene->_sequences.addTimer(60, 71);
+			break;
+
+		case 9:
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 6);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_shouldRemoveEyes = true;
+			_scene->_sequences.addTimer(60, 71);
+			break;
+
+		case 13:
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 7);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_shouldRemoveEyes = true;
+			_scene->_sequences.addTimer(60, 71);
+			break;
+
+		case 14:
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 8);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_shouldRemoveEyes = true;
+			_scene->_sequences.addTimer(60, 71);
+			break;
+
+		case 15:
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 24, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 5, 8);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
+			break;
+
+		case 17:
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 20, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 9, 11);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
+			break;
+
+		case 21:
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 9);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_shouldRemoveEyes = true;
+			_scene->_sequences.addTimer(60, 71);
+			break;
+
+		case 25:
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 10);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_shouldRemoveEyes = true;
+			_scene->_sequences.addTimer(60, 71);
+			break;
+
+		case 27:
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 11);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_shouldRemoveEyes = true;
+			_scene->_sequences.addTimer(60, 71);
+			break;
+
+		case 29:
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 20, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
+			break;
+
+		default:
+			_scene->_sequences.addTimer(1, 71);
+			break;
+		}
+	}
+
+	if (_game._trigger == 71) {
+		if (_shouldRemoveEyes) {
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_shouldRemoveEyes = false;
+		}
+		_eyesRunningFl = false;
+		_randVal = 0;
+	}
+
+	if (_game._trigger == 100) {
+		if (_alreadyTalkingFl)
+			_alreadyTalkingFl = false;
+		else
+			_hermitMovingFl = true;
+	}
+
+	if (_stickFingerFl && (_scene->_activeAnimation->getCurrentFrame() == 47)) {
+		_stickFingerFl = false;
+		_hermitMovingFl = true;
+		_hermitMode = 1;
+	}
+
+	if ((_scene->_activeAnimation->getCurrentFrame() == 240) && _check1Fl) {
+		_check1Fl = false;
+		_scene->_kernelMessages.add(Common::Point(33, 88), 0xFDFC, 0, 0, 90, _game.getQuote(0x27E));
+		_scene->_sequences.addTimer(120, 120);
+	}
+
+	if (_game._trigger == 120) {
+		int msgIdx = _scene->_kernelMessages.add(Common::Point(28, 102), 0xFDFC, 0, 0, 90, _game.getQuote(0x27F));
+		_scene->_kernelMessages.setQuoted(msgIdx, 4, true);
+		_scene->_sequences.addTimer(100, 121);
+	}
+
+	if (_game._trigger == 121) {
+		int msgIdx = _scene->_kernelMessages.add(Common::Point(23, 116), 0xFDFC, 0, 0, 90, _game.getQuote(0x280));
+		_scene->_kernelMessages.setQuoted(msgIdx, 4, true);
+	}
+
+	if (_hermitMode == 1) {
+		if (_startTradingFl) {
+			_hermitMode = 6;
+			_hermitMovingFl = false;
+			_hermitTalkingFl = false;
+			_scene->_sequences.addTimer(1, 110);
+		} else if (_hermitTalkingFl) {
+			_hermitMode = 2;
+			_nextFrame = 18;
+			_hermitMovingFl = false;
+		} else {
+			switch (_vm->getRandomNumber(1, 5)) {
+			case 1:
+				_nextFrame = 46;
+				break;
+
+			case 2:
+				_nextFrame = 47;
+				break;
+
+			case 3:
+				_nextFrame = 48;
+				break;
+
+			case 4:
+				_nextFrame = 49;
+				break;
+
+			case 5:
+				_nextFrame = 50;
+				break;
+
+			default:
+				break;
+			}
+		}
+	}
+
+	if (_hermitMode == 2) {
+		if (_startTradingFl) {
+			_hermitMode = 6;
+			_hermitMovingFl = false;
+			_hermitTalkingFl = false;
+			_scene->_sequences.addTimer(1, 110);
+		} else if (_hermitMovingFl) {
+			_hermitMode = 1;
+			_nextFrame = 47;
+			_hermitTalkingFl = false;
+		} else {
+			switch (_vm->getRandomNumber(1, 4)) {
+			case 1:
+				_nextFrame = 18;
+				break;
+
+			case 2:
+				_nextFrame = 20;
+				break;
+
+			case 3:
+				_nextFrame = 22;
+				break;
+
+			case 4:
+				_nextFrame = 24;
+				break;
+
+			default:
+				break;
+			}
+		}
+	}
+
+	if (_scene->_activeAnimation->getCurrentFrame() == 254)
+		_game._player._stepEnabled = true;
+
+	if (_game._trigger == 110) {
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 7, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 2);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 111);
+	}
+
+	if (_game._trigger == 111) {
+		int syncIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 2);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], syncIdx);
+		_nextFrame = 1;
+	}
+
+	if (_game._trigger == 112) {
+		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+		_game._player._visible = true;
+	}
+
+	if (_hermitMode == 6) {
+		if ((_scene->_activeAnimation->getCurrentFrame() == 9) && _check1Fl) {
+			_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 7, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 112);
+			_check1Fl = false;
+		}
+
+		if ((_scene->_activeAnimation->getCurrentFrame() == 17) && !_check1Fl) {
+			_nextFrame = 26;
+			_hermitMode = 4;
+			_check1Fl = true;
+		}
+	}
+
+	if (_hermitMode == 4) {
+		if ((_scene->_activeAnimation->getCurrentFrame() == 33) && _check1Fl) {
+			displayHermitQuestions(_hermitDisplayedQuestion);
+			_nextFrame = 1;
+			_check1Fl = false;
+		}
+
+		if ((_scene->_activeAnimation->getCurrentFrame() == 9) && !_check1Fl) {
+			_nextFrame = 8;
+			_scene->_sequences.addTimer(1, 113);
+			_check1Fl = true;
+		}
+	}
+
+	if (_game._trigger == 113) {
+		_game._player._visible = false;
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 7, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 2);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 114);
+	}
+
+	if (_game._trigger == 114) {
+		_resetBatterieText = true;
+		int syncIdx = _globals._sequenceIndexes[3];
+		_nextFrame = 10;
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 7, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 2);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], syncIdx);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 115);
+	}
+
+	if ((_nextFrame >= 0) && (_nextFrame != _scene->_activeAnimation->getCurrentFrame())) {
+		_scene->_activeAnimation->setCurrentFrame(_nextFrame);
+		_nextFrame = -1;
+	}
+
+	if (_game._trigger == 115) {
+		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+		_game._player._visible = true;
+		if (_hermitDisplayedQuestion == 21) {
+			_game._player._stepEnabled = false;
+			handleTrading();
+			_hermitMode = 0;
+			_startTradingFl = false;
+			_nextFrame = 52;
+			_globals[kHasTalkedToHermit] = true;
+			_scene->_hotspots.activate(0x45A, false);
+		} else {
+			_game._player._stepEnabled = true;
+			_hermitMode = 1;
+			_nextFrame = 47;
+			_hermitTalkingFl = false;
+			_startTradingFl = false;
+			_check1Fl = true;
+		}
+	}
+}
+
+void Scene611::preActions() {
+	if (_action.isAction(0x1AD, 0x423))
+		_game._player._walkOffScreenSceneId = 609;
+
+	if (_resetBatterieText)
+		_scene->_kernelMessages.reset();
+}
+
+void Scene611::actions() {
+	if (_game._screenObjects._inputMode == 1)
+		handleDialog();
+	else if ((_action.isAction(VERB_GIVE, 0x107, 0x45A)) || (_action.isAction(VERB_GIVE, 0x73, 0x45A))) {
+		_action._activeAction._verbId = 0x294;
+		_giveBatteriesFl = true;
+		handleSubDialog1();
+	} else if (_action.isAction(VERB_GIVE, 0x45A)) {
+		_scene->_kernelMessages.reset();
+
+		Common::String curQuote = _game.getQuote(0x323);
+		int width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		int quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y), 0xFDFC, 0, 0, 120, curQuote);
+
+		curQuote = _game.getQuote(0x324);
+		width = _vm->_font->getWidth(curQuote, _scene->_textSpacing);
+		quotePosX = _defaultDialogPos.x - (width / 2);
+		_scene->_kernelMessages.add(Common::Point(quotePosX, _defaultDialogPos.y + 14), 0xFDFC, 0, 0, 120, curQuote);
+	} else if (_game._trigger == 90) {
+		if (_dialog2.read(0x29C) && _dialog2.read(0x29D) && _dialog2.read(0x29E)) {
+			handleTalking(180);
+			if (_vm->getRandomNumber(1, 2) == 1)
+				displayHermitQuestions(1);
+			else
+				displayHermitQuestions(2);
+		} else {
+			handleTalking(180);
+			if (_vm->getRandomNumber(1, 2) == 1)
+				displayHermitQuestions(3);
+			else
+				displayHermitQuestions(4);
+		}
+
+		_duringDialogFl = true;
+		if (_dialog2.read(0x29F)) {
+			_hermitDialogNode = 1;
+			_dialog1.start();
+			_duringDialogFl = true;
+		} else {
+			_hermitDialogNode = 2;
+			_dialog2.write(0x29F, true);
+			_dialog2.start();
+			_duringDialogFl = true;
+		}
+	} else if (_action.isAction(VERB_TALKTO, 0x45A)) {
+		if (!_dialog1.read(0x287)) {
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x27A));
+			_scene->_sequences.addTimer(120, 90);
+		} else {
+			int nextQuote = 0;
+			switch (_vm->getRandomNumber(1, 3)) {
+			case 1:
+				nextQuote = 0x27B;
+				break;
+
+			case 2:
+				nextQuote = 0x27C;
+				break;
+
+			case 3:
+				nextQuote = 0x27D;
+				break;
+			}
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(nextQuote));
+			_scene->_sequences.addTimer(120, 90);
+		}
+	} else if ((_action.isAction(VERB_WALKTO) || _action.isAction(VERB_LOOK)) && _action.isAction(0x275)) {
+		switch (_game._trigger) {
+		case 0:
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x279));
+			_scene->_sequences.addTimer(60, 1);
+			break;
+
+		case 1:
+			handleRatMoves();
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action._lookFlag) {
+		if (_globals[kHasTalkedToHermit])
+			_vm->_dialogs->show(61111);
+		else
+			_vm->_dialogs->show(61110);
+	} else if (_action.isAction(VERB_LOOK, 0x45A))
+		_vm->_dialogs->show(61112);
+	else if (_action.isAction(VERB_LOOK, 0x25C))
+		_vm->_dialogs->show(61113);
+	else if (_action.isAction(VERB_TAKE, 0x25C))
+		_vm->_dialogs->show(61114);
+	else if (_action.isAction(VERB_LOOK, 0x49A))
+		_vm->_dialogs->show(61115);
+	else if (_action.isAction(VERB_TAKE, 0x49A))
+		_vm->_dialogs->show(61116);
+	else if (_action.isAction(VERB_OPEN, 0x49A))
+		_vm->_dialogs->show(61117);
+	else if (_action.isAction(VERB_LOOK, 0x122))
+		_vm->_dialogs->show(61118);
+	else if (_action.isAction(VERB_OPEN, 0x122))
+		_vm->_dialogs->show(61119);
+	else if (_action.isAction(VERB_TAKE, 0x122))
+		_vm->_dialogs->show(61120);
+	else if (_action.isAction(VERB_LOOK, 0x323))
+		_vm->_dialogs->show(61121);
+	else if (_action.isAction(VERB_LOOK, 0x49C))
+		_vm->_dialogs->show(61122);
+	else if (_action.isAction(VERB_LOOK, 0x45B))
+		_vm->_dialogs->show(61123);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene620::setup() {
 	_game._player._spritesPrefix = "";
 	setAAName();
diff --git a/engines/mads/nebular/nebular_scenes6.h b/engines/mads/nebular/nebular_scenes6.h
index 10bf2e8..4c465bf 100644
--- a/engines/mads/nebular/nebular_scenes6.h
+++ b/engines/mads/nebular/nebular_scenes6.h
@@ -247,6 +247,59 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene611: public Scene6xx{
+private:
+	bool _seenRatFl;
+	bool _eyesRunningFl;
+	bool _shouldRemoveEyes;
+	bool _ratPresentFl;
+	bool _duringDialogFl;
+	bool _resetBatterieText;
+	bool _hermitTalkingFl;
+	bool _hermitMovingFl;
+	bool _alreadyTalkingFl;
+	bool _giveBatteriesFl;
+	bool _startTradingFl;
+	bool _check1Fl;
+	bool _stickFingerFl;
+
+	int _randVal;
+	int _ratHotspotId;
+	int _hermitDialogNode;
+	int _hermitDisplayedQuestion;
+	int _nextFrame;
+	int _hermitMode;
+
+	uint32 _ratTimer;
+
+	Conversation _dialog1;
+	Conversation _dialog2;
+
+	Common::Point _defaultDialogPos;
+
+	void handleTrading();
+	void handleRatMoves();
+	void handleDialog();
+	void handleSubDialog1();
+	void handleSubDialog2();
+	void handleTalking(int delay);
+	void setDialogNode(int node);
+	void displayHermitQuestions(int question);
+
+	bool check2ChargedBatteries();
+	bool check4ChargedBatteries();
+
+public:
+	Scene611(MADSEngine *vm) : Scene6xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 class Scene620: public Scene6xx{
 public:
 	Scene620(MADSEngine *vm) : Scene6xx(vm) {}


Commit: 2db45fac8c8808cb887e435db051e39c575d7667
    https://github.com/scummvm/scummvm/commit/2db45fac8c8808cb887e435db051e39c575d7667
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-15T00:51:10+02:00

Commit Message:
MADS: Implement Scene 612

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes6.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index a4ec04c..64511a3 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -245,7 +245,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 611:	// back alley
 		return new Scene611(vm);
 	case 612:	// expressway / maintenance building
-		return new DummyScene(vm);	// TODO
+		return new Scene612(vm);
 	case 620:	// cutscene, viewport glass breaking
 		return new Scene620(vm);
 
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index 7006acc..4cacfac 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -4259,6 +4259,215 @@ void Scene611::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene612::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x87);
+	_scene->addActiveVocab(0xD);
+}
+
+void Scene612::handleWinchMovement() {
+	switch (_game._trigger) {
+	case 0:
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 10, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 1, 5);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 5, 1);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+		break;
+
+	case 1:
+		// CHECKME: Is the "else" block useful as action is always equal to 1 at this point?
+		// Or is it a missing bit of code we could fix?
+		if (action == 1) {
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 17, 7, 0, 0);
+			_vm->_sound->command(19);
+			_game._objects.setRoom(OBJ_PADLOCK_KEY, 1);
+			_globals[kBoatRaised] = false;
+		} else {
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 17, 9, 0, 0);
+			_vm->_sound->command(18);
+		}
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+		break;
+
+	case 2:
+		_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[4]);
+		_game._player._visible = true;
+		break;
+
+	case 3: {
+		int syncIdx = _globals._sequenceIndexes[2];
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, _cycleIndex);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], syncIdx);
+		_scene->_kernelMessages.reset();
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x2F4));
+		_game._player._stepEnabled = true;
+
+		_vm->_dialogs->show(61217);
+		}
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene612::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', -1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('p', -1));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RXCD_3");
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXRC_6");
+
+	if ((_globals[kLineStatus] == 2) || (_globals[kLineStatus] == 3)) {
+		_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('f', -1));
+		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, -1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1);
+		int idx = _scene->_dynamicHotspots.add(0x87, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(34, 117), FACING_SOUTHEAST);
+	}
+
+	if (_globals[kBoatRaised])
+		_cycleIndex = -2;
+	else
+		_cycleIndex = -1;
+
+	_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, _cycleIndex);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
+
+	if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(280, 75);
+		_game._player._facing = FACING_SOUTHWEST;
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 3);
+		_scene->loadAnimation(formAnimName('R', 1), 70);
+	}
+
+	sceneEntrySound();
+
+	if (_scene->_roomChanged)
+		_game._objects.addToInventory(OBJ_PADLOCK_KEY);
+
+	_game.loadQuoteSet(0x2F5, 0x2F4, 0);
+}
+
+void Scene612::step() {
+	switch (_game._trigger) {
+	case 70:
+		_game._player._visible = true;
+		_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
+		_scene->_sequences.addTimer(6, 71);
+		break;
+
+	case 71:
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 2);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 72);
+		break;
+
+	case 72:
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 2);
+		_game._player._stepEnabled = true;
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene612::actions() {
+	if (_action.isAction(0x325, 0x324)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			break;
+
+		case 1: {
+			int syncIdx = _globals._sequenceIndexes[1];
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 3);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[1], syncIdx);
+			_scene->_sequences.addTimer(6, 2);
+			}
+			break;
+
+		case 2:
+			_game._player._visible = false;
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], true, 10, 1, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+			break;
+
+		case 3: {
+			int syncIdx = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], true, -2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], syncIdx);
+			_scene->_nextSceneId = 504;
+			}
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(0x17B, 0xFF, 0x45F)) {
+		_cycleIndex = -2;
+		action = 1;
+		handleWinchMovement();
+	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x466))
+		_vm->_dialogs->show(61210);
+	else if (_action.isAction(VERB_LOOK, 0x347) || _action.isAction(VERB_LOOK, 0x45E)) {
+		if (_globals[kBoatRaised])
+			_vm->_dialogs->show(61211);
+		else
+			_vm->_dialogs->show(61212);
+	} else if (_action.isAction(VERB_TAKE, 0x347))
+		_vm->_dialogs->show(61213);
+	else if (_action.isAction(VERB_LOOK, 0x45F)) {
+		if (_globals[kBoatRaised])
+			_vm->_dialogs->show(61214);
+		else
+			_vm->_dialogs->show(61216);
+	} else if (_action.isAction(VERB_OPEN, 0x45F))
+		_vm->_dialogs->show(61215);
+	else if (_action.isAction(VERB_LOOK, 0x33D))
+		_vm->_dialogs->show(61218);
+	else if (_action.isAction(VERB_LOOK, 0x464))
+		_vm->_dialogs->show(61219);
+	else if (_action.isAction(VERB_LOOK, 0x2CD))
+		_vm->_dialogs->show(61220);
+	else if (_action.isAction(VERB_LOOK, 0x4A2))
+		_vm->_dialogs->show(61221);
+	else if (_action.isAction(VERB_OPEN, 0x4A2))
+		_vm->_dialogs->show(61222);
+	else if (_action.isAction(VERB_LOOK, 0x18D))
+		_vm->_dialogs->show(61223);
+	else if (_action.isAction(VERB_LOOK, 0x257))
+		_vm->_dialogs->show(61224);
+	else if (_action.isAction(0x1AD, 0x461) || _action.isAction(0x1AD, 0x463))
+		_vm->_dialogs->show(61225);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene620::setup() {
 	_game._player._spritesPrefix = "";
 	setAAName();
diff --git a/engines/mads/nebular/nebular_scenes6.h b/engines/mads/nebular/nebular_scenes6.h
index 4c465bf..294cf35 100644
--- a/engines/mads/nebular/nebular_scenes6.h
+++ b/engines/mads/nebular/nebular_scenes6.h
@@ -300,6 +300,24 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene612: public Scene6xx{
+private:
+	int action;
+	int _cycleIndex;
+
+	void handleWinchMovement();
+
+public:
+	Scene612(MADSEngine *vm) : Scene6xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 class Scene620: public Scene6xx{
 public:
 	Scene620(MADSEngine *vm) : Scene6xx(vm) {}


Commit: 95e144a3142fcab0c11b5e0d2452a899a06750c9
    https://github.com/scummvm/scummvm/commit/95e144a3142fcab0c11b5e0d2452a899a06750c9
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-15T07:14:13+02:00

Commit Message:
MADS: Some refactoring in scene group 7

Changed paths:
    engines/mads/nebular/nebular_scenes7.cpp



diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index cb9880e..46eb86c 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -120,19 +120,14 @@ void Scene701::enter() {
 	}
 
 	if (_globals[kBoatStatus] == BOAT_UNFLOODED) {
-		if (_globals[kBoatRaised]) {
+		if (_globals[kBoatRaised])
 			_globals[kBoatStatus] = BOAT_GONE;
-		} else {
-			if (_globals[kLineStatus] == LINE_TIED) {
-				_globals[kBoatStatus] = BOAT_TIED_FLOATING;
-			} else {
-				if (_game._difficulty == DIFFICULTY_HARD) {
-					_globals[kBoatStatus] = BOAT_ADRIFT;
-				} else {
-					_globals[kBoatStatus] = BOAT_TIED;
-				}
-			}
-		}
+		else if (_globals[kLineStatus] == LINE_TIED)
+			_globals[kBoatStatus] = BOAT_TIED_FLOATING;
+		else if (_game._difficulty == DIFFICULTY_HARD)
+			_globals[kBoatStatus] = BOAT_ADRIFT;
+		else 
+			_globals[kBoatStatus] = BOAT_TIED;
 	}
 
 	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
@@ -213,81 +208,67 @@ void Scene702::enter() {
 }
 
 void Scene702::preActions() {
-	if (_action.isAction(VERB_WALKTO, NOUN_WEST_END_OF_PLATFORM)) {
+	if (_action.isAction(VERB_WALKTO, NOUN_WEST_END_OF_PLATFORM))
 		_game._player._walkOffScreenSceneId = 701;
-	}
 }
 
 void Scene702::actions() {
-	if (_action.isAction(VERB_WALK_ALONG, NOUN_PLATFORM)) {
-		_action._inProgress = false;
-	} else if (_action.isAction(VERB_STEP_INTO, NOUN_TELEPORTER)) {
+	if (_action.isAction(VERB_WALK_ALONG, NOUN_PLATFORM))
+		; // Only set the action as finished
+	else if (_action.isAction(VERB_STEP_INTO, NOUN_TELEPORTER)) {
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
 		_scene->_nextSceneId = 711;
-		_action._inProgress = false;
-	} else if (_action.isAction(VERB_TAKE, NOUN_BONES) && _action._mainObjectSource == 4) {
-		// Take bones
-		if (!_game._objects.isInInventory(OBJ_BONES) || _game._trigger) {
-			switch (_game._trigger) {
-			case 0:
-				_game._player._stepEnabled = false;
-				_game._player._visible = false;
-				_globals._sequenceIndexes[12] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[12], false, 5, 2, 0, 0);
-				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[12]);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_SPRITE, 4, 1);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
-				break;
-			case 1:
-				_vm->_sound->command(0xF);
-				if (_game._objects.isInInventory(OBJ_BONE))
-					_game._objects.setRoom(OBJ_BONE, NOWHERE);
-				_game._objects.addToInventory(OBJ_BONES);
-				_vm->_dialogs->show(OBJ_BONES, 70218);
-				break;
-			case 2:
-				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[12]);
-				_game._player._visible = true;
-				_game._player._stepEnabled = true;
-				break;
-			default:
-				break;
-			}
-
-			_action._inProgress = false;
+	} else if (_action.isAction(VERB_TAKE, NOUN_BONES) && _action._mainObjectSource == 4 && (!_game._objects.isInInventory(OBJ_BONES) || _game._trigger)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_globals._sequenceIndexes[12] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[12], false, 5, 2, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[12]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_SPRITE, 4, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+		case 1:
+			_vm->_sound->command(0xF);
+			if (_game._objects.isInInventory(OBJ_BONE))
+				_game._objects.setRoom(OBJ_BONE, NOWHERE);
+			_game._objects.addToInventory(OBJ_BONES);
+			_vm->_dialogs->show(OBJ_BONES, 70218);
+			break;
+		case 2:
+			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[12]);
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			break;
+		default:
+			break;
 		}
-	} else if (_action._lookFlag) {
+	} else if (_action._lookFlag)
 		_vm->_dialogs->show(70210);
-		_action._inProgress = false;
-	} else if (_action.isAction(VERB_LOOK, NOUN_PLATFORM)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_PLATFORM))
 		_vm->_dialogs->show(70211);
-		_action._inProgress = false;
-	} else if (_action.isAction(VERB_LOOK, NOUN_CEMENT_BLOCK)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_CEMENT_BLOCK))
 		_vm->_dialogs->show(70212);
-		_action._inProgress = false;
-	} else if (_action.isAction(VERB_LOOK, NOUN_ROCK)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_ROCK))
 		_vm->_dialogs->show(70213);
-		_action._inProgress = false;
-	} else if (_action.isAction(VERB_TAKE, NOUN_ROCK)) {
+	else if (_action.isAction(VERB_TAKE, NOUN_ROCK))
 		_vm->_dialogs->show(70214);
-		_action._inProgress = false;
-	} else if (_action.isAction(VERB_LOOK, NOUN_WEST_END_OF_PLATFORM)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_WEST_END_OF_PLATFORM))
 		_vm->_dialogs->show(70215);
-		_action._inProgress = false;
-	} else if (_action.isAction(VERB_LOOK, NOUN_TELEPORTER)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_TELEPORTER))
 		_vm->_dialogs->show(70216);
-		_action._inProgress = false;
-	} else if (_action.isAction(VERB_LOOK, NOUN_BONES) && _action._mainObjectSource == 4) {
+	else if (_action.isAction(VERB_LOOK, NOUN_BONES) && _action._mainObjectSource == 4)
 		_vm->_dialogs->show(70217);
-		_action._inProgress = false;
-	} else if (_action.isAction(VERB_TAKE, NOUN_BONES) && _action._mainObjectSource == 4) {
+	else if (_action.isAction(VERB_TAKE, NOUN_BONES) && _action._mainObjectSource == 4) {
 		if (_game._objects.isInInventory(OBJ_BONES))
 			_vm->_dialogs->show(70219);
-		_action._inProgress = false;
-	} else if (_action.isAction(VERB_LOOK, NOUN_SUBMERGED_CITY)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_SUBMERGED_CITY))
 		_vm->_dialogs->show(70220);
-		_action._inProgress = false;
-	}
+	else
+		return;
+
+	_action._inProgress = false;
 }
 
 /*------------------------------------------------------------------------*/
@@ -507,108 +488,90 @@ void Scene752::preActions() {
 }
 
 void Scene752::actions() {
-	if (_action.isAction(VERB_WALK_ALONG, NOUN_PLATFORM)) {
-		_action._inProgress = false;
-	} else if (_action.isAction(VERB_STEP_INTO, NOUN_TELEPORTER)) {
+	if (_action.isAction(VERB_WALK_ALONG, NOUN_PLATFORM))
+		;
+	else if (_action.isAction(VERB_STEP_INTO, NOUN_TELEPORTER)) {
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
 		_scene->_nextSceneId = 711;
-		_action._inProgress = false;
-	} else if (_action.isAction(VERB_TAKE, NOUN_ID_CARD)) {
-		// Take ID card
-		if (!_game._objects.isInInventory(OBJ_ID_CARD) || _game._trigger) {
-			switch (_game._trigger) {
-			case 0:
-				_game._player._stepEnabled = false;
-				_game._player._visible = false;
-				_globals._sequenceIndexes[12] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[12], false, 5, 2, 0, 0);
-				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[12]);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_SPRITE, 4, 1);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
-				break;
-			case 1:
-				_vm->_sound->command(0xF);
-				_scene->_sequences.remove(_globals._sequenceIndexes[13]);
-				_game._objects.addToInventory(OBJ_ID_CARD);
-				_scene->_dynamicHotspots.remove(_cardId);
-				_vm->_dialogs->show(OBJ_ID_CARD, 830);
-				break;
-			case 2:
-				_game._player._visible = true;
-				_game._player._stepEnabled = true;
-				break;
-			default:
-				break;
-			}
-
-			_action._inProgress = false;
+	} else if (_action.isAction(VERB_TAKE, NOUN_ID_CARD) && (!_game._objects.isInInventory(OBJ_ID_CARD) || _game._trigger)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_globals._sequenceIndexes[12] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[12], false, 5, 2, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[12]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_SPRITE, 4, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+		case 1:
+			_vm->_sound->command(0xF);
+			_scene->_sequences.remove(_globals._sequenceIndexes[13]);
+			_game._objects.addToInventory(OBJ_ID_CARD);
+			_scene->_dynamicHotspots.remove(_cardId);
+			_vm->_dialogs->show(OBJ_ID_CARD, 830);
+			break;
+		case 2:
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			break;
+		default:
+			break;
 		}
-	} else if (_action.isAction(VERB_TAKE, NOUN_BONES) && _action._mainObjectSource == 4) {
-		// Take bones
-		if (!_game._objects.isInInventory(OBJ_BONES) || _game._trigger) {
-			switch (_game._trigger) {
-			case 0:
-				_game._player._stepEnabled = false;
-				_game._player._visible = false;
-				_globals._sequenceIndexes[12] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[12], false, 5, 2, 0, 0);
-				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[12]);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_SPRITE, 4, 1);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
-				break;
-			case 1:
-				_vm->_sound->command(0xF);
-				if (_game._objects.isInInventory(OBJ_BONE))
-					_game._objects.setRoom(OBJ_BONE, NOWHERE);
-				_game._objects.addToInventory(OBJ_BONES);
-				_vm->_dialogs->show(OBJ_BONES, 75221);
-				break;
-			case 2:
-				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[12]);
-				_game._player._visible = true;
-				_game._player._stepEnabled = true;
-				break;
-			default:
-				break;
-			}
-
-			_action._inProgress = false;
+	} else if (_action.isAction(VERB_TAKE, NOUN_BONES) && _action._mainObjectSource == 4 && (!_game._objects.isInInventory(OBJ_BONES) || _game._trigger)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_globals._sequenceIndexes[12] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[12], false, 5, 2, 0, 0);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[12]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_SPRITE, 4, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+		case 1:
+			_vm->_sound->command(0xF);
+			if (_game._objects.isInInventory(OBJ_BONE))
+				_game._objects.setRoom(OBJ_BONE, NOWHERE);
+			_game._objects.addToInventory(OBJ_BONES);
+			_vm->_dialogs->show(OBJ_BONES, 75221);
+			break;
+		case 2:
+			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[12]);
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			break;
+		default:
+			break;
 		}
 	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, NOUN_CITY)) {
 		if (_globals[kLaserHoleIsThere])
 			_vm->_dialogs->show(75212);
 		else
 			_vm->_dialogs->show(75210);
-
-		_action._inProgress = false;
-	} else if (_action.isAction(VERB_LOOK, NOUN_PLATFORM)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_PLATFORM))
 		_vm->_dialogs->show(75213);
-		_action._inProgress = false;
-	} else if (_action.isAction(VERB_LOOK, NOUN_CEMENT_BLOCK)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_CEMENT_BLOCK))
 		_vm->_dialogs->show(75214);
-		_action._inProgress = false;
-	} else if (_action.isAction(VERB_LOOK, NOUN_ROCK)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_ROCK))
 		_vm->_dialogs->show(75215);
-		_action._inProgress = false;
-	} else if (_action.isAction(VERB_TAKE, NOUN_ROCK)) {
+	else if (_action.isAction(VERB_TAKE, NOUN_ROCK))
 		_vm->_dialogs->show(75216);
-		_action._inProgress = false;
-	} else if (_action.isAction(VERB_LOOK, NOUN_WEST_END_OF_PLATFORM)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_WEST_END_OF_PLATFORM))
 		_vm->_dialogs->show(75217);
-		_action._inProgress = false;
-	} else if (_action.isAction(VERB_LOOK, NOUN_TELEPORTER)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_TELEPORTER))
 		_vm->_dialogs->show(75218);
-		_action._inProgress = false;
-	} else if ((_action.isAction(VERB_LOOK, NOUN_BONES) || _action.isAction(VERB_LOOK, NOUN_ID_CARD)) && _action._mainObjectSource == 4) {
+	else if ((_action.isAction(VERB_LOOK, NOUN_BONES) || _action.isAction(VERB_LOOK, NOUN_ID_CARD)) && _action._mainObjectSource == 4) {
 		if (_game._objects[OBJ_ID_CARD]._roomNumber == 752)
 			_vm->_dialogs->show(75219);
 		else
 			_vm->_dialogs->show(75220);
-		_action._inProgress = false;
 	} else if (_action.isAction(VERB_TAKE, NOUN_BONES) && _action._mainObjectSource == 4) {
 		if (_game._objects.isInInventory(OBJ_BONES))
 			_vm->_dialogs->show(75222);
-		_action._inProgress = false;
-	}
+	} else
+		return;
+
+	_action._inProgress = false;
 }
 
 /*------------------------------------------------------------------------*/


Commit: 9fcebd296a1828831e052fbd55181363e252bbaa
    https://github.com/scummvm/scummvm/commit/9fcebd296a1828831e052fbd55181363e252bbaa
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-15T09:48:32+03:00

Commit Message:
MADS: Some bugfixes to the debug console

Changed paths:
    engines/mads/debugger.cpp



diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp
index 3594c83..e3ddf02 100644
--- a/engines/mads/debugger.cpp
+++ b/engines/mads/debugger.cpp
@@ -30,7 +30,7 @@ Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) {
 	_showMousePos = false;
 
 	DCmd_Register("continue",		WRAP_METHOD(Debugger, Cmd_Exit));
-	DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_Mouse));
+	DCmd_Register("mouse", WRAP_METHOD(Debugger, Cmd_Mouse));
 	DCmd_Register("scene", WRAP_METHOD(Debugger, Cmd_LoadScene));
 	DCmd_Register("show_hotspots", WRAP_METHOD(Debugger, Cmd_ShowHotSpots));
 	DCmd_Register("list_hotspots", WRAP_METHOD(Debugger, Cmd_ListHotSpots));
@@ -60,7 +60,7 @@ static int strToInt(const char *s) {
 
 bool Debugger::Cmd_Mouse(int argc, const char **argv) {
 	if (argc < 2) {
-		DebugPrintf("Format: mouse [ on | off ]\n");
+		DebugPrintf("Usage: %s [ on | off ]\n", argv[0]);
 	} else {
 		_showMousePos = strcmp(argv[1], "on") == 0;
 	}
@@ -178,6 +178,7 @@ bool Debugger::Cmd_DumpFile(int argc, const char **argv) {
 
 			inFile.read(data, inFile.size());
 			outFile.write(data, inFile.size());
+			outFile.flush();
 
 			delete[] data;
 			inFile.close();


Commit: f46dc0a44ebcd3dd48154fd09b468e7d01b7e4c8
    https://github.com/scummvm/scummvm/commit/f46dc0a44ebcd3dd48154fd09b468e7d01b7e4c8
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-15T10:16:02+03:00

Commit Message:
MADS: Add a dummy implementation of setMotion()

This resolves the FIXME in scene 109

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/sequence.h



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index f317b28..b2e07dc 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -2455,8 +2455,7 @@ void Scene109::step() {
 		_hungryFl = true;
 	}
 
-	// FIXME: The fish animation never moves, so x is never updated and the scene freezes
-	if (_eatingFirstFish /*&& (_scene->_sequences[_globals._sequenceIndexes[10]]._msgPos.x >= 178)*/) {
+	if (_eatingFirstFish && (_scene->_sequences[_globals._sequenceIndexes[10]]._msgPos.x >= 178)) {
 		_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 4, 1, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 4);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_SPRITE, 29, 72);
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index 8abef5c..bb084cc 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -126,7 +126,12 @@ public:
 	void setScale(int spriteIdx, int scale);
 	void setMsgLayout(int seqIndex);
 	void setDone(int seqIndex);
-	void setMotion(int seqIndex, int flags, int deltaX, int deltaY) { warning("TODO: setMotion()"); }
+	void setMotion(int seqIndex, int flags, int deltaX, int deltaY) {
+		warning("TODO: setMotion()");
+		// HACK: Just offset by the delta for now
+		_entries[seqIndex]._msgPos.x += deltaX;
+		_entries[seqIndex]._msgPos.y += deltaY;
+	}
 };
 
 } // End of namespace MADS


Commit: 02df998be90158d6d603f0cf3d337787f1014b1c
    https://github.com/scummvm/scummvm/commit/02df998be90158d6d603f0cf3d337787f1014b1c
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-15T11:13:46+03:00

Commit Message:
MADS: Bugfixes and cleanup for scene 202

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 64511a3..df19326 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -425,7 +425,7 @@ void SceneTeleporter::teleporterHandleKey() {
 		_scene->_sequences.addSubEntry(_handSequenceId, SEQUENCE_TRIGGER_LOOP, 0, 1);
 		_scene->_sequences.addSubEntry(_handSequenceId, SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 
-		if (_globals[kMeteorologistWatch] == 0)
+		if (_globals[kMeteorologistWatch] == METEOROLOGIST_NORMAL)
 			_vm->_events->hideCursor();
 
 		}
@@ -477,7 +477,7 @@ void SceneTeleporter::teleporterHandleKey() {
 		if (_finishedCodeCounter == 1) {
 			_finishedCodeCounter++;
 
-			if (_globals[kMeteorologistWatch] != 0)
+			if (_globals[kMeteorologistWatch] != METEOROLOGIST_NORMAL)
 				_scene->_nextSceneId = 202;
 			else {
 				_vm->_events->showCursor();
@@ -492,14 +492,14 @@ void SceneTeleporter::teleporterHandleKey() {
 					_scene->_nextSceneId = _teleporterSceneId;
 				}
 			}
-		} else if (_globals[kMeteorologistWatch] != 0)
+		} else if (_globals[kMeteorologistWatch] != METEOROLOGIST_NORMAL)
 			_scene->_sequences.addTimer(30, 230 + _meteorologistCurPlace);
 
 		break;
 
 	case 3:
 		if (!_finishedCodeCounter) {
-			if (_globals[kMeteorologistWatch] == 0) {
+			if (_globals[kMeteorologistWatch] == METEOROLOGIST_NORMAL) {
 				_game._player._stepEnabled = true;
 				_vm->_events->showCursor();
 			}
@@ -513,7 +513,7 @@ void SceneTeleporter::teleporterHandleKey() {
 
 void SceneTeleporter::teleporterEnter() {
 	_game._player._visible   = false;
-	_game._player._stepEnabled = (_globals[kMeteorologistWatch] == 0);
+	_game._player._stepEnabled = (_globals[kMeteorologistWatch] == METEOROLOGIST_NORMAL);
 	_scene->_kernelMessages._talkFont = _vm->_font->getFont(FONT_TELE);
 	_scene->_textSpacing = 0;
 	_curCode   = 0;
@@ -553,7 +553,7 @@ void SceneTeleporter::teleporterEnter() {
 
 	_meteorologistCurPlace = 0;
 
-	if (_globals[kMeteorologistWatch] != 0)
+	if (_globals[kMeteorologistWatch] != METEOROLOGIST_NORMAL)
 		_scene->_sequences.addTimer(30, 230);
 
 	_vm->_sound->command(36);
@@ -582,7 +582,7 @@ bool SceneTeleporter::teleporterActions() {
 }
 
 void SceneTeleporter::teleporterStep() {
-	if ((_globals[kMeteorologistWatch] != 0) && (_game._trigger >= 230)) {
+	if ((_globals[kMeteorologistWatch] != METEOROLOGIST_NORMAL) && (_game._trigger >= 230)) {
 		int place = _game._trigger - 230;
 		int digit;
 
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 3534613..60526f7 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -66,6 +66,7 @@ enum Verb {
 
 enum Noun {
 	NOUN_BIG_LEAVES     = 0x23,
+	NOUN_BINOCULARS     = 0x27,
 	NOUN_BLOWGUN        = 0x29,
 	NOUN_BOMB           = 0x2A,
 	NOUN_BOMBS          = 0x2B,
@@ -109,6 +110,7 @@ enum Noun {
 	NOUN_HUGE_LEGS      = 0x1A8,
 	NOUN_LEAF_COVERED_PIT  = 0x1A9,
 	NOUN_PILE_OF_LEAVES = 0x1AA,
+	NOUN_STRANGE_DEVICE = 0x1B6,
 	NOUN_CAPTIVE_CREATURE = 0x1C3,
 	NOUN_NATIVE_WOMAN	= 0x1DC,
 	NOUN_PLATFORM       = 0x22C,
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 3943704..b38aace 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -99,7 +99,7 @@ void Scene2xx::sceneEntrySound() {
 				_vm->_sound->command(10);
 			break;
 		case 213:
-			if (_globals[kMeteorologistWatch] == 0)
+			if (_globals[kMeteorologistWatch] == METEOROLOGIST_NORMAL)
 				_vm->_sound->command(1);
 			else
 				_vm->_sound->command(9);
@@ -419,26 +419,23 @@ void Scene202::enter() {
 	if (_scene->_roomChanged)
 		_game._objects.addToInventory(OBJ_BINOCULARS);
 
-	if (_globals[kMeteorologistWatch]) {
+	if (_globals[kMeteorologistWatch] != METEOROLOGIST_NORMAL) {
 		_game._player._visible = false;
 		_game._player._stepEnabled = false;
-		if (_globals[kMeteorologistWatch] == 2)
-			_ladderTopFl = true;
-		else
-			_ladderTopFl = false;
-
-		if (_globals[kMeteorologistWatch] < 1)
-			_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
-		else
-			_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 8);
-		_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
+		_ladderTopFl = (_globals[kMeteorologistWatch] == METEOROLOGIST_TOWER);
 
 		if (_ladderTopFl) {
+			_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 8);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
+
 			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(247, 82));
 			_game._player._playerPos = Common::Point(246, 124);
 			_game._player._facing = FACING_NORTH;
 			_globals[kTeleporterUnderstood] = true;
 		} else {
+			_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
+
 			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
 			_game._player._playerPos = Common::Point(171, 122);
 			_game._player._facing = FACING_NORTH;
@@ -447,15 +444,17 @@ void Scene202::enter() {
 		_scene->loadAnimation(formAnimName('M', -1), 71);
 		_scene->_activeAnimation->setCurrentFrame(200);
 	} else {
-		_game._player._visible = false;
-		_scene->_sequences.startCycle(_globals._sequenceIndexes[9], true, 1);
-		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
-		_game._player._playerPos = Common::Point(246, 124);
-		_game._player._facing = FACING_NORTH;
+		if (_ladderTopFl) {
+			_game._player._visible = false;
+			_scene->_sequences.startCycle(_globals._sequenceIndexes[9], true, 1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
+			_game._player._playerPos = Common::Point(246, 124);
+			_game._player._facing = FACING_NORTH;
+		}
 	}
 
-	_meteorologistSpecial = 0;
+	_meteorologistSpecial = false;
 }
 
 void Scene202::setRandomKernelMessage() {
@@ -480,30 +479,35 @@ void Scene202::step() {
 	if (_game._trigger == 71) {
 		_vm->_sound->command(3);
 		_vm->_sound->command(9);
-		_meteoClock1 = 900 + _scene->_frameStartTime;
-		Common::Point msgPos;
-		int msgFlag;
-		if (!_ladderTopFl) {
-			msgPos = Common::Point(0, 0);
-			msgFlag = 2;
-		} else {
-			msgPos = Common::Point(248, 15);
-			msgFlag = 0;
-		}
-		int msgIndex = _scene->_kernelMessages.add(msgPos, 0x1110, msgFlag | 32, 0, 120, _game.getQuote(102));
-		_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
 
-		if (_globals[kMeteorologistWatch] == 1) {
-			_action._activeAction._verbId = VERB_LOOK;
-			_action._activeAction._objectNameId = 39;
-			_action._activeAction._indirectObjectId = 438;
-			_game._triggerSetupMode = SEQUENCE_TRIGGER_PARSER;
-			_scene->_sequences.addTimer(120, 2);
-			_meteorologistSpecial = -1;
-		} else if (_globals[kMeteorologistWatch] == 2) {
-			_scene->_sequences.addTimer(120, 90);
+		_meteoClock1 = _scene->_frameStartTime + 15 * 60;
+
+		if (_globals[kMeteorologistWatch] != METEOROLOGIST_NORMAL) {
+			Common::Point msgPos;
+			int msgFlag;
+			if (!_ladderTopFl) {
+				msgPos = Common::Point(0, 0);
+				msgFlag = 2;
+			} else {
+				msgPos = Common::Point(248, 15);
+				msgFlag = 0;
+			}
+			int msgIndex = _scene->_kernelMessages.add(msgPos, 0x1110, msgFlag | 32, 0, 120, _game.getQuote(102));
+			_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+
+			if (_globals[kMeteorologistWatch] == METEOROLOGIST_GROUND) {
+				_action._activeAction._verbId = VERB_LOOK;
+				_action._activeAction._objectNameId = NOUN_BINOCULARS;
+				_action._activeAction._indirectObjectId = NOUN_STRANGE_DEVICE;
+				_game._triggerSetupMode = SEQUENCE_TRIGGER_PARSER;
+				_scene->_sequences.addTimer(2 * 60, 2);
+				_meteorologistSpecial = true;
+			} else if (_globals[kMeteorologistWatch] == METEOROLOGIST_TOWER) {
+				_scene->_sequences.addTimer(2 * 60, 90);
+			}
 		}
-		_globals[kMeteorologistWatch] = 0;
+
+		_globals[kMeteorologistWatch] = METEOROLOGIST_NORMAL;
 	}
 
 	switch (_game._trigger) {
@@ -550,7 +554,7 @@ void Scene202::step() {
 		break;
 	}
 
-	if (!_scene->_activeAnimation && (_globals[kMeteorologistStatus] != 2) && (_meteoClock2 <= _scene->_frameStartTime) && (_meteoClock1 <= _scene->_frameStartTime)) {
+	if (!_scene->_activeAnimation && (_globals[kMeteorologistStatus] != METEOROLOGIST_GONE) && (_meteoClock2 <= _scene->_frameStartTime) && (_meteoClock1 <= _scene->_frameStartTime)) {
 		int randVal = _vm->getRandomNumber(1, 500);
 		int threshold = 1;
 		if (_ladderTopFl)
@@ -574,10 +578,10 @@ void Scene202::step() {
 
 	if (_waitingMeteoFl) {
 		if (_scene->_activeAnimation->getCurrentFrame() >= 200) {
-			if ((_globals[kMeteorologistWatch] == 2) || _globals[kLadderBroken]) {
+			if ((_globals[kMeteorologistWatch] == METEOROLOGIST_TOWER) || _globals[kLadderBroken]) {
 				_scene->_nextSceneId = 213;
 			} else {
-				_vm->_dialogs->show(0x4EE9);
+				_vm->_dialogs->show(20201);
 				_scene->_reloadSceneFlag = true;
 			}
 		}
@@ -597,7 +601,7 @@ void Scene202::step() {
 		}
 	}
 
-	if (_meteoClock2 + 7200 <= _scene->_frameStartTime) {
+	if (_meteoClock2 + 120 * 60 <= _scene->_frameStartTime) {
 		_toTeleportFl = true;
 	}
 
@@ -613,10 +617,12 @@ void Scene202::step() {
 	case 42:
 	case 77:
 	case 96:
+		_stationCounter = 0;
 		frameStep = subStep1(randVal);
 		break;
 	case 51:
 	case 74:
+		_toStationFl = false;
 		frameStep = subStep2(randVal);
 		break;
 	case 27:
@@ -645,19 +651,13 @@ void Scene202::step() {
 		break;
 	}
 
-	if (frameStep < 0)
-		return;
-
-	int nextFrame = 1 + _scene->_activeAnimation->getCurrentFrame() - frameStep;
-	if (nextFrame) {
-		_scene->_activeAnimation->setCurrentFrame(nextFrame);
-		_meteoFrame = nextFrame;
+	if (frameStep >= 0 && frameStep != _scene->_activeAnimation->getCurrentFrame() + 1) {
+		_scene->_activeAnimation->setCurrentFrame(frameStep);
+		_meteoFrame = frameStep;
 	}
 }
 
 int Scene202::subStep1(int randVal) {
-	_stationCounter = 0;
-
 	if ((randVal <= 100) || _toStationFl)
 		return 42;
 
@@ -671,8 +671,6 @@ int Scene202::subStep1(int randVal) {
 }
 
 int Scene202::subStep2(int randVal) {
-	_toStationFl = false;
-
 	if ((randVal <= 150) && (_stationCounter < 5))
 		return 51;
 
@@ -849,7 +847,7 @@ void Scene202::actions() {
 					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
 					if (_scene->_activeAnimation) {
 						_waitingMeteoFl = true;
-						_globals[kMeteorologistWatch] = 1;
+						_globals[kMeteorologistWatch] = METEOROLOGIST_GROUND;
 					} else {
 						_scene->_sequences.addTimer(120, 2);
 					}
@@ -894,7 +892,7 @@ void Scene202::actions() {
 							_scene->_sequences.addTimer(120, 2);
 						} else {
 							_waitingMeteoFl = true;
-							_globals[kMeteorologistWatch] = 2;
+							_globals[kMeteorologistWatch] = METEOROLOGIST_GONE;
 							if ((_scene->_activeAnimation->getCurrentFrame() >= 44) && (_scene->_activeAnimation->getCurrentFrame() <= 75)) {
 								_scene->_kernelMessages.reset();
 								int msgIndex = _scene->_kernelMessages.add(Common::Point(248, 15), 0x1110, 32, 0, 60, _game.getQuote(100));
@@ -911,7 +909,7 @@ void Scene202::actions() {
 				case 2:
 					if (!_scene->_activeAnimation)
 						_vm->_dialogs->show(0x4EFE);
-					_meteorologistSpecial = 0;
+					_meteorologistSpecial = false;
 					_scene->_sequences.remove(_globals._sequenceIndexes[10]);
 					_globals._sequenceIndexes[9] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
 					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
@@ -1000,7 +998,7 @@ void Scene202::synchronize(Common::Serializer &s) {
 	s.syncAsUint32LE(_meteoClock2);
 	s.syncAsUint32LE(_startTime);
 
-	s.syncAsSint32LE(_meteorologistSpecial);
+	s.syncAsByte(_meteorologistSpecial);
 }
 
 /*****************************************************************************/
@@ -4863,7 +4861,7 @@ void Scene213::setup() {
 }
 
 void Scene213::enter() {
-	if (_globals[kMeteorologistWatch] != 0)
+	if (_globals[kMeteorologistWatch] != METEOROLOGIST_ABSENT)
 		_handSpriteId = _scene->_sprites.addSprites("*METHAND");
 	else if (_globals[kSexOfRex] == REX_MALE)
 		_handSpriteId = _scene->_sprites.addSprites("*REXHAND");
@@ -4874,7 +4872,7 @@ void Scene213::enter() {
 
 	// The original is calling Scene2xx::sceneEntrySound()
 		if (_vm->_musicFlag) {
-			if (_globals[kMeteorologistWatch] == 0)
+			if (_globals[kMeteorologistWatch] == METEOROLOGIST_ABSENT)
 				_vm->_sound->command(1);
 			else
 				_vm->_sound->command(9);
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 14a5d75..b4f4866 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -67,7 +67,7 @@ private:
 	bool _activeMsgFl, _ladderTopFl, _waitingMeteoFl, _toStationFl, _toTeleportFl;
 	int _ladderHotspotId, _lastRoute, _stationCounter, _meteoFrame;
 	uint32 _meteoClock1, _meteoClock2, _startTime;
-	int _meteorologistSpecial;
+	bool _meteorologistSpecial;
 
 	int subStep1(int randVal);
 	int subStep2(int randVal);


Commit: 1a7e586a6737474875e3f8dfc7bb20938f05fbe3
    https://github.com/scummvm/scummvm/commit/1a7e586a6737474875e3f8dfc7bb20938f05fbe3
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-15T12:40:42+03:00

Commit Message:
MADS: Further work on scene 701

Changed paths:
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes7.h



diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 60526f7..d02f6cb 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -116,6 +116,9 @@ enum Noun {
 	NOUN_PLATFORM       = 0x22C,
 	NOUN_ALCOHOL        = 0x310,
 	NOUN_SUBMERGED_CITY = 0x313,
+	NOUN_CEMENT_PYLON   = 0x316,
+	NOUN_ELEVATOR       = 0x317,
+	NOUN_BUILDING       = 0x323,
 	NOUN_LASER_BEAM     = 0x343,
 	NOUN_BOAT           = 0x345,
 	NOUN_CEMENT_BLOCK   = 0x38E,
@@ -125,7 +128,8 @@ enum Noun {
 	NOUN_DASH			= 0x3AE,
 	NOUN_SPLASH			= 0x3AF,
 	NOUN_BIRDS          = 0x487,
-	NOUN_WEST_END_OF_PLATFORM = 0x4A9
+	NOUN_WEST_END_OF_PLATFORM = 0x4A9,
+	NOUN_EAST_END_OF_PLATFORM = 0x4AA
 };
 
 class SceneFactory {
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 46eb86c..302c8ba 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -103,7 +103,7 @@ void Scene701::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('b', 5));
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('b', 0));
-	//_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('b', 1));	// FIXME: Invalid resource?
+	//_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('b', 1));	// FIXME: Broken sprite?
 	_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RM202A1");
 	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('b', 8));
 
@@ -156,17 +156,167 @@ void Scene701::enter() {
 		break;
 	}
 
-	// TODO: Line status
+	// TODO: Enable once sprite 3 can be loaded properly
+	/*
+	if (_globals[kLineStatus] == LINE_DROPPED || _globals[kLineStatus] == LINE_TIED) {
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 8);
+		int idx = _scene->_dynamicHotspots.add(NOUN_FISHING_LINE, VERB_WALKTO, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+		_fishingLineId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(234, 129), FACING_NORTHEAST);
+	}
+	*/
+
+	if (_scene->_priorSceneId == 702) {
+		_game._player._playerPos = Common::Point(309, 138);
+		_game._player._facing = FACING_WEST;
+	} else if (_scene->_priorSceneId == 710) {
+		_game._player._playerPos = Common::Point(154, 129);
+		_game._player._facing = FACING_NORTH;
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[5], Common::Point(155, 129));
+		_scene->_sequences.addTimer(15, 60);
+	} else if (_scene->_priorSceneId == 703) {
+		_game._player._playerPos = Common::Point(231, 127);
+		_game._player._facing = FACING_SOUTH;
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+		_scene->loadAnimation(formAnimName('B', 1), 80);
+		_vm->_sound->command(28);
+	} else if (_scene->_priorSceneId != -2 && _scene->_priorSceneId != -620) {
+		_game._player._playerPos = Common::Point(22, 131);
+		_game._player._facing = FACING_EAST;
+		// TODO: Enable once step() is implemented
+		//_game._player._stepEnabled = false;
+		//_scene->_sequences.addTimer(1 * 60, 70);
+	}
 
-	// TODO
+	_game.loadQuoteSet(0x310, 0x30F, 0);
+	sceneEntrySound();
+}
+
+void Scene701::step() {
+	switch(_game._trigger) {
+	case 60:
+		// TODO
+		break;
+	case 61:
+		// TODO
+		break;
+	case 70:
+		// TODO
+		break;
+	case 71:
+		_game._player.walk(Common::Point(61, 131), FACING_EAST);
+		_scene->_sequences.addTimer(2 * 60, 72);
+		break;
+	case 72:
+		// TODO
+		break;
+	case 73:
+		// TODO
+		break;
+	case 80:
+		_game._player._visible = true;
+		// TODO
+		_globals[kBoatStatus] = BOAT_TIED;
+		_game._player._stepEnabled = true;
+		break;
+	}
 }
 
 void Scene701::preActions() {
-	// TODO
+	if (_action.isAction(VERB_WALKTO, NOUN_EAST_END_OF_PLATFORM)) {
+		_game._player._walkOffScreenSceneId = 702;
+	}
+
+	if (_action.isAction(VERB_LOOK, NOUN_BUILDING)) {
+		_game._player.walk(Common::Point(154, 129), FACING_NORTHEAST);
+	}
+
+	if (_action.isAction(VERB_LOOK, NOUN_BINOCULARS, NOUN_BUILDING)) {
+		_game._player.walk(Common::Point(154, 129), FACING_NORTH);
+	}
 }
 
 void Scene701::actions() {
-	// TODO
+	if (_action.isAction(VERB_WALK_ALONG, NOUN_PLATFORM))
+		return;
+	
+	if (_action.isAction(VERB_LOOK, NOUN_BINOCULARS, NOUN_BUILDING) && _game._objects[OBJ_VASE]._roomNumber == 706) {
+		switch (_game._trigger) {
+		case 0:
+			// TODO
+			break;
+		case 1:
+			// TODO
+			break;
+		case 2:
+			_scene->_nextSceneId = 710;
+			break;
+		}
+	} else if (_action.isAction(VERB_STEP_INTO, NOUN_ELEVATOR)) {
+		switch (_game._trigger) {
+		case 0:
+			// TODO
+			break;
+		case 1:
+			// TODO
+			break;
+		case 3:
+			// TODO
+			break;
+		case 4:
+			// TODO
+			break;
+		}
+	} else if (false) {
+		// TODO: boat + fishing line action
+	} else if (_action.isAction(VERB_CLIMB_INTO, NOUN_BOAT) && _globals[kBoatStatus] == BOAT_TIED) {
+		switch (_game._trigger) {
+		case 0:
+			// TODO
+			break;
+		case 1:
+			_scene->_nextSceneId = 703;
+			break;
+		}
+	} else if (_action._lookFlag) {
+		if (_globals[kBoatStatus] != BOAT_GONE) {
+			if (_globals[kBoatStatus] == BOAT_TIED)
+				_vm->_dialogs->show(70128);
+			else
+				_vm->_dialogs->show(70110);
+		} else {
+			_vm->_dialogs->show(70111);
+		}
+	} else if (_action.isAction(VERB_LOOK, NOUN_SUBMERGED_CITY)) {
+		_vm->_dialogs->show(70112);
+	} else if (_action.isAction(VERB_LOOK, 0)) {
+		_vm->_dialogs->show(70113);
+	} else if (_action.isAction(VERB_LOOK, NOUN_PLATFORM)) {
+		_vm->_dialogs->show(70114);
+	} else if (_action.isAction(VERB_LOOK, NOUN_CEMENT_PYLON)) {
+		_vm->_dialogs->show(70115);
+	} else if (false) {
+		// TODO: hook
+	} else if (_action.isAction(VERB_LOOK, NOUN_ROCK)) {
+		_vm->_dialogs->show(70118);
+	} else if (_action.isAction(VERB_TAKE, NOUN_ROCK)) {
+		_vm->_dialogs->show(70119);
+	} else if (_action.isAction(VERB_LOOK, NOUN_EAST_END_OF_PLATFORM)) {
+		_vm->_dialogs->show(70120);
+	} else if (_action.isAction(VERB_LOOK, NOUN_BUILDING)) {
+		_vm->_dialogs->show(70121);
+	} else if (_action.isAction(VERB_LOOK, NOUN_BOAT)) {
+		if (_globals[kBoatStatus] == BOAT_ADRIFT || _globals[kBoatStatus] == BOAT_TIED_FLOATING)
+			_vm->_dialogs->show(70122);
+		else
+			_vm->_dialogs->show(70123);
+	} else if (false) {
+		// TODO: fishing rod + boat
+	}
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/nebular/nebular_scenes7.h b/engines/mads/nebular/nebular_scenes7.h
index cc82206..c878149 100644
--- a/engines/mads/nebular/nebular_scenes7.h
+++ b/engines/mads/nebular/nebular_scenes7.h
@@ -51,13 +51,17 @@ public:
 };
 
 class Scene701: public Scene7xx {
+private:
+	int _fishingLineId;
+
 public:
-	Scene701(MADSEngine *vm) : Scene7xx(vm) {}
+	Scene701(MADSEngine *vm) : Scene7xx(vm), _fishingLineId(-1) {}
 
 	virtual void setup();
 	virtual void enter();
 	virtual void preActions();
 	virtual void actions();
+	virtual void step();
 };
 
 class Scene702: public Scene7xx {


Commit: c1663ab6cc6c0b898c8de6b2c30dee1ec596ad56
    https://github.com/scummvm/scummvm/commit/c1663ab6cc6c0b898c8de6b2c30dee1ec596ad56
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-15T12:35:08-04:00

Commit Message:
MADS: Implemented sound player for scene group 3

Changed paths:
    engines/mads/nebular/sound_nebular.cpp
    engines/mads/nebular/sound_nebular.h
    engines/mads/sound.cpp



diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp
index 5636598..53b6042 100644
--- a/engines/mads/nebular/sound_nebular.cpp
+++ b/engines/mads/nebular/sound_nebular.cpp
@@ -32,6 +32,8 @@ namespace MADS {
 
 namespace Nebular {
 
+bool AdlibChannel::_channelsEnabled;
+
 AdlibChannel::AdlibChannel() {
 	_activeCount = 0;
 	_field1 = 0;
@@ -58,6 +60,8 @@ AdlibChannel::AdlibChannel() {
 	_field1D = 0;
 	_field1E = 0;
 	_field1F = 0;
+
+	_field20 = 0;
 }
 
 void AdlibChannel::reset() {
@@ -76,6 +80,8 @@ void AdlibChannel::enable(int flag) {
 		// a simple null pointer
 		_soundData = nullptr;
 	}
+
+	_channelsEnabled = true;
 }
 
 void AdlibChannel::setPtr2(byte *pData) {
@@ -149,6 +155,7 @@ ASound::ASound(Audio::Mixer *mixer, const Common::String &filename, int dataOffs
 		error("Could not open file - %s", filename.c_str());
 
 	// Initialise fields
+	_commandParam = 0;
 	_activeChannelPtr = nullptr;
 	_samplePtr = nullptr;
 	_frameCounter = 0;
@@ -178,6 +185,8 @@ ASound::ASound(Audio::Mixer *mixer, const Common::String &filename, int dataOffs
 	_samplesPerCallback = getRate() / CALLBACKS_PER_SECOND;
 	_samplesPerCallbackRemainder = getRate() % CALLBACKS_PER_SECOND;
 
+	AdlibChannel::_channelsEnabled = false;
+
 	// Store passed parameters, and setup OPL
 	_dataOffset = dataOffset;
 	_mixer = mixer;
@@ -387,8 +396,10 @@ void ASound::pollChannels() {
 }
 
 void ASound::checkChannels() {
-	for (int i = 0; i < ADLIB_CHANNEL_COUNT; ++i)
-		_channels[i].check(_nullData);
+	if (AdlibChannel::_channelsEnabled) {
+		for (int i = 0; i < ADLIB_CHANNEL_COUNT; ++i)
+			_channels[i].check(_nullData);
+	}
 }
 
 void ASound::pollActiveChannel() {
@@ -1236,6 +1247,11 @@ int ASound2::command(int commandId, int param) {
 	return (this->*_commandList[commandId])();
 }
 
+int ASound2::command0() {
+	_command12Param = 0xFD;
+	return ASound::command0();
+}
+
 int ASound2::command9() {
 	byte *pData1 = loadData(0x1094, 376);
 	if (!isSoundActive(pData1)) {
@@ -1564,6 +1580,410 @@ int ASound2::command43() {
 	return 0;
 }
 
+/*-----------------------------------------------------------------------*/
+
+const ASound3::CommandPtr ASound3::_commandList[61] = {
+	&ASound3::command0, &ASound3::command1, &ASound3::command2, &ASound3::command3,
+	&ASound3::command4, &ASound3::command5, &ASound3::command6, &ASound3::command7,
+	&ASound3::command8, &ASound3::command9, &ASound3::command10, &ASound3::command11,
+	&ASound3::nullCommand, &ASound3::command13, &ASound3::command14, &ASound3::command15,
+	&ASound3::command16, &ASound3::command17, &ASound3::command18, &ASound3::command19,
+	&ASound3::command20, &ASound3::command21, &ASound3::command22, &ASound3::command23,
+	&ASound3::command24, &ASound3::command25, &ASound3::command26, &ASound3::command27,
+	&ASound3::command28, &ASound3::command29, &ASound3::command30, &ASound3::command31,
+	&ASound3::command32, &ASound3::command33, &ASound3::command34, &ASound3::command35,
+	&ASound3::command36, &ASound3::command37, &ASound3::command38, &ASound3::command39,
+	&ASound3::command40, &ASound3::command41, &ASound3::command42, &ASound3::command43,
+	&ASound3::command44, &ASound3::command45, &ASound3::command46, &ASound3::command47,
+	&ASound3::nullCommand, &ASound3::command49, &ASound3::command50, &ASound3::command51,
+	&ASound3::nullCommand, &ASound3::nullCommand, &ASound3::nullCommand, &ASound3::nullCommand,
+	&ASound3::nullCommand, &ASound3::command57, &ASound3::nullCommand, &ASound3::command59,
+	&ASound3::command60
+};
+
+ASound3::ASound3(Audio::Mixer *mixer) : ASound(mixer, "asound.003", 0x15B0) {
+	_command39Flag = false;
+
+	// Load sound samples
+	_soundFile.seek(_dataOffset + 0x122);
+	for (int i = 0; i < 192; ++i)
+		_samples.push_back(AdlibSample(_soundFile));
+}
+
+int ASound3::command(int commandId, int param) {
+	if (commandId > 60)
+		return 0;
+
+	_commandParam = param;
+	_frameCounter = 0;
+	return (this->*_commandList[commandId])();
+}
+
+int ASound3::command9() {
+	AdlibChannel::_channelsEnabled = _commandParam != 0;
+	
+	return 0;
+}
+
+int ASound3::command10() {
+	byte *pData1 = loadData(0x13EA, 254);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[0].load(pData1);
+		_channels[1].load(loadData(0X14E8, 452));
+		_channels[2].load(loadData(0x16AC, 396));
+		_channels[3].load(loadData(0x1838, 118));
+		_channels[4].load(loadData(0x18AE, 74));
+	}
+
+	return 0;
+}
+
+int ASound3::command11() {
+	byte *pData1 = loadData(0x2B84, 596);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[0].load(pData1);
+		_channels[1].load(loadData(0x2DD8, 562));
+		_channels[2].load(loadData(0x300A, 1694));
+		_channels[3].load(loadData(0x36A8, 1100));
+		_channels[4].load(loadData(0x3AF4, 420));
+		_channels[5].load(loadData(0x3C98, 1516));
+	}
+
+	return 0;
+}
+
+int ASound3::command13() {
+	byte *pData1 = loadData(0x4470, 64);
+	if (!isSoundActive(pData1)) {
+		command1();
+		playSoundData(pData1);
+		playSound(0x44B0, 64);
+		playSound(0x44F0, 64);
+		playSound(0x4530, 64);
+		playSound(0x4570, 64);
+		playSound(0X45b0, 64);
+	}
+
+	return 0;
+}
+
+int ASound3::command14() {
+	byte *pData1 = loadData(0X45F0, 36);
+	if (!isSoundActive(pData1)) {
+		command1();
+		playSoundData(pData1);
+		playSound(0x4614, 36);
+		playSound(0x4638, 36);
+		playSound(0x465C, 32);
+		playSound(0x467C, 76);
+		playSound(0x46C8, 74);
+	}
+
+	return 0;
+}
+
+int ASound3::command15() {
+	_channels[3].load(loadData(0x36A8, 1100));
+	_channels[4].load(loadData(0x3AF4, 420));
+	_channels[5].load(loadData(0x3C98, 1516));
+
+	_channels[3]._field20 = 0xDD;
+	_channels[4]._field20 = 0xDD;
+	_channels[5]._field20 = 0xDD;
+
+	return 0;
+}
+
+int ASound3::command16() {
+	byte *pData1 = loadData(0x4712, 398);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[0].load(pData1);
+		_channels[1].load(loadData(0x48A0, 354));
+		_channels[2].load(loadData(0x4A02, 410));
+		_channels[3].load(loadData(0x4B9C, 392));
+	}
+
+	return 0;
+}
+
+int ASound3::command17() {
+	byte *pData1 = loadData(0x18F8, 400);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[0].load(pData1);
+		_channels[1].load(loadData(0x1A88, 680));
+		_channels[2].load(loadData(0x1D30, 478));
+		_channels[3].load(loadData(0x1F0E, 1146));
+		_channels[4].load(loadData(0x2388, 1006));
+		_channels[5].load(loadData(0x2776, 1038));
+	}
+
+	return 0;
+}
+
+int ASound3::command18() {
+	byte *pData1 = loadData(0x4284, 142);
+	if (!isSoundActive(pData1)) {
+		command1();
+		playSoundData(pData1);
+		playSound(0x4312, 172);
+		playSound(0x43BE, 88);
+		playSound(0x4416, 90);
+	}
+
+	return 0;
+}
+
+int ASound3::command19() {
+	playSound(0x4F6, 8);
+
+	return 0;
+}
+
+int ASound3::command20() {
+	playSound(0x4F1C, 10);
+
+	return 0;
+}
+
+int ASound3::command21() {
+	playSound(0x4F2E, 8);
+
+	return 0;
+}
+
+int ASound3::command22() {
+	playSound(0x4F36, 16);
+
+	return 0;
+}
+
+int ASound3::command23() {
+	playSound(0x4F50, 10);
+	playSound(0x4F46, 10);
+
+	return 0;
+}
+
+int ASound3::command24() {
+	// WORKAROUND: Original calls isSoundActive without loading data pointer
+	byte *pData = loadData(0x4EFC, 12);
+	if (!isSoundActive(pData)) {
+		int v;
+		while ((v = (getRandomNumber() & 0x3F)) > 45)
+			;
+
+		pData[6] = v + 19;
+		playSoundData(pData);
+	}
+
+	return 0;
+}
+
+int ASound3::command25() {
+	playSound(0x4EE6, 22);
+
+	return 0;
+}
+
+int ASound3::command26() {
+	playSound(0x4F5A, 8);
+
+	return 0;
+}
+
+int ASound3::command27() {
+	playSound(0x4DA2, 34);
+	playSound(0x4DC4, 20);
+
+	return 0;
+}
+
+int ASound3::command28() {
+	playSound(0x4F72, 10);
+	playSound(0x4F72, 10);
+
+	return 0;
+}
+
+int ASound3::command29() {
+	playSound(0x4F72, 10);
+	playSound(0x4F72, 10);
+
+	return 0;
+}
+
+int ASound3::command30() {
+	playSound(0x4E5A, 22);
+	playSound(0x4E70, 22);
+	playSound(0x4E86, 22);
+
+	return 0;
+}
+
+int ASound3::command31() {
+	playSound(0x4F7C, 40);
+
+	return 0;
+}
+
+int ASound3::command32() {
+	playSound(0x4ED2, 10);
+
+	return 0;
+}
+
+int ASound3::command33() {
+	playSound(0x4EC2, 16);
+
+	return 0;
+}
+
+int ASound3::command34() {
+	playSound(0x4EB2, 16);
+
+	return 0;
+}
+
+int ASound3::command35() {
+	playSound(0x4E9C, 22);
+
+	return 0;
+}
+
+int ASound3::command36() {
+	playSound(0x4D2C, 16);
+
+	return 0;
+}
+
+int ASound3::command37() {
+	playSound(0x4E1E, 20);
+	playSound(0x4E32, 30);
+	playSound(0x4E50, 10);
+
+	return 0;
+}
+
+int ASound3::command38() {
+	playSound(0x4FAC, 10);
+
+	return 0;
+}
+
+int ASound3::command39() {
+	_command39Flag = !_command39Flag;
+	if (_command39Flag) {
+		playSound(0x4FD0, 8);
+	} else {
+		playSound(0x4FD8, 8);
+	}
+
+	return 0;
+}
+
+int ASound3::command40() {
+	_command39Flag = !_command39Flag;
+	if (_command39Flag) {
+		playSound(0x4EE0, 8);
+	} else {
+		playSound(0x4EE8, 8);
+	}
+
+	return 0;
+}
+
+int ASound3::command41() {
+	playSound(0x4F08, 20);
+
+	return 0;
+}
+
+int ASound3::command42() {
+	playSound(0x4DD8, 28);
+	playSound(0x4DF4, 42);
+
+	return 0;
+}
+
+int ASound3::command43() {
+	playSound(0x4FB6, 12);
+	playSound(0x4FC2, 14);
+
+	return 0;
+}
+
+int ASound3::command44() {
+	playSound(0x4FFE, 14);
+
+	return 0;
+}
+
+int ASound3::command45() {
+	playSound(0x500C, 14);
+
+	return 0;
+}
+
+int ASound3::command46() {
+	playSound(0x4D78, 14);
+	playSound(0x4D86, 14);
+	playSound(0x4D94, 14);
+
+	return 0;
+}
+
+int ASound3::command47() {
+	playSound(0x4D62, 8);
+	playSound(0x4D6A, 14);
+
+	return 0;
+}
+
+int ASound3::command49() {
+	playSound(0x4D62, 8);
+	playSound(0x4D6A, 14);
+
+	return 0;
+}
+
+int ASound3::command50() {
+	playSound(0x4D3C, 14);
+	playSound(0x4D4A, 14);
+	playSound(0x4D58, 10);
+
+	return 0;
+}
+
+int ASound3::command51() {
+	playSound(0x4FF0, 14);
+
+	return 0;
+}
+
+int ASound3::command57() {
+	byte *pData = loadData(0x4EDC, 10);
+	pData[6] = (getRandomNumber() & 7) + 85;
+	playSoundData(pData);
+
+	return 0;
+}
+
+int ASound3::command59() {
+	playSound(0x4F62, 16);
+
+	return 0;
+}
+
+int ASound3::command60() {
+	playSound(0x4FA4, 8);
+
+	return 0;
+}
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/sound_nebular.h b/engines/mads/nebular/sound_nebular.h
index 3c69c0c..289c3b9 100644
--- a/engines/mads/nebular/sound_nebular.h
+++ b/engines/mads/nebular/sound_nebular.h
@@ -67,6 +67,11 @@ public:
 	int _field1D;
 	int _field1E;
 	int _field1F;
+	
+	// TODO: Only used by asound.003. Figure out usage
+	byte _field20;
+public:
+	static bool _channelsEnabled;
 public:
 	AdlibChannel();
 
@@ -180,6 +185,8 @@ private:
 
 	void updateFNumber();
 protected:
+	int _commandParam;
+
 	/**
 	 * Queue a byte for an Adlib register
 	 */
@@ -245,7 +252,7 @@ protected:
 	 */
 	int getRandomNumber();
 
-	int command0();
+	virtual int command0();
 	int command1();
 	int command2();
 	int command3();
@@ -361,7 +368,6 @@ private:
 	typedef int (ASound1::*CommandPtr)();
 	static const CommandPtr _commandList[42];
 	bool _cmd23Toggle;
-	int _commandParam;
 
 	int command9();
 	int command10();
@@ -412,6 +418,7 @@ private:
 	typedef int (ASound2::*CommandPtr)();
 	static const CommandPtr _commandList[44];
 
+	virtual int command0();
 	int command9();
 	int command10();
 	int command11();
@@ -456,6 +463,67 @@ public:
 	virtual int command(int commandId, int param);
 };
 
+class ASound3 : public ASound {
+private:
+	bool _command39Flag;
+
+	typedef int (ASound3::*CommandPtr)();
+	static const CommandPtr _commandList[61];
+
+	int command9();
+	int command10();
+	int command11();
+	int command13();
+	int command14();
+	int command15();
+	int command16();
+	int command17();
+	int command18();
+	int command19();
+	int command20();
+	int command21();
+	int command22();
+	int command23();
+	int command24();
+	int command25();
+	int command26();
+	int command27();
+	int command28();
+	int command29();
+	int command30();
+	int command31();
+	int command32();
+	int command33();
+	int command34();
+	int command35();
+	int command36();
+	int command37();
+	int command38();
+	int command39();
+	int command40();
+	int command41();
+	int command42();
+	int command43();
+	int command44();
+	int command45();
+	int command46();
+	int command47();
+	int command49();
+	int command50();
+	int command51();
+	int command57();
+	int command59();
+	int command60();
+	int nullCommand() { return 0; }
+
+	void command9Randomize();
+	void command9Apply(byte *data, int val, int incr);
+public:
+	ASound3(Audio::Mixer *mixer);
+
+	virtual int command(int commandId, int param);
+};
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index 3dc53be..72826ef 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -55,6 +55,9 @@ void SoundManager::init(int sectionNumber) {
 		case 2:
 			_driver = new Nebular::ASound2(_mixer);
 			break;
+		case 3:
+			_driver = new Nebular::ASound3(_mixer);
+			break;
 		default:
 			_driver = nullptr;
 			break;


Commit: c05aaa029be1f396201cdcb2a999af3976ebd11a
    https://github.com/scummvm/scummvm/commit/c05aaa029be1f396201cdcb2a999af3976ebd11a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-15T15:06:35-04:00

Commit Message:
MADS: Implemented sound player for scene group 4

Changed paths:
    engines/mads/nebular/sound_nebular.cpp
    engines/mads/nebular/sound_nebular.h
    engines/mads/sound.cpp



diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp
index 53b6042..8b1a02e 100644
--- a/engines/mads/nebular/sound_nebular.cpp
+++ b/engines/mads/nebular/sound_nebular.cpp
@@ -1984,6 +1984,266 @@ int ASound3::command60() {
 	return 0;
 }
 
+/*-----------------------------------------------------------------------*/
+
+const ASound4::CommandPtr ASound4::_commandList[61] = {
+	&ASound4::command0, &ASound4::command1, &ASound4::command2, &ASound4::command3,
+	&ASound4::command4, &ASound4::command5, &ASound4::command6, &ASound4::command7,
+	&ASound4::command8, &ASound4::nullCommand, &ASound4::command10, &ASound4::nullCommand,
+	&ASound4::command12, &ASound4::nullCommand, &ASound4::nullCommand, &ASound4::nullCommand,
+	&ASound4::nullCommand, &ASound4::nullCommand, &ASound4::nullCommand, &ASound4::command19,
+	&ASound4::command20, &ASound4::command21, &ASound4::nullCommand, &ASound4::nullCommand,
+	&ASound4::command24, &ASound4::nullCommand, &ASound4::nullCommand, &ASound4::command27,
+	&ASound4::nullCommand, &ASound4::nullCommand, &ASound4::command30, &ASound4::nullCommand,
+	&ASound4::command32, &ASound4::command33, &ASound4::command34, &ASound4::command35,
+	&ASound4::command36, &ASound4::command37, &ASound4::command38, &ASound4::nullCommand,
+	&ASound4::nullCommand, &ASound4::nullCommand, &ASound4::nullCommand, &ASound4::command43,
+	&ASound4::nullCommand, &ASound4::nullCommand, &ASound4::nullCommand, &ASound4::nullCommand,
+	&ASound4::nullCommand, &ASound4::nullCommand, &ASound4::nullCommand, &ASound4::nullCommand,
+	&ASound4::nullCommand, &ASound4::nullCommand, &ASound4::nullCommand, &ASound4::nullCommand,
+	&ASound4::nullCommand, &ASound4::command57, &ASound4::nullCommand, &ASound4::command59,
+	&ASound4::command60
+};
+
+ASound4::ASound4(Audio::Mixer *mixer) : ASound(mixer, "asound.004", 0x14F0) {
+	// Load sound samples
+	_soundFile.seek(_dataOffset + 0x122);
+	for (int i = 0; i < 210; ++i)
+		_samples.push_back(AdlibSample(_soundFile));
+}
+
+int ASound4::command(int commandId, int param) {
+	if (commandId > 60)
+		return 0;
+
+	_commandParam = param;
+	_frameCounter = 0;
+	return (this->*_commandList[commandId])();
+}
+
+int ASound4::command10() {
+	byte *pData = loadData(0x22AA, 254);
+	if (!isSoundActive(pData)) {
+		command1();
+		_channels[0].load(pData);
+		_channels[1].load(loadData(0x23A8, 452));
+		_channels[2].load(loadData(0x256C, 396));
+		_channels[3].load(loadData(0x26F8, 118));
+		_channels[4].load(loadData(0x276E, 74));
+	}
+
+	return 0;
+}
+
+int ASound4::command12() {
+	byte *pData = loadData(0x16A8, 550);
+	if (!isSoundActive(pData)) {
+		command1();
+		_channels[0].load(pData);
+		_channels[1].load(loadData(0x18CE, 442));
+		_channels[2].load(loadData(0x1A88, 298));
+		_channels[3].load(loadData(0x1BB2, 354));
+		_channels[4].load(loadData(0x1D14, 572));
+		_channels[4].load(loadData(0x1F50, 560));
+	}
+
+	int v = (_commandParam > 0x40) ? _commandParam - 0x40 : 0;
+	v += 0xB5;
+	for (int channelNum = 0; channelNum < 6; ++channelNum)
+		_channels[channelNum]._field20 = v;
+
+	return 0;
+}
+
+int ASound4::command19() {
+	playSound(0x28EC, 8);
+	
+	return 0;
+}
+
+int ASound4::command20() {
+	playSound(0x28E2, 10);
+
+	return 0;
+}
+
+int ASound4::command21() {
+	playSound(0x27C0, 8);
+
+	return 0;
+}
+
+int ASound4::command24() {
+	int v;
+	while ((v = (getRandomNumber() & 0x3F)) > 45)
+		;
+
+	byte *pData = loadData(0x28D6, 12);
+	pData[6] = v + 19;
+	playSoundData(pData);
+
+	return 0;
+}
+
+int ASound4::command27() {
+	playSound(0x27D8, 34);
+	playSound(0x27FA, 20);
+
+	return 0;
+}
+
+int ASound4::command30() {
+	playSound(0x284A, 22);
+	playSound(0x2860, 22);
+	playSound(0x2876, 22);
+
+	return 0;
+}
+
+int ASound4::command32() {
+	playSound(0x28C2, 10);
+
+	return 0;
+}
+
+int ASound4::command33() {
+	playSound(0x28B2, 16);
+
+	return 0;
+}
+
+int ASound4::command34() {
+	playSound(0x28A2, 16);
+
+	return 0;
+}
+
+int ASound4::command35() {
+	playSound(0x288C, 22);
+
+	return 0;
+}
+
+int ASound4::command36() {
+	playSound(0x27C8, 16);
+
+	return 0;
+}
+
+int ASound4::command37() {
+	playSound(0x280E, 20);
+	playSound(0x2822, 30);
+	playSound(0x2840, 10);
+
+	return 0;
+}
+
+int ASound4::command38() {
+	playSound(0x2904, 10);
+
+	return 0;
+}
+
+int ASound4::command43() {
+	playSound(0x290E, 12);
+	playSound(0x291A, 14);
+
+	return 0;
+}
+
+int ASound4::command52() {
+	byte *pData = loadData(0x23A8, 452);
+	if (_channels[1]._ptr1 == pData) {
+		pData = loadData(0x146E, 570);
+		if (!isSoundActive(pData)) {
+			_channels[0].load(pData);
+			_channels[1]._field20 = 0xD8;
+			_channels[2]._field20 = 0xD8;
+		}
+	}
+
+	return 0;
+}
+
+int ASound4::command53() {
+	method1();
+	_channels[0]._field20 = 0;
+
+	return 0;
+}
+
+int ASound4::command54() {
+	method1();
+	_channels[1]._field20 = 0;
+	_channels[2]._field20 = 0;
+
+	return 0;
+}
+
+int ASound4::command55() {
+	method1();
+	_channels[3]._field20 = 0;
+	_channels[4]._field20 = 0;
+
+	return 0;
+}
+
+int ASound4::command56() {
+	method1();
+	_channels[5]._field20 = 0;
+
+	return 0;
+}
+
+int ASound4::command57() {
+	int v = (getRandomNumber() & 7) + 85;
+	byte *pData = loadData(0x28CC, 10);
+	pData[6] = v;
+	playSoundData(pData);
+
+	return 0;
+}
+
+int ASound4::command58() {
+	byte *pData = loadData(0x146E, 570);
+	if (_channels[1]._ptr1 == pData) {
+		_channels[0].load(loadData(0x22AA, 254));
+		_channels[1]._field20 = 0;
+		_channels[2]._field20 = 0;
+	}
+
+	return 0;
+}
+
+int ASound4::command59() {
+	playSound(0x28F4, 8);
+
+	return 0;
+}
+
+int ASound4::command60() {
+	playSound(0x28FC, 8);
+
+	return 0;
+}
+
+void ASound4::method1() {
+	byte *pData = loadData(0x2180, 58);
+	if (!isSoundActive(pData)) {
+		command1();
+
+		_channels[0].load(pData);
+		_channels[1].load(loadData(0x21BA, 48));
+		_channels[2].load(loadData(0x21EA, 50));
+		_channels[3].load(loadData(0x221C, 40));
+		_channels[4].load(loadData(0x2244, 28));
+		_channels[5].load(loadData(0x2260, 74));
+
+		for (int channel = 0; channel < 6; ++channel)
+			_channels[channel]._field20 = 0xB5;
+	}
+}
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/sound_nebular.h b/engines/mads/nebular/sound_nebular.h
index 289c3b9..68c9fdf 100644
--- a/engines/mads/nebular/sound_nebular.h
+++ b/engines/mads/nebular/sound_nebular.h
@@ -524,6 +524,46 @@ public:
 	virtual int command(int commandId, int param);
 };
 
+class ASound4 : public ASound {
+private:
+	typedef int (ASound4::*CommandPtr)();
+	static const CommandPtr _commandList[61];
+
+	int command10();
+	int command12();
+	int command19();
+	int command20();
+	int command21();
+	int command24();
+	int command27();
+	int command30();
+	int command32();
+	int command33();
+	int command34();
+	int command35();
+	int command36();
+	int command37();
+	int command38();
+	int command43();
+	int command52();
+	int command53();
+	int command54();
+	int command55();
+	int command56();
+	int command57();
+	int command58();
+	int command59();
+	int command60();
+	int nullCommand() { return 0; }
+
+	void method1();
+public:
+	ASound4(Audio::Mixer *mixer);
+
+	virtual int command(int commandId, int param);
+};
+
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index 72826ef..adab5f7 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -58,6 +58,9 @@ void SoundManager::init(int sectionNumber) {
 		case 3:
 			_driver = new Nebular::ASound3(_mixer);
 			break;
+		case 4:
+			_driver = new Nebular::ASound4(_mixer);
+			break;
 		default:
 			_driver = nullptr;
 			break;


Commit: 690efa51f53c74e3f3cfc402829a2714024a141e
    https://github.com/scummvm/scummvm/commit/690efa51f53c74e3f3cfc402829a2714024a141e
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-15T22:13:26+02:00

Commit Message:
MADS: Implement scene 703

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes7.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index df19326..fb7bb05 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -255,7 +255,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 702:	// outside teleporter (after city is submerged)
 		return new Scene702(vm);
 	case 703:	// water
-		return new DummyScene(vm);	// TODO
+		return new Scene703(vm);
 	case 704:	// water, building in the distance
 		return new DummyScene(vm);	// TODO
 	case 705:	// water, outside building
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 302c8ba..ec99f14 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -126,7 +126,7 @@ void Scene701::enter() {
 			_globals[kBoatStatus] = BOAT_TIED_FLOATING;
 		else if (_game._difficulty == DIFFICULTY_HARD)
 			_globals[kBoatStatus] = BOAT_ADRIFT;
-		else 
+		else
 			_globals[kBoatStatus] = BOAT_TIED;
 	}
 
@@ -382,7 +382,7 @@ void Scene702::actions() {
 		case 1:
 			_vm->_sound->command(0xF);
 			if (_game._objects.isInInventory(OBJ_BONE))
-				_game._objects.setRoom(OBJ_BONE, NOWHERE);
+				_game._objects.setRoom(OBJ_BONE, 1);
 			_game._objects.addToInventory(OBJ_BONES);
 			_vm->_dialogs->show(OBJ_BONES, 70218);
 			break;
@@ -423,6 +423,532 @@ void Scene702::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene703::setup() {
+	_game._player._spritesPrefix = "";
+	setAAName();
+}
+
+void Scene703::handleBottleInterface() {
+	switch (_globals[kBottleStatus]) {
+	case 0:
+		_dialog1.write(0x311, true);
+		_dialog1.write(0x312, true);
+		_dialog1.write(0x313, true);
+		_dialog1.write(0x314, true);
+		_dialog1.write(0x315, true);
+		break;
+
+	case 1:
+		_dialog1.write(0x311, false);
+		_dialog1.write(0x312, true);
+		_dialog1.write(0x313, true);
+		_dialog1.write(0x314, true);
+		_dialog1.write(0x315, true);
+		break;
+
+	case 2:
+		_dialog1.write(0x311, false);
+		_dialog1.write(0x312, false);
+		_dialog1.write(0x313, true);
+		_dialog1.write(0x314, true);
+		_dialog1.write(0x315, true);
+		break;
+
+	case 3:
+		_dialog1.write(0x311, false);
+		_dialog1.write(0x312, false);
+		_dialog1.write(0x313, false);
+		_dialog1.write(0x314, true);
+		_dialog1.write(0x315, true);
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene703::setBottleSequence() {
+	_scene->_userInterface.setup(kInputBuildingSentences);
+	_game._player._stepEnabled = false;
+	if (_boatDir == 2)
+		_curSequence = 6;
+	else
+		_curSequence = 7;
+}
+
+void Scene703::handleFillBottle(int quote) {
+	switch (quote) {
+	case 0x311:
+		_globals[kBottleStatus] = 1;
+		setBottleSequence();
+		break;
+
+	case 0x312:
+		_globals[kBottleStatus] = 2;
+		setBottleSequence();
+		break;
+
+	case 0x313:
+		_globals[kBottleStatus] = 3;
+		setBottleSequence();
+		break;
+
+	case 0x314:
+		_globals[kBottleStatus] = 4;
+		setBottleSequence();
+		break;
+
+	case 0x315:
+		_scene->_userInterface.setup(kInputBuildingSentences);
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene703::enter() {
+	_game._player._visible = false;
+
+	if (!_game._visitedScenes._sceneRevisited) {
+		if (_scene->_priorSceneId == 704)
+			_globals[kMonsterAlive] = false;
+		else
+			_globals[kMonsterAlive] = true;
+	}
+
+	_startMonsterTimer = true;
+	_rexDeathFl = true;
+	_monsterTime = 0;
+	_restartTrigger70Fl = true;
+	_useBomb = false;
+	_boatFrame = -1;
+
+	if (!_globals[kMonsterAlive])
+		_scene->_hotspots.activate(0x468, false);
+
+	if (_scene->_priorSceneId == 704) {
+		_game._player._stepEnabled = false;
+		_curSequence = 2;
+		_boatDir = 2;
+		_monsterMode = 0;
+		_scene->loadAnimation(formAnimName('A', -1), 0);
+		_scene->_activeAnimation->setCurrentFrame(34);
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._stepEnabled = false;
+		_boatDir = 1;
+		if (_globals[kMonsterAlive]) {
+			_monsterMode = 1;
+			_curSequence = 0;
+			_scene->loadAnimation(formAnimName('B', -1), 0);
+		} else {
+			_curSequence = 0;
+			_monsterMode = 0;
+			_scene->loadAnimation(formAnimName('A', -1), 0);
+		}
+	} else if (_globals[kMonsterAlive]) {
+		_curSequence = 0;
+		_boatDir = 1;
+		_monsterMode = 1;
+		_scene->loadAnimation(formAnimName('B', -1), 0);
+		_scene->_activeAnimation->setCurrentFrame(39);
+	} else if (_boatDir == 1) {
+		_curSequence = 0;
+		_monsterMode = 0;
+		_scene->loadAnimation(formAnimName('A', -1), 0);
+		_scene->_activeAnimation->setCurrentFrame(9);
+	} else if (_boatDir == 2) {
+		_curSequence = 0;
+		_monsterMode = 0;
+		_scene->loadAnimation(formAnimName('A', -1), 0);
+		_scene->_activeAnimation->setCurrentFrame(56);
+	}
+
+	if (_scene->_roomChanged) {
+		_game._objects.addToInventory(OBJ_TWINKIFRUIT);
+		_game._objects.addToInventory(OBJ_BOMB);
+		_game._objects.addToInventory(OBJ_CHICKEN);
+		_game._objects.addToInventory(OBJ_BONES);
+	}
+
+	_game.loadQuoteSet(0x311, 0x312, 0x313, 0x314, 0x315, 0);
+	_dialog1.setup(0x98, 0x311, 0x312, 0x313, 0x314, 0x315, 0);
+	sceneEntrySound();
+	_vm->_sound->command(28);
+}
+
+void Scene703::step() {
+	if (_startMonsterTimer) {
+		long diff = _scene->_frameStartTime - _lastFrameTime;
+		if ((diff >= 0) && (diff <= 12))
+			_monsterTime += diff;
+		else
+			_monsterTime++;
+
+		_lastFrameTime = _scene->_frameStartTime;
+	}
+
+	if ((_monsterTime >= 2400) && !_rexDeathFl && !_useBomb) {
+		_startMonsterTimer = false;
+		_rexDeathFl = true;
+		_game._player._stepEnabled = false;
+		_scene->freeAnimation();
+		_monsterMode = 3;
+		_scene->loadAnimation(formAnimName('D', -1), 0);
+		_rexDeathFl = false;
+		_monsterTime = 0;
+	}
+
+
+	if (_game._trigger == 70)
+		_scene->_reloadSceneFlag = true;
+
+	if ((_monsterMode == 3) && (_scene->_activeAnimation != nullptr)) {
+		if (_scene->_activeAnimation->getCurrentFrame() != _boatFrame) {
+			_boatFrame = _scene->_activeAnimation->getCurrentFrame();
+			int nextBoatFrame = -1;
+
+			if (_boatFrame == 62) {
+				nextBoatFrame = 61;
+				if (_restartTrigger70Fl) {
+					_restartTrigger70Fl = false;
+					_scene->_sequences.addTimer(15, 70);
+				}
+			}
+
+			if ((nextBoatFrame >= 0) && (nextBoatFrame != _scene->_activeAnimation->getCurrentFrame())) {
+				_scene->_activeAnimation->setCurrentFrame(nextBoatFrame);
+				_boatFrame = nextBoatFrame;
+			}
+		}
+	}
+
+	if (_game._trigger == 70)
+		_scene->_reloadSceneFlag = true;
+
+	if ((_monsterMode == 0) && (_scene->_activeAnimation != nullptr)) {
+		if (_scene->_activeAnimation->getCurrentFrame() != _boatFrame) {
+			_boatFrame = _scene->_activeAnimation->getCurrentFrame();
+			int nextBoatFrame = -1;
+
+			switch (_boatFrame) {
+			case 11:
+				if (_curSequence == 7) {
+					_curSequence = 0;
+					nextBoatFrame = 100;
+				} else if (_curSequence == 5)
+					nextBoatFrame = 82;
+				else if (_curSequence == 1)
+					nextBoatFrame = 11;
+				else {
+					nextBoatFrame = 9;
+					if (!_game._player._stepEnabled)
+						_game._player._stepEnabled = true;
+				}
+				break;
+
+			case 34:
+				if (_curSequence != 2)
+					_scene->_nextSceneId = 704;
+				break;
+
+			case 57:
+				if (_curSequence == 6) {
+					_curSequence = 0;
+					nextBoatFrame = 91;
+				} else if (_curSequence == 4)
+					nextBoatFrame = 73;
+				else if (_curSequence == 3)
+					nextBoatFrame = 57;
+				else {
+					nextBoatFrame = 56;
+					if (!_game._player._stepEnabled)
+						_game._player._stepEnabled = true;
+				}
+				break;
+
+			case 73:
+				_scene->_nextSceneId = 701;
+				break;
+
+			case 82:
+				nextBoatFrame = 11;
+				break;
+
+			case 91:
+				nextBoatFrame = 57;
+				break;
+
+			case 100:
+				nextBoatFrame = 56;
+				if (!_game._player._stepEnabled) {
+					_scene->_sequences.addTimer(30, 80);
+					_game._player._stepEnabled = true;
+				}
+				break;
+
+			case 110:
+				nextBoatFrame = 9;
+				if (!_game._player._stepEnabled) {
+					_scene->_sequences.addTimer(30, 80);
+					_game._player._stepEnabled = true;
+				}
+				break;
+
+			default:
+				break;
+			}
+
+			if ((nextBoatFrame >= 0) && (nextBoatFrame != _scene->_activeAnimation->getCurrentFrame())) {
+				_scene->_activeAnimation->setCurrentFrame(nextBoatFrame);
+				_boatFrame = nextBoatFrame;
+			}
+		}
+	}
+
+	if (_game._trigger == 80) {
+		switch (_globals[kBottleStatus]) {
+		case 0:
+			_vm->_dialogs->show(432);
+			break;
+
+		case 1:
+			_vm->_dialogs->show(70324);
+			break;
+
+		case 2:
+			_vm->_dialogs->show(70325);
+			break;
+
+		case 3:
+			_vm->_dialogs->show(70326);
+			break;
+
+		case 4:
+			_vm->_dialogs->show(70327);
+			break;
+
+		default:
+			break;
+		}
+	}
+
+
+	if ((_monsterMode == 1) && (_scene->_activeAnimation != nullptr)) {
+		if (_scene->_activeAnimation->getCurrentFrame() != _boatFrame) {
+			_boatFrame = _scene->_activeAnimation->getCurrentFrame();
+			int nextBoatFrame = -1;
+
+			switch (_boatFrame) {
+			case 39:
+				_game._player._stepEnabled = true;
+				_startMonsterTimer = true;
+				_rexDeathFl = false;
+				break;
+
+			case 40:
+			case 49:
+			case 54:
+			case 67:
+			case 78:
+			case 87:
+			case 96:
+			case 105:
+			case 114:
+			case 123:
+				if (_curSequence == 8)
+					nextBoatFrame = 129;
+
+				break;
+
+			case 129:
+				nextBoatFrame = 39;
+				break;
+
+			case 151:
+				_scene->_nextSceneId = 701;
+				break;
+
+			default:
+				break;
+			}
+
+			if ((nextBoatFrame >= 0) && (nextBoatFrame != _scene->_activeAnimation->getCurrentFrame())) {
+				_scene->_activeAnimation->setCurrentFrame(nextBoatFrame);
+				_boatFrame = nextBoatFrame;
+			}
+		}
+	}
+
+	if ((_monsterMode == 2) && (_scene->_activeAnimation != nullptr)) {
+		if (_scene->_activeAnimation->getCurrentFrame() != _boatFrame) {
+			_boatFrame = _scene->_activeAnimation->getCurrentFrame();
+			int nextBoatFrame = -1;
+
+			switch (_boatFrame) {
+			case 14:
+				if (!_useBomb) {
+					if (_game._difficulty == DIFFICULTY_HARD)
+						_game._objects.setRoom(OBJ_CHICKEN, 1);
+					else
+						_vm->_dialogs->show(70319);
+				}
+				nextBoatFrame = 80;
+				break;
+
+			case 33:
+				if (_game._objects.isInInventory(OBJ_BONES)) {
+					_game._objects.setRoom(OBJ_BONES, 1);
+					_game._objects.addToInventory(OBJ_BONE);
+				} else
+					_game._objects.setRoom(OBJ_BONE, 1);
+
+				nextBoatFrame = 80;
+				break;
+
+			case 53:
+				_game._objects.setRoom(OBJ_TWINKIFRUIT, 1);
+				nextBoatFrame = 80;
+				_curSequence = 9;
+				break;
+
+			case 80:
+				if (_game._difficulty == DIFFICULTY_HARD) {
+					_game._objects.setRoom(OBJ_BOMB, 1);
+					_vm->_dialogs->show(70318);
+				} else
+					_vm->_dialogs->show(70317);
+
+				_scene->freeAnimation();
+				_monsterMode = 1;
+				_scene->loadAnimation(formAnimName('B', -1));
+				_scene->_activeAnimation->setCurrentFrame(39);
+				_game._player._stepEnabled = true;
+				break;
+
+			case 91:
+				if (!_useBomb) {
+					_scene->freeAnimation();
+					_monsterMode = 1;
+					_scene->loadAnimation(formAnimName('B', -1));
+					_scene->_activeAnimation->setCurrentFrame(39);
+					_game._player._stepEnabled = true;
+				} else
+					_game._objects.setRoom(OBJ_CHICKEN_BOMB, 1);
+
+				break;
+
+			case 126:
+				_scene->_hotspots.activate(0x468, false);
+				_globals[kMonsterAlive] = false;
+				_scene->freeAnimation();
+				_monsterMode = 0;
+				_scene->loadAnimation(formAnimName('A', -1));
+				_scene->_activeAnimation->setCurrentFrame(9);
+				_game._player._stepEnabled = true;
+				if (_game._storyMode == STORYMODE_NAUGHTY)
+					_vm->_dialogs->show(70321);
+				else
+					_vm->_dialogs->show(70322);
+
+				break;
+
+			default:
+				break;
+			}
+
+			if ((nextBoatFrame >= 0) && (nextBoatFrame != _scene->_activeAnimation->getCurrentFrame())) {
+				_scene->_activeAnimation->setCurrentFrame(nextBoatFrame);
+				_boatFrame = nextBoatFrame;
+			}
+		}
+	}
+}
+
+void Scene703::actions() {
+	if (_game._screenObjects._inputMode == 1)
+		handleFillBottle(_action._activeAction._verbId);
+	else if (_action.isAction(0x3B1, 0x3B0)) {
+		_game._player._stepEnabled = false;
+		if (_globals[kMonsterAlive])
+			_curSequence = 8;
+		else if (_boatDir == 1)
+			_curSequence = 5;
+		else
+			_curSequence = 3;
+	} else if (_action.isAction(0x3B1, 0x3B2)) {
+		_game._player._stepEnabled = false;
+		if (_globals[kMonsterAlive]) {
+			_startMonsterTimer = false;
+			_rexDeathFl = true;
+			_monsterTime = 0;
+			_scene->freeAnimation();
+			_monsterMode = 3;
+			_scene->loadAnimation(formAnimName('D', -1));
+		} else if (_boatDir == 2)
+			_curSequence = 4;
+		else
+			_curSequence = 1;
+	} else if (_action.isAction(VERB_THROW, 0x2C, 0x468) || _action.isAction(VERB_THROW, 0x2D, 0x468)) {
+		_game._player._stepEnabled = false;
+		_scene->freeAnimation();
+		_monsterMode = 2;
+		_scene->loadAnimation(formAnimName('C', -1));
+		_scene->_activeAnimation->setCurrentFrame(19);
+	} else if (_action.isAction(VERB_THROW, 0x49, 0x468)) {
+		_game._player._stepEnabled = false;
+		_scene->freeAnimation();
+		_monsterMode = 2;
+		_scene->loadAnimation(formAnimName('C', -1));
+	} else if (_action.isAction(VERB_THROW, 0x17A, 0x468)) {
+		_game._player._stepEnabled = false;
+		_scene->freeAnimation();
+		_monsterMode = 2;
+		_scene->loadAnimation(formAnimName('C', -1));
+		_scene->_activeAnimation->setCurrentFrame(39);
+	} else if (_action.isAction(VERB_THROW, 0x2A, 0x468)) {
+		_game._player._stepEnabled = false;
+		_scene->freeAnimation();
+		_monsterMode = 2;
+		_scene->loadAnimation(formAnimName('C', -1));
+		_scene->_activeAnimation->setCurrentFrame(59);
+	} else if (_action.isAction(VERB_THROW, 0x4A, 0x468)) {
+		_useBomb = true;
+		_game._player._stepEnabled = false;
+		_scene->freeAnimation();
+		_monsterMode = 2;
+		_scene->loadAnimation(formAnimName('C', -1));
+	} else if (_action.isAction(VERB_PUT, 0x2E, 0x18F) || _action.isAction(0x85, 0x2E, 0x18F)) {
+		if (_globals[kBottleStatus] != 4) {
+			handleBottleInterface();
+			_dialog1.start();
+		} else
+			_vm->_dialogs->show(70323);
+	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x468)) {
+		if (_globals[kMonsterAlive])
+			_vm->_dialogs->show(70310);
+	} else if (_action.isAction(VERB_LOOK, 0x18F)) {
+		if (!_globals[kMonsterAlive])
+			_vm->_dialogs->show(70311);
+		else
+			_vm->_dialogs->show(70312);
+	} else if (_action.isAction(VERB_LOOK, 0x3B2)) {
+		if (_globals[kMonsterAlive])
+			_vm->_dialogs->show(70313);
+		else if (_game._visitedScenes.exists(710))
+			_vm->_dialogs->show(70314);
+		else
+			_vm->_dialogs->show(70315);
+	} else if (_action.isAction(VERB_LOOK, 0x3B3))
+		_vm->_dialogs->show(70316);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene707::setup() {
 	_game._player._spritesPrefix = "";
 	// The original calls Scene7xx::setAAName()
@@ -588,14 +1114,14 @@ void Scene752::enter() {
 
 	if (_game._objects[OBJ_ID_CARD]._roomNumber == 752) {
 		_globals._spriteIndexes[13] = _scene->_sprites.addSprites(formAnimName('i', -1));
-		_globals._sequenceIndexes[13] =  _scene->_sequences.startCycle(_globals._spriteIndexes[13], false, 1);
+		_globals._sequenceIndexes[13] = _scene->_sequences.startCycle(_globals._spriteIndexes[13], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
 		int idx = _scene->_dynamicHotspots.add(0xB3, VERB_WALKTO, _globals._sequenceIndexes[13], Common::Rect(0, 0, 0, 0));
 		_cardId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(234, 135), FACING_NORTH);
 	}
 
 	if (_game._globals[kLaserHoleIsThere]) {
-		_globals._sequenceIndexes[14] =  _scene->_sequences.startCycle(_globals._spriteIndexes[14], false, 1);
+		_globals._sequenceIndexes[14] = _scene->_sequences.startCycle(_globals._spriteIndexes[14], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[14], 13);
 		int idx = _scene->_dynamicHotspots.add(NOUN_LASER_BEAM, VERB_LOOK_AT, _globals._sequenceIndexes[14], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(215, 130), FACING_NORTHWEST);
@@ -681,7 +1207,7 @@ void Scene752::actions() {
 		case 1:
 			_vm->_sound->command(0xF);
 			if (_game._objects.isInInventory(OBJ_BONE))
-				_game._objects.setRoom(OBJ_BONE, NOWHERE);
+				_game._objects.setRoom(OBJ_BONE, 1);
 			_game._objects.addToInventory(OBJ_BONES);
 			_vm->_dialogs->show(OBJ_BONES, 75221);
 			break;
diff --git a/engines/mads/nebular/nebular_scenes7.h b/engines/mads/nebular/nebular_scenes7.h
index c878149..049cc54 100644
--- a/engines/mads/nebular/nebular_scenes7.h
+++ b/engines/mads/nebular/nebular_scenes7.h
@@ -74,6 +74,38 @@ public:
 	virtual void actions();
 };
 
+class Scene703: public Scene7xx{
+private:
+	int _monsterMode;
+	int _boatFrame;
+	int _curSequence;
+	int _boatDir;
+
+	bool _useBomb;
+	bool _startMonsterTimer;
+	bool _rexDeathFl;
+	bool _restartTrigger70Fl;
+
+	uint32 _lastFrameTime;
+	uint32 _monsterTime;
+
+	Conversation _dialog1;
+
+	void handleBottleInterface();
+	void setBottleSequence();
+	void handleFillBottle(int quote);
+
+public:
+	Scene703(MADSEngine *vm) : Scene7xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 class Scene707: public SceneTeleporter {
 public:
 	Scene707(MADSEngine *vm) : SceneTeleporter(vm) {}


Commit: 84b38d8b390745da15bb0b9526209b60492df723
    https://github.com/scummvm/scummvm/commit/84b38d8b390745da15bb0b9526209b60492df723
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-15T19:53:12-04:00

Commit Message:
MADS: Fix incorrect array indexes referencing outputIndexes

Changed paths:
    engines/mads/nebular/sound_nebular.cpp



diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp
index 8b1a02e..a2a66a3 100644
--- a/engines/mads/nebular/sound_nebular.cpp
+++ b/engines/mads/nebular/sound_nebular.cpp
@@ -686,7 +686,7 @@ void ASound::updateChannelState() {
 }
 
 static const int outputIndexes[] = {
-	3, 1, 4, 2, 5, 6, 9, 7, 10, 8, 11, 12, 15, 13, 16, 14, 17
+	0, 3, 1, 4, 2, 5, 6, 9, 7, 10, 8, 11, 12, 15, 13, 16, 14, 17
 };
 static const int outputChannels[] = {
 	0, 1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 13, 16, 17, 18, 19, 20, 21, 0
@@ -704,7 +704,7 @@ static const int volumeList[] = {
 };
 
 void ASound::updateActiveChannel() {
-	int reg = 0x40 + outputChannels[outputIndexes[_activeChannelNumber * 2]];
+	int reg = 0x40 + outputChannels[outputIndexes[_activeChannelNumber * 2 + 1]];
 	int portVal = _ports[reg] & 0xFFC0;
 	int newVolume = CLIP(_activeChannelPtr->_volume + _activeChannelPtr->_field1E, 0, 63);
 
@@ -725,7 +725,7 @@ void ASound::loadSample(int sampleIndex) {
 
 	_activeChannelReg = _activeChannelNumber;
 	_samplePtr = &_samples[sampleIndex * 2];
-	_v11 = outputChannels[outputIndexes[_activeChannelReg * 2 - 1]];
+	_v11 = outputChannels[outputIndexes[_activeChannelReg * 2]];
 	processSample();
 
 	AdlibChannelData &cd = _channelData[_activeChannelNumber];
@@ -735,7 +735,7 @@ void ASound::loadSample(int sampleIndex) {
 	cd._field0 = _samplePtr->_fieldE;
 
 	_samplePtr = &_samples[sampleIndex * 2 + 1];
-	_v11 = outputChannels[outputIndexes[_activeChannelReg * 2]];
+	_v11 = outputChannels[outputIndexes[_activeChannelReg * 2 + 1]];
 	processSample();
 }
 


Commit: d7086fc3a5a93c2162511ac25a4f3c46f8b041a4
    https://github.com/scummvm/scummvm/commit/d7086fc3a5a93c2162511ac25a4f3c46f8b041a4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-15T19:54:51-04:00

Commit Message:
MADS: Implemented sound player for scene group 5

Changed paths:
    engines/mads/nebular/sound_nebular.cpp
    engines/mads/nebular/sound_nebular.h
    engines/mads/sound.cpp



diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp
index a2a66a3..13696d8 100644
--- a/engines/mads/nebular/sound_nebular.cpp
+++ b/engines/mads/nebular/sound_nebular.cpp
@@ -2244,6 +2244,251 @@ void ASound4::method1() {
 	}
 }
 
+
+/*-----------------------------------------------------------------------*/
+
+const ASound5::CommandPtr ASound5::_commandList[42] = {
+	&ASound5::command0, &ASound5::command1, &ASound5::command2, &ASound5::command3,
+	&ASound5::command4, &ASound5::command5, &ASound5::command6, &ASound5::command7,
+	&ASound5::command8, &ASound5::command9, &ASound5::command10, &ASound5::command11,
+	&ASound5::command11, &ASound5::command13, &ASound5::command14, &ASound5::command15,
+	&ASound5::command16, &ASound5::command17, &ASound5::command18, &ASound5::command19,
+	&ASound5::command20, &ASound5::command21, &ASound5::command22, &ASound5::command23,
+	&ASound5::command11, &ASound5::command11, &ASound5::command26, &ASound5::command27,
+	&ASound5::command28, &ASound5::command29, &ASound5::command30, &ASound5::command31,
+	&ASound5::command32, &ASound5::command33, &ASound5::command34, &ASound5::command35,
+	&ASound5::command36, &ASound5::command37, &ASound5::command38, &ASound5::command39,
+	&ASound5::command40, &ASound5::command41
+};
+
+ASound5::ASound5(Audio::Mixer *mixer) : ASound(mixer, "asound.002", 0x15E0) {
+	// Load sound samples
+	_soundFile.seek(_dataOffset + 0x144);
+	for (int i = 0; i < 164; ++i)
+		_samples.push_back(AdlibSample(_soundFile));
+}
+
+int ASound5::command(int commandId, int param) {
+	if (commandId > 41)
+		return 0;
+
+	_frameCounter = 0;
+	return (this->*_commandList[commandId])();
+}
+
+int ASound5::command9() {
+	byte *pData = loadData(0x2114, 10);
+	pData[6] = (getRandomNumber() & 7) + 85;
+	playSoundData(pData);
+
+	return 0;
+}
+
+int ASound5::command10() {
+	playSound(0x211E, 10);
+
+	return 0;
+}
+
+int ASound5::command11() {
+	playSound(0x2016, 10);
+
+	return 0;
+}
+
+int ASound5::command13() {
+	playSound(0x2154, 10);
+
+	return 0;
+}
+
+int ASound5::command14() {
+	playSound(0x21DC, 22);
+
+	return 0;
+}
+
+int ASound5::command15() {
+	byte *pData = loadData(0x21DC, 22);
+	if (_channels[0]._ptr1 == pData) {
+		pData = loadData(0x1F2, 12);
+		_channels[0]._soundData = pData;
+		_channels[0]._field17 = 1;
+		_channels[0]._field19 = 1;
+	}
+
+	return 0;
+}
+
+int ASound5::command16() {
+	playSound(0x214C, 8);
+
+	return 0;
+}
+
+int ASound5::command17() {
+	playSound(0x2142, 10);
+
+	return 0;
+}
+
+int ASound5::command18() {
+	playSound(0x21A2, 22);
+
+	return 0;
+}
+
+int ASound5::command19() {
+	playSound(0x2190, 18);
+
+	return 0;
+}
+
+int ASound5::command20() {
+	playSound(0x2170, 16);
+
+	return 0;
+}
+
+int ASound5::command21() {
+	playSound(0x2180, 16);
+
+	return 0;
+}
+
+int ASound5::command22() {
+	playSound(0x2168, 8);
+
+	return 0;
+}
+
+int ASound5::command23() {
+	playSound(0x215E, 10);
+
+	return 0;
+}
+
+int ASound5::command26() {
+	playSound(0x21B8, 12);
+
+	return 0;
+}
+
+int ASound5::command27() {
+	playSound(0x21C4, 24);
+
+	return 0;
+}
+
+int ASound5::command28() {
+	playSound(0x2020, 34);
+	playSound(0x4904, 20);
+
+	return 0;
+}
+
+int ASound5::command29() {
+	byte *pData = loadData(0x17C, 312);
+	if (!isSoundActive(pData)) {
+		command1();
+		_channels[0].load(pData);
+		_channels[1].load(loadData(0x1864, 304));
+		_channels[2].load(loadData(0x1994, 222));
+		_channels[3].load(loadData(0x1864, 304));
+		_channels[4].load(loadData(0x1994, 222));
+	}
+
+	return 0;
+}
+
+int ASound5::command30() {
+	playSound(0x2092, 22);
+	playSound(0x20A8, 22);
+	playSound(0x20BE, 22);
+
+	return 0;
+}
+
+int ASound5::command31() {
+	playSound(0x2128, 22);
+	playSound(0x2134, 14);
+
+	return 0;
+}
+
+int ASound5::command32() {
+	playSound(0x210A, 10);
+
+	return 0;
+}
+
+int ASound5::command33() {
+	playSound(0x20FA, 16);
+
+	return 0;
+}
+
+int ASound5::command34() {
+	playSound(0x20EA, 16);
+
+	return 0;
+}
+
+int ASound5::command35() {
+	playSound(0x20D4, 22);
+
+	return 0;
+}
+
+int ASound5::command36() {
+	playSound(0x2006, 16);
+
+	return 0;
+}
+
+int ASound5::command37() {
+	playSound(0x2056, 20);
+	playSound(0x206A, 30);
+	playSound(0x2088, 10);
+
+	return 0;
+}
+
+int ASound5::command38() {
+	byte *pData1 = loadData(0x14F2, 570);
+	if (_channels[3]._ptr1 == pData1) {
+		_channels[3].load(loadData(0x1A72, 522));
+		_channels[3].load(loadData(0x1C7C, 874));
+	}
+
+	return 0;
+}
+
+int ASound5::command39() {
+	playSound(0x1FEE, 8);
+
+	return 0;
+}
+
+int ASound5::command40() {
+	playSound(0x1FF6, 16);
+
+	return 0;
+}
+
+int ASound5::command41() {
+	byte *pData1 = loadData(0x14F2, 570);
+	if (!isSoundActive(pData1)) {
+		byte *pData2 = loadData(0x1A72, 522);
+		if (_channels[3]._ptr1 == pData2) {
+			_channels[3].load(pData1);
+			_channels[4].load(loadData(0x1FE6, 8));
+		}
+	}
+
+	return 0;
+}
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/sound_nebular.h b/engines/mads/nebular/sound_nebular.h
index 68c9fdf..db6ca97 100644
--- a/engines/mads/nebular/sound_nebular.h
+++ b/engines/mads/nebular/sound_nebular.h
@@ -563,6 +563,52 @@ public:
 	virtual int command(int commandId, int param);
 };
 
+class ASound5 : public ASound {
+private:
+	typedef int (ASound5::*CommandPtr)();
+	static const CommandPtr _commandList[42];
+
+	int command9();
+	int command10();
+	int command11();
+	int command12();
+	int command13();
+	int command14();
+	int command15();
+	int command16();
+	int command17();
+	int command18();
+	int command19();
+	int command20();
+	int command21();
+	int command22();
+	int command23();
+	int command24();
+	int command25();
+	int command26();
+	int command27();
+	int command28();
+	int command29();
+	int command30();
+	int command31();
+	int command32();
+	int command33();
+	int command34();
+	int command35();
+	int command36();
+	int command37();
+	int command38();
+	int command39();
+	int command40();
+	int command41();
+	int command42();
+	int command43();
+public:
+	ASound5(Audio::Mixer *mixer);
+
+	virtual int command(int commandId, int param);
+};
+
 
 } // End of namespace Nebular
 
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index adab5f7..deaaba1 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -61,6 +61,9 @@ void SoundManager::init(int sectionNumber) {
 		case 4:
 			_driver = new Nebular::ASound4(_mixer);
 			break;
+		case 5:
+			_driver = new Nebular::ASound5(_mixer);
+			break;
 		default:
 			_driver = nullptr;
 			break;


Commit: 80bac656ab0173c4f644a7ff961e8611a31e8430
    https://github.com/scummvm/scummvm/commit/80bac656ab0173c4f644a7ff961e8611a31e8430
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-16T03:41:12+03:00

Commit Message:
MADS: Add some nouns for the teleporter

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index fb7bb05..3d26a41 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -561,9 +561,9 @@ void SceneTeleporter::teleporterEnter() {
 
 bool SceneTeleporter::teleporterActions() {
 	bool retVal = false;
-	static int _buttonList[12] = { 0x1D0, 0x1D1, 0x1D2, 0x1D3, 0x1D4, 0x1D5, 0x1D6, 0x1D7, 0x1D8, 0x1D9, 0x1DB, 0x1DA };
+	static int _buttonList[12] = { NOUN_0_KEY, NOUN_1_KEY, NOUN_2_KEY, NOUN_3_KEY, NOUN_4_KEY, NOUN_5_KEY, NOUN_6_KEY, NOUN_7_KEY, NOUN_8_KEY, NOUN_9_KEY, NOUN_SMILE_KEY, NOUN_FROWN_KEY };
 
-	if (_action.isAction(0x11A) || _action.isAction(VERB_PUSH)) {
+	if (_action.isAction(VERB_PRESS) || _action.isAction(VERB_PUSH)) {
 		for (int i = 0; i < 12; i++) {
 			if (_action._activeAction._objectNameId == _buttonList[i])
 				_buttonTyped = i;
@@ -572,7 +572,7 @@ bool SceneTeleporter::teleporterActions() {
 		retVal = true;
 	}
 
-	if (_action.isAction(0x1CE, 0x1CF)) {
+	if (_action.isAction(VERB_EXIT_FROM, NOUN_DEVICE)) {
 		_globals[kTeleporterCommand] = 3;
 		_scene->_nextSceneId = _teleporterSceneId;
 		retVal = true;
@@ -595,7 +595,7 @@ void SceneTeleporter::teleporterStep() {
 		} else {
 			digit   = 10;
 		}
-		_buttonTyped              = digit;
+		_buttonTyped = digit;
 		_meteorologistCurPlace = place + 1;
 		_game._trigger = -1;
 	}
diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index d02f6cb..dc35b11 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -52,6 +52,7 @@ enum Verb {
 	VERB_LOOK_IN		= 0x0D2,
 	VERB_LOOK_THROUGH	= 0x0D3,
 	VERB_PEER_THROUGH	= 0x103,
+	VERB_PRESS          = 0x11A,
 	VERB_READ			= 0x11F,
 	VERB_SHOOT          = 0x13A,
 	VERB_SIT_IN         = 0x13F,
@@ -59,6 +60,7 @@ enum Verb {
 	VERB_WALK_THROUGH   = 0x18B,
 	VERB_WALK_TOWARDS   = 0x18C,
 	VERB_WALK_DOWN      = 0x1AD,
+	VERB_EXIT_FROM      = 0x1CE,
 	VERB_CLIMB_INTO     = 0x2F7,
 	VERB_STEP_INTO      = 0x2F9,
 	VERB_WALK_ALONG     = 0x312,
@@ -76,8 +78,10 @@ enum Noun {
 	NOUN_CHAIR          = 0x47,
 	NOUN_CHICKEN        = 0x49,
 	NOUN_CHICKEN_BOMB   = 0x4A,
+	NOUN_CONTROL_PANEL  = 0x59,
 	NOUN_DEAD_FISH		= 0x65,
 	NOUN_DOOR			= 0x6E,
+	NOUN_ENTER_KEY      = 0x7A,
 	NOUN_FISHING_LINE	= 0x87,
 	NOUN_FRONT_WINDOW	= 0x8E,
 	NOUN_FUZZY_DICE		= 0x91,
@@ -85,6 +89,7 @@ enum Noun {
 	NOUN_HULL			= 0x0A8,
 	NOUN_ID_CARD        = 0x0B3,
 	NOUN_JUNGLE			= 0x0B8,
+	NOUN_KEYPAD         = 0x0C4,
 	NOUN_LADDER         = 0x0C7,
 	NOUN_LIFE_SUPPORT_SECTION  = 0x0CC,
 	NOUN_LOG			= 0x0D0,
@@ -106,12 +111,27 @@ enum Noun {
 	NOUN_TIMEBOMB       = 0x171,
 	NOUN_TWINKIFRUIT    = 0x17A,
 	NOUN_VIEW_SCREEN    = 0x180,
+	NOUN_VIEWPORT       = 0x181,
 	NOUN_DEEP_PIT       = 0x19E,
 	NOUN_HUGE_LEGS      = 0x1A8,
 	NOUN_LEAF_COVERED_PIT  = 0x1A9,
 	NOUN_PILE_OF_LEAVES = 0x1AA,
 	NOUN_STRANGE_DEVICE = 0x1B6,
 	NOUN_CAPTIVE_CREATURE = 0x1C3,
+	NOUN_DISPLAY        = 0x1CC,
+	NOUN_DEVICE         = 0x1CF,
+	NOUN_0_KEY          = 0x1D0,
+	NOUN_1_KEY          = 0x1D1,
+	NOUN_2_KEY          = 0x1D2,
+	NOUN_3_KEY          = 0x1D3,
+	NOUN_4_KEY          = 0x1D4,
+	NOUN_5_KEY          = 0x1D5,
+	NOUN_6_KEY          = 0x1D6,
+	NOUN_7_KEY          = 0x1D7,
+	NOUN_8_KEY          = 0x1D8,
+	NOUN_9_KEY          = 0x1D9,
+	NOUN_FROWN_KEY      = 0x1DA,
+	NOUN_SMILE_KEY      = 0x1DB,
 	NOUN_NATIVE_WOMAN	= 0x1DC,
 	NOUN_PLATFORM       = 0x22C,
 	NOUN_ALCOHOL        = 0x310,
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index b38aace..256bdad 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -4861,7 +4861,7 @@ void Scene213::setup() {
 }
 
 void Scene213::enter() {
-	if (_globals[kMeteorologistWatch] != METEOROLOGIST_ABSENT)
+	if (_globals[kMeteorologistWatch] != METEOROLOGIST_NORMAL)
 		_handSpriteId = _scene->_sprites.addSprites("*METHAND");
 	else if (_globals[kSexOfRex] == REX_MALE)
 		_handSpriteId = _scene->_sprites.addSprites("*REXHAND");
@@ -4872,7 +4872,7 @@ void Scene213::enter() {
 
 	// The original is calling Scene2xx::sceneEntrySound()
 		if (_vm->_musicFlag) {
-			if (_globals[kMeteorologistWatch] == METEOROLOGIST_ABSENT)
+			if (_globals[kMeteorologistWatch] == METEOROLOGIST_NORMAL)
 				_vm->_sound->command(1);
 			else
 				_vm->_sound->command(9);
@@ -4890,23 +4890,23 @@ void Scene213::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x59))
+	if (_action.isAction(VERB_LOOK, NOUN_CONTROL_PANEL))
 		_vm->_dialogs->show(21301);
-	else if (_action.isAction(VERB_LOOK, 0xC4) || _action.isAction (0xB7, 0xC4))
+	else if (_action.isAction(VERB_LOOK, NOUN_KEYPAD) || _action.isAction (VERB_INSPECT, NOUN_KEYPAD))
 		_vm->_dialogs->show(21302);
-	else if (_action.isAction(VERB_LOOK, 0x1CC))
+	else if (_action.isAction(VERB_LOOK, NOUN_DISPLAY))
 		_vm->_dialogs->show(21303);
-	else if (_action.isAction(VERB_LOOK, 0x181) || _action.isAction(0x103, 0x181))
+	else if (_action.isAction(VERB_LOOK, NOUN_VIEWPORT) || _action.isAction(VERB_PEER_THROUGH, NOUN_VIEWPORT))
 		_vm->_dialogs->show(21304);
-	else if (_action.isAction(VERB_LOOK, 0x1CF))
+	else if (_action.isAction(VERB_LOOK, NOUN_DEVICE))
 		_vm->_dialogs->show(21305);
-	else if (_action.isAction(VERB_LOOK, 0x1D0) || _action.isAction(VERB_LOOK, 0x1D1)
-	 || _action.isAction(VERB_LOOK, 0x1D2) || _action.isAction(VERB_LOOK, 0x1D3)
-	 || _action.isAction(VERB_LOOK, 0x1D4) || _action.isAction(VERB_LOOK, 0x1D5)
-	 || _action.isAction(VERB_LOOK, 0x1D6) || _action.isAction(VERB_LOOK, 0x1D7)
-	 || _action.isAction(VERB_LOOK, 0x1D8) || _action.isAction(VERB_LOOK, 0x1D9)
-	 || _action.isAction(VERB_LOOK, 0x1DB) || _action.isAction(VERB_LOOK, 0x7A)
-	 || _action.isAction(VERB_LOOK, 0x1DA))
+	else if (_action.isAction(VERB_LOOK, NOUN_0_KEY) || _action.isAction(VERB_LOOK, NOUN_1_KEY)
+	      || _action.isAction(VERB_LOOK, NOUN_2_KEY) || _action.isAction(VERB_LOOK, NOUN_3_KEY)
+	      || _action.isAction(VERB_LOOK, NOUN_4_KEY) || _action.isAction(VERB_LOOK, NOUN_5_KEY)
+	      || _action.isAction(VERB_LOOK, NOUN_6_KEY) || _action.isAction(VERB_LOOK, NOUN_7_KEY)
+	      || _action.isAction(VERB_LOOK, NOUN_8_KEY) || _action.isAction(VERB_LOOK, NOUN_9_KEY)
+	      || _action.isAction(VERB_LOOK, NOUN_SMILE_KEY) || _action.isAction(VERB_LOOK, NOUN_FROWN_KEY)
+	      || _action.isAction(VERB_LOOK, NOUN_ENTER_KEY))
 		_vm->_dialogs->show(21306);
 	else
 		return;


Commit: 655233bdfbb7412aa2070d3d9bd76b28e395c38e
    https://github.com/scummvm/scummvm/commit/655233bdfbb7412aa2070d3d9bd76b28e395c38e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-16T03:41:12+03:00

Commit Message:
MADS: Fix bug when watching the meteorologist through the binoculars

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 3d26a41..8053818 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -582,7 +582,10 @@ bool SceneTeleporter::teleporterActions() {
 }
 
 void SceneTeleporter::teleporterStep() {
-	if ((_globals[kMeteorologistWatch] != METEOROLOGIST_NORMAL) && (_game._trigger >= 230)) {
+	if (_globals[kMeteorologistWatch] == METEOROLOGIST_NORMAL)
+		return;
+
+	if (_game._trigger >= 230) {
 		int place = _game._trigger - 230;
 		int digit;
 


Commit: 7028bc3b712ae5b198dd6d495cf2c90dd49eae43
    https://github.com/scummvm/scummvm/commit/7028bc3b712ae5b198dd6d495cf2c90dd49eae43
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-15T21:06:26-04:00

Commit Message:
MADS: Implement sound player for scene group 6

Changed paths:
    engines/mads/nebular/sound_nebular.cpp
    engines/mads/nebular/sound_nebular.h
    engines/mads/sound.cpp



diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp
index 13696d8..b839cad 100644
--- a/engines/mads/nebular/sound_nebular.cpp
+++ b/engines/mads/nebular/sound_nebular.cpp
@@ -2489,6 +2489,160 @@ int ASound5::command41() {
 	return 0;
 }
 
+/*-----------------------------------------------------------------------*/
+
+const ASound6::CommandPtr ASound6::_commandList[30] = {
+	&ASound6::command0, &ASound6::command1, &ASound6::command2, &ASound6::command3,
+	&ASound6::command4, &ASound6::command5, &ASound6::command6, &ASound6::command7,
+	&ASound6::command8, &ASound6::command9, &ASound6::command10, &ASound6::command11,
+	&ASound6::command11, &ASound6::command13, &ASound6::command14, &ASound6::command15,
+	&ASound6::command16, &ASound6::command17, &ASound6::command18, &ASound6::command19,
+	&ASound6::command20, &ASound6::command21, &ASound6::command22, &ASound6::command23,
+	&ASound6::command11, &ASound6::command11, &ASound6::nullCommand, &ASound6::nullCommand,
+	&ASound6::nullCommand, &ASound6::command29
+};
+
+ASound6::ASound6(Audio::Mixer *mixer) : ASound(mixer, "asound.006", 0x1390) {
+	// Load sound samples
+	_soundFile.seek(_dataOffset + 0x122);
+	for (int i = 0; i < 200; ++i)
+		_samples.push_back(AdlibSample(_soundFile));
+}
+
+int ASound6::command(int commandId, int param) {
+	if (commandId > 29)
+		return 0;
+
+	_frameCounter = 0;
+	return (this->*_commandList[commandId])();
+}
+
+int ASound6::command9() {
+	byte *pData = loadData(0x2194, 10);
+	pData[6] = (getRandomNumber() & 7) + 85;
+	playSoundData(pData);
+
+	return 0;
+}
+
+int ASound6::command10() {
+	playSound(0x2224, 24);
+
+	return 0;
+}
+
+int ASound6::command11() {
+	playSound(0x2202, 34);
+
+	return 0;
+}
+
+int ASound6::command12() {
+	playSound(0x2246, 8);
+
+	return 0;
+}
+
+int ASound6::command13() {
+	playSound(0x2298, 28);
+
+	return 0;
+}
+
+int ASound6::command14() {
+	playSound(0x22B4, 27);
+
+	return 0;
+}
+
+int ASound6::command15() {
+	playSound(0x219E, 12);
+
+	return 0;
+}
+
+int ASound6::command16() {
+	playSound(0x21AA, 22);
+	playSound(0x21C0, 12);
+
+	return 0;
+}
+
+int ASound6::command17() {
+	playSound(0x21CC, 54);
+
+	return 0;
+}
+
+int ASound6::command18() {
+	playSound(0x2270, 16);
+
+	return 0;
+}
+
+int ASound6::command19() {
+	playSound(0x2280, 16);
+
+	return 0;
+}
+
+int ASound6::command20() {
+	playSound(0x223C, 10);
+
+	return 0;
+}
+
+int ASound6::command21() {
+	playSound(0x224E, 34);
+
+	return 0;
+}
+
+int ASound6::command22() {
+	playSound(0x2290, 8);
+
+	return 0;
+}
+
+int ASound6::command23() {
+	playSound(0x215E, 34);
+	playSound(0x2180, 20);
+
+	return 0;
+}
+
+int ASound6::command24() {
+	byte *pData1 = loadData(0x1D54, 540);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[0].load(pData1);
+		_channels[1].load(loadData(0x1F70, 52));
+		_channels[2].load(loadData(0x1FA4, 430));
+	}
+
+	return 0;
+}
+
+int ASound6::command25() {
+	playSound(0x2152, 12);
+
+	return 0;
+}
+
+int ASound6::command29() {
+	byte *pData1 = loadData(0x149A, 312);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[0].load(pData1);
+		_channels[1].load(loadData(0x15D2, 304));
+		_channels[2].load(loadData(0x1702, 222));
+		_channels[3].load(loadData(0x17E0, 522));
+		_channels[4].load(loadData(0x19EA, 874));
+	}
+
+	return 0;
+}
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/sound_nebular.h b/engines/mads/nebular/sound_nebular.h
index db6ca97..771aac4 100644
--- a/engines/mads/nebular/sound_nebular.h
+++ b/engines/mads/nebular/sound_nebular.h
@@ -261,6 +261,8 @@ protected:
 	int command6();
 	int command7();
 	int command8();
+
+	int nullCommand() { return 0; }
 public:
 	Audio::Mixer *_mixer;
 	FM_OPL *_opl;
@@ -514,7 +516,6 @@ private:
 	int command57();
 	int command59();
 	int command60();
-	int nullCommand() { return 0; }
 
 	void command9Randomize();
 	void command9Apply(byte *data, int val, int incr);
@@ -554,7 +555,6 @@ private:
 	int command58();
 	int command59();
 	int command60();
-	int nullCommand() { return 0; }
 
 	void method1();
 public:
@@ -609,6 +609,34 @@ public:
 	virtual int command(int commandId, int param);
 };
 
+class ASound6 : public ASound {
+private:
+	typedef int (ASound6::*CommandPtr)();
+	static const CommandPtr _commandList[30];
+
+	int command9();
+	int command10();
+	int command11();
+	int command12();
+	int command13();
+	int command14();
+	int command15();
+	int command16();
+	int command17();
+	int command18();
+	int command19();
+	int command20();
+	int command21();
+	int command22();
+	int command23();
+	int command24();
+	int command25();
+	int command29();
+public:
+	ASound6(Audio::Mixer *mixer);
+
+	virtual int command(int commandId, int param);
+};
 
 } // End of namespace Nebular
 
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index deaaba1..79a2b4e 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -64,6 +64,9 @@ void SoundManager::init(int sectionNumber) {
 		case 5:
 			_driver = new Nebular::ASound5(_mixer);
 			break;
+		case 6:
+			_driver = new Nebular::ASound6(_mixer);
+			break;
 		default:
 			_driver = nullptr;
 			break;


Commit: 82064df60a730f792e978db7c29e7280d1604cff
    https://github.com/scummvm/scummvm/commit/82064df60a730f792e978db7c29e7280d1604cff
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-16T05:04:25+03:00

Commit Message:
MADS: Bugfix for sequence triggers

Fixes a lot of broken sequences

Changed paths:
    engines/mads/sequence.h



diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index bb084cc..b23f595 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -46,7 +46,7 @@ struct SequenceSubEntries {
 	int _count;
 	SequenceTrigger _mode[SEQUENCE_ENTRY_SUBSET_MAX];
 	int _frameIndex[SEQUENCE_ENTRY_SUBSET_MAX];
-	int8 _trigger[SEQUENCE_ENTRY_SUBSET_MAX];
+	int _trigger[SEQUENCE_ENTRY_SUBSET_MAX];
 };
 
 struct SequenceEntry {


Commit: 41c93dc0b5861df729b7da7ea41225e51811a0a5
    https://github.com/scummvm/scummvm/commit/41c93dc0b5861df729b7da7ea41225e51811a0a5
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-16T05:04:25+03:00

Commit Message:
MADS: Check if a rect is sane before attempting to create it

Changed paths:
    engines/mads/screen.cpp



diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 09f87f3..6a70bfb 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -206,6 +206,10 @@ void DirtyAreas::copy(MSurface *srcSurface, MSurface *destSurface, const Common:
 	for (uint i = 0; i < size(); ++i) {
 		const Common::Rect &srcBounds = (*this)[i]._bounds;
 
+		// Check if this is a sane rectangle before attempting to create it
+		if (srcBounds.left >= srcBounds.right || srcBounds.top >= srcBounds.bottom)
+			continue;
+
 		Common::Rect bounds(srcBounds.left + posAdjust.x, srcBounds.top + posAdjust.y,
 			srcBounds.right + posAdjust.x, srcBounds.bottom + posAdjust.y);
 
@@ -219,6 +223,10 @@ void DirtyAreas::copyToScreen(const Common::Point &posAdjust) {
 	for (uint i = 0; i < size(); ++i) {
 		const Common::Rect &srcBounds = (*this)[i]._bounds;
 
+		// Check if this is a sane rectangle before attempting to create it
+		if (srcBounds.left >= srcBounds.right || srcBounds.top >= srcBounds.bottom)
+			continue;
+		
 		Common::Rect bounds(srcBounds.left + posAdjust.x, srcBounds.top + posAdjust.y,
 			srcBounds.right + posAdjust.x, srcBounds.bottom + posAdjust.y);
 


Commit: e776a76241b9c0ba46c268cccf1b04610f86a715
    https://github.com/scummvm/scummvm/commit/e776a76241b9c0ba46c268cccf1b04610f86a715
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-15T22:13:02-04:00

Commit Message:
MADS: Implemented sound player for scene group 7

Changed paths:
    engines/mads/nebular/sound_nebular.cpp
    engines/mads/nebular/sound_nebular.h
    engines/mads/sound.cpp



diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp
index b839cad..997ea18 100644
--- a/engines/mads/nebular/sound_nebular.cpp
+++ b/engines/mads/nebular/sound_nebular.cpp
@@ -2643,6 +2643,212 @@ int ASound6::command29() {
 	return 0;
 }
 
+/*-----------------------------------------------------------------------*/
+
+const ASound7::CommandPtr ASound7::_commandList[38] = {
+	&ASound7::command0, &ASound7::command1, &ASound7::command2, &ASound7::command3,
+	&ASound7::command4, &ASound7::command5, &ASound7::command6, &ASound7::command7,
+	&ASound7::command8, &ASound7::command9, &ASound7::nullCommand, &ASound7::nullCommand,
+	&ASound7::nullCommand, &ASound7::nullCommand, &ASound7::nullCommand, &ASound7::command15,
+	&ASound7::command16, &ASound7::command16, &ASound7::command18, &ASound7::command19,
+	&ASound7::command20, &ASound7::command21, &ASound7::command22, &ASound7::command23,
+	&ASound7::command24, &ASound7::command25, &ASound7::command26, &ASound7::command27, 
+	&ASound7::command28, &ASound7::nullCommand, &ASound7::command30, &ASound7::nullCommand,
+	&ASound7::command32, &ASound7::command33, &ASound7::command34, &ASound7::command35,
+	&ASound7::command36, &ASound7::command37
+};
+
+ASound7::ASound7(Audio::Mixer *mixer) : ASound(mixer, "asound.007", 0x1460) {
+	// Load sound samples
+	_soundFile.seek(_dataOffset + 0x122);
+	for (int i = 0; i < 214; ++i)
+		_samples.push_back(AdlibSample(_soundFile));
+}
+
+int ASound7::command(int commandId, int param) {
+	if (commandId > 38)
+		return 0;
+
+	_frameCounter = 0;
+	return (this->*_commandList[commandId])();
+}
+
+int ASound7::command9() {
+	byte *pData1 = loadData(0x2992, 122);
+	if (!isSoundActive(pData1)) {
+		_channels[0].load(pData1);
+		_channels[1].load(loadData(0x2A0C, 76));
+		_channels[2].load(loadData(0x2A58, 122));
+		_channels[3].load(loadData(0x2AD2, 38));
+	}
+
+	return 0;
+}
+
+int ASound7::command15() {
+	byte *pData = loadData(0x2B3E, 10);
+	pData[6] = (getRandomNumber() & 7) + 85;
+
+	return 0;
+}
+
+int ASound7::command16() {
+	playSound(0x2CE2, 8);
+
+	return 0;
+}
+
+int ASound7::command18() {
+	playSound(0x2C94, 22);
+
+	return 0;
+}
+
+int ASound7::command19() {
+	byte *pData1 = loadData(0x2C94, 22);
+	byte *pData2 = loadData(0x2CAA, 16);
+	if (_channels[8]._ptr1 == pData1 || _channels[8]._ptr1 == pData2) {
+		_channels[8]._soundData = loadData(0x2CBA, 12);
+		_channels[8]._field17 = 1;
+		_channels[8]._field19 = 1;
+	}
+
+	return 0;
+}
+
+int ASound7::command20() {
+	playSound(0x2CD0, 18);
+
+	return 0;
+}
+
+int ASound7::command21() {
+	playSound(0x2CC6, 10);
+
+	return 0;
+}
+
+int ASound7::command22() {
+	playSound(0x2C08, 140);
+
+	return 0;
+}
+
+int ASound7::command23() {
+	playSound(0x2B08, 34);
+	playSound(0x2B2A, 20);
+
+	return 0;
+}
+
+int ASound7::command24() {
+	byte *pData1 = loadData(0x14C6, 144);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[0].load(pData1);
+		_channels[1].load(loadData(0x1556, 146));
+		_channels[2].load(loadData(0x15E8, 138));
+		_channels[3].load(loadData(0x1672, 122));
+		_channels[4].load(loadData(0x16EC, 74));
+	}
+
+	return 0;
+}
+
+int ASound7::command25() {
+	byte *pData1 = loadData(0x1DBE, 182);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[0].load(pData1);
+		_channels[1].load(loadData(0x1E74, 182));
+		_channels[2].load(loadData(0x1F2A, 186));
+		_channels[3].load(loadData(0x1FE4, 244));
+	}
+
+	return 0;
+}
+
+int ASound7::command26() {
+	byte *pData1 = loadData(0x20D8, 312);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[0].load(pData1);
+		_channels[1].load(loadData(0x2210, 304));
+		_channels[2].load(loadData(0x2340, 222));
+		_channels[3].load(loadData(0x241E, 522));
+		_channels[4].load(loadData(0x2628, 874));
+	}
+
+	return 0;
+}
+
+int ASound7::command27() {
+	byte *pData1 = loadData(0x1736, 158);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[0].load(pData1);
+		_channels[1].load(loadData(0x17D4, 288));
+		_channels[2].load(loadData(0x18F4, 290));
+		_channels[3].load(loadData(0x1A16, 396));
+		_channels[4].load(loadData(0x1BA2, 380));
+		_channels[5].load(loadData(0x1D1E, 160));
+	}
+
+	return 0;
+}
+
+int ASound7::command28() {
+	playSound(0x2CAA, 16);
+
+	return 0;
+}
+
+int ASound7::command30() {
+	playSound(0x2B86, 22);
+	playSound(0x2B9C, 22);
+	playSound(0x2BB2, 22);
+
+	return 0;
+}
+
+int ASound7::command32() {
+	playSound(0x2BFE, 10);
+
+	return 0;
+}
+
+int ASound7::command33() {
+	playSound(0x2BEE, 16);
+
+	return 0;
+}
+
+int ASound7::command34() {
+	playSound(0x2BDE, 16);
+
+	return 0;
+}
+
+int ASound7::command35() {
+	playSound(0x2BC8, 22);
+
+	return 0;
+}
+
+int ASound7::command36() {
+	playSound(0x2AF8, 16);
+
+	return 0;
+}
+
+int ASound7::command37() {
+	playSound(0x2B48, 20);
+	playSound(0x2B5C, 32);
+	playSound(0x2B7C, 10);
+
+	return 0;
+}
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/sound_nebular.h b/engines/mads/nebular/sound_nebular.h
index 771aac4..997f6bb 100644
--- a/engines/mads/nebular/sound_nebular.h
+++ b/engines/mads/nebular/sound_nebular.h
@@ -638,6 +638,38 @@ public:
 	virtual int command(int commandId, int param);
 };
 
+class ASound7 : public ASound {
+private:
+	typedef int (ASound7::*CommandPtr)();
+	static const CommandPtr _commandList[38];
+
+	int command9();
+	int command15();
+	int command16();
+	int command18();
+	int command19();
+	int command20();
+	int command21();
+	int command22();
+	int command23();
+	int command24();
+	int command25();
+	int command26();
+	int command27();
+	int command28();
+	int command30();
+	int command32();
+	int command33();
+	int command34();
+	int command35();
+	int command36();
+	int command37();
+public:
+	ASound7(Audio::Mixer *mixer);
+
+	virtual int command(int commandId, int param);
+};
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index 79a2b4e..b6563ce 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -67,6 +67,9 @@ void SoundManager::init(int sectionNumber) {
 		case 6:
 			_driver = new Nebular::ASound6(_mixer);
 			break;
+		case 7:
+			_driver = new Nebular::ASound1(_mixer);
+			break;
 		default:
 			_driver = nullptr;
 			break;


Commit: c151132b121787083faf234469716772008b36ff
    https://github.com/scummvm/scummvm/commit/c151132b121787083faf234469716772008b36ff
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-16T05:27:48+03:00

Commit Message:
MADS: Bugfixes for shooting down the monkey

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 256bdad..fedbff3 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -3017,7 +3017,7 @@ void Scene209::step() {
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 7);
 			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 228);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 229);
 			break;
 
 		case 229: {
@@ -3295,8 +3295,8 @@ void Scene209::actions() {
 	}
 
 	if (_globals[kMonkeyStatus] == MONKEY_HAS_BINOCULARS) {
-		if ((_action.isAction(VERB_SHOOT) || _action.isAction(VERB_HOSE_DOWN)) && _action.isAction(NOUN_MONKEY)
-			&& _action.isAction(NOUN_BLOWGUN) && _game._objects.isInInventory(OBJ_BLOWGUN) && _game._objects.isInInventory(OBJ_POISON_DARTS)) {
+		if ((_action.isAction(VERB_SHOOT) || _action.isAction(VERB_HOSE_DOWN)) && _action.isTarget(NOUN_MONKEY)
+			&& _action.isObject(NOUN_BLOWGUN) && _game._objects.isInInventory(OBJ_BLOWGUN) && _game._objects.isInInventory(OBJ_POISON_DARTS)) {
 			if (_action.isAction(VERB_SHOOT, NOUN_BLOWGUN, NOUN_MONKEY) && !_startShootingInTimerFl) {
 				_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 				_scene->_sequences.addTimer(1, 231);


Commit: f9fe18c5063611f6e7ec727157efb5a34e69bd56
    https://github.com/scummvm/scummvm/commit/f9fe18c5063611f6e7ec727157efb5a34e69bd56
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-16T06:25:00+03:00

Commit Message:
MADS: Bugfixes and cleanup for scene 202

Changed paths:
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index dc35b11..61cbd44 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -40,6 +40,7 @@ enum {
 
 enum Verb {
 	VERB_CLIMB_DOWN     = 0x04E,
+	VERB_CLIMB_UP       = 0x050,
 	VERB_EAT			= 0x075,
 	VERB_EXAMINE		= 0x07D,
 	VERB_HOSE_DOWN		= 0x0A6,
@@ -57,6 +58,7 @@ enum Verb {
 	VERB_SHOOT          = 0x13A,
 	VERB_SIT_IN         = 0x13F,
 	VERB_SMELL			= 0x147,
+	VERB_WALK_INSIDE    = 0x188,
 	VERB_WALK_THROUGH   = 0x18B,
 	VERB_WALK_TOWARDS   = 0x18C,
 	VERB_WALK_DOWN      = 0x1AD,
@@ -101,6 +103,7 @@ enum Noun {
 	NOUN_REFRIDGERATOR	= 0x122,
 	NOUN_ROBO_KITCHEN	= 0x127,
 	NOUN_ROCK           = 0x128,
+	NOUN_ROCKS          = 0x129,
 	NOUN_SHIELD_ACCESS_PANEL  = 0x135,
 	NOUN_SHIELD_MODULATOR	= 0x137,
 	NOUN_SKULL          = 0x140,
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index fedbff3..8830a1b 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -181,7 +181,7 @@ void Scene201::enter() {
 			_scene->loadAnimation(formAnimName(sepChar, suffixNum), abortTimers);
 	}
 
-	if ((_scene->_priorSceneId == 202) && (_globals[kMeteorologistStatus] == 1) && !_scene->_roomChanged) {
+	if ((_scene->_priorSceneId == 202) && (_globals[kMeteorologistStatus] == METEOROLOGIST_PRESENT) && !_scene->_roomChanged) {
 		_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('a', 0));
 		_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('a', 1));
 		_game.loadQuoteSet(90, 91, 0);
@@ -199,7 +199,7 @@ void Scene201::enter() {
 		_pterodactylFlag = true;
 
 	if (_globals[kTeleporterUnderstood])
-		_scene->_hotspots.activate(438, false);
+		_scene->_hotspots.activate(NOUN_STRANGE_DEVICE, false);
 
 	sceneEntrySound();
 }
@@ -282,11 +282,11 @@ void Scene201::actions() {
 	if (_action._lookFlag == false) {
 		if (_action.isAction(VERB_WALK_TOWARDS, 0x83))
 			_scene->_nextSceneId = 202;
-		else if ((_action.isAction(0x50, 0x156)) || (_action.isAction(0x188, 0x16C)) || (_action.isAction(0x188, 0x1B6))) {
+		else if ((_action.isAction(VERB_CLIMB_UP, 0x156)) || (_action.isAction(VERB_WALK_INSIDE, NOUN_TELEPORTER)) || (_action.isAction(VERB_WALK_INSIDE, NOUN_STRANGE_DEVICE))) {
 			if (_game._trigger == 0) {
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
-				int sepChar = (_globals[kSexOfRex] == SEX_UNKNOWN) ? 't' : 'u';
+				int sepChar = (_globals[kSexOfRex] == SEX_MALE) ? 't' : 'u';
 				_scene->loadAnimation(formAnimName(sepChar, 0), 1);
 			} else if (_game._trigger == 1) {
 				_scene->_nextSceneId = 213;
@@ -319,7 +319,7 @@ void Scene201::actions() {
 		} else
 			return;
 	} else {
-		_vm->_dialogs->show(0x4E8F);
+		_vm->_dialogs->show(20111);
 	}
 	_action._inProgress = false;
 }
@@ -536,7 +536,7 @@ void Scene202::step() {
 		}
 		break;
 	case 93: {
-		_globals[kLadderBroken] = -1;
+		_globals[kLadderBroken] = false;
 		_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 0, 0, 0);
 		_scene->_hotspots.activate(NOUN_LADDER, false);
 		int idx = _scene->_dynamicHotspots.add(NOUN_BROKEN_LADDER, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
@@ -743,241 +743,233 @@ void Scene202::preActions() {
 }
 
 void Scene202::actions() {
-	if (_action._lookFlag == false) {
-		if (_action.isAction(0x4E, NOUN_LADDER)) {
-			_action._inProgress = false;
-			return;
-		} else if (_action.isAction(VERB_WALK_TOWARDS, 0x83)) {
-			_scene->_nextSceneId = 203;
-		} else if (_action.isAction(VERB_WALK_TOWARDS, 0x82)) {
-			if (_globals[kMeteorologistStatus] != 2) {
-				if (_scene->_activeAnimation)
-					_globals[kMeteorologistStatus] = 1;
-				else
-					_globals[kMeteorologistStatus] = 0;
+	if (_action._lookFlag) {
+		_vm->_dialogs->show(20219);
+		return;
+	}
+	
+	if (_action.isAction(VERB_CLIMB_DOWN, NOUN_LADDER)) {
+		_action._inProgress = false;
+		return;
+	} else if (_action.isAction(VERB_WALK_TOWARDS, 0x83)) {
+		_scene->_nextSceneId = 203;
+	} else if (_action.isAction(VERB_WALK_TOWARDS, 0x82)) {
+		if (_globals[kMeteorologistStatus] != METEOROLOGIST_GONE) {
+			if (_scene->_activeAnimation)
+				_globals[kMeteorologistStatus] = METEOROLOGIST_PRESENT;
+			else
+				_globals[kMeteorologistStatus] = METEOROLOGIST_ABSENT;
+		}
+		_scene->_nextSceneId = 201;
+	} else if (_action.isAction(VERB_TAKE, NOUN_BONE) && _action._mainObjectSource == 4) {
+		switch (_game._trigger) {
+		case 0:
+			if (_game._objects.isInInventory(OBJ_BONES)) {
+				_vm->_dialogs->show(20221);
+			} else {
+				_game._player._stepEnabled = false;
+				_game._player._visible = false;
+				_globals._sequenceIndexes[7] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[7], false, 3, 2, 0, 0);
+				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[7]);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_SPRITE, 6, 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 			}
-			_scene->_nextSceneId = 201;
-		} else if (_action.isAction(VERB_TAKE, 0x2C)) {
-			if (_action._mainObjectSource == 4) {
-				switch (_game._trigger) {
-				case 0:
-					if (_game._objects.isInInventory(OBJ_BONES)) {
-						_vm->_dialogs->show(0x4EFB);
-					} else {
-						_game._player._stepEnabled = false;
-						_game._player._visible = false;
-						_globals._sequenceIndexes[7] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[6], false, 3, 2, 0, 0);
-						_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[7]);
-						_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_SPRITE, 6, 1);
-						_scene->_sequences.addSubEntry(_globals._sequenceIndexes[7], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
-					}
-					break;
-				case 1:
-					if (_game._player._playerPos == Common::Point(132,97)) {
-						_scene->_sequences.remove(_globals._sequenceIndexes[1]);
-						_globals[kBone202Status] |= 1;
-					} else {
-						_scene->_sequences.remove(_globals._sequenceIndexes[6]);
-						_globals[kBone202Status] |= 2;
-					}
-					break;
-				case 2:
-					if (_game._objects.isInInventory(OBJ_BONE)) {
-						_game._objects.removeFromInventory(OBJ_BONE, 1);
-						_game._objects.addToInventory(OBJ_BONES);
-						_vm->_dialogs->showItem(OBJ_BONES, 0x4EFA, 0);
-					} else {
-						_game._objects.addToInventory(OBJ_BONE);
-						_vm->_dialogs->showItem(OBJ_BONE, 0x4EFA, 0);
-					}
-					_scene->changeVariant(_globals[kBone202Status]);
-					_game._player._stepEnabled = true;
-					_game._player._visible = true;
-					break;
-				default:
-					_action._inProgress = false;
-					return;
-				}
+			break;
+		case 1:
+			if (_game._player._playerPos == Common::Point(132, 97)) {
+				_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+				_globals[kBone202Status] |= BONE_202_LEFT_GONE;
+			} else {
+				_scene->_sequences.remove(_globals._sequenceIndexes[6]);
+				_globals[kBone202Status] |= BONE_202_RIGHT_GONE;
+			}
+			break;
+		case 2:
+			if (_game._objects.isInInventory(OBJ_BONE)) {
+				_game._objects.removeFromInventory(OBJ_BONE, NOWHERE);
+				_game._objects.addToInventory(OBJ_BONES);
+				_vm->_dialogs->showItem(OBJ_BONES, 20218);
+			} else {
+				_game._objects.addToInventory(OBJ_BONE);
+				_vm->_dialogs->showItem(OBJ_BONE, 20218);
+			}
+			_scene->changeVariant(_globals[kBone202Status]);
+			_game._player._stepEnabled = true;
+			_game._player._visible = true;
+			break;
+		default:
+			break;
+		}
+
+		_action._inProgress = false;
+	} else if ((_action.isAction(VERB_CLIMB_UP, NOUN_LADDER)) && !_globals[kLadderBroken]) {
+		switch (_game._trigger) {
+		case 0:
+			_vm->_sound->command(29);
+			_meteoClock1 = _scene->_frameStartTime;
+			_game._player._visible = false;
+			_game._player._stepEnabled = false;
+
+			_ladderHotspotId = _scene->_dynamicHotspots.add(NOUN_LADDER, 79, -1, Common::Rect(241, 68, 241 + 12, 68 + 54));
+			_scene->_dynamicHotspots.setPosition(_ladderHotspotId, Common::Point(246, 124), FACING_NORTH);
+			_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			break;
+		case 1: {
+			_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[8], _globals._sequenceIndexes[9]);
+			_ladderTopFl = true;
+			_game._player._stepEnabled = true;
+			int msgIndex = _scene->_kernelMessages.add(Common::Point(248, 15), 0x1110, 32, 0, 60, _game.getQuote(97));
+			_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
 			}
-		} else if ((_action.isAction(0x50, NOUN_LADDER)) && (_globals[kLadderBroken] == 0)) {
+			break;
+		default:
+			_action._inProgress = false;
+			return;
+		}
+	} else if (((_action.isAction(VERB_LOOK, NOUN_BINOCULARS, 0x82)) || (_action.isAction(VERB_LOOK, NOUN_BINOCULARS, 0x1B6))) && (_globals[kSexOfRex] == SEX_MALE)) {
+		if (!_ladderTopFl) {
 			switch (_game._trigger) {
 			case 0:
-				_vm->_sound->command(29);
-				_meteoClock1 = _scene->_frameStartTime;
-				_game._player._visible = false;
 				_game._player._stepEnabled = false;
-
-				_ladderHotspotId = _scene->_dynamicHotspots.add(NOUN_LADDER, 79, -1, Common::Rect(241, 68, 241 + 12, 68 + 54));
-				_scene->_dynamicHotspots.setPosition(_ladderHotspotId, Common::Point(246, 124), FACING_NORTH);
-				_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
-				_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 1);
-				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+				_game._player._visible= false;
+				_globals._sequenceIndexes[10] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 1, 6);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
+				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[10]);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 				break;
-			case 1: {
-				_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
-				_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
-				_scene->_sequences.updateTimeout(_globals._sequenceIndexes[8], _globals._sequenceIndexes[9]);
-				_ladderTopFl = true;
-				_game._player._stepEnabled = true;
-				int msgIndex = _scene->_kernelMessages.add(Common::Point(248, 15), 0x1110, 32, 0, 60, _game.getQuote(97));
-				_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
+			case 1:
+				_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
+				if (_scene->_activeAnimation) {
+					_waitingMeteoFl = true;
+					_globals[kMeteorologistWatch] = METEOROLOGIST_GROUND;
+				} else {
+					_scene->_sequences.addTimer(120, 2);
+				}
+				break;
+			case 2:
+				if (!_scene->_activeAnimation && !_meteorologistSpecial) {
+					_vm->_dialogs->show(0x4EFE);
 				}
+				_scene->_sequences.remove(_globals._sequenceIndexes[10]);
+				_globals._sequenceIndexes[10] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 1, 6);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+				break;
+			case 3:
+				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[10]);
+				_game._player._stepEnabled = true;
+				_game._player._visible = true;
 				break;
 			default:
 				_action._inProgress = false;
 				return;
 			}
-		} else if (((_action.isAction(VERB_LOOK, 0x27, 0x82)) || (_action.isAction(VERB_LOOK, 0x27, 0x1B6))) && (_globals[kSexOfRex] == SEX_MALE)) {
-			if (!_ladderTopFl) {
-				switch (_game._trigger) {
-				case 0:
-					_game._player._stepEnabled = false;
-					_game._player._visible= false;
-					_globals._sequenceIndexes[10] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
-					_scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 1, 6);
-					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
-					_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
-					_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[10]);
-					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
-					break;
-				case 1:
-					_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
-					_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
-					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
-					if (_scene->_activeAnimation) {
-						_waitingMeteoFl = true;
-						_globals[kMeteorologistWatch] = METEOROLOGIST_GROUND;
-					} else {
+		} else {
+			switch (_game._trigger) {
+			case 0:
+				_toTeleportFl = true;
+				_game._player._stepEnabled = false;
+				_scene->_sequences.remove(_globals._sequenceIndexes[9]);
+				_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+				break;
+			case 1:
+				_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, -2);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(247, 82));
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
+				if (_scene->_activeAnimation) {
+					if (_scene->_activeAnimation->getCurrentFrame() > 200) {
 						_scene->_sequences.addTimer(120, 2);
-					}
-					break;
-				case 2:
-					if (!_scene->_activeAnimation && !_meteorologistSpecial) {
-						_vm->_dialogs->show(0x4EFE);
-					}
-					_scene->_sequences.remove(_globals._sequenceIndexes[10]);
-					_globals._sequenceIndexes[10] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
-					_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
-					_scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 1, 6);
-					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
-					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
-					break;
-				case 3:
-					_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[10]);
-					_game._player._stepEnabled = true;
-					_game._player._visible = true;
-					break;
-				default:
-					_action._inProgress = false;
-					return;
-				}
-			} else {
-				switch (_game._trigger) {
-				case 0:
-					_toTeleportFl = true;
-					_game._player._stepEnabled = false;
-					_scene->_sequences.remove(_globals._sequenceIndexes[9]);
-					_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0);
-					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
-					_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
-					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
-					break;
-				case 1:
-					_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, -2);
-					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(247, 82));
-					_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
-					if (_scene->_activeAnimation) {
-						if (_scene->_activeAnimation->getCurrentFrame() > 200) {
-							_scene->_sequences.addTimer(120, 2);
+					} else {
+						_waitingMeteoFl = true;
+						_globals[kMeteorologistWatch] = METEOROLOGIST_GONE;
+						if ((_scene->_activeAnimation->getCurrentFrame() >= 44) && (_scene->_activeAnimation->getCurrentFrame() <= 75)) {
+							_scene->_kernelMessages.reset();
+							int msgIndex = _scene->_kernelMessages.add(Common::Point(248, 15), 0x1110, 32, 0, 60, _game.getQuote(100));
+							_scene->_kernelMessages.setQuoted(msgIndex, 4, false);
 						} else {
-							_waitingMeteoFl = true;
-							_globals[kMeteorologistWatch] = METEOROLOGIST_GONE;
-							if ((_scene->_activeAnimation->getCurrentFrame() >= 44) && (_scene->_activeAnimation->getCurrentFrame() <= 75)) {
-								_scene->_kernelMessages.reset();
-								int msgIndex = _scene->_kernelMessages.add(Common::Point(248, 15), 0x1110, 32, 0, 60, _game.getQuote(100));
-								_scene->_kernelMessages.setQuoted(msgIndex, 4, false);
-							} else {
-								_action._inProgress = false;
-								return;
-							}
+							_action._inProgress = false;
+							return;
 						}
-					} else {
-						_scene->_sequences.addTimer(120, 2);
 					}
-					break;
-				case 2:
-					if (!_scene->_activeAnimation)
-						_vm->_dialogs->show(0x4EFE);
-					_meteorologistSpecial = false;
-					_scene->_sequences.remove(_globals._sequenceIndexes[10]);
-					_globals._sequenceIndexes[9] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
-					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
-					_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
-					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
-					break;
-				case 3:
-					_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
-					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
-					_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
-					_game._player._stepEnabled = true;
-					break;
-				default:
-					_action._inProgress = false;
-					return;
+				} else {
+					_scene->_sequences.addTimer(120, 2);
 				}
-			}
-		} else if (_action.isAction(0x188, 0xAA)) {
-			setRandomKernelMessage();
-		} else if (_action.isAction(VERB_LOOK, 0x129)) {
-			_vm->_dialogs->show(0x4EEA);
-		} else if (_action.isAction(VERB_LOOK, 0x86)) {
-			_vm->_dialogs->show(0x4EEB);
-		} else if (_action.isAction(VERB_LOOK, 0x19C)) {
-			_vm->_dialogs->show(0x4EEC);
-		} else if (_action.isAction(VERB_LOOK, 0x82)) {
-			if ((_globals[kMeteorologistStatus] == 0) || (_globals[kMeteorologistStatus] == 2)) {
-				_vm->_dialogs->show(0x4EED);
-			} else if (_globals[kMeteorologistStatus] == 1) {
-				_vm->_dialogs->show(0x4EFC);
-			} else {
+				break;
+			case 2:
+				if (!_scene->_activeAnimation)
+					_vm->_dialogs->show(0x4EFE);
+				_meteorologistSpecial = false;
+				_scene->_sequences.remove(_globals._sequenceIndexes[10]);
+				_globals._sequenceIndexes[9] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+				break;
+			case 3:
+				_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
+				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
+				_game._player._stepEnabled = true;
+				break;
+			default:
 				_action._inProgress = false;
 				return;
 			}
-		} else if (_action.isAction(VERB_LOOK, 0x18E)) {
-			_vm->_dialogs->show(0x4EEE);
-		} else if (_action.isAction(VERB_LOOK, 0x164)) {
-			_vm->_dialogs->show(0x4EEF);
-		} else if (_action.isAction(VERB_LOOK, 0x175)) {
-			_vm->_dialogs->show(0x4EF0);
-		} else if (_action.isAction(VERB_LOOK, 0x174)) {
-			_vm->_dialogs->show(0x4EF1);
-		} else if (_action.isAction(VERB_LOOK, 0x142)) {
-			_vm->_dialogs->show(0x4EF2);
-		} else if (_action.isAction(VERB_LOOK, 0xAA)) {
-			if ((_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == FACING_NORTH))
-				_vm->_dialogs->show(0x4EF4);
-			else
-				_vm->_dialogs->show(0x4EF3);
-		} else if (_action.isAction(VERB_LOOK, 0x186)) {
-			_vm->_dialogs->show(0x4EF5);
-		} else if (_action.isAction(VERB_LOOK, 0x1B5)) {
-			_vm->_dialogs->show(0x4EF6);
-		} else if (_action.isAction(VERB_LOOK, 0x140)) {
-			_vm->_dialogs->show(0x4EF7);
-		} else if (_action.isAction(VERB_TAKE, 0x140)) {
-			_vm->_dialogs->show(0x4EF8);
-		} else if (_action.isAction(VERB_LOOK, 0x2D)) {
-			if (_action._commandSource == 4)
-				_vm->_dialogs->show(0x4EF9);
-			else
-				return;
-		} else {
-			return;
 		}
-	} else {
-		_vm->_dialogs->show(0x4EFB);
+	} else if (_action.isAction(0x188, 0xAA)) {
+		setRandomKernelMessage();
+	} else if (_action.isAction(VERB_LOOK, NOUN_ROCKS)) {
+		_vm->_dialogs->show(20202);
+	} else if (_action.isAction(VERB_LOOK, 0x86)) {
+		_vm->_dialogs->show(20203);
+	} else if (_action.isAction(VERB_LOOK, 0x19C)) {
+		_vm->_dialogs->show(20204);
+	} else if (_action.isAction(VERB_LOOK, 0x82)) {
+		if ((_globals[kMeteorologistStatus] == METEOROLOGIST_ABSENT) || (_globals[kMeteorologistStatus] == METEOROLOGIST_GONE))
+			_vm->_dialogs->show(20205);
+		else if (_globals[kMeteorologistStatus] == METEOROLOGIST_PRESENT)
+			_vm->_dialogs->show(20220);
+	} else if (_action.isAction(VERB_LOOK, 0x18E)) {
+		_vm->_dialogs->show(0x4EEE);
+	} else if (_action.isAction(VERB_LOOK, 0x164)) {
+		_vm->_dialogs->show(0x4EEF);
+	} else if (_action.isAction(VERB_LOOK, 0x175)) {
+		_vm->_dialogs->show(0x4EF0);
+	} else if (_action.isAction(VERB_LOOK, 0x174)) {
+		_vm->_dialogs->show(0x4EF1);
+	} else if (_action.isAction(VERB_LOOK, 0x142)) {
+		_vm->_dialogs->show(0x4EF2);
+	} else if (_action.isAction(VERB_LOOK, 0xAA)) {
+		if ((_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == FACING_NORTH))
+			_vm->_dialogs->show(20212);
+		else
+			_vm->_dialogs->show(20211);
+	} else if (_action.isAction(VERB_LOOK, NOUN_STRANGE_DEVICE)) {
+		_vm->_dialogs->show(20213);
+	} else if (_action.isAction(VERB_LOOK, 0x1B5)) {
+		_vm->_dialogs->show(0x4EF6);
+	} else if (_action.isAction(VERB_LOOK, NOUN_SKULL)) {
+		_vm->_dialogs->show(0x4EF7);
+	} else if (_action.isAction(VERB_TAKE, NOUN_SKULL)) {
+		_vm->_dialogs->show(0x4EF8);
+	} else if (_action.isAction(VERB_LOOK, NOUN_BONES) && _action._commandSource == 4) {
+		_vm->_dialogs->show(0x4EF9);
 	}
+
 	_action._inProgress = false;
 }
 


Commit: 4cf895ad062a5ded60ea5dc57991d6ba6941e46e
    https://github.com/scummvm/scummvm/commit/4cf895ad062a5ded60ea5dc57991d6ba6941e46e
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-16T06:26:11+03:00

Commit Message:
MADS: Do not attempt to remove objects that aren't in the inventory

Fixes a crash when the guards take Rex's stuff

Changed paths:
    engines/mads/inventory.cpp



diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index d41a55f..79a8e87 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -161,6 +161,10 @@ void InventoryObjects::removeFromInventory(int objectId, int newScene) {
 			invIndex = idx;
 	}
 
+	// If the object isn't in the player's inventory, stop here
+	if (invIndex < 0)
+		return;
+
 	int selectedIndex = userInterface._selectedInvIndex;
 	bool noSelection = selectedIndex < 0;
 


Commit: 8a30fe7d5d2490fdd169208291c6f1148c1f7d8a
    https://github.com/scummvm/scummvm/commit/8a30fe7d5d2490fdd169208291c6f1148c1f7d8a
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-16T06:27:29+03:00

Commit Message:
MADS: Add a FIXME for scene 307

Changed paths:
    engines/mads/nebular/nebular_scenes3.cpp



diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 78421e6..81ee04a 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -819,7 +819,8 @@ void Scene307::step() {
 		}
 		_lastFrameTime = _scene->_frameStartTime;
 
-		if ((_guardTime > 3000) && !_duringPeeingFl && (_scene->_activeAnimation == nullptr)
+		// FIXME: The active animation is never a zero pointer, so the guards never show up
+		if ((_guardTime > 3000) && !_duringPeeingFl /*&& (_scene->_activeAnimation == nullptr)*/
 		&& (_game._screenObjects._inputMode != 1) && _globals[kMetBuddyBeast] && !_activePrisonerFl) {
 			if (!_game._objects.isInInventory(OBJ_SCALPEL) && !_grateOpenedFl) {
 				_game._player._stepEnabled = false;


Commit: 514f122847c1e6be7b9901800bd3298d47ae72bb
    https://github.com/scummvm/scummvm/commit/514f122847c1e6be7b9901800bd3298d47ae72bb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-16T09:05:05-04:00

Commit Message:
MADS: Implemented sound player for scene group 8

Changed paths:
    engines/mads/nebular/sound_nebular.cpp
    engines/mads/nebular/sound_nebular.h
    engines/mads/sound.cpp



diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp
index 997ea18..5ee34b4 100644
--- a/engines/mads/nebular/sound_nebular.cpp
+++ b/engines/mads/nebular/sound_nebular.cpp
@@ -2849,6 +2849,259 @@ int ASound7::command37() {
 	return 0;
 }
 
+/*-----------------------------------------------------------------------*/
+
+const ASound8::CommandPtr ASound8::_commandList[38] = {
+	&ASound8::command0, &ASound8::command1, &ASound8::command2, &ASound8::command3,
+	&ASound8::command4, &ASound8::command5, &ASound8::command6, &ASound8::command7,
+	&ASound8::command8, &ASound8::command9, &ASound8::command10, &ASound8::command11,
+	&ASound8::command12, &ASound8::command13, &ASound8::command14, &ASound8::command15,
+	&ASound8::command16, &ASound8::command16, &ASound8::command18, &ASound8::command19,
+	&ASound8::command20, &ASound8::command21, &ASound8::command22, &ASound8::command23,
+	&ASound8::command24, &ASound8::command25, &ASound8::command26, &ASound8::command27,
+	&ASound8::command28, &ASound8::command29, &ASound8::command30, &ASound8::command31,
+	&ASound8::command32, &ASound8::command33, &ASound8::command34, &ASound8::command35,
+	&ASound8::command36, &ASound8::command37
+};
+
+ASound8::ASound8(Audio::Mixer *mixer) : ASound(mixer, "asound.008", 0x1490) {
+	// Load sound samples
+	_soundFile.seek(_dataOffset + 0x122);
+	for (int i = 0; i < 174; ++i)
+		_samples.push_back(AdlibSample(_soundFile));
+}
+
+int ASound8::command(int commandId, int param) {
+	if (commandId > 38)
+		return 0;
+
+	_frameCounter = 0;
+	return (this->*_commandList[commandId])();
+}
+
+int ASound8::command9() {
+	byte *pData = loadData(0x15BE, 10);
+	pData[6] = (getRandomNumber() & 7) + 85;
+	playSoundData(pData);
+
+	return 0;
+}
+
+int ASound8::command10() {
+	byte *pData = loadData(0x2B3E, 10);
+	pData[6] = (getRandomNumber() & 7) + 85;
+	playSoundData(pData);
+
+	return 0;
+}
+
+int ASound8::command11() {
+	playSound(0x17CA, 12);
+
+	return 0;
+}
+
+int ASound8::command12() {
+	playSound(0x17D6, 12);
+
+	return 0;
+}
+
+int ASound8::command13() {
+	playSound(0x1694, 10);
+
+	return 0;
+}
+
+int ASound8::command14() {
+	playSound(0x169E, 24);
+
+	return 0;
+}
+
+int ASound8::command15() {
+	byte *pData = loadData(0x169E, 24);
+	if (_channels[8]._ptr1 == pData) {
+		_channels[8]._soundData = loadData(0x16B6, 12);
+		_channels[8]._field17 = 1;
+		_channels[8]._field19 = 1;
+	}
+
+	return 0;
+}
+
+int ASound8::command16() {
+	playSound(0x1686, 14);
+
+	return 0;
+}
+
+int ASound8::command17() {
+	playSound(0x17EC, 12);
+
+	return 0;
+}
+
+int ASound8::command18() {
+	playSound(0x17F8, 12);
+
+	return 0;
+}
+
+int ASound8::command19() {
+	playSound(0x16D8, 8);
+
+	return 0;
+}
+
+int ASound8::command20() {
+	playSound(0x16E0, 8);
+
+	return 0;
+}
+
+int ASound8::command21() {
+	playSound(0x17E2, 10);
+
+	return 0;
+}
+
+int ASound8::command22() {
+	playSound(0x178C, 14);
+	playSound(0x179A, 14);
+	playSound(0x17A8, 14);
+
+	return 0;
+}
+
+int ASound8::command23() {
+	playSound(0x2B08, 34);
+	playSound(0x2B2A, 20);
+
+	return 0;
+}
+
+int ASound8::command24() {
+	playSound(0x17B6, 8);
+
+	return 0;
+}
+
+int ASound8::command25() {
+	playSound(0x17BE, 12);
+
+	return 0;
+}
+
+int ASound8::command26() {
+	playSound(0x16C2, 22);
+
+	return 0;
+}
+
+int ASound8::command27() {
+	playSound(0x1588, 34);
+	playSound(0x15AA, 20);
+
+	return 0;
+}
+
+int ASound8::command28() {
+	byte *pData1 = loadData(0x114E, 376);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[0].load(pData1);
+		_channels[2].load(loadData(0x12F8, 130));
+		
+		byte *pData = loadData(0x12C6, 50);
+		method1(pData);
+		_channels[1].load(pData);
+	}
+
+	return 0;
+}
+
+void ASound8::method1(byte *pData) {
+	int v;
+	while ((v = (getRandomNumber() & 0x3F)) > 36)
+		;
+
+	adjustRange(pData, v + 20, -1);
+	adjustRange(pData + 1, 10 - ((v + 1) / 6), 1);
+}
+
+void ASound8::adjustRange(byte *pData, byte v, int incr) {
+	pData += 8;
+
+	for (int i = 0; i < 10; ++i, pData += 4, v += incr) {
+		*pData = v;
+	}
+}
+
+int ASound8::command29() {
+	byte *pData1 = loadData(0x137A, 60);
+	if (!isSoundActive(pData1)) {
+		command1();
+		_channels[0].load(pData1);
+		_channels[1].load(loadData(0x13B6, 318));
+		_channels[2].load(loadData(0x14F4, 118));
+	}
+
+	return 0;
+}
+
+int ASound8::command30() {
+	playSound(0x1644, 22);
+	playSound(0x165A, 22);
+	playSound(0x1670, 22);
+
+	return 0;
+}
+
+int ASound8::command31() {
+	playSound(0x156A, 14);
+
+	return 0;
+}
+
+int ASound8::command32() {
+	playSound(0x163A, 10);
+
+	return 0;
+}
+
+int ASound8::command33() {
+	playSound(0x162A, 16);
+
+	return 0;
+}
+
+int ASound8::command34() {
+	playSound(0x161A, 16);
+
+	return 0;
+}
+
+int ASound8::command35() {
+	playSound(0x1604, 22);
+
+	return 0;
+}
+
+int ASound8::command36() {
+	playSound(0x1578, 16);
+
+	return 0;
+}
+
+int ASound8::command37() {
+	playSound(0x15C8, 20);
+	playSound(0x15DC, 30);
+	playSound(0X15FA, 10);
+
+	return 0;
+}
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/sound_nebular.h b/engines/mads/nebular/sound_nebular.h
index 997f6bb..b5dee5b 100644
--- a/engines/mads/nebular/sound_nebular.h
+++ b/engines/mads/nebular/sound_nebular.h
@@ -670,6 +670,49 @@ public:
 	virtual int command(int commandId, int param);
 };
 
+class ASound8 : public ASound {
+private:
+	typedef int (ASound8::*CommandPtr)();
+	static const CommandPtr _commandList[38];
+
+	int command9();
+	int command10();
+	int command11();
+	int command12();
+	int command13();
+	int command14();
+	int command15();
+	int command16();
+	int command17();
+	int command18();
+	int command19();
+	int command20();
+	int command21();
+	int command22();
+	int command23();
+	int command24();
+	int command25();
+	int command26();
+	int command27();
+	int command28();
+	int command29();
+	int command30();
+	int command31();
+	int command32();
+	int command33();
+	int command34();
+	int command35();
+	int command36();
+	int command37();
+
+	void method1(byte *pData);
+	void adjustRange(byte *pData, byte v, int incr);
+public:
+	ASound8(Audio::Mixer *mixer);
+
+	virtual int command(int commandId, int param);
+};
+
 } // End of namespace Nebular
 
 } // End of namespace MADS
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index b6563ce..2b8bb1e 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -68,7 +68,10 @@ void SoundManager::init(int sectionNumber) {
 			_driver = new Nebular::ASound6(_mixer);
 			break;
 		case 7:
-			_driver = new Nebular::ASound1(_mixer);
+			_driver = new Nebular::ASound7(_mixer);
+			break;
+		case 8:
+			_driver = new Nebular::ASound8(_mixer);
 			break;
 		default:
 			_driver = nullptr;


Commit: dbf2cfef5754aaf3b5fbe47860106cf5386525f8
    https://github.com/scummvm/scummvm/commit/dbf2cfef5754aaf3b5fbe47860106cf5386525f8
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-16T18:56:21+02:00

Commit Message:
MADS: Remove some optional parameters

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes5.cpp



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 8830a1b..c602427 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1180,7 +1180,7 @@ void Scene205::enter() {
 		_game._player._playerPos = Common::Point(99, 152);
 
 	if (_globals[kSexOfRex] != SEX_MALE) {
-		_scene->loadAnimation(formAnimName('a', -1), 0);
+		_scene->loadAnimation(formAnimName('a', -1));
 		_scene->_activeAnimation->_resetFlag = false;
 	} else {
 		_beingKicked = true;
@@ -4100,7 +4100,7 @@ void Scene210::enter() {
 	}
 
 	if (_globals[kTwinklesStatus] == 0) {
-		_scene->loadAnimation(formAnimName('A', -1), 0);
+		_scene->loadAnimation(formAnimName('A', -1));
 		_twinkleAnimationType = 1;
 	} else
 		_scene->_hotspots.activate(476, false);
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 81ee04a..03026c1 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -3215,7 +3215,7 @@ void Scene319::step() {
 		_nextAction1 = _nextAction2;
 		_animFrame = 0;
 		_scene->freeAnimation();
-		_scene->loadAnimation(formAnimName('b', 0), false);
+		_scene->loadAnimation(formAnimName('b', 0));
 		if (_nextAction1 == 3)
 			_scene->_activeAnimation->setCurrentFrame(85);
 		else if (_nextAction1 == 1)
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index 11af55b..168daea 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -1933,7 +1933,7 @@ void Scene511::actions() {
 						_lineAnimationMode = 1;
 						_lineAnimationPosition = 1;
 						_lineMoving = true;
-						_scene->loadAnimation(formAnimName('R', -1), 0);
+						_scene->loadAnimation(formAnimName('R', -1));
 						_scene->_sequences.addTimer(1, 1);
 					} else if (_game._trigger == 1) {
 						if (_lineMoving) {


Commit: 54d8f17686d7fc7c4a9269c983e10ad4073c71f0
    https://github.com/scummvm/scummvm/commit/54d8f17686d7fc7c4a9269c983e10ad4073c71f0
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-16T18:56:22+02:00

Commit Message:
MADS: Implement scene 704

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes7.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 8053818..b9cf62b 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -257,7 +257,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 703:	// water
 		return new Scene703(vm);
 	case 704:	// water, building in the distance
-		return new DummyScene(vm);	// TODO
+		return new Scene704(vm);
 	case 705:	// water, outside building
 		return new DummyScene(vm);	// TODO
 	case 706:	// inside building, pedestral room, outside teleporter
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index c602427..a86b78f 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -761,7 +761,7 @@ void Scene202::actions() {
 				_globals[kMeteorologistStatus] = METEOROLOGIST_ABSENT;
 		}
 		_scene->_nextSceneId = 201;
-	} else if (_action.isAction(VERB_TAKE, NOUN_BONE) && _action._mainObjectSource == 4) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_BONE) && (_action._mainObjectSource == 4)) {
 		switch (_game._trigger) {
 		case 0:
 			if (_game._objects.isInInventory(OBJ_BONES)) {
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index ec99f14..d288432 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -532,7 +532,7 @@ void Scene703::enter() {
 		_curSequence = 2;
 		_boatDir = 2;
 		_monsterMode = 0;
-		_scene->loadAnimation(formAnimName('A', -1), 0);
+		_scene->loadAnimation(formAnimName('A', -1));
 		_scene->_activeAnimation->setCurrentFrame(34);
 	} else if (_scene->_priorSceneId != -2) {
 		_game._player._stepEnabled = false;
@@ -540,27 +540,27 @@ void Scene703::enter() {
 		if (_globals[kMonsterAlive]) {
 			_monsterMode = 1;
 			_curSequence = 0;
-			_scene->loadAnimation(formAnimName('B', -1), 0);
+			_scene->loadAnimation(formAnimName('B', -1));
 		} else {
 			_curSequence = 0;
 			_monsterMode = 0;
-			_scene->loadAnimation(formAnimName('A', -1), 0);
+			_scene->loadAnimation(formAnimName('A', -1));
 		}
 	} else if (_globals[kMonsterAlive]) {
 		_curSequence = 0;
 		_boatDir = 1;
 		_monsterMode = 1;
-		_scene->loadAnimation(formAnimName('B', -1), 0);
+		_scene->loadAnimation(formAnimName('B', -1));
 		_scene->_activeAnimation->setCurrentFrame(39);
 	} else if (_boatDir == 1) {
 		_curSequence = 0;
 		_monsterMode = 0;
-		_scene->loadAnimation(formAnimName('A', -1), 0);
+		_scene->loadAnimation(formAnimName('A', -1));
 		_scene->_activeAnimation->setCurrentFrame(9);
 	} else if (_boatDir == 2) {
 		_curSequence = 0;
 		_monsterMode = 0;
-		_scene->loadAnimation(formAnimName('A', -1), 0);
+		_scene->loadAnimation(formAnimName('A', -1));
 		_scene->_activeAnimation->setCurrentFrame(56);
 	}
 
@@ -594,7 +594,7 @@ void Scene703::step() {
 		_game._player._stepEnabled = false;
 		_scene->freeAnimation();
 		_monsterMode = 3;
-		_scene->loadAnimation(formAnimName('D', -1), 0);
+		_scene->loadAnimation(formAnimName('D', -1));
 		_rexDeathFl = false;
 		_monsterTime = 0;
 	}
@@ -949,6 +949,345 @@ void Scene703::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene704::setup() {
+	_game._player._spritesPrefix = "";
+	setAAName();
+	_scene->addActiveVocab(0x2E);
+	_scene->addActiveVocab(0xD1);
+}
+
+void Scene704::handleBottleInterface() {
+	switch (_globals[kBottleStatus]) {
+	case 0:
+		_dialog1.write(0x311, true);
+		_dialog1.write(0x312, true);
+		_dialog1.write(0x313, true);
+		_dialog1.write(0x314, true);
+		_dialog1.write(0x315, true);
+		break;
+
+	case 1:
+		_dialog1.write(0x311, false);
+		_dialog1.write(0x312, true);
+		_dialog1.write(0x313, true);
+		_dialog1.write(0x314, true);
+		_dialog1.write(0x315, true);
+		break;
+
+	case 2:
+		_dialog1.write(0x311, false);
+		_dialog1.write(0x312, false);
+		_dialog1.write(0x313, true);
+		_dialog1.write(0x314, true);
+		_dialog1.write(0x315, true);
+		break;
+
+	case 3:
+		_dialog1.write(0x311, false);
+		_dialog1.write(0x312, false);
+		_dialog1.write(0x313, false);
+		_dialog1.write(0x314, true);
+		_dialog1.write(0x315, true);
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene704::setBottleSequence() {
+	_scene->_userInterface.setup(kInputBuildingSentences);
+	_game._player._stepEnabled = false;
+	if (_boatDirection == 2)
+		_animationMode = 6;
+	else
+		_animationMode = 7;
+}
+
+void Scene704::handleFillBottle(int quote) {
+	switch (quote) {
+	case 0x311:
+		_globals[kBottleStatus] = 1;
+		setBottleSequence();
+		break;
+
+	case 0x312:
+		_globals[kBottleStatus] = 2;
+		setBottleSequence();
+		break;
+
+	case 0x313:
+		_globals[kBottleStatus] = 3;
+		setBottleSequence();
+		break;
+
+	case 0x314:
+		_globals[kBottleStatus] = 4;
+		setBottleSequence();
+		break;
+
+	case 0x315:
+		_scene->_userInterface.setup(kInputBuildingSentences);
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene704::enter() {
+	if (_game._objects[OBJ_BOTTLE]._roomNumber == _scene->_currentSceneId) {
+		_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('b', 0));
+		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+		if (_scene->_priorSceneId == 705) {
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(123, 125));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+		} else {
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(190, 122));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 2);
+		}
+		int idx = _scene->_dynamicHotspots.add(0x2D, 0xD1, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_bottleHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(-2, 0), FACING_NONE);
+	}
+
+	_game._player._visible = false;
+	_takeBottleFl = false;
+	_boatCurrentFrame = -1;
+
+	if (_scene->_priorSceneId == 705) {
+		_game._player._stepEnabled = false;
+		_animationMode = 2;
+		_boatDirection = 2;
+		_scene->loadAnimation(formAnimName('A', -1));
+		_scene->_activeAnimation->setCurrentFrame(36);
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._stepEnabled = false;
+		_boatDirection = 1;
+		_scene->loadAnimation(formAnimName('A', -1));
+	} else if (_boatDirection == 1) {
+		_scene->loadAnimation(formAnimName('A', -1));
+		_scene->_activeAnimation->setCurrentFrame(8);
+	} else if (_boatDirection == 2) {
+		if (_game._objects[OBJ_BOTTLE]._roomNumber == _scene->_currentSceneId) {
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(123, 125));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+		}
+		_scene->loadAnimation(formAnimName('A', -1));
+		_scene->_activeAnimation->setCurrentFrame(57);
+	}
+
+	if (_scene->_roomChanged)
+		_globals[kMonsterAlive] = false;
+
+	_game.loadQuoteSet(0x311, 0x312, 0x313, 0x314, 0x315, 0);
+	_dialog1.setup(0x98, 0x311, 0x312, 0x313, 0x314, 0x315, 0);
+
+	sceneEntrySound();
+	_vm->_sound->command(28);
+}
+
+void Scene704::step() {
+	if (_scene->_activeAnimation != nullptr) {
+		if (_scene->_activeAnimation->getCurrentFrame() != _boatCurrentFrame) {
+			_boatCurrentFrame = _scene->_activeAnimation->getCurrentFrame();
+			int nextFrame = -1;
+
+			switch (_boatCurrentFrame) {
+			case 10:
+				switch (_animationMode) {
+				case 1:
+					nextFrame = 10;
+					break;
+				case 5:
+					nextFrame = 74;
+					break;
+				case 7:
+					_animationMode = 0;
+					nextFrame = 92;
+					break;
+				default:
+					if (!_game._player._stepEnabled)
+						_game._player._stepEnabled = true;
+
+					nextFrame = 8;
+					break;
+				}
+				break;
+
+			case 36:
+				if (_animationMode != 2)
+					_scene->_nextSceneId = 705;
+				break;
+
+			case 59:
+				switch (_animationMode) {
+				case 3:
+					nextFrame = 59;
+					break;
+
+				case 4:
+					nextFrame = 65;
+					break;
+
+				case 6:
+					_animationMode = 0;
+					nextFrame = 83;
+					break;
+
+				default:
+					if (!_game._player._stepEnabled) {
+						_game._player._stepEnabled = true;
+					}
+					nextFrame = 57;
+					break;
+				}
+				break;
+
+			case 65:
+				_scene->_nextSceneId = 703;
+				break;
+
+			case 74:
+				nextFrame = 10;
+				break;
+
+			case 83:
+				nextFrame = 59;
+				break;
+
+			case 90:
+				if (_takeBottleFl) {
+					_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+					_scene->_dynamicHotspots.remove(_bottleHotspotId);
+					_game._objects.addToInventory(OBJ_BOTTLE);
+					_vm->_sound->command(15);
+					_vm->_dialogs->showItem(OBJ_BOTTLE, 70415);
+				}
+				break;
+
+			case 92:
+				nextFrame = 57;
+				if (!_game._player._stepEnabled && !_takeBottleFl) {
+					_scene->_sequences.addTimer(30, 70);
+					_game._player._stepEnabled = true;
+				}
+				break;
+
+			case 98:
+				if (_takeBottleFl) {
+					_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+					_scene->_dynamicHotspots.remove(_bottleHotspotId);
+					_game._objects.addToInventory(OBJ_BOTTLE);
+					_vm->_sound->command(15);
+					_vm->_dialogs->showItem(OBJ_BOTTLE, 70415);
+				}
+				break;
+
+			case 101:
+				nextFrame = 8;
+				if (!_game._player._stepEnabled && !_takeBottleFl) {
+					_scene->_sequences.addTimer(30, 70);
+					_game._player._stepEnabled = true;
+				}
+				break;
+
+			default:
+				break;
+			}
+
+			if ((nextFrame >= 0) && (nextFrame != _scene->_activeAnimation->getCurrentFrame())) {
+				_scene->_activeAnimation->setCurrentFrame(nextFrame);
+				_boatCurrentFrame = nextFrame;
+			}
+		}
+	}
+
+	if (_game._trigger == 70) {
+		switch (_globals[kBottleStatus]) {
+		case 0:
+			_vm->_dialogs->show(432);
+			break;
+
+		case 1:
+			_vm->_dialogs->show(70324);
+			break;
+
+		case 2:
+			_vm->_dialogs->show(70325);
+			break;
+
+		case 3:
+			_vm->_dialogs->show(70326);
+			break;
+
+		case 4:
+			_vm->_dialogs->show(70327);
+			break;
+
+		default:
+			break;
+		}
+	}
+}
+
+void Scene704::actions() {
+	if (_game._screenObjects._inputMode == 1)
+		handleFillBottle(_action._activeAction._verbId);
+	else if (_action.isAction(0x3B1, 0x3B4)) {
+		_game._player._stepEnabled = false;
+		if (_boatDirection == 1)
+			_animationMode = 5;
+		else
+			_animationMode = 3;
+	} else if (_action.isAction(0x3B1, 0x3B2)) {
+		_game._player._stepEnabled = false;
+		if (_boatDirection == 2)
+			_animationMode = 4;
+		else
+			_animationMode = 1;
+	} else if (_action.isAction(VERB_TAKE, 0x2E)) {
+		if (!_game._objects.isInInventory(OBJ_BOTTLE)) {
+			_game._player._stepEnabled = false;
+			_takeBottleFl = true;
+			if (_boatDirection == 2) {
+				_animationMode = 6;
+			} else {
+				_animationMode = 7;
+			}
+		}
+	} else if (_action.isAction(VERB_PUT, 0x2E, 0x18F) || _action.isAction(0x85, 0x2E, 0x18F)) {
+		if (_game._objects.isInInventory(OBJ_BOTTLE)) {
+			if (_globals[kBottleStatus] != 4) {
+				_takeBottleFl = false;
+				handleBottleInterface();
+				_dialog1.start();
+			} else
+				_vm->_dialogs->show(70323);
+		}
+	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x18F))
+		_vm->_dialogs->show(70410);
+	else if (_action.isAction(VERB_LOOK, 0x3B2)) {
+		if (_game._visitedScenes.exists(710))
+			_vm->_dialogs->show(70411);
+		else
+			_vm->_dialogs->show(70412);
+	} else if (_action.isAction(VERB_LOOK, 0x3B3))
+		_vm->_dialogs->show(70413);
+	else if (_action.isAction(VERB_LOOK, 0x2E) && (_action._mainObjectSource == 4))
+		_vm->_dialogs->show(70414);
+	else if (_action.isAction(VERB_LOOK, 0x3B4))
+		_vm->_dialogs->show(70416);
+	else if (_action.isAction(VERB_LOOK, 0x142))
+		_vm->_dialogs->show(70417);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene707::setup() {
 	_game._player._spritesPrefix = "";
 	// The original calls Scene7xx::setAAName()
diff --git a/engines/mads/nebular/nebular_scenes7.h b/engines/mads/nebular/nebular_scenes7.h
index 049cc54..34695dd 100644
--- a/engines/mads/nebular/nebular_scenes7.h
+++ b/engines/mads/nebular/nebular_scenes7.h
@@ -106,6 +106,32 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene704: public Scene7xx{
+private:
+	int _bottleHotspotId;
+	int _boatCurrentFrame;
+	int _animationMode;
+	int _boatDirection;
+
+	bool _takeBottleFl;
+
+	Conversation _dialog1;
+
+	void handleFillBottle(int quote);
+	void setBottleSequence();
+	void handleBottleInterface();
+
+public:
+	Scene704(MADSEngine *vm) : Scene7xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 class Scene707: public SceneTeleporter {
 public:
 	Scene707(MADSEngine *vm) : SceneTeleporter(vm) {}


Commit: ede08b748a7af7912ed3dde37eea22a1fb2bb684
    https://github.com/scummvm/scummvm/commit/ede08b748a7af7912ed3dde37eea22a1fb2bb684
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-16T20:29:36+03:00

Commit Message:
MADS: Spacing

Changed paths:
    engines/mads/nebular/nebular_scenes3.cpp



diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 03026c1..aca9b8b 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -2678,7 +2678,7 @@ void Scene318::step() {
 	case 60:
 		_vm->_sound->command(3);
 		_animMode = 2;
-		_scene->_reloadSceneFlag= true;
+		_scene->_reloadSceneFlag = true;
 		break;
 
 	case 61:


Commit: a197d91df64cb625c6640fdd9fe0a5f74d61a208
    https://github.com/scummvm/scummvm/commit/a197d91df64cb625c6640fdd9fe0a5f74d61a208
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-16T20:29:37+03:00

Commit Message:
MADS: Add a sanity check in pollActiveChannel()

This avoids a crash when Rex is knocked unconscious in scene 318

Changed paths:
    engines/mads/nebular/sound_nebular.cpp



diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp
index 5ee34b4..666b686 100644
--- a/engines/mads/nebular/sound_nebular.cpp
+++ b/engines/mads/nebular/sound_nebular.cpp
@@ -413,6 +413,10 @@ void ASound::pollActiveChannel() {
 		if (--_activeChannelPtr->_activeCount <= 0) {
 			for (;;) {
 				byte *pSrc = chan->_pSrc;
+				if (!chan->_ptr1) {
+					warning("pollActiveChannel(): No data found for sound channel");
+					break;
+				}
 				if (!(*pSrc & 0x80) || (*pSrc <= 0xF0)) {
 					if (updateFlag)
 						updateActiveChannel();


Commit: 73dbec2011d9f678df1c25aa8f91d98623f94701
    https://github.com/scummvm/scummvm/commit/73dbec2011d9f678df1c25aa8f91d98623f94701
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-16T13:52:43-04:00

Commit Message:
MADS: Clean up sound driver creation switch block

Changed paths:
    engines/mads/sound.cpp



diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index 2b8bb1e..64144bb 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -47,7 +47,6 @@ void SoundManager::init(int sectionNumber) {
 
 	switch (_vm->getGameID()) {
 	case GType_RexNebular:
-		// TODO: Other Rex Adlib section drivers
 		switch (sectionNumber) {
 		case 1:
 			_driver = new Nebular::ASound1(_mixer);
@@ -73,6 +72,8 @@ void SoundManager::init(int sectionNumber) {
 		case 8:
 			_driver = new Nebular::ASound8(_mixer);
 			break;
+		case 9:
+			error("Sound driver 9 not implemented");
 		default:
 			_driver = nullptr;
 			break;


Commit: 7010bc6be492e62f3a2cdd8e6801fc6c44343486
    https://github.com/scummvm/scummvm/commit/7010bc6be492e62f3a2cdd8e6801fc6c44343486
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-16T20:57:08+03:00

Commit Message:
MADS: Some more work on scene 701

Changed paths:
    engines/mads/nebular/nebular_scenes7.cpp



diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index d288432..9e63978 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -247,10 +247,19 @@ void Scene701::actions() {
 	if (_action.isAction(VERB_LOOK, NOUN_BINOCULARS, NOUN_BUILDING) && _game._objects[OBJ_VASE]._roomNumber == 706) {
 		switch (_game._trigger) {
 		case 0:
-			// TODO
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 1, 0, 0);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[5], Common::Point(155, 129));
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			break;
-		case 1:
-			// TODO
+		case 1: {
+			int temp = _globals._sequenceIndexes[5];
+			_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, -2);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[5], Common::Point(155, 129));
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[5], temp);
+			_scene->_sequences.addTimer(15, 2);
+			}
 			break;
 		case 2:
 			_scene->_nextSceneId = 710;
@@ -259,10 +268,13 @@ void Scene701::actions() {
 	} else if (_action.isAction(VERB_STEP_INTO, NOUN_ELEVATOR)) {
 		switch (_game._trigger) {
 		case 0:
-			// TODO
+			_game._player._stepEnabled = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			// TODO: finish this
 			break;
 		case 1:
-			// TODO
+			_game._player.walk(Common::Point(22, 131), FACING_EAST);
+			_scene->_sequences.addTimer(2 * 60, 3);
 			break;
 		case 3:
 			// TODO


Commit: 3f4e4c50b9ce807aec62406c8bfeeff4ed68cb3b
    https://github.com/scummvm/scummvm/commit/3f4e4c50b9ce807aec62406c8bfeeff4ed68cb3b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-16T21:10:04+03:00

Commit Message:
MADS: Bugfix for scene 804

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes8.cpp



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index b9cf62b..fe336a6 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -280,7 +280,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 		return new DummyScene(vm);	// TODO
 	case 803:	// empty launch pad
 		return new DummyScene(vm);	// TODO
-	case 804:	// ??? (broken animation)
+	case 804:	// inside Rex's ship - cockpit
 		return new Scene804(vm);
 	case 805:	// service panel
 		return new DummyScene(vm);	// TODO
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 0be53ef..296fd74 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -123,7 +123,7 @@ void Scene804::enter() {
 			_globals._sequenceIndexes[8] = _scene->_sequences.startCycle(_globals._spriteIndexes[8], false, 1);
 
 		if (_globals[kWindowFixed] == 0)
-			_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
+			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(133, 139));


Commit: 1c54f97916ebcd8ae9921827d39cfa95a840c26e
    https://github.com/scummvm/scummvm/commit/1c54f97916ebcd8ae9921827d39cfa95a840c26e
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-16T20:38:50+02:00

Commit Message:
MADS: Implement scene 705

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes7.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index fe336a6..04c4c6e 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -259,7 +259,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 704:	// water, building in the distance
 		return new Scene704(vm);
 	case 705:	// water, outside building
-		return new DummyScene(vm);	// TODO
+		return new Scene705(vm);
 	case 706:	// inside building, pedestral room, outside teleporter
 		return new DummyScene(vm);	// TODO
 	case 707:	// teleporter
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 9e63978..6470624 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -1300,6 +1300,270 @@ void Scene704::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene705::setup() {
+	_game._player._spritesPrefix = "";
+	setAAName();
+}
+
+void Scene705::handleBottleInterface() {
+	switch (_globals[kBottleStatus]) {
+	case 0:
+		_dialog1.write(0x311, true);
+		_dialog1.write(0x312, true);
+		_dialog1.write(0x313, true);
+		_dialog1.write(0x314, true);
+		_dialog1.write(0x315, true);
+		break;
+
+	case 1:
+		_dialog1.write(0x311, false);
+		_dialog1.write(0x312, true);
+		_dialog1.write(0x313, true);
+		_dialog1.write(0x314, true);
+		_dialog1.write(0x315, true);
+		break;
+
+	case 2:
+		_dialog1.write(0x311, false);
+		_dialog1.write(0x312, false);
+		_dialog1.write(0x313, true);
+		_dialog1.write(0x314, true);
+		_dialog1.write(0x315, true);
+		break;
+
+	case 3:
+		_dialog1.write(0x311, false);
+		_dialog1.write(0x312, false);
+		_dialog1.write(0x313, false);
+		_dialog1.write(0x314, true);
+		_dialog1.write(0x315, true);
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene705::setBottleSequence() {
+	_scene->_userInterface.setup(kInputBuildingSentences);
+	_game._player._stepEnabled = false;
+	_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+	_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+	_scene->loadAnimation(formAnimName('F', -1), 90);
+}
+
+void Scene705::handleFillBottle(int quote) {
+	switch (quote) {
+	case 0x311:
+		_globals[kBottleStatus] = 1;
+		setBottleSequence();
+		break;
+
+	case 0x312:
+		_globals[kBottleStatus] = 2;
+		setBottleSequence();
+		break;
+
+	case 0x313:
+		_globals[kBottleStatus] = 3;
+		setBottleSequence();
+		break;
+
+	case 0x314:
+		_globals[kBottleStatus] = 4;
+		setBottleSequence();
+		break;
+
+	case 0x315:
+		_scene->_userInterface.setup(kInputBuildingSentences);
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene705::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('b', 0));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('b', 1));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 0));
+
+	_game._player._visible = false;
+
+	if (_scene->_priorSceneId == 706) {
+		_game._player._stepEnabled = false;
+		_globals._sequenceIndexes[3] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[3], false, 9, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 4);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._stepEnabled = false;
+		_scene->_sequences.addTimer(1, 80);
+		_vm->_sound->command(28);
+	} else
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+
+	if (_scene->_roomChanged)
+		_game._objects.addToInventory(OBJ_BOTTLE);
+
+	_game.loadQuoteSet(0x311, 0x312, 0x313, 0x314, 0x315, 0);
+	_dialog1.setup(0x98, 0x311, 0x312, 0x313, 0x314, 0x315, 0);
+	sceneEntrySound();
+}
+
+void Scene705::step() {
+	switch (_game._trigger) {
+	case 70:
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle (_globals._spriteIndexes[3], false, 9, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 4);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
+		break;
+
+	case 71: {
+		int syncIdx = _globals._sequenceIndexes[3];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], syncIdx);
+		_game._player._stepEnabled = true;
+		}
+		break;
+
+	default:
+		break;
+	}
+
+	switch (_game._trigger) {
+	case 80:
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[1], false, 9, 1, 0, 0);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 2);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 81);
+		break;
+
+	case 81: {
+		_vm->_sound->command(19);
+		int syncIdx = _globals._sequenceIndexes[1];
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], syncIdx);
+		_game._player._stepEnabled = true;
+		}
+		break;
+
+	default:
+		break;
+	}
+
+	switch (_game._trigger) {
+	case 90:
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+		_scene->_sequences.addTimer(30, 91);
+		break;
+
+	case 91:
+		switch (_globals[kBottleStatus]) {
+		case 0:
+			_vm->_dialogs->show(432);
+			break;
+
+		case 1:
+			_vm->_dialogs->show(70324);
+			break;
+
+		case 2:
+			_vm->_dialogs->show(70325);
+			break;
+
+		case 3:
+			_vm->_dialogs->show(70326);
+			break;
+
+		case 4:
+			_vm->_dialogs->show(70327);
+			break;
+
+		default:
+			break;
+		}
+		_game._player._stepEnabled = true;
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene705::actions() {
+	if (_game._screenObjects._inputMode == 1)
+		handleFillBottle(_action._activeAction._verbId);
+	else if (_action.isAction(0x3B1, 0x3B4)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[2], false, 6, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			_vm->_sound->command(18);
+			break;
+
+		case 1: {
+			int syncIdx = _globals._sequenceIndexes[2];
+			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], syncIdx);
+			_scene->_nextSceneId = 704;
+			_game._player._stepEnabled = true;
+			}
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(0x4F, 0x197)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[3], false, 6, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 16);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			break;
+
+		case 1: {
+			int syncIdx = _globals._sequenceIndexes[3];
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 16);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], syncIdx);
+			_scene->_nextSceneId = 706;
+			_game._player._stepEnabled = true;
+			}
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(0x85, 0x2E, 0x18F) || _action.isAction(VERB_PUT, 0x2E, 0x18F)) {
+		if (_globals[kBottleStatus] != 4) {
+			handleBottleInterface();
+			_dialog1.start();
+		} else
+			_vm->_dialogs->show(70323);
+	} if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x18F))
+		_vm->_dialogs->show(70511);
+	else if (_action.isAction(VERB_LOOK, 0x3B3))
+		_vm->_dialogs->show(70512);
+	else if (_action.isAction(VERB_LOOK, 0x3B4))
+		_vm->_dialogs->show(70513);
+	else if (_action.isAction(VERB_LOOK, 0x142))
+		_vm->_dialogs->show(70514);
+	else if (_action.isAction(VERB_LOOK, 0x323))
+		_vm->_dialogs->show(70515);
+	else if (_action.isAction(VERB_LOOK, 0x197))
+		_vm->_dialogs->show(70516);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene707::setup() {
 	_game._player._spritesPrefix = "";
 	// The original calls Scene7xx::setAAName()
diff --git a/engines/mads/nebular/nebular_scenes7.h b/engines/mads/nebular/nebular_scenes7.h
index 34695dd..06d5d04 100644
--- a/engines/mads/nebular/nebular_scenes7.h
+++ b/engines/mads/nebular/nebular_scenes7.h
@@ -132,6 +132,25 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene705: public Scene7xx{
+private:
+	Conversation _dialog1;
+
+	void handleFillBottle(int quote);
+	void setBottleSequence();
+	void handleBottleInterface();
+
+public:
+	Scene705(MADSEngine *vm) : Scene7xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 class Scene707: public SceneTeleporter {
 public:
 	Scene707(MADSEngine *vm) : SceneTeleporter(vm) {}


Commit: 3af6bbb397ae94bfbfceeaeab9979613d1047cbb
    https://github.com/scummvm/scummvm/commit/3af6bbb397ae94bfbfceeaeab9979613d1047cbb
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-16T22:00:29+02:00

Commit Message:
MADS: Implement scene 706

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes7.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 04c4c6e..a626bdf 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -261,7 +261,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 705:	// water, outside building
 		return new Scene705(vm);
 	case 706:	// inside building, pedestral room, outside teleporter
-		return new DummyScene(vm);	// TODO
+		return new Scene706(vm);
 	case 707:	// teleporter
 		return new Scene707(vm);
 	case 710:	// looking at pedestral room through binoculars
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 6470624..94bb7b6 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -381,7 +381,7 @@ void Scene702::actions() {
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
 		_scene->_nextSceneId = 711;
-	} else if (_action.isAction(VERB_TAKE, NOUN_BONES) && _action._mainObjectSource == 4 && (!_game._objects.isInInventory(OBJ_BONES) || _game._trigger)) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_BONES) && (_action._mainObjectSource == 4) && (!_game._objects.isInInventory(OBJ_BONES) || _game._trigger)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -420,9 +420,9 @@ void Scene702::actions() {
 		_vm->_dialogs->show(70215);
 	else if (_action.isAction(VERB_LOOK, NOUN_TELEPORTER))
 		_vm->_dialogs->show(70216);
-	else if (_action.isAction(VERB_LOOK, NOUN_BONES) && _action._mainObjectSource == 4)
+	else if (_action.isAction(VERB_LOOK, NOUN_BONES) && (_action._mainObjectSource == 4))
 		_vm->_dialogs->show(70217);
-	else if (_action.isAction(VERB_TAKE, NOUN_BONES) && _action._mainObjectSource == 4) {
+	else if (_action.isAction(VERB_TAKE, NOUN_BONES) && (_action._mainObjectSource == 4)) {
 		if (_game._objects.isInInventory(OBJ_BONES))
 			_vm->_dialogs->show(70219);
 	} else if (_action.isAction(VERB_LOOK, NOUN_SUBMERGED_CITY))
@@ -1564,6 +1564,277 @@ void Scene705::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene706::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x2E);
+	_scene->addActiveVocab(0x17D);
+	_scene->addActiveVocab(0xD);
+}
+
+void Scene706::handleRexDeath() {
+	switch (_game._trigger) {
+	case 0:
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_scene->loadAnimation(formAnimName('a', -1), 2);
+		break;
+
+	case 2:
+		if (_animationMode == 1)
+			_vm->_dialogs->show(70625);
+		else if (_globals[kBottleStatus] < 2)
+			_vm->_dialogs->show(70628);
+		else
+			_vm->_dialogs->show(70629);
+
+		_game._objects.setRoom(OBJ_VASE, _scene->_currentSceneId);
+		if (_animationMode == 2)
+			_game._objects.setRoom(OBJ_BOTTLE, 2);
+
+		_animationMode = 0;
+		_scene->_reloadSceneFlag = true;
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene706::handleTakeVase() {
+	switch (_game._trigger) {
+	case 0:
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 4, 2, 0, 0);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[3]);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 7, 1);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+		break;
+
+	case 1:
+		_vm->_sound->command(9);
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_scene->_dynamicHotspots.remove(_vaseHotspotId);
+		_game._objects.addToInventory(OBJ_VASE);
+		if (_vaseMode == 1) {
+			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 4);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(195, 99));
+			int idx = _scene->_dynamicHotspots.add(0x2E, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+			_scene->_dynamicHotspots.setPosition(idx, Common::Point(175, 124), FACING_SOUTHEAST);
+			_game._objects.setRoom(OBJ_BOTTLE, _scene->_currentSceneId);
+		}
+		break;
+
+	case 2:
+		_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[3]);
+		_game._player._visible = true;
+		_vm->_dialogs->showItem(OBJ_VASE, 70630);
+		_game._player._stepEnabled = true;
+		break;
+	}
+}
+
+void Scene706::enter() {
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RXMRC_3");
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('b', -1));
+
+	if (!_game._visitedScenes._sceneRevisited)
+		_emptyPedestral = false;
+
+	if (_game._objects[OBJ_VASE]._roomNumber == _scene->_currentSceneId) {
+		_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('v', -1));
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 4);
+		int idx = _scene->_dynamicHotspots.add(0x17D, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_vaseHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(175, 124), FACING_SOUTHEAST);
+	} else if (_game._objects.isInRoom(OBJ_BOTTLE)) {
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 4);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(195, 99));
+		int idx = _scene->_dynamicHotspots.add(0x2E, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(175, 124), FACING_SOUTHEAST);
+	}
+
+	_game._player._visible = true;
+
+	if (_scene->_priorSceneId == 707) {
+		_game._player._playerPos = Common::Point(277, 103);
+		_game._player._facing = FACING_SOUTHWEST;
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(167, 152);
+		_game._player._facing = FACING_NORTH;
+	}
+
+	if (_globals[kTeleporterCommand]) {
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+
+		switch (_globals[kTeleporterCommand]) {
+		case 1:
+			_scene->loadAnimation(formAnimName('E', 1), 75);
+			break;
+
+		case 2:
+			_scene->loadAnimation(formAnimName('E', -1), 80);
+			break;
+
+		default:
+			_game._player.walk(Common::Point(264, 116), FACING_SOUTHWEST);
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			break;
+		}
+		_globals[kTeleporterCommand] = 0;
+	}
+
+	_animationMode = 0;
+
+	if (_scene->_roomChanged) {
+		_game._objects.addToInventory(OBJ_BOTTLE);
+		_globals[kBottleStatus] = 2;
+	}
+
+	sceneEntrySound();
+}
+
+void Scene706::step() {
+	if (_game._trigger == 75) {
+		_game._player._stepEnabled = true;
+		_game._player._visible = true;
+		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+		_game._player.walk(Common::Point(264, 116), FACING_SOUTHWEST);
+	}
+
+	if (_game._trigger == 80) {
+		_globals[kTeleporterCommand] = 1;
+		_scene->_nextSceneId = _globals[kTeleporterDestination];
+		_scene->_reloadSceneFlag = true;
+	}
+
+	if (_scene->_activeAnimation != nullptr) {
+		if ((_animationMode != 0) && (_scene->_activeAnimation->getCurrentFrame() != _animationFrame)) {
+			_animationFrame = _scene->_activeAnimation->getCurrentFrame();
+
+			if (_animationFrame == 6) {
+				_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+				_game._objects.setRoom(OBJ_VASE, 2);
+
+				if (_animationMode == 2) {
+					_game._objects.setRoom(OBJ_BOTTLE, 1);
+
+					_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
+					_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 4);
+					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(195, 99));
+					int idx = _scene->_dynamicHotspots.add(0x2E, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+					_scene->_dynamicHotspots.setPosition(idx, Common::Point(175, 124), FACING_SOUTHEAST);
+				}
+			}
+		}
+	}
+}
+
+void Scene706::preActions() {
+	if (_action.isAction(VERB_LOOK, 0x46E))
+		_game._player._needToWalk = true;
+}
+
+void Scene706::actions() {
+	if (_action.isAction(0x188, 0x16C)) {
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_scene->_nextSceneId = 707;
+		_action._inProgress = false;
+		return;
+	}
+	
+	if (_action.isAction(0x298, 0x2FA)) {
+		_scene->_nextSceneId = 705;
+		_action._inProgress = false;
+		return;
+	}
+	
+	if (_action.isAction(VERB_TAKE, 0x17D)) {
+		if (_game._difficulty != DIFFICULTY_EASY) {
+			_animationMode = 1;
+			handleRexDeath();
+		} else if (_game._trigger || !_game._objects.isInInventory(OBJ_VASE)) {
+			handleTakeVase();
+			_emptyPedestral = true;
+		}
+		_action._inProgress = false;
+		return;
+	}
+	
+	if (_action.isAction(VERB_PUT, 0x2E, 0x344)) {
+		if ((_globals[kBottleStatus] == 2 && _game._difficulty == DIFFICULTY_HARD) ||
+			 (_globals[kBottleStatus] != 0 && _game._difficulty != DIFFICULTY_HARD)) {
+			if (!_game._objects.isInInventory(OBJ_VASE) || _game._trigger) {
+				_vaseMode = 1;
+				handleTakeVase();
+				_action._inProgress = false;
+				return;
+			}
+		} else if (_game._objects.isInRoom(OBJ_VASE) || _game._trigger) {
+			_animationMode = 2;
+			handleRexDeath();
+			_action._inProgress = false;
+			return;
+		}
+	}
+	
+	if (_action.isAction(VERB_PUT, 0x344) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
+		warning("Replace the next if when the function is implemented");
+		warning("if (sub_13D46(_game._objects.getIdFromDesc(_action._activeAction._objectNameId), 0xA))");
+		if (true)
+			_vm->_dialogs->show(70626);
+		else
+			_vm->_dialogs->show(70627);
+	} else if (_action.isAction(VERB_TAKE, 0x2E) && _game._objects.isInInventory(OBJ_VASE))
+		_vm->_dialogs->show(70631);
+	else if (_action._lookFlag) {
+		if (_game._objects[OBJ_VASE]._roomNumber == _scene->_currentSceneId)
+			_vm->_dialogs->show(70610);
+		else
+			_vm->_dialogs->show(70611);
+	} else if (_action.isAction(VERB_LOOK, 0x89))
+		_vm->_dialogs->show(70612);
+	else if (_action.isAction(VERB_LOOK, 0x32B))
+		_vm->_dialogs->show(70613);
+	else if (_action.isAction(VERB_LOOK, 0x46B))
+		_vm->_dialogs->show(70614);
+	else if (_action.isAction(VERB_TAKE, 0x46B))
+		_vm->_dialogs->show(70615);
+	else if (_action.isAction(VERB_LOOK, 0x46D))
+		_vm->_dialogs->show(70616);
+	else if (_action.isAction(VERB_LOOK, 0x46E))
+		_vm->_dialogs->show(70617);
+	else if (_action.isAction(VERB_LOOK, 0x46C))
+		_vm->_dialogs->show(70618);
+	else if (_action.isAction(VERB_LOOK, 0x18D))
+		_vm->_dialogs->show(70619);
+	else if (_action.isAction(VERB_LOOK, 0x344)) {
+		if (_game._objects[OBJ_VASE]._roomNumber == _scene->_currentSceneId)
+			_vm->_dialogs->show(70620);
+		else if (_game._objects[OBJ_BOTTLE]._roomNumber == _scene->_currentSceneId)
+			_vm->_dialogs->show(70622);
+		else
+			_vm->_dialogs->show(70621);
+	} else if (_action.isAction(VERB_LOOK, 0x16C))
+		_vm->_dialogs->show(70623);
+	else if (_action.isAction(VERB_LOOK, 0x17D) && (_game._objects[OBJ_VASE]._roomNumber == _scene->_currentSceneId))
+		_vm->_dialogs->show(70624);
+	else if (_action.isAction(VERB_LOOK, 0x2E) && (_action._mainObjectSource == 4))
+		_vm->_dialogs->show(70632);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene707::setup() {
 	_game._player._spritesPrefix = "";
 	// The original calls Scene7xx::setAAName()
@@ -1809,7 +2080,7 @@ void Scene752::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_TAKE, NOUN_BONES) && _action._mainObjectSource == 4 && (!_game._objects.isInInventory(OBJ_BONES) || _game._trigger)) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_BONES) && (_action._mainObjectSource == 4) && (!_game._objects.isInInventory(OBJ_BONES) || _game._trigger)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1851,12 +2122,12 @@ void Scene752::actions() {
 		_vm->_dialogs->show(75217);
 	else if (_action.isAction(VERB_LOOK, NOUN_TELEPORTER))
 		_vm->_dialogs->show(75218);
-	else if ((_action.isAction(VERB_LOOK, NOUN_BONES) || _action.isAction(VERB_LOOK, NOUN_ID_CARD)) && _action._mainObjectSource == 4) {
+	else if ((_action.isAction(VERB_LOOK, NOUN_BONES) || _action.isAction(VERB_LOOK, NOUN_ID_CARD)) && (_action._mainObjectSource == 4)) {
 		if (_game._objects[OBJ_ID_CARD]._roomNumber == 752)
 			_vm->_dialogs->show(75219);
 		else
 			_vm->_dialogs->show(75220);
-	} else if (_action.isAction(VERB_TAKE, NOUN_BONES) && _action._mainObjectSource == 4) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_BONES) && (_action._mainObjectSource == 4)) {
 		if (_game._objects.isInInventory(OBJ_BONES))
 			_vm->_dialogs->show(75222);
 	} else
diff --git a/engines/mads/nebular/nebular_scenes7.h b/engines/mads/nebular/nebular_scenes7.h
index 06d5d04..f5f9867 100644
--- a/engines/mads/nebular/nebular_scenes7.h
+++ b/engines/mads/nebular/nebular_scenes7.h
@@ -151,6 +151,29 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene706: public Scene7xx{
+private:
+	int _vaseHotspotId;
+	int _vaseMode;       // CHECKME: Use?
+	int _animationMode;
+	int _animationFrame;
+
+	bool _emptyPedestral;
+
+	void handleTakeVase();
+	void handleRexDeath();
+
+public:
+	Scene706(MADSEngine *vm) : Scene7xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 class Scene707: public SceneTeleporter {
 public:
 	Scene707(MADSEngine *vm) : SceneTeleporter(vm) {}


Commit: d590ca39d139136cf616d80beb525ff3a07acca2
    https://github.com/scummvm/scummvm/commit/d590ca39d139136cf616d80beb525ff3a07acca2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-16T18:30:41-04:00

Commit Message:
MADS: Properly implemented object quality code

Changed paths:
    engines/mads/inventory.cpp
    engines/mads/inventory.h
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes7.cpp



diff --git a/engines/mads/inventory.cpp b/engines/mads/inventory.cpp
index 79a8e87..434d284 100644
--- a/engines/mads/inventory.cpp
+++ b/engines/mads/inventory.cpp
@@ -31,16 +31,46 @@ void InventoryObject::synchronize(Common::Serializer &s) {
 	s.syncAsUint16LE(_roomNumber);
 	s.syncAsByte(_article);
 	s.syncAsByte(_vocabCount);
+	s.syncAsByte(_qualitiesCount);
+	s.skip(1);
 
-	for (int i = 0; i < 3; ++i) {
+	for (int i = 0; i < MAX_VOCAB; ++i) {
+		s.syncAsUint16LE(_vocabList[i]._vocabId);
 		s.syncAsByte(_vocabList[i]._verbType);
 		s.syncAsByte(_vocabList[i]._prepType);
-		s.syncAsUint16LE( _vocabList[i]._vocabId);
 	}
 
-	s.skip(4);	// field12
-	s.syncBytes((byte *)&_mutilateString[0], 10);
-	s.skip(16);
+	for (int i = 0; i < MAX_QUALITIES; ++i)
+		s.syncAsByte(_qualityId[i]);
+	for (int i = 0; i < MAX_QUALITIES; ++i)
+		s.syncAsSint32LE(_qualityValue[i]);
+}
+
+bool InventoryObject::hasQuality(int qualityId) const {
+	for (int i = 0; i < _qualitiesCount; ++i) {
+		if (_qualityId[i] == qualityId)
+			return true;
+	}
+
+	return false;
+}
+
+void InventoryObject::setQuality(int qualityId, int qualityValue) {
+	for (int i = 0; i < _qualitiesCount; ++i) {
+		if (_qualityId[i] == qualityId) {
+			_qualityValue[i] = qualityValue;
+		}
+	}
+}
+
+int InventoryObject::getQuality(int qualityId) const {
+	for (int i = 0; i < _qualitiesCount; ++i) {
+		if (_qualityId[i] == qualityId) {
+			return _qualityValue[i];
+		}
+	}
+
+	return 0;
 }
 
 /*------------------------------------------------------------------------*/
@@ -92,20 +122,6 @@ void InventoryObjects::synchronize(Common::Serializer &s) {
 	}
 }
 
-void InventoryObjects::setQuality(int objIndex, int id, const byte *p) {
-	// TODO: This whole method seems weird. Check it out more thoroughly once
-	// more of the engine is implemented
-	for (int i = 0; i < (int)size(); ++i) {
-		InventoryObject &obj = (*this)[i];
-		if (obj._vocabList[0]._verbType <= i)
-			break;
-
-		if (obj._mutilateString[6 + i] == id) {
-			(*this)[objIndex]._objFolder = p;
-		}
-	}
-}
-
 void InventoryObjects::setRoom(int objectId, int sceneNumber) {
 	InventoryObject &obj = (*this)[objectId];
 
diff --git a/engines/mads/inventory.h b/engines/mads/inventory.h
index 9d79431..7fb123e 100644
--- a/engines/mads/inventory.h
+++ b/engines/mads/inventory.h
@@ -35,24 +35,46 @@ enum {
 
 class MADSEngine;
 
+#define MAX_VOCAB 5
+#define MAX_QUALITIES 4
+
 class InventoryObject {
 public:
 	int _descId;
 	int _roomNumber;
 	int _article;
 	int _vocabCount;
+	int _qualitiesCount;
+	int syntax;
+
 	struct {
+		int _vocabId;
 		VerbType _verbType;
 		PrepType _prepType;
-		int _vocabId;
-	} _vocabList[3];
-	char _mutilateString[10];	// ???
-	const byte *_objFolder;		// ???
+	} _vocabList[MAX_VOCAB];
+
+	int _qualityId[MAX_QUALITIES];
+	int _qualityValue[MAX_QUALITIES];
 
 	/**
 	 * Synchronizes the data for a given object
 	 */
 	void synchronize(Common::Serializer &s);
+
+	/**
+	 * Returns true if the given object has the specified quality
+	 */
+	bool hasQuality(int qualityId) const;
+
+	/**
+	 * Sets the quality value for a given quality Id
+	 */
+	void setQuality(int qualityId, int qualityValue);
+
+	/**
+	 * Gets the quality value for a given quality Id
+	 */
+	int getQuality(int qualityId) const;
 };
 
 class InventoryObjects: public Common::Array<InventoryObject> {
@@ -85,11 +107,6 @@ public:
 	}
 
 	/**
-	 * Set the associated quality data for an inventory object
-	 */
-	void setQuality(int objIndex, int id, const byte *p);
-
-	/**
 	 * Sets an item's scene number
 	 */
 	void setRoom(int objectId, int sceneNumber);
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 600c153..1ec025c 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -98,7 +98,7 @@ void GameNebular::initialiseGlobals() {
 
 	/* Section #4 variables */
 	_globals[kBadFirstIngredient] = -1;
-	_objects.setQuality(OBJ_CHARGE_CASES, EXPLOSIVES_INSIDE, nullptr);
+	_objects[OBJ_CHARGE_CASES].setQuality(EXPLOSIVES_INSIDE, 0);
 	_globals[kHasPurchased] = false;
 	_globals[kBeenThruHelgaScene] = false;
 	_globals[kNextIngredient] = 0;
@@ -394,8 +394,7 @@ void GameNebular::doObjectAction() {
 			dialogs.showItem(id, 402);
 		} else {
 			int messageId = 800 + id;
-			if (id == OBJ_CHARGE_CASES) {
-				error("TODO: object_get_folder - loc_29B48");
+			if ((id == OBJ_CHARGE_CASES) && _objects[OBJ_CHARGE_CASES].getQuality(3) != 0) {
 				messageId = 860;
 			}
 
@@ -435,7 +434,14 @@ void GameNebular::doObjectAction() {
 		dialogs.show(_globals[kTopButtonPushed] ? 502 : 501);
 	} else if ((action.isAction(25, 106, 72) || action.isAction(VERB_PUT, 106, 72)) &&
 			_objects.isInInventory(OBJ_DETONATORS) && _objects.isInInventory(OBJ_CHARGE_CASES)) {
-		error("TODO: loc_29DBA");
+		if (_objects[OBJ_CHARGE_CASES].getQuality(3)) {
+			_objects.setRoom(OBJ_CHARGE_CASES, 1);
+			_objects.setRoom(OBJ_DETONATORS, 1);
+			_objects.addToInventory(OBJ_BOMBS);
+			dialogs.showItem(OBJ_BOMBS, 403);
+		} else {
+			dialogs.show(405);
+		}
 	} else if (action.isAction(25, 106)) {
 		dialogs.show(470);
 	} else if ((action.isAction(25, 371, 43) || action.isAction(7, 371, 43) || action.isAction(25, 371, 42)
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index 91c522c..e8e9596 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -3513,8 +3513,7 @@ void Scene411::enter() {
 	_dialog3.setup(0x5D, 0x254, 0x260, 0x25C, 0x258, 0x262, -1);
 	_dialog4.setup(0x5E, 0x255, 0x261, 0x25D, 0x259, 0x262, -1);
 
-	warning("TODO: Replace the next line by: if ((_globals[kNextIngredient] >= 4) && (!object_get_folder(OBJ_CHARGE_CASES, 3))) {");
-	if (_globals[kNextIngredient] >= 4) {
+	if (_globals[kNextIngredient] >= 4 && _game._objects[OBJ_CHARGE_CASES].getQuality(3)) {
 		_scene->_hotspots.activate(0x3AB, false);
 		_scene->_hotspots.activate(0x30D, true);
 	} else {
@@ -3522,11 +3521,9 @@ void Scene411::enter() {
 		_scene->_hotspots.activate(0x3AB, true);
 	}
 
-	warning("TODO: Replace the next line by: if ((!_globals[kNextIngredient] >= 4) && (object_get_folder(OBJ_CHARGE_CASES, 3))) {");
-	if (!(_globals[kNextIngredient] >= 4))
+	if (_globals[kNextIngredient] >= 4 && _game._objects[OBJ_CHARGE_CASES].getQuality(3)) {
 		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], true, 6);
-	else if (true) {
-		warning("TODO: The previous if was: else if (!object_get_folder(OBJ_CHARGE_CASES, 3)) {");
+	} else if (!_game._objects[OBJ_CHARGE_CASES].getQuality(3)) {
 		switch (_globals[kNextIngredient]) {
 		case 1:
 			_vm->_sound->command(53);
@@ -3559,8 +3556,7 @@ void Scene411::enter() {
 		}
 	}
 
-	warning("TODO: Replace the next if by: if ((_globals[kNextIngredient] >= 4) && (object_get_folder(OBJ_CHARGE_CASES, 3))) {");
-	if (_globals[kNextIngredient] >= 4) {
+	if (_globals[kNextIngredient] >= 4 && _game._objects[OBJ_CHARGE_CASES].getQuality(3)) {
 		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], true, 6);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
 	}
@@ -3722,9 +3718,9 @@ void Scene411::actions() {
 		return;
 	}
 
-	warning("TODO: add the following condition to the if statement: (!object_get_folder(OBJ_CHARGE_CASES, 3)) &&");
-	if ((_globals[kNextIngredient] >= 4) && (_action.isAction(VERB_TAKE, 0x3AB) || _action.isAction(VERB_PUT, 0x48, 0x3AB)) &&
-		(_game._objects.isInInventory(OBJ_CHARGE_CASES))) {
+	if ((_globals[kNextIngredient] >= 4) && (_action.isAction(VERB_TAKE, 0x3AB) || _action.isAction(VERB_PUT, 0x48, 0x3AB)) 
+			&& !_game._objects[OBJ_CHARGE_CASES].getQuality(3) 
+			&& _game._objects.isInInventory(OBJ_CHARGE_CASES)) {
 		switch (_game._trigger) {
 		case 0:
 			_vm->_sound->command(10);
@@ -3764,7 +3760,7 @@ void Scene411::actions() {
 			_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
 			_game._player._visible = true;
 			_game._player._stepEnabled = true;
-			warning("TODO: InventoryObjects_setData(OBJ_CHARGE_CASES, 3, true);");
+			_game._objects[OBJ_CHARGE_CASES].setQuality(3, 1);
 			_vm->_dialogs->showItem(OBJ_CHARGE_CASES, 41142);
 			break;
 		}
@@ -3927,15 +3923,12 @@ void Scene411::actions() {
 	else if ((_action.isAction(VERB_LOOK, 0x3A9)) && (_game._objects.isInRoom(OBJ_LECITHIN)))
 		_vm->_dialogs->show(41123);
 	else if (_action.isAction(VERB_LOOK, 0x30D)) {
-		if (_globals[kNextIngredient] > 0) {
-			warning("TODO: the if statement should be: if ((_globals[kNextIngredient] > 0) && !object_get_folder(OBJ_CHARGE_CASES, 3))");
+		if (_globals[kNextIngredient] > 0 && !_game._objects[OBJ_CHARGE_CASES].getQuality(3)) {
 			_vm->_dialogs->show(41126);
-		} else if (_globals[kNextIngredient] == 0) {
-			warning("TODO: the if statement should be: else if ((_globals[kNextIngredient] == 0) || object_get_folder(OBJ_CHARGE_CASES, 3)) {");
+		} else if (_globals[kNextIngredient] == 0 || _game._objects[OBJ_CHARGE_CASES].getQuality(3)) {
 			_vm->_dialogs->show(41125);
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x3AB)) {
-		warning("TODO: The if statement should be if (_action.isAction(VERB_LOOK, 0x3AB) && !object_get_folder(OBJ_CHARGE_CASES, 3)) {");
+	} else if (_action.isAction(VERB_LOOK, 0x3AB) && _game._objects[OBJ_CHARGE_CASES].getQuality(3) == 0) {
 		_vm->_dialogs->show(41127);
 	} else if (_action.isAction(VERB_TAKE, 0x30D))
 		_vm->_dialogs->show(41128);
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 94bb7b6..385141d 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -1785,9 +1785,8 @@ void Scene706::actions() {
 	}
 	
 	if (_action.isAction(VERB_PUT, 0x344) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
-		warning("Replace the next if when the function is implemented");
-		warning("if (sub_13D46(_game._objects.getIdFromDesc(_action._activeAction._objectNameId), 0xA))");
-		if (true)
+		int objectId = _game._objects.getIdFromDesc(_action._activeAction._objectNameId);
+		if (_game._objects[objectId].hasQuality(10))
 			_vm->_dialogs->show(70626);
 		else
 			_vm->_dialogs->show(70627);


Commit: 5d62f6bb296ffd7dd62b0e75ccaa5df776bdc13b
    https://github.com/scummvm/scummvm/commit/5d62f6bb296ffd7dd62b0e75ccaa5df776bdc13b
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-17T00:37:55+02:00

Commit Message:
MADS: Implement scene 751

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes7.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index a626bdf..958c3dd 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -269,7 +269,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 711:	// inside teleporter
 		return new Scene711(vm);
 	case 751:	// outside elevator (before city is submerged)
-		return new DummyScene(vm);	// TODO
+		return new Scene751(vm);
 	case 752:	// outside teleporter (before city is submerged)
 		return new Scene752(vm);
 
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 385141d..1ce9566 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -1413,7 +1413,7 @@ void Scene705::enter() {
 void Scene705::step() {
 	switch (_game._trigger) {
 	case 70:
-		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle (_globals._spriteIndexes[3], false, 9, 1, 0, 0);
+		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 9, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 4);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
 		break;
@@ -1432,7 +1432,7 @@ void Scene705::step() {
 
 	switch (_game._trigger) {
 	case 80:
-		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[1], false, 9, 1, 0, 0);
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 9, 1, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 2);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 81);
 		break;
@@ -1497,7 +1497,7 @@ void Scene705::actions() {
 		case 0:
 			_game._player._stepEnabled = false;
 			_scene->_sequences.remove(_globals._sequenceIndexes[3]);
-			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[2], false, 6, 1, 0, 0);
+			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 1, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 2);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			_vm->_sound->command(18);
@@ -1521,7 +1521,7 @@ void Scene705::actions() {
 		case 0:
 			_game._player._stepEnabled = false;
 			_scene->_sequences.remove(_globals._sequenceIndexes[3]);
-			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[3], false, 6, 1, 0, 0);
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 1, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 16);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			break;
@@ -1973,6 +1973,331 @@ void Scene711::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene751::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x87);
+	_scene->addActiveVocab(0xD);
+}
+
+void Scene751::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites("*RM701X0");
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 0));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('f', 0));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RM202A1");
+
+	if (!_game._visitedScenes._sceneRevisited)
+		_rexHandingLine = false;
+
+	if (_globals[kLineStatus] == 2 || _globals[kLineStatus] == 3) {
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 7);
+		int idx = _scene->_dynamicHotspots.add(0x87, 0xD, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(268, 140), FACING_NORTHWEST);
+	}
+
+	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
+
+	if (_scene->_priorSceneId == 752) {
+		_game._player._playerPos = Common::Point(309, 138);
+		_game._player._facing = FACING_WEST;
+	} else if (_scene->_priorSceneId == 710) {
+		_game._player._playerPos = Common::Point(154, 129);
+		_game._player._facing = FACING_NORTH;
+		_game._player._visible = false;
+		_game._player._stepEnabled = false;
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, -2);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(155, 129));
+		_scene->_sequences.addTimer(15, 70);
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(22, 131);
+		_game._player._facing = FACING_EAST;
+		_game._player._stepEnabled = false;
+		_scene->_sequences.addTimer(60, 60);
+	} else if (_rexHandingLine) {
+		_game._player._visible = false;
+		_game._player._playerPos = Common::Point(268, 140);
+		_game._player._facing = FACING_NORTHWEST; 
+		_game._player._visible = false;
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 7);
+		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+	} else if (_globals[kLineStatus] == 2) {
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 7);
+		int idx = _scene->_dynamicHotspots.add(0x87, 0xD, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(268, 140), FACING_NORTHWEST);
+	}
+
+	if (_scene->_roomChanged) {
+		_game._objects.addToInventory(OBJ_FISHING_LINE);
+		_game._objects.addToInventory(OBJ_BINOCULARS);
+	}
+
+	sceneEntrySound();
+	_game.loadQuoteSet(0x30A, 0x30B, 0x30C, 0x30D, 0x30E, 0);
+
+	if (_globals[kTimebombTimer] > 0)
+		_globals[kTimebombTimer] = 10200;
+}
+
+void Scene751::step() {
+	switch (_game._trigger) {
+	case 70:
+		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+		_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 6, 1, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(155, 129));
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
+		break;
+
+	case 71:
+		_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[4]);
+		_game._player._visible = true;
+		_game._player._stepEnabled = true;
+		break;
+
+	default:
+		break;
+	}
+
+	if ((_globals[kTimebombTimer] >= 10800) && (_globals[kTimebombStatus] == 1)) {
+		_globals[kTimebombStatus] = 3;
+		_globals[kTimebombTimer] = 0;
+		_globals[kCheckDaemonTimebomb] = false;
+		_scene->_nextSceneId = 620;
+	}
+
+	switch (_game._trigger) {
+	case 60:
+		_vm->_sound->command(16);
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 1, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 61);
+		break; 
+
+	case 61:
+		_game._player.walk(Common::Point(61, 131), FACING_EAST);
+		_scene->_sequences.addTimer(120, 62);
+		break;
+
+	case 62:
+		_vm->_sound->command(17);
+		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 5, 1, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 63);
+		break; 
+
+	case 63:
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1); 
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
+		_game._player._stepEnabled = true;
+		_scene->_kernelMessages.reset();
+		break;
+
+	default:
+		break;
+	}
+}
+
+void Scene751::preActions() {
+	if (_action.isAction(VERB_LOOK, 0x470))
+		_game._player.walk(Common::Point(154, 129), FACING_NORTHEAST);
+
+	if (_action.isAction(VERB_LOOK, 0x27, 0x470))
+		_game._player.walk(Common::Point(154, 129), FACING_NORTH);
+
+	if (_action.isAction(VERB_WALKTO, 0x4AA))
+		_game._player._walkOffScreenSceneId = 752;
+
+	if (!_rexHandingLine)
+		return;
+
+	if (_action.isAction(VERB_LOOK) || _action.isAction(0x87) || _action.isAction(VERB_TALKTO))
+		_game._player._needToWalk = false;
+
+	if ((!_action.isAction(VERB_PUT, 0x87, 0x467) || !_action.isAction(0x170, 0x87, 0x467) || !_action.isAction(0x19, 0x87, 0x467))
+	&& (_game._player._needToWalk)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._readyToWalk = false;
+			_game._player._stepEnabled = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 11, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, 7);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			break;
+
+		case 1:
+			_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[2]);
+			_game._player._visible = true;
+			_rexHandingLine = false;
+			_game._player._stepEnabled = true;
+			_game._player._readyToWalk = true; 
+			break;
+
+		default:
+			break;
+		} 
+	}
+}
+
+void Scene751::actions() {
+	if (_action.isAction(0x312, 0x22C))
+		; // Nothing
+	else if (_action.isAction(VERB_LOOK, 0x27, 0x470)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_game._player._visible = false;
+			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6, 1, 0, 0);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(155, 129));
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			break;
+
+		case 1: {
+			int syncIdx = _globals._sequenceIndexes[4];
+			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, -2);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(155, 129));
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], syncIdx);
+			_scene->_sequences.addTimer(15, 2);
+			}
+			break;
+
+		case 2:
+			_scene->_nextSceneId = 710;
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(0x2F9, 0x317)) { 
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_vm->_sound->command(16);
+			_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 1, 0, 0);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x30D));
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+			break;
+
+		case 1:
+			_game._player.walk(Common::Point(22, 131), FACING_EAST); 
+			_scene->_sequences.addTimer(120, 3);
+			break;
+
+		case 3:
+			_vm->_sound->command(17);
+			_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 5, 1, 0, 0);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 4);
+			break;
+
+		case 4:
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1); 
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
+			_scene->_sequences.addTimer(60, 5);
+			break;
+
+		case 5:
+			_game._player._stepEnabled = true;
+			_scene->_nextSceneId = 513;
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(VERB_PUT, 0x87, 0x467) || _action.isAction(0x170, 0x87, 0x467) || _action.isAction(0x19, 0x87, 0x467)) {
+		if (_globals[kLineStatus] == 1) {
+			switch (_game._trigger) {
+			case 0:
+				_game._player._visible = false;
+				_game._player._stepEnabled = false;
+				_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, 6);
+				_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], -1);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
+				break;
+
+			case 1: {
+				int syncIdx = _globals._sequenceIndexes[2];
+				_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 7);
+				_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], syncIdx);
+				_scene->_sequences.addTimer(30, 2);
+				}
+				break;
+
+			case 2:
+				_rexHandingLine = true;
+				_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+				_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 8, -2);
+				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
+				break;
+
+			case 3: {
+				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[2]);
+				_game._player._visible = true;
+				_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -1);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 7);
+				int idx = _scene->_dynamicHotspots.add(0x87, 0xD, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+				_scene->_dynamicHotspots.setPosition(idx, Common::Point(268, 140), FACING_NORTHWEST);
+				_scene->_kernelMessages.reset();
+				_game._objects.setRoom(OBJ_FISHING_LINE, _scene->_currentSceneId);
+				_rexHandingLine = false;
+				_globals[kLineStatus] = 2;
+				_game._player._stepEnabled = true;
+				_vm->_dialogs->show(75120);
+				}
+				break;
+
+			default:
+				break;
+			}
+		}
+	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x38F))
+		_vm->_dialogs->show(75110);
+	else if (_action.isAction(VERB_LOOK, 0x317))
+		_vm->_dialogs->show(75112);
+	else if (_action.isAction(VERB_LOOK, 0x22C))
+		_vm->_dialogs->show(75113);
+	else if (_action.isAction(VERB_LOOK, 0x316))
+		_vm->_dialogs->show(75114);
+	else if ((_action.isAction(VERB_LOOK, 0x467) || _action.isAction(VERB_LOOK, 0x87)) 
+		&& (_globals[kLineStatus] == 2 || _globals[kLineStatus] == 3))
+		_vm->_dialogs->show(75116);
+	else if (_action.isAction(VERB_LOOK, 0x467))
+		_vm->_dialogs->show(75115);
+	else if (_action.isAction(VERB_LOOK, 0x128))
+		_vm->_dialogs->show(75117);
+	else if (_action.isAction(VERB_TAKE, 0x128))
+		_vm->_dialogs->show(75118);
+	else if (_action.isAction(VERB_LOOK, 0x4AA))
+		_vm->_dialogs->show(75119);
+	else if (_action.isAction(VERB_TAKE, 0x87) && (_globals[kLineStatus] == 3 || _globals[kLineStatus] == 2))
+		_vm->_dialogs->show(75121);
+	else if (_action.isAction(VERB_LOOK, 0x470))
+		_vm->_dialogs->show(75122);
+	else if (_action.isAction(0x170, 0x87, 0x316) || _action.isAction(0x19, 0x87, 0x316))
+		_vm->_dialogs->show(75123);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene752::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
diff --git a/engines/mads/nebular/nebular_scenes7.h b/engines/mads/nebular/nebular_scenes7.h
index f5f9867..6b128db 100644
--- a/engines/mads/nebular/nebular_scenes7.h
+++ b/engines/mads/nebular/nebular_scenes7.h
@@ -204,6 +204,21 @@ public:
 	virtual void actions();
 };
 
+class Scene751: public Scene7xx{
+private:
+	bool _rexHandingLine;
+
+public:
+	Scene751(MADSEngine *vm) : Scene7xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 class Scene752: public Scene7xx {
 private:
 	int _cardId;


Commit: 622f97244df3f6bf80c86c4452f064bee8871e3d
    https://github.com/scummvm/scummvm/commit/622f97244df3f6bf80c86c4452f064bee8871e3d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-16T23:02:35-04:00

Commit Message:
MADS: In progress framework for on-screen random messages

Changed paths:
    engines/mads/messages.cpp
    engines/mads/messages.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes3.cpp



diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index e498ab9..8ec6350 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -36,6 +36,9 @@ KernelMessages::KernelMessages(MADSEngine *vm): _vm(vm) {
 	}
 
 	_talkFont = _vm->_font->getFont(FONT_CONVERSATION);
+
+	_randomMaxMessages = 0;
+	resetRandomMessages();
 }
 
 KernelMessages::~KernelMessages() {
@@ -138,7 +141,7 @@ void KernelMessages::reset() {
 		remove(i);
 
 	_talkFont = _vm->_font->getFont(FONT_CONVERSATION);
-	warning("TODO: KernelMessages::reset - sub_20454");
+	resetRandomMessages();
 }
 
 void KernelMessages::update() {
@@ -303,6 +306,46 @@ void KernelMessages::setQuoted(int msgIndex, int numTicks, bool quoted) {
 	}
 }
 
+void KernelMessages::resetRandomMessages() {
+	for (int i = 0; i < RANDOM_MESSAGE_SIZE; ++i) {
+		_randomMessages[i]._handle = -1;
+		_randomMessages[i]._quote = -1;
+	}
+}
+
+#define RANDOM_MESSAGE_TRIGGER 240
+
+void KernelMessages::randomServer() {
+	if ((_vm->_game->_trigger >= RANDOM_MESSAGE_TRIGGER) &&
+		(_vm->_game->_trigger <  (RANDOM_MESSAGE_TRIGGER + _randomMaxMessages))) {
+		_randomMessages[_vm->_game->_trigger - RANDOM_MESSAGE_TRIGGER]._handle = -1;
+		_randomMessages[_vm->_game->_trigger - RANDOM_MESSAGE_TRIGGER]._quote = -1;
+	}
+}
+
+int KernelMessages::checkRandom() {
+	int total = 0;
+
+	for (int i = 0; i < _randomMaxMessages; ++i) {
+		if (_randomMessages[i]._handle >= 0)
+			++total;
+	}
+	
+	return total;
+}
+
+bool KernelMessages::generateRandom(int major, int minor) {
+	// TODO
+	return false;
+}
+
+void KernelMessages::initRandomMessages(int maxSimultaneousMessages,
+		const Common::Rect &bounds, int minYSpacing, int scrollRate,
+		int color, int duration, int quoteId, ...) {
+	// TODO
+}
+
+
 /*------------------------------------------------------------------------*/
 
 TextDisplay::TextDisplay() {
diff --git a/engines/mads/messages.h b/engines/mads/messages.h
index 8aa8cd5..7211598 100644
--- a/engines/mads/messages.h
+++ b/engines/mads/messages.h
@@ -34,6 +34,7 @@ namespace MADS {
 #define KERNEL_MESSAGES_SIZE 10
 #define INDEFINITE_TIMEOUT 9999999
 #define TEXT_DISPLAY_SIZE 40
+#define RANDOM_MESSAGE_SIZE 4
 
 enum KernelMessageFlags {
 	KMSG_QUOTED = 1, KMSG_PLAYER_TIMEOUT = 2, KMSG_SEQ_ENTRY = 4, KMSG_SCROLL = 8,
@@ -67,9 +68,19 @@ public:
 class KernelMessages {
 private:
 	MADSEngine *_vm;
+
+	struct RandomEntry {
+		int _handle;
+		int _quote;
+	};
+	RandomEntry _randomMessages[RANDOM_MESSAGE_SIZE];
+	int _randomMaxMessages;
+
+	void resetRandomMessages();
 public:
 	Common::Array<KernelMessage> _entries;
 	Font *_talkFont;
+public:	
 	KernelMessages(MADSEngine *vm);
 	~KernelMessages();
 
@@ -85,6 +96,25 @@ public:
 	void processText(int msgIndex);
 	void delay(uint32 priorFrameTime, uint32 currentTime);
 	void setQuoted(int msgIndex, int numTicks, bool quoted);
+
+	void initRandomMessages(int maxSimultaneousMessages,
+		const Common::Rect &bounds, int minYSpacing, int scrollRate,
+		int color, int duration, int quoteId, ...);
+
+	/**
+	 * Handles expiring any active random messages as necessary
+	 */
+	void randomServer();
+
+	/**
+	 * Return the number of currently active random messages
+	 */
+	int checkRandom();
+
+	/**
+	 * Handles generating new random messages
+	 */
+	bool generateRandom(int major, int minor);
 };
 
 class TextDisplay {
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index a86b78f..1f5200a 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1174,7 +1174,9 @@ void Scene205::enter() {
 	_chickenTime = _vm->_game->_scene._frameStartTime;
 
 	if (_globals[kSexOfRex] == SEX_FEMALE)
-		warning("sub71704(0x3, 0xC3, 0x108, 0x63, 0x86, 0xD, 2, 0xFDFC, 0x3C, 0x6C, 0x6C, 0x6D, 0x6D, 0x6E, 0x6E, 0x6F, 0x6C, 0);");
+		_scene->_kernelMessages.initRandomMessages(3,
+			Common::Rect(195, 99, 264, 134), 13, 2, 0xFDFC, 60,
+			108, 108, 109, 109, 110, 110, 111, 108, 0);
 
 	if (_scene->_priorSceneId != -2)
 		_game._player._playerPos = Common::Point(99, 152);
@@ -1196,13 +1198,18 @@ void Scene205::enter() {
 }
 
 void Scene205::step() {
+	int chanceMajor, chanceMinor;
+
 	if (_globals[kSexOfRex] == SEX_FEMALE) {
-		warning("TODO: sub7178C()");
+		_scene->_kernelMessages.randomServer();
 
 		if (_vm->_game->_scene._frameStartTime >= _chickenTime) {
-			warning("TODO: if (sub717B2(100, 1 + sub7176C())) {");
-			_vm->_sound->command(28);
-			//	 }
+			chanceMajor = 100;
+			chanceMinor = _scene->_kernelMessages.checkRandom() + 1;
+
+			if (_scene->_kernelMessages.generateRandom(chanceMajor, chanceMinor))
+				_vm->_sound->command(28);
+
 			_chickenTime = _vm->_game->_scene._frameStartTime + 2;
 		}
 	}
@@ -4553,7 +4560,9 @@ void Scene211::enter() {
 	_game.loadQuoteSet(0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 1, 0);
 
 	if (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY)
-		warning("sub71704(0x2, 0x0, 0x36, 0x0, 0x1E, 0xD, 2, 0xFDFC, 0x3C, 0x97, 0x98, 0x99, 0x9A, 0);");
+		_scene->_kernelMessages.initRandomMessages(2,
+			Common::Rect(0, 0, 54, 30), 13, 2, 0xFDFC, 60,
+			151, 152, 153, 154, 0);
 
 	_monkeyTime = _vm->_game->_scene._frameStartTime;
 	_scrollY = 30;
@@ -4565,13 +4574,18 @@ void Scene211::enter() {
 }
 
 void Scene211::step() {
+	int chanceMajor, chanceMinor;
+
 	if (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY) {
-		warning("TODO: sub7178C()");
+		_scene->_kernelMessages.randomServer();
 
 		if (!_ambushFl && !_wakeFl && (_vm->_game->_scene._frameStartTime >= _monkeyTime)) {
-			warning("if (sub717B2(80, 1 + sub7176C())) {");
+			chanceMajor = 80;
+			chanceMinor = _scene->_kernelMessages.checkRandom() * 4 + 1;
+
+			if (_scene->_kernelMessages.generateRandom(chanceMajor, chanceMinor))
 				_vm->_sound->command(18);
-			// }
+
 			_monkeyTime = _vm->_game->_scene._frameStartTime + 2;
 		}
 
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index aca9b8b..4652c51 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -5536,7 +5536,9 @@ void Scene389::enter() {
 	else {
 		_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('m', -1));
 		_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 6, 0, 0, 0);
-		warning("TODO: sub71704(1, 88, 177, 19, 17, 0xD, 2, 0xFDFC, 0x3C, 0xF7, 0xF8, 0xF9, 0);");
+		_scene->_kernelMessages.initRandomMessages(1,
+			Common::Rect(88, 19, 177, 77), 13, 2, 0xFDFC, 60,
+			247, 248, 249, 0);
 	}
 
 	_vm->_palette->setEntry(252, 63, 37, 26);
@@ -5548,10 +5550,13 @@ void Scene389::enter() {
 }
 
 void Scene389::step() {
-	warning("TODO: sub7178C()");
-
+	int chanceMajor, chanceMinor;
+	
+	_scene->_kernelMessages.randomServer();
 	if (_scene->_frameStartTime >= _monsterTime) {
-		warning("sub717B2(20, (sub7176C() << 2) + 1);");
+		chanceMajor = 20;
+		chanceMinor = _scene->_kernelMessages.checkRandom() * 4 + 1;
+		_scene->_kernelMessages.generateRandom(chanceMajor, chanceMinor);
 		_monsterTime = _scene->_frameStartTime + 2;
 	}
 }


Commit: dc1d78e8ad86bc608064cc4c3daf54247a1ccee2
    https://github.com/scummvm/scummvm/commit/dc1d78e8ad86bc608064cc4c3daf54247a1ccee2
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-17T09:52:21+02:00

Commit Message:
MADS: Implement scene 801

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/nebular/nebular_scenes8.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 958c3dd..d8eadc1 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -275,7 +275,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 
 	// Scene group #8
 	case 801:	// control room, outside teleporter
-		return new DummyScene(vm);	// TODO
+		return new Scene801(vm);
 	case 802:	// launch pad with destroyed ship
 		return new DummyScene(vm);	// TODO
 	case 803:	// empty launch pad
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 296fd74..13ab001 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -11,7 +11,7 @@
 
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  * GNU General Public License for more details.
 
  * You should have received a copy of the GNU General Public License
@@ -76,6 +76,230 @@ void Scene8xx::sceneEntrySound() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene801::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene801::enter() {
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 0));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 2));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 3));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('a', -1));
+
+	if (_scene->_priorSceneId != 802) {
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 5);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 13);
+	}
+
+	if ((_globals[kCameFromCut]) && (_globals[kCutX] != 0)) {
+		_game._player._playerPos = Common::Point(_globals[kCutX], _globals[kCutY]);
+		_game._player._facing = (Facing)_globals[kCutFacing];
+		_globals[kCutX] = 0;
+		_globals[kCameFromCut] = false;
+		_globals[kReturnFromCut] = false;
+		_globals[kBeamIsUp] = false;
+		_globals[kForceBeamDown] = false;
+		_globals[kDontRepeat] = false;
+	} else if (_scene->_priorSceneId == 808) {
+		_game._player._playerPos = Common::Point(148, 110);
+		_game._player._facing = FACING_NORTH;
+	} else if (_scene->_priorSceneId == 802) {
+		_game._player._playerPos = Common::Point(307, 111);
+		_game._player.walk(Common::Point(270, 118), FACING_WEST);
+		_game._player._visible = true;
+	} else if ((_scene->_priorSceneId != -2) && !_globals[kTeleporterCommand]) {
+		_game._player._playerPos = Common::Point(8, 117);
+		_game._player.walk(Common::Point(41, 115), FACING_EAST);
+		_game._player._visible = true;
+	}
+
+	_globals[kBetweenRooms] = false;
+
+	if (_globals[kTeleporterCommand]) {
+		_game._player._stepEnabled = false;
+		switch (_globals[kTeleporterCommand]) {
+		case 1:
+			_game._player._playerPos = Common::Point(8, 117);
+			_globals[kTeleporterUnderstood] = true;
+			_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 13);
+			_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 75);
+			_vm->_sound->command(30);
+			break;
+
+		case 2:
+			_game._player._playerPos = Common::Point(8, 117);
+			_globals[kTeleporterUnderstood] = true;
+			_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 13);
+			_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 8090);
+			_vm->_sound->command(30);
+			break;
+
+		case 3:
+		case 4:
+			_game._player._playerPos = Common::Point(8, 117);
+			_game._player.walk(Common::Point(41, 115), FACING_EAST);
+			_game._player._visible = true;
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+		_globals[kTeleporterCommand] = 0;
+	}
+
+	_walkThroughDoor = false;
+	if (_scene->_priorSceneId == 802) {
+		_game._player._stepEnabled = false;
+		_walkThroughDoor = true;
+	}
+
+	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 11, 0, 0, 0);
+	_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -1, -2);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 14);
+
+	_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 9, 0, 0, 0);
+	_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], -1, -2);
+	_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 14);
+
+	sceneEntrySound();
+}
+
+void Scene801::step() {
+	if (_game._trigger == 75) {
+		if (_globals[kSexOfRex] == REX_FEMALE) {
+			_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 8, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 8);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 140);
+		} else {
+			_game._player._stepEnabled = true;
+			_game._player._visible = true;
+			_game._player._playerPos = Common::Point(8, 117);
+			_game._player.walk(Common::Point(41, 115), FACING_EAST);
+		}
+	}
+
+	if (_game._trigger == 140) {
+		_vm->_sound->command(27);
+		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 8);
+		_scene->_sequences.addTimer(100, 141);
+	}
+
+	if (_game._trigger == 141) {
+		_scene->_reloadSceneFlag = true;
+		_scene->_nextSceneId = _scene->_priorSceneId;
+		_globals[kTeleporterCommand] = 0;
+	}
+
+	if (_game._trigger == 80) {
+		_globals[kTeleporterCommand] = 1;
+		_scene->_nextSceneId = _globals[kTeleporterDestination];
+		_scene->_reloadSceneFlag = true;
+	}
+
+	if (_walkThroughDoor && (_game._player._playerPos == Common::Point(270, 118))) {
+		_game._player._stepEnabled = false;
+		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 4, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 5);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 10);
+		_walkThroughDoor = false;
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 120);
+	}
+
+	if (_game._trigger == 120) {
+		_vm->_sound->command(12);
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 5);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 10);
+		_game._player._stepEnabled = true;
+	}
+
+	if (_game._trigger == 90) {
+		_game._player.walk(Common::Point(307, 111), FACING_EAST);
+		_scene->_sequences.addTimer(80, 130);
+	}
+
+	if (_game._trigger == 130) {
+		_vm->_sound->command(12);
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 4, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 5);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 10);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 110);
+	}
+
+	if (_game._trigger == 110) {
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 5);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 10);
+		_scene->_nextSceneId = 802;
+	}
+}
+
+void Scene801::preActions() {
+	if (_action.isAction(VERB_LOOK, 0x59)) {
+		_game._player.walk(Common::Point(148, 110), FACING_NORTH);
+		_game._player._needToWalk = true;
+		_game._player._readyToWalk = true;
+	}
+
+	if (_action.isAction(0x188, 0x16C) && _globals[kBeamIsUp]) {
+		_globals[kCutX] = _game._player._playerPos.x;
+		_globals[kCutY] = _game._player._playerPos.y;
+		_globals[kCutFacing] = _game._player._facing;
+		_globals[kForceBeamDown] = true;
+		_globals[kDontRepeat] = true;
+		_scene->_nextSceneId = 803;
+	}
+}
+
+void Scene801::actions() {
+	if (_action.isAction(VERB_LOOK, 0x59))
+		_scene->_nextSceneId = 808;
+	else if (_action.isAction(0x188, 0x16C)) {
+		_game._player._stepEnabled = false;
+		_game._player._visible = false;
+		_scene->_nextSceneId = 807;
+	} else if (_action.isAction(0x18B, 0x6E) && (_game._player._playerPos == Common::Point(270, 118))) {
+		_game._player._stepEnabled = false;
+		_game._player._facing = FACING_EAST;
+		_game._player.selectSeries();
+		_globals[kBetweenRooms] = true;
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+		_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 4, 1, 0, 0);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 90);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 5);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 13);
+		_vm->_sound->command(11);
+	} else if (_action.isAction(VERB_LOOK, 0x46))
+		_vm->_dialogs->show(80110);
+	else if (_action.isAction(VERB_LOOK, 0xE2))
+		_vm->_dialogs->show(80111);
+	else if (_action.isAction(VERB_LOOK, 0x16C))
+		_vm->_dialogs->show(80112);
+	else if (_action.isAction(VERB_LOOK, 0x2C7) || _action._lookFlag)
+		_vm->_dialogs->show(80113);
+	else if (_action.isAction(VERB_LOOK, 0x390))
+		_vm->_dialogs->show(80114);
+	else if (_action.isAction(VERB_LOOK, 0x391))
+		_vm->_dialogs->show(80115);
+	else if (_action.isAction(VERB_LOOK, 0x18D))
+		_vm->_dialogs->show(80116);
+	else if (_action.isAction(VERB_LOOK, 0x6E))
+		_vm->_dialogs->show(80117);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene804::setup() {
 	Scene8xx::setPlayerSpritesPrefix();
 	Scene8xx::setAAName();
@@ -297,7 +521,7 @@ void Scene804::step() {
 		_scene->_nextSceneId = 803;
 	}
 
-	if ((_scene->_activeAnimation->getCurrentFrame() == 72) && !_alreadyPop)  {
+	if ((_scene->_activeAnimation->getCurrentFrame() == 72) && !_alreadyPop) {
 		_vm->_sound->command(21);
 		_alreadyPop = true;
 	}
diff --git a/engines/mads/nebular/nebular_scenes8.h b/engines/mads/nebular/nebular_scenes8.h
index 1ea2959..8ba55d6 100644
--- a/engines/mads/nebular/nebular_scenes8.h
+++ b/engines/mads/nebular/nebular_scenes8.h
@@ -52,6 +52,21 @@ public:
 	Scene8xx(MADSEngine *vm) : NebularScene(vm) {}
 };
 
+class Scene801: public Scene8xx{
+private:
+	bool _walkThroughDoor;
+
+public:
+	Scene801(MADSEngine *vm) : Scene8xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 class Scene804: public Scene8xx {
 private:
 	bool _messWithThrottle;


Commit: 73945d55320bd5cee6cebe06bb62607be4217af7
    https://github.com/scummvm/scummvm/commit/73945d55320bd5cee6cebe06bb62607be4217af7
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-17T12:50:47+03:00

Commit Message:
MADS: Further work on scene 701

Changed paths:
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes7.cpp



diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 61cbd44..2c38dd0 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -39,6 +39,7 @@ enum {
 };
 
 enum Verb {
+	VERB_CAST           = 0x03D,
 	VERB_CLIMB_DOWN     = 0x04E,
 	VERB_CLIMB_UP       = 0x050,
 	VERB_EAT			= 0x075,
@@ -65,7 +66,7 @@ enum Verb {
 	VERB_EXIT_FROM      = 0x1CE,
 	VERB_CLIMB_INTO     = 0x2F7,
 	VERB_STEP_INTO      = 0x2F9,
-	VERB_WALK_ALONG     = 0x312,
+	VERB_WALK_ALONG     = 0x312
 };
 
 enum Noun {
@@ -85,6 +86,7 @@ enum Noun {
 	NOUN_DOOR			= 0x6E,
 	NOUN_ENTER_KEY      = 0x7A,
 	NOUN_FISHING_LINE	= 0x87,
+	NOUN_FISHING_ROD    = 0x88,
 	NOUN_FRONT_WINDOW	= 0x8E,
 	NOUN_FUZZY_DICE		= 0x91,
 	NOUN_HOTPANTS		= 0x0A7,
@@ -150,6 +152,7 @@ enum Noun {
 	NOUN_DROP			= 0x3AD,
 	NOUN_DASH			= 0x3AE,
 	NOUN_SPLASH			= 0x3AF,
+	NOUN_HOOK           = 0x467,
 	NOUN_BIRDS          = 0x487,
 	NOUN_WEST_END_OF_PLATFORM = 0x4A9,
 	NOUN_EAST_END_OF_PLATFORM = 0x4AA
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 1ce9566..cc24070 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -187,9 +187,8 @@ void Scene701::enter() {
 	} else if (_scene->_priorSceneId != -2 && _scene->_priorSceneId != -620) {
 		_game._player._playerPos = Common::Point(22, 131);
 		_game._player._facing = FACING_EAST;
-		// TODO: Enable once step() is implemented
-		//_game._player._stepEnabled = false;
-		//_scene->_sequences.addTimer(1 * 60, 70);
+		_game._player._stepEnabled = false;
+		_scene->_sequences.addTimer(1 * 60, 70);
 	}
 
 	_game.loadQuoteSet(0x310, 0x30F, 0);
@@ -199,27 +198,49 @@ void Scene701::enter() {
 void Scene701::step() {
 	switch(_game._trigger) {
 	case 60:
-		// TODO
+		_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+		_globals._sequenceIndexes[5] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], false, 6, 1, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[5], Common::Point(155, 129));
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 61);
 		break;
 	case 61:
-		// TODO
+		_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[5]);
+		_game._player._visible = true;
+		_game._player._stepEnabled = true;
 		break;
 	case 70:
-		// TODO
+		_vm->_sound->command(16);
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 1, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
 		break;
 	case 71:
 		_game._player.walk(Common::Point(61, 131), FACING_EAST);
 		_scene->_sequences.addTimer(2 * 60, 72);
 		break;
 	case 72:
-		// TODO
+		_vm->_sound->command(17);
+		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 5, 1, 0, 0);
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 73);
 		break;
 	case 73:
-		// TODO
+		_game._player._stepEnabled = true;
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1); 
+		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
+		_scene->_kernelMessages.reset();
 		break;
 	case 80:
 		_game._player._visible = true;
-		// TODO
+		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 9);
+		int idx = _scene->_dynamicHotspots.add(NOUN_BOAT, VERB_CLIMB_INTO, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(234, 129), FACING_NORTH);
 		_globals[kBoatStatus] = BOAT_TIED;
 		_game._player._stepEnabled = true;
 		break;
@@ -270,25 +291,64 @@ void Scene701::actions() {
 		case 0:
 			_game._player._stepEnabled = false;
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
-			// TODO: finish this
+			_vm->_sound->command(16);
+			_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 1, 0, 0);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
+			_scene->_kernelMessages.reset();
+			_scene->_kernelMessages.add(Common::Point(0, 0), 0x310, 34, 0, 120, _game.getQuote(0x30D));
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			break;
 		case 1:
 			_game._player.walk(Common::Point(22, 131), FACING_EAST);
 			_scene->_sequences.addTimer(2 * 60, 3);
 			break;
 		case 3:
-			// TODO
+			_vm->_sound->command(17);
+			_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 5, 1, 0, 0);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 4);
 			break;
 		case 4:
-			// TODO
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1); 
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
+			_globals[kResurrectRoom] = 701;
+			_scene->_nextSceneId = 605;
 			break;
 		}
-	} else if (false) {
-		// TODO: boat + fishing line action
+	} else if ((_action.isAction(VERB_PULL, NOUN_BOAT) || _action.isAction(VERB_TAKE, NOUN_BOAT) ||
+			   _action.isAction(VERB_PULL, NOUN_FISHING_LINE) || _action.isAction(VERB_TAKE, NOUN_FISHING_LINE)) &&
+			   !_game._objects.isInInventory(OBJ_FISHING_LINE)) {
+		if (_globals[kBoatStatus] == BOAT_TIED_FLOATING) {
+			switch (_game._trigger) {
+			case 0:
+				// TODO
+				break;
+			case 1:
+				// TODO
+				break;
+			case 2:
+				_globals[kBoatStatus] = BOAT_TIED;
+				_globals[kLineStatus] = LINE_NOW_UNTIED;
+				_game._player._stepEnabled = true;
+				break;
+			}
+		} else if (_globals[kBoatStatus] == BOAT_TIED) {
+			_vm->_dialogs->show(70125);
+		} else if (_globals[kLineStatus] == LINE_DROPPED) {
+			// TODO
+		} else {
+			_vm->_dialogs->show(70127);
+		}
 	} else if (_action.isAction(VERB_CLIMB_INTO, NOUN_BOAT) && _globals[kBoatStatus] == BOAT_TIED) {
 		switch (_game._trigger) {
 		case 0:
-			// TODO
+			_game._player._stepEnabled = false;
+			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+			_game._player._visible = false;
+			_scene->loadAnimation(formAnimName('B', 0), 1);
 			break;
 		case 1:
 			_scene->_nextSceneId = 703;
@@ -311,8 +371,11 @@ void Scene701::actions() {
 		_vm->_dialogs->show(70114);
 	} else if (_action.isAction(VERB_LOOK, NOUN_CEMENT_PYLON)) {
 		_vm->_dialogs->show(70115);
-	} else if (false) {
-		// TODO: hook
+	} else if (_action.isAction(VERB_LOOK, NOUN_HOOK)) {
+		if (_globals[kLineStatus] == LINE_NOT_DROPPED || _globals[kLineStatus] == LINE_NOW_UNTIED)
+			_vm->_dialogs->show(70116);
+		else
+			_vm->_dialogs->show(70117);
 	} else if (_action.isAction(VERB_LOOK, NOUN_ROCK)) {
 		_vm->_dialogs->show(70118);
 	} else if (_action.isAction(VERB_TAKE, NOUN_ROCK)) {
@@ -326,8 +389,9 @@ void Scene701::actions() {
 			_vm->_dialogs->show(70122);
 		else
 			_vm->_dialogs->show(70123);
-	} else if (false) {
-		// TODO: fishing rod + boat
+	} else if (_action.isAction(VERB_CAST, NOUN_FISHING_ROD, NOUN_BOAT)) {
+		if (_game._objects.isInInventory(OBJ_FISHING_LINE))
+			_vm->_dialogs->show(70124);
 	}
 }
 


Commit: 15dfef0796b8cc1288370758d593d443f8e7270c
    https://github.com/scummvm/scummvm/commit/15dfef0796b8cc1288370758d593d443f8e7270c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-17T17:42:36+02:00

Commit Message:
MADS: Implement scene 802

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/nebular/nebular_scenes8.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index d8eadc1..206b476 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -277,7 +277,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 801:	// control room, outside teleporter
 		return new Scene801(vm);
 	case 802:	// launch pad with destroyed ship
-		return new DummyScene(vm);	// TODO
+		return new Scene802(vm);
 	case 803:	// empty launch pad
 		return new DummyScene(vm);	// TODO
 	case 804:	// inside Rex's ship - cockpit
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 13ab001..2d05ff9 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -300,6 +300,214 @@ void Scene801::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene802::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x137);
+	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(0x123);
+}
+
+void Scene802::enter() {
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RXMRC_8");
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('f', 2));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('f', 0));
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('f', 1));
+	_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RXMBD_8");
+	_globals[kBetweenRooms] = false;
+
+	if ((_globals[kCameFromCut]) && (_globals[kCutX] != 0)) {
+		_game._player._playerPos.x = _globals[kCutX];
+		_game._player._playerPos.y = _globals[kCutY];
+		_game._player._facing = (Facing)_globals[kCutFacing];
+		_globals[kCutX] = 0; 
+		_globals[kCameFromCut] = false;
+		_globals[kReturnFromCut] = false;
+		_globals[kBeamIsUp] = false;
+		_globals[kForceBeamDown] = false;
+		_globals[kDontRepeat] = false;
+		_globals[kAntigravClock] = _scene->_frameStartTime;
+	} else if (_scene->_priorSceneId == 801) {
+		_game._player._playerPos = Common::Point(15, 129);
+		_game._player._facing = FACING_EAST;
+	} else if (_scene->_priorSceneId == 803) {
+		_game._player._playerPos = Common::Point(303, 119);
+		_game._player._facing = FACING_WEST;
+
+	} else if (_scene->_priorSceneId != -2) {
+		_game._player._playerPos = Common::Point(15, 129); 
+		_game._player._facing = FACING_EAST; 
+	}
+
+	_game._player._visible = true;
+
+
+
+	if (_globals[kHasWatchedAntigrav] && !_globals[kRemoteSequenceRan]) {
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_scene->_sequences.addTimer(200, 70);
+	}
+
+	if ((_globals[kRemoteOnGround]) && (!_game._objects.isInInventory(OBJ_REMOTE))) {
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 8);
+		int idx = _scene->_dynamicHotspots.add(0x123, 0xD,_globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(107, 99), FACING_NORTH);
+	}
+
+	if (!_game._objects.isInInventory(OBJ_SHIELD_MODULATOR) && !_globals[kShieldModInstalled]) {
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 8);
+		int idx = _scene->_dynamicHotspots.add(0x137, 0xD, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(93, 97), FACING_NORTH);
+	}
+	sceneEntrySound();
+}
+
+void Scene802::step() {
+	if (_game._trigger == 70) {
+		_game._player._stepEnabled = false;
+		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 19);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 4, 72);
+	}
+
+	if (_game._trigger == 71) {
+		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 8);
+		int idx = _scene->_dynamicHotspots.add(0x123, 0xD, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(107, 99), FACING_NORTH);
+
+		_globals[kRemoteSequenceRan] = true;
+		_globals[kRemoteOnGround] = true;
+		_game._player._stepEnabled = true;
+	}
+
+	if (_game._trigger == 72)
+		_vm->_sound->command(13);
+}
+
+void Scene802::preActions() {
+	if (_action.isAction(0x18C, 0x393))
+		_game._player._walkOffScreenSceneId = 801;
+
+	if (_action.isAction(0x1AD, 0x1C1)) {
+		_game._player._walkOffScreenSceneId = 803;
+		_globals[kForceBeamDown] = false;
+	}
+
+	if (_action.isAction(VERB_TAKE, 0x139))
+		_game._player._needToWalk = false;
+}
+
+void Scene802::actions() {
+	if (_action.isAction(VERB_TAKE, 0x137) && !_game._objects.isInInventory(OBJ_SHIELD_MODULATOR)) {
+		switch (_game._trigger) {
+		case (0):
+			_game._player._stepEnabled = false;
+			_game._player._visible = false; 
+			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], true, 7, 2, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 2);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 2, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+
+		case 1:
+			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+			_vm->_sound->command(9);
+			break;
+
+		case 2:
+			_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
+			_game._player._visible = true;
+			_scene->_sequences.addTimer(20, 3);
+			break; 
+
+		case 3:
+			_game._player._stepEnabled = true;
+			_game._objects.addToInventory(OBJ_SHIELD_MODULATOR);
+			_vm->_dialogs->showItem(OBJ_SHIELD_MODULATOR, 80215);
+			break;
+
+		default:
+			break;
+		}
+	} else if ((_action.isAction(VERB_TAKE, 0x123)) && (!_game._objects.isInInventory(OBJ_REMOTE))) {
+		switch (_game._trigger) {
+		case (0):
+			_game._player._stepEnabled = false;
+			_game._player._visible = false; 
+			_globals._sequenceIndexes[5] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], true, 7, 2, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 4);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_SPRITE, 4, 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
+			break;
+
+		case 1:
+			_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+			_vm->_sound->command(9);
+			_globals[kRemoteOnGround] = false;
+			break;
+
+		case 2:
+			_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
+			_game._player._visible = true;
+			_scene->_sequences.addTimer(20, 3);
+			break; 
+
+		case 3:
+			_game._player._stepEnabled = true;
+			_game._objects.addToInventory(OBJ_REMOTE);
+			_vm->_dialogs->showItem(OBJ_REMOTE, 80223);
+			break;
+
+		default:
+			break;
+		}
+	} else if (!_globals[kRemoteOnGround] && (_game._objects.isInInventory(OBJ_SHIELD_MODULATOR) || _globals[kShieldModInstalled])
+		&& (_action.isAction(VERB_LOOK, 0x392) || _action._lookFlag))
+		_vm->_dialogs->show(80210);
+	else if (!_globals[kRemoteOnGround]&& !_game._objects.isInInventory(OBJ_SHIELD_MODULATOR) && !_globals[kShieldModInstalled]
+		&& (_action.isAction(VERB_LOOK, 0x392) || _action._lookFlag))
+		_vm->_dialogs->show(80211);
+	else if (_globals[kRemoteOnGround] && !_game._objects.isInInventory(OBJ_SHIELD_MODULATOR) && !_globals[kShieldModInstalled]
+		&& (_action.isAction(VERB_LOOK, 0x392) || _action._lookFlag))
+		_vm->_dialogs->show(80213);
+	else if (_globals[kRemoteOnGround] && (_game._objects.isInInventory(OBJ_SHIELD_MODULATOR) || _globals[kShieldModInstalled]) 
+		&& (_action.isAction(VERB_LOOK, 0x392) || _action._lookFlag))
+		_vm->_dialogs->show(80212);
+	else if (!_game._objects.isInInventory(OBJ_SHIELD_MODULATOR) && !_globals[kShieldModInstalled] && _action.isAction(VERB_LOOK, 0x137))
+		_vm->_dialogs->show(80214);
+	else if (_globals[kRemoteOnGround] && _action.isAction(VERB_LOOK, 0x123))
+		_vm->_dialogs->show(80216);
+	else if (_action.isAction(VERB_LOOK, 0x139)) {
+		if ((!_game._objects.isInInventory(OBJ_SHIELD_MODULATOR)) && (!_globals[kShieldModInstalled]))
+			_vm->_dialogs->show(80218);
+		else
+			_vm->_dialogs->show(80217);
+	} else if (_action.isAction(VERB_LOOK, 0x39))
+		_vm->_dialogs->show(80219);
+	else if (_action.isAction(VERB_LOOK, 0x1C1))
+		_vm->_dialogs->show(80220);
+	else if (_action.isAction(VERB_LOOK, 0x142))
+		_vm->_dialogs->show(80221);
+	else if (_action.isAction(VERB_TAKE, 0x139))
+		_vm->_dialogs->show(80222);
+	else if (_action.isAction(VERB_LOOK, 0x174) || _action.isAction(VERB_LOOK, 0x175))
+		_vm->_dialogs->show(80224);
+	else if (_action.isAction(VERB_LOOK, 0x393))
+		_vm->_dialogs->show(80225);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene804::setup() {
 	Scene8xx::setPlayerSpritesPrefix();
 	Scene8xx::setAAName();
diff --git a/engines/mads/nebular/nebular_scenes8.h b/engines/mads/nebular/nebular_scenes8.h
index 8ba55d6..1e31b89 100644
--- a/engines/mads/nebular/nebular_scenes8.h
+++ b/engines/mads/nebular/nebular_scenes8.h
@@ -67,6 +67,18 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene802: public Scene8xx{
+public:
+	Scene802(MADSEngine *vm) : Scene8xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 class Scene804: public Scene8xx {
 private:
 	bool _messWithThrottle;


Commit: 11f784713e302c38aab0dbdc779632136096bb2a
    https://github.com/scummvm/scummvm/commit/11f784713e302c38aab0dbdc779632136096bb2a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-17T12:04:39-04:00

Commit Message:
MADS: Completed random message generation method

Changed paths:
    engines/mads/messages.cpp
    engines/mads/messages.h



diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index 8ec6350..23fdbb2 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -29,6 +29,19 @@
 
 namespace MADS {
 
+RandomMessages::RandomMessages() {
+	reserve(RANDOM_MESSAGE_SIZE);
+	_randomSpacing = 0;
+}
+
+void RandomMessages::reset() {
+	for (uint i = 0; i < size(); ++i) {
+		(*this)[i]._handle = -1;
+		(*this)[i]._quoteId = -1;
+	}
+}
+
+
 KernelMessages::KernelMessages(MADSEngine *vm): _vm(vm) {
 	for (int i = 0; i < KERNEL_MESSAGES_SIZE; ++i) {
 		KernelMessage rec;
@@ -36,9 +49,6 @@ KernelMessages::KernelMessages(MADSEngine *vm): _vm(vm) {
 	}
 
 	_talkFont = _vm->_font->getFont(FONT_CONVERSATION);
-
-	_randomMaxMessages = 0;
-	resetRandomMessages();
 }
 
 KernelMessages::~KernelMessages() {
@@ -141,7 +151,7 @@ void KernelMessages::reset() {
 		remove(i);
 
 	_talkFont = _vm->_font->getFont(FONT_CONVERSATION);
-	resetRandomMessages();
+	_randomMessages.clear();
 }
 
 void KernelMessages::update() {
@@ -306,27 +316,20 @@ void KernelMessages::setQuoted(int msgIndex, int numTicks, bool quoted) {
 	}
 }
 
-void KernelMessages::resetRandomMessages() {
-	for (int i = 0; i < RANDOM_MESSAGE_SIZE; ++i) {
-		_randomMessages[i]._handle = -1;
-		_randomMessages[i]._quote = -1;
-	}
-}
-
 #define RANDOM_MESSAGE_TRIGGER 240
 
 void KernelMessages::randomServer() {
 	if ((_vm->_game->_trigger >= RANDOM_MESSAGE_TRIGGER) &&
-		(_vm->_game->_trigger <  (RANDOM_MESSAGE_TRIGGER + _randomMaxMessages))) {
+		(_vm->_game->_trigger <  (RANDOM_MESSAGE_TRIGGER + (int)_randomMessages.size()))) {
 		_randomMessages[_vm->_game->_trigger - RANDOM_MESSAGE_TRIGGER]._handle = -1;
-		_randomMessages[_vm->_game->_trigger - RANDOM_MESSAGE_TRIGGER]._quote = -1;
+		_randomMessages[_vm->_game->_trigger - RANDOM_MESSAGE_TRIGGER]._quoteId = -1;
 	}
 }
 
 int KernelMessages::checkRandom() {
 	int total = 0;
 
-	for (int i = 0; i < _randomMaxMessages; ++i) {
+	for (uint i = 0; i < _randomMessages.size(); ++i) {
 		if (_randomMessages[i]._handle >= 0)
 			++total;
 	}
@@ -335,8 +338,97 @@ int KernelMessages::checkRandom() {
 }
 
 bool KernelMessages::generateRandom(int major, int minor) {
-	// TODO
-	return false;
+	bool generatedMessage = false;
+
+	// Scan through the random messages array
+	for (uint msgCtr = 0; msgCtr < _randomMessages.size(); msgCtr++) {
+		// Find currently active random messages
+		if (_randomMessages[msgCtr]._handle < 0) {
+			// Check whether there's any existing 'scrolling in' message
+			bool bad = false;
+			for (uint scanCtr = 0; scanCtr < _randomMessages.size(); ++scanCtr) {
+				if (_randomMessages[scanCtr]._handle >= 0) {
+					if (_entries[_randomMessages[scanCtr]._handle]._flags & KMSG_SCROLL) {
+						bad = true;
+						break;
+					}
+				}
+			}
+
+			// Do a random check for a new message to appear
+			if (_vm->getRandomNumber(major) <= minor && !bad) {
+				int quoteId;
+
+				// Pick a random quote to display from the available list
+				do {
+					int quoteIdx = _vm->getRandomNumber(_randomQuotes.size() - 1);
+					quoteId = _randomQuotes[quoteIdx];
+
+					// Ensure the quote isn't already in use
+					bad = false;
+					for (uint scanCtr = 0; scanCtr < _randomMessages.size(); ++scanCtr) {
+						if (quoteId == _randomMessages[scanCtr]._quoteId) {
+							bad = true;
+							break;
+						}
+					}
+				} while (bad);
+
+				// Store the quote Id to be used
+				_randomMessages[msgCtr]._quoteId = quoteId;
+
+				// Position the message at a random position
+				Common::Point textPos;
+				textPos.x = _vm->getRandomNumber(_randomMessages._bounds.left,
+					_randomMessages._bounds.right);
+
+				// Figure out Y position, making sure not to be overlapping with
+				// any other on-screen message
+				int abortCounter = 0;
+
+				do {
+					// Ensure we don't get stuck in an infinite loop if too many messages
+					// are alrady on-screen
+					if (abortCounter++ > 100) goto done;
+					bad = false;
+
+					// Set potential new Y position
+					textPos.y = _vm->getRandomNumber(_randomMessages._bounds.top,
+						_randomMessages._bounds.bottom);
+
+					// Ensure it doesn't overlap an existing on-screen message
+					for (uint msgCtr2 = 0; msgCtr2 < _randomMessages.size(); ++msgCtr2) {
+						if (_randomMessages[msgCtr2]._handle >= 0) {
+							int lastY = _entries[_randomMessages[msgCtr2]._handle]._position.y;
+
+							if ((textPos.y >= (lastY - _randomMessages._randomSpacing)) &&
+								(textPos.y <= (lastY + _randomMessages._randomSpacing))) {
+								bad = true;
+							}
+						}
+					}
+				} while (bad);
+
+				// Add the message
+				_randomMessages[msgCtr]._handle = add(textPos, _randomMessages._color, 0,
+					RANDOM_MESSAGE_TRIGGER + msgCtr, _randomMessages._duration,
+					_vm->_game->getQuote(_randomMessages[msgCtr]._quoteId));
+
+				if (_randomMessages._scrollRate > 0) {
+					if (_randomMessages[msgCtr]._handle >= 0) {
+						setQuoted(_randomMessages[msgCtr]._handle,
+							_randomMessages._scrollRate, true);
+					}
+				}
+
+				generatedMessage = true;
+				break;
+			}
+		}
+	}
+
+done:
+	return generatedMessage;
 }
 
 void KernelMessages::initRandomMessages(int maxSimultaneousMessages,
diff --git a/engines/mads/messages.h b/engines/mads/messages.h
index 7211598..241f493 100644
--- a/engines/mads/messages.h
+++ b/engines/mads/messages.h
@@ -65,18 +65,32 @@ public:
 	KernelMessage();
 };
 
+struct RandomEntry {
+	int _handle;
+	int _quoteId;
+
+	RandomEntry() { _handle = _quoteId = -1; }
+};
+
+class RandomMessages: public Common::Array<RandomEntry> {
+public:
+	Common::Rect _bounds;
+	int _randomSpacing;
+	int _color;
+	int _duration;
+	int _scrollRate;
+public:
+	RandomMessages();
+
+	void reset();
+};
+
 class KernelMessages {
 private:
 	MADSEngine *_vm;
 
-	struct RandomEntry {
-		int _handle;
-		int _quote;
-	};
-	RandomEntry _randomMessages[RANDOM_MESSAGE_SIZE];
-	int _randomMaxMessages;
-
-	void resetRandomMessages();
+	Common::Array<int> _randomQuotes;
+	RandomMessages _randomMessages;
 public:
 	Common::Array<KernelMessage> _entries;
 	Font *_talkFont;


Commit: 3244db7ff45bcee9190abe9e209a66eb2464b653
    https://github.com/scummvm/scummvm/commit/3244db7ff45bcee9190abe9e209a66eb2464b653
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-17T12:30:17-04:00

Commit Message:
MADS: Added initialisation method for random messages display

Changed paths:
    engines/mads/messages.cpp



diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index 23fdbb2..4fd02cc 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -434,7 +434,29 @@ done:
 void KernelMessages::initRandomMessages(int maxSimultaneousMessages,
 		const Common::Rect &bounds, int minYSpacing, int scrollRate,
 		int color, int duration, int quoteId, ...) {
-	// TODO
+	// Reset the random messages list
+	_randomMessages.clear();
+	_randomMessages.resize(maxSimultaneousMessages);
+
+	// Store passed parameters
+	_randomMessages._bounds = bounds;
+	_randomMessages._randomSpacing = minYSpacing;
+	_randomMessages._scrollRate = scrollRate;
+	_randomMessages._color = color;
+	_randomMessages._duration = duration;
+
+	// Store the variable length random quote list
+	va_list va;
+	va_start(va, quoteId);
+	_randomQuotes.clear();
+
+	while (quoteId > 0) {
+		_randomQuotes.push_back(quoteId);
+		assert(_randomQuotes.size() < 100);
+		quoteId = va_arg(va, int);
+	}
+
+	va_end(va);
 }
 
 


Commit: bc639c25c8f8e8f6a86235f59352851313753830
    https://github.com/scummvm/scummvm/commit/bc639c25c8f8e8f6a86235f59352851313753830
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-17T14:35:48-04:00

Commit Message:
MADS: Fix for using inventory actions

Changed paths:
    engines/mads/action.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index e959395..5d63c3a 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -472,8 +472,8 @@ void MADSAction::checkActionAtMousePos() {
 				_mainObjectSource = CAT_NONE;
 			} else {
 				InventoryObject &invObject = _vm->_game->_objects.getItem(userInterface._selectedInvIndex);
-				_verbType = invObject._vocabList[_selectedRow + 1]._verbType;
-				_prepType = invObject._vocabList[_selectedRow + 1]._prepType;
+				_verbType = invObject._vocabList[_selectedRow]._verbType;
+				_prepType = invObject._vocabList[_selectedRow]._prepType;
 				_hotspotId = userInterface._selectedInvIndex;
 				_mainObjectSource = CAT_INV_LIST;
 


Commit: e7bef9019a71105a19c9f4eff567b8df47387a8b
    https://github.com/scummvm/scummvm/commit/e7bef9019a71105a19c9f4eff567b8df47387a8b
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-18T12:29:48+02:00

Commit Message:
MADS: Implement scene 803, add an ongoingGame global flag to exit the multiple game loops

Changed paths:
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/nebular/nebular_scenes8.h
    engines/mads/scene.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 34b229f..3b00116 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -77,6 +77,8 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 	_triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 	_winStatus = 0;
 	_widepipeCtr = 0;
+	_ongoingGame = true;
+
 
 	// Load the inventory object list
 	_objects.load();
@@ -152,7 +154,7 @@ void Game::run() {
 }
 
 void Game::gameLoop() {
-	while (!_vm->shouldQuit() && _statusFlag) {
+	while (!_vm->shouldQuit() && _statusFlag && _ongoingGame) {
 		if (_loadGameSlot != -1) {
 			loadGame(_loadGameSlot);
 			_loadGameSlot = -1;
@@ -166,9 +168,8 @@ void Game::gameLoop() {
 
 		_scene._spriteSlots.reset();
 
-		if (_sectionNumber == _currentSectionNumber) {
+		if (_sectionNumber == _currentSectionNumber)
 			sectionLoop();
-		}
 
 		_player.releasePlayerSprites();
 		assert(_scene._sprites.size() == 0);
@@ -183,7 +184,7 @@ void Game::gameLoop() {
 }
 
 void Game::sectionLoop() {
-	while (!_vm->shouldQuit() && _statusFlag && _sectionNumber == _currentSectionNumber) {
+	while (!_vm->shouldQuit() && _statusFlag && (_sectionNumber == _currentSectionNumber) && _ongoingGame) {
 		_kernelMode = KERNEL_ROOM_PRELOAD;
 		_player._spritesChanged = true;
 		_quoteEmergency = false;
@@ -460,6 +461,7 @@ void Game::synchronize(Common::Serializer &s, bool phase1) {
 		s.syncAsUint16LE(_triggerMode);
 		synchronizeString(s, _aaName);
 		s.syncAsSint16LE(_lastSave);
+		s.syncAsByte(_ongoingGame);
 
 		_scene.synchronize(s);
 		_objects.synchronize(s);
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 358a266..0e96405 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -149,6 +149,8 @@ public:
 	int _winStatus;
 	int _widepipeCtr;
 	int _loadGameSlot;
+	bool _ongoingGame;
+
 public:
 	virtual ~Game();
 
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 2d05ff9..1c7cd75 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -36,9 +36,8 @@ void Scene8xx::setPlayerSpritesPrefix() {
 			_scene->_nextSceneId == 804 || _scene->_nextSceneId == 805 ||
 			_scene->_nextSceneId == 808 || _scene->_nextSceneId == 810) {
 		_game._player._spritesPrefix = "";
-	} else {
+	} else
 		_game._player._spritesPrefix = _globals[kSexOfRex] == SEX_FEMALE ? "ROX" : "RXM";
-	}
 
 	_vm->_palette->setEntry(16, 0x0A, 0x3F, 0x3F);
 	_vm->_palette->setEntry(17, 0x0A, 0x2D, 0x2D);
@@ -62,12 +61,15 @@ void Scene8xx::sceneEntrySound() {
 		case 808:
 			_vm->_sound->command(20);
 			break;
+
 		case 805:
 			_vm->_sound->command(23);
 			break;
+
 		case 810:
 			_vm->_sound->command(10);
 			break;
+
 		default:
 			break;
 		}
@@ -508,6 +510,320 @@ void Scene802::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene803::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x472);
+	_scene->addActiveVocab(0xD);
+
+	if ((!_globals[kFromCockpit] && _globals[kReturnFromCut] && !_globals[kBeamIsUp])
+		|| (_globals[kFromCockpit] && !_globals[kExitShip])) {
+		_game._player._spritesPrefix = "";
+		_game._player._spritesChanged = true;
+	}
+}
+
+void Scene803::enter() {
+	_globals[kBetweenRooms] = false;
+	_game._player._visible = false;
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('f', 1));
+	_globals._spriteIndexes[9] = _scene->_sprites.addSprites("*RXMBD_2");
+	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('d', 1));
+
+	_game.loadQuoteSet(0x31B, 0x31C, 0x31D, 0x31E, 0x31F, 0x320, 0x321, 0x322, 0);
+
+	if (_globals[kHoppyDead]) {
+		_globals._spriteIndexes[7]  = _scene->_sprites.addSprites(formAnimName('e', 1));
+		_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, 1);
+		int idx = _scene->_dynamicHotspots.add(0x472, 0xD, _globals._sequenceIndexes[7], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(66, 123), FACING_SOUTH);
+	} 
+
+	if (!_globals[kBeamIsUp] && !_globals[kReturnFromCut] && (!_globals[kFromCockpit] || _globals[kExitShip])) {
+		_globals._sequenceIndexes[1]  = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 2, 2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+	}
+
+	if (!_globals[kFromCockpit]) {
+		if (!_globals[kReturnFromCut]) {
+			if (_scene->_priorSceneId != -2) {
+				_game._player._playerPos = Common::Point(15, 130);      
+				_game._player._facing           = FACING_EAST; 
+			}
+			_game._player._visible   = true;
+		} else if (!_globals[kBeamIsUp]){
+			_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 1));
+			_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 3));
+			_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('a', 2));
+			_game._player._visible   = false;
+			_game._player._stepEnabled = false;
+			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 15);
+			_globals._sequenceIndexes[3]  = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
+			_vm->_sound->command(14);
+		} 
+
+		if (_globals[kBeamIsUp] && !_globals[kReturnFromCut]){
+			if (_globals[kForceBeamDown])
+				_game._player._visible   = false;
+			else
+				_game._player._visible   = true; 
+
+			_globals._spriteIndexes[5]  = _scene->_sprites.addSprites(formAnimName('b', 1));
+			_vm->_sound->command(15);
+			_game._player._stepEnabled   = false;
+			_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 12, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 6);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 100);
+		}
+	} else if (!_globals[kExitShip]) {
+		if (!_globals[kBeamIsUp]) {
+			_globals._spriteIndexes[3]   = _scene->_sprites.addSprites(formAnimName('a', 1));
+			_game._player._visible   = false;
+			_game._player._stepEnabled = false;
+			_globals._sequenceIndexes[3]  = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 130);
+			_vm->_sound->command(14);
+		} else {
+			_globals._spriteIndexes[8]   = _scene->_sprites.addSprites(formAnimName('c', 1));
+			_game._player._visible    = false;
+			_game._player._stepEnabled  = false;
+			_globals._sequenceIndexes[8]  = _scene->_sequences.startCycle(_globals._spriteIndexes[8], false, 1);
+			_globals._sequenceIndexes[8]  = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 1);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 140);
+		}
+	} else {
+		_game._player._stepEnabled = false;
+		_game._player._playerPos = Common::Point(197, 96);
+		_game._player._facing = FACING_SOUTHWEST;
+		_game._player._visible = true;
+		_globals._spriteIndexes[6]  = _scene->_sprites.addSprites(formAnimName('d', 1));
+		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 19);
+		_scene->_sequences.addTimer(1, 150);
+	}
+
+	sceneEntrySound();
+}
+
+void Scene803::step() {
+	if (_game._trigger == 120) {
+		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 19);
+		_scene->_nextSceneId = 804;
+	}
+
+	if (_game._trigger == 100) {
+		_globals._sequenceIndexes[1]  = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 2, 2);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
+		if (!_globals[kHoppyDead]) { 
+			_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 7, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 7, 12);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5],SEQUENCE_TRIGGER_EXPIRE, 0, 101);
+		} else {
+			_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, -2);
+			int idx = _scene->_dynamicHotspots.add(0x472, 0xD, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+			_scene->_dynamicHotspots.setPosition(idx, Common::Point(66, 123), FACING_SOUTH);
+			_vm->_sound->command(16);
+			_globals[kCameFromCut]           = true;
+			_globals[kBeamIsUp]              = false;
+			_globals[kReturnFromCut]         = false;
+			_globals[kDontRepeat]             = false;
+			_globals[kHoppyDead]              = true;
+			_globals[kHasWatchedAntigrav]  = true;
+
+			if (_globals[kForceBeamDown])
+				_scene->_nextSceneId = _scene->_priorSceneId;
+			else
+				_game._player._stepEnabled       = true;
+		}
+	} 
+
+	if (_game._trigger == 101) {
+		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, -2);
+		int idx = _scene->_dynamicHotspots.add(0x472, 0xD, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(66, 123), FACING_SOUTH);
+		_vm->_sound->command(16);
+		_globals[kCameFromCut]           = true;
+		_globals[kBeamIsUp]              = false;
+		_globals[kReturnFromCut]         = false;
+		_globals[kDontRepeat]             = false;
+		_globals[kHoppyDead]              = true;
+		_globals[kHasWatchedAntigrav]  = true;
+
+		if (_globals[kForceBeamDown])
+			_scene->_nextSceneId = _scene->_priorSceneId;
+		else
+			_game._player._stepEnabled       = true;
+	}
+
+	if (_game._trigger == 80) {
+		if (!_globals[kHoppyDead])
+			_scene->_sequences.addTimer(350, 70);
+
+		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 12, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 1, 3);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 90);
+	}
+
+	if (_game._trigger == 70) {
+		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
+		_vm->_sound->command(31);
+	}
+
+	if (_game._trigger == 71)
+		_scene->_sequences.addTimer(200, 110);
+
+	if (_game._trigger == 90) {
+		int syncIdx = _globals._sequenceIndexes[4];
+		_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 15, 0, 0, 0);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], syncIdx);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 4, 9);
+		if (_globals[kHoppyDead])
+			_scene->_sequences.addTimer(200, 110);
+	}
+
+	if (_game._trigger == 110)
+		_scene->_nextSceneId           = 808;
+
+	if (_game._trigger == 130) {
+		_globals[kBeamIsUp] = true;
+		_scene->_nextSceneId = 804;
+	}
+
+	if (_game._trigger == 140) {
+		if (!_globals[kWindowFixed]) {
+			_scene->_nextSceneId         = 810;
+			_globals[kInSpace] = true;
+		} else {
+			if (!_globals[kShieldModInstalled])
+				_game._winStatus = 1;
+			else if (!_globals[kTargetModInstalled])
+				_game._winStatus = 2;
+			else
+				_game._winStatus = 3;
+
+			_game._ongoingGame = false;
+		}
+	}
+
+	if (_game._trigger == 150) {
+		_scene->_sequences.remove(_globals._sequenceIndexes[6]); 
+		_vm->_sound->command(18);
+		_globals._sequenceIndexes[6] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[6], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 1, 19);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 4);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 151);
+	}
+
+	if (_game._trigger == 151) {
+		_globals[kBeamIsUp]      = false;
+		_globals[kFromCockpit]    = false;
+		_globals[kExitShip]       = false;
+		_game._player._stepEnabled = true;
+	}
+}
+
+void Scene803::preActions() {
+	if (_action.isAction(0x1AD, 0x1AE))
+		_game._player._walkOffScreenSceneId = 802;
+
+	if (_action.isAction(VERB_TAKE, 0x139))
+		_game._player._needToWalk = false;
+}
+
+void Scene803::actions() {
+	if (_action.isAction(VERB_TAKE, 0x472)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled  = false;
+			_game._player._visible    = false;  
+			_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[9], 1, 4);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[9]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 160);
+			break;
+
+		case 160: {
+			int syncIdx = _globals._sequenceIndexes[9];
+			_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 4);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[9], syncIdx);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[9]);
+			_scene->_sequences.addTimer(60, 161);
+			}
+			break;
+
+		case 161: {
+			int quoteId = 0x31A + _vm->getRandomNumber(1, 8);
+			_scene->_kernelMessages.add(Common::Point(64, 67), 0x1110, 32, 0, 80, _game.getQuote(quoteId));
+			_scene->_sequences.addTimer(60, 162);
+			}
+			break;
+
+		case 162:
+			_scene->_sequences.remove(_globals._sequenceIndexes[9]);
+			_globals._sequenceIndexes[9] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0);
+			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[9], 1, 4);
+			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[9]);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 163);
+			break;
+
+		case 163:
+			_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
+			_game._player._visible   = true;
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(0x3B8, 0x139)) {
+		_vm->_sound->command(17);
+		_game._player._stepEnabled = false;
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 1, 19);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 4);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 120);
+		_globals[kBeamIsUp] = false;
+	} else if (_action.isAction(VERB_LOOK, 0x392))
+		_vm->_dialogs->show(80310);
+	else if (_action._lookFlag)
+		_vm->_dialogs->show(80310);
+	else if (_action.isAction(VERB_LOOK, 0x395))
+		_vm->_dialogs->show(80311);
+	else if (_action.isAction(VERB_LOOK, 0x472)) {
+		if (_game._storyMode == STORYMODE_NICE)
+			_vm->_dialogs->show(80312);
+		else
+			_vm->_dialogs->show(80313);
+	} else if (_action.isAction(VERB_LOOK, 0x39))
+		_vm->_dialogs->show(80315);
+	else if (_action.isAction(VERB_LOOK, 0x139))
+		_vm->_dialogs->show(80317);
+	else if (_action.isAction(VERB_LOOK, 0x396))
+		_vm->_dialogs->show(80318);
+	else if (_action.isAction(VERB_LOOK, 0x174) || _action.isAction(VERB_LOOK, 0x175))
+		_vm->_dialogs->show(80319);
+	else if (_action.isAction(VERB_LOOK, 0x142))
+		_vm->_dialogs->show(80320);
+	else if (_action.isAction(VERB_TAKE, 0x139))
+		_vm->_dialogs->show(80321);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
+
 void Scene804::setup() {
 	Scene8xx::setPlayerSpritesPrefix();
 	Scene8xx::setAAName();
diff --git a/engines/mads/nebular/nebular_scenes8.h b/engines/mads/nebular/nebular_scenes8.h
index 1e31b89..3af0a1c 100644
--- a/engines/mads/nebular/nebular_scenes8.h
+++ b/engines/mads/nebular/nebular_scenes8.h
@@ -79,6 +79,18 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene803: public Scene8xx{
+public:
+	Scene803(MADSEngine *vm) : Scene8xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 class Scene804: public Scene8xx {
 private:
 	bool _messWithThrottle;
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 601acc5..3ef88fa 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -255,7 +255,7 @@ void Scene::loadVocabStrings() {
 }
 
 void Scene::initPaletteAnimation(Common::Array<PaletteCycle> &palCycles, bool animFlag) {
-	// Initialise the animation palette and ticks list
+	// Initialize the animation palette and ticks list
 	_cycleTicks.clear();
 	_paletteCycles.clear();
 
@@ -334,7 +334,7 @@ bool Scene::getDepthHighBits(const Common::Point &pt) {
 }
 
 void Scene::loop() {
-	while (!_vm->shouldQuit() && !_reloadSceneFlag && _nextSceneId == _currentSceneId) {
+	while (!_vm->shouldQuit() && !_reloadSceneFlag && (_nextSceneId == _currentSceneId) && _vm->_game->_ongoingGame) {
 		// Handle drawing a game frame
 		doFrame();
 


Commit: e1a06ae543f0926118d2b82aa5344752e11ead1d
    https://github.com/scummvm/scummvm/commit/e1a06ae543f0926118d2b82aa5344752e11ead1d
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-18T12:34:15+02:00

Commit Message:
MADS: Replace _ongoingGame by the use of quitGame()

Changed paths:
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/scene.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 3b00116..3c69f45 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -77,8 +77,6 @@ Game::Game(MADSEngine *vm): _vm(vm), _surface(nullptr), _objects(vm),
 	_triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 	_winStatus = 0;
 	_widepipeCtr = 0;
-	_ongoingGame = true;
-
 
 	// Load the inventory object list
 	_objects.load();
@@ -154,7 +152,7 @@ void Game::run() {
 }
 
 void Game::gameLoop() {
-	while (!_vm->shouldQuit() && _statusFlag && _ongoingGame) {
+	while (!_vm->shouldQuit() && _statusFlag) {
 		if (_loadGameSlot != -1) {
 			loadGame(_loadGameSlot);
 			_loadGameSlot = -1;
@@ -184,7 +182,7 @@ void Game::gameLoop() {
 }
 
 void Game::sectionLoop() {
-	while (!_vm->shouldQuit() && _statusFlag && (_sectionNumber == _currentSectionNumber) && _ongoingGame) {
+	while (!_vm->shouldQuit() && _statusFlag && (_sectionNumber == _currentSectionNumber)) {
 		_kernelMode = KERNEL_ROOM_PRELOAD;
 		_player._spritesChanged = true;
 		_quoteEmergency = false;
@@ -461,7 +459,6 @@ void Game::synchronize(Common::Serializer &s, bool phase1) {
 		s.syncAsUint16LE(_triggerMode);
 		synchronizeString(s, _aaName);
 		s.syncAsSint16LE(_lastSave);
-		s.syncAsByte(_ongoingGame);
 
 		_scene.synchronize(s);
 		_objects.synchronize(s);
diff --git a/engines/mads/game.h b/engines/mads/game.h
index 0e96405..d171638 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -149,7 +149,6 @@ public:
 	int _winStatus;
 	int _widepipeCtr;
 	int _loadGameSlot;
-	bool _ongoingGame;
 
 public:
 	virtual ~Game();
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 1c7cd75..de89402 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -709,7 +709,7 @@ void Scene803::step() {
 			else
 				_game._winStatus = 3;
 
-			_game._ongoingGame = false;
+			_vm->quitGame();
 		}
 	}
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 3ef88fa..84e4edc 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -334,7 +334,7 @@ bool Scene::getDepthHighBits(const Common::Point &pt) {
 }
 
 void Scene::loop() {
-	while (!_vm->shouldQuit() && !_reloadSceneFlag && (_nextSceneId == _currentSceneId) && _vm->_game->_ongoingGame) {
+	while (!_vm->shouldQuit() && !_reloadSceneFlag && (_nextSceneId == _currentSceneId)) {
 		// Handle drawing a game frame
 		doFrame();
 


Commit: 9f081b0a8b6d9e2f3a5e1477a994e5295ef5beb8
    https://github.com/scummvm/scummvm/commit/9f081b0a8b6d9e2f3a5e1477a994e5295ef5beb8
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-18T13:12:04+02:00

Commit Message:
MADS: Implement scene 805

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/nebular/nebular_scenes8.h
    engines/mads/player.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 206b476..8b3456c 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -279,11 +279,11 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 802:	// launch pad with destroyed ship
 		return new Scene802(vm);
 	case 803:	// empty launch pad
-		return new DummyScene(vm);	// TODO
+		return new Scene803(vm);
 	case 804:	// inside Rex's ship - cockpit
 		return new Scene804(vm);
 	case 805:	// service panel
-		return new DummyScene(vm);	// TODO
+		return new Scene805(vm);
 	case 807:	// teleporter
 		return new Scene807(vm);
 	case 808:	// antigrav control
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index de89402..ab3b67e 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -533,14 +533,14 @@ void Scene803::enter() {
 	_game.loadQuoteSet(0x31B, 0x31C, 0x31D, 0x31E, 0x31F, 0x320, 0x321, 0x322, 0);
 
 	if (_globals[kHoppyDead]) {
-		_globals._spriteIndexes[7]  = _scene->_sprites.addSprites(formAnimName('e', 1));
+		_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('e', 1));
 		_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, 1);
 		int idx = _scene->_dynamicHotspots.add(0x472, 0xD, _globals._sequenceIndexes[7], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(66, 123), FACING_SOUTH);
 	} 
 
 	if (!_globals[kBeamIsUp] && !_globals[kReturnFromCut] && (!_globals[kFromCockpit] || _globals[kExitShip])) {
-		_globals._sequenceIndexes[1]  = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 1, 0, 0);
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 2, 2);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 	}
@@ -548,19 +548,19 @@ void Scene803::enter() {
 	if (!_globals[kFromCockpit]) {
 		if (!_globals[kReturnFromCut]) {
 			if (_scene->_priorSceneId != -2) {
-				_game._player._playerPos = Common::Point(15, 130);      
-				_game._player._facing           = FACING_EAST; 
+				_game._player._playerPos = Common::Point(15, 130); 
+				_game._player._facing = FACING_EAST; 
 			}
-			_game._player._visible   = true;
+			_game._player._visible = true;
 		} else if (!_globals[kBeamIsUp]){
 			_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 1));
 			_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 3));
 			_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('a', 2));
-			_game._player._visible   = false;
+			_game._player._visible = false;
 			_game._player._stepEnabled = false;
 			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 15);
-			_globals._sequenceIndexes[3]  = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 1);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
 			_vm->_sound->command(14);
@@ -568,13 +568,13 @@ void Scene803::enter() {
 
 		if (_globals[kBeamIsUp] && !_globals[kReturnFromCut]){
 			if (_globals[kForceBeamDown])
-				_game._player._visible   = false;
+				_game._player._visible = false;
 			else
-				_game._player._visible   = true; 
+				_game._player._visible = true; 
 
-			_globals._spriteIndexes[5]  = _scene->_sprites.addSprites(formAnimName('b', 1));
+			_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('b', 1));
 			_vm->_sound->command(15);
-			_game._player._stepEnabled   = false;
+			_game._player._stepEnabled = false;
 			_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 12, 1, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 6);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1);
@@ -582,19 +582,19 @@ void Scene803::enter() {
 		}
 	} else if (!_globals[kExitShip]) {
 		if (!_globals[kBeamIsUp]) {
-			_globals._spriteIndexes[3]   = _scene->_sprites.addSprites(formAnimName('a', 1));
-			_game._player._visible   = false;
+			_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 1));
+			_game._player._visible = false;
 			_game._player._stepEnabled = false;
-			_globals._sequenceIndexes[3]  = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
+			_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 8, 1, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 1);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 130);
 			_vm->_sound->command(14);
 		} else {
-			_globals._spriteIndexes[8]   = _scene->_sprites.addSprites(formAnimName('c', 1));
-			_game._player._visible    = false;
-			_game._player._stepEnabled  = false;
-			_globals._sequenceIndexes[8]  = _scene->_sequences.startCycle(_globals._spriteIndexes[8], false, 1);
-			_globals._sequenceIndexes[8]  = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
+			_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('c', 1));
+			_game._player._visible = false;
+			_game._player._stepEnabled = false;
+			_globals._sequenceIndexes[8] = _scene->_sequences.startCycle(_globals._spriteIndexes[8], false, 1);
+			_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 1);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[8], SEQUENCE_TRIGGER_EXPIRE, 0, 140);
 		}
@@ -603,7 +603,7 @@ void Scene803::enter() {
 		_game._player._playerPos = Common::Point(197, 96);
 		_game._player._facing = FACING_SOUTHWEST;
 		_game._player._visible = true;
-		_globals._spriteIndexes[6]  = _scene->_sprites.addSprites(formAnimName('d', 1));
+		_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('d', 1));
 		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 19);
 		_scene->_sequences.addTimer(1, 150);
 	}
@@ -618,7 +618,7 @@ void Scene803::step() {
 	}
 
 	if (_game._trigger == 100) {
-		_globals._sequenceIndexes[1]  = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 1, 0, 0);
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 2, 2);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 		if (!_globals[kHoppyDead]) { 
@@ -630,17 +630,17 @@ void Scene803::step() {
 			int idx = _scene->_dynamicHotspots.add(0x472, 0xD, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
 			_scene->_dynamicHotspots.setPosition(idx, Common::Point(66, 123), FACING_SOUTH);
 			_vm->_sound->command(16);
-			_globals[kCameFromCut]           = true;
-			_globals[kBeamIsUp]              = false;
-			_globals[kReturnFromCut]         = false;
-			_globals[kDontRepeat]             = false;
-			_globals[kHoppyDead]              = true;
-			_globals[kHasWatchedAntigrav]  = true;
+			_globals[kCameFromCut] = true;
+			_globals[kBeamIsUp] = false;
+			_globals[kReturnFromCut] = false;
+			_globals[kDontRepeat] = false;
+			_globals[kHoppyDead] = true;
+			_globals[kHasWatchedAntigrav] = true;
 
 			if (_globals[kForceBeamDown])
 				_scene->_nextSceneId = _scene->_priorSceneId;
 			else
-				_game._player._stepEnabled       = true;
+				_game._player._stepEnabled = true;
 		}
 	} 
 
@@ -649,17 +649,17 @@ void Scene803::step() {
 		int idx = _scene->_dynamicHotspots.add(0x472, 0xD, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(66, 123), FACING_SOUTH);
 		_vm->_sound->command(16);
-		_globals[kCameFromCut]           = true;
-		_globals[kBeamIsUp]              = false;
-		_globals[kReturnFromCut]         = false;
-		_globals[kDontRepeat]             = false;
-		_globals[kHoppyDead]              = true;
-		_globals[kHasWatchedAntigrav]  = true;
+		_globals[kCameFromCut] = true;
+		_globals[kBeamIsUp] = false;
+		_globals[kReturnFromCut] = false;
+		_globals[kDontRepeat] = false;
+		_globals[kHoppyDead] = true;
+		_globals[kHasWatchedAntigrav] = true;
 
 		if (_globals[kForceBeamDown])
 			_scene->_nextSceneId = _scene->_priorSceneId;
 		else
-			_game._player._stepEnabled       = true;
+			_game._player._stepEnabled = true;
 	}
 
 	if (_game._trigger == 80) {
@@ -690,7 +690,7 @@ void Scene803::step() {
 	}
 
 	if (_game._trigger == 110)
-		_scene->_nextSceneId           = 808;
+		_scene->_nextSceneId = 808;
 
 	if (_game._trigger == 130) {
 		_globals[kBeamIsUp] = true;
@@ -699,7 +699,7 @@ void Scene803::step() {
 
 	if (_game._trigger == 140) {
 		if (!_globals[kWindowFixed]) {
-			_scene->_nextSceneId         = 810;
+			_scene->_nextSceneId = 810;
 			_globals[kInSpace] = true;
 		} else {
 			if (!_globals[kShieldModInstalled])
@@ -723,9 +723,9 @@ void Scene803::step() {
 	}
 
 	if (_game._trigger == 151) {
-		_globals[kBeamIsUp]      = false;
-		_globals[kFromCockpit]    = false;
-		_globals[kExitShip]       = false;
+		_globals[kBeamIsUp] = false;
+		_globals[kFromCockpit] = false;
+		_globals[kExitShip] = false;
 		_game._player._stepEnabled = true;
 	}
 }
@@ -742,8 +742,8 @@ void Scene803::actions() {
 	if (_action.isAction(VERB_TAKE, 0x472)) {
 		switch (_game._trigger) {
 		case 0:
-			_game._player._stepEnabled  = false;
-			_game._player._visible    = false;  
+			_game._player._stepEnabled = false;
+			_game._player._visible = false; 
 			_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[9], 1, 4);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[9]);
@@ -776,7 +776,7 @@ void Scene803::actions() {
 
 		case 163:
 			_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
-			_game._player._visible   = true;
+			_game._player._visible = true;
 			_game._player._stepEnabled = true;
 			break;
 
@@ -908,9 +908,8 @@ void Scene804::step() {
 			_resetFrame = 42;
 		}
 
-		if (_scene->_activeAnimation->getCurrentFrame() == 65) {
+		if (_scene->_activeAnimation->getCurrentFrame() == 65)
 			_scene->_sequences.remove(_globals._sequenceIndexes[7]);
-		}
 
 		switch (_game._storyMode) {
 		case STORYMODE_NAUGHTY:
@@ -1058,6 +1057,123 @@ void Scene804::step() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene805::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(0x476);
+	_scene->addActiveVocab(0x167);
+	_scene->addActiveVocab(0x137);
+}
+
+void Scene805::enter() {
+	_game._player._visible = false;
+	_scene->_userInterface.setup(kInputLimitedSentences);
+
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('a', 1));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 2));
+
+	if (_globals[kShieldModInstalled]) {
+		_scene->_hotspots.activate(OBJ_SHIELD_MODULATOR, false);
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 25);
+		int idx = _scene->_dynamicHotspots.add(0x137, 0x476, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(0, 0), FACING_DUMMY);
+	}
+
+	if (_globals[kTargetModInstalled]) {
+		_scene->_hotspots.activate(OBJ_TARGET_MODULE, false);
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 12);
+		int idx = _scene->_dynamicHotspots.add(0x167, 0x476, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(0, 0), FACING_DUMMY);
+	}
+
+	sceneEntrySound();
+}
+
+void Scene805::step() {
+	if (_game._trigger == 70) {
+		_scene->_hotspots.activate(OBJ_SHIELD_MODULATOR, false);
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 25);
+		int idx = _scene->_dynamicHotspots.add(0x137, 0x476, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(0, 0), FACING_DUMMY);
+		_globals[kShieldModInstalled] = true;
+		_game._objects.setRoom(OBJ_SHIELD_MODULATOR, NOWHERE);
+		_game._player._stepEnabled = true;
+		_vm->_sound->command(24);
+	}
+
+	if (_game._trigger == 80) {
+		_scene->_hotspots.activate(OBJ_TARGET_MODULE, false);
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 12);
+		int idx = _scene->_dynamicHotspots.add(0x167, 0x476, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.setPosition(idx, Common::Point(0, 0), FACING_DUMMY);
+		_globals[kTargetModInstalled] = true;
+		_game._objects.setRoom(OBJ_TARGET_MODULE, NOWHERE);
+		_game._player._stepEnabled = true;
+		_vm->_sound->command(24);
+	}
+
+	if (_game._trigger == 71) {
+		_scene->_hotspots.activate(OBJ_SHIELD_MODULATOR, true);
+		_globals[kShieldModInstalled] = false;
+		_game._objects.addToInventory(OBJ_SHIELD_MODULATOR);
+		_game._player._stepEnabled = true;
+	}
+
+	if (_game._trigger == 81) {
+		_scene->_hotspots.activate(OBJ_TARGET_MODULE, true);
+		_globals[kTargetModInstalled] = false;
+		_game._objects.addToInventory(OBJ_TARGET_MODULE);
+		_game._player._stepEnabled = true;
+	}
+}
+
+void Scene805::preActions() {
+	_game._player._needToWalk = false;
+}
+
+void Scene805::actions() {
+	if (_action.isAction(0x298, 0x398))
+		_scene->_nextSceneId = 804;
+	else if (_action.isAction(0x474, 0x137) && _game._objects.isInInventory(OBJ_SHIELD_MODULATOR)) {
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 7, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], -1, -2);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
+		_game._player._stepEnabled = false;
+	} else if (_action.isAction(0x474, 0x167) && _game._objects.isInInventory(OBJ_TARGET_MODULE)) {
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, -2);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
+		_game._player._stepEnabled = false;
+	} else if (_action.isAction(0x476, 0x137) && _globals[kShieldModInstalled]) {
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]); 
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 7, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], -1, -2);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
+		_game._player._stepEnabled = false;
+	} else if (_action.isAction(0x476, 0x167) && _globals[kTargetModInstalled]) {
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]); 
+		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
+		_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, -2);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 81);
+		_game._player._stepEnabled = false;
+	} else if (_action.isAction(0x474, 0x137) && !_game._objects.isInInventory(OBJ_SHIELD_MODULATOR))
+		_vm->_dialogs->show(80511);
+	else if (_action.isAction(0x474, 0x167) && !_game._objects.isInInventory(OBJ_TARGET_MODULE))
+		_vm->_dialogs->show(80510);
+	else if (_action.isAction(0x476, 0x475))
+		_vm->_dialogs->show(80512);
+	else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 void Scene807::setup() {
 	_game._player._spritesPrefix = "";
 	// The original was calling Scene8xx::setAAName()
diff --git a/engines/mads/nebular/nebular_scenes8.h b/engines/mads/nebular/nebular_scenes8.h
index 3af0a1c..00dcb7e 100644
--- a/engines/mads/nebular/nebular_scenes8.h
+++ b/engines/mads/nebular/nebular_scenes8.h
@@ -111,6 +111,18 @@ public:
 	virtual void actions() {};
 };
 
+class Scene805: public Scene8xx{
+public:
+	Scene805(MADSEngine *vm) : Scene8xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions();
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 class Scene807: public SceneTeleporter {
 public:
 	Scene807(MADSEngine *vm) : SceneTeleporter(vm) {}
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 97fc3e7..8127ee2 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -42,7 +42,7 @@ enum Facing {
 	FACING_NORTH = 8, FACING_SOUTH = 2, FACING_EAST = 6, FACING_WEST = 4,
 	FACING_NORTHEAST = 9, FACING_SOUTHEAST = 3,
 	FACING_SOUTHWEST = 1, FACING_NORTHWEST = 7,
-	FACING_NONE = 5
+	FACING_NONE = 5, FACING_DUMMY = 0
 };
 
 class Player {


Commit: ba4122cca206268f93b248b83c3975d948204e08
    https://github.com/scummvm/scummvm/commit/ba4122cca206268f93b248b83c3975d948204e08
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-18T14:42:19+02:00

Commit Message:
MADS: Implement scene 808

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/nebular/nebular_scenes8.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 8b3456c..4b59d24 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -287,7 +287,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 807:	// teleporter
 		return new Scene807(vm);
 	case 808:	// antigrav control
-		return new DummyScene(vm);	// TODO
+		return new Scene808(vm);
 	case 810:	// cutscene: Rex's ship leaving the planet
 		return new DummyScene(vm);	// TODO
 
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index ab3b67e..b2b2895 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -322,7 +322,7 @@ void Scene802::enter() {
 		_game._player._playerPos.x = _globals[kCutX];
 		_game._player._playerPos.y = _globals[kCutY];
 		_game._player._facing = (Facing)_globals[kCutFacing];
-		_globals[kCutX] = 0; 
+		_globals[kCutX] = 0;
 		_globals[kCameFromCut] = false;
 		_globals[kReturnFromCut] = false;
 		_globals[kBeamIsUp] = false;
@@ -337,8 +337,8 @@ void Scene802::enter() {
 		_game._player._facing = FACING_WEST;
 
 	} else if (_scene->_priorSceneId != -2) {
-		_game._player._playerPos = Common::Point(15, 129); 
-		_game._player._facing = FACING_EAST; 
+		_game._player._playerPos = Common::Point(15, 129);
+		_game._player._facing = FACING_EAST;
 	}
 
 	_game._player._visible = true;
@@ -408,7 +408,7 @@ void Scene802::actions() {
 		switch (_game._trigger) {
 		case (0):
 			_game._player._stepEnabled = false;
-			_game._player._visible = false; 
+			_game._player._visible = false;
 			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], true, 7, 2, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 2);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
@@ -425,7 +425,7 @@ void Scene802::actions() {
 			_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
 			_game._player._visible = true;
 			_scene->_sequences.addTimer(20, 3);
-			break; 
+			break;
 
 		case 3:
 			_game._player._stepEnabled = true;
@@ -440,7 +440,7 @@ void Scene802::actions() {
 		switch (_game._trigger) {
 		case (0):
 			_game._player._stepEnabled = false;
-			_game._player._visible = false; 
+			_game._player._visible = false;
 			_globals._sequenceIndexes[5] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], true, 7, 2, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 1, 4);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
@@ -458,7 +458,7 @@ void Scene802::actions() {
 			_game._player._priorTimer = _scene->_frameStartTime + _game._player._ticksAmount;
 			_game._player._visible = true;
 			_scene->_sequences.addTimer(20, 3);
-			break; 
+			break;
 
 		case 3:
 			_game._player._stepEnabled = true;
@@ -478,7 +478,7 @@ void Scene802::actions() {
 	else if (_globals[kRemoteOnGround] && !_game._objects.isInInventory(OBJ_SHIELD_MODULATOR) && !_globals[kShieldModInstalled]
 		&& (_action.isAction(VERB_LOOK, 0x392) || _action._lookFlag))
 		_vm->_dialogs->show(80213);
-	else if (_globals[kRemoteOnGround] && (_game._objects.isInInventory(OBJ_SHIELD_MODULATOR) || _globals[kShieldModInstalled]) 
+	else if (_globals[kRemoteOnGround] && (_game._objects.isInInventory(OBJ_SHIELD_MODULATOR) || _globals[kShieldModInstalled])
 		&& (_action.isAction(VERB_LOOK, 0x392) || _action._lookFlag))
 		_vm->_dialogs->show(80212);
 	else if (!_game._objects.isInInventory(OBJ_SHIELD_MODULATOR) && !_globals[kShieldModInstalled] && _action.isAction(VERB_LOOK, 0x137))
@@ -537,7 +537,7 @@ void Scene803::enter() {
 		_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, 1);
 		int idx = _scene->_dynamicHotspots.add(0x472, 0xD, _globals._sequenceIndexes[7], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(66, 123), FACING_SOUTH);
-	} 
+	}
 
 	if (!_globals[kBeamIsUp] && !_globals[kReturnFromCut] && (!_globals[kFromCockpit] || _globals[kExitShip])) {
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 1, 0, 0);
@@ -548,8 +548,8 @@ void Scene803::enter() {
 	if (!_globals[kFromCockpit]) {
 		if (!_globals[kReturnFromCut]) {
 			if (_scene->_priorSceneId != -2) {
-				_game._player._playerPos = Common::Point(15, 130); 
-				_game._player._facing = FACING_EAST; 
+				_game._player._playerPos = Common::Point(15, 130);
+				_game._player._facing = FACING_EAST;
 			}
 			_game._player._visible = true;
 		} else if (!_globals[kBeamIsUp]){
@@ -564,13 +564,13 @@ void Scene803::enter() {
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 1);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
 			_vm->_sound->command(14);
-		} 
+		}
 
 		if (_globals[kBeamIsUp] && !_globals[kReturnFromCut]){
 			if (_globals[kForceBeamDown])
 				_game._player._visible = false;
 			else
-				_game._player._visible = true; 
+				_game._player._visible = true;
 
 			_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('b', 1));
 			_vm->_sound->command(15);
@@ -621,7 +621,7 @@ void Scene803::step() {
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 2, 2);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
-		if (!_globals[kHoppyDead]) { 
+		if (!_globals[kHoppyDead]) {
 			_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 7, 1, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 7, 12);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5],SEQUENCE_TRIGGER_EXPIRE, 0, 101);
@@ -642,7 +642,7 @@ void Scene803::step() {
 			else
 				_game._player._stepEnabled = true;
 		}
-	} 
+	}
 
 	if (_game._trigger == 101) {
 		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, -2);
@@ -714,7 +714,7 @@ void Scene803::step() {
 	}
 
 	if (_game._trigger == 150) {
-		_scene->_sequences.remove(_globals._sequenceIndexes[6]); 
+		_scene->_sequences.remove(_globals._sequenceIndexes[6]);
 		_vm->_sound->command(18);
 		_globals._sequenceIndexes[6] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[6], false, 8, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 1, 19);
@@ -743,7 +743,7 @@ void Scene803::actions() {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
-			_game._player._visible = false; 
+			_game._player._visible = false;
 			_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[9], 1, 4);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[9]);
@@ -1147,14 +1147,14 @@ void Scene805::actions() {
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
 		_game._player._stepEnabled = false;
 	} else if (_action.isAction(0x476, 0x137) && _globals[kShieldModInstalled]) {
-		_scene->_sequences.remove(_globals._sequenceIndexes[1]); 
+		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 7, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], -1, -2);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
 		_game._player._stepEnabled = false;
 	} else if (_action.isAction(0x476, 0x167) && _globals[kTargetModInstalled]) {
-		_scene->_sequences.remove(_globals._sequenceIndexes[2]); 
+		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, -2);
@@ -1230,5 +1230,211 @@ void Scene807::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene808::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene808::enter() {
+	_scene->_userInterface.setup(kInputLimitedSentences);
+
+	_globals._spriteIndexes[4] = _scene->_sprites.addSprites ("*REXHAND");
+	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('b', 0));
+	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('b', 1));
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('b', 2));
+
+	if (_globals[kTopButtonPushed])
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+	else
+		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
+
+	_goingTo803 = false;
+
+	if (_globals[kCameFromCut] && _globals[kCutX] != 0) {
+		_globals[kCutX] = 0;
+		_globals[kCameFromCut] = false;
+		_globals[kReturnFromCut] = false;
+		_globals[kBeamIsUp] = false;
+		_globals[kForceBeamDown] = false;
+		_globals[kDontRepeat] = false;
+	} else if ((_scene->_priorSceneId == 803) && _globals[kReturnFromCut]){
+		_globals[kDontRepeat] = false;
+		_globals[kBeamIsUp] = true;
+		_globals[kAntigravClock] = _scene->_frameStartTime;
+		_globals[kAntigravTiming] = _scene->_frameStartTime;
+		_globals[kForceBeamDown] = false;
+		_globals[kReturnFromCut] = false;
+	}
+
+	_globals[kBetweenRooms] = false;
+
+	if (_globals[kBeamIsUp]) {
+		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 8);
+	}
+
+	sceneEntrySound();
+}
+
+void Scene808::actions() {
+	if (_action.isAction(0x11A, 0x3BC)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 4, 1, 0, 0);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(248, 211));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
+			break;
+
+		case 70:
+			if (!_globals[kBeamIsUp] && !_globals[kTopButtonPushed]) {
+				_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 8);
+				_goingTo803 = true;
+				_vm->_sound->command(20);
+				_vm->_sound->command(25);
+			}
+			_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 4, 1, 0, 0);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(248, 211));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
+			break;
+
+		case 71:
+			_game._player._stepEnabled = true;
+			if (_goingTo803 && !_globals[kTopButtonPushed]) {
+				_goingTo803 = false;
+				_globals[kReturnFromCut] = true;
+				_scene->_nextSceneId = 803;
+			}
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(0x11A, 0x3BE)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 4, 1, 0, 0);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(248, 186));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 90);
+			break;
+		case 90:
+			if (_globals[kTopButtonPushed]) {
+				_scene->_sequences.remove(_globals._sequenceIndexes[1]);
+				_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 8);
+				_vm->_sound->command(20);
+			}
+			_globals[kTopButtonPushed] = false;
+			_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 4, 1, 0, 0);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(248, 186));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 91);
+			break;
+
+		case 91:
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(0x11A, 0x3BD)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 4, 1, 0, 0);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(248, 163));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
+			break;
+
+		case 80:
+			if (!_globals[kTopButtonPushed]) {
+				_scene->_sequences.remove(_globals._sequenceIndexes[2]);
+				_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
+				_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 8);
+				_vm->_sound->command(20);
+			 }
+			_globals[kTopButtonPushed] = true;
+			_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 4, 1, 0, 0);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(248, 163));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 81);
+			break;
+
+		case 81:
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(0x11A, 0x3BF)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 4, 2, 0, 0);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(168, 211));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
+			break;
+
+		case 70:
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(0x11A, 0x3BB)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 4, 2, 0, 0);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(172, 163));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
+			break;
+
+		case 80:
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(0x11A, 0x3BA)) {
+		switch (_game._trigger) {
+		case 0:
+			_game._player._stepEnabled = false;
+			_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 4, 2, 0, 0);
+			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(172, 186));
+			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 2);
+			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 90);
+			break;
+
+		case 90:
+			_game._player._stepEnabled = true;
+			break;
+
+		default:
+			break;
+		}
+	} else if (_action.isAction(0x298, 0x1E0)) {
+		_scene->_nextSceneId = 801;
+		_globals[kBetweenRooms] = true;
+	} else
+		return;
+
+	_action._inProgress = false;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes8.h b/engines/mads/nebular/nebular_scenes8.h
index 00dcb7e..7c22853 100644
--- a/engines/mads/nebular/nebular_scenes8.h
+++ b/engines/mads/nebular/nebular_scenes8.h
@@ -133,6 +133,21 @@ public:
 	virtual void actions();
 };
 
+class Scene808: public Scene8xx{
+private:
+	bool _goingTo803;
+
+public:
+	Scene808(MADSEngine *vm) : Scene8xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step() {};
+	virtual void preActions() {};
+	virtual void actions();
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: d3b136993f6a47ce5701462b641598bc7180142c
    https://github.com/scummvm/scummvm/commit/d3b136993f6a47ce5701462b641598bc7180142c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-18T14:52:19+02:00

Commit Message:
MADS: Implement scene 810

Changed paths:
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/nebular/nebular_scenes8.h



diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index 4b59d24..f8c113e 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -289,7 +289,7 @@ SceneLogic *SceneFactory::createScene(MADSEngine *vm) {
 	case 808:	// antigrav control
 		return new Scene808(vm);
 	case 810:	// cutscene: Rex's ship leaving the planet
-		return new DummyScene(vm);	// TODO
+		return new Scene810(vm);
 
 	default:
 		error("Invalid scene %d called", scene._nextSceneId);
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index b2b2895..fee39a7 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -1436,5 +1436,32 @@ void Scene808::actions() {
 
 /*------------------------------------------------------------------------*/
 
+void Scene810::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
+void Scene810::enter() {
+	_scene->_userInterface.setup(kInputLimitedSentences);
+	_game._player._visible = false;
+	_game._player._stepEnabled = false;
+	_scene->loadAnimation(Resources::formatName(810, 'a', -1, EXT_AA, ""));
+	_moveAllowed = true;
+
+	sceneEntrySound();
+}
+
+void Scene810::step() {
+	if ((_scene->_activeAnimation->getCurrentFrame() == 200) && _moveAllowed) {
+		_scene->_sequences.addTimer(100, 70);
+		_moveAllowed = false;
+	}
+
+	if (_game._trigger == 70)
+		_scene->_nextSceneId = 804;
+}
+
+/*------------------------------------------------------------------------*/
+
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes8.h b/engines/mads/nebular/nebular_scenes8.h
index 7c22853..5193c4f 100644
--- a/engines/mads/nebular/nebular_scenes8.h
+++ b/engines/mads/nebular/nebular_scenes8.h
@@ -148,6 +148,21 @@ public:
 	virtual void postActions() {};
 };
 
+class Scene810: public Scene8xx{
+private:
+	bool _moveAllowed;
+
+public:
+	Scene810(MADSEngine *vm) : Scene8xx(vm) {}
+
+	virtual void setup();
+	virtual void enter();
+	virtual void step();
+	virtual void preActions() {};
+	virtual void actions() {};
+	virtual void postActions() {};
+};
+
 } // End of namespace Nebular
 } // End of namespace MADS
 


Commit: e59d2ace2db3a9c52195332655798e93f19a54d9
    https://github.com/scummvm/scummvm/commit/e59d2ace2db3a9c52195332655798e93f19a54d9
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-18T20:57:59+02:00

Commit Message:
MADS: Some work and bugfixing in scene 701

Changed paths:
    engines/mads/nebular/nebular_scenes7.cpp



diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index cc24070..85c79e4 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -103,7 +103,7 @@ void Scene701::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('b', 5));
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('b', 0));
-	//_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('b', 1));	// FIXME: Broken sprite?
+//	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('b', 1));	// TODO: FIXME: Broken sprite?
 	_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RM202A1");
 	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('b', 8));
 
@@ -156,15 +156,15 @@ void Scene701::enter() {
 		break;
 	}
 
-	// TODO: Enable once sprite 3 can be loaded properly
-	/*
+// TODO: Enable once sprite 3 can be loaded properly
+/*
 	if (_globals[kLineStatus] == LINE_DROPPED || _globals[kLineStatus] == LINE_TIED) {
 		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 8);
 		int idx = _scene->_dynamicHotspots.add(NOUN_FISHING_LINE, VERB_WALKTO, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
 		_fishingLineId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(234, 129), FACING_NORTHEAST);
 	}
-	*/
+*/
 
 	if (_scene->_priorSceneId == 702) {
 		_game._player._playerPos = Common::Point(309, 138);
@@ -203,11 +203,13 @@ void Scene701::step() {
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[5], Common::Point(155, 129));
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 61);
 		break;
+
 	case 61:
 		_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[5]);
 		_game._player._visible = true;
 		_game._player._stepEnabled = true;
 		break;
+
 	case 70:
 		_vm->_sound->command(16);
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
@@ -216,10 +218,12 @@ void Scene701::step() {
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
 		break;
+
 	case 71:
 		_game._player.walk(Common::Point(61, 131), FACING_EAST);
 		_scene->_sequences.addTimer(2 * 60, 72);
 		break;
+
 	case 72:
 		_vm->_sound->command(17);
 		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 5, 1, 0, 0);
@@ -227,14 +231,16 @@ void Scene701::step() {
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 73);
 		break;
+
 	case 73:
 		_game._player._stepEnabled = true;
-		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1); 
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 		_scene->_kernelMessages.reset();
 		break;
-	case 80:
+
+	case 80: {
 		_game._player._visible = true;
 		_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
@@ -243,28 +249,29 @@ void Scene701::step() {
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(234, 129), FACING_NORTH);
 		_globals[kBoatStatus] = BOAT_TIED;
 		_game._player._stepEnabled = true;
+		}
+		break;
+
+	default:
 		break;
 	}
 }
 
 void Scene701::preActions() {
-	if (_action.isAction(VERB_WALKTO, NOUN_EAST_END_OF_PLATFORM)) {
+	if (_action.isAction(VERB_WALKTO, NOUN_EAST_END_OF_PLATFORM))
 		_game._player._walkOffScreenSceneId = 702;
-	}
 
-	if (_action.isAction(VERB_LOOK, NOUN_BUILDING)) {
+	if (_action.isAction(VERB_LOOK, NOUN_BUILDING))
 		_game._player.walk(Common::Point(154, 129), FACING_NORTHEAST);
-	}
 
-	if (_action.isAction(VERB_LOOK, NOUN_BINOCULARS, NOUN_BUILDING)) {
+	if (_action.isAction(VERB_LOOK, NOUN_BINOCULARS, NOUN_BUILDING))
 		_game._player.walk(Common::Point(154, 129), FACING_NORTH);
-	}
 }
 
 void Scene701::actions() {
 	if (_action.isAction(VERB_WALK_ALONG, NOUN_PLATFORM))
 		return;
-	
+
 	if (_action.isAction(VERB_LOOK, NOUN_BINOCULARS, NOUN_BUILDING) && _game._objects[OBJ_VASE]._roomNumber == 706) {
 		switch (_game._trigger) {
 		case 0:
@@ -274,6 +281,7 @@ void Scene701::actions() {
 			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[5], Common::Point(155, 129));
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			break;
+
 		case 1: {
 			int temp = _globals._sequenceIndexes[5];
 			_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, -2);
@@ -282,9 +290,13 @@ void Scene701::actions() {
 			_scene->_sequences.addTimer(15, 2);
 			}
 			break;
+
 		case 2:
 			_scene->_nextSceneId = 710;
 			break;
+
+		default:
+			break;
 		}
 	} else if (_action.isAction(VERB_STEP_INTO, NOUN_ELEVATOR)) {
 		switch (_game._trigger) {
@@ -299,10 +311,12 @@ void Scene701::actions() {
 			_scene->_kernelMessages.add(Common::Point(0, 0), 0x310, 34, 0, 120, _game.getQuote(0x30D));
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			break;
+
 		case 1:
 			_game._player.walk(Common::Point(22, 131), FACING_EAST);
 			_scene->_sequences.addTimer(2 * 60, 3);
 			break;
+
 		case 3:
 			_vm->_sound->command(17);
 			_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 5, 1, 0, 0);
@@ -310,13 +324,17 @@ void Scene701::actions() {
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 4);
 			break;
+
 		case 4:
-			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1); 
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
 			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 			_globals[kResurrectRoom] = 701;
 			_scene->_nextSceneId = 605;
 			break;
+
+		default:
+			break;
 		}
 	} else if ((_action.isAction(VERB_PULL, NOUN_BOAT) || _action.isAction(VERB_TAKE, NOUN_BOAT) ||
 			   _action.isAction(VERB_PULL, NOUN_FISHING_LINE) || _action.isAction(VERB_TAKE, NOUN_FISHING_LINE)) &&
@@ -324,21 +342,43 @@ void Scene701::actions() {
 		if (_globals[kBoatStatus] == BOAT_TIED_FLOATING) {
 			switch (_game._trigger) {
 			case 0:
-				// TODO
+				_game._player._stepEnabled = false;
+				_scene->_sequences.remove(_globals._sequenceIndexes[4]);
+				_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+				_scene->_dynamicHotspots.remove(_fishingLineId);
+				_scene->_hotspots.activate(NOUN_BOAT, false);
+				_game._player._visible = false;
+				_scene->loadAnimation(formAnimName('E', -1), 1);
 				break;
-			case 1:
-				// TODO
+
+			case 1: {
+				_game._player._visible = true;
+				_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
+				_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
+				_scene->_sequences.setDepth (_globals._sequenceIndexes[2], 9);
+				int idx = _scene->_dynamicHotspots.add(NOUN_BOAT, VERB_CLIMB_INTO, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+				_scene->_dynamicHotspots.setPosition(idx, Common::Point(231, 127), FACING_NORTH);
+				_scene->_sequences.addTimer(15, 2);
+				}
 				break;
+
 			case 2:
 				_globals[kBoatStatus] = BOAT_TIED;
 				_globals[kLineStatus] = LINE_NOW_UNTIED;
 				_game._player._stepEnabled = true;
 				break;
+
+			default:
+				break;
 			}
 		} else if (_globals[kBoatStatus] == BOAT_TIED) {
 			_vm->_dialogs->show(70125);
 		} else if (_globals[kLineStatus] == LINE_DROPPED) {
-			// TODO
+			_globals[kLineStatus] = LINE_NOW_UNTIED;
+			_game._objects.addToInventory(OBJ_FISHING_LINE);
+			_vm->_sound->command(15);
+			_scene->_sequences.remove(_globals._sequenceIndexes[3]);
+			_vm->_dialogs->showItem(OBJ_FISHING_LINE, 70126);
 		} else {
 			_vm->_dialogs->show(70127);
 		}
@@ -350,9 +390,13 @@ void Scene701::actions() {
 			_game._player._visible = false;
 			_scene->loadAnimation(formAnimName('B', 0), 1);
 			break;
+
 		case 1:
 			_scene->_nextSceneId = 703;
 			break;
+
+		default:
+			break;
 		}
 	} else if (_action._lookFlag) {
 		if (_globals[kBoatStatus] != BOAT_GONE) {
@@ -360,39 +404,40 @@ void Scene701::actions() {
 				_vm->_dialogs->show(70128);
 			else
 				_vm->_dialogs->show(70110);
-		} else {
+		} else
 			_vm->_dialogs->show(70111);
-		}
-	} else if (_action.isAction(VERB_LOOK, NOUN_SUBMERGED_CITY)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_SUBMERGED_CITY))
 		_vm->_dialogs->show(70112);
-	} else if (_action.isAction(VERB_LOOK, 0)) {
+	else if (_action.isAction(VERB_LOOK, 0))
 		_vm->_dialogs->show(70113);
-	} else if (_action.isAction(VERB_LOOK, NOUN_PLATFORM)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_PLATFORM))
 		_vm->_dialogs->show(70114);
-	} else if (_action.isAction(VERB_LOOK, NOUN_CEMENT_PYLON)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_CEMENT_PYLON))
 		_vm->_dialogs->show(70115);
-	} else if (_action.isAction(VERB_LOOK, NOUN_HOOK)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_HOOK)) {
 		if (_globals[kLineStatus] == LINE_NOT_DROPPED || _globals[kLineStatus] == LINE_NOW_UNTIED)
 			_vm->_dialogs->show(70116);
 		else
 			_vm->_dialogs->show(70117);
-	} else if (_action.isAction(VERB_LOOK, NOUN_ROCK)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_ROCK))
 		_vm->_dialogs->show(70118);
-	} else if (_action.isAction(VERB_TAKE, NOUN_ROCK)) {
+	else if (_action.isAction(VERB_TAKE, NOUN_ROCK))
 		_vm->_dialogs->show(70119);
-	} else if (_action.isAction(VERB_LOOK, NOUN_EAST_END_OF_PLATFORM)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_EAST_END_OF_PLATFORM))
 		_vm->_dialogs->show(70120);
-	} else if (_action.isAction(VERB_LOOK, NOUN_BUILDING)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_BUILDING))
 		_vm->_dialogs->show(70121);
-	} else if (_action.isAction(VERB_LOOK, NOUN_BOAT)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_BOAT)) {
 		if (_globals[kBoatStatus] == BOAT_ADRIFT || _globals[kBoatStatus] == BOAT_TIED_FLOATING)
 			_vm->_dialogs->show(70122);
 		else
 			_vm->_dialogs->show(70123);
-	} else if (_action.isAction(VERB_CAST, NOUN_FISHING_ROD, NOUN_BOAT)) {
-		if (_game._objects.isInInventory(OBJ_FISHING_LINE))
-			_vm->_dialogs->show(70124);
-	}
+	} else if (_action.isAction(VERB_CAST, NOUN_FISHING_ROD, NOUN_BOAT) && _game._objects.isInInventory(OBJ_FISHING_LINE))
+		_vm->_dialogs->show(70124);
+	else
+		return;
+
+	_action._inProgress = false;
 }
 
 /*------------------------------------------------------------------------*/
@@ -1812,13 +1857,13 @@ void Scene706::actions() {
 		_action._inProgress = false;
 		return;
 	}
-	
+
 	if (_action.isAction(0x298, 0x2FA)) {
 		_scene->_nextSceneId = 705;
 		_action._inProgress = false;
 		return;
 	}
-	
+
 	if (_action.isAction(VERB_TAKE, 0x17D)) {
 		if (_game._difficulty != DIFFICULTY_EASY) {
 			_animationMode = 1;
@@ -1830,7 +1875,7 @@ void Scene706::actions() {
 		_action._inProgress = false;
 		return;
 	}
-	
+
 	if (_action.isAction(VERB_PUT, 0x2E, 0x344)) {
 		if ((_globals[kBottleStatus] == 2 && _game._difficulty == DIFFICULTY_HARD) ||
 			 (_globals[kBottleStatus] != 0 && _game._difficulty != DIFFICULTY_HARD)) {
@@ -1847,7 +1892,7 @@ void Scene706::actions() {
 			return;
 		}
 	}
-	
+
 	if (_action.isAction(VERB_PUT, 0x344) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
 		int objectId = _game._objects.getIdFromDesc(_action._activeAction._objectNameId);
 		if (_game._objects[objectId].hasQuality(10))
@@ -2083,7 +2128,7 @@ void Scene751::enter() {
 	} else if (_rexHandingLine) {
 		_game._player._visible = false;
 		_game._player._playerPos = Common::Point(268, 140);
-		_game._player._facing = FACING_NORTHWEST; 
+		_game._player._facing = FACING_NORTHWEST;
 		_game._player._visible = false;
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 7);
 		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
@@ -2140,7 +2185,7 @@ void Scene751::step() {
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 61);
-		break; 
+		break;
 
 	case 61:
 		_game._player.walk(Common::Point(61, 131), FACING_EAST);
@@ -2153,10 +2198,10 @@ void Scene751::step() {
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 63);
-		break; 
+		break;
 
 	case 63:
-		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1); 
+		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 		_game._player._stepEnabled = true;
@@ -2201,12 +2246,12 @@ void Scene751::preActions() {
 			_game._player._visible = true;
 			_rexHandingLine = false;
 			_game._player._stepEnabled = true;
-			_game._player._readyToWalk = true; 
+			_game._player._readyToWalk = true;
 			break;
 
 		default:
 			break;
-		} 
+		}
 	}
 }
 
@@ -2239,7 +2284,7 @@ void Scene751::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(0x2F9, 0x317)) { 
+	} else if (_action.isAction(0x2F9, 0x317)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -2254,7 +2299,7 @@ void Scene751::actions() {
 			break;
 
 		case 1:
-			_game._player.walk(Common::Point(22, 131), FACING_EAST); 
+			_game._player.walk(Common::Point(22, 131), FACING_EAST);
 			_scene->_sequences.addTimer(120, 3);
 			break;
 
@@ -2267,7 +2312,7 @@ void Scene751::actions() {
 			break;
 
 		case 4:
-			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1); 
+			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
 			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 			_scene->_sequences.addTimer(60, 5);
@@ -2337,7 +2382,7 @@ void Scene751::actions() {
 		_vm->_dialogs->show(75113);
 	else if (_action.isAction(VERB_LOOK, 0x316))
 		_vm->_dialogs->show(75114);
-	else if ((_action.isAction(VERB_LOOK, 0x467) || _action.isAction(VERB_LOOK, 0x87)) 
+	else if ((_action.isAction(VERB_LOOK, 0x467) || _action.isAction(VERB_LOOK, 0x87))
 		&& (_globals[kLineStatus] == 2 || _globals[kLineStatus] == 3))
 		_vm->_dialogs->show(75116);
 	else if (_action.isAction(VERB_LOOK, 0x467))


Commit: cacd7c51ed9e06abc8a5c9e301054a585b7aab45
    https://github.com/scummvm/scummvm/commit/cacd7c51ed9e06abc8a5c9e301054a585b7aab45
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-18T20:58:01+02:00

Commit Message:
MADS: Remove temporary DummyScene

Changed paths:
    engines/mads/nebular/nebular_scenes.h



diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 2c38dd0..ac98363 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -232,20 +232,7 @@ protected:
 	SceneTeleporter(MADSEngine *vm) : NebularScene(vm) {}
 };
 
-// TODO: Temporary, remove once all scenes are implemented properly
-class DummyScene: public NebularScene {
-public:
-	DummyScene(MADSEngine *vm) : NebularScene(vm) {
-		warning("Unimplemented scene");
-	}
-
-	virtual void setup() {}
-	virtual void enter() {}
-	virtual void actions() {}
-};
-
 } // End of namespace Nebular
-
 } // End of namespace MADS
 
 #endif /* MADS_NEBULAR_SCENES_H */


Commit: 96aaf48f44c9c832e5b0daa66a57726ca732b9d9
    https://github.com/scummvm/scummvm/commit/96aaf48f44c9c832e5b0daa66a57726ca732b9d9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-18T16:12:40-04:00

Commit Message:
MADS: Changed 16-bit globals over to be 32-bits

Changed paths:
    engines/mads/globals.cpp
    engines/mads/globals.h
    engines/mads/nebular/globals_nebular.cpp
    engines/mads/nebular/globals_nebular.h



diff --git a/engines/mads/globals.cpp b/engines/mads/globals.cpp
index f46ca1e..1d08899 100644
--- a/engines/mads/globals.cpp
+++ b/engines/mads/globals.cpp
@@ -26,28 +26,8 @@
 namespace MADS {
 
 void Globals::reset() {
-	for (uint i = 0; i < _data.size(); ++i)
-		_data[i] = 0;
+	for (uint i = 0; i < size(); ++i)
+		(*this)[i] = 0;
 }
 
-void Globals::synchronize(Common::Serializer &s) {
-	int count = _data.size();
-	s.syncAsUint16LE(count);
-	int16 v;
-
-	if (s.isSaving()) {
-		for (int idx = 0; idx < count; ++idx) {
-			v = _data[idx];
-			s.syncAsSint16LE(v);
-		}
-	} else {
-		_data.clear();
-		for (int idx = 0; idx < count; ++idx) {
-			s.syncAsSint16LE(v);
-			_data.push_back(v);
-		}
-	}
-}
-
-
 } // End of namespace MADS
diff --git a/engines/mads/globals.h b/engines/mads/globals.h
index 92e9d96..92cd0bb 100644
--- a/engines/mads/globals.h
+++ b/engines/mads/globals.h
@@ -26,31 +26,20 @@
 #include "common/scummsys.h"
 #include "common/array.h"
 #include "common/serializer.h"
+#include "mads/resources.h"
 
 namespace MADS {
 
-class Globals {
-protected:
-	Common::Array<int16> _data;
+class Globals: public SynchronizedList {
 public:
 	Globals() {}
 
 	virtual ~Globals() {}
 
-	/**
-	* Square brackets operator for accessing flags
-	*/
-	int16 &operator[](int idx) { return _data[idx]; }
-
 	/*
 	 * Resets all the globals to empty
 	 */
 	void reset();
-
-	/**
-	 * Synchronize the globals data
-	 */
-	virtual void synchronize(Common::Serializer &s);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/globals_nebular.cpp b/engines/mads/nebular/globals_nebular.cpp
index 2e50794..7bb89a5 100644
--- a/engines/mads/nebular/globals_nebular.cpp
+++ b/engines/mads/nebular/globals_nebular.cpp
@@ -30,7 +30,7 @@ namespace Nebular {
 
 NebularGlobals::NebularGlobals(): Globals() {
 	// Initialize lists
-	_data.resize(210);
+	resize(210);
 	_spriteIndexes.resize(30);
 	_sequenceIndexes.resize(30);
 
diff --git a/engines/mads/nebular/globals_nebular.h b/engines/mads/nebular/globals_nebular.h
index fea90c5..980e6ea 100644
--- a/engines/mads/nebular/globals_nebular.h
+++ b/engines/mads/nebular/globals_nebular.h
@@ -36,7 +36,7 @@ enum GlobalId {
 	kSexOfRex				= 0,
 	kOldSexOfRex			= 1,
 	kWalkerTiming           = 2,
-	kWalkerTiming0			= 3,
+//	kWalkerTiming0			= 3,
 	kTalkInanimateCount		= 4,
 	kCopyProtectFailed		= 5,
 
@@ -162,9 +162,9 @@ enum GlobalId {
 
 	/* Section #6 Time-Bomb Variables */
 	kTimebombClock			= 142,
-	kTimebombClock0			= 143,
+//	kTimebombClock0			= 143,
 	kTimebombTimer			= 144,
-	kTimebombTimer0			= 145,
+//	kTimebombTimer0			= 145,
 	kWarnedFloodCity		= 146,
 
 	/* Section #7 Variables */
@@ -175,9 +175,9 @@ enum GlobalId {
 
 	/* Section #8 Variables */
 	kAntigravClock			= 160,
-	kAntigravClock0			= 161,
+//	kAntigravClock0			= 161,
 	kAntigravTiming			= 162,
-	kAntigravTiming0		= 163,
+//	kAntigravTiming0		= 163,
 	kWindowFixed			= 164,
 	kInSpace                = 165,
 	kReturnFromCut			= 166,


Commit: edb5db36b525526eea3622c38ec1057e103e76a2
    https://github.com/scummvm/scummvm/commit/edb5db36b525526eea3622c38ec1057e103e76a2
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-18T22:30:11+02:00

Commit Message:
MADS: Add removePlayerSprites(), remove a TODO

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/player.cpp
    engines/mads/player.h



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 1f5200a..b423b9f 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1331,8 +1331,7 @@ void Scene205::actions() {
 			_game._player._stepEnabled = false;
 			_vm->_palette->lock();
 			_scene->_kernelMessages.reset();
-			warning("TODO: sub70402();");
-
+			_game._player.removePlayerSprites();
 			_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('a', 0));
 			_vm->_palette->refreshSceneColors();
 			_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 96e2cd6..edec92a 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -766,4 +766,18 @@ void Player::synchronize(Common::Serializer &s) {
 	s.syncAsByte(_mirror);
 }
 
+void Player::removePlayerSprites() {
+	int heroSpriteId = _spritesStart;
+	for (int i = 0; i < 8; i++) {
+		if (_spriteSetsPresent[i]) {
+			_vm->_game->_scene._sprites.remove(heroSpriteId++);
+			_spriteSetsPresent[i] = false;
+		}
+	}
+
+	_vm->_game->_scene._spriteSlots.clear();
+	_vm->_game->_scene._spriteSlots.fullRefresh();
+	_vm->_game->_player._visible = false;
+}
+
 } // End of namespace MADS
diff --git a/engines/mads/player.h b/engines/mads/player.h
index 8127ee2..671ac9d 100644
--- a/engines/mads/player.h
+++ b/engines/mads/player.h
@@ -219,6 +219,8 @@ public:
 	static void preloadSequences(const Common::String &prefix, int level) {
 		// No implementation in ScummVM
 	}
+
+	void removePlayerSprites();
 };
 
 } // End of namespace MADS


Commit: 7f82b0eafa1663c6f8a46ba62f267cfef85dd2c5
    https://github.com/scummvm/scummvm/commit/7f82b0eafa1663c6f8a46ba62f267cfef85dd2c5
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-18T23:00:04+02:00

Commit Message:
MADS: Rework removePlayerSprites(), get rid of another TODO

Changed paths:
    engines/mads/animation.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/player.cpp



diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 0556c3a..a1d957e 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -217,6 +217,8 @@ public:
 	bool freeFlag() const { return _freeFlag; }
 	bool getAnimMode() const { return _header._animMode; }
 	int roomNumber() const { return _header._roomNumber; }
+
+	void resetSpriteSetsCount() { _header._spriteSetsCount = 0; } // CHECKME: See if it doesn't leak the memory when the destructor is called
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index b423b9f..0f8af57 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1340,7 +1340,7 @@ void Scene205::actions() {
 			_vm->_sound->command(27);
 		} else if (_game._trigger == 1) {
 			if (_scene->_activeAnimation != nullptr)
-				warning("scene->_activeAnimation._spriteSetsCount = 0;");
+				_scene->_activeAnimation->resetSpriteSetsCount();
 
 			_vm->_dialogs->show(20516);
 			_scene->_reloadSceneFlag = true;
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index edec92a..3672c80 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -767,17 +767,20 @@ void Player::synchronize(Common::Serializer &s) {
 }
 
 void Player::removePlayerSprites() {
+	Scene &scene = _vm->_game->_scene;
 	int heroSpriteId = _spritesStart;
 	for (int i = 0; i < 8; i++) {
 		if (_spriteSetsPresent[i]) {
-			_vm->_game->_scene._sprites.remove(heroSpriteId++);
+			scene._sprites.remove(heroSpriteId++);
 			_spriteSetsPresent[i] = false;
 		}
 	}
 
-	_vm->_game->_scene._spriteSlots.clear();
-	_vm->_game->_scene._spriteSlots.fullRefresh();
-	_vm->_game->_player._visible = false;
+	if (scene._activeAnimation != nullptr)
+		scene._activeAnimation->resetSpriteSetsCount();
+
+	scene._spriteSlots.fullRefresh();
+	_visible = false;
 }
 
 } // End of namespace MADS


Commit: 46cedfc90384708bfddcd1bbc6d9468ca3014f31
    https://github.com/scummvm/scummvm/commit/46cedfc90384708bfddcd1bbc6d9468ca3014f31
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-19T07:04:26+02:00

Commit Message:
MADS: Implement two palette functions

Changed paths:
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 4652c51..4358aa4 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -3236,8 +3236,8 @@ void Scene319::step() {
 		break;
 
 	case 72:
-		warning("TODO: sub7CBD8(-1, 0, 0);");
-		warning("TODO: sub7CBE4(0, 0, 0);");
+		_vm->_palette->setColorFlags(0xFF, 0, 0);
+		_vm->_palette->setColorValues(0, 0, 0);
 		_vm->_palette->fadeOut(_vm->_palette->_mainPalette, 18, 228, 16, 1, 8, 248, 0, 0);
 		warning("TODO: shake_countdown = 1;");
 		_scene->_reloadSceneFlag = true;
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index e718059..a4608a6 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -714,6 +714,18 @@ void Palette::setLowRange() {
 	_vm->_palette->setPalette(_mainPalette, 0, 4);
 }
 
+void Palette::setColorFlags(byte r, byte g, byte b) {
+	_colorFlags[0] = r;
+	_colorFlags[1] = g;
+	_colorFlags[2] = b;
+}
+
+void Palette::setColorValues(byte r, byte g, byte b) {
+	_colorValues[0] = r;
+	_colorValues[1] = g;
+	_colorValues[2] = b;
+}
+
 void Palette::fadeOut(byte palette[PALETTE_SIZE], int start, int count, int v1, int v2, int v3, int v4, int v5, int v6) {
 	warning("TODO: Palette::fadeOut()");
 }
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index e1f7de8..3af0c28 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -308,6 +308,8 @@ public:
 		warning("TODO: Palette::close");
 	}
 
+	void setColorFlags(byte r, byte g, byte b);
+	void setColorValues(byte r, byte g, byte b);
 	void fadeOut(byte palette[PALETTE_SIZE], int start, int count, int v1, int v2, int v3, int v4, int v5, int v6);
 
 	void lock();


Commit: e016e65767598d5aeb172f3cce8bcb106df25ddc
    https://github.com/scummvm/scummvm/commit/e016e65767598d5aeb172f3cce8bcb106df25ddc
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-19T20:53:40+02:00

Commit Message:
MADS: Reduce the scope of a variable in Action, rename some British variable names

Changed paths:
    engines/mads/action.cpp
    engines/mads/action.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index 5d63c3a..f26a999 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -87,9 +87,9 @@ void MADSAction::clear() {
 	_pickedWord = 0;
 }
 
-void MADSAction::appendVocab(int vocabId, bool capitalise) {
+void MADSAction::appendVocab(int vocabId, bool capitalize) {
 	Common::String vocabStr = _vm->_game->_scene.getVocab(vocabId);
-	if (capitalise)
+	if (capitalize)
 		vocabStr.setChar(toupper(vocabStr[0]), 0);
 
 	_statusText += vocabStr;
@@ -109,7 +109,6 @@ void MADSAction::startWalkingDirectly(int walkType) {
 void MADSAction::set() {
 	Scene &scene = _vm->_game->_scene;
 	UserInterface &userInterface = scene._userInterface;
-	bool flag = false;
 	_statusText = "";
 
 	_action._verbId = VERB_NONE;
@@ -128,6 +127,7 @@ void MADSAction::set() {
 		// Two 'look' actions in succession, so the action becomes 'Look around'
 		_statusText = kLookAroundStr;
 	} else {
+		bool flag = false;
 		if ((_commandSource == CAT_INV_VOCAB) && (_selectedRow >= 0)
 				&& (_verbType == VERB_THAT) && (_prepType == PREP_NONE)) {
 			// Use/to action
@@ -137,7 +137,7 @@ void MADSAction::set() {
 			_action._objectNameId = objEntry._descId;
 			_action._verbId = objEntry._vocabList[_selectedRow]._vocabId;
 
-			// Set up the status text stirng
+			// Set up the status text string
 			_statusText = kUseStr;
 			appendVocab(_action._objectNameId);
 			_statusText += kToStr;
diff --git a/engines/mads/action.h b/engines/mads/action.h
index af52d2c..3010226 100644
--- a/engines/mads/action.h
+++ b/engines/mads/action.h
@@ -106,7 +106,7 @@ private:
 	MADSEngine *_vm;
 	Common::String _statusText;
 
-	void appendVocab(int vocabId, bool capitalise = false);
+	void appendVocab(int vocabId, bool capitalize = false);
 
 	void startWalkingDirectly(int walkType);
 public:


Commit: 6d1fc8256f19e0b320b9b160b198f17af1cd14ff
    https://github.com/scummvm/scummvm/commit/6d1fc8256f19e0b320b9b160b198f17af1cd14ff
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-19T20:56:03+02:00

Commit Message:
MADS: Some more British -> American English modifications

Changed paths:
    engines/mads/dragonsphere/game_dragonsphere.cpp
    engines/mads/dragonsphere/game_dragonsphere.h
    engines/mads/game.cpp
    engines/mads/game.h
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/game_nebular.cpp
    engines/mads/nebular/game_nebular.h
    engines/mads/nebular/sound_nebular.cpp
    engines/mads/phantom/game_phantom.cpp
    engines/mads/phantom/game_phantom.h



diff --git a/engines/mads/dragonsphere/game_dragonsphere.cpp b/engines/mads/dragonsphere/game_dragonsphere.cpp
index 49c3846..bee5312 100644
--- a/engines/mads/dragonsphere/game_dragonsphere.cpp
+++ b/engines/mads/dragonsphere/game_dragonsphere.cpp
@@ -58,7 +58,7 @@ ProtectionResult GameDragonsphere::checkCopyProtection() {
 	return PROTECTION_SUCCEED;
 }
 
-void GameDragonsphere::initialiseGlobals() {
+void GameDragonsphere::initializeGlobals() {
 	//int count, count2;
 	//int bad;
 
diff --git a/engines/mads/dragonsphere/game_dragonsphere.h b/engines/mads/dragonsphere/game_dragonsphere.h
index 2bfcde1..cd7ac57 100644
--- a/engines/mads/dragonsphere/game_dragonsphere.h
+++ b/engines/mads/dragonsphere/game_dragonsphere.h
@@ -53,7 +53,7 @@ protected:
 
 	virtual ProtectionResult checkCopyProtection();
 
-	virtual void initialiseGlobals();
+	virtual void initializeGlobals();
 
 	virtual void setSectionHandler();
 
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 3c69f45..118dc82 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -95,7 +95,7 @@ Game::~Game() {
 }
 
 void Game::run() {
-	initialiseGlobals();
+	initializeGlobals();
 
 	// If requested, load a savegame instead of showing the intro
 	if (ConfMan.hasKey("save_slot")) {
@@ -144,7 +144,7 @@ void Game::run() {
 	}
 
 	if (protectionResult != 1 && protectionResult != 2) {
-		initialiseGlobals();
+		initializeGlobals();
 	}
 
 	if (_statusFlag)
diff --git a/engines/mads/game.h b/engines/mads/game.h
index d171638..a55de61 100644
--- a/engines/mads/game.h
+++ b/engines/mads/game.h
@@ -112,7 +112,7 @@ protected:
 	/**
 	 * Initialises global variables for a new game
 	 */
-	virtual void initialiseGlobals() = 0;
+	virtual void initializeGlobals() = 0;
 
 	/**
 	 * Set up the section handler specific to each section
diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index df423f9..f22ec1a 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -425,7 +425,7 @@ void PictureDialog::save() {
 		frame->getTransparencyIndex());
 	_vm->_screen.copyRectToScreen(_vm->_screen.getBounds());
 
-	// Adjust the dialog colours to use
+	// Adjust the dialog colors to use
 	TEXTDIALOG_CONTENT1 -= 10;
 	TEXTDIALOG_CONTENT2 -= 10;
 	TEXTDIALOG_EDGE -= 10;
diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 1ec025c..8be6068 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -59,7 +59,7 @@ ProtectionResult GameNebular::checkCopyProtection() {
 	return PROTECTION_SUCCEED;
 }
 
-void GameNebular::initialiseGlobals() {
+void GameNebular::initializeGlobals() {
 	int count, count2;
 	int bad;
 
diff --git a/engines/mads/nebular/game_nebular.h b/engines/mads/nebular/game_nebular.h
index 82ddfb5..da25221 100644
--- a/engines/mads/nebular/game_nebular.h
+++ b/engines/mads/nebular/game_nebular.h
@@ -103,7 +103,7 @@ protected:
 
 	virtual ProtectionResult checkCopyProtection();
 
-	virtual void initialiseGlobals();
+	virtual void initializeGlobals();
 
 	virtual void setSectionHandler();
 
diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp
index 666b686..b20b0d2 100644
--- a/engines/mads/nebular/sound_nebular.cpp
+++ b/engines/mads/nebular/sound_nebular.cpp
@@ -154,7 +154,7 @@ ASound::ASound(Audio::Mixer *mixer, const Common::String &filename, int dataOffs
 	if (!_soundFile.open(filename))
 		error("Could not open file - %s", filename.c_str());
 
-	// Initialise fields
+	// Initialize fields
 	_commandParam = 0;
 	_activeChannelPtr = nullptr;
 	_samplePtr = nullptr;
diff --git a/engines/mads/phantom/game_phantom.cpp b/engines/mads/phantom/game_phantom.cpp
index 5232322..bcaec8e 100644
--- a/engines/mads/phantom/game_phantom.cpp
+++ b/engines/mads/phantom/game_phantom.cpp
@@ -58,7 +58,7 @@ ProtectionResult GamePhantom::checkCopyProtection() {
 	return PROTECTION_SUCCEED;
 }
 
-void GamePhantom::initialiseGlobals() {
+void GamePhantom::initializeGlobals() {
 	//int count, count2;
 	//int bad;
 
diff --git a/engines/mads/phantom/game_phantom.h b/engines/mads/phantom/game_phantom.h
index 96299fb..3043e53 100644
--- a/engines/mads/phantom/game_phantom.h
+++ b/engines/mads/phantom/game_phantom.h
@@ -52,7 +52,7 @@ protected:
 
 	virtual ProtectionResult checkCopyProtection();
 
-	virtual void initialiseGlobals();
+	virtual void initializeGlobals();
 
 	virtual void setSectionHandler();
 


Commit: 20c26931269871f599897d01cb93502bd58b1412
    https://github.com/scummvm/scummvm/commit/20c26931269871f599897d01cb93502bd58b1412
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-19T21:40:12+02:00

Commit Message:
MADS: Fix scrolling check

Changed paths:
    engines/mads/animation.cpp



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 089e21d..3e10fe9 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -399,7 +399,7 @@ void Animation::loadInterface(UserInterface &interfaceSurface, MSurface &depthSu
 }
 
 bool Animation::hasScroll() const {
-	return (_header._scrollPosition.x != 0) || (_header._scrollPosition.x != 0);
+	return (_header._scrollPosition.x != 0) || (_header._scrollPosition.y != 0);
 }
 
 void Animation::update() {


Commit: 9544db6510a9290559e0e1ece86aad7f97989341
    https://github.com/scummvm/scummvm/commit/9544db6510a9290559e0e1ece86aad7f97989341
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-19T21:43:18+02:00

Commit Message:
MADS: Reduce the scope of a variable in ASound

Changed paths:
    engines/mads/nebular/sound_nebular.cpp



diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp
index b20b0d2..6bc6974 100644
--- a/engines/mads/nebular/sound_nebular.cpp
+++ b/engines/mads/nebular/sound_nebular.cpp
@@ -404,12 +404,12 @@ void ASound::checkChannels() {
 
 void ASound::pollActiveChannel() {
 	AdlibChannel *chan = _activeChannelPtr;
-	bool updateFlag = true;
 
 	if (chan->_activeCount) {
 		if (chan->_field8 > 0 && --chan->_field8 == 0)
 			updateOctave();
 
+		bool updateFlag = true;
 		if (--_activeChannelPtr->_activeCount <= 0) {
 			for (;;) {
 				byte *pSrc = chan->_pSrc;


Commit: 83f82104d0a49ba9eff521426b58831ac3b21a86
    https://github.com/scummvm/scummvm/commit/83f82104d0a49ba9eff521426b58831ac3b21a86
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-19T21:46:15+02:00

Commit Message:
MADS: Reduce the scope of another variable in Animation

Changed paths:
    engines/mads/animation.cpp



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 3e10fe9..f006d1f 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -464,9 +464,8 @@ void Animation::update() {
 		paChanged = true;
 	}
 
-	int newIndex = -1;
 	if (paChanged) {
-		newIndex = scene._spriteSlots.add();
+		int newIndex = scene._spriteSlots.add();
 		scene._spriteSlots[newIndex]._seqIndex = -1;
 		scene._spriteSlots[newIndex]._flags = IMG_REFRESH;
 	}


Commit: b384447e71af3b10a152f7a3d863e65db525476c
    https://github.com/scummvm/scummvm/commit/b384447e71af3b10a152f7a3d863e65db525476c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-19T21:54:25+02:00

Commit Message:
MADS: Reduce the scope of some variables in Palette

Changed paths:
    engines/mads/palette.cpp



diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index a4608a6..23e8895 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -587,7 +587,6 @@ uint8 Palette::palIndexFromRgb(byte r, byte g, byte b, byte *paletteData) {
 	byte index = 0;
 	int32 minDist = 0x7fffffff;
 	byte palData[PALETTE_SIZE];
-	int Rdiff, Gdiff, Bdiff;
 
 	if (paletteData == NULL) {
 		g_system->getPaletteManager()->grabPalette(palData, 0, PALETTE_COUNT);
@@ -595,9 +594,9 @@ uint8 Palette::palIndexFromRgb(byte r, byte g, byte b, byte *paletteData) {
 	}
 
 	for (int palIndex = 0; palIndex < PALETTE_COUNT; ++palIndex) {
-		Rdiff = r - paletteData[palIndex * 3];
-		Gdiff = g - paletteData[palIndex * 3 + 1];
-		Bdiff = b - paletteData[palIndex * 3 + 2];
+		int Rdiff = r - paletteData[palIndex * 3];
+		int Gdiff = g - paletteData[palIndex * 3 + 1];
+		int Bdiff = b - paletteData[palIndex * 3 + 2];
 
 		if (Rdiff * Rdiff + Gdiff * Gdiff + Bdiff * Bdiff < minDist) {
 			minDist = Rdiff * Rdiff + Gdiff * Gdiff + Bdiff * Bdiff;
@@ -609,7 +608,6 @@ uint8 Palette::palIndexFromRgb(byte r, byte g, byte b, byte *paletteData) {
 }
 
 void Palette::setGradient(byte *palette, int start, int count, int rgbValue1, int rgbValue2) {
-	int rgbCtr = 0;
 	int rgbCurrent = rgbValue2;
 	int rgbDiff = -(rgbValue2 - rgbValue1);
 
@@ -618,6 +616,7 @@ void Palette::setGradient(byte *palette, int start, int count, int rgbValue1, in
 		int endVal = count - 1;
 		int numLeft = count;
 
+		int rgbCtr = 0;
 		do {
 			pDest[0] = pDest[1] = pDest[2] = rgbCurrent;
 


Commit: 081a7ee30cfdf8a29f0cd896eef18b838dd154f8
    https://github.com/scummvm/scummvm/commit/081a7ee30cfdf8a29f0cd896eef18b838dd154f8
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-19T22:21:27+02:00

Commit Message:
MADS: Refactor a bit the calls of generateRandom()

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes3.cpp



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 0f8af57..0685cf6 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1198,16 +1198,12 @@ void Scene205::enter() {
 }
 
 void Scene205::step() {
-	int chanceMajor, chanceMinor;
-
 	if (_globals[kSexOfRex] == SEX_FEMALE) {
 		_scene->_kernelMessages.randomServer();
 
 		if (_vm->_game->_scene._frameStartTime >= _chickenTime) {
-			chanceMajor = 100;
-			chanceMinor = _scene->_kernelMessages.checkRandom() + 1;
-
-			if (_scene->_kernelMessages.generateRandom(chanceMajor, chanceMinor))
+			int chanceMinor = _scene->_kernelMessages.checkRandom() + 1;
+			if (_scene->_kernelMessages.generateRandom(100, chanceMinor))
 				_vm->_sound->command(28);
 
 			_chickenTime = _vm->_game->_scene._frameStartTime + 2;
@@ -4573,16 +4569,12 @@ void Scene211::enter() {
 }
 
 void Scene211::step() {
-	int chanceMajor, chanceMinor;
-
 	if (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY) {
 		_scene->_kernelMessages.randomServer();
 
 		if (!_ambushFl && !_wakeFl && (_vm->_game->_scene._frameStartTime >= _monkeyTime)) {
-			chanceMajor = 80;
-			chanceMinor = _scene->_kernelMessages.checkRandom() * 4 + 1;
-
-			if (_scene->_kernelMessages.generateRandom(chanceMajor, chanceMinor))
+			int chanceMinor = _scene->_kernelMessages.checkRandom() * 4 + 1;
+			if (_scene->_kernelMessages.generateRandom(80, chanceMinor))
 				_vm->_sound->command(18);
 
 			_monkeyTime = _vm->_game->_scene._frameStartTime + 2;
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 4358aa4..f7283c8 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -5550,13 +5550,10 @@ void Scene389::enter() {
 }
 
 void Scene389::step() {
-	int chanceMajor, chanceMinor;
-	
 	_scene->_kernelMessages.randomServer();
 	if (_scene->_frameStartTime >= _monsterTime) {
-		chanceMajor = 20;
-		chanceMinor = _scene->_kernelMessages.checkRandom() * 4 + 1;
-		_scene->_kernelMessages.generateRandom(chanceMajor, chanceMinor);
+		int chanceMinor = _scene->_kernelMessages.checkRandom() * 4 + 1;
+		_scene->_kernelMessages.generateRandom(20, chanceMinor);
 		_monsterTime = _scene->_frameStartTime + 2;
 	}
 }


Commit: 9613db3edf71787eb211076081281a9bc5c2f6ba
    https://github.com/scummvm/scummvm/commit/9613db3edf71787eb211076081281a9bc5c2f6ba
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-19T22:21:58+02:00

Commit Message:
MADS: Reduce the scope of a variable in Resource

Changed paths:
    engines/mads/resources.cpp



diff --git a/engines/mads/resources.cpp b/engines/mads/resources.cpp
index 4f5596d..83077b6 100644
--- a/engines/mads/resources.cpp
+++ b/engines/mads/resources.cpp
@@ -410,13 +410,13 @@ void SynchronizedList::synchronize(Common::Serializer &s) {
 
 void synchronizeString(Common::Serializer &s, Common::String &str) {
 	int len = str.size();
-	char c;
 	s.syncAsUint16LE(len);
 
 	if (s.isSaving()) {
 		s.syncBytes((byte *)str.c_str(), len);
 	} else {
 		str.clear();
+		char c;
 		for (int i = 0; i < len; ++i) {
 			s.syncAsByte(c);
 			str += c;


Commit: 373b67e5be7688f5dd904c81a4a9702bf131c032
    https://github.com/scummvm/scummvm/commit/373b67e5be7688f5dd904c81a4a9702bf131c032
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-19T22:41:27+02:00

Commit Message:
MADS: Some refactoring in scene 402

Changed paths:
    engines/mads/nebular/nebular_scenes4.cpp



diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index e8e9596..79352fb 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -1232,13 +1232,8 @@ void Scene402::step() {
 		break;
 
 	case 53:
-		if (_bigBeatFl) {
-			_scene->_sequences.remove(_globals._sequenceIndexes[5]);
-			_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
-		} else {
-			_scene->_sequences.remove(_globals._sequenceIndexes[5]);
-			_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
-		}
+		_scene->_sequences.remove(_globals._sequenceIndexes[5]);
+		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1);
 		_waitingGinnyMove = false;
 		break;
@@ -1378,14 +1373,12 @@ void Scene402::step() {
 		}
 	}
 
-	if (!_blowingSmoke) {
-		if (_vm->getRandomNumber(1, 300) == 1) {
-			_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 1, 0, 0);
-			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 14);
-			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14);
-			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 30);
-			_blowingSmoke = true;
-		}
+	if (!_blowingSmoke && (_vm->getRandomNumber(1, 300) == 1)) {
+		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 8, 1, 0, 0);
+		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 1, 14);
+		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 14);
+		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 30);
+		_blowingSmoke = true;
 	}
 
 	switch (_game._trigger) {


Commit: 499f09a1c0ffccca52a8bc13401a6724af2b9b9b
    https://github.com/scummvm/scummvm/commit/499f09a1c0ffccca52a8bc13401a6724af2b9b9b
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-19T22:46:09+02:00

Commit Message:
MADS: Reduce variable scope in scene group 5, rename one variable

Changed paths:
    engines/mads/nebular/nebular_scenes5.cpp



diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index 168daea..c884170 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -886,10 +886,9 @@ void Scene505::enter() {
 }
 
 void Scene505::step() {
-	int resetFrame;
 	if (_frame != _scene->_activeAnimation->getCurrentFrame()) {
 		_frame = _scene->_activeAnimation->getCurrentFrame();
-		resetFrame = -1;
+		int resetFrame = -1;
 
 		switch (_frame) {
 		case 4:
@@ -1267,8 +1266,6 @@ void Scene506::room_506_door_sequences() {
 }
 
 void Scene506::actions() {
-	int temp;
-
 	if (_action.isAction(0x242, 0x37D)) {
 		if (_firstDoorFl) {
 			_heroFacing = FACING_NORTHWEST;
@@ -1293,11 +1290,12 @@ void Scene506::actions() {
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			break;
 
-		case 1:
-			temp = _globals._sequenceIndexes[3];
+		case 1: {
+			int syncIdx = _globals._sequenceIndexes[3];
 			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
-			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], temp);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], syncIdx);
 			_scene->_sequences.addTimer(6, 2);
+			}
 			break;
 
 		case 2:
@@ -1307,12 +1305,13 @@ void Scene506::actions() {
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
 			break;
 
-		case 3:
-			temp = _globals._sequenceIndexes[4];
+		case 3: {
+			int syncIdx = _globals._sequenceIndexes[4];
 			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, -2);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
-			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], temp);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], syncIdx);
 			_scene->_nextSceneId = 504;
+			}
 			break;
 
 		default:


Commit: 410ba93433e0a8c055bad7f7241db4868007a0bb
    https://github.com/scummvm/scummvm/commit/410ba93433e0a8c055bad7f7241db4868007a0bb
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-19T22:50:30+02:00

Commit Message:
MADS: Some refactoring in scene group 3

Changed paths:
    engines/mads/nebular/nebular_scenes3.cpp



diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index f7283c8..40f2533 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -2138,8 +2138,6 @@ void Scene316::handleRoxInGrate() {
 }
 
 void Scene316::enter() {
-	int series;
-
 	if (_globals[kSexOfRex] == REX_MALE) {
 		_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('g', -1));
 		_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXCL_8");
@@ -2165,8 +2163,8 @@ void Scene316::enter() {
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
 		_vm->_sound->command(44);
-		series = (_globals[kSexOfRex] == REX_MALE) ? 1 : 2;
-		_globals._sequenceIndexes[1] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[series], false, 6, 1, 0, 0);
+		int spriteIdx = (_globals[kSexOfRex] == REX_MALE) ? 1 : 2;
+		_globals._sequenceIndexes[1] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[spriteIdx], false, 6, 1, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 2);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 60);
 	} else if (_scene->_priorSceneId != -2)
@@ -2177,8 +2175,6 @@ void Scene316::enter() {
 }
 
 void Scene316::step() {
-	int temp;
-
 	if (_game._trigger == 60) {
 		_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[1]);
 		_game._player._visible = true;
@@ -2200,20 +2196,22 @@ void Scene316::step() {
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 72);
 			break;
 
-		case 71:
-			temp = _globals._sequenceIndexes[3];
+		case 71: {
+			int synxIdx = _globals._sequenceIndexes[3];
 			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
-			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], temp);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], synxIdx);
+			}
 			break;
 
-		case 72:
-			temp = _globals._sequenceIndexes[6];
+		case 72: {
+			int synxIdx = _globals._sequenceIndexes[6];
 			_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 12, 1, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[6], 6, 9);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[6]);
-			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[6], temp);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[6], synxIdx);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 73);
+			}
 			break;
 
 		case 73:
@@ -2230,11 +2228,12 @@ void Scene316::step() {
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 75);
 			break;
 
-		case 74:
-			temp = _globals._sequenceIndexes[3];
+		case 74: {
+			int synxIdx = _globals._sequenceIndexes[3];
 			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 12);
-			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], temp);
+			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[3], synxIdx);
+			}
 			break;
 
 		case 75:
@@ -2360,17 +2359,15 @@ void Scene318::setup() {
 }
 
 void Scene318::handleDialog() {
-	int temp;
-
 	if (!_game._trigger) {
 		_game._player._stepEnabled = false;
 		handleRexDialogs(_action._activeAction._verbId);
 	} else if (_game._trigger == 2) {
-		temp = _globals._sequenceIndexes[2];
+		int synxIdx = _globals._sequenceIndexes[2];
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
-		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], temp);
+		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], synxIdx);
 		_vm->_sound->command(3);
 		_scene->_userInterface.setup(kInputLimitedSentences);
 		_game._player._stepEnabled = true;


Commit: 2c5ef8021875c088d7fe409ba5a09bea9decdbba
    https://github.com/scummvm/scummvm/commit/2c5ef8021875c088d7fe409ba5a09bea9decdbba
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-19T22:56:34+02:00

Commit Message:
MADS: Fix bug in scene 207

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 0685cf6..e853c0a 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1542,8 +1542,8 @@ void Scene207::actions() {
 	} else {
 		if ((_game._player._playerPos.x > 150) && (_game._player._playerPos.x < 189) &&
 		    (_game._player._playerPos.y > 111) && (_game._player._playerPos.y < 130)) {
-			if ((_game._player._playerPos.x <= 162) && (_game._player._playerPos.x >= 181) &&
-			    (_game._player._playerPos.y <= 115) && (_game._player._playerPos.y >= 126)) {
+			if ((_game._player._playerPos.x <= 162) || (_game._player._playerPos.x >= 181) ||
+			    (_game._player._playerPos.y <= 115) || (_game._player._playerPos.y >= 126)) {
 				_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 10, 2, 0, 0);
 				_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 2, 0, 0);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 6);


Commit: 33fb64a1bdf6e470ca63e03a4199e28cb8b6172b
    https://github.com/scummvm/scummvm/commit/33fb64a1bdf6e470ca63e03a4199e28cb8b6172b
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-19T23:57:51+02:00

Commit Message:
MADS: Remove some useless empty functions

Changed paths:
    engines/mads/nebular/nebular_scenes5.h
    engines/mads/nebular/nebular_scenes6.h
    engines/mads/nebular/nebular_scenes7.h
    engines/mads/nebular/nebular_scenes8.h



diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
index 9d5e76a..bc22a62 100644
--- a/engines/mads/nebular/nebular_scenes5.h
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -195,7 +195,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene512: public Scene5xx{
@@ -208,10 +207,7 @@ public:
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene513: public Scene5xx{
@@ -221,9 +217,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene515: public Scene5xx{
@@ -233,9 +227,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions() {};
-	virtual void postActions() {};
 };
 
 class Scene551: public Scene5xx{
@@ -247,7 +239,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes6.h b/engines/mads/nebular/nebular_scenes6.h
index 294cf35..731b220 100644
--- a/engines/mads/nebular/nebular_scenes6.h
+++ b/engines/mads/nebular/nebular_scenes6.h
@@ -57,9 +57,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene602: public Scene6xx{
@@ -76,10 +74,7 @@ public:
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene603: public Scene6xx{
@@ -92,10 +87,7 @@ public:
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene604: public Scene6xx{
@@ -117,9 +109,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene605: public Scene6xx{
@@ -129,9 +119,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene607: public Scene6xx{
@@ -158,7 +146,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene608: public Scene6xx{
@@ -206,7 +193,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene609: public Scene6xx{
@@ -223,7 +209,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene610: public Scene6xx{
@@ -242,9 +227,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene611: public Scene6xx{
@@ -297,7 +280,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene612: public Scene6xx{
@@ -313,9 +295,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene620: public Scene6xx{
@@ -325,9 +305,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions() {};
-	virtual void postActions() {};
 };
 } // End of namespace Nebular
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes7.h b/engines/mads/nebular/nebular_scenes7.h
index 6b128db..0223fe2 100644
--- a/engines/mads/nebular/nebular_scenes7.h
+++ b/engines/mads/nebular/nebular_scenes7.h
@@ -101,9 +101,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene704: public Scene7xx{
@@ -127,9 +125,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene705: public Scene7xx{
@@ -146,9 +142,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene706: public Scene7xx{
@@ -171,7 +165,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene707: public SceneTeleporter {
@@ -216,7 +209,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene752: public Scene7xx {
diff --git a/engines/mads/nebular/nebular_scenes8.h b/engines/mads/nebular/nebular_scenes8.h
index 5193c4f..590f31c 100644
--- a/engines/mads/nebular/nebular_scenes8.h
+++ b/engines/mads/nebular/nebular_scenes8.h
@@ -64,7 +64,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene802: public Scene8xx{
@@ -76,7 +75,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene803: public Scene8xx{
@@ -88,7 +86,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene804: public Scene8xx {
@@ -120,7 +117,6 @@ public:
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene807: public SceneTeleporter {
@@ -142,10 +138,7 @@ public:
 
 	virtual void setup();
 	virtual void enter();
-	virtual void step() {};
-	virtual void preActions() {};
 	virtual void actions();
-	virtual void postActions() {};
 };
 
 class Scene810: public Scene8xx{
@@ -158,9 +151,7 @@ public:
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void preActions() {};
 	virtual void actions() {};
-	virtual void postActions() {};
 };
 
 } // End of namespace Nebular


Commit: 42e8daf49d67e839c695b12518369faf58ce9ddd
    https://github.com/scummvm/scummvm/commit/42e8daf49d67e839c695b12518369faf58ce9ddd
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T01:17:01+03:00

Commit Message:
MADS: Replace hex values in dialogs with their decimal values

The decimal values make much more sense than their hex counterparts
in dialogs. Only scene groups 1 - 3 are affected, since the others
have decimal values already

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes3.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index b2e07dc..875c58c 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -127,7 +127,7 @@ void Scene101::sayDang() {
 		break;
 
 	case 73:
-		_vm->_dialogs->show(0x2785);
+		_vm->_dialogs->show(10117);
 		_game._player._stepEnabled = true;
 		break;
 	}
@@ -325,7 +325,7 @@ void Scene101::preActions() {
 
 void Scene101::actions() {
 	if (_action._lookFlag) {
-		_vm->_dialogs->show(0x278D);
+		_vm->_dialogs->show(10125);
 		_action._inProgress = false;
 		return;
 	}
@@ -369,7 +369,7 @@ void Scene101::actions() {
 				break;
 			}
 		} else {
-			_vm->_dialogs->show(0x2793);
+			_vm->_dialogs->show(10131);
 			_action._inProgress = false;
 			return;
 		}
@@ -414,18 +414,18 @@ void Scene101::actions() {
 	if (_action.isAction(VERB_LOOK, 0x135) || (_action.isAction(VERB_LOOK, 0x137) && !_game._objects.isInInventory(OBJ_SHIELD_MODULATOR)) ) {
 		if (_panelOpened) {
 			if (_game._objects.isInRoom(OBJ_SHIELD_MODULATOR))
-				_vm->_dialogs->show(0x2790);
+				_vm->_dialogs->show(10128);
 			else
-				_vm->_dialogs->show(0x2791);
+				_vm->_dialogs->show(10129);
 		} else {
-			_vm->_dialogs->show(0x278F);
+			_vm->_dialogs->show(10127);
 		}
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_OPEN, 0x135) && _panelOpened) {
-		_vm->_dialogs->show(0x2792);
+		_vm->_dialogs->show(10130);
 		_action._inProgress = false;
 		return;
 	}
@@ -470,133 +470,133 @@ void Scene101::actions() {
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x47)) {
-		_vm->_dialogs->show(0x2775);
+		_vm->_dialogs->show(10101);
 		_action._inProgress = false;
 		return;
 	}
 
 	if ((_action.isAction(VERB_LOOK) || _action.isAction(0x103)) && (_action.isAction(0x8E) || _action.isAction(0xF9))) {
-		_vm->_dialogs->show(0x2776);
+		_vm->_dialogs->show(10102);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0xA8) || _action.isAction(VERB_LOOK, 0xF8) || _action.isAction(0x7D, 0xA8) || _action.isAction(0x7D, 0xF8)) {
-		_vm->_dialogs->show(0x2777);
+		_vm->_dialogs->show(10103);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x91)) {
-		_vm->_dialogs->show(0x2778);
+		_vm->_dialogs->show(10104);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0xE1) || _action.isAction(0xD2, 0xE1)) {
-		_vm->_dialogs->show(0x2779);
+		_vm->_dialogs->show(10105);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x60)) {
-		_vm->_dialogs->show(0x277A);
+		_vm->_dialogs->show(10106);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x111)) {
-		_vm->_dialogs->show(0x277B);
+		_vm->_dialogs->show(10107);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x7B) || (_action.isAction(VERB_OPEN, 0x7B) && !_game._objects.isInInventory(OBJ_REBREATHER))) {
-		_vm->_dialogs->show(0x277D);
+		_vm->_dialogs->show(10109);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_OPEN, 0x7B)) {
-		_vm->_dialogs->show(0x277E);
+		_vm->_dialogs->show(10110);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x166)) {
-		_vm->_dialogs->show(0x277F);
+		_vm->_dialogs->show(10111);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0xCA)) {
-		_vm->_dialogs->show(0x278E);
+		_vm->_dialogs->show(10126);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x63)) {
-		_vm->_dialogs->show(0x2780);
+		_vm->_dialogs->show(10112);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0xEB)) {
-		_vm->_dialogs->show(0x2781);
+		_vm->_dialogs->show(10113);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x78)) {
-		_vm->_dialogs->show(0x2782);
+		_vm->_dialogs->show(10114);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x190)) {
-		_vm->_dialogs->show(0x2783);
+		_vm->_dialogs->show(10115);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x138)) {
-		_vm->_dialogs->show(0x2784);
+		_vm->_dialogs->show(10116);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_TAKE, 0x111)) {
-		_vm->_dialogs->show(0x2786);
+		_vm->_dialogs->show(10118);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_TAKE, 0x91)) {
-		_vm->_dialogs->show(0x2787);
+		_vm->_dialogs->show(10119);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_OPEN, 0x63)) {
-		_vm->_dialogs->show(0x2789);
+		_vm->_dialogs->show(10121);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_OPEN, 0x60)) {
-		_vm->_dialogs->show(0x278A);
+		_vm->_dialogs->show(10122);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_CLOSE, 0x60)) {
-		_vm->_dialogs->show(0x278B);
+		_vm->_dialogs->show(10123);
 		_action._inProgress = false;
 		return;
 	}
 
 	if ((_action.isAction(VERB_LOOK) || _action.isAction(0x112)) && _action.isAction(0x17E)) {
-		_vm->_dialogs->show(0x278C);
+		_vm->_dialogs->show(10124);
 		_action._inProgress = false;
 		return;
 	}
@@ -742,7 +742,7 @@ void Scene102::step() {
 		_fridgeCommentCount++;
 		if (_fridgeCommentCount > 16384) {
 			_fridgeOpenedDescr = true;
-			_vm->_dialogs->show(0x27E5);
+			_vm->_dialogs->show(10213);
 		}
 	}
 
@@ -793,7 +793,7 @@ void Scene102::actions() {
 	bool justOpenedFl = false;
 
 	if (_action._lookFlag) {
-		_vm->_dialogs->show(0x27FA);
+		_vm->_dialogs->show(10234);
 		_action._inProgress = false;
 		return;
 	}
@@ -840,9 +840,9 @@ void Scene102::actions() {
 
 	if (_action.isAction(VERB_LOOK, 0x122) || _action.isAction(VERB_OPEN, 0x122)) {
 		if (_game._objects.isInRoom(OBJ_BURGER))
-			_vm->_dialogs->show(0x27F6);
+			_vm->_dialogs->show(10230);
 		else
-			_vm->_dialogs->show(0x27F5);
+			_vm->_dialogs->show(10229);
 
 		_fridgeFirstOpenFl = false;
 		_action._inProgress = false;
@@ -864,13 +864,13 @@ void Scene102::actions() {
 	}
 
 	if (_action.isAction(VERB_CLOSE, 0x122)) {
-		_vm->_dialogs->show(0x27E5);
+		_vm->_dialogs->show(10213);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_TAKE, 0x122)) {
-		_vm->_dialogs->show(0x8);
+		_vm->_dialogs->show(8);
 		_action._inProgress = false;
 		return;
 	}
@@ -905,67 +905,67 @@ void Scene102::actions() {
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x194)) {
-		_vm->_dialogs->show(0x27E4);
+		_vm->_dialogs->show(10212);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x79)) {
-		_vm->_dialogs->show(0x27DD);
+		_vm->_dialogs->show(10205);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x6E)) {
-		_vm->_dialogs->show(0x27DC);
+		_vm->_dialogs->show(10204);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(0x155, 0x46) || _action.isAction(VERB_LOOK, 0x46)) {
-		_vm->_dialogs->show(0x27DB);
+		_vm->_dialogs->show(10203);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(0x155, 0xFD) || _action.isAction(VERB_LOOK, 0xFD)) {
-		_vm->_dialogs->show(0x27DA);
+		_vm->_dialogs->show(10202);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x127)) {
-		_vm->_dialogs->show(0x27E7);
+		_vm->_dialogs->show(10215);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_PUT, 0x35, 0x127) && _game._objects.isInInventory(OBJ_BURGER)) {
-		_vm->_dialogs->show(0x27E8);
+		_vm->_dialogs->show(10216);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_PUT, 0x122) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
-		_vm->_dialogs->show(0x27E9);
+		_vm->_dialogs->show(10217);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_PUT, 0x127) && (_action.isAction(0x65) || _action.isAction(0x157))) {
-		_vm->_dialogs->show(0x27F6);
+		_vm->_dialogs->show(10230);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_OPEN, 0x127)) {
-		_vm->_dialogs->show(0x27EA);
+		_vm->_dialogs->show(10218);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x52)) {
-		_vm->_dialogs->show(0x27EB);
+		_vm->_dialogs->show(10219);
 		_action._inProgress = false;
 		return;
 	}
@@ -973,12 +973,12 @@ void Scene102::actions() {
 	if ((_action.isObject(0xC7) || _action.isObject(0xA3)) && (_action.isAction(VERB_LOOK) || _action.isAction(0x50) || _action.isAction(0x4F))) {
 		if (_game._objects.isInInventory(OBJ_REBREATHER)) {
 			if (!_action.isAction(0x50) && !_action.isAction(0x4F)) {
-				_vm->_dialogs->show(0x27F7);
+				_vm->_dialogs->show(10231);
 				_action._inProgress = false;
 				return;
 			}
 		} else if (_action.isAction(VERB_LOOK) || (_game._difficulty != DIFFICULTY_EASY)) {
-			_vm->_dialogs->show(0x27EE);
+			_vm->_dialogs->show(10222);
 			_action._inProgress = false;
 			return;
 		}
@@ -1011,7 +1011,7 @@ void Scene102::actions() {
 
 		case 6:
 			if (_game._objects.isInInventory(OBJ_REBREATHER) && !_game._visitedScenes.exists(106))
-				_vm->_dialogs->show(0x27FD);
+				_vm->_dialogs->show(10237);
 			_scene->_nextSceneId = 106;
 			break;
 		}
@@ -1020,60 +1020,60 @@ void Scene102::actions() {
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x118)) {
-		_vm->_dialogs->show(0x27F2);
+		_vm->_dialogs->show(10226);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x197) || _action.isAction(0xD3, 0x197)) {
-		_vm->_dialogs->show(0x27F3);
+		_vm->_dialogs->show(10227);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x70) || _action.isAction(VERB_WALKTO, 0x70)) {
-		_vm->_dialogs->show(0x27F4);
+		_vm->_dialogs->show(10228);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x71) || ((_action.isAction(VERB_CLOSE, 0x71) || _action.isAction(VERB_PUSH, 0x71)) && !_drawerDescrFl)) {
-		_vm->_dialogs->show(0x27EC);
+		_vm->_dialogs->show(10220);
 		_drawerDescrFl = true;
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_CLOSE, 0x71) || _action.isAction(VERB_PUSH, 0x71)) {
-		_vm->_dialogs->show(0x27ED);
+		_vm->_dialogs->show(10221);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_OPEN, 0x71)) {
-		_vm->_dialogs->show(0x27FC);
+		_vm->_dialogs->show(10236);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x47) || (_action.isAction(0x13F, 0x47) && !_chairDescrFl)) {
 		_chairDescrFl = true;
-		_vm->_dialogs->show(0x27E2);
+		_vm->_dialogs->show(10210);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(0x13F, 0x47)) {
-		_vm->_dialogs->show(0x27E3);
+		_vm->_dialogs->show(10211);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0xDE)) {
 		if (_globals[kMedicineCabinetOpen])
-			_vm->_dialogs->show(0x27DF);
+			_vm->_dialogs->show(10207);
 		else
-			_vm->_dialogs->show(0x27DE);
+			_vm->_dialogs->show(10206);
 
 		_action._inProgress = false;
 		return;
@@ -1096,7 +1096,7 @@ void Scene102::actions() {
 		case 2:
 			_game._player._stepEnabled = true;
 			_globals[kMedicineCabinetOpen] = false;
-			_vm->_dialogs->show(0x27E1);
+			_vm->_dialogs->show(10209);
 			break;
 		}
 		_action._inProgress = false;
@@ -1122,9 +1122,9 @@ void Scene102::actions() {
 			_game._player._stepEnabled = true;
 			_globals[kMedicineCabinetOpen] = true;
 			if (_globals[kMedicineCabinetVirgin]) {
-				_vm->_dialogs->show(0x27E0);
+				_vm->_dialogs->show(10208);
 			} else {
-				_vm->_dialogs->show(0x27DF);
+				_vm->_dialogs->show(10207);
 			}
 			_globals[kMedicineCabinetVirgin] = false;
 			break;
@@ -1172,38 +1172,38 @@ void Scene102::actions() {
 	}
 
 	if (_action.isAction(VERB_TAKE, 0x117)) {
-		_vm->_dialogs->show(0x27F0);
+		_vm->_dialogs->show(10224);
 		_action._inProgress = false;
 		return;
 	}
 
 	if ((_action.isAction(VERB_PUSH) || _action.isAction(VERB_PULL)) && _action.isAction(0x194)) {
-		_vm->_dialogs->show(0x27F1);
+		_vm->_dialogs->show(10225);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x89)) {
-		_vm->_dialogs->show(0x27F8);
+		_vm->_dialogs->show(10232);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x27) && !_game._objects.isInInventory(OBJ_BINOCULARS)) {
-		_vm->_dialogs->show(0x27F9);
+		_vm->_dialogs->show(10233);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x35) && (_action._mainObjectSource == 4)) {
-		_vm->_dialogs->show(0x321);
+		_vm->_dialogs->show(801);
 		_action._inProgress = false;
 	}
 }
 
 void Scene102::postActions() {
 	if (_action.isAction(VERB_PUT, 0x127) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
-		_vm->_dialogs->show(0x27E9);
+		_vm->_dialogs->show(10217);
 		_action._inProgress = false;
 	}
 }
@@ -1528,7 +1528,7 @@ void Scene103::actions() {
 
 void Scene103::postActions() {
 	if (_action.isAction(27) && !_action.isAction(VERB_WALKTO)) {
-		_vm->_dialogs->show(0x2841);
+		_vm->_dialogs->show(10305);
 		_action._inProgress = false;
 	} else {
 		if (_action.isAction(VERB_PUT, 85, 144)) {
@@ -1616,7 +1616,7 @@ void Scene104::step() {
 				break;
 
 			case 2:
-				_vm->_dialogs->show(0x28A6);
+				_vm->_dialogs->show(10406);
 				_scene->_reloadSceneFlag = true;
 				break;
 			}
@@ -1655,7 +1655,7 @@ void Scene104::step() {
 				break;
 
 			case 3:
-				_vm->_dialogs->show(0x28A6);
+				_vm->_dialogs->show(10406);
 				_scene->_reloadSceneFlag = true;
 				break;
 			}
@@ -1687,7 +1687,7 @@ void Scene104::step() {
 				break;
 
 			case 2:
-				_vm->_dialogs->show(0x28A6);
+				_vm->_dialogs->show(10406);
 				_scene->_reloadSceneFlag = true;
 				break;
 			}
@@ -1725,15 +1725,15 @@ void Scene104::preActions() {
 
 void Scene104::actions() {
 	if (_action._lookFlag)
-		_vm->_dialogs->show(0x28A5);
+		_vm->_dialogs->show(10405);
 	else if (_action.isAction(VERB_LOOK, 0x5E))
-		_vm->_dialogs->show(0x28A4);
+		_vm->_dialogs->show(10404);
 	else if (_action.isAction(VERB_LOOK, 0x158))
-		_vm->_dialogs->show(0x28A3);
+		_vm->_dialogs->show(10403);
 	else if (_action.isAction(VERB_LOOK, 0x4D))
-		_vm->_dialogs->show(0x28A1);
+		_vm->_dialogs->show(10401);
 	else if (_action.isAction(VERB_LOOK, 0xF0))
-		_vm->_dialogs->show(0x28A2);
+		_vm->_dialogs->show(10402);
 	else
 		return;
 
@@ -1825,7 +1825,7 @@ void Scene105::step() {
 			break;
 
 		case 3:
-			_vm->_dialogs->show(0x290B);
+			_vm->_dialogs->show(10507);
 			_scene->_reloadSceneFlag = true;
 			_scene->_sequences.addTimer(90, 4);
 			break;
@@ -1855,7 +1855,7 @@ void Scene105::preActions() {
 
 void Scene105::actions() {
 	if (_action._lookFlag)
-		_vm->_dialogs->show(0x2910);
+		_vm->_dialogs->show(10512);
 	else if (_action.isAction(VERB_TAKE, 0x65) && _globals[kFishIn105]) {
 		if (_game._objects.isInInventory(OBJ_DEAD_FISH)) {
 			int randVal = _vm->getRandomNumber(74, 76);
@@ -1868,25 +1868,25 @@ void Scene105::actions() {
 			_vm->_dialogs->showItem(OBJ_DEAD_FISH, 802, 0);
 		}
 	} else if (_action.isAction(VERB_LOOK, 0x195))
-		_vm->_dialogs->show(0x2905);
+		_vm->_dialogs->show(10501);
 	else if (_action.isAction(VERB_LOOK, 0x4D))
-		_vm->_dialogs->show(0x2906);
+		_vm->_dialogs->show(10502);
 	else if (_action.isAction(VERB_LOOK, 0xF0))
-		_vm->_dialogs->show(0x2907);
+		_vm->_dialogs->show(10503);
 	else if (_action.isAction(VERB_LOOK, 0xDD))
-		_vm->_dialogs->show(0x2908);
+		_vm->_dialogs->show(10504);
 	else if (_action.isAction(VERB_TAKE, 0xDD))
-		_vm->_dialogs->show(0x2909);
+		_vm->_dialogs->show(10505);
 	else if (_action.isAction(VERB_LOOK, 0xE0))
-		_vm->_dialogs->show(0x290A);
+		_vm->_dialogs->show(10506);
 	else if (_action.isAction(VERB_LOOK, 0x65))
-		_vm->_dialogs->show(0x290C);
+		_vm->_dialogs->show(10508);
 	else if (_action.isAction(VERB_LOOK, 0x158))
-		_vm->_dialogs->show(0x290D);
+		_vm->_dialogs->show(10509);
 	else if (_action.isAction(VERB_LOOK, 0xF5))
-		_vm->_dialogs->show(0x290E);
+		_vm->_dialogs->show(10510);
 	else if (_action.isAction(VERB_LOOK, 0x129))
-		_vm->_dialogs->show(0x290F);
+		_vm->_dialogs->show(10511);
 	else
 		return;
 
@@ -2064,7 +2064,7 @@ void Scene106::preActions() {
 
 void Scene106::actions() {
 	if (_action._lookFlag)
-		_vm->_dialogs->show(0x2976);
+		_vm->_dialogs->show(10614);
 	else if (_action.isAction(0x15C, 0xD9)) {
 		_game._player._stepEnabled = false;
 		_game._player._prepareWalkPos = Common::Point(95, 72);
@@ -2074,31 +2074,31 @@ void Scene106::actions() {
 		_game._player._frameNumber = 9;
 		_backToShipFl = true;
 	} else if (_action.isAction(VERB_LOOK, 0x13) || _action.isAction(0xD1, 0x13))
-		_vm->_dialogs->show(0x2969);
+		_vm->_dialogs->show(10601);
 	else if (_action.isAction(VERB_TAKE, 0x13))
-		_vm->_dialogs->show(0x296A);
+		_vm->_dialogs->show(10602);
 	else if (_action.isAction(VERB_LOOK, 0x12F) || _action.isAction(VERB_LOOK, 0x130))
-		_vm->_dialogs->show(0x296B);
+		_vm->_dialogs->show(10603);
 	else if (_action.isAction(VERB_TAKE, 0x12F) || _action.isAction(VERB_TAKE, 0x130))
-		_vm->_dialogs->show(0x296C);
+		_vm->_dialogs->show(10604);
 	else if (_action.isAction(VERB_LOOK, 0xF3))
-		_vm->_dialogs->show(0x296D);
+		_vm->_dialogs->show(10605);
 	else if (_action.isAction(VERB_LOOK, 0x109) || _action.isAction(0xD1, 0x109))
-		_vm->_dialogs->show(0x296E);
+		_vm->_dialogs->show(10606);
 	else if (_action.isAction(0x109) && (_action.isAction(VERB_PUSH) || _action.isAction(VERB_PULL) || _action.isAction(VERB_TAKE)))
-		_vm->_dialogs->show(0x296F);
+		_vm->_dialogs->show(10607);
 	else if (_action.isAction(VERB_LOOK, 0x139) || _action.isAction(0xD1, 0x139))
-		_vm->_dialogs->show(0x2970);
+		_vm->_dialogs->show(10608);
 	else if (_action.isAction(VERB_LOOK, 0xD9))
-		_vm->_dialogs->show(0x2971);
+		_vm->_dialogs->show(10609);
 	else if (_action.isAction(VERB_OPEN, 0xD9))
-		_vm->_dialogs->show(0x2972);
+		_vm->_dialogs->show(10610);
 	else if (_action.isAction(VERB_CLOSE, 0xD9))
-		_vm->_dialogs->show(0x2973);
+		_vm->_dialogs->show(10611);
 	else if (_action.isAction(VERB_LOOK, 0x12E))
-		_vm->_dialogs->show(0x2974);
+		_vm->_dialogs->show(10612);
 	else if (_action.isAction(VERB_LOOK, 0xF0))
-		_vm->_dialogs->show(0x2975);
+		_vm->_dialogs->show(10613);
 	else
 		return;
 
@@ -2187,7 +2187,7 @@ void Scene107::preActions() {
 
 void Scene107::actions() {
 	if (_action._lookFlag)
-		_vm->_dialogs->show(0x29D4);
+		_vm->_dialogs->show(10708);
 	else if (_action.isAction(VERB_TAKE, 0x65) && _globals[kFishIn107]) {
 		if (_game._objects.isInInventory(OBJ_DEAD_FISH)) {
 			int randVal = _vm->getRandomNumber(74, 76);
@@ -2202,23 +2202,23 @@ void Scene107::actions() {
 	} else if (_action.isAction(0x15D, 0xEE))
 		_scene->_nextSceneId = 105;
 	else if (_action.isAction(VERB_LOOK, 0xEE))
-		_vm->_dialogs->show(0x29CD);
+		_vm->_dialogs->show(10701);
 	else if (_action.isAction(VERB_LOOK, 0x65) && (_action._mainObjectSource == 4))
-		_vm->_dialogs->show(0x29CE);
+		_vm->_dialogs->show(10702);
 	else if (_action.isAction(VERB_LOOK, 0x38))
-		_vm->_dialogs->show(0x29CF);
+		_vm->_dialogs->show(10703);
 	else if (_action.isAction(VERB_LOOK, 0x128))
-		_vm->_dialogs->show(0x29D0);
+		_vm->_dialogs->show(10704);
 	else if (_action.isAction(VERB_LOOK, 0x12F))
-		_vm->_dialogs->show(0x29D1);
+		_vm->_dialogs->show(10705);
 	else if (_action.isAction(VERB_LOOK, 0xF5))
-		_vm->_dialogs->show(0x29D2);
+		_vm->_dialogs->show(10706);
 	else if (_action.isAction(VERB_LOOK, 0x4D))
-		_vm->_dialogs->show(0x29D3);
+		_vm->_dialogs->show(10707);
 	else if (_action.isAction(VERB_LOOK, 0xDA))
-		_vm->_dialogs->show(0x29D5);
+		_vm->_dialogs->show(10709);
 	else if (_action.isAction(VERB_TAKE, 0xDA))
-		_vm->_dialogs->show(0x29D6);
+		_vm->_dialogs->show(10710);
 	else
 		return;
 
@@ -2279,7 +2279,7 @@ void Scene108::preActions() {
 
 void Scene108::actions() {
 	if (_action._lookFlag)
-		_vm->_dialogs->show(0x2A3C);
+		_vm->_dialogs->show(10812);
 	else if (_action.isAction(VERB_TAKE, 0x65) && _globals[kFishIn108]) {
 		if (_game._objects.isInInventory(OBJ_DEAD_FISH)) {
 			int randVal = _vm->getRandomNumber(74, 76);
@@ -2294,25 +2294,25 @@ void Scene108::actions() {
 	} else if (_action.isAction(0x15D, 0xF4))
 		_scene->_nextSceneId = 107;
 	else if (_action.isAction(VERB_LOOK, 0x4D))
-		_vm->_dialogs->show(0x2A31);
+		_vm->_dialogs->show(10801);
 	else if (_action.isAction(VERB_LOOK, 0xF0))
-		_vm->_dialogs->show(0x2A32);
+		_vm->_dialogs->show(10802);
 	else if (_action.isAction(VERB_LOOK, 0xF1))
-		_vm->_dialogs->show(0x2A33);
+		_vm->_dialogs->show(10803);
 	else if (_action.isAction(VERB_TAKE, 0xF1))
-		_vm->_dialogs->show(0x2A34);
+		_vm->_dialogs->show(10804);
 	else if (_action.isAction(VERB_LOOK, 0x129))
-		_vm->_dialogs->show(0x2A35);
+		_vm->_dialogs->show(10805);
 	else if (_action.isAction(VERB_TAKE, 0x129))
-		_vm->_dialogs->show(0x2A36);
+		_vm->_dialogs->show(10806);
 	else if (_action.isAction(VERB_LOOK, 0x65))
-		_vm->_dialogs->show(0x2A37);
+		_vm->_dialogs->show(10807);
 	else if (_action.isAction(VERB_LOOK, 0xFB))
-		_vm->_dialogs->show(0x2A39);
+		_vm->_dialogs->show(10809);
 	else if (_action.isAction(VERB_LOOK, 0xF4))
-		_vm->_dialogs->show(0x2A3A);
+		_vm->_dialogs->show(10810);
 	else if (_action.isAction(VERB_LOOK, 0x158))
-		_vm->_dialogs->show(0x2A3B);
+		_vm->_dialogs->show(10811);
 	else
 		return;
 
@@ -2509,7 +2509,7 @@ void Scene109::preActions() {
 
 void Scene109::actions() {
 	if (_action._lookFlag) {
-		_vm->_dialogs->show(0x2AA0);
+		_vm->_dialogs->show(10912);
 		_action._inProgress = false;
 		return;
 	}
@@ -2667,7 +2667,7 @@ void Scene109::actions() {
 						_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
 						int idx = _scene->_dynamicHotspots.add(53, 348, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
 						_scene->_dynamicHotspots.setPosition(idx, Common::Point(-3, 0), FACING_NORTHEAST);
-						_vm->_dialogs->show(0x2AA3);
+						_vm->_dialogs->show(10915);
 						}
 						break;
 
@@ -2689,30 +2689,30 @@ void Scene109::actions() {
 		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
 		_game._objects.addToInventory(OBJ_BURGER);
 	} else if (_action.isAction(VERB_LOOK, 0xF0))
-		_vm->_dialogs->show(0x2A95);
+		_vm->_dialogs->show(10901);
 	else if (_action.isAction(VERB_LOOK, 0x5A))
-		_vm->_dialogs->show(0x2A96);
+		_vm->_dialogs->show(10902);
 	else if ((_action.isAction(VERB_TAKE) || _action.isAction(VERB_PULL)) && _action.isAction(0x5A))
-		_vm->_dialogs->show(0x2A97);
+		_vm->_dialogs->show(10903);
 	else if (_action.isAction(VERB_LOOK, 0x129))
-		_vm->_dialogs->show(0x2A98);
+		_vm->_dialogs->show(10904);
 	else if (_action.isAction(VERB_TAKE, 0x129))
-		_vm->_dialogs->show(0x2A99);
+		_vm->_dialogs->show(10905);
 	else if (_action.isAction(VERB_LOOK, 0x45))
-		_vm->_dialogs->show(0x2A9A);
+		_vm->_dialogs->show(10906);
 	else if (_action.isAction(VERB_LOOK, 0x178)) {
 		if (_globals[kHoovicAlive])
-			_vm->_dialogs->show(0x2A9B);
+			_vm->_dialogs->show(10907);
 		else
-			_vm->_dialogs->show(0x2AA1);
+			_vm->_dialogs->show(10913);
 	} else if (_action.isAction(VERB_LOOK, 0x146))
-		_vm->_dialogs->show(0x2A9C);
+		_vm->_dialogs->show(10908);
 	else if (_action.isAction(VERB_LOOK, 0xFC))
-		_vm->_dialogs->show(0x2A9F);
+		_vm->_dialogs->show(10911);
 	else if (_action.isAction(VERB_PUT, 0x146))
-		_vm->_dialogs->show(0x2A9E);
+		_vm->_dialogs->show(10910);
 	else if (_action.isAction(VERB_LOOK, 0x66))
-		_vm->_dialogs->show(0x2AA2);
+		_vm->_dialogs->show(10914);
 	else
 		return;
 
@@ -2832,21 +2832,21 @@ void Scene110::actions() {
 			break;
 		}
 	} else if ((_action._lookFlag) || _action.isAction(VERB_LOOK, 0x3F))
-		_vm->_dialogs->show(0x2AF9);
+		_vm->_dialogs->show(11001);
 	else if (_action.isAction(VERB_LOOK, 0x40) || _action.isAction(0xD1, 0x40))
-		_vm->_dialogs->show(0x2AFA);
+		_vm->_dialogs->show(11002);
 	else if (_action.isAction(VERB_LOOK, 0x129))
-		_vm->_dialogs->show(0x2AFB);
+		_vm->_dialogs->show(11003);
 	else if (_action.isAction(VERB_TAKE, 0x129))
-		_vm->_dialogs->show(0x2AFC);
+		_vm->_dialogs->show(11004);
 	else if (_action.isAction(VERB_LOOK, 0x178))
-		_vm->_dialogs->show(0x2AFD);
+		_vm->_dialogs->show(11005);
 	else if (_action.isAction(VERB_LOOK, 0x41))
-		_vm->_dialogs->show(0x2AFE);
+		_vm->_dialogs->show(11006);
 	else if (_action.isAction(VERB_LOOK, 0x8F))
-		_vm->_dialogs->show(0x2AFF);
+		_vm->_dialogs->show(11007);
 	else if (_action.isAction(VERB_TAKE, 0x8F))
-		_vm->_dialogs->show(0x2B00);
+		_vm->_dialogs->show(11008);
 	else
 		return;
 
@@ -2983,17 +2983,17 @@ void Scene111::actions() {
 			break;
 		}
 	} else if (_action.isAction(VERB_LOOK, 0x43))
-		_vm->_dialogs->show(0x2B5D);
+		_vm->_dialogs->show(11101);
 	else if (_action.isAction(VERB_LOOK, 0x116))
-		_vm->_dialogs->show(0x2B5E);
+		_vm->_dialogs->show(11102);
 	else if (_action.isAction(VERB_LOOK, 0x41))
-		_vm->_dialogs->show(0x2B5F);
+		_vm->_dialogs->show(11103);
 	else if (_action.isAction(VERB_LOOK, 0x153))
-		_vm->_dialogs->show(0x2B60);
+		_vm->_dialogs->show(11104);
 	else if (_action.isAction(VERB_LOOK, 0xC8))
-		_vm->_dialogs->show(0x2B61);
+		_vm->_dialogs->show(11105);
 	else if ((_action.isAction(VERB_PULL) || _action.isAction(VERB_TAKE)) && (_action.isAction(0x153) || _action.isAction(0xC8)))
-		_vm->_dialogs->show(0x2B62);
+		_vm->_dialogs->show(11106);
 	else
 		return;
 
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index e853c0a..47582cd 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -273,7 +273,7 @@ void Scene201::step() {
 
 	if (_game._trigger == 78) {
 		_vm->_sound->command(40);
-		_vm->_dialogs->show(0x4E92);
+		_vm->_dialogs->show(20114);
 		_scene->_reloadSceneFlag = true;
 	}
 }
@@ -292,30 +292,30 @@ void Scene201::actions() {
 				_scene->_nextSceneId = 213;
 			}
 		} else if (_action.isAction(VERB_LOOK, 0x1A6)) {
-			_vm->_dialogs->show(0x4E85);
+			_vm->_dialogs->show(20101);
 		} else if (_action.isAction(VERB_LOOK, 0x129)) {
-			_vm->_dialogs->show(0x4E86);
+			_vm->_dialogs->show(20102);
 		} else if (_action.isAction(VERB_LOOK, 0x16F)) {
-			_vm->_dialogs->show(0x4E87);
+			_vm->_dialogs->show(20103);
 		} else if (_action.isAction(VERB_LOOK, 0x142)) {
-			_vm->_dialogs->show(0x4E88);
+			_vm->_dialogs->show(20104);
 		} else if (_action.isAction(VERB_LOOK, 0x18F)) {
-			_vm->_dialogs->show(0x4E89);
+			_vm->_dialogs->show(20105);
 		} else if (_action.isAction(VERB_LOOK, 0x1B9)) {
-			_vm->_dialogs->show(0x4E8A);
+			_vm->_dialogs->show(20106);
 		} else if (_action.isAction(VERB_LOOK, 0x192)) {
-			_vm->_dialogs->show(0x4E8B);
+			_vm->_dialogs->show(20107);
 		} else if (_action.isAction(VERB_LOOK, 0x1BA)) {
-			_vm->_dialogs->show(0x4E8C);
+			_vm->_dialogs->show(20108);
 		} else if (_action.isAction(VERB_LOOK, 0x83)) {
-			_vm->_dialogs->show(0x4E8E);
+			_vm->_dialogs->show(20110);
 		} else if (_action.isAction(VERB_LOOK, 0x1B6)) {
 			if (_globals[kMeteorologistEverSeen])
-				_vm->_dialogs->show(0x4E90);
+				_vm->_dialogs->show(20112);
 			else
-				_vm->_dialogs->show(0x4E8D);
+				_vm->_dialogs->show(20109);
 		} else if (_action.isAction(VERB_LOOK, 0x16C)) {
-			_vm->_dialogs->show(0x4E91);
+			_vm->_dialogs->show(20113);
 		} else
 			return;
 	} else {
@@ -857,7 +857,7 @@ void Scene202::actions() {
 				break;
 			case 2:
 				if (!_scene->_activeAnimation && !_meteorologistSpecial) {
-					_vm->_dialogs->show(0x4EFE);
+					_vm->_dialogs->show(20222);
 				}
 				_scene->_sequences.remove(_globals._sequenceIndexes[10]);
 				_globals._sequenceIndexes[10] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
@@ -911,7 +911,7 @@ void Scene202::actions() {
 				break;
 			case 2:
 				if (!_scene->_activeAnimation)
-					_vm->_dialogs->show(0x4EFE);
+					_vm->_dialogs->show(20222);
 				_meteorologistSpecial = false;
 				_scene->_sequences.remove(_globals._sequenceIndexes[10]);
 				_globals._sequenceIndexes[9] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
@@ -944,15 +944,15 @@ void Scene202::actions() {
 		else if (_globals[kMeteorologistStatus] == METEOROLOGIST_PRESENT)
 			_vm->_dialogs->show(20220);
 	} else if (_action.isAction(VERB_LOOK, 0x18E)) {
-		_vm->_dialogs->show(0x4EEE);
+		_vm->_dialogs->show(20206);
 	} else if (_action.isAction(VERB_LOOK, 0x164)) {
-		_vm->_dialogs->show(0x4EEF);
+		_vm->_dialogs->show(20207);
 	} else if (_action.isAction(VERB_LOOK, 0x175)) {
-		_vm->_dialogs->show(0x4EF0);
+		_vm->_dialogs->show(20208);
 	} else if (_action.isAction(VERB_LOOK, 0x174)) {
-		_vm->_dialogs->show(0x4EF1);
+		_vm->_dialogs->show(20209);
 	} else if (_action.isAction(VERB_LOOK, 0x142)) {
-		_vm->_dialogs->show(0x4EF2);
+		_vm->_dialogs->show(20210);
 	} else if (_action.isAction(VERB_LOOK, 0xAA)) {
 		if ((_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == FACING_NORTH))
 			_vm->_dialogs->show(20212);
@@ -961,13 +961,13 @@ void Scene202::actions() {
 	} else if (_action.isAction(VERB_LOOK, NOUN_STRANGE_DEVICE)) {
 		_vm->_dialogs->show(20213);
 	} else if (_action.isAction(VERB_LOOK, 0x1B5)) {
-		_vm->_dialogs->show(0x4EF6);
+		_vm->_dialogs->show(20214);
 	} else if (_action.isAction(VERB_LOOK, NOUN_SKULL)) {
-		_vm->_dialogs->show(0x4EF7);
+		_vm->_dialogs->show(20215);
 	} else if (_action.isAction(VERB_TAKE, NOUN_SKULL)) {
-		_vm->_dialogs->show(0x4EF8);
+		_vm->_dialogs->show(20216);
 	} else if (_action.isAction(VERB_LOOK, NOUN_BONES) && _action._commandSource == 4) {
-		_vm->_dialogs->show(0x4EF9);
+		_vm->_dialogs->show(20217);
 	}
 
 	_action._inProgress = false;
@@ -1082,23 +1082,23 @@ void Scene203::preActions() {
 
 void Scene203::actions() {
 	if (_action._savedFields._lookFlag) {
-		_vm->_dialogs->show(0x4F53);
+		_vm->_dialogs->show(20307);
 	} else if (_action.isAction(VERB_WALK_TOWARDS, 0x83)) {
 		_scene->_nextSceneId = 208;
 	} else if (_action.isAction(VERB_WALK_TOWARDS, 0x82)) {
 		_scene->_nextSceneId = 202;
 	} else if (_action.isAction(VERB_LOOK, 0x142)) {
-		_vm->_dialogs->show(0x4F4D);
+		_vm->_dialogs->show(20301);
 	} else if (_action.isAction(VERB_LOOK, 0x4D)) {
-		_vm->_dialogs->show(0x4F4E);
+		_vm->_dialogs->show(20302);
 	} else if (_action.isAction(VERB_LOOK, 0x100)) {
-		_vm->_dialogs->show(0x4F4F);
+		_vm->_dialogs->show(20303);
 	} else if (_action.isAction(VERB_LOOK, 0x82)) {
-		_vm->_dialogs->show(0x4F50);
+		_vm->_dialogs->show(20304);
 	} else if (_action.isAction(VERB_LOOK, 0x1A6)) {
-		_vm->_dialogs->show(0x4F51);
+		_vm->_dialogs->show(20305);
 	} else if (_action.isAction(VERB_LOOK, 0x30)) {
-		_vm->_dialogs->show(0x4F51);
+		_vm->_dialogs->show(20305);
 	} else
 		return;
 
@@ -1536,7 +1536,7 @@ void Scene207::preActions() {
 
 void Scene207::actions() {
 	if (_action._savedFields._lookFlag) {
-		_vm->_dialogs->show(0x50E7);
+		_vm->_dialogs->show(20711);
 	} else if (_action.isAction(VERB_WALK_THROUGH, 0x70)) {
 		_scene->_nextSceneId = 214;
 	} else {
@@ -1556,33 +1556,33 @@ void Scene207::actions() {
 		}
 
 		if (_action.isAction(VERB_LOOK, 0x69)) {
-			_vm->_dialogs->show(0x50DD);
+			_vm->_dialogs->show(20701);
 		} else if (_action.isAction(VERB_LOOK, 0x1AF)) {
-			_vm->_dialogs->show(0x50DE);
+			_vm->_dialogs->show(20702);
 		} else if (_action.isAction(VERB_LOOK, 0x141)) {
-			_vm->_dialogs->show(0x50DF);
+			_vm->_dialogs->show(20703);
 		} else if (_action.isAction(VERB_LOOK, 0x3E)) {
-			_vm->_dialogs->show(0x50E0);
+			_vm->_dialogs->show(20704);
 		} else if (_action.isAction(VERB_LOOK, 0x198)) {
-			_vm->_dialogs->show(0x50E1);
+			_vm->_dialogs->show(20705);
 		} else if (_action.isAction(VERB_LOOK, 0x1AE)) {
-			_vm->_dialogs->show(0x50E2);
+			_vm->_dialogs->show(20706);
 		} else if (_action.isAction(VERB_LOOK, 0xE8)) {
-			_vm->_dialogs->show(0x50E3);
+			_vm->_dialogs->show(20707);
 		} else if (_action.isAction(VERB_LOOK, 0x12)) {
-			_vm->_dialogs->show(0x50E4);
+			_vm->_dialogs->show(20708);
 		} else if (_action.isAction(VERB_LOOK, 0x1AC)) {
-			_vm->_dialogs->show(0x50E5);
+			_vm->_dialogs->show(20709);
 		} else if (_action.isAction(VERB_LOOK, 0x185)) {
-			_vm->_dialogs->show(0x50E6);
+			_vm->_dialogs->show(20710);
 		} else if (_action.isAction(VERB_TAKE, 0x141)) {
-			_vm->_dialogs->show(0x50E8);
+			_vm->_dialogs->show(20712);
 		} else if (_action.isAction(VERB_TAKE, 0x12)) {
-			_vm->_dialogs->show(0x50E9);
+			_vm->_dialogs->show(20713);
 		} else if (_action.isAction(VERB_LOOK, 0x14D)) {
-			_vm->_dialogs->show(0x50EA);
+			_vm->_dialogs->show(20714);
 		} else if (_action.isAction(VERB_TAKE, 0x14D)) {
-			_vm->_dialogs->show(0x50EB);
+			_vm->_dialogs->show(20715);
 		} else
 			return;
 	}
@@ -1832,52 +1832,52 @@ void Scene208::actions() {
 	} else if (_action.isAction(VERB_PUT, NOUN_BURGER, NOUN_LEAF_COVERED_PIT)) {
 		subAction(4);
 		if (_game._player._stepEnabled) {
-			_vm->_dialogs->show(0x514C);
+			_vm->_dialogs->show(20812);
 		}
 	} else if (_action.isAction(VERB_PUT, NOUN_DEAD_FISH, NOUN_LEAF_COVERED_PIT)) {
 		subAction(5);
 		if (_game._player._stepEnabled) {
-			_vm->_dialogs->show(0x514C);
+			_vm->_dialogs->show(20812);
 		}
 	} else if (_action.isAction(VERB_LOOK, 0x5D)) {
-		_vm->_dialogs->show(0x5141);
+		_vm->_dialogs->show(20801);
 	} else if (_action.isAction(VERB_LOOK, 0xF6)) {
-		_vm->_dialogs->show(0x5142);
+		_vm->_dialogs->show(20802);
 	} else if (_action.isAction(VERB_LOOK, 0x16F)) {
-		_vm->_dialogs->show(0x5143);
+		_vm->_dialogs->show(20803);
 	} else if (_action.isAction(VERB_LOOK, 0x129)) {
-		_vm->_dialogs->show(0x5144);
+		_vm->_dialogs->show(20804);
 	} else if (_action.isAction(VERB_LOOK, 0x1A1)) {
-		_vm->_dialogs->show(0x5145);
+		_vm->_dialogs->show(20805);
 	} else if (_action.isAction(VERB_TAKE, 0x1A1)) {
-		_vm->_dialogs->show(0x5146);
+		_vm->_dialogs->show(20806);
 	} else if (_action.isAction(VERB_LOOK, 0x9B)) {
-		_vm->_dialogs->show(0x5147);
+		_vm->_dialogs->show(20807);
 	} else if (_action.isAction(VERB_LOOK, NOUN_DEEP_PIT)) {
-		_vm->_dialogs->show(0x5148);
+		_vm->_dialogs->show(20808);
 	} else if (_action.isAction(VERB_LOOK, NOUN_PILE_OF_LEAVES)) {
-		_vm->_dialogs->show(0x5149);
+		_vm->_dialogs->show(20809);
 	} else if (_action.isAction(VERB_LOOK, NOUN_LEAF_COVERED_PIT)) {
 		if (_game._difficulty == DIFFICULTY_EASY)
-			_vm->_dialogs->show(0x514A);
+			_vm->_dialogs->show(20810);
 		else
-			_vm->_dialogs->show(0x514B);
+			_vm->_dialogs->show(20811);
 	} else if (_action.isAction(VERB_LOOK, 0x174) || _action.isAction(VERB_LOOK, 0x175)) {
-		_vm->_dialogs->show(0x514D);
+		_vm->_dialogs->show(20813);
 	} else if (_action.isAction(VERB_TAKE, NOUN_LEAF_COVERED_PIT)) {
-		_vm->_dialogs->show(0x514E);
+		_vm->_dialogs->show(20814);
 	} else if (_action.isAction(VERB_LOOK, NOUN_HUGE_LEGS)) {
-		_vm->_dialogs->show(0x514F);
+		_vm->_dialogs->show(20815);
 	} else if (_action.isAction(VERB_TAKE, NOUN_HUGE_LEGS) || _action.isAction(VERB_PULL, NOUN_HUGE_LEGS)) {
-		_vm->_dialogs->show(0x5150);
+		_vm->_dialogs->show(20816);
 	} else if (_action._savedFields._lookFlag == 0) {
 		return;
 	} else if (_globals[kRhotundaStatus] == 1) {
-		_vm->_dialogs->show(0x5153);
+		_vm->_dialogs->show(20819);
 	} else if (_globals[kLeavesStatus] == 2) {
-		_vm->_dialogs->show(0x5152);
+		_vm->_dialogs->show(20818);
 	} else {
-		_vm->_dialogs->show(0x5151);
+		_vm->_dialogs->show(20817);
 	}
 
 	_action._inProgress = false;
@@ -2581,7 +2581,7 @@ void Scene209::handleMonkeyFall() {
 		_fallFl = false;
 		_counter = 0;
 		_pauseMode = 0;
-		_vm->_dialogs->show(0x51AE);
+		_vm->_dialogs->show(20910);
 		_game._player._stepEnabled = true;
 		break;
 	}
@@ -3171,7 +3171,7 @@ void Scene209::preActions() {
 
 void Scene209::actions() {
 	if (_action._lookFlag) {
-		_vm->_dialogs->show(0x51B0);
+		_vm->_dialogs->show(20912);
 		_action._inProgress = false;
 		return;
 	}
@@ -3315,7 +3315,7 @@ void Scene209::actions() {
 		if (_action.isAction(VERB_LOOK, NOUN_MONKEY)) {
 			_pitchFl = true;
 			_game._player._stepEnabled = false;
-			_vm->_dialogs->show(0x51B2);
+			_vm->_dialogs->show(20914);
 			_action._inProgress = false;
 			return;
 		}
@@ -3387,69 +3387,69 @@ void Scene209::actions() {
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x142)) {
-		_vm->_dialogs->show(0x51A5);
+		_vm->_dialogs->show(20901);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x1A3)) {
-		_vm->_dialogs->show(0x51A6);
+		_vm->_dialogs->show(20902);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x1A4)) {
-		_vm->_dialogs->show(0x51A7);
+		_vm->_dialogs->show(20903);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x1A6)) {
-		_vm->_dialogs->show(0x51A8);
+		_vm->_dialogs->show(20904);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x84)) {
-		_vm->_dialogs->show(0x51A9);
+		_vm->_dialogs->show(20905);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x1A2)) {
-		_vm->_dialogs->show(0x51AA);
+		_vm->_dialogs->show(20906);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x10F) && (_action._savedFields._mainObjectSource == 4)) {
-		_vm->_dialogs->show(0x51AB);
+		_vm->_dialogs->show(20907);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_GIVE, 0x17A, 0xE3) || _action.isAction(VERB_THROW, 0x17A, 0xE3)) {
-		_vm->_dialogs->show(0x51AD);
+		_vm->_dialogs->show(20909);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x175)) {
-		_vm->_dialogs->show(0x51B1);
+		_vm->_dialogs->show(20913);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_THROW, 0xE3) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
 		if (!_action.isAction(0x114)) {
-			_vm->_dialogs->show(0x51B3);
+			_vm->_dialogs->show(20915);
 		}
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_THROW, 0x114, 0xE3)) {
-		_vm->_dialogs->show(0x51B4);
+		_vm->_dialogs->show(20916);
 		_action._inProgress = false;
 		return;
 	}
@@ -3457,27 +3457,27 @@ void Scene209::actions() {
 	if (_action.isAction(VERB_LOOK, 0x100)) {
 		if (_globals[kMonkeyStatus] == MONKEY_HAS_BINOCULARS) {
 			if (_monkeyPosition == 1)
-				_vm->_dialogs->show(0x51B5);
+				_vm->_dialogs->show(20917);
 			else
-				_vm->_dialogs->show(0x51B6);
+				_vm->_dialogs->show(20918);
 		} else {
 			if (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY)
-				_vm->_dialogs->show(0x51B5);
+				_vm->_dialogs->show(20917);
 			else
-				_vm->_dialogs->show(0x51B7);
+				_vm->_dialogs->show(20919);
 		}
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x3A4)) {
-		_vm->_dialogs->show(0x51B8);
+		_vm->_dialogs->show(20920);
 		_action._inProgress = false;
 		return;
 	}
 
 	if (_action.isAction(VERB_TAKE, 0x3A4)) {
-		_vm->_dialogs->show(0x51B9);
+		_vm->_dialogs->show(20921);
 		_action._inProgress = false;
 		return;
 	}
@@ -4327,7 +4327,7 @@ void Scene210::preActions() {
 
 void Scene210::actions() {
 	if (_action.isAction(VERB_LOOK, 0x27, 0x1C0)) {
-		_vm->_dialogs->show(0x5219);
+		_vm->_dialogs->show(21017);
 	} else if (_game._screenObjects._inputMode == 1) {
 		handleConversations();
 	} else if (_action.isAction(VERB_TALKTO, 0x1DC) ||
@@ -4444,38 +4444,38 @@ void Scene210::actions() {
 	} else if (_action.isAction(VERB_LOOK, 0xAA)) {
 		if (_globals[kTwinklesStatus] == TWINKLES_GONE) {
 			if (_game._storyMode == STORYMODE_NAUGHTY)
-				_vm->_dialogs->show(0x520B);
+				_vm->_dialogs->show(21003);
 			else
-				_vm->_dialogs->show(0x520A);
+				_vm->_dialogs->show(21002);
 		} else {
-			_vm->_dialogs->show(0x5209);
+			_vm->_dialogs->show(21001);
 		}
 	} else if (_action.isAction(VERB_LOOK, 0x31)) {
-		_vm->_dialogs->show(0x520C);
+		_vm->_dialogs->show(21004);
 	} else if (_action.isAction(VERB_LOOK, 0xA7)) {
-		_vm->_dialogs->show(0x520D);
+		_vm->_dialogs->show(21005);
 	} else if (_action.isAction(VERB_TAKE, 0xA7) || _action.isAction(VERB_TAKE, 0x31)) {
-		_vm->_dialogs->show(0x520E);
+		_vm->_dialogs->show(21006);
 	} else if (_action.isAction(VERB_LOOK, 0x1C5)) {
-		_vm->_dialogs->show(0x520F);
+		_vm->_dialogs->show(21007);
 	} else if (_action.isAction(VERB_LOOK, 0x3A)) {
-		_vm->_dialogs->show(0x5210);
+		_vm->_dialogs->show(21008);
 	} else if (_action.isAction(VERB_LOOK, 0x1B0)) {
-		_vm->_dialogs->show(0x5211);
+		_vm->_dialogs->show(21009);
 	} else if (_action.isAction(VERB_LOOK, 0x1DC)) {
-		_vm->_dialogs->show(0x5212);
+		_vm->_dialogs->show(21010);
 	} else if (_action.isAction(0x13A, 0x1DC) || _action.isAction(0xA6, 0x1DC)) {
-		_vm->_dialogs->show(0x5213);
+		_vm->_dialogs->show(21011);
 	} else if (_action.isAction(VERB_LOOK, 0x1BF)) {
-		_vm->_dialogs->show(0x5214);
+		_vm->_dialogs->show(21012);
 	} else if (_action.isAction(VERB_LOOK, 0x5F)) {
-		_vm->_dialogs->show(0x5215);
+		_vm->_dialogs->show(21013);
 	} else if (_action.isAction(VERB_LOOK, 0x53)) {
-		_vm->_dialogs->show(0x5216);
+		_vm->_dialogs->show(21014);
 	} else if (_action.isAction(VERB_TAKE, 0x53)) {
-		_vm->_dialogs->show(0x5217);
+		_vm->_dialogs->show(21015);
 	} else if (_action.isAction(VERB_LOOK, 0x1C0)) {
-		_vm->_dialogs->show(0x5218);
+		_vm->_dialogs->show(21016);
 	} else {
 		// Not handled
 		return;
@@ -4738,39 +4738,39 @@ void Scene211::preActions() {
 
 void Scene211::actions() {
 	if (_action._lookFlag && (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY))
-		_vm->_dialogs->show(0x5277);
+		_vm->_dialogs->show(21111);
 	else if (_action.isAction(VERB_LOOK, 0x27, 0x100))
-		_vm->_dialogs->show(0x527C);
+		_vm->_dialogs->show(21116);
 	else if (_action.isAction(VERB_LOOK, 0x3A))
-		_vm->_dialogs->show(0x526D);
+		_vm->_dialogs->show(21101);
 	else if (_action.isAction(VERB_LOOK, 0x1B2))
-		_vm->_dialogs->show(0x526E);
+		_vm->_dialogs->show(21102);
 	else if (_action.isAction(VERB_LOOK, 0x100)) {
 		if (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY) {
 			if (_game._storyMode == STORYMODE_NAUGHTY)
-				_vm->_dialogs->show(0x526F);
+				_vm->_dialogs->show(21103);
 			else
-				_vm->_dialogs->show(0x5270);
+				_vm->_dialogs->show(21104);
 		} else {
-			_vm->_dialogs->show(0x5271);
+			_vm->_dialogs->show(21105);
 		}
 	} else if (_action.isAction(VERB_LOOK, 0x1B3)) {
 		if (_game._storyMode == STORYMODE_NAUGHTY)
-			_vm->_dialogs->show(0x5272);
+			_vm->_dialogs->show(21106);
 		else
-			_vm->_dialogs->show(0x5273);
+			_vm->_dialogs->show(21107);
 	} else if (_action.isAction(VERB_LOOK, 0xB8))
-		_vm->_dialogs->show(0x5274);
+		_vm->_dialogs->show(21108);
 	else if (_action.isAction(VERB_LOOK, 0x1B1))
-		_vm->_dialogs->show(0x5275);
+		_vm->_dialogs->show(21109);
 	else if (_action.isAction(VERB_LOOK, 0x1AE))
-		_vm->_dialogs->show(0x5276);
+		_vm->_dialogs->show(21110);
 	else if (_action.isAction(VERB_LOOK, 0x144))
-		_vm->_dialogs->show(0x5279);
+		_vm->_dialogs->show(21113);
 	else if (_action.isAction(VERB_TAKE, 0x144))
-		_vm->_dialogs->show(0x527A);
+		_vm->_dialogs->show(21114);
 	else if (_action.isAction(VERB_LOOK, 0x129))
-		_vm->_dialogs->show(0x527B);
+		_vm->_dialogs->show(21115);
 	else
 		return;
 
@@ -4821,27 +4821,27 @@ void Scene212::preActions() {
 
 void Scene212::actions() {
 	if (_action._lookFlag)
-		_vm->_dialogs->show(0x52D9);
+		_vm->_dialogs->show(21209);
 	else if (_action.isAction(VERB_WALK_TOWARDS) && (_action.isObject(0x82) || _action.isObject(0xE8)))
 		_scene->_nextSceneId = 208;
 	else if (_action.isAction(VERB_WALK_TOWARDS, 0x3F))
 		_scene->_nextSceneId = 111;
 	else if (_action.isAction(VERB_LOOK, 0x19C))
-		_vm->_dialogs->show(0x52D1);
+		_vm->_dialogs->show(21201);
 	else if (_action.isAction(VERB_LOOK, 0x129))
-		_vm->_dialogs->show(0x52D2);
+		_vm->_dialogs->show(21202);
 	else if (_action.isAction(VERB_LOOK, 0x41))
-		_vm->_dialogs->show(0x52D3);
+		_vm->_dialogs->show(21203);
 	else if (_action.isAction(VERB_LOOK, 0x142))
-		_vm->_dialogs->show(0x52D4);
+		_vm->_dialogs->show(21204);
 	else if (_action.isAction(VERB_LOOK, 0x82))
-		_vm->_dialogs->show(0x52D5);
+		_vm->_dialogs->show(21205);
 	else if (_action.isAction(VERB_LOOK, 0x175))
-		_vm->_dialogs->show(0x52D6);
+		_vm->_dialogs->show(21206);
 	else if (_action.isAction(VERB_LOOK, 0x110))
-		_vm->_dialogs->show(0x52D7);
+		_vm->_dialogs->show(21207);
 	else if (_action.isAction(VERB_LOOK, 0xE8))
-		_vm->_dialogs->show(0x52D8);
+		_vm->_dialogs->show(21208);
 	else
 		return;
 
@@ -4991,7 +4991,7 @@ void Scene214::step() {
 
 void Scene214::actions() {
 	if (_action._lookFlag)
-		_vm->_dialogs->show(0x53B3);
+		_vm->_dialogs->show(21427);
 	else if (_action.isAction(0x18A, 0xAA))
 		_scene->_nextSceneId = 207;
 	else if (_action.isAction(VERB_TAKE, 0x114) && (_game._trigger || _game._objects.isInRoom(OBJ_POISON_DARTS))) {
@@ -5053,60 +5053,60 @@ void Scene214::actions() {
 			break;
 		}
 	} else if (_action.isAction(VERB_LOOK, 0x197))
-		_vm->_dialogs->show(0x5399);
+		_vm->_dialogs->show(21401);
 	else if (_action.isAction(VERB_LOOK, 0x7E))
-		_vm->_dialogs->show(0x539A);
+		_vm->_dialogs->show(21402);
 	else if (_action.isAction(VERB_LOOK, 0x1C3))
-		_vm->_dialogs->show(0x539B);
+		_vm->_dialogs->show(21403);
 	else if (_action.isAction(VERB_LOOK, 0x21))
-		_vm->_dialogs->show(0x539C);
+		_vm->_dialogs->show(21404);
 	else if (_action.isAction(VERB_LOOK, 0x1BB))
-		_vm->_dialogs->show(0x539D);
+		_vm->_dialogs->show(21405);
 	else if (_action.isAction(VERB_LOOK, 0x1BE)) {
 		if (_game._storyMode == STORYMODE_NAUGHTY) {
-			_vm->_dialogs->show(0x539E);
+			_vm->_dialogs->show(21406);
 		} else {
-			_vm->_dialogs->show(0x539F);
+			_vm->_dialogs->show(21407);
 		}
 	} else if (_action.isAction(VERB_LOOK, 0x1BC))
-		_vm->_dialogs->show(0x53A0);
+		_vm->_dialogs->show(21408);
 	else if (_action.isAction(VERB_TAKE, 0x1BE) || _action.isAction(VERB_TAKE, 0x1BC))
-		_vm->_dialogs->show(0x53A1);
+		_vm->_dialogs->show(21409);
 	else if (_action.isAction(VERB_LOOK, 0x13D))
-		_vm->_dialogs->show(0x53A2);
+		_vm->_dialogs->show(21410);
 	else if (_action.isAction(VERB_TAKE, 0x13D) || _action.isAction(VERB_TAKE, 0x48A))
-		_vm->_dialogs->show(0x53A3);
+		_vm->_dialogs->show(21411);
 	else if (_action.isAction(VERB_LOOK, 0x48A))
-		_vm->_dialogs->show(0x53B4);
+		_vm->_dialogs->show(21428);
 	else if (_action.isAction(VERB_LOOK, 0x114) && (_action._savedFields._mainObjectSource == 4))
-		_vm->_dialogs->show(0x53A4);
+		_vm->_dialogs->show(21412);
 	else if (_action.isAction(VERB_OPEN, 0x7E))
-		_vm->_dialogs->show(0x53A6);
+		_vm->_dialogs->show(21414);
 	else if (_action.isAction(VERB_TALKTO, 0x1C3))
-		_vm->_dialogs->show(0x53A7);
+		_vm->_dialogs->show(21415);
 	else if (_action.isAction(VERB_GIVE, 0x17A, 0x1C3))
-		_vm->_dialogs->show(0x53A8);
+		_vm->_dialogs->show(21416);
 	else if (_action.isAction(0x13A, 0x29, 0x1C3) || _action.isAction(0xA6, 0x29, 0x1C3))
-		_vm->_dialogs->show(0x53A9);
+		_vm->_dialogs->show(21417);
 	else if (_action.isAction(VERB_LOOK, 0x473))
-		_vm->_dialogs->show(0x53AA);
+		_vm->_dialogs->show(21418);
 	else if (_action.isAction(VERB_TAKE, 0x473))
-		_vm->_dialogs->show(0x53AB);
+		_vm->_dialogs->show(21419);
 	else if (_action.isAction(VERB_TAKE, 0x21))
-		_vm->_dialogs->show(0x53AC);
+		_vm->_dialogs->show(21420);
 	else if (_action.isAction(VERB_LOOK, 0x8A))
-		_vm->_dialogs->show(0x53AD);
+		_vm->_dialogs->show(21421);
 	else if (_action.isAction(VERB_LOOK, 0x29))
-		_vm->_dialogs->show(0x53AE);
+		_vm->_dialogs->show(21422);
 	else if (_action.isAction(VERB_LOOK, 0x160)) {
 		if (_game._objects.isInRoom(OBJ_POISON_DARTS) && _game._objects.isInRoom(OBJ_BLOWGUN)) {
-			_vm->_dialogs->show(0x53AF);
+			_vm->_dialogs->show(21423);
 		} else if (_game._objects.isInRoom(OBJ_POISON_DARTS) && !_game._objects.isInRoom(OBJ_BLOWGUN)) {
-			_vm->_dialogs->show(0x53B0);
+			_vm->_dialogs->show(21424);
 		} else if (!_game._objects.isInRoom(OBJ_POISON_DARTS) && _game._objects.isInRoom(OBJ_BLOWGUN)) {
-			_vm->_dialogs->show(0x53B1);
+			_vm->_dialogs->show(21425);
 		} else {
-			_vm->_dialogs->show(0x53B2);
+			_vm->_dialogs->show(21426);
 		}
 	} else
 		return;
@@ -5173,7 +5173,7 @@ void Scene215::step() {
 
 void Scene215::actions() {
 	if (_action._lookFlag)
-		_vm->_dialogs->show(0x5405);
+		_vm->_dialogs->show(21509);
 	else if (_action.isAction(VERB_TAKE, 0x17A)) {
 		if (!_game._objects.isInInventory(OBJ_TWINKIFRUIT) || _game._trigger) {
 			switch (_game._trigger) {
@@ -5213,29 +5213,29 @@ void Scene215::actions() {
 	} else if (_action.isAction(0x18A, 0xAA))
 		_scene->_nextSceneId = 210;
 	else if (_action.isAction(VERB_LOOK, 0x21))
-		_vm->_dialogs->show(0x53FD);
+		_vm->_dialogs->show(21501);
 	else if (_action.isAction(VERB_LOOK, 0x1CB))
-		_vm->_dialogs->show(0x53FE);
+		_vm->_dialogs->show(21502);
 	else if (_action.isAction(VERB_LOOK, 0x3A3))
-		_vm->_dialogs->show(0x53FF);
+		_vm->_dialogs->show(21503);
 	else if (_action.isAction(VERB_LOOK, 0xD5))
-		_vm->_dialogs->show(0x5400);
+		_vm->_dialogs->show(21504);
 	else if (_action.isAction(VERB_LOOK, 0x197))
-		_vm->_dialogs->show(0x5401);
+		_vm->_dialogs->show(21505);
 	else if (_action.isAction(VERB_LOOK, 0x289))
-		_vm->_dialogs->show(0x5402);
+		_vm->_dialogs->show(21506);
 	else if (_action.isAction(VERB_LOOK, 0x17A) && (_action._savedFields._mainObjectSource == 4))
-		_vm->_dialogs->show(0x5403);
+		_vm->_dialogs->show(21507);
 	else if (_action.isAction(VERB_TAKE, 0x21))
-		_vm->_dialogs->show(0x5406);
+		_vm->_dialogs->show(21510);
 	else if (_action.isAction(VERB_TAKE, 0xD5))
-		_vm->_dialogs->show(0x5407);
+		_vm->_dialogs->show(21511);
 	else if (_action.isAction(VERB_LOOK, 0x1CA))
-		_vm->_dialogs->show(0x5408);
+		_vm->_dialogs->show(21512);
 	else if (_action.isAction(VERB_TAKE, 0x1CA))
-		_vm->_dialogs->show(0x5409);
+		_vm->_dialogs->show(21513);
 	else if (_action.isAction(VERB_TAKE, 0x3A3))
-		_vm->_dialogs->show(0x540A);
+		_vm->_dialogs->show(21514);
 	else
 		return;
 
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 40f2533..5337c99 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -859,7 +859,7 @@ void Scene307::step() {
 
 void Scene307::actions() {
 	if (_action._lookFlag)
-		_vm->_dialogs->show(0x77FB);
+		_vm->_dialogs->show(30715);
 	else if (_game._screenObjects._inputMode == 1)
 		handleDialog();
 	else if (_action.isAction(VERB_TALKTO, 0x207) || _action.isAction(VERB_TALKTO, 0x18D) || _action.isAction(VERB_TALKTO, 0x21B)) {
@@ -1043,7 +1043,7 @@ void Scene307::actions() {
 			}
 		}
 	} else if (_action.isAction(0x20C, 0x21B) && (_game._storyMode != STORYMODE_NAUGHTY))
-		_vm->_dialogs->show(0x7803);
+		_vm->_dialogs->show(30723);
 	else if (_action.isAction(0x20C, 0x21B)) {
 		if (!_afterPeeingFl) {
 			switch (_game._trigger) {
@@ -1096,40 +1096,40 @@ void Scene307::actions() {
 		}
 	} else if (_action.isAction(VERB_LOOK, 0x11)) {
 		if (!_grateOpenedFl)
-			_vm->_dialogs->show(0x77F6);
+			_vm->_dialogs->show(30710);
 		else
-			_vm->_dialogs->show(0x77F7);
+			_vm->_dialogs->show(30711);
 	} else if (_action.isAction(VERB_LOOK, 0x1CB))
-		_vm->_dialogs->show(0x77F8);
+		_vm->_dialogs->show(30712);
 	else if (_action.isAction(VERB_LOOK, 0x216))
-		_vm->_dialogs->show(0x77F9);
+		_vm->_dialogs->show(30713);
 	else if (_action.isAction(VERB_LOOK, 0x21B))
-		_vm->_dialogs->show(0x77FA);
+		_vm->_dialogs->show(30714);
 	else if (_action.isAction(0x134, 0x12C))
-		_vm->_dialogs->show(0x77FC);
+		_vm->_dialogs->show(30716);
 	else if (_action.isAction(VERB_LOOK, 0x207))
-		_vm->_dialogs->show(0x77FD);
+		_vm->_dialogs->show(30717);
 	else if (_action.isAction(VERB_LOOK, 0xCD))
-		_vm->_dialogs->show(0x77FE);
+		_vm->_dialogs->show(30718);
 	else if (_action.isAction(0x242, 0x204)) {
 		switch (_fieldCollisionCounter) {
 		case 0:
-			_vm->_dialogs->show(0x77FF);
+			_vm->_dialogs->show(30719);
 			_fieldCollisionCounter = 1;
 			break;
 
 		case 1:
-			_vm->_dialogs->show(0x7800);
+			_vm->_dialogs->show(30720);
 			_fieldCollisionCounter = 2;
 			break;
 
 		case 2:
-			_vm->_dialogs->show(0x7801);
+			_vm->_dialogs->show(30721);
 			_fieldCollisionCounter = 3;
 			break;
 
 		case 3:
-			_vm->_dialogs->show(0x7802);
+			_vm->_dialogs->show(30722);
 			break;
 		}
 	} else
@@ -1691,7 +1691,7 @@ void Scene311::step() {
 
 void Scene311::actions() {
 	if (_action._lookFlag)
-		_vm->_dialogs->show(0x798F);
+		_vm->_dialogs->show(31119);
 	else if (_checkGuardFl) {
 		_checkGuardFl = false;
 		_scene->_kernelMessages.reset();
@@ -1791,25 +1791,25 @@ void Scene311::actions() {
 			break;
 		}
 	} else if (_action.isAction(VERB_LOOK, 0x1E4))
-		_vm->_dialogs->show(0x7986);
+		_vm->_dialogs->show(31110);
 	else if (_action.isAction(VERB_LOOK, 0x18D))
-		_vm->_dialogs->show(0x7987);
+		_vm->_dialogs->show(31111);
 	else if (_action.isAction(VERB_LOOK, 0x220) || _action.isAction(0x155, 0x220))
-		_vm->_dialogs->show(0x7988);
+		_vm->_dialogs->show(31112);
 	else if (_action.isAction(VERB_LOOK, 0x208) || _action.isAction(0x155, 0x208))
-		_vm->_dialogs->show(0x7989);
+		_vm->_dialogs->show(31113);
 	else if (_action.isAction(VERB_TAKE, 0x208))
-		_vm->_dialogs->show(0x798A);
+		_vm->_dialogs->show(31114);
 	else if (_action.isAction(VERB_LOOK, 0xCD) || _action.isAction(0x155, 0xCD))
-		_vm->_dialogs->show(0x798B);
+		_vm->_dialogs->show(31115);
 	else if (_action.isAction(VERB_TAKE, 0xCD))
-		_vm->_dialogs->show(0x798C);
+		_vm->_dialogs->show(31116);
 	else if (_action.isAction(VERB_LOOK, 0x2BA))
-		_vm->_dialogs->show(0x798D);
+		_vm->_dialogs->show(31117);
 	else if (_action.isAction(VERB_LOOK, 0x2B9))
-		_vm->_dialogs->show(0x798E);
+		_vm->_dialogs->show(31118);
 	else if (_action.isAction(VERB_LOOK, 0x11))
-		_vm->_dialogs->show(0x7990);
+		_vm->_dialogs->show(31120);
 	else
 		return;
 
@@ -1880,13 +1880,13 @@ void Scene313::actions() {
 	else if (_action.isAction(0x2FB, 0x2EF)) {
 		if (_globals[kSexOfRex] == REX_FEMALE) {
 			_globals[kSexOfRex] = REX_MALE;
-			_vm->_dialogs->show(0x7A45);
+			_vm->_dialogs->show(31301);
 		}
 		_scene->_nextSceneId = 391;
 	} else if (_action.isAction(0x2FB, 0x300)) {
 		if (_globals[kSexOfRex] == REX_FEMALE) {
 			_globals[kSexOfRex] = REX_MALE;
-			_vm->_dialogs->show(0x7A45);
+			_vm->_dialogs->show(31301);
 		}
 		_scene->_nextSceneId = 366;
 	} else if (!_action.isAction(0x301, 0x2D4))
@@ -2267,7 +2267,7 @@ void Scene316::actions() {
 		switch (_game._trigger) {
 		case 0:
 			if (_globals[kCityFlooded]) {
-				_vm->_dialogs->show(0x7B87);
+				_vm->_dialogs->show(31623);
 			} else {
 				_vm->_sound->command(45);
 				_game._player._stepEnabled = false;
@@ -2315,35 +2315,35 @@ void Scene316::actions() {
 			break;
 		}
 	} else if (_action.isAction(VERB_LOOK, 0x22C))
-		_vm->_dialogs->show(0x7B7A);
+		_vm->_dialogs->show(31610);
 	else if (_action.isAction(VERB_LOOK, 0x1B6)) {
 		if (_game._visitedScenes.exists(321))
-			_vm->_dialogs->show(0x7B7C);
+			_vm->_dialogs->show(31612);
 		else
-			_vm->_dialogs->show(0x7B7B);
+			_vm->_dialogs->show(31611);
 	} else if (_action.isAction(VERB_LOOK, 0x2C6))
-		_vm->_dialogs->show(0x7B7D);
+		_vm->_dialogs->show(31613);
 	else if (_action.isAction(VERB_LOOK, 0x2C7))
-		_vm->_dialogs->show(0x7B7E);
+		_vm->_dialogs->show(31614);
 	else if (_action.isAction(VERB_LOOK, 0x1E0))
-		_vm->_dialogs->show(0x7B7F);
+		_vm->_dialogs->show(31615);
 	else if (_action.isAction(VERB_LOOK, 0xE2))
-		_vm->_dialogs->show(0x7B80);
+		_vm->_dialogs->show(31616);
 	else if (_action.isAction(VERB_LOOK, 0x226))
-		_vm->_dialogs->show(0x7B81);
+		_vm->_dialogs->show(31617);
 	else if (_action.isAction(VERB_LOOK, 0x11))
-		_vm->_dialogs->show(0x7B82);
+		_vm->_dialogs->show(31618);
 	else if (_action.isAction(VERB_LOOK, 0x2B9)) {
 		if (!_globals[kAfterHavoc]) {
 			if (_game._difficulty != DIFFICULTY_EASY)
-				_vm->_dialogs->show(0x7B84);
+				_vm->_dialogs->show(31620);
 			else
-				_vm->_dialogs->show(0x7B83);
+				_vm->_dialogs->show(31619);
 		}
 	} else if (_action.isAction(VERB_LOOK, 0x89))
-		_vm->_dialogs->show(0x7B85);
+		_vm->_dialogs->show(31621);
 	else if (_action.isAction(VERB_LOOK, 0x257))
-		_vm->_dialogs->show(0x7B86);
+		_vm->_dialogs->show(31622);
 	else
 		return;
 
@@ -2843,7 +2843,7 @@ void Scene318::actions() {
 				_vm->_dialogs->showItem(OBJ_AUDIO_TAPE, 0x7C5B);
 				_game._objects.addToInventory(OBJ_AUDIO_TAPE);
 			} else
-				_vm->_dialogs->show(0x7C5A);
+				_vm->_dialogs->show(31834);
 
 			_action._inProgress = false;
 			return;
@@ -2851,84 +2851,84 @@ void Scene318::actions() {
 
 		if (_action.isAction(VERB_LOOK, 0x165)) {
 			if (_game._objects.isInRoom(OBJ_AUDIO_TAPE))
-				_vm->_dialogs->show(0x7C59);
+				_vm->_dialogs->show(31833);
 			else
-				_vm->_dialogs->show(0x7C5A);
+				_vm->_dialogs->show(31834);
 
 			_action._inProgress = false;
 			return;
 		}
 
 		if (_action.isAction(0x242, 0x488)) {
-			_vm->_dialogs->show(0x7C57);
+			_vm->_dialogs->show(31831);
 			_action._inProgress = false;
 			return;
 		}
 
 		if (_action.isAction(VERB_LOOK, 0x2D9)) {
-			_vm->_dialogs->show(0x7C4F);
+			_vm->_dialogs->show(31823);
 			_action._inProgress = false;
 			return;
 		}
 
 		if (_action.isAction(VERB_LOOK, 0x308)) {
-			_vm->_dialogs->show(0x7C51);
+			_vm->_dialogs->show(31825);
 			_action._inProgress = false;
 			return;
 		}
 	} else { // Not visible
 		if (_action.isAction(VERB_LOOK, 0x2D9)) {
-			_vm->_dialogs->show(0x7C4E);
+			_vm->_dialogs->show(31822);
 			_action._inProgress = false;
 			return;
 		}
 
 		if (_action.isAction(VERB_LOOK, 0x308)) {
-			_vm->_dialogs->show(0x7C50);
+			_vm->_dialogs->show(31824);
 			_action._inProgress = false;
 			return;
 		}
 	}
 
 	if (_action.isAction(VERB_LOOK, 0x18D))
-		_vm->_dialogs->show(0x7C42);
+		_vm->_dialogs->show(31810);
 	else if (_action.isAction(VERB_LOOK, 0x89))
-		_vm->_dialogs->show(0x7C43);
+		_vm->_dialogs->show(31811);
 	else if (_action.isAction(VERB_LOOK, 0x2BA))
-		_vm->_dialogs->show(0x7C44);
+		_vm->_dialogs->show(31812);
 	else if (_action.isAction(VERB_LOOK, 0x2B3))
-		_vm->_dialogs->show(0x7C45);
+		_vm->_dialogs->show(31813);
 	else if (_action.isAction(VERB_LOOK, 0x2CB))
-		_vm->_dialogs->show(0x7C46);
+		_vm->_dialogs->show(31814);
 	else if (_action.isAction(VERB_LOOK, 0x216))
-		_vm->_dialogs->show(0x7C47);
+		_vm->_dialogs->show(31815);
 	else if (_action.isAction(VERB_LOOK, 0x319))
-		_vm->_dialogs->show(0x7C48);
+		_vm->_dialogs->show(31816);
 	else if (_action.isAction(VERB_LOOK, 0x477))
-		_vm->_dialogs->show(0x7C49);
+		_vm->_dialogs->show(31817);
 	else if (_action.isAction(VERB_LOOK, 0xE2))
-		_vm->_dialogs->show(0x7C4A);
+		_vm->_dialogs->show(31818);
 	else if (_action.isAction(VERB_LOOK, 0x2C9))
-		_vm->_dialogs->show(0x7C4B);
+		_vm->_dialogs->show(31819);
 	else if (_action.isAction(VERB_LOOK, 0x2C7))
-		_vm->_dialogs->show(0x7C4C);
+		_vm->_dialogs->show(31820);
 	else if (_action.isAction(VERB_LOOK, 0x2C8))
-		_vm->_dialogs->show(0x7C4D);
+		_vm->_dialogs->show(31821);
 	else if (_action.isAction(VERB_OPEN, 0x2C9))
-		_vm->_dialogs->show(0x7C55);
+		_vm->_dialogs->show(31829);
 	else if (_action.isAction(VERB_LOOK, 0x307))
-		_vm->_dialogs->show(0x7C56);
+		_vm->_dialogs->show(31830);
 	else if (_action.isAction(VERB_LOOK, 0x3A1))
-		_vm->_dialogs->show(0x7C58);
+		_vm->_dialogs->show(31832);
 	else if (_action.isAction(VERB_LOOK, 0x3A2))
-		_vm->_dialogs->show(0x7C5C);
+		_vm->_dialogs->show(31836);
 	else if (_action._lookFlag) {
 		if (_game._player._visible || _game._objects.isInInventory(OBJ_SCALPEL))
-			_vm->_dialogs->show(0x7C54);
+			_vm->_dialogs->show(31828);
 		else if (_internVisibleFl)
-			_vm->_dialogs->show(0x7C52);
+			_vm->_dialogs->show(31826);
 		else
-			_vm->_dialogs->show(0x7C53);
+			_vm->_dialogs->show(31827);
 	} else
 		return;
 
@@ -3640,7 +3640,7 @@ void Scene320::step() {
 
 void Scene320::actions() {
 	if (_action._lookFlag)
-		_vm->_dialogs->show(0x7D0B);
+		_vm->_dialogs->show(32011);
 	else if ((_action.isAction(0x11A) || _action.isAction(VERB_PUSH)) &&
 		(_action.isAction(0x2E8) || _action.isAction(0x2E9) || _action.isAction(0x2EA) || _action.isAction(0x2EB) ||
 		 _action.isAction(0x2DE) || _action.isAction(0x2DD) || _action.isAction(0x2E0) || _action.isAction(0x2E1) ||
@@ -3712,37 +3712,37 @@ void Scene320::actions() {
 	} else if (_action.isAction(0x1CD, 0x2EF))
 		_scene->_nextSceneId = 311;
 	else if (_action.isAction(VERB_LOOK, 0x2DC))
-		_vm->_dialogs->show(0x7D01);
+		_vm->_dialogs->show(32001);
 	else if (_action.isAction(VERB_LOOK, 0x2DB))
-		_vm->_dialogs->show(0x7D02);
+		_vm->_dialogs->show(32002);
 	else if (_action.isAction(VERB_LOOK, 0x1E4))
-		_vm->_dialogs->show(0x7D03);
+		_vm->_dialogs->show(32003);
 	else if (_action.isAction(VERB_LOOK, 0x2EF))
-		_vm->_dialogs->show(0x7D04);
+		_vm->_dialogs->show(32004);
 	else if (_action.isAction(VERB_LOOK, 0x2ED))
-		_vm->_dialogs->show(0x7D05);
+		_vm->_dialogs->show(32005);
 	else if (_action.isAction(VERB_LOOK, 0x2EE))
-		_vm->_dialogs->show(0x7D06);
+		_vm->_dialogs->show(32006);
 	else if (_action.isAction(VERB_LOOK, 0x2F1))
-		_vm->_dialogs->show(0x7D06);
+		_vm->_dialogs->show(32006);
 	else if (_action.isAction(VERB_LOOK, 0x2F3))
-		_vm->_dialogs->show(0x7D08);
+		_vm->_dialogs->show(32008);
 	else if (_action.isAction(VERB_LOOK, 0x2F0))
-		_vm->_dialogs->show(0x7D09);
+		_vm->_dialogs->show(32009);
 	else if (_action.isAction(VERB_LOOK, 0x2F2))
-		_vm->_dialogs->show(0x7D0A);
+		_vm->_dialogs->show(32010);
 	else if (_action.isAction(VERB_TAKE, 0x2ED))
-		_vm->_dialogs->show(0x7D0C);
+		_vm->_dialogs->show(32012);
 	else if (_action.isAction(VERB_TAKE, 0x2F2))
-		_vm->_dialogs->show(0x7D0D);
+		_vm->_dialogs->show(32013);
 	else if (_action.isAction(VERB_TAKE, 0x2EE) || _action.isAction(0x75, 0x2EE))
-		_vm->_dialogs->show(0x7D0E);
+		_vm->_dialogs->show(32014);
 	else if (_action.isAction(VERB_TAKE, 0x2F3))
-		_vm->_dialogs->show(0x7D0F);
+		_vm->_dialogs->show(32015);
 	else if (_action.isAction(VERB_TAKE, 0x2F1))
-		_vm->_dialogs->show(0x7D10);
+		_vm->_dialogs->show(32016);
 	else if (_action.isAction(VERB_TAKE, 0x2F0))
-		_vm->_dialogs->show(0x7D11);
+		_vm->_dialogs->show(32017);
 	else
 		return;
 
@@ -3953,7 +3953,7 @@ void Scene351::step() {
 
 void Scene351::actions() {
 	if (_action._lookFlag)
-		_vm->_dialogs->show(0x8931);
+		_vm->_dialogs->show(35121);
 	else if (_action.isAction(0x2F9, 0x16C))
 		_scene->_nextSceneId = 322;
 	else if (_action.isAction(0x1AD, 0x2B3))
@@ -3991,30 +3991,30 @@ void Scene351::actions() {
 			}
 		}
 	} else if (_action.isAction(VERB_LOOK, 0x180))
-		_vm->_dialogs->show(0x8926);
+		_vm->_dialogs->show(35110);
 	else if (_action.isAction(VERB_LOOK, 0x23A))
-		_vm->_dialogs->show(0x8927);
+		_vm->_dialogs->show(35111);
 	else if (_action.isAction(VERB_LOOK, 0x1E6))
-		_vm->_dialogs->show(0x8928);
+		_vm->_dialogs->show(35112);
 	else if (_action.isAction(VERB_LOOK, 0x239)) {
 		if (_game._objects[0xF]._roomNumber == 351)
-			_vm->_dialogs->show(0x892A);
+			_vm->_dialogs->show(35114);
 		else
-			_vm->_dialogs->show(0x8929);
+			_vm->_dialogs->show(35113);
 	} else if (_action.isAction(VERB_LOOK, 0x2C7))
-		_vm->_dialogs->show(0x892B);
+		_vm->_dialogs->show(35115);
 	else if (_action.isAction(VERB_LOOK, 0x1E4))
-		_vm->_dialogs->show(0x892C);
+		_vm->_dialogs->show(35116);
 	else if (_action.isAction(VERB_LOOK, 0xD7))
-		_vm->_dialogs->show(0x892D);
+		_vm->_dialogs->show(35117);
 	else if (_action.isAction(VERB_LOOK, 0x16C))
-		_vm->_dialogs->show(0x892E);
+		_vm->_dialogs->show(35118);
 	else if (_action.isAction(VERB_LOOK, 0x59))
-		_vm->_dialogs->show(0x892F);
+		_vm->_dialogs->show(35119);
 	else if (_action.isAction(VERB_LOOK, 0x2B3))
-		_vm->_dialogs->show(0x8930);
+		_vm->_dialogs->show(35120);
 	else if (_action.isAction(VERB_LOOK, 0x1EB))
-		_vm->_dialogs->show(0x8932);
+		_vm->_dialogs->show(35122);
 	else
 		return;
 
@@ -4225,7 +4225,7 @@ void Scene352::preActions() {
 
 void Scene352::actions() {
 	if (_action._lookFlag) {
-		_vm->_dialogs->show(0x8999);
+		_vm->_dialogs->show(35225);
 		_action._inProgress = false;
 		return;
 	}
@@ -4509,53 +4509,53 @@ void Scene352::actions() {
 			break;
 		}
 	} else if (_action.isAction(VERB_LOOK, 0x1F3))
-		_vm->_dialogs->show(0x898A);
+		_vm->_dialogs->show(35210);
 	else if (_action.isAction(VERB_LOOK, 0xE2)) {
 		if (_game._storyMode == STORYMODE_NAUGHTY)
-			_vm->_dialogs->show(0x898B);
+			_vm->_dialogs->show(35211);
 		else
-			_vm->_dialogs->show(0x898C);
+			_vm->_dialogs->show(35212);
 	} else if (_action.isAction(VERB_LOOK, 0x1CC))
-		_vm->_dialogs->show(0x898D);
+		_vm->_dialogs->show(35213);
 	else if (_action.isAction(VERB_LOOK, 0x2CD))
-		_vm->_dialogs->show(0x898E);
+		_vm->_dialogs->show(35214);
 	else if (_action.isAction(VERB_LOOK, 0x165) && (_action._savedFields._mainObjectSource == 4))
-		_vm->_dialogs->show(0x898F);
+		_vm->_dialogs->show(35215);
 	else if (_action.isAction(VERB_LOOK, 0x11))
-		_vm->_dialogs->show(0x8990);
+		_vm->_dialogs->show(35216);
 	else if (_action.isAction(VERB_LOOK, 0x3B6) && (_action._savedFields._mainObjectSource == 4))
-		_vm->_dialogs->show(0x8991);
+		_vm->_dialogs->show(35217);
 	else if (_action.isAction(VERB_LOOK, 0x2DA))
-		_vm->_dialogs->show(0x8992);
+		_vm->_dialogs->show(35218);
 	else if (_action.isAction(VERB_LOOK, 0x51))
-		_vm->_dialogs->show(0x8993);
+		_vm->_dialogs->show(35219);
 	else if (_action.isAction(VERB_LOOK, 0x2CE))
-		_vm->_dialogs->show(0x8994);
+		_vm->_dialogs->show(35220);
 	else if (_action.isAction(VERB_LOOK, 0x1F8)) {
 		if (!_vaultOpenFl)
-			_vm->_dialogs->show(0x8995);
+			_vm->_dialogs->show(35221);
 	} else if (_action.isAction(VERB_LOOK, 0x2F4))
-		_vm->_dialogs->show(0x8996);
+		_vm->_dialogs->show(35222);
 	else if (_action.isAction(VERB_LOOK, 0x2F5))
-		_vm->_dialogs->show(0x8997);
+		_vm->_dialogs->show(35223);
 	else if (_action.isAction(VERB_LOOK, 0x2B3))
-		_vm->_dialogs->show(0x8998);
+		_vm->_dialogs->show(35224);
 	else if (_action.isAction(VERB_TAKE, 0x2F5))
-		_vm->_dialogs->show(0x899A);
+		_vm->_dialogs->show(35226);
 	else if (_action.isAction(VERB_LOOK, 0x1E4))
-		_vm->_dialogs->show(0x899D);
+		_vm->_dialogs->show(35229);
 	else if (_action.isAction(VERB_LOOK, 0x239))
-		_vm->_dialogs->show(0x899E);
+		_vm->_dialogs->show(35230);
 	else if (_action.isAction(VERB_LOOK, 0x70))
-		_vm->_dialogs->show(0x899F);
+		_vm->_dialogs->show(35231);
 	else if (_action.isAction(VERB_LOOK, 0x160))
-		_vm->_dialogs->show(0x89A0);
+		_vm->_dialogs->show(35232);
 	else if (_action.isAction(VERB_LOOK, 0x3B5))
-		_vm->_dialogs->show(0x89A1);
+		_vm->_dialogs->show(35233);
 	else if (_action.isAction(VERB_LOOK, 0x257))
-		_vm->_dialogs->show(0x89A2);
+		_vm->_dialogs->show(35234);
 	else if (_action.isAction(VERB_LOOK, 0x1F5))
-		_vm->_dialogs->show(0x89A3);
+		_vm->_dialogs->show(35235);
 	else
 		return;
 }
@@ -4597,27 +4597,27 @@ void Scene353::enter() {
 
 void Scene353::actions() {
 	if (_action._lookFlag)
-		_vm->_dialogs->show(0x89F3);
+		_vm->_dialogs->show(35315);
 	else if (_action.isAction(0x18B, 0x70))
 		_scene->_nextSceneId = 352;
 	else if (_action.isAction(0x1AD, 0x2B3))
 		_scene->_nextSceneId = 354;
 	else if (_action.isAction(VERB_LOOK, 0x23D))
-		_vm->_dialogs->show(0x89EE);
+		_vm->_dialogs->show(35310);
 	else if (_action.isAction(VERB_LOOK, 0x1FA) || _action.isAction(VERB_LOOK, 0x10C))
-		_vm->_dialogs->show(0x89EF);
+		_vm->_dialogs->show(35311);
 	else if (_action.isAction(VERB_LOOK, 0x23C))
-		_vm->_dialogs->show(0x89F0);
+		_vm->_dialogs->show(35312);
 	else if (_action.isAction(VERB_LOOK, 0x70))
-		_vm->_dialogs->show(0x89F1);
+		_vm->_dialogs->show(35313);
 	else if (_action.isAction(VERB_LOOK, 0x2B3))
-		_vm->_dialogs->show(0x89F2);
+		_vm->_dialogs->show(35314);
 	else if (_action.isAction(VERB_LOOK, 0x89))
-		_vm->_dialogs->show(0x89F4);
+		_vm->_dialogs->show(35316);
 	else if (_action.isAction(VERB_LOOK, 0x46))
-		_vm->_dialogs->show(0x89F5);
+		_vm->_dialogs->show(35317);
 	else if (_action.isAction(VERB_LOOK, 0x18D))
-		_vm->_dialogs->show(0x89F6);
+		_vm->_dialogs->show(35318);
 	else
 		return;
 
@@ -4655,7 +4655,7 @@ void Scene354::preActions() {
 
 void Scene354::actions() {
 	if (_action._lookFlag)
-		_vm->_dialogs->show(0x8A56);
+		_vm->_dialogs->show(35414);
 	else if (_action.isAction(0x1AD, 0x2B4)) {
 		_game._player.startWalking(Common::Point(208, 0), FACING_NORTHEAST);
 		_game._player._walkOffScreenSceneId = 353;
@@ -4666,25 +4666,25 @@ void Scene354::actions() {
 	else if (_action.isAction(0x1AD, 0x2B3))
 		_scene->_nextSceneId = 401;
 	else if (_action.isAction(VERB_LOOK, 0x2C6))
-		_vm->_dialogs->show(0x8A52);
+		_vm->_dialogs->show(35410);
 	else if (_action.isAction(VERB_LOOK, 0x1FD))
-		_vm->_dialogs->show(0x8A53);
+		_vm->_dialogs->show(35411);
 	else if (_action.isAction(VERB_LOOK, 0x2D0))
-		_vm->_dialogs->show(0x8A54);
+		_vm->_dialogs->show(35412);
 	else if (_action.isAction(VERB_LOOK, 0x206))
-		_vm->_dialogs->show(0x8A55);
+		_vm->_dialogs->show(35413);
 	else if (_action.isAction(VERB_LOOK, 0x2B4))
-		_vm->_dialogs->show(0x8A57);
+		_vm->_dialogs->show(35415);
 	else if (_action.isAction(VERB_LOOK, 0x2B3))
-		_vm->_dialogs->show(0x8A58);
+		_vm->_dialogs->show(35416);
 	else if (_action.isAction(VERB_LOOK, 0x2B9))
-		_vm->_dialogs->show(0x8A59);
+		_vm->_dialogs->show(35417);
 	else if (_action.isAction(VERB_LOOK, 0x2BA))
-		_vm->_dialogs->show(0x8A5A);
+		_vm->_dialogs->show(35418);
 	else if (_action.isAction(VERB_LOOK, 0x218))
-		_vm->_dialogs->show(0x8A5B);
+		_vm->_dialogs->show(35419);
 	else if (_action.isAction(VERB_LOOK, 0x239))
-		_vm->_dialogs->show(0x8A5C);
+		_vm->_dialogs->show(35420);
 	else
 		return;
 
@@ -4725,33 +4725,33 @@ void Scene357::preActions() {
 
 void Scene357::actions() {
 	if (_action._lookFlag)
-		_vm->_dialogs->show(0x8B83);
+		_vm->_dialogs->show(35715);
 	else if (_action.isAction(VERB_LOOK, 0x11))
-		_vm->_dialogs->show(0x8B7E);
+		_vm->_dialogs->show(35710);
 	else if (_action.isAction(0x2F7, 0x11))
-		_vm->_dialogs->show(0x8B7F);
+		_vm->_dialogs->show(35711);
 	else if (_action.isAction(VERB_LOOK, 0x1CB))
-		_vm->_dialogs->show(0x8B80);
+		_vm->_dialogs->show(35712);
 	else if (_action.isAction(VERB_LOOK, 0x216))
-		_vm->_dialogs->show(0x8B81);
+		_vm->_dialogs->show(35713);
 	else if (_action.isAction(VERB_LOOK, 0x21B))
-		_vm->_dialogs->show(0x8B82);
+		_vm->_dialogs->show(35714);
 	else if (_action.isAction(VERB_LOOK, 0x207))
-		_vm->_dialogs->show(0x8B84);
+		_vm->_dialogs->show(35716);
 	else if (_action.isAction(VERB_LOOK, 0xCD))
-		_vm->_dialogs->show(0x8B85);
+		_vm->_dialogs->show(35717);
 	else if (_action.isAction(VERB_LOOK, 0x23A))
-		_vm->_dialogs->show(0x8B86);
+		_vm->_dialogs->show(35718);
 	else if (_action.isAction(VERB_LOOK, 0x218))
-		_vm->_dialogs->show(0x8B87);
+		_vm->_dialogs->show(35719);
 	else if (_action.isAction(VERB_TAKE, 0x218))
-		_vm->_dialogs->show(0x8B88);
+		_vm->_dialogs->show(35720);
 	else if (_action.isAction(VERB_LOOK, 0x18D))
-		_vm->_dialogs->show(0x8B89);
+		_vm->_dialogs->show(35721);
 	else if (_action.isAction(VERB_LOOK, 0x2B9))
-		_vm->_dialogs->show(0x8B8A);
+		_vm->_dialogs->show(35722);
 	else if (_action.isAction(VERB_LOOK, 0x2BA))
-		_vm->_dialogs->show(0x8B8B);
+		_vm->_dialogs->show(35723);
 	else
 		return;
 
@@ -4789,21 +4789,21 @@ void Scene358::preActions() {
 
 void Scene358::actions() {
 	if (_action._lookFlag)
-		_vm->_dialogs->show(0x8BE7);
+		_vm->_dialogs->show(35815);
 	else if (_action.isAction(VERB_LOOK, 0x2BA))
-		_vm->_dialogs->show(0x8BE2);
+		_vm->_dialogs->show(35810);
 	else if (_action.isAction(VERB_LOOK, 0x2B9))
-		_vm->_dialogs->show(0x8BE3);
+		_vm->_dialogs->show(35811);
 	else if (_action.isAction(VERB_LOOK, 0x1CB))
-		_vm->_dialogs->show(0x8BE4);
+		_vm->_dialogs->show(35812);
 	else if (_action.isAction(VERB_LOOK, 0x216))
-		_vm->_dialogs->show(0x8BE5);
+		_vm->_dialogs->show(35813);
 	else if (_action.isAction(VERB_LOOK, 0x21B))
-		_vm->_dialogs->show(0x8BE6);
+		_vm->_dialogs->show(35814);
 	else if (_action.isAction(VERB_LOOK, 0x204) || _action.isAction(VERB_LOOK, 0x18D))
-		_vm->_dialogs->show(0x8BE8);
+		_vm->_dialogs->show(35816);
 	else if (_action.isAction(VERB_LOOK, 0x11))
-		_vm->_dialogs->show(0x8BE9);
+		_vm->_dialogs->show(35817);
 	else
 		return;
 
@@ -4856,16 +4856,16 @@ void Scene359::preActions() {
 void Scene359::actions() {
 	if (_action._lookFlag) {
 		if ((_game._difficulty != DIFFICULTY_HARD) && (_game._objects[OBJ_SECURITY_CARD]._roomNumber == 359))
-			_vm->_dialogs->show(0x8C4A);
+			_vm->_dialogs->show(35914);
 		else
-			_vm->_dialogs->show(0x8C4B);
+			_vm->_dialogs->show(35915);
 	} else if (_action.isAction(VERB_TAKE, 0x131)) {
 		if (_game._trigger || !_game._objects.isInInventory(OBJ_SECURITY_CARD)) {
 			switch (_game._trigger) {
 			case 0:
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
-				_vm->_dialogs->show(0x8C50);
+				_vm->_dialogs->show(35920);
 				if (_globals[kSexOfRex] == REX_MALE) {
 					_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 4, 2, 0, 0);
 					_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
@@ -4904,43 +4904,43 @@ void Scene359::actions() {
 			}
 		}
 	} else if (_action.isAction(VERB_LOOK, 0x23E))
-		_vm->_dialogs->show(0x8C46);
+		_vm->_dialogs->show(35910);
 	else if (_action.isAction(VERB_LOOK, 0x1CB))
-		_vm->_dialogs->show(0x8C47);
+		_vm->_dialogs->show(35911);
 	else if (_action.isAction(VERB_LOOK, 0x216))
-		_vm->_dialogs->show(0x8C48);
+		_vm->_dialogs->show(35912);
 	else if (_action.isAction(VERB_LOOK, 0x21B))
-		_vm->_dialogs->show(0x8C49);
+		_vm->_dialogs->show(35913);
 	else if (_action.isAction(VERB_LOOK, 0x2B9))
-		_vm->_dialogs->show(0x8C4C);
+		_vm->_dialogs->show(35916);
 	else if (_action.isAction(VERB_LOOK, 0x2BA))
-		_vm->_dialogs->show(0x8C4D);
+		_vm->_dialogs->show(35917);
 	else if (_action.isAction(VERB_LOOK, 0x215))
-		_vm->_dialogs->show(0x8C4E);
+		_vm->_dialogs->show(35918);
 	else if (_action.isAction(VERB_TAKE, 0x215))
-		_vm->_dialogs->show(0x8C4F);
+		_vm->_dialogs->show(35919);
 	else if (_action.isAction(VERB_LOOK, 0x131) && (_action._mainObjectSource == 4))
-		_vm->_dialogs->show(0x8C51);
+		_vm->_dialogs->show(35921);
 	else if (_action.isAction(VERB_LOOK, 0x2D2)) {
 		if ((_game._difficulty != DIFFICULTY_HARD) && (_game._objects[OBJ_SECURITY_CARD]._roomNumber == 359))
-			_vm->_dialogs->show(0x8C52);
+			_vm->_dialogs->show(35922);
 		else
-			_vm->_dialogs->show(0x8C53);
+			_vm->_dialogs->show(35923);
 	} else if (_action.isAction(VERB_LOOK, 0x23F))
-		_vm->_dialogs->show(0x8C54);
+		_vm->_dialogs->show(35924);
 	else if (_action.isAction(VERB_TAKE, 0x23F))
-		_vm->_dialogs->show(0x8C55);
+		_vm->_dialogs->show(35925);
 	else if (_action.isAction(VERB_LOOK, 0x23A))
-		_vm->_dialogs->show(0x8C56);
+		_vm->_dialogs->show(35926);
 	else if (_action.isAction(VERB_LOOK, 0x204))
-		_vm->_dialogs->show(0x8C57);
+		_vm->_dialogs->show(35927);
 	else if (_action.isAction(VERB_LOOK, 0x89)) {
 		if ((_game._difficulty != DIFFICULTY_HARD) && (_game._objects[OBJ_SECURITY_CARD]._roomNumber == 359))
-			_vm->_dialogs->show(0x8C58);
+			_vm->_dialogs->show(35928);
 		else
-			_vm->_dialogs->show(0x8C59);
+			_vm->_dialogs->show(35929);
 	} else if (_action.isAction(VERB_OPEN, 0x11) || _action.isAction(VERB_LOOK, 0x11))
-		_vm->_dialogs->show(0x8CB0);
+		_vm->_dialogs->show(36016);
 	else
 		return;
 
@@ -4985,23 +4985,23 @@ void Scene360::preActions() {
 
 void Scene360::actions() {
 	if (_action._lookFlag)
-		_vm->_dialogs->show(0x8CAF);
+		_vm->_dialogs->show(36015);
 	else if (_action.isAction(VERB_LOOK, 0x2BA))
-		_vm->_dialogs->show(0x8CAA);
+		_vm->_dialogs->show(36010);
 	else if (_action.isAction(VERB_LOOK, 0x2B9))
-		_vm->_dialogs->show(0x8CAB);
+		_vm->_dialogs->show(36011);
 	else if (_action.isAction(VERB_LOOK, 0x1CB))
-		_vm->_dialogs->show(0x8CAC);
+		_vm->_dialogs->show(36012);
 	else if (_action.isAction(VERB_LOOK, 0x216))
-		_vm->_dialogs->show(0x8CAD);
+		_vm->_dialogs->show(36013);
 	else if (_action.isAction(VERB_LOOK, 0x21B))
-		_vm->_dialogs->show(0x8CAE);
+		_vm->_dialogs->show(36014);
 	else if (_action.isAction(VERB_LOOK, 0x11))
-		_vm->_dialogs->show(0x8CB0);
+		_vm->_dialogs->show(36016);
 	else if (_action.isAction(VERB_LOOK, 0x204))
-		_vm->_dialogs->show(0x8CB1);
+		_vm->_dialogs->show(36017);
 	else if (_action.isAction(VERB_LOOK, 0x18D))
-		_vm->_dialogs->show(0x8CB2);
+		_vm->_dialogs->show(36018);
 	else
 		return;
 
@@ -5357,7 +5357,7 @@ void Scene361::preActions() {
 
 void Scene361::actions() {
 	if (_action._lookFlag)
-		_vm->_dialogs->show(0x8D17);
+		_vm->_dialogs->show(36119);
 	else if (_action.isAction(0x21F, 0x1E4)) {
 		_scene->_kernelMessages.reset();
 		_scene->_kernelMessages.addQuote(0xFC, 120, 0);
@@ -5367,25 +5367,25 @@ void Scene361::actions() {
 		else
 			handleRexAction();
 	} else if (_action.isAction(VERB_LOOK, 0x1E4))
-		_vm->_dialogs->show(0x8D0E);
+		_vm->_dialogs->show(36110);
 	else if (_action.isAction(VERB_LOOK, 0x18D))
-		_vm->_dialogs->show(0x8D0F);
+		_vm->_dialogs->show(36111);
 	else if (_action.isAction(VERB_LOOK, 0x220) || _action.isAction(0x155, 0x220))
-		_vm->_dialogs->show(0x8D10);
+		_vm->_dialogs->show(36112);
 	else if (_action.isAction(VERB_LOOK, 0x208) || _action.isAction(0x155, 0x208))
-		_vm->_dialogs->show(0x8D11);
+		_vm->_dialogs->show(36113);
 	else if (_action.isAction(VERB_TAKE, 0x208))
-		_vm->_dialogs->show(0x8D12);
+		_vm->_dialogs->show(36114);
 	else if (_action.isAction(VERB_LOOK, 0x2F8) || _action.isAction(0x155, 0x2F8))
-		_vm->_dialogs->show(0x8D13);
+		_vm->_dialogs->show(36115);
 	else if (_action.isAction(VERB_TAKE, 0x2F8))
-		_vm->_dialogs->show(0x8D14);
+		_vm->_dialogs->show(36116);
 	else if (_action.isAction(VERB_LOOK, 0x2BA))
-		_vm->_dialogs->show(0x8D15);
+		_vm->_dialogs->show(36117);
 	else if (_action.isAction(VERB_LOOK, 0x2B9))
-		_vm->_dialogs->show(0x8D16);
+		_vm->_dialogs->show(36118);
 	else if (_action.isAction(VERB_LOOK, 0x11))
-		_vm->_dialogs->show(0x8D18);
+		_vm->_dialogs->show(36120);
 	else
 		return;
 
@@ -5444,9 +5444,9 @@ void Scene387::actions() {
 	if (_action.isAction(0x2D5, 0x2D4))
 		_scene->_nextSceneId = 313;
 	else if (_action.isAction(0xD3, 0x2D3))
-		_vm->_dialogs->show(0x9736);
+		_vm->_dialogs->show(38710);
 	else if (_action.isAction(VERB_OPEN, 0x2D3))
-		_vm->_dialogs->show(0x9737);
+		_vm->_dialogs->show(38711);
 	else
 		return;
 
@@ -5505,11 +5505,11 @@ void Scene388::actions() {
 		}
 	} else if (_action.isAction(0xD3, 0x2D3)) {
 		if (_globals[kAfterHavoc])
-			_vm->_dialogs->show(0x979B);
+			_vm->_dialogs->show(38811);
 		else
-			_vm->_dialogs->show(0x979A);
+			_vm->_dialogs->show(38810);
 	} else if (_action.isAction(VERB_OPEN, 0x2D3))
-		_vm->_dialogs->show(0x979C);
+		_vm->_dialogs->show(38812);
 	else
 		return;
 
@@ -5579,16 +5579,16 @@ void Scene389::actions() {
 	} else if (_action.isAction(0xD3, 0x2D3)) {
 		if (_globals[kAfterHavoc]) {
 			if ((_game._difficulty != DIFFICULTY_HARD) && (_game._objects[OBJ_SECURITY_CARD]._roomNumber == 359))
-				_vm->_dialogs->show(0x97FF);
+				_vm->_dialogs->show(38911);
 			else
-				_vm->_dialogs->show(0x9800);
+				_vm->_dialogs->show(38912);
 		} else
-			_vm->_dialogs->show(0x97FE);
+			_vm->_dialogs->show(38910);
 	} else if (_action.isAction(VERB_OPEN, 0x2D3)) {
 		if (_globals[kAfterHavoc])
-			_vm->_dialogs->show(0x9802);
+			_vm->_dialogs->show(38914);
 		else
-			_vm->_dialogs->show(0x9801);
+			_vm->_dialogs->show(38913);
 	} else
 		return;
 
@@ -5620,9 +5620,9 @@ void Scene390::actions() {
 	if (_action.isAction(0x2D5, 0x2D4))
 		_scene->_nextSceneId = 313;
 	else if (_action.isAction(0xD3, 0x2D3))
-		_vm->_dialogs->show(0x9862);
+		_vm->_dialogs->show(39010);
 	else if (_action.isAction(VERB_OPEN, 0x2D3))
-		_vm->_dialogs->show(0x9863);
+		_vm->_dialogs->show(39011);
 	else
 		return;
 
@@ -5647,9 +5647,9 @@ void Scene391::actions() {
 		_scene->_nextSceneId = 313;
 	else if (_action.isAction(VERB_OPEN, 0x2D3)) {
 		if (_globals[kKickedIn391Grate])
-			_vm->_dialogs->show(0x98C9);
+			_vm->_dialogs->show(39113);
 		else {
-			_vm->_dialogs->show(0x98C8);
+			_vm->_dialogs->show(39112);
 			_globals[kKickedIn391Grate] = true;
 		}
 
@@ -5659,9 +5659,9 @@ void Scene391::actions() {
 			_scene->_nextSceneId = 311;
 	} else if (_action.isAction(0xD3, 0x2D3)) {
 		if (_globals[kAfterHavoc])
-			_vm->_dialogs->show(0x98C7);
+			_vm->_dialogs->show(39111);
 		else
-			_vm->_dialogs->show(0x98C6);
+			_vm->_dialogs->show(39110);
 	} else
 		return;
 
@@ -5687,16 +5687,16 @@ void Scene399::actions() {
 	else if (_action.isAction(0xD3, 0x2D3)) {
 		if (_globals[kAfterHavoc]) {
 			if ((_game._difficulty != DIFFICULTY_HARD) && (_game._objects[OBJ_SECURITY_CARD]._roomNumber == 359))
-				_vm->_dialogs->show(0x97FF);
+				_vm->_dialogs->show(38911);
 			else
-				_vm->_dialogs->show(0x9800);
+				_vm->_dialogs->show(38912);
 		} else
-			_vm->_dialogs->show(0x97FE);
+			_vm->_dialogs->show(38910);
 	} else if (_action.isAction(VERB_OPEN, 0x2D3)) {
 		if (_globals[kAfterHavoc])
-			_vm->_dialogs->show(0x9802);
+			_vm->_dialogs->show(38914);
 		else
-			_vm->_dialogs->show(0x9801);
+			_vm->_dialogs->show(38913);
 	} else
 		return;
 


Commit: 8619f856742a5ad1df3822d3881b5cddffb322c1
    https://github.com/scummvm/scummvm/commit/8619f856742a5ad1df3822d3881b5cddffb322c1
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T01:43:26+03:00

Commit Message:
MADS: Bugfixes and cleanup in scene 101

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 875c58c..025d551 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -272,7 +272,7 @@ void Scene101::preActions() {
 		_game._player._needToWalk = true;
 
 	if (_sittingFl) {
-		if (_action.isAction(VERB_LOOK) || _action.isAction(0x47) || _action.isAction(VERB_TALKTO) || _action.isAction(0x103) || _action.isAction(0x7D))
+		if (_action.isAction(VERB_LOOK) || _action.isObject(NOUN_CHAIR) || _action.isAction(VERB_TALKTO) || _action.isAction(VERB_PEER_THROUGH) || _action.isAction(VERB_EXAMINE))
 			_game._player._needToWalk = false;
 
 		if (_game._player._needToWalk) {
@@ -301,12 +301,12 @@ void Scene101::preActions() {
 		}
 	}
 
-	if (_panelOpened && !(_action.isAction(0x135) || _action.isAction(0x137))) {
+	if (_panelOpened && !(_action.isObject(NOUN_SHIELD_ACCESS_PANEL) || _action.isObject(NOUN_SHIELD_MODULATOR))) {
 		switch (_game._trigger) {
 		case 0:
 			if (_game._player._needToWalk) {
 				_scene->_sequences.remove(_globals._sequenceIndexes[13]);
-				_shieldSpriteIdx = _game._objects.isInRoom(0x18) ? 13 : 14;
+				_shieldSpriteIdx = _game._objects.isInRoom(OBJ_SHIELD_MODULATOR) ? 13 : 14;
 				_globals._sequenceIndexes[13] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[_shieldSpriteIdx], false, 6, 1, 0, 0);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 				_game._player._stepEnabled = false;
@@ -330,13 +330,13 @@ void Scene101::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_WALKTO, 0xCC)) {
+	if (_action.isAction(VERB_WALKTO, NOUN_LIFE_SUPPORT_SECTION)) {
 		_scene->_nextSceneId = 102;
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(0x13F, 0x47) || (_action.isAction(VERB_LOOK, 0x180) && !_sittingFl)) {
+	if (_action.isAction(VERB_SIT_IN, NOUN_CHAIR) || (_action.isAction(VERB_LOOK, NOUN_VIEW_SCREEN) && !_sittingFl)) {
 		if (!_sittingFl) {
 			switch (_game._trigger) {
 			case 0:
@@ -361,7 +361,7 @@ void Scene101::actions() {
 				_sittingFl = true;
 				_scene->_hotspots.activate(71, false);
 				_chairHotspotId = _scene->_dynamicHotspots.add(71, 0x13F, -1, Common::Rect(159, 84, 159 + 33, 84 + 36));
-				if (!_action.isAction(VERB_LOOK, 0x180)) {
+				if (!_action.isAction(VERB_LOOK, NOUN_VIEW_SCREEN)) {
 					_action._inProgress = false;
 					return;
 				}
@@ -375,7 +375,7 @@ void Scene101::actions() {
 		}
 	}
 
-	if (((_action.isAction(VERB_WALKTO, 0x135) || _action.isAction(VERB_OPEN, 0x135))) && !_panelOpened) {
+	if (((_action.isAction(VERB_WALKTO, NOUN_SHIELD_ACCESS_PANEL) || _action.isAction(VERB_OPEN, NOUN_SHIELD_ACCESS_PANEL))) && !_panelOpened) {
 		switch (_game._trigger) {
 		case 0:
 			_shieldSpriteIdx = _game._objects.isInRoom(0x18) ? 13 : 14;
@@ -399,19 +399,19 @@ void Scene101::actions() {
 		return;
 	}
 
-	if ((_action.isAction(VERB_TAKE, 0x137) || _action.isAction(VERB_PULL, 0x137)) && _game._objects.isInRoom(0x18)) {
+	if ((_action.isAction(VERB_TAKE, NOUN_SHIELD_MODULATOR) || _action.isAction(VERB_PULL, NOUN_SHIELD_MODULATOR)) && _game._objects.isInRoom(OBJ_SHIELD_MODULATOR)) {
 		_game._objects.addToInventory(OBJ_SHIELD_MODULATOR);
 		_scene->_sequences.remove(_globals._sequenceIndexes[13]);
 		_globals._sequenceIndexes[13] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[14], false, 6, 0, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], -2, -2);
-		_scene->_hotspots.activate(0x137, false);
+		_scene->_hotspots.activate(NOUN_SHIELD_MODULATOR, false);
 		_vm->_dialogs->showItem(OBJ_SHIELD_MODULATOR, 10120);
 		_vm->_sound->command(22);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x135) || (_action.isAction(VERB_LOOK, 0x137) && !_game._objects.isInInventory(OBJ_SHIELD_MODULATOR)) ) {
+	if (_action.isAction(VERB_LOOK, NOUN_SHIELD_ACCESS_PANEL) || (_action.isAction(VERB_LOOK, NOUN_SHIELD_MODULATOR) && !_game._objects.isInInventory(OBJ_SHIELD_MODULATOR)) ) {
 		if (_panelOpened) {
 			if (_game._objects.isInRoom(OBJ_SHIELD_MODULATOR))
 				_vm->_dialogs->show(10128);
@@ -475,7 +475,7 @@ void Scene101::actions() {
 		return;
 	}
 
-	if ((_action.isAction(VERB_LOOK) || _action.isAction(0x103)) && (_action.isAction(0x8E) || _action.isAction(0xF9))) {
+	if ((_action.isAction(VERB_LOOK) || _action.isAction(VERB_PEER_THROUGH)) && (_action.isAction(0x8E) || _action.isAction(0xF9))) {
 		_vm->_dialogs->show(10102);
 		_action._inProgress = false;
 		return;


Commit: 87418b66a007baf454d37d97857d13b186b6bb0a
    https://github.com/scummvm/scummvm/commit/87418b66a007baf454d37d97857d13b186b6bb0a
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T02:29:41+03:00

Commit Message:
MADS: Replace several verbs with their friendly names

Changed paths:
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes8.cpp



diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index ac98363..674e785 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -42,31 +42,44 @@ enum Verb {
 	VERB_CAST           = 0x03D,
 	VERB_CLIMB_DOWN     = 0x04E,
 	VERB_CLIMB_UP       = 0x050,
-	VERB_EAT			= 0x075,
-	VERB_EXAMINE		= 0x07D,
-	VERB_HOSE_DOWN		= 0x0A6,
-	VERB_IGNITE			= 0x0B4,
-	VERB_INFLATE		= 0x0B5,
-	VERB_INSERT			= 0x0B6,
-	VERB_INSPECT		= 0x0B7,
-	VERB_HURL			= 0x0A9,
-	VERB_LOOK_AT		= 0x0D1,
-	VERB_LOOK_IN		= 0x0D2,
-	VERB_LOOK_THROUGH	= 0x0D3,
-	VERB_PEER_THROUGH	= 0x103,
+	VERB_DIVE_INTO      = 0x06D,
+	VERB_EAT            = 0x075,
+	VERB_EXAMINE        = 0x07D,
+	VERB_HOSE_DOWN      = 0x0A6,
+	VERB_IGNITE         = 0x0B4,
+	VERB_INFLATE        = 0x0B5,
+	VERB_INSERT         = 0x0B6,
+	VERB_INSPECT        = 0x0B7,
+	VERB_HURL           = 0x0A9,
+	VERB_LOOK_AT        = 0x0D1,
+	VERB_LOOK_IN        = 0x0D2,
+	VERB_LOOK_THROUGH   = 0x0D3,
+	VERB_PEER_THROUGH   = 0x103,
+	VERB_PLAY           = 0x112,
 	VERB_PRESS          = 0x11A,
-	VERB_READ			= 0x11F,
+	VERB_READ           = 0x11F,
 	VERB_SHOOT          = 0x13A,
 	VERB_SIT_IN         = 0x13F,
-	VERB_SMELL			= 0x147,
+	VERB_SMELL          = 0x147,
+	VERB_STARE_AT       = 0x155,
+	VERB_SWIM_INTO      = 0x15A,
+	VERB_SWIM_THROUGH   = 0x15B,
+	VERB_SWIM_TO        = 0x15C,
+	VERB_SWIM_TOWARDS   = 0x15D,
+	VERB_SWIM_UNDER     = 0x15E,
 	VERB_WALK_INSIDE    = 0x188,
 	VERB_WALK_THROUGH   = 0x18B,
 	VERB_WALK_TOWARDS   = 0x18C,
 	VERB_WALK_DOWN      = 0x1AD,
 	VERB_EXIT_FROM      = 0x1CE,
+	VERB_EXIT           = 0x298,
 	VERB_CLIMB_INTO     = 0x2F7,
 	VERB_STEP_INTO      = 0x2F9,
-	VERB_WALK_ALONG     = 0x312
+	VERB_SIT_ON         = 0x30B,
+	VERB_WALK_ALONG     = 0x312,
+	VERB_ENTER          = 0x3B8,
+	VERB_INSTALL        = 0x474,
+	VERB_REMOVE         = 0x476
 };
 
 enum Noun {
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 025d551..c2765ea 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -481,7 +481,7 @@ void Scene101::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0xA8) || _action.isAction(VERB_LOOK, 0xF8) || _action.isAction(0x7D, 0xA8) || _action.isAction(0x7D, 0xF8)) {
+	if (_action.isAction(VERB_LOOK, 0xA8) || _action.isAction(VERB_LOOK, 0xF8) || _action.isAction(VERB_EXAMINE, 0xA8) || _action.isAction(VERB_EXAMINE, 0xF8)) {
 		_vm->_dialogs->show(10103);
 		_action._inProgress = false;
 		return;
@@ -493,7 +493,7 @@ void Scene101::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0xE1) || _action.isAction(0xD2, 0xE1)) {
+	if (_action.isAction(VERB_LOOK, 0xE1) || _action.isAction(VERB_LOOK_IN, 0xE1)) {
 		_vm->_dialogs->show(10105);
 		_action._inProgress = false;
 		return;
@@ -595,7 +595,7 @@ void Scene101::actions() {
 		return;
 	}
 
-	if ((_action.isAction(VERB_LOOK) || _action.isAction(0x112)) && _action.isAction(0x17E)) {
+	if ((_action.isAction(VERB_LOOK) || _action.isAction(VERB_PLAY)) && _action.isAction(0x17E)) {
 		_vm->_dialogs->show(10124);
 		_action._inProgress = false;
 		return;
@@ -875,7 +875,7 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(0x18B, 0x6E)) {
+	if (_action.isAction(VERB_WALK_THROUGH, 0x6E)) {
 		switch (_game._trigger) {
 		case 0:
 			_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 1, 0, 0);
@@ -922,13 +922,13 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(0x155, 0x46) || _action.isAction(VERB_LOOK, 0x46)) {
+	if (_action.isAction(VERB_STARE_AT, 0x46) || _action.isAction(VERB_LOOK, 0x46)) {
 		_vm->_dialogs->show(10203);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(0x155, 0xFD) || _action.isAction(VERB_LOOK, 0xFD)) {
+	if (_action.isAction(VERB_STARE_AT, 0xFD) || _action.isAction(VERB_LOOK, 0xFD)) {
 		_vm->_dialogs->show(10202);
 		_action._inProgress = false;
 		return;
@@ -970,9 +970,9 @@ void Scene102::actions() {
 		return;
 	}
 
-	if ((_action.isObject(0xC7) || _action.isObject(0xA3)) && (_action.isAction(VERB_LOOK) || _action.isAction(0x50) || _action.isAction(0x4F))) {
+	if ((_action.isObject(0xC7) || _action.isObject(0xA3)) && (_action.isAction(VERB_LOOK) || _action.isAction(VERB_CLIMB_UP) || _action.isAction(0x4F))) {
 		if (_game._objects.isInInventory(OBJ_REBREATHER)) {
-			if (!_action.isAction(0x50) && !_action.isAction(0x4F)) {
+			if (!_action.isAction(VERB_CLIMB_UP) && !_action.isAction(0x4F)) {
 				_vm->_dialogs->show(10231);
 				_action._inProgress = false;
 				return;
@@ -984,7 +984,7 @@ void Scene102::actions() {
 		}
 	}
 
-	if ((_action.isObject(0xC7) || _action.isObject(0xA3)) && (_action.isAction(0x50) || _action.isAction(0x4F)) ) {
+	if ((_action.isObject(0xC7) || _action.isObject(0xA3)) && (_action.isAction(VERB_CLIMB_UP) || _action.isAction(0x4F)) ) {
 		switch (_game._trigger) {
 		case 0:
 			_scene->loadAnimation(formAnimName('A', -1), 1);
@@ -1025,7 +1025,7 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x197) || _action.isAction(0xD3, 0x197)) {
+	if (_action.isAction(VERB_LOOK, 0x197) || _action.isAction(VERB_LOOK_THROUGH, 0x197)) {
 		_vm->_dialogs->show(10227);
 		_action._inProgress = false;
 		return;
@@ -1056,14 +1056,14 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x47) || (_action.isAction(0x13F, 0x47) && !_chairDescrFl)) {
+	if (_action.isAction(VERB_LOOK, 0x47) || (_action.isAction(VERB_SIT_IN, 0x47) && !_chairDescrFl)) {
 		_chairDescrFl = true;
 		_vm->_dialogs->show(10210);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(0x13F, 0x47)) {
+	if (_action.isAction(VERB_SIT_IN, 0x47)) {
 		_vm->_dialogs->show(10211);
 		_action._inProgress = false;
 		return;
@@ -1716,10 +1716,10 @@ void Scene104::step() {
 }
 
 void Scene104::preActions() {
-	if (_action.isAction(0x15D, 0x74))
+	if (_action.isAction(VERB_SWIM_TOWARDS, 0x74))
 		_game._player._walkOffScreenSceneId = 105;
 
-	if (_action.isAction(0x15D, 0x75))
+	if (_action.isAction(VERB_SWIM_TOWARDS, 0x75))
 		_game._player._walkOffScreenSceneId = 106;
 }
 
@@ -1843,10 +1843,10 @@ void Scene105::step() {
 }
 
 void Scene105::preActions() {
-	if (_action.isAction(0x15D, 0x195))
+	if (_action.isAction(VERB_SWIM_TOWARDS, 0x195))
 		_game._player._walkOffScreenSceneId = 104;
 
-	if (_action.isAction(0x15D, 0xF5))
+	if (_action.isAction(VERB_SWIM_TOWARDS, 0xF5))
 		_game._player._walkOffScreenSceneId = 107;
 
 	if (_action.isAction(0xE0) && (_action.isAction(VERB_TALKTO) || _action.isAction(VERB_LOOK)))
@@ -2052,20 +2052,20 @@ void Scene106::step() {
 }
 
 void Scene106::preActions() {
-	if (_action.isAction(0x15D, 0x12E) || _action.isAction(0x15D, 0x130)) {
+	if (_action.isAction(VERB_SWIM_TOWARDS, 0x12E) || _action.isAction(VERB_SWIM_TOWARDS, 0x130)) {
 		_game._player._stepEnabled = false;
 		_scene->_sprites[_game._player._spritesStart + 1]->_charInfo->_velocity = 24;
 		_game._player._walkOffScreenSceneId = 104;
 	}
 
-	if (_action.isAction(0x15D, 0xF3))
+	if (_action.isAction(VERB_SWIM_TOWARDS, 0xF3))
 		_game._player._walkOffScreenSceneId = 107;
 }
 
 void Scene106::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(10614);
-	else if (_action.isAction(0x15C, 0xD9)) {
+	else if (_action.isAction(VERB_SWIM_TO, 0xD9)) {
 		_game._player._stepEnabled = false;
 		_game._player._prepareWalkPos = Common::Point(95, 72);
 		_game._player._prepareWalkFacing = FACING_WEST;
@@ -2073,7 +2073,7 @@ void Scene106::actions() {
 		_game._player._readyToWalk = true;
 		_game._player._frameNumber = 9;
 		_backToShipFl = true;
-	} else if (_action.isAction(VERB_LOOK, 0x13) || _action.isAction(0xD1, 0x13))
+	} else if (_action.isAction(VERB_LOOK, 0x13) || _action.isAction(VERB_LOOK_AT, 0x13))
 		_vm->_dialogs->show(10601);
 	else if (_action.isAction(VERB_TAKE, 0x13))
 		_vm->_dialogs->show(10602);
@@ -2083,11 +2083,11 @@ void Scene106::actions() {
 		_vm->_dialogs->show(10604);
 	else if (_action.isAction(VERB_LOOK, 0xF3))
 		_vm->_dialogs->show(10605);
-	else if (_action.isAction(VERB_LOOK, 0x109) || _action.isAction(0xD1, 0x109))
+	else if (_action.isAction(VERB_LOOK, 0x109) || _action.isAction(VERB_LOOK_AT, 0x109))
 		_vm->_dialogs->show(10606);
 	else if (_action.isAction(0x109) && (_action.isAction(VERB_PUSH) || _action.isAction(VERB_PULL) || _action.isAction(VERB_TAKE)))
 		_vm->_dialogs->show(10607);
-	else if (_action.isAction(VERB_LOOK, 0x139) || _action.isAction(0xD1, 0x139))
+	else if (_action.isAction(VERB_LOOK, 0x139) || _action.isAction(VERB_LOOK_AT, 0x139))
 		_vm->_dialogs->show(10608);
 	else if (_action.isAction(VERB_LOOK, 0xD9))
 		_vm->_dialogs->show(10609);
@@ -2178,10 +2178,10 @@ void Scene107::step() {
 }
 
 void Scene107::preActions() {
-	if (_action.isAction(0x15D, 0xF6))
+	if (_action.isAction(VERB_SWIM_TOWARDS, 0xF6))
 		_game._player._walkOffScreenSceneId = 106;
 
-	if (_action.isAction(0x15D, 0xF5))
+	if (_action.isAction(VERB_SWIM_TOWARDS, 0xF5))
 		_game._player._walkOffScreenSceneId = 108;
 }
 
@@ -2199,7 +2199,7 @@ void Scene107::actions() {
 			_globals[kFishIn107] = false;
 			_vm->_dialogs->showItem(OBJ_DEAD_FISH, 802);
 		}
-	} else if (_action.isAction(0x15D, 0xEE))
+	} else if (_action.isAction(VERB_SWIM_TOWARDS, 0xEE))
 		_scene->_nextSceneId = 105;
 	else if (_action.isAction(VERB_LOOK, 0xEE))
 		_vm->_dialogs->show(10701);
@@ -2273,7 +2273,7 @@ void Scene108::enter() {
 }
 
 void Scene108::preActions() {
-	if (_action.isAction(0x15E, 0xFB))
+	if (_action.isAction(VERB_SWIM_UNDER, 0xFB))
 		_game._player._walkOffScreenSceneId = 109;
 }
 
@@ -2291,7 +2291,7 @@ void Scene108::actions() {
 			_globals[kFishIn108] = false;
 			_vm->_dialogs->showItem(OBJ_DEAD_FISH, 10808);
 		}
-	} else if (_action.isAction(0x15D, 0xF4))
+	} else if (_action.isAction(VERB_SWIM_TOWARDS, 0xF4))
 		_scene->_nextSceneId = 107;
 	else if (_action.isAction(VERB_LOOK, 0x4D))
 		_vm->_dialogs->show(10801);
@@ -2485,7 +2485,7 @@ void Scene109::step() {
 }
 
 void Scene109::preActions() {
-	if (_action.isAction(0x15E, 0xFC))
+	if (_action.isAction(VERB_SWIM_UNDER, 0xFC))
 		_game._player._walkOffScreenSceneId = 108;
 
 	if ((_action.isAction(VERB_THROW) || _action.isAction(VERB_GIVE) || _action.isAction(VERB_PUT))
@@ -2500,7 +2500,7 @@ void Scene109::preActions() {
 		}
 	}
 
-	if ((_action.isAction(0x15A, 0x178) || _action.isAction(0x15C, 0x146))
+	if ((_action.isAction(VERB_SWIM_INTO, 0x178) || _action.isAction(VERB_SWIM_TO, 0x146))
 	&& (!_globals[kHoovicAlive] || _globals[kHoovicSated]) && (_action.isObject(0x178)))
 		_game._player._walkOffScreenSceneId = 110;
 
@@ -2789,7 +2789,7 @@ void Scene110::step() {
 }
 
 void Scene110::preActions() {
-	if (_action.isAction(0x15B, 0x41))
+	if (_action.isAction(VERB_SWIM_THROUGH, 0x41))
 		_game._player._walkOffScreenSceneId = 109;
 
 	if (_crabsFl) {
@@ -2817,7 +2817,7 @@ void Scene110::preActions() {
 }
 
 void Scene110::actions() {
-	if (_action.isAction(0x15B, 0x178)) {
+	if (_action.isAction(VERB_SWIM_THROUGH, 0x178)) {
 		switch (_game._trigger) {
 		case 0:
 			_scene->loadAnimation(Resources::formatName(110, 'T', 0, EXT_AA, ""), 1);
@@ -2833,7 +2833,7 @@ void Scene110::actions() {
 		}
 	} else if ((_action._lookFlag) || _action.isAction(VERB_LOOK, 0x3F))
 		_vm->_dialogs->show(11001);
-	else if (_action.isAction(VERB_LOOK, 0x40) || _action.isAction(0xD1, 0x40))
+	else if (_action.isAction(VERB_LOOK, 0x40) || _action.isAction(VERB_LOOK_AT, 0x40))
 		_vm->_dialogs->show(11002);
 	else if (_action.isAction(VERB_LOOK, 0x129))
 		_vm->_dialogs->show(11003);
@@ -2964,12 +2964,12 @@ void Scene111::step() {
 }
 
 void Scene111::preActions() {
-	if (_action.isAction(0x18B, 0x41))
+	if (_action.isAction(VERB_WALK_THROUGH, 0x41))
 		_game._player._walkOffScreenSceneId = 212;
 }
 
 void Scene111::actions() {
-	if (_action.isAction(0x6D, 0x116) && _game._objects.isInInventory(OBJ_REBREATHER)) {
+	if (_action.isAction(VERB_DIVE_INTO, 0x116) && _game._objects.isInInventory(OBJ_REBREATHER)) {
 		switch (_game._trigger) {
 		case 0:
 			_scene->loadAnimation(Resources::formatName(111, 'A', 1, EXT_AA, ""), 1);
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 47582cd..cfb261c 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -712,7 +712,7 @@ void Scene202::preActions() {
 	if (player._readyToWalk)
 		_scene->_kernelMessages.reset();
 
-	if (!_ladderTopFl && (_action.isAction(0x4E, NOUN_LADDER) || !player._readyToWalk)) {
+	if (!_ladderTopFl && (_action.isAction(VERB_CLIMB_DOWN, NOUN_LADDER) || !player._readyToWalk)) {
 		if (_game._trigger == 0) {
 			_vm->_sound->command(29);
 			player._readyToWalk = false;
@@ -930,7 +930,7 @@ void Scene202::actions() {
 				return;
 			}
 		}
-	} else if (_action.isAction(0x188, 0xAA)) {
+	} else if (_action.isAction(VERB_WALK_INSIDE, 0xAA)) {
 		setRandomKernelMessage();
 	} else if (_action.isAction(VERB_LOOK, NOUN_ROCKS)) {
 		_vm->_dialogs->show(20202);
@@ -1342,7 +1342,7 @@ void Scene205::actions() {
 			_scene->_reloadSceneFlag = true;
 		}
 	} else {
-		if (_action.isAction(0x1AD, 0x1C7))
+		if (_action.isAction(VERB_WALK_DOWN, 0x1C7))
 			_scene->_nextSceneId = 210;
 
 		if (_action.isAction(VERB_WALKTO, 0x86) || _action.isAction(VERB_WALKTO, 0x1C2)) {
@@ -4464,7 +4464,7 @@ void Scene210::actions() {
 		_vm->_dialogs->show(21009);
 	} else if (_action.isAction(VERB_LOOK, 0x1DC)) {
 		_vm->_dialogs->show(21010);
-	} else if (_action.isAction(0x13A, 0x1DC) || _action.isAction(0xA6, 0x1DC)) {
+	} else if (_action.isAction(VERB_SHOOT, 0x1DC) || _action.isAction(VERB_HOSE_DOWN, 0x1DC)) {
 		_vm->_dialogs->show(21011);
 	} else if (_action.isAction(VERB_LOOK, 0x1BF)) {
 		_vm->_dialogs->show(21012);
@@ -5086,7 +5086,7 @@ void Scene214::actions() {
 		_vm->_dialogs->show(21415);
 	else if (_action.isAction(VERB_GIVE, 0x17A, 0x1C3))
 		_vm->_dialogs->show(21416);
-	else if (_action.isAction(0x13A, 0x29, 0x1C3) || _action.isAction(0xA6, 0x29, 0x1C3))
+	else if (_action.isAction(VERB_SHOOT, 0x29, 0x1C3) || _action.isAction(VERB_HOSE_DOWN, 0x29, 0x1C3))
 		_vm->_dialogs->show(21417);
 	else if (_action.isAction(VERB_LOOK, 0x473))
 		_vm->_dialogs->show(21418);
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 5337c99..d0dd477 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -959,7 +959,7 @@ void Scene307::actions() {
 		default:
 			break;
 		}
-	}else if (_action.isAction(0x2F7, 0x11)) {
+	}else if (_action.isAction(VERB_CLIMB_INTO, 0x11)) {
 		if (_grateOpenedFl) {
 			switch (_game._trigger) {
 			case 0:
@@ -1698,7 +1698,7 @@ void Scene311::actions() {
 		_scene->_kernelMessages.addQuote(0xFA, 120, 0);
 	} else if (_action.isAction(0x21F, 0x1E4))
 		_scene->_nextSceneId = 320;
-	else if (_action.isAction(0x2F7, 0x11)) {
+	else if (_action.isAction(VERB_CLIMB_INTO, 0x11)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1794,13 +1794,13 @@ void Scene311::actions() {
 		_vm->_dialogs->show(31110);
 	else if (_action.isAction(VERB_LOOK, 0x18D))
 		_vm->_dialogs->show(31111);
-	else if (_action.isAction(VERB_LOOK, 0x220) || _action.isAction(0x155, 0x220))
+	else if (_action.isAction(VERB_LOOK, 0x220) || _action.isAction(VERB_STARE_AT, 0x220))
 		_vm->_dialogs->show(31112);
-	else if (_action.isAction(VERB_LOOK, 0x208) || _action.isAction(0x155, 0x208))
+	else if (_action.isAction(VERB_LOOK, 0x208) || _action.isAction(VERB_STARE_AT, 0x208))
 		_vm->_dialogs->show(31113);
 	else if (_action.isAction(VERB_TAKE, 0x208))
 		_vm->_dialogs->show(31114);
-	else if (_action.isAction(VERB_LOOK, 0xCD) || _action.isAction(0x155, 0xCD))
+	else if (_action.isAction(VERB_LOOK, 0xCD) || _action.isAction(VERB_STARE_AT, 0xCD))
 		_vm->_dialogs->show(31115);
 	else if (_action.isAction(VERB_TAKE, 0xCD))
 		_vm->_dialogs->show(31116);
@@ -2249,7 +2249,7 @@ void Scene316::step() {
 }
 
 void Scene316::preActions() {
-	if (_action.isAction(0x1AD, 0x2B9)) {
+	if (_action.isAction(VERB_WALK_DOWN, 0x2B9)) {
 		if (_globals[kAfterHavoc])
 			_game._player._walkOffScreenSceneId = 354;
 		else
@@ -2258,7 +2258,7 @@ void Scene316::preActions() {
 }
 
 void Scene316::actions() {
-	if (_action.isAction(0x2F7, 0x11)) {
+	if (_action.isAction(VERB_CLIMB_INTO, 0x11)) {
 		if (_globals[kSexOfRex] == REX_FEMALE)
 			handleRoxInGrate();
 		else
@@ -2740,7 +2740,7 @@ void Scene318::preActions() {
 	if (_game._player._needToWalk)
 		_game._player._needToWalk = _game._player._visible;
 
-	if (_action.isAction(0x1AD, 0x2BA))
+	if (_action.isAction(VERB_WALK_DOWN, 0x2BA))
 		_game._player._walkOffScreenSceneId = 357;
 }
 
@@ -2832,7 +2832,7 @@ void Scene318::actions() {
 	}
 
 	if (_game._player._visible) {
-		if (_action.isAction(0x1AD, 0x2B3)) {
+		if (_action.isAction(VERB_WALK_DOWN, 0x2B3)) {
 			_scene->_nextSceneId = 407;
 			_action._inProgress = false;
 			return;
@@ -3641,7 +3641,7 @@ void Scene320::step() {
 void Scene320::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(32011);
-	else if ((_action.isAction(0x11A) || _action.isAction(VERB_PUSH)) &&
+	else if ((_action.isAction(VERB_PRESS) || _action.isAction(VERB_PUSH)) &&
 		(_action.isAction(0x2E8) || _action.isAction(0x2E9) || _action.isAction(0x2EA) || _action.isAction(0x2EB) ||
 		 _action.isAction(0x2DE) || _action.isAction(0x2DD) || _action.isAction(0x2E0) || _action.isAction(0x2E1) ||
 		 _action.isAction(0x2E2) || _action.isAction(0x2E3) || _action.isAction(0x2E4) || _action.isAction(0x2E5) ||
@@ -3735,7 +3735,7 @@ void Scene320::actions() {
 		_vm->_dialogs->show(32012);
 	else if (_action.isAction(VERB_TAKE, 0x2F2))
 		_vm->_dialogs->show(32013);
-	else if (_action.isAction(VERB_TAKE, 0x2EE) || _action.isAction(0x75, 0x2EE))
+	else if (_action.isAction(VERB_TAKE, 0x2EE) || _action.isAction(VERB_EAT, 0x2EE))
 		_vm->_dialogs->show(32014);
 	else if (_action.isAction(VERB_TAKE, 0x2F3))
 		_vm->_dialogs->show(32015);
@@ -3838,7 +3838,7 @@ void Scene322::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x181) || _action.isAction(0x103, 0x181))
+	if (_action.isAction(VERB_LOOK, 0x181) || _action.isAction(VERB_PEER_THROUGH, 0x181))
 		_vm->_dialogs->show(32210);
 	else if (_action.isAction(VERB_LOOK, 0xC4))
 		_vm->_dialogs->show(32211);
@@ -3954,9 +3954,9 @@ void Scene351::step() {
 void Scene351::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(35121);
-	else if (_action.isAction(0x2F9, 0x16C))
+	else if (_action.isAction(VERB_STEP_INTO, 0x16C))
 		_scene->_nextSceneId = 322;
-	else if (_action.isAction(0x1AD, 0x2B3))
+	else if (_action.isAction(VERB_WALK_DOWN, 0x2B3))
 		_scene->_nextSceneId = 352;
 	else if (_action.isAction(VERB_TAKE, 0x5C)) {
 		if (_game._trigger || !_game._objects.isInInventory(0xF)) {
@@ -4217,7 +4217,7 @@ void Scene352::preActions() {
 			_game._player.walk(Common::Point(271, 111), FACING_NORTHEAST);
 	}
 
-	if (_action.isAction(0x18B, 0x70) || _action.isAction(0x1AD, 0x2B3) || _action.isAction(VERB_PUT, 0x3B6, 0x89)) {
+	if (_action.isAction(VERB_WALK_THROUGH, 0x70) || _action.isAction(VERB_WALK_DOWN, 0x2B3) || _action.isAction(VERB_PUT, 0x3B6, 0x89)) {
 		if (_game._objects.isInInventory(OBJ_GUARDS_ARM))
 			_game._player.walk(Common::Point(230, 117), FACING_NORTHWEST);
 	}
@@ -4288,15 +4288,15 @@ void Scene352::actions() {
 	bool exit_corridor = false;
 	bool exit_doorway = false;
 
-	if (_action.isAction(0x1AD, 0x2B3)) {
+	if (_action.isAction(VERB_WALK_DOWN, 0x2B3)) {
 		exit_corridor = true;
 	}
 
-	if (_action.isAction(0x18B, 0x70)) {
+	if (_action.isAction(VERB_WALK_THROUGH, 0x70)) {
 		exit_doorway = true;
 	}
 
-	if (_action.isAction(0x1AD, 0x2B3) || _action.isAction(0x18B, 0x70) || _action.isAction(VERB_PUT, 0x3B6, 0x89)) {
+	if (_action.isAction(VERB_WALK_DOWN, 0x2B3) || _action.isAction(VERB_WALK_THROUGH, 0x70) || _action.isAction(VERB_PUT, 0x3B6, 0x89)) {
 		if (_mustPutArmDownFl)
 			putArmDown(exit_corridor, exit_doorway);
 		else if (exit_corridor)
@@ -4598,9 +4598,9 @@ void Scene353::enter() {
 void Scene353::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(35315);
-	else if (_action.isAction(0x18B, 0x70))
+	else if (_action.isAction(VERB_WALK_THROUGH, 0x70))
 		_scene->_nextSceneId = 352;
-	else if (_action.isAction(0x1AD, 0x2B3))
+	else if (_action.isAction(VERB_WALK_DOWN, 0x2B3))
 		_scene->_nextSceneId = 354;
 	else if (_action.isAction(VERB_LOOK, 0x23D))
 		_vm->_dialogs->show(35310);
@@ -4649,21 +4649,21 @@ void Scene354::enter() {
 }
 
 void Scene354::preActions() {
-	if (_action.isAction(0x1AD, 0x2B3))
+	if (_action.isAction(VERB_WALK_DOWN, 0x2B3))
 		_game._player._walkOffScreenSceneId = 401;
 }
 
 void Scene354::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(35414);
-	else if (_action.isAction(0x1AD, 0x2B4)) {
+	else if (_action.isAction(VERB_WALK_DOWN, 0x2B4)) {
 		_game._player.startWalking(Common::Point(208, 0), FACING_NORTHEAST);
 		_game._player._walkOffScreenSceneId = 353;
-	} else if (_action.isAction(0x1AD, 0x2B9))
+	} else if (_action.isAction(VERB_WALK_DOWN, 0x2B9))
 		_scene->_nextSceneId = 361;
-	else if (_action.isAction(0x1AD, 0x2BA))
+	else if (_action.isAction(VERB_WALK_DOWN, 0x2BA))
 		_scene->_nextSceneId = 316;
-	else if (_action.isAction(0x1AD, 0x2B3))
+	else if (_action.isAction(VERB_WALK_DOWN, 0x2B3))
 		_scene->_nextSceneId = 401;
 	else if (_action.isAction(VERB_LOOK, 0x2C6))
 		_vm->_dialogs->show(35410);
@@ -4716,10 +4716,10 @@ void Scene357::enter() {
 }
 
 void Scene357::preActions() {
-	if (_action.isAction(0x1AD, 0x2B9))
+	if (_action.isAction(VERB_WALK_DOWN, 0x2B9))
 		_game._player._walkOffScreenSceneId = 318;
 
-	if (_action.isAction(0x1AD, 0x2BA))
+	if (_action.isAction(VERB_WALK_DOWN, 0x2BA))
 		_game._player._walkOffScreenSceneId = 358;
 }
 
@@ -4728,7 +4728,7 @@ void Scene357::actions() {
 		_vm->_dialogs->show(35715);
 	else if (_action.isAction(VERB_LOOK, 0x11))
 		_vm->_dialogs->show(35710);
-	else if (_action.isAction(0x2F7, 0x11))
+	else if (_action.isAction(VERB_CLIMB_INTO, 0x11))
 		_vm->_dialogs->show(35711);
 	else if (_action.isAction(VERB_LOOK, 0x1CB))
 		_vm->_dialogs->show(35712);
@@ -4780,10 +4780,10 @@ void Scene358::enter() {
 }
 
 void Scene358::preActions() {
-	if (_action.isAction(0x1AD, 0x2B9))
+	if (_action.isAction(VERB_WALK_DOWN, 0x2B9))
 		_game._player._walkOffScreenSceneId = 357;
 
-	if (_action.isAction(0x1AD, 0x2BA))
+	if (_action.isAction(VERB_WALK_DOWN, 0x2BA))
 		_game._player._walkOffScreenSceneId = 359;
 }
 
@@ -4846,10 +4846,10 @@ void Scene359::enter() {
 }
 
 void Scene359::preActions() {
-	if (_action.isAction(0x1AD, 0x2B9))
+	if (_action.isAction(VERB_WALK_DOWN, 0x2B9))
 		_game._player._walkOffScreenSceneId = 358;
 
-	if (_action.isAction(0x1AD, 0x2BA))
+	if (_action.isAction(VERB_WALK_DOWN, 0x2BA))
 		_game._player._walkOffScreenSceneId = 360;
 }
 
@@ -4976,10 +4976,10 @@ void Scene360::enter() {
 }
 
 void Scene360::preActions() {
-	if (_action.isAction(0x1AD, 0x2B9))
+	if (_action.isAction(VERB_WALK_DOWN, 0x2B9))
 		_game._player._walkOffScreenSceneId = 359;
 
-	if (_action.isAction(0x1AD, 0x2BA))
+	if (_action.isAction(VERB_WALK_DOWN, 0x2BA))
 		_game._player._walkOffScreenSceneId = 361;
 }
 
@@ -5348,10 +5348,10 @@ void Scene361::step() {
 }
 
 void Scene361::preActions() {
-	if (_action.isAction(0x1AD, 0x2B9))
+	if (_action.isAction(VERB_WALK_DOWN, 0x2B9))
 		_game._player._walkOffScreenSceneId = 360;
 
-	if (_action.isAction(0x1AD, 0x2BA))
+	if (_action.isAction(VERB_WALK_DOWN, 0x2BA))
 		_game._player._walkOffScreenSceneId = 354;
 }
 
@@ -5361,7 +5361,7 @@ void Scene361::actions() {
 	else if (_action.isAction(0x21F, 0x1E4)) {
 		_scene->_kernelMessages.reset();
 		_scene->_kernelMessages.addQuote(0xFC, 120, 0);
-	} else if (_action.isAction(0x2F7, 0x11)) {
+	} else if (_action.isAction(VERB_CLIMB_INTO, 0x11)) {
 		if (_globals[kSexOfRex] == REX_FEMALE)
 			handleRoxAction();
 		else
@@ -5370,13 +5370,13 @@ void Scene361::actions() {
 		_vm->_dialogs->show(36110);
 	else if (_action.isAction(VERB_LOOK, 0x18D))
 		_vm->_dialogs->show(36111);
-	else if (_action.isAction(VERB_LOOK, 0x220) || _action.isAction(0x155, 0x220))
+	else if (_action.isAction(VERB_LOOK, 0x220) || _action.isAction(VERB_STARE_AT, 0x220))
 		_vm->_dialogs->show(36112);
-	else if (_action.isAction(VERB_LOOK, 0x208) || _action.isAction(0x155, 0x208))
+	else if (_action.isAction(VERB_LOOK, 0x208) || _action.isAction(VERB_STARE_AT, 0x208))
 		_vm->_dialogs->show(36113);
 	else if (_action.isAction(VERB_TAKE, 0x208))
 		_vm->_dialogs->show(36114);
-	else if (_action.isAction(VERB_LOOK, 0x2F8) || _action.isAction(0x155, 0x2F8))
+	else if (_action.isAction(VERB_LOOK, 0x2F8) || _action.isAction(VERB_STARE_AT, 0x2F8))
 		_vm->_dialogs->show(36115);
 	else if (_action.isAction(VERB_TAKE, 0x2F8))
 		_vm->_dialogs->show(36116);
@@ -5414,7 +5414,7 @@ void Scene366::actions() {
 		else
 			_vm->_dialogs->show(36613);
 		_scene->_nextSceneId = 316;
-	} else if (_action.isAction(0xD3, 0x2D3)) {
+	} else if (_action.isAction(VERB_LOOK_THROUGH, 0x2D3)) {
 		if (_game._visitedScenes.exists(321))
 			_vm->_dialogs->show(36611);
 		else
@@ -5443,7 +5443,7 @@ void Scene387::enter() {
 void Scene387::actions() {
 	if (_action.isAction(0x2D5, 0x2D4))
 		_scene->_nextSceneId = 313;
-	else if (_action.isAction(0xD3, 0x2D3))
+	else if (_action.isAction(VERB_LOOK_THROUGH, 0x2D3))
 		_vm->_dialogs->show(38710);
 	else if (_action.isAction(VERB_OPEN, 0x2D3))
 		_vm->_dialogs->show(38711);
@@ -5503,7 +5503,7 @@ void Scene388::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(0xD3, 0x2D3)) {
+	} else if (_action.isAction(VERB_LOOK_THROUGH, 0x2D3)) {
 		if (_globals[kAfterHavoc])
 			_vm->_dialogs->show(38811);
 		else
@@ -5576,7 +5576,7 @@ void Scene389::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(0xD3, 0x2D3)) {
+	} else if (_action.isAction(VERB_LOOK_THROUGH, 0x2D3)) {
 		if (_globals[kAfterHavoc]) {
 			if ((_game._difficulty != DIFFICULTY_HARD) && (_game._objects[OBJ_SECURITY_CARD]._roomNumber == 359))
 				_vm->_dialogs->show(38911);
@@ -5619,7 +5619,7 @@ void Scene390::enter() {
 void Scene390::actions() {
 	if (_action.isAction(0x2D5, 0x2D4))
 		_scene->_nextSceneId = 313;
-	else if (_action.isAction(0xD3, 0x2D3))
+	else if (_action.isAction(VERB_LOOK_THROUGH, 0x2D3))
 		_vm->_dialogs->show(39010);
 	else if (_action.isAction(VERB_OPEN, 0x2D3))
 		_vm->_dialogs->show(39011);
@@ -5657,7 +5657,7 @@ void Scene391::actions() {
 			_scene->_nextSceneId = 361;
 		else
 			_scene->_nextSceneId = 311;
-	} else if (_action.isAction(0xD3, 0x2D3)) {
+	} else if (_action.isAction(VERB_LOOK_THROUGH, 0x2D3)) {
 		if (_globals[kAfterHavoc])
 			_vm->_dialogs->show(39111);
 		else
@@ -5684,7 +5684,7 @@ void Scene399::enter() {
 void Scene399::actions() {
 	if (_action.isAction(0x2D5, 0x2D4))
 		_scene->_nextSceneId = 313;
-	else if (_action.isAction(0xD3, 0x2D3)) {
+	else if (_action.isAction(VERB_LOOK_THROUGH, 0x2D3)) {
 		if (_globals[kAfterHavoc]) {
 			if ((_game._difficulty != DIFFICULTY_HARD) && (_game._objects[OBJ_SECURITY_CARD]._roomNumber == 359))
 				_vm->_dialogs->show(38911);
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index 79352fb..2053c47 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -158,12 +158,12 @@ void Scene401::step() {
 }
 
 void Scene401::preActions() {
-	if (_action.isAction(0x1AD, 0x2B4)) {
+	if (_action.isAction(VERB_WALK_DOWN, 0x2B4)) {
 		_game._player.walk(Common::Point(149, 89), FACING_NORTH);
 		_northFl = false;
 	}
 
-	if (_action.isAction(0x1AD, 0x2B3) && !_northFl)
+	if (_action.isAction(VERB_WALK_DOWN, 0x2B3) && !_northFl)
 		_game._player._walkOffScreenSceneId = 405;
 
 	if (_action.isAction(VERB_TAKE))
@@ -207,7 +207,7 @@ void Scene401::actions() {
 	if (_action.isAction(0x242, 0x241)) {
 		if (!_northFl)
 			_scene->_nextSceneId = 402;
-	} else if (_action.isAction(0x1AD, 0x2B4))
+	} else if (_action.isAction(VERB_WALK_DOWN, 0x2B4))
 		_scene->_nextSceneId = 354;
 	else if (_action.isAction(VERB_LOOK, 0x1F3)) {
 		if (_globals[kHasBeenScanned])
@@ -1977,7 +1977,7 @@ void Scene402::step() {
 }
 
 void Scene402::preActions() {
-	if (_action.isAction(0x30B, 0x24A) && (_game._player._prepareWalkPos.x != 248))
+	if (_action.isAction(VERB_SIT_ON, 0x24A) && (_game._player._prepareWalkPos.x != 248))
 		_game._player.walk(Common::Point(232, 112), FACING_EAST);
 
 	if (_action.isAction(VERB_WALKTO, 0x309))
@@ -2144,10 +2144,10 @@ void Scene402::actions() {
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_scene->_sequences.addTimer(120, 44);
 		_game._player._stepEnabled = false;
-	} else if (_action.isAction(0x30B, 0x24A) && (_game._player._targetPos.x == 248)){
+	} else if (_action.isAction(VERB_WALK_ALONG, 0x24A) && (_game._player._targetPos.x == 248)){
 		_scene->_kernelMessages.add(Common::Point(0, -14), 0x1110, 34, 0, 120, _game.getQuote(0x20D));
 		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x20E));
-	} else if (_action.isAction(0x30B, 0x24A) && !_roxOnStool && (_game._player._targetPos.x != 248)) {
+	} else if (_action.isAction(VERB_WALK_ALONG, 0x24A) && !_roxOnStool && (_game._player._targetPos.x != 248)) {
 		_game._player._visible = false;
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 7, 1, 0, 0);
@@ -2435,10 +2435,10 @@ void Scene405::preActions() {
 	if (_action.isAction(VERB_TAKE))
 		_game._player._needToWalk = false;
 
-	if (_action.isAction(0x1AD, 0x2BA))
+	if (_action.isAction(VERB_WALK_DOWN, 0x2BA))
 		_game._player._walkOffScreenSceneId = 401;
 
-	if (_action.isAction(0x1AD, 0x2B9))
+	if (_action.isAction(VERB_WALK_DOWN, 0x2B9))
 		_game._player._walkOffScreenSceneId = 406;
 
 	if (_action.isAction(VERB_CLOSE, 0x259) && _globals[kArmoryDoorOpen])
@@ -2446,11 +2446,11 @@ void Scene405::preActions() {
 }
 
 void Scene405::actions() {
-	if (_action.isAction(0x18B, 0x6E))
+	if (_action.isAction(VERB_WALK_THROUGH, 0x6E))
 		_scene->_nextSceneId = 413;
-	else if (_action.isAction(0x18B, 0x259) && _globals[kArmoryDoorOpen])
+	else if (_action.isAction(VERB_WALK_THROUGH, 0x259) && _globals[kArmoryDoorOpen])
 		_scene->_nextSceneId = 408;
-	else if (_action.isAction(0x18B, 0x259) && !_globals[kArmoryDoorOpen])
+	else if (_action.isAction(VERB_WALK_THROUGH, 0x259) && !_globals[kArmoryDoorOpen])
 		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 60, _game.getQuote(0x24F));
 	else if (_action.isAction(VERB_PUT, 0x131, 0x251) && !_globals[kArmoryDoorOpen]) {
 		_game._player._stepEnabled = false;
@@ -2621,10 +2621,10 @@ void Scene406::step() {
 }
 
 void Scene406::preActions() {
-	if (_action.isAction(0x1AD, 0x2BA))
+	if (_action.isAction(VERB_WALK_DOWN, 0x2BA))
 		_game._player._walkOffScreenSceneId = 405;
 
-	if (_action.isAction(0x1AD, 0x2B9))
+	if (_action.isAction(VERB_WALK_DOWN, 0x2B9))
 		_game._player._walkOffScreenSceneId = 407;
 
 	if (_action.isAction(VERB_TAKE))
@@ -2635,16 +2635,16 @@ void Scene406::preActions() {
 }
 
 void Scene406::actions() {
-	if (_action.isAction(0x18B, 0x6E) && (_game._player._targetPos.x> 100)) {
+	if (_action.isAction(VERB_WALK_THROUGH, 0x6E) && (_game._player._targetPos.x> 100)) {
 		_game._player._stepEnabled = false;
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
 		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 3, 1, 0, 0);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
 		_vm->_sound->command(19);
-	} else if (_action.isAction(0x18B, 0x6E) && _globals[kStorageDoorOpen] && (_game._player._targetPos.x < 100))
+	} else if (_action.isAction(VERB_WALK_THROUGH, 0x6E) && _globals[kStorageDoorOpen] && (_game._player._targetPos.x < 100))
 		_scene->_nextSceneId = 410;
-	else if (_action.isAction(0x18B, 0x6E) && !_globals[kStorageDoorOpen] && (_game._player._targetPos.x < 100)) {
+	else if (_action.isAction(VERB_WALK_THROUGH, 0x6E) && !_globals[kStorageDoorOpen] && (_game._player._targetPos.x < 100)) {
 		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 60, _game.getQuote(0x24F));
 		if (!_hitStorageDoor) {
 			_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
@@ -2774,7 +2774,7 @@ void Scene407::preActions() {
 	if (_action.isAction(VERB_LOOK, 0x6E))
 		_game._player._needToWalk = true;
 
-	if (_action.isAction(0x1AD, 0x2B4)) {
+	if (_action.isAction(VERB_WALK_DOWN, 0x2B4)) {
 		_game._player.walk(Common::Point(172, 91), FACING_NORTH);
 		_fromNorth = false;
 	}
@@ -2813,9 +2813,9 @@ void Scene407::actions() {
 		}
 	}
 
-	if (_action.isAction(0x1AD, 0x2B3) && !_fromNorth)
+	if (_action.isAction(VERB_WALK_DOWN, 0x2B3) && !_fromNorth)
 		_scene->_nextSceneId = 406;
-	else if (_action.isAction(0x1AD, 0x2B4))
+	else if (_action.isAction(VERB_WALK_DOWN, 0x2B4))
 		_scene->_nextSceneId = 318;
 	else if (_action.isAction(VERB_LOOK, 0x1F3)) {
 		if (_globals[kHasBeenScanned])
@@ -3030,11 +3030,11 @@ void Scene409::actions() {
 
 	if (_action.isAction(VERB_LOOK, 0x181))
 		_vm->_dialogs->show(40910);
-	else if (_action.isAction(0x103, 0x181))
+	else if (_action.isAction(VERB_PEER_THROUGH, 0x181))
 		_vm->_dialogs->show(40910);
 	else if (_action.isAction(VERB_LOOK, 0xC4))
 		_vm->_dialogs->show(40911);
-	else if (_action.isAction(0xB7, 0xC4))
+	else if (_action.isAction(VERB_INSPECT, 0xC4))
 		_vm->_dialogs->show(40911);
 	else if (_action.isAction(VERB_LOOK, 0x1CC))
 		_vm->_dialogs->show(40912);
@@ -4086,11 +4086,11 @@ void Scene413::preActions() {
 }
 
 void Scene413::actions() {
-	if (_action.isAction(0x188, 0x16C)) {
+	if (_action.isAction(VERB_WALK_INSIDE, 0x16C)) {
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
 		_scene->_nextSceneId = 409;
-	} else if (_action.isAction(0x188, 0x2B3))
+	} else if (_action.isAction(VERB_WALK_INSIDE, 0x2B3))
 		_scene->_nextSceneId = 405;
 	else if (_action.isAction(VERB_LOOK, 0x2C4))
 		_vm->_dialogs->show(41310);
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index c884170..44363ec 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -274,7 +274,7 @@ void Scene501::step() {
 }
 
 void Scene501::preActions() {
-	if (_action.isAction(0x1AD) && (_action.isAction(0x321) || _action.isAction(0x322)))
+	if (_action.isAction(VERB_WALK_DOWN) && (_action.isAction(0x321) || _action.isAction(0x322)))
 		_game._player._walkOffScreenSceneId = 551;
 }
 
@@ -430,7 +430,7 @@ void Scene501::actions() {
 	else if (_action.isAction(VERB_LOOK, 0x322))
 		_vm->_dialogs->show(50118);
 	else if (_action.isAction(VERB_LOOK, 0x361) || _action.isAction(VERB_LOOK, 0x360)
-		|| _action.isAction(0x1AD, 0x361) || _action.isAction(0x1AD, 0x360))
+		|| _action.isAction(VERB_WALK_DOWN, 0x361) || _action.isAction(VERB_WALK_DOWN, 0x360))
 		_vm->_dialogs->show(50119);
 	else if (_action.isAction(VERB_LOOK, 0x323))
 		_vm->_dialogs->show(50120);
@@ -490,7 +490,7 @@ void Scene502::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x181) || _action.isAction(0x103, 0x181))
+	if (_action.isAction(VERB_LOOK, 0x181) || _action.isAction(VERB_PEER_THROUGH, 0x181))
 		_vm->_dialogs->show(50210);
 	else if (_action.isAction(VERB_LOOK, 0xC4))
 		_vm->_dialogs->show(50211);
@@ -742,7 +742,7 @@ void Scene504::preActions() {
 }
 
 void Scene504::actions() {
-	if (_action.isAction(0x1CE, 0x324)) {
+	if (_action.isAction(VERB_EXIT_FROM, 0x324)) {
 		_vm->_sound->command(15);
 		_scene->_nextSceneId = _globals[kHoverCarLocation];
 	} else if (_action.isAction(0xE, 0x380)) {
@@ -815,7 +815,7 @@ void Scene504::actions() {
 		_vm->_dialogs->show(50414);
 	else if (_action.isAction(VERB_LOOK, 0x382))
 		_vm->_dialogs->show(50415);
-	else if (_action.isAction(VERB_LOOK, 0x386) || _action.isAction(0xD3, 0x386))
+	else if (_action.isAction(VERB_LOOK, 0x386) || _action.isAction(VERB_LOOK_THROUGH, 0x386))
 		_vm->_dialogs->show(50416);
 	else if (_action.isAction(VERB_LOOK, 0x120))
 		_vm->_dialogs->show(50417);
@@ -1071,7 +1071,7 @@ void Scene505::step() {
 }
 
 void Scene505::actions() {
-	if (_action.isAction(0x11A))
+	if (_action.isAction(VERB_PRESS))
 		_nextButtonId = _action._activeAction._objectNameId;
 	else if (_action.isAction(0x2D5, 0x38C))
 		_scene->_nextSceneId = 504;
@@ -1333,7 +1333,7 @@ void Scene506::actions() {
 		_vm->_dialogs->show(50615);
 	else if (_action.isAction(VERB_LOOK, 0x37D))
 		_vm->_dialogs->show(50616);
-	else if (_action.isAction(VERB_LOOK, 0x360) || _action.isAction(0x1AD, 0x360))
+	else if (_action.isAction(VERB_LOOK, 0x360) || _action.isAction(VERB_WALK_DOWN, 0x360))
 		_vm->_dialogs->show(50617);
 	else if (_action.isAction(VERB_LOOK, 0x373))
 		_vm->_dialogs->show(50619);
@@ -1374,7 +1374,7 @@ void Scene507::enter() {
 	sceneEntrySound();
 }
 void Scene507::actions() {
-	if (_action.isAction(0x18B, 0x378))
+	if (_action.isAction(VERB_WALK_THROUGH, 0x378))
 		_scene->_nextSceneId = 506;
 	else if (_action.isAction(VERB_TAKE, 0x106)) {
 		if (_game._trigger || !_game._objects.isInInventory(OBJ_PENLIGHT)) {
@@ -1996,7 +1996,7 @@ void Scene511::actions() {
 		_vm->_dialogs->show(51113);
 	else if (_action.isAction(VERB_LOOK, 0x31D))
 		_vm->_dialogs->show(51114);
-	else if (_action.isAction(0x1AD, 0x322) || _action.isAction(0x1AD, 0x361) || _action.isAction(0x1AD, 0x321))
+	else if (_action.isAction(VERB_WALK_DOWN, 0x322) || _action.isAction(VERB_WALK_DOWN, 0x361) || _action.isAction(VERB_WALK_DOWN, 0x321))
 		_vm->_dialogs->show(51115);
 	else if (_action.isAction(VERB_LOOK, 0x37B))
 		_vm->_dialogs->show(51116);
@@ -2286,7 +2286,7 @@ void Scene512::actions() {
 		_vm->_dialogs->show(51218);
 	else if (_action.isAction(VERB_TAKE, 0x354))
 		_vm->_dialogs->show(51219);
-	else if (_action.isAction(VERB_LOOK, 0x349) || _action.isAction(0x103, 0x349))
+	else if (_action.isAction(VERB_LOOK, 0x349) || _action.isAction(VERB_PEER_THROUGH, 0x349))
 		_vm->_dialogs->show(51220);
 	else if (_action.isAction(VERB_LOOK, 0x160))
 		_vm->_dialogs->show(51221);
@@ -2539,7 +2539,7 @@ void Scene513::actions() {
 		_vm->_dialogs->show(51315);
 	else if (_action.isAction(VERB_LOOK, 0x244))
 		_vm->_dialogs->show(51316);
-	else if (_action.isAction(VERB_LOOK, 0x360) || _action.isAction(0x1AD, 0x360))
+	else if (_action.isAction(VERB_LOOK, 0x360) || _action.isAction(VERB_WALK_DOWN, 0x360))
 		_vm->_dialogs->show(51317);
 	else if (_action.isAction(VERB_OPEN, 0x367) || _action.isAction(VERB_OPEN, 0x317))
 		_vm->_dialogs->show(51319);
@@ -2681,12 +2681,12 @@ void Scene551::step() {
 }
 
 void Scene551::preActions() {
-	if (_action.isAction(0x1AD) && (_action.isAction(0x360) || _action.isAction(0x361)))
+	if (_action.isAction(VERB_WALK_DOWN) && (_action.isAction(0x360) || _action.isAction(0x361)))
 		_game._player._walkOffScreenSceneId = 501;
 }
 
 void Scene551::actions() {
-	if (_action.isAction(0x2F9, 0x16C))
+	if (_action.isAction(VERB_STEP_INTO, 0x16C))
 		_scene->_nextSceneId = 502;
 	else if ((_action._lookFlag))
 		_vm->_dialogs->show(55117);
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index 4cacfac..0921ceb 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -147,7 +147,7 @@ void Scene601::step() {
 }
 
 void Scene601::actions() {
-	if (_action.isAction(0x18B, 0x378))
+	if (_action.isAction(VERB_WALK_THROUGH, 0x378))
 		_scene->_nextSceneId = 602;
 	else if (_action.isAction(0x325, 0x324)) {
 		switch (_game._trigger) {
@@ -197,7 +197,7 @@ void Scene601::actions() {
 		_vm->_dialogs->show(60113);
 	else if (_action.isAction(VERB_LOOK, 0x323))
 		_vm->_dialogs->show(60114);
-	else if (_action.isAction(0x1AD, 0x31E))
+	else if (_action.isAction(VERB_WALK_DOWN, 0x31E))
 		_vm->_dialogs->show(60115);
 	else if (_action.isAction(VERB_LOOK, 0x48E))
 		_vm->_dialogs->show(60116);
@@ -383,9 +383,9 @@ void Scene602::handleSafeActions() {
 }
 
 void Scene602::actions() {
-	if (_action.isAction(0x18B, 0x1F9))
+	if (_action.isAction(VERB_WALK_THROUGH, 0x1F9))
 		_scene->_nextSceneId = 601;
-	else if (_action.isAction(0x18B, 0x70))
+	else if (_action.isAction(VERB_WALK_THROUGH, 0x70))
 		_scene->_nextSceneId = 603;
 	else if (_action.isAction(VERB_OPEN, 0x3D3) && ((_globals[kSafeStatus] == 0) || (_globals[kSafeStatus] == 2))) {
 		_safeMode = 1;
@@ -564,7 +564,7 @@ void Scene603::enter() {
 }
 
 void Scene603::actions() {
-	if (_action.isAction(0x18C, 0x3F1))
+	if (_action.isAction(VERB_WALK_TOWARDS, 0x3F1))
 		_scene->_nextSceneId = 602;
 	else if (_action.isAction(VERB_TAKE, 0x57)) {
 		if ( _game._trigger || !_game._objects.isInInventory(OBJ_COMPACT_CASE)) {
@@ -1296,7 +1296,7 @@ void Scene607::preActions() {
 	if (_action.isAction(VERB_TALKTO, 0x471))
 		_game._player._needToWalk = false;
 
-	if (_action.isAction(0x18B, 0x478) && (_globals[kDogStatus] == 2) && (_game._difficulty != DIFFICULTY_EASY)) {
+	if (_action.isAction(VERB_WALK_THROUGH, 0x478) && (_globals[kDogStatus] == 2) && (_game._difficulty != DIFFICULTY_EASY)) {
 		_shopAvailable = true;
 		_dogTimer = 0;
 	}
@@ -1309,7 +1309,7 @@ void Scene607::preActions() {
 }
 
 void Scene607::actions() {
-	if (_action.isAction(0x18B, 0x478))
+	if (_action.isAction(VERB_WALK_THROUGH, 0x478))
 		_scene->_nextSceneId = 608;
 	else if (_action.isAction(0x325, 0x324)) {
 		switch (_game._trigger) {
@@ -1406,7 +1406,7 @@ void Scene607::actions() {
 		_vm->_dialogs->show(60727);
 	else if (_action.isAction(VERB_LOOK, 0x31F))
 		_vm->_dialogs->show(60728);
-	else if (_action.isAction(0x1AD, 0x31E))
+	else if (_action.isAction(VERB_WALK_DOWN, 0x31E))
 		_vm->_dialogs->show(60730);
 	else if (_action.isAction(0x3FF) && (_action.isAction(VERB_OPEN) || _action.isAction(VERB_PUSH) || _action.isAction(VERB_PULL)))
 		_vm->_dialogs->show(60731);
@@ -2091,7 +2091,7 @@ void Scene608::preActions() {
 }
 
 void Scene608::actions() {
-	if (_action.isAction(0x18B, 0x70))
+	if (_action.isAction(VERB_WALK_THROUGH, 0x70))
 		_scene->_nextSceneId = 607;
 	else if (_action.isAction(VERB_PUSH, 0x403)) {
 		_game._player._stepEnabled = true;
@@ -2586,9 +2586,9 @@ void Scene609::preActions() {
 }
 
 void Scene609::actions() {
-	if (_action.isAction(0x18C, 0x423))
+	if (_action.isAction(VERB_WALK_TOWARDS, 0x423))
 		_scene->_nextSceneId = 611;
-	else if (_action.isAction(0x18B, 0x425)) {
+	else if (_action.isAction(VERB_WALK_THROUGH, 0x425)) {
 		if (!_globals[kBeenInVideoStore]) {
 			switch (_game._trigger) {
 			case 0:
@@ -2691,7 +2691,7 @@ void Scene609::actions() {
 			_vm->_dialogs->show(60918);
 		else
 			_vm->_dialogs->show(60919);
-	} else if (_action.isAction(0x1AD, 0x31E))
+	} else if (_action.isAction(VERB_WALK_DOWN, 0x31E))
 		_vm->_dialogs->show(60730);
 	else
 		return;
@@ -2763,7 +2763,7 @@ void Scene610::step() {
 }
 
 void Scene610::actions() {
-	if (_action.isAction(0x1CE, 0x427))
+	if (_action.isAction(VERB_EXIT_FROM, 0x427))
 		_scene->_nextSceneId = 609;
 	else if (_action.isAction(VERB_TAKE, 0x108)) {
 		if ( _game._trigger || !_game._objects.isInInventory(OBJ_PHONE_HANDSET)) {
@@ -4130,7 +4130,7 @@ void Scene611::step() {
 }
 
 void Scene611::preActions() {
-	if (_action.isAction(0x1AD, 0x423))
+	if (_action.isAction(VERB_WALK_DOWN, 0x423))
 		_game._player._walkOffScreenSceneId = 609;
 
 	if (_resetBatterieText)
@@ -4458,7 +4458,7 @@ void Scene612::actions() {
 		_vm->_dialogs->show(61223);
 	else if (_action.isAction(VERB_LOOK, 0x257))
 		_vm->_dialogs->show(61224);
-	else if (_action.isAction(0x1AD, 0x461) || _action.isAction(0x1AD, 0x463))
+	else if (_action.isAction(VERB_WALK_DOWN, 0x461) || _action.isAction(VERB_WALK_DOWN, 0x463))
 		_vm->_dialogs->show(61225);
 	else
 		return;
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 85c79e4..07230ea 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -1850,7 +1850,7 @@ void Scene706::preActions() {
 }
 
 void Scene706::actions() {
-	if (_action.isAction(0x188, 0x16C)) {
+	if (_action.isAction(VERB_WALK_INSIDE, 0x16C)) {
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
 		_scene->_nextSceneId = 707;
@@ -1858,7 +1858,7 @@ void Scene706::actions() {
 		return;
 	}
 
-	if (_action.isAction(0x298, 0x2FA)) {
+	if (_action.isAction(VERB_EXIT, 0x2FA)) {
 		_scene->_nextSceneId = 705;
 		_action._inProgress = false;
 		return;
@@ -1970,7 +1970,7 @@ void Scene707::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x181) || _action.isAction(0x103, 0x181))
+	if (_action.isAction(VERB_LOOK, 0x181) || _action.isAction(VERB_PEER_THROUGH, 0x181))
 		_vm->_dialogs->show(70710);
 	else if (_action.isAction(VERB_LOOK, 0xC4))
 		_vm->_dialogs->show(70711);
@@ -2256,7 +2256,7 @@ void Scene751::preActions() {
 }
 
 void Scene751::actions() {
-	if (_action.isAction(0x312, 0x22C))
+	if (_action.isAction(VERB_WALK_ALONG, 0x22C))
 		; // Nothing
 	else if (_action.isAction(VERB_LOOK, 0x27, 0x470)) {
 		switch (_game._trigger) {
@@ -2284,7 +2284,7 @@ void Scene751::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(0x2F9, 0x317)) {
+	} else if (_action.isAction(VERB_STEP_INTO, 0x317)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index fee39a7..6ecde8a 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -249,7 +249,7 @@ void Scene801::preActions() {
 		_game._player._readyToWalk = true;
 	}
 
-	if (_action.isAction(0x188, 0x16C) && _globals[kBeamIsUp]) {
+	if (_action.isAction(VERB_WALK_INSIDE, 0x16C) && _globals[kBeamIsUp]) {
 		_globals[kCutX] = _game._player._playerPos.x;
 		_globals[kCutY] = _game._player._playerPos.y;
 		_globals[kCutFacing] = _game._player._facing;
@@ -262,11 +262,11 @@ void Scene801::preActions() {
 void Scene801::actions() {
 	if (_action.isAction(VERB_LOOK, 0x59))
 		_scene->_nextSceneId = 808;
-	else if (_action.isAction(0x188, 0x16C)) {
+	else if (_action.isAction(VERB_WALK_INSIDE, 0x16C)) {
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
 		_scene->_nextSceneId = 807;
-	} else if (_action.isAction(0x18B, 0x6E) && (_game._player._playerPos == Common::Point(270, 118))) {
+	} else if (_action.isAction(VERB_WALK_THROUGH, 0x6E) && (_game._player._playerPos == Common::Point(270, 118))) {
 		_game._player._stepEnabled = false;
 		_game._player._facing = FACING_EAST;
 		_game._player.selectSeries();
@@ -391,10 +391,10 @@ void Scene802::step() {
 }
 
 void Scene802::preActions() {
-	if (_action.isAction(0x18C, 0x393))
+	if (_action.isAction(VERB_WALK_TOWARDS, 0x393))
 		_game._player._walkOffScreenSceneId = 801;
 
-	if (_action.isAction(0x1AD, 0x1C1)) {
+	if (_action.isAction(VERB_WALK_DOWN, 0x1C1)) {
 		_game._player._walkOffScreenSceneId = 803;
 		_globals[kForceBeamDown] = false;
 	}
@@ -731,7 +731,7 @@ void Scene803::step() {
 }
 
 void Scene803::preActions() {
-	if (_action.isAction(0x1AD, 0x1AE))
+	if (_action.isAction(VERB_WALK_DOWN, 0x1AE))
 		_game._player._walkOffScreenSceneId = 802;
 
 	if (_action.isAction(VERB_TAKE, 0x139))
@@ -783,7 +783,7 @@ void Scene803::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(0x3B8, 0x139)) {
+	} else if (_action.isAction(VERB_ENTER, 0x139)) {
 		_vm->_sound->command(17);
 		_game._player._stepEnabled = false;
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
@@ -1132,39 +1132,39 @@ void Scene805::preActions() {
 }
 
 void Scene805::actions() {
-	if (_action.isAction(0x298, 0x398))
+	if (_action.isAction(VERB_EXIT, 0x398))
 		_scene->_nextSceneId = 804;
-	else if (_action.isAction(0x474, 0x137) && _game._objects.isInInventory(OBJ_SHIELD_MODULATOR)) {
+	else if (_action.isAction(VERB_INSTALL, 0x137) && _game._objects.isInInventory(OBJ_SHIELD_MODULATOR)) {
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 7, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], -1, -2);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
 		_game._player._stepEnabled = false;
-	} else if (_action.isAction(0x474, 0x167) && _game._objects.isInInventory(OBJ_TARGET_MODULE)) {
+	} else if (_action.isAction(VERB_INSTALL, 0x167) && _game._objects.isInInventory(OBJ_TARGET_MODULE)) {
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, -2);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
 		_game._player._stepEnabled = false;
-	} else if (_action.isAction(0x476, 0x137) && _globals[kShieldModInstalled]) {
+	} else if (_action.isAction(VERB_REMOVE, 0x137) && _globals[kShieldModInstalled]) {
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 7, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], -1, -2);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
 		_game._player._stepEnabled = false;
-	} else if (_action.isAction(0x476, 0x167) && _globals[kTargetModInstalled]) {
+	} else if (_action.isAction(VERB_REMOVE, 0x167) && _globals[kTargetModInstalled]) {
 		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, -2);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 81);
 		_game._player._stepEnabled = false;
-	} else if (_action.isAction(0x474, 0x137) && !_game._objects.isInInventory(OBJ_SHIELD_MODULATOR))
+	} else if (_action.isAction(VERB_INSTALL, 0x137) && !_game._objects.isInInventory(OBJ_SHIELD_MODULATOR))
 		_vm->_dialogs->show(80511);
-	else if (_action.isAction(0x474, 0x167) && !_game._objects.isInInventory(OBJ_TARGET_MODULE))
+	else if (_action.isAction(VERB_INSTALL, 0x167) && !_game._objects.isInInventory(OBJ_TARGET_MODULE))
 		_vm->_dialogs->show(80510);
-	else if (_action.isAction(0x476, 0x475))
+	else if (_action.isAction(VERB_REMOVE, 0x475))
 		_vm->_dialogs->show(80512);
 	else
 		return;
@@ -1207,9 +1207,9 @@ void Scene807::actions() {
 
 	if (_action.isAction(VERB_LOOK, 0x181))
 		_vm->_dialogs->show(80710);
-	else if (_action.isAction(0x103, 0x181))
+	else if (_action.isAction(VERB_PEER_THROUGH, 0x181))
 		_vm->_dialogs->show(80710);
-	else if (_action.isAction(VERB_LOOK, 0xC4) && _action.isAction(0xB7, 0xC4))
+	else if (_action.isAction(VERB_LOOK, 0xC4) && _action.isAction(VERB_INSPECT, 0xC4))
 		_vm->_dialogs->show(80711);
 	else if (_action.isAction(VERB_LOOK, 0x1CC))
 		_vm->_dialogs->show(80712);
@@ -1277,7 +1277,7 @@ void Scene808::enter() {
 }
 
 void Scene808::actions() {
-	if (_action.isAction(0x11A, 0x3BC)) {
+	if (_action.isAction(VERB_PRESS, 0x3BC)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1313,7 +1313,7 @@ void Scene808::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(0x11A, 0x3BE)) {
+	} else if (_action.isAction(VERB_PRESS, 0x3BE)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1343,7 +1343,7 @@ void Scene808::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(0x11A, 0x3BD)) {
+	} else if (_action.isAction(VERB_PRESS, 0x3BD)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1374,7 +1374,7 @@ void Scene808::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(0x11A, 0x3BF)) {
+	} else if (_action.isAction(VERB_PRESS, 0x3BF)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1391,7 +1391,7 @@ void Scene808::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(0x11A, 0x3BB)) {
+	} else if (_action.isAction(VERB_PRESS, 0x3BB)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1408,7 +1408,7 @@ void Scene808::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(0x11A, 0x3BA)) {
+	} else if (_action.isAction(VERB_PRESS, 0x3BA)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1425,7 +1425,7 @@ void Scene808::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(0x298, 0x1E0)) {
+	} else if (_action.isAction(VERB_EXIT, 0x1E0)) {
 		_scene->_nextSceneId = 801;
 		_globals[kBetweenRooms] = true;
 	} else


Commit: 03add3cdd7e737d28596a96cdc7bf7857cc2ee77
    https://github.com/scummvm/scummvm/commit/03add3cdd7e737d28596a96cdc7bf7857cc2ee77
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T02:33:09+03:00

Commit Message:
MADS: Replace more dialog IDs with their decimal values

Changed paths:
    engines/mads/nebular/game_nebular.cpp



diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 8be6068..1afee51 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -577,29 +577,29 @@ void GameNebular::unhandledAction() {
 
 	if (action.isAction(VERB_THROW, NOUN_BOMB) || action.isAction(VERB_THROW, NOUN_BOMBS)
 	|| action.isAction(VERB_THROW, NOUN_TIMEBOMB) || action.isAction(VERB_THROW, NOUN_CHICKEN_BOMB))
-		_vm->_dialogs->show(0x2A);
+		_vm->_dialogs->show(42);
 	else if (action.isAction(0x6C))
-		_vm->_dialogs->show(0x1B3);
+		_vm->_dialogs->show(435);
 	else if ((action.isAction(VERB_EAT, NOUN_DEAD_FISH) || action.isAction(VERB_EAT, NOUN_STUFFED_FISH)) && _vm->_game->_objects.isInInventory(_vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId)))
-		_vm->_dialogs->show(0xC);
+		_vm->_dialogs->show(12);
 	else if ((action.isAction(VERB_SMELL, NOUN_DEAD_FISH) || action.isAction(VERB_SMELL, NOUN_STUFFED_FISH)) && _vm->_game->_objects.isInInventory(_vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId)))
-		_vm->_dialogs->show(0xD);
+		_vm->_dialogs->show(13);
 	else if (action.isAction(VERB_EAT, NOUN_CHICKEN) && _vm->_game->_objects.isInInventory(OBJ_CHICKEN))
-		_vm->_dialogs->show(0x390);
+		_vm->_dialogs->show(912);
 	else if ((action.isAction(VERB_SHOOT) || action.isAction(VERB_HOSE_DOWN)) && action.isAction(NOUN_BLOWGUN)) {
 		if ((_scene._currentSceneId >= 104) && (_scene._currentSceneId <= 111))
-			_vm->_dialogs->show(0x26);
+			_vm->_dialogs->show(38);
 		else if (action.isAction(0x10D))
-			_vm->_dialogs->show(0x29);
+			_vm->_dialogs->show(41);
 		else if (action.isAction(NOUN_CHICKEN) || action.isAction(0x185) || action.isAction(0x14D)
 				|| action.isAction(0x1DD) || action.isAction(0x15F) || action.isAction(NOUN_CAPTIVE_CREATURE)) {
-			_vm->_dialogs->show(0x28);
+			_vm->_dialogs->show(40);
 		} else
-			_vm->_dialogs->show(0x27);
+			_vm->_dialogs->show(39);
 	} else if (action.isAction(VERB_TALKTO)) {
 		_globals[kTalkInanimateCount] = (_globals[kTalkInanimateCount] + 1) % 16;
 		if (!_globals[kTalkInanimateCount]) {
-			_vm->_dialogs->show(0x2);
+			_vm->_dialogs->show(2);
 		} else {
 			Common::String tmpMsg = "\"Greetings, ";
 			tmpMsg += _vm->_game->_scene.getVocab(action._activeAction._objectNameId);
@@ -608,78 +608,78 @@ void GameNebular::unhandledAction() {
 			_scene._kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, tmpMsg);
 		}
 	} else if (action.isAction(VERB_GIVE, NOUN_DOOR, 0x46) || action.isAction(VERB_CLOSE, NOUN_CHAIR))
-		_vm->_dialogs->show(0x3);
+		_vm->_dialogs->show(3);
 	else if (action.isAction(VERB_THROW)) {
 		int objId = _vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId);
 		if (objId < 0)
-			_vm->_dialogs->show(0x4);
+			_vm->_dialogs->show(4);
 		else if (_vm->_game->_objects[objId]._roomNumber != 2)
-			_vm->_dialogs->show(0x5);
+			_vm->_dialogs->show(5);
 		else
-			_vm->_dialogs->show(0x6);
+			_vm->_dialogs->show(6);
 	} else if (action.isAction(VERB_LOOK)) {
 		if (action.isAction(0x27) && (action._activeAction._indirectObjectId > 0))
-			_vm->_dialogs->show(0xA);
+			_vm->_dialogs->show(10);
 		else if (randVal < 600)
-			_vm->_dialogs->show(0x7);
+			_vm->_dialogs->show(7);
 		else
-			_vm->_dialogs->show(0x15);
+			_vm->_dialogs->show(21);
 	} else if (action.isAction(VERB_TAKE)) {
 		int objId = _vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId);
 		if (_vm->_game->_objects.isInInventory(objId))
-			_vm->_dialogs->show(0x10);
+			_vm->_dialogs->show(16);
 		else if (randVal <= 333)
-			_vm->_dialogs->show(0x8);
+			_vm->_dialogs->show(8);
 		else if (randVal <= 666)
-			_vm->_dialogs->show(0x16);
+			_vm->_dialogs->show(22);
 		else
-			_vm->_dialogs->show(0x17);
+			_vm->_dialogs->show(23);
 	} else if (action.isAction(VERB_CLOSE)) {
 		if (randVal <= 333)
-			_vm->_dialogs->show(0x9);
+			_vm->_dialogs->show(9);
 		else
-			_vm->_dialogs->show(0x21);
+			_vm->_dialogs->show(33);
 	} else if (action.isAction(VERB_OPEN)) {
 		if (randVal <= 500)
-			_vm->_dialogs->show(0x1E);
+			_vm->_dialogs->show(30);
 		else if (randVal <= 750)
-			_vm->_dialogs->show(0x1F);
+			_vm->_dialogs->show(31);
 		else
-			_vm->_dialogs->show(0x20);
+			_vm->_dialogs->show(32);
 	} else if (action.isAction(VERB_PULL))
-		_vm->_dialogs->show(0x12);
+		_vm->_dialogs->show(18);
 	else if (action.isAction(VERB_PUSH)) {
 		if (randVal < 750)
-			_vm->_dialogs->show(0x13);
+			_vm->_dialogs->show(19);
 		else
-			_vm->_dialogs->show(0x14);
+			_vm->_dialogs->show(20);
 	} else if (action.isAction(VERB_PUT)) {
 		int objId = _vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId);
 		if (_vm->_game->_objects.isInInventory(objId))
-			_vm->_dialogs->show(0x19);
+			_vm->_dialogs->show(25);
 		else
-			_vm->_dialogs->show(0x18);
+			_vm->_dialogs->show(24);
 	} else if (action.isAction(VERB_GIVE)) {
 		int objId = _vm->_game->_objects.getIdFromDesc(action._activeAction._objectNameId);
 		if (!_vm->_game->_objects.isInInventory(objId))
-			_vm->_dialogs->show(0x1A);
+			_vm->_dialogs->show(26);
 		else if (randVal <= 500)
-			_vm->_dialogs->show(0x1C);
+			_vm->_dialogs->show(28);
 		else
-			_vm->_dialogs->show(0x1D);
+			_vm->_dialogs->show(29);
 	} else if (!action.isAction(VERB_WALKTO) && !action.isAction(0x187) && !action.isAction(0x18C) && !action.isAction(0x1AD)
 			&& !action.isAction(0x15C) && !action.isAction(0x159) && !action.isAction(0x15A) && !action.isAction(0x15B)
 			&& !action.isAction(0x15E)) {
 		if (randVal <= 100)
-			_vm->_dialogs->show(0x24);
+			_vm->_dialogs->show(36);
 		else if (randVal <= 200)
-			_vm->_dialogs->show(0x1);
+			_vm->_dialogs->show(1);
 		else if (randVal <= 475)
-			_vm->_dialogs->show(0x22);
+			_vm->_dialogs->show(34);
 		else if (randVal <= 750)
-			_vm->_dialogs->show(0x23);
+			_vm->_dialogs->show(35);
 		else
-			_vm->_dialogs->show(0x25);
+			_vm->_dialogs->show(37);
 	}
 }
 


Commit: d3c5a88bfca98d4664dbbd7729811a94819169bc
    https://github.com/scummvm/scummvm/commit/d3c5a88bfca98d4664dbbd7729811a94819169bc
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T02:34:32+03:00

Commit Message:
MADS: Fix some usages of isAction() with nouns

Changed paths:
    engines/mads/nebular/game_nebular.cpp



diff --git a/engines/mads/nebular/game_nebular.cpp b/engines/mads/nebular/game_nebular.cpp
index 1afee51..51e06d0 100644
--- a/engines/mads/nebular/game_nebular.cpp
+++ b/engines/mads/nebular/game_nebular.cpp
@@ -586,13 +586,13 @@ void GameNebular::unhandledAction() {
 		_vm->_dialogs->show(13);
 	else if (action.isAction(VERB_EAT, NOUN_CHICKEN) && _vm->_game->_objects.isInInventory(OBJ_CHICKEN))
 		_vm->_dialogs->show(912);
-	else if ((action.isAction(VERB_SHOOT) || action.isAction(VERB_HOSE_DOWN)) && action.isAction(NOUN_BLOWGUN)) {
+	else if ((action.isAction(VERB_SHOOT) || action.isAction(VERB_HOSE_DOWN)) && action.isObject(NOUN_BLOWGUN)) {
 		if ((_scene._currentSceneId >= 104) && (_scene._currentSceneId <= 111))
 			_vm->_dialogs->show(38);
 		else if (action.isAction(0x10D))
 			_vm->_dialogs->show(41);
-		else if (action.isAction(NOUN_CHICKEN) || action.isAction(0x185) || action.isAction(0x14D)
-				|| action.isAction(0x1DD) || action.isAction(0x15F) || action.isAction(NOUN_CAPTIVE_CREATURE)) {
+		else if (action.isObject(NOUN_CHICKEN) || action.isAction(0x185) || action.isAction(0x14D)
+				|| action.isAction(0x1DD) || action.isAction(0x15F) || action.isObject(NOUN_CAPTIVE_CREATURE)) {
 			_vm->_dialogs->show(40);
 		} else
 			_vm->_dialogs->show(39);


Commit: 7f8c1e9a4855a812348807cd6b33412e4d93f138
    https://github.com/scummvm/scummvm/commit/7f8c1e9a4855a812348807cd6b33412e4d93f138
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T04:05:32+03:00

Commit Message:
MADS: Replace more verbs with their friendly names

Changed paths:
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes6.cpp



diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 674e785..e385c6a 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -67,16 +67,22 @@ enum Verb {
 	VERB_SWIM_TO        = 0x15C,
 	VERB_SWIM_TOWARDS   = 0x15D,
 	VERB_SWIM_UNDER     = 0x15E,
+	VERB_UNLOCK         = 0x17B,
 	VERB_WALK_INSIDE    = 0x188,
 	VERB_WALK_THROUGH   = 0x18B,
 	VERB_WALK_TOWARDS   = 0x18C,
 	VERB_WALK_DOWN      = 0x1AD,
 	VERB_EXIT_FROM      = 0x1CE,
+	VERB_WALK_UP        = 0x227,
+	VERB_WALK_INTO      = 0x242,
 	VERB_EXIT           = 0x298,
+	VERB_WALK_ONTO      = 0x2B5,
 	VERB_CLIMB_INTO     = 0x2F7,
 	VERB_STEP_INTO      = 0x2F9,
 	VERB_SIT_ON         = 0x30B,
 	VERB_WALK_ALONG     = 0x312,
+	VERB_WALK           = 0x32F,
+	VERB_GET_INTO       = 0x36A,
 	VERB_ENTER          = 0x3B8,
 	VERB_INSTALL        = 0x474,
 	VERB_REMOVE         = 0x476
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index d0dd477..b0085d5 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -1111,7 +1111,7 @@ void Scene307::actions() {
 		_vm->_dialogs->show(30717);
 	else if (_action.isAction(VERB_LOOK, 0xCD))
 		_vm->_dialogs->show(30718);
-	else if (_action.isAction(0x242, 0x204)) {
+	else if (_action.isAction(VERB_WALK_INTO, 0x204)) {
 		switch (_fieldCollisionCounter) {
 		case 0:
 			_vm->_dialogs->show(30719);
@@ -2263,7 +2263,7 @@ void Scene316::actions() {
 			handleRoxInGrate();
 		else
 			handleRexInGrate();
-	} else if (_action.isAction(0x227, 0x226) || _action.isAction(0x2B5, 0x22C)) {
+	} else if (_action.isAction(VERB_WALK_UP, 0x226) || _action.isAction(VERB_WALK_ONTO, 0x22C)) {
 		switch (_game._trigger) {
 		case 0:
 			if (_globals[kCityFlooded]) {
@@ -2859,7 +2859,7 @@ void Scene318::actions() {
 			return;
 		}
 
-		if (_action.isAction(0x242, 0x488)) {
+		if (_action.isAction(VERB_WALK_INTO, 0x488)) {
 			_vm->_dialogs->show(31831);
 			_action._inProgress = false;
 			return;
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index 2053c47..d8f3607 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -204,7 +204,7 @@ void Scene401::actions() {
 		}
 	}
 
-	if (_action.isAction(0x242, 0x241)) {
+	if (_action.isAction(VERB_WALK_INTO, 0x241)) {
 		if (!_northFl)
 			_scene->_nextSceneId = 402;
 	} else if (_action.isAction(VERB_WALK_DOWN, 0x2B4))
@@ -2048,9 +2048,9 @@ void Scene402::actions() {
 		_game._player._stepEnabled = true;
 	} else if (_game._screenObjects._inputMode == 1)
 		handleDialogs();
-	else if (_action.isAction(0x242, 0x2B3))
+	else if (_action.isAction(VERB_WALK_INTO, 0x2B3))
 		_scene->_nextSceneId = 401;
-	else if (_action.isAction(0x2B5, 0x248))
+	else if (_action.isAction(VERB_WALK_ONTO, 0x248))
 		; // just... nothing
 	else if (_action.isAction(VERB_TALKTO, 0x3AA)) {
 		switch (_game._trigger) {
@@ -2878,7 +2878,7 @@ void Scene408::preActions() {
 }
 
 void Scene408::actions() {
-	if (_action.isAction(0x242, 0x2B3)) {
+	if (_action.isAction(VERB_WALK_INTO, 0x2B3)) {
 		_scene->_nextSceneId = 405;
 		_vm->_sound->command(58);
 	} else if (_action.isAction(VERB_TAKE, 0x167) && (_game._objects.isInRoom(OBJ_TARGET_MODULE) || _game._trigger)) {
@@ -3127,7 +3127,7 @@ void Scene410::preActions() {
 }
 
 void Scene410::actions() {
-	if (_action.isAction(0x242, 0x2B3))
+	if (_action.isAction(VERB_WALK_INTO, 0x2B3))
 		_scene->_nextSceneId = 406;
 	else if (_action.isAction(VERB_TAKE, 0x48) && (_game._objects.isInRoom(OBJ_CHARGE_CASES) || _game._trigger)) {
 		switch (_game._trigger) {
@@ -3704,7 +3704,7 @@ void Scene411::actions() {
 		return;
 	}
 
-	if (_action.isAction(0x242, 0x2B3)) {
+	if (_action.isAction(VERB_WALK_INTO, 0x2B3)) {
 		_scene->_nextSceneId = 406;
 		_vm->_sound->command(10);
 		_action._inProgress = false;
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index 44363ec..ef7ef89 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -279,7 +279,7 @@ void Scene501::preActions() {
 }
 
 void Scene501::actions() {
-	if (_action.isAction(0x36A, 0x324)) {
+	if (_action.isAction(VERB_GET_INTO, 0x324)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -544,7 +544,7 @@ void Scene503::enter() {
 }
 
 void Scene503::actions() {
-	if (_action.isAction(0x32F, 0xF9))
+	if (_action.isAction(VERB_WALK, 0xF9))
 		_scene->_nextSceneId = 501;
 	else if (_action.isAction(VERB_TAKE, 0x6A)) {
 		if ( _game._trigger || !_game._objects.isInInventory(OBJ_DETONATORS)) {
@@ -626,7 +626,7 @@ void Scene503::actions() {
 		_vm->_dialogs->show(50327);
 	else if (_action.isAction(VERB_OPEN, 0x36D))
 		_vm->_dialogs->show(50329);
-	else if (_action.isAction(0xC, 0x36D) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId)))
+	else if (_action.isAction(VERB_THROW, 0x36D) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId)))
 		_vm->_dialogs->show(50330);
 	else
 		return;
@@ -1186,7 +1186,7 @@ void Scene506::room_506_door_sequences() {
 	_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 
 	if (_firstDoorFl) {
-		if (_action.isAction(0x242, 0x336) || ((_scene->_priorSceneId == 507) && !_actionFl)) {
+		if (_action.isAction(VERB_WALK_INTO, 0x336) || ((_scene->_priorSceneId == 507) && !_actionFl)) {
 			_doorDepth = 13;
 			_doorSpriteIdx = _globals._spriteIndexes[2];
 			_doorSequenceIdx = _globals._sequenceIndexes[2];
@@ -1266,21 +1266,21 @@ void Scene506::room_506_door_sequences() {
 }
 
 void Scene506::actions() {
-	if (_action.isAction(0x242, 0x37D)) {
+	if (_action.isAction(VERB_WALK_INTO, 0x37D)) {
 		if (_firstDoorFl) {
 			_heroFacing = FACING_NORTHWEST;
 			_doorPos = Common::Point(16, 111);
 		}
 		_actionFl = true;
 		room_506_door_sequences();
-	} else if (_action.isAction(0x242, 0x336)) {
+	} else if (_action.isAction(VERB_WALK_INTO, 0x336)) {
 		if (_firstDoorFl) {
 			_heroFacing = FACING_NORTHWEST;
 			_doorPos = Common::Point(80, 102);
 		}
 		_actionFl = true;
 		room_506_door_sequences();
-	} else if (_action.isAction(0x36A, 0x324)) {
+	} else if (_action.isAction(VERB_GET_INTO, 0x324)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1528,7 +1528,7 @@ void Scene508::enter() {
 }
 
 void Scene508::preActions() {
-	if (_action.isAction(0x32F, 0xF9))
+	if (_action.isAction(VERB_WALK, 0xF9))
 		_game._player._walkOffScreenSceneId = 506;
 }
 
@@ -1882,9 +1882,9 @@ void Scene511::preActions() {
 }
 
 void Scene511::actions() {
-	if (_action.isAction(0x242, 0x372))
+	if (_action.isAction(VERB_WALK_INTO, 0x372))
 		_scene->_nextSceneId = 512;
-	else if (_action.isAction(0x36A, 0x324)) {
+	else if (_action.isAction(VERB_GET_INTO, 0x324)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -2004,7 +2004,7 @@ void Scene511::actions() {
 		_vm->_dialogs->show(51117);
 	else if (_action.isAction(VERB_LOOK, 0x37C))
 		_vm->_dialogs->show(51118);
-	else if (_action.isAction(0x17B, 0xFF, 0x37C) || _action.isAction(0x17B, 0x6F, 0x37C))
+	else if (_action.isAction(VERB_UNLOCK, 0xFF, 0x37C) || _action.isAction(VERB_UNLOCK, 0x6F, 0x37C))
 		_vm->_dialogs->show(51119);
 	else if ( (_action.isAction(VERB_PUT) || _action.isAction(VERB_THROW))
 		 && (_action.isAction(0x171) || _action.isAction(0x2A) || _action.isAction(0x2B))
@@ -2102,7 +2102,7 @@ void Scene512::enter() {
 }
 
 void Scene512::actions() {
-	if (_action.isAction(0x32F, 0xF9))
+	if (_action.isAction(VERB_WALK, 0xF9))
 		_scene->_nextSceneId = 511;
 	else if (_action.isAction(VERB_TAKE, 0x88)) {
 		if (_game._trigger || !_game._objects.isInInventory(OBJ_FISHING_ROD)) {
@@ -2436,7 +2436,7 @@ void Scene513::step() {
 }
 
 void Scene513::actions() {
-	if (_action.isAction(0x36A, 0x324)) {
+	if (_action.isAction(VERB_GET_INTO, 0x324)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index 0921ceb..5198984 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -395,7 +395,7 @@ void Scene602::actions() {
 		_safeMode = 2;
 		_cycleIndex = -1;
 		handleSafeActions();
-	} else if (_action.isAction(0x17B, 0x3A7, 0x3D3)) {
+	} else if (_action.isAction(VERB_UNLOCK, 0x3A7, 0x3D3)) {
 		if ((_globals[kSafeStatus] == 0) && (_game._difficulty != DIFFICULTY_HARD)) {
 			_safeMode = 3;
 			_cycleIndex = -2;
@@ -506,7 +506,7 @@ void Scene602::actions() {
 			_vm->_dialogs->show(60235);
 		else
 			_vm->_dialogs->show(60236);
-	} else if (_action.isAction(0x17B, 0x6F, 0x3D3) || _action.isAction(0x17B, 0xFF, 0x3D3))
+	} else if (_action.isAction(VERB_UNLOCK, 0x6F, 0x3D3) || _action.isAction(VERB_UNLOCK, 0xFF, 0x3D3))
 		_vm->_dialogs->show(60225);
 	else if (_action.isAction(VERB_PULL, 0x3D3))
 		_vm->_dialogs->show(60226);
@@ -2581,7 +2581,7 @@ void Scene609::enterStore() {
 }
 
 void Scene609::preActions() {
-	if (_action.isAction(0x17B, 0x6F, 0x425))
+	if (_action.isAction(VERB_UNLOCK, 0x6F, 0x425))
 		_game._player.walk(Common::Point(78, 99), FACING_NORTHWEST);
 }
 
@@ -2629,7 +2629,7 @@ void Scene609::actions() {
 			_videoDoorMode = 2;
 			enterStore();
 		}
-	} else if (_action.isAction(0x17B, 0x6F, 0x425)) {
+	} else if (_action.isAction(VERB_UNLOCK, 0x6F, 0x425)) {
 		_videoDoorMode = 1;
 		enterStore();
 	} else if (_action.isAction(0x325, 0x324)) {
@@ -4424,7 +4424,7 @@ void Scene612::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(0x17B, 0xFF, 0x45F)) {
+	} else if (_action.isAction(VERB_UNLOCK, 0xFF, 0x45F)) {
 		_cycleIndex = -2;
 		action = 1;
 		handleWinchMovement();


Commit: 0d09060fa8a08000116fb3defb0c930eb30c6526
    https://github.com/scummvm/scummvm/commit/0d09060fa8a08000116fb3defb0c930eb30c6526
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T04:50:35+03:00

Commit Message:
MADS: Replace more verbs with friendly names and fix usages of isAction

Changed paths:
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes7.cpp



diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index e385c6a..75e0077 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -39,8 +39,10 @@ enum {
 };
 
 enum Verb {
+	VERB_ACTIVATE       = 0x00E,
 	VERB_CAST           = 0x03D,
 	VERB_CLIMB_DOWN     = 0x04E,
+	VERB_CLIMB_THROUGH  = 0x04F,
 	VERB_CLIMB_UP       = 0x050,
 	VERB_DIVE_INTO      = 0x06D,
 	VERB_EAT            = 0x075,
@@ -57,6 +59,7 @@ enum Verb {
 	VERB_PEER_THROUGH   = 0x103,
 	VERB_PLAY           = 0x112,
 	VERB_PRESS          = 0x11A,
+	VERB_PRY            = 0x11C,
 	VERB_READ           = 0x11F,
 	VERB_SHOOT          = 0x13A,
 	VERB_SIT_IN         = 0x13F,
@@ -72,16 +75,22 @@ enum Verb {
 	VERB_WALK_THROUGH   = 0x18B,
 	VERB_WALK_TOWARDS   = 0x18C,
 	VERB_WALK_DOWN      = 0x1AD,
+	VERB_LEAVE          = 0x1CD,
 	VERB_EXIT_FROM      = 0x1CE,
+	VERB_USE            = 0x20C,
+	VERB_SIT_AT         = 0x21F,
 	VERB_WALK_UP        = 0x227,
 	VERB_WALK_INTO      = 0x242,
 	VERB_EXIT           = 0x298,
 	VERB_WALK_ONTO      = 0x2B5,
+	VERB_RETURN_TO      = 0x2D5,
 	VERB_CLIMB_INTO     = 0x2F7,
 	VERB_STEP_INTO      = 0x2F9,
+	VERB_CRAWL_TO       = 0x2FB,
 	VERB_SIT_ON         = 0x30B,
 	VERB_WALK_ALONG     = 0x312,
 	VERB_WALK           = 0x32F,
+	VERB_REFLECT        = 0x365,
 	VERB_GET_INTO       = 0x36A,
 	VERB_ENTER          = 0x3B8,
 	VERB_INSTALL        = 0x474,
@@ -103,6 +112,7 @@ enum Noun {
 	NOUN_CONTROL_PANEL  = 0x59,
 	NOUN_DEAD_FISH		= 0x65,
 	NOUN_DOOR			= 0x6E,
+	NOUN_DRAWER         = 0x71,
 	NOUN_ENTER_KEY      = 0x7A,
 	NOUN_FISHING_LINE	= 0x87,
 	NOUN_FISHING_ROD    = 0x88,
@@ -121,7 +131,7 @@ enum Noun {
 	NOUN_OUTSIDE		= 0x0F9,
 	NOUN_PIRANHA        = 0x10D,
 	NOUN_PLANT_STALK	= 0x10F,
-	NOUN_REFRIDGERATOR	= 0x122,
+	NOUN_REFRIGERATOR	= 0x122,
 	NOUN_ROBO_KITCHEN	= 0x127,
 	NOUN_ROCK           = 0x128,
 	NOUN_ROCKS          = 0x129,
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index c2765ea..7c4af52 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -475,7 +475,7 @@ void Scene101::actions() {
 		return;
 	}
 
-	if ((_action.isAction(VERB_LOOK) || _action.isAction(VERB_PEER_THROUGH)) && (_action.isAction(0x8E) || _action.isAction(0xF9))) {
+	if ((_action.isAction(VERB_LOOK) || _action.isAction(VERB_PEER_THROUGH)) && (_action.isObject(NOUN_FRONT_WINDOW) || _action.isObject(NOUN_OUTSIDE))) {
 		_vm->_dialogs->show(10102);
 		_action._inProgress = false;
 		return;
@@ -595,7 +595,7 @@ void Scene101::actions() {
 		return;
 	}
 
-	if ((_action.isAction(VERB_LOOK) || _action.isAction(VERB_PLAY)) && _action.isAction(0x17E)) {
+	if ((_action.isAction(VERB_LOOK) || _action.isAction(VERB_PLAY)) && _action.isObject(0x17E)) {
 		_vm->_dialogs->show(10124);
 		_action._inProgress = false;
 		return;
@@ -758,10 +758,10 @@ void Scene102::step() {
 }
 
 void Scene102::preActions() {
-	if (_action.isAction(0x122) || _action.isAction(0x117))
+	if (_action.isObject(0x122) || _action.isObject(0x117))
 		_game._player._needToWalk = _game._player._readyToWalk;
 
-	if (_fridgeOpenedFl && !_action.isAction(0x122)) {
+	if (_fridgeOpenedFl && !_action.isObject(0x122)) {
 		switch (_game._trigger) {
 		case 0:
 			if (_game._player._needToWalk) {
@@ -798,7 +798,7 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isObject(0x122) && !_fridgeOpenedFl) {
+	if (_action.isObject(NOUN_REFRIGERATOR) && !_fridgeOpenedFl) {
 		switch (_game._trigger) {
 		case 0:
 			_globals._sequenceIndexes[7] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[7], false, 6, 1, 0, 0);
@@ -838,7 +838,7 @@ void Scene102::actions() {
 		}
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x122) || _action.isAction(VERB_OPEN, 0x122)) {
+	if (_action.isAction(VERB_LOOK, NOUN_REFRIGERATOR) || _action.isAction(VERB_OPEN, NOUN_REFRIGERATOR)) {
 		if (_game._objects.isInRoom(OBJ_BURGER))
 			_vm->_dialogs->show(10230);
 		else
@@ -849,7 +849,7 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_WALKTO, 0x122) && justOpenedFl) {
+	if (_action.isAction(VERB_WALKTO, NOUN_REFRIGERATOR) && justOpenedFl) {
 		_fridgeFirstOpenFl = false;
 		int quoteId = _vm->getRandomNumber(59, 63);
 		Common::String curQuote = _game.getQuote(quoteId);
@@ -863,13 +863,13 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_CLOSE, 0x122)) {
+	if (_action.isAction(VERB_CLOSE, NOUN_REFRIGERATOR)) {
 		_vm->_dialogs->show(10213);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_TAKE, 0x122)) {
+	if (_action.isAction(VERB_TAKE, NOUN_REFRIGERATOR)) {
 		_vm->_dialogs->show(8);
 		_action._inProgress = false;
 		return;
@@ -934,31 +934,31 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x127)) {
+	if (_action.isAction(VERB_LOOK, NOUN_ROBO_KITCHEN)) {
 		_vm->_dialogs->show(10215);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_PUT, 0x35, 0x127) && _game._objects.isInInventory(OBJ_BURGER)) {
+	if (_action.isAction(VERB_PUT, NOUN_BURGER, NOUN_ROBO_KITCHEN) && _game._objects.isInInventory(OBJ_BURGER)) {
 		_vm->_dialogs->show(10216);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_PUT, 0x122) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
+	if (_action.isAction(VERB_PUT, NOUN_REFRIGERATOR) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
 		_vm->_dialogs->show(10217);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_PUT, 0x127) && (_action.isAction(0x65) || _action.isAction(0x157))) {
+	if (_action.isAction(VERB_PUT, NOUN_DEAD_FISH, NOUN_ROBO_KITCHEN) || _action.isAction(VERB_PUT, NOUN_STUFFED_FISH, NOUN_ROBO_KITCHEN)) {
 		_vm->_dialogs->show(10230);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_OPEN, 0x127)) {
+	if (_action.isAction(VERB_OPEN, NOUN_ROBO_KITCHEN)) {
 		_vm->_dialogs->show(10218);
 		_action._inProgress = false;
 		return;
@@ -970,9 +970,9 @@ void Scene102::actions() {
 		return;
 	}
 
-	if ((_action.isObject(0xC7) || _action.isObject(0xA3)) && (_action.isAction(VERB_LOOK) || _action.isAction(VERB_CLIMB_UP) || _action.isAction(0x4F))) {
+	if ((_action.isObject(NOUN_LADDER) || _action.isObject(0xA3)) && (_action.isAction(VERB_LOOK) || _action.isAction(VERB_CLIMB_UP) || _action.isAction(VERB_CLIMB_THROUGH))) {
 		if (_game._objects.isInInventory(OBJ_REBREATHER)) {
-			if (!_action.isAction(VERB_CLIMB_UP) && !_action.isAction(0x4F)) {
+			if (!_action.isAction(VERB_CLIMB_UP) && !_action.isAction(VERB_CLIMB_THROUGH)) {
 				_vm->_dialogs->show(10231);
 				_action._inProgress = false;
 				return;
@@ -984,7 +984,7 @@ void Scene102::actions() {
 		}
 	}
 
-	if ((_action.isObject(0xC7) || _action.isObject(0xA3)) && (_action.isAction(VERB_CLIMB_UP) || _action.isAction(0x4F)) ) {
+	if ((_action.isObject(NOUN_LADDER) || _action.isObject(0xA3)) && (_action.isAction(VERB_CLIMB_UP) || _action.isAction(VERB_CLIMB_THROUGH)) ) {
 		switch (_game._trigger) {
 		case 0:
 			_scene->loadAnimation(formAnimName('A', -1), 1);
@@ -1037,20 +1037,20 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x71) || ((_action.isAction(VERB_CLOSE, 0x71) || _action.isAction(VERB_PUSH, 0x71)) && !_drawerDescrFl)) {
+	if (_action.isAction(VERB_LOOK, NOUN_DRAWER) || ((_action.isAction(VERB_CLOSE, NOUN_DRAWER) || _action.isAction(VERB_PUSH, NOUN_DRAWER)) && !_drawerDescrFl)) {
 		_vm->_dialogs->show(10220);
 		_drawerDescrFl = true;
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_CLOSE, 0x71) || _action.isAction(VERB_PUSH, 0x71)) {
+	if (_action.isAction(VERB_CLOSE, NOUN_DRAWER) || _action.isAction(VERB_PUSH, NOUN_DRAWER)) {
 		_vm->_dialogs->show(10221);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_OPEN, 0x71)) {
+	if (_action.isAction(VERB_OPEN, NOUN_DRAWER)) {
 		_vm->_dialogs->show(10236);
 		_action._inProgress = false;
 		return;
@@ -1177,7 +1177,7 @@ void Scene102::actions() {
 		return;
 	}
 
-	if ((_action.isAction(VERB_PUSH) || _action.isAction(VERB_PULL)) && _action.isAction(0x194)) {
+	if ((_action.isAction(VERB_PUSH) || _action.isAction(VERB_PULL)) && _action.isObject(0x194)) {
 		_vm->_dialogs->show(10225);
 		_action._inProgress = false;
 		return;
@@ -1849,7 +1849,7 @@ void Scene105::preActions() {
 	if (_action.isAction(VERB_SWIM_TOWARDS, 0xF5))
 		_game._player._walkOffScreenSceneId = 107;
 
-	if (_action.isAction(0xE0) && (_action.isAction(VERB_TALKTO) || _action.isAction(VERB_LOOK)))
+	if (_action.isObject(0xE0) && (_action.isAction(VERB_TALKTO) || _action.isAction(VERB_LOOK)))
 		_game._player._needToWalk = false;
 }
 
@@ -2085,7 +2085,7 @@ void Scene106::actions() {
 		_vm->_dialogs->show(10605);
 	else if (_action.isAction(VERB_LOOK, 0x109) || _action.isAction(VERB_LOOK_AT, 0x109))
 		_vm->_dialogs->show(10606);
-	else if (_action.isAction(0x109) && (_action.isAction(VERB_PUSH) || _action.isAction(VERB_PULL) || _action.isAction(VERB_TAKE)))
+	else if (_action.isObject(0x109) && (_action.isAction(VERB_PUSH) || _action.isAction(VERB_PULL) || _action.isAction(VERB_TAKE)))
 		_vm->_dialogs->show(10607);
 	else if (_action.isAction(VERB_LOOK, 0x139) || _action.isAction(VERB_LOOK_AT, 0x139))
 		_vm->_dialogs->show(10608);
@@ -2692,7 +2692,7 @@ void Scene109::actions() {
 		_vm->_dialogs->show(10901);
 	else if (_action.isAction(VERB_LOOK, 0x5A))
 		_vm->_dialogs->show(10902);
-	else if ((_action.isAction(VERB_TAKE) || _action.isAction(VERB_PULL)) && _action.isAction(0x5A))
+	else if ((_action.isAction(VERB_TAKE) || _action.isAction(VERB_PULL)) && _action.isObject(0x5A))
 		_vm->_dialogs->show(10903);
 	else if (_action.isAction(VERB_LOOK, 0x129))
 		_vm->_dialogs->show(10904);
@@ -2992,7 +2992,7 @@ void Scene111::actions() {
 		_vm->_dialogs->show(11104);
 	else if (_action.isAction(VERB_LOOK, 0xC8))
 		_vm->_dialogs->show(11105);
-	else if ((_action.isAction(VERB_PULL) || _action.isAction(VERB_TAKE)) && (_action.isAction(0x153) || _action.isAction(0xC8)))
+	else if ((_action.isAction(VERB_PULL) || _action.isAction(VERB_TAKE)) && (_action.isObject(0x153) || _action.isObject(0xC8)))
 		_vm->_dialogs->show(11106);
 	else
 		return;
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index b0085d5..00de84e 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -884,7 +884,7 @@ void Scene307::actions() {
 			setDialogNode(node);
 			break;
 		}
-	} else if (_action.isAction(0x11C, 0x12C, 0x11)) {
+	} else if (_action.isAction(VERB_PRY, 0x12C, 0x11)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1042,9 +1042,9 @@ void Scene307::actions() {
 				break;
 			}
 		}
-	} else if (_action.isAction(0x20C, 0x21B) && (_game._storyMode != STORYMODE_NAUGHTY))
+	} else if (_action.isAction(VERB_USE, 0x21B) && (_game._storyMode != STORYMODE_NAUGHTY))
 		_vm->_dialogs->show(30723);
-	else if (_action.isAction(0x20C, 0x21B)) {
+	else if (_action.isAction(VERB_USE, 0x21B)) {
 		if (!_afterPeeingFl) {
 			switch (_game._trigger) {
 			case 0:
@@ -1696,7 +1696,7 @@ void Scene311::actions() {
 		_checkGuardFl = false;
 		_scene->_kernelMessages.reset();
 		_scene->_kernelMessages.addQuote(0xFA, 120, 0);
-	} else if (_action.isAction(0x21F, 0x1E4))
+	} else if (_action.isAction(VERB_SIT_AT, 0x1E4))
 		_scene->_nextSceneId = 320;
 	else if (_action.isAction(VERB_CLIMB_INTO, 0x11)) {
 		switch (_game._trigger) {
@@ -1866,24 +1866,24 @@ void Scene313::enter() {
 }
 
 void Scene313::actions() {
-	if (_action.isAction(0x2FB, 0x2FC))
+	if (_action.isAction(VERB_CRAWL_TO, 0x2FC))
 		_scene->_nextSceneId = 387;
-	else if (_action.isAction(0x2FB, 0x2FD))
+	else if (_action.isAction(VERB_CRAWL_TO, 0x2FD))
 		_scene->_nextSceneId = 388;
-	else if (_action.isAction(0x2FB, 0x2FE)) {
+	else if (_action.isAction(VERB_CRAWL_TO, 0x2FE)) {
 		if (_globals[kAfterHavoc])
 			_scene->_nextSceneId = 399;
 		else
 			_scene->_nextSceneId = 389;
-	} else if (_action.isAction(0x2FB, 0x2FF))
+	} else if (_action.isAction(VERB_CRAWL_TO, 0x2FF))
 		_scene->_nextSceneId = 390;
-	else if (_action.isAction(0x2FB, 0x2EF)) {
+	else if (_action.isAction(VERB_CRAWL_TO, 0x2EF)) {
 		if (_globals[kSexOfRex] == REX_FEMALE) {
 			_globals[kSexOfRex] = REX_MALE;
 			_vm->_dialogs->show(31301);
 		}
 		_scene->_nextSceneId = 391;
-	} else if (_action.isAction(0x2FB, 0x300)) {
+	} else if (_action.isAction(VERB_CRAWL_TO, 0x300)) {
 		if (_globals[kSexOfRex] == REX_FEMALE) {
 			_globals[kSexOfRex] = REX_MALE;
 			_vm->_dialogs->show(31301);
@@ -3642,10 +3642,10 @@ void Scene320::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(32011);
 	else if ((_action.isAction(VERB_PRESS) || _action.isAction(VERB_PUSH)) &&
-		(_action.isAction(0x2E8) || _action.isAction(0x2E9) || _action.isAction(0x2EA) || _action.isAction(0x2EB) ||
-		 _action.isAction(0x2DE) || _action.isAction(0x2DD) || _action.isAction(0x2E0) || _action.isAction(0x2E1) ||
-		 _action.isAction(0x2E2) || _action.isAction(0x2E3) || _action.isAction(0x2E4) || _action.isAction(0x2E5) ||
-		 _action.isAction(0x2E6) || _action.isAction(0x2E7)
+		(_action.isObject(0x2E8) || _action.isObject(0x2E9) || _action.isObject(0x2EA) || _action.isObject(0x2EB) ||
+		 _action.isObject(0x2DE) || _action.isObject(0x2DD) || _action.isObject(0x2E0) || _action.isObject(0x2E1) ||
+		 _action.isObject(0x2E2) || _action.isObject(0x2E3) || _action.isObject(0x2E4) || _action.isObject(0x2E5) ||
+		 _action.isObject(0x2E6) || _action.isObject(0x2E7)
 		)) {
 		switch (_game._trigger) {
 		case 0:
@@ -3709,7 +3709,7 @@ void Scene320::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(0x1CD, 0x2EF))
+	} else if (_action.isAction(VERB_LEAVE, 0x2EF))
 		_scene->_nextSceneId = 311;
 	else if (_action.isAction(VERB_LOOK, 0x2DC))
 		_vm->_dialogs->show(32001);
@@ -5358,7 +5358,7 @@ void Scene361::preActions() {
 void Scene361::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(36119);
-	else if (_action.isAction(0x21F, 0x1E4)) {
+	else if (_action.isAction(VERB_SIT_AT, 0x1E4)) {
 		_scene->_kernelMessages.reset();
 		_scene->_kernelMessages.addQuote(0xFC, 120, 0);
 	} else if (_action.isAction(VERB_CLIMB_INTO, 0x11)) {
@@ -5406,7 +5406,7 @@ void Scene366::enter() {
 }
 
 void Scene366::actions() {
-	if (_action.isAction(0x2D5, 0x2D4))
+	if (_action.isAction(VERB_RETURN_TO, 0x2D4))
 		_scene->_nextSceneId = 302;
 	else if (_action.isAction(VERB_OPEN, 0x2D3)) {
 		if (_game._visitedScenes.exists(316))
@@ -5441,7 +5441,7 @@ void Scene387::enter() {
 }
 
 void Scene387::actions() {
-	if (_action.isAction(0x2D5, 0x2D4))
+	if (_action.isAction(VERB_RETURN_TO, 0x2D4))
 		_scene->_nextSceneId = 313;
 	else if (_action.isAction(VERB_LOOK_THROUGH, 0x2D3))
 		_vm->_dialogs->show(38710);
@@ -5479,7 +5479,7 @@ void Scene388::enter() {
 }
 
 void Scene388::actions() {
-	if (_action.isAction(0x2D5, 0x2D4))
+	if (_action.isAction(VERB_RETURN_TO, 0x2D4))
 		_scene->_nextSceneId = 313;
 	else if (_action.isAction(VERB_TALKTO, 0x303)) {
 		switch (_game._trigger) {
@@ -5556,7 +5556,7 @@ void Scene389::step() {
 }
 
 void Scene389::actions() {
-	if (_action.isAction(0x2D5, 0x2D4))
+	if (_action.isAction(VERB_RETURN_TO, 0x2D4))
 		_scene->_nextSceneId = 313;
 	else if (_action.isAction(VERB_TALKTO, 0x304)) {
 		switch (_game._trigger) {
@@ -5617,7 +5617,7 @@ void Scene390::enter() {
 }
 
 void Scene390::actions() {
-	if (_action.isAction(0x2D5, 0x2D4))
+	if (_action.isAction(VERB_RETURN_TO, 0x2D4))
 		_scene->_nextSceneId = 313;
 	else if (_action.isAction(VERB_LOOK_THROUGH, 0x2D3))
 		_vm->_dialogs->show(39010);
@@ -5643,7 +5643,7 @@ void Scene391::enter() {
 }
 
 void Scene391::actions() {
-	if (_action.isAction(0x2D5, 0x2D4))
+	if (_action.isAction(VERB_RETURN_TO, 0x2D4))
 		_scene->_nextSceneId = 313;
 	else if (_action.isAction(VERB_OPEN, 0x2D3)) {
 		if (_globals[kKickedIn391Grate])
@@ -5682,7 +5682,7 @@ void Scene399::enter() {
 }
 
 void Scene399::actions() {
-	if (_action.isAction(0x2D5, 0x2D4))
+	if (_action.isAction(VERB_RETURN_TO, 0x2D4))
 		_scene->_nextSceneId = 313;
 	else if (_action.isAction(VERB_LOOK_THROUGH, 0x2D3)) {
 		if (_globals[kAfterHavoc]) {
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index ef7ef89..ef50e12 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -274,7 +274,7 @@ void Scene501::step() {
 }
 
 void Scene501::preActions() {
-	if (_action.isAction(VERB_WALK_DOWN) && (_action.isAction(0x321) || _action.isAction(0x322)))
+	if (_action.isAction(VERB_WALK_DOWN) && (_action.isObject(0x321) || _action.isObject(0x322)))
 		_game._player._walkOffScreenSceneId = 551;
 }
 
@@ -745,7 +745,7 @@ void Scene504::actions() {
 	if (_action.isAction(VERB_EXIT_FROM, 0x324)) {
 		_vm->_sound->command(15);
 		_scene->_nextSceneId = _globals[kHoverCarLocation];
-	} else if (_action.isAction(0xE, 0x380)) {
+	} else if (_action.isAction(VERB_ACTIVATE, 0x380)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1073,7 +1073,7 @@ void Scene505::step() {
 void Scene505::actions() {
 	if (_action.isAction(VERB_PRESS))
 		_nextButtonId = _action._activeAction._objectNameId;
-	else if (_action.isAction(0x2D5, 0x38C))
+	else if (_action.isAction(VERB_RETURN_TO, 0x38C))
 		_scene->_nextSceneId = 504;
 	else if (_action.isAction(VERB_LOOK, 0x180))
 		_vm->_dialogs->show(50510);
@@ -1651,10 +1651,10 @@ void Scene508::actions() {
 		} else {
 			_vm->_dialogs->show(50837);
 		}
-	} else if (_action.isAction(0x365, 0x120, 0x343) || _action.isAction(VERB_PUT, 0x120, 0x344) || _action.isAction(VERB_PUT, 0x120, 0x343)) {
+	} else if (_action.isAction(VERB_REFLECT, 0x120, 0x343) || _action.isAction(VERB_PUT, 0x120, 0x344) || _action.isAction(VERB_PUT, 0x120, 0x343)) {
 		_chosenObject = 1;
 		handlePedestral();
-	} else if (_action.isAction(VERB_PUT, 0x57, 0x344) || _action.isAction(VERB_PUT, 0x57, 0x343) || _action.isAction(0x365, 0x57, 0x343)) {
+	} else if (_action.isAction(VERB_PUT, 0x57, 0x344) || _action.isAction(VERB_PUT, 0x57, 0x343) || _action.isAction(VERB_REFLECT, 0x57, 0x343)) {
 		_chosenObject = 2;
 		handlePedestral();
 	} else if (_action._lookFlag)
@@ -2681,7 +2681,7 @@ void Scene551::step() {
 }
 
 void Scene551::preActions() {
-	if (_action.isAction(VERB_WALK_DOWN) && (_action.isAction(0x360) || _action.isAction(0x361)))
+	if (_action.isAction(VERB_WALK_DOWN) && (_action.isObject(0x360) || _action.isObject(0x361)))
 		_game._player._walkOffScreenSceneId = 501;
 }
 
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index 5198984..a8f9ac1 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -402,7 +402,7 @@ void Scene602::actions() {
 			handleSafeActions();
 		}
 	} else if ((_action.isAction(VERB_PUT, 0x120, 0x343) || _action.isAction(VERB_PUT, 0x57, 0x343)
-		|| _action.isAction(0x365, 0x57, 0x343) || _action.isAction(0x365, 0x120, 0x343)) && (_globals[kSafeStatus] == 0)) {
+		|| _action.isAction(VERB_REFLECT, 0x57, 0x343) || _action.isAction(VERB_REFLECT, 0x120, 0x343)) && (_globals[kSafeStatus] == 0)) {
 		switch (_game._trigger) {
 		case 0:
 			_vm->_dialogs->show(60230);
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 07230ea..2d85b2e 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -1625,7 +1625,7 @@ void Scene705::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(0x4F, 0x197)) {
+	} else if (_action.isAction(VERB_CLIMB_THROUGH, 0x197)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;


Commit: e409f4dedd989b49184a865f59dc152e85303489
    https://github.com/scummvm/scummvm/commit/e409f4dedd989b49184a865f59dc152e85303489
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T05:43:49+03:00

Commit Message:
MADS: Add debugger commands for the game vocab

Changed paths:
    engines/mads/debugger.cpp
    engines/mads/debugger.h
    engines/mads/scene.cpp
    engines/mads/scene.h



diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp
index e3ddf02..8baafdd 100644
--- a/engines/mads/debugger.cpp
+++ b/engines/mads/debugger.cpp
@@ -39,6 +39,8 @@ Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) {
 	DCmd_Register("show_codes", WRAP_METHOD(Debugger, Cmd_ShowCodes));
 	DCmd_Register("dump_file", WRAP_METHOD(Debugger, Cmd_DumpFile));
 	DCmd_Register("show_quote", WRAP_METHOD(Debugger, Cmd_ShowQuote));
+	DCmd_Register("show_vocab", WRAP_METHOD(Debugger, Cmd_ShowVocab));
+	DCmd_Register("dump_vocab", WRAP_METHOD(Debugger, Cmd_DumpVocab));
 	DCmd_Register("item", WRAP_METHOD(Debugger, Cmd_Item));
 }
 
@@ -200,6 +202,46 @@ bool Debugger::Cmd_ShowQuote(int argc, const char **argv) {
 	return true;
 }
 
+bool Debugger::Cmd_ShowVocab(int argc, const char **argv) {
+	if (argc != 2) {
+		for (uint32 i = 0; i < _vm->_game->_scene.getVocabStringsCount(); i++) {
+			DebugPrintf("%03d: '%s'\n", i, _vm->_game->_scene.getVocab(i + 1).c_str());
+		}
+	} else {
+		int vocabId = strToInt(argv[1]);
+		DebugPrintf("%03d: '%s'\n", vocabId, _vm->_game->_scene.getVocab(vocabId + 1).c_str());
+	}
+
+	return true;
+}
+
+bool Debugger::Cmd_DumpVocab(int argc, const char **argv) {
+	Common::DumpFile outFile;
+	outFile.open("vocab.txt");
+
+	for (uint32 i = 0; i < _vm->_game->_scene.getVocabStringsCount(); i++) {
+		Common::String curId = Common::String::format("%x", i + 1);
+		Common::String curVocab = _vm->_game->_scene.getVocab(i + 1);
+		curVocab.toUppercase();
+
+		for (uint j = 0; j < curVocab.size(); j++) {
+			if (curVocab[j] == ' ' || curVocab[j] == '-')
+				curVocab.setChar('_', j);
+		}
+
+		Common::String cur = "\tNOUN_" + curVocab + " = 0x" + curId + ",\n";
+		
+		outFile.writeString(cur.c_str());
+	}
+
+	outFile.flush();
+	outFile.close();
+
+	DebugPrintf("Game vocab dumped\n");
+
+	return true;
+}
+
 bool Debugger::Cmd_Item(int argc, const char **argv) {
 	InventoryObjects &objects = _vm->_game->_objects;
 
diff --git a/engines/mads/debugger.h b/engines/mads/debugger.h
index 1982749..0c048f2 100644
--- a/engines/mads/debugger.h
+++ b/engines/mads/debugger.h
@@ -43,6 +43,8 @@ protected:
 	bool Cmd_ShowCodes(int argc, const char **argv);
 	bool Cmd_DumpFile(int argc, const char **argv);
 	bool Cmd_ShowQuote(int argc, const char **argv);
+	bool Cmd_ShowVocab(int argc, const char **argv);
+	bool Cmd_DumpVocab(int argc, const char **argv);
 	bool Cmd_Item(int argc, const char **argv);
 public:
 	bool _showMousePos;
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 84e4edc..0c241eb 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -254,6 +254,10 @@ void Scene::loadVocabStrings() {
 	f.close();
 }
 
+uint32 Scene::getVocabStringsCount() const {
+	return _vocabStrings.size();
+}
+
 void Scene::initPaletteAnimation(Common::Array<PaletteCycle> &palCycles, bool animFlag) {
 	// Initialize the animation palette and ticks list
 	_cycleTicks.clear();
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 69a2c0d..27fb901 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -152,6 +152,11 @@ public:
 	void addActiveVocab(int vocabId);
 
 	/**
+	 * Get the number of entries in the game's vocabulary
+	 */
+	uint32 getVocabStringsCount() const;
+
+	/**
 	 * Clear the sequence list
 	 */
 	void clearSequenceList();


Commit: 59d7f8bfc00456eb34357d2eba12223f80c0f0f9
    https://github.com/scummvm/scummvm/commit/59d7f8bfc00456eb34357d2eba12223f80c0f0f9
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T06:47:18+03:00

Commit Message:
MADS: Replace most of the action nouns with their friendly names

Changed paths:
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes8.cpp



diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index 75e0077..d97fa4b 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -98,93 +98,1203 @@ enum Verb {
 };
 
 enum Noun {
-	NOUN_BIG_LEAVES     = 0x23,
-	NOUN_BINOCULARS     = 0x27,
-	NOUN_BLOWGUN        = 0x29,
-	NOUN_BOMB           = 0x2A,
-	NOUN_BOMBS          = 0x2B,
-	NOUN_BONE           = 0x2C,
-	NOUN_BONES          = 0x2D,
-	NOUN_BURGER         = 0x35,
-	NOUN_CHAIR          = 0x47,
-	NOUN_CHICKEN        = 0x49,
-	NOUN_CHICKEN_BOMB   = 0x4A,
-	NOUN_CONTROL_PANEL  = 0x59,
-	NOUN_DEAD_FISH		= 0x65,
-	NOUN_DOOR			= 0x6E,
-	NOUN_DRAWER         = 0x71,
-	NOUN_ENTER_KEY      = 0x7A,
-	NOUN_FISHING_LINE	= 0x87,
-	NOUN_FISHING_ROD    = 0x88,
-	NOUN_FRONT_WINDOW	= 0x8E,
-	NOUN_FUZZY_DICE		= 0x91,
-	NOUN_HOTPANTS		= 0x0A7,
-	NOUN_HULL			= 0x0A8,
-	NOUN_ID_CARD        = 0x0B3,
-	NOUN_JUNGLE			= 0x0B8,
-	NOUN_KEYPAD         = 0x0C4,
-	NOUN_LADDER         = 0x0C7,
-	NOUN_LIFE_SUPPORT_SECTION  = 0x0CC,
-	NOUN_LOG			= 0x0D0,
-	NOUN_MONKEY			= 0x0E3,
-	NOUN_OUTER_HULL		= 0x0F8,
-	NOUN_OUTSIDE		= 0x0F9,
-	NOUN_PIRANHA        = 0x10D,
-	NOUN_PLANT_STALK	= 0x10F,
-	NOUN_REFRIGERATOR	= 0x122,
-	NOUN_ROBO_KITCHEN	= 0x127,
-	NOUN_ROCK           = 0x128,
-	NOUN_ROCKS          = 0x129,
-	NOUN_SHIELD_ACCESS_PANEL  = 0x135,
-	NOUN_SHIELD_MODULATOR	= 0x137,
-	NOUN_SKULL          = 0x140,
-	NOUN_TELEPORTER     = 0x16C,
-	NOUN_BROKEN_LADDER  = 0x1C9,
-	NOUN_STUFFED_FISH	= 0x157,
-	NOUN_15F            = 0x15F,
-	NOUN_TIMEBOMB       = 0x171,
-	NOUN_TWINKIFRUIT    = 0x17A,
-	NOUN_VIEW_SCREEN    = 0x180,
-	NOUN_VIEWPORT       = 0x181,
-	NOUN_DEEP_PIT       = 0x19E,
-	NOUN_HUGE_LEGS      = 0x1A8,
-	NOUN_LEAF_COVERED_PIT  = 0x1A9,
+	NOUN_GAME = 0x1,
+	NOUN_QSAVE = 0x2,
+	NOUN_LOOK = 0x3,
+	NOUN_TAKE = 0x4,
+	NOUN_PUSH = 0x5,
+	NOUN_OPEN = 0x6,
+	NOUN_PUT = 0x7,
+	NOUN_TALK_TO = 0x8,
+	NOUN_GIVE = 0x9,
+	NOUN_PULL = 0xA,
+	NOUN_CLOSE = 0xB,
+	NOUN_THROW = 0xC,
+	NOUN_WALK_TO = 0xD,
+	NOUN_ACTIVATE = 0xE,
+	NOUN_ADMIRE = 0xF,
+	NOUN_ADSM = 0x10,
+	NOUN_AIR_VENT = 0x11,
+	NOUN_ALOE_PLANT = 0x12,
+	NOUN_ANEMONE = 0x13,
+	NOUN_ANOMOMETER = 0x14,
+	NOUN_AREA_AROUND_HUT = 0x15,
+	NOUN_AREA_TO_SOUTH = 0x16,
+	NOUN_AREA_TO_WEST = 0x17,
+	NOUN_AROMATIC_MEAT = 0x18,
+	NOUN_ATTACH = 0x19,
+	NOUN_AUDIO_TAPE = 0x1A,
+	NOUN_AUXILIARY_POWER = 0x1B,
+	NOUN_BADMITTON_BRAT = 0x1C,
+	NOUN_BAG = 0x1D,
+	NOUN_BAMBOO_TREE = 0x1E,
+	NOUN_BATS = 0x1F,
+	NOUN_BAWLEMER_ORIOLE_HUN = 0x20,
+	NOUN_BEAR_RUG = 0x21,
+	NOUN_BEASTLY_TROPHY = 0x22,
+	NOUN_BIG_LEAVES = 0x23,
+	NOUN_BIG_PIPES = 0x24,
+	NOUN_BIG_SKY = 0x25,
+	NOUN_BIG_STONE = 0x26,
+	NOUN_BINOCULARS = 0x27,
+	NOUN_BIRDIES = 0x28,
+	NOUN_BLOWGUN = 0x29,
+	NOUN_BOMB = 0x2A,
+	NOUN_BOMBS = 0x2B,
+	NOUN_BONE = 0x2C,
+	NOUN_BONES = 0x2D,
+	NOUN_BOTTLE = 0x2E,
+	NOUN_BOULDER = 0x2F,
+	NOUN_BOULDERS = 0x30,
+	NOUN_BRA = 0x31,
+	NOUN_BREAK = 0x32,
+	NOUN_BREATHE_AIR = 0x33,
+	NOUN_BULKHEAD = 0x34,
+	NOUN_BURGER = 0x35,
+	NOUN_BURN = 0x36,
+	NOUN_BURNT_OUT_WARP_COIL = 0x37,
+	NOUN_BUSH_LIKE_FORMATION = 0x38,
+	NOUN_BUSHES = 0x39,
+	NOUN_BUSHY_FERN = 0x3A,
+	NOUN_CACTUS = 0x3B,
+	NOUN_CARD = 0x3C,
+	NOUN_CAST = 0x3D,
+	NOUN_CAULDRON = 0x3E,
+	NOUN_CAVE = 0x3F,
+	NOUN_CAVE_CEILING = 0x40,
+	NOUN_CAVE_ENTRANCE = 0x41,
+	NOUN_CAVE_EXIT = 0x42,
+	NOUN_CAVE_FLOOR = 0x43,
+	NOUN_CAVE_TO_EAST = 0x44,
+	NOUN_CAVE_WALL = 0x45,
+	NOUN_CEILING = 0x46,
+	NOUN_CHAIR = 0x47,
+	NOUN_CHARGE_CASES = 0x48,
+	NOUN_CHICKEN = 0x49,
+	NOUN_CHICKEN_BOMB = 0x4A,
+	NOUN_CLEARING_TO_EAST = 0x4B,
+	NOUN_CLEARING_TO_SOUTH = 0x4C,
+	NOUN_CLIFF_FACE = 0x4D,
+	NOUN_CLIMB_DOWN = 0x4E,
+	NOUN_CLIMB_THROUGH = 0x4F,
+	NOUN_CLIMB_UP = 0x50,
+	NOUN_CLOCK = 0x51,
+	NOUN_CLOSET = 0x52,
+	NOUN_CLOTHESLINE = 0x53,
+	NOUN_CLUMP_OF_TREES = 0x54,
+	NOUN_COAL = 0x55,
+	NOUN_COCOANUT = 0x56,
+	NOUN_COMPACT_CASE = 0x57,
+	NOUN_COMPUTER_GAME = 0x58,
+	NOUN_CONTROL_PANEL = 0x59,
+	NOUN_CORAL = 0x5A,
+	NOUN_CRAB = 0x5B,
+	NOUN_CREDIT_CHIP = 0x5C,
+	NOUN_CUMULOUS_CLOUD = 0x5D,
+	NOUN_CURIOUS_WEED_PATCH = 0x5E,
+	NOUN_CURTAIN = 0x5F,
+	NOUN_CURTAINS = 0x60,
+	NOUN_CUT = 0x61,
+	NOUN_DAMAGE_CONTROL = 0x62,
+	NOUN_DAMAGE_CONTROL_PANEL = 0x63,
+	NOUN_DAMPEN = 0x64,
+	NOUN_DEAD_FISH = 0x65,
+	NOUN_DEAD_PURPLE_MONSTER = 0x66,
+	NOUN_DECLIVITOUS_CHASM = 0x67,
+	NOUN_DEEP_DARK_FOREST = 0x68,
+	NOUN_DENSE_FOREST = 0x69,
+	NOUN_DETONATORS = 0x6A,
+	NOUN_DINO_MITE = 0x6B,
+	NOUN_DISASSEMBLE = 0x6C,
+	NOUN_DIVE_INTO = 0x6D,
+	NOUN_DOOR = 0x6E,
+	NOUN_DOOR_KEY = 0x6F,
+	NOUN_DOORWAY = 0x70,
+	NOUN_DRAWER = 0x71,
+	NOUN_DRINK = 0x72,
+	NOUN_DURAFAIL_CELLS = 0x73,
+	NOUN_EASTERN_CLIFF_FACE = 0x74,
+	NOUN_EAT = 0x75,
+	NOUN_EJECT = 0x76,
+	NOUN_EMPTY = 0x77,
+	NOUN_ENGINEERING_CONTROLS = 0x78,
+	NOUN_ENGINEERING_SECTION = 0x79,
+	NOUN_ENTER_KEY = 0x7A,
+	NOUN_ESCAPE_HATCH = 0x7B,
+	NOUN_ESTROTOXIN = 0x7C,
+	NOUN_EXAMINE = 0x7D,
+	NOUN_EXPERIMENT_CAGE = 0x7E,
+	NOUN_EXTINGUISH = 0x7F,
+	NOUN_FACE_ID = 0x80,
+	NOUN_FERN = 0x81,
+	NOUN_FIELD_TO_NORTH = 0x82,
+	NOUN_FIELD_TO_SOUTH = 0x83,
+	NOUN_FIELD_TO_WEST = 0x84,
+	NOUN_FILL = 0x85,
+	NOUN_FIRE_PIT = 0x86,
+	NOUN_FISHING_LINE = 0x87,
+	NOUN_FISHING_ROD = 0x88,
+	NOUN_FLOOR = 0x89,
+	NOUN_FLOOR_OF_HUT = 0x8A,
+	NOUN_FLOOR_TILE = 0x8B,
+	NOUN_FONDLE = 0x8C,
+	NOUN_FOREST_TO_EAST = 0x8D,
+	NOUN_FRONT_WINDOW = 0x8E,
+	NOUN_FUNGOIDS = 0x8F,
+	NOUN_FURNACE = 0x90,
+	NOUN_FUZZY_DICE = 0x91,
+	NOUN_GAZE = 0x92,
+	NOUN_GAZE_AT = 0x93,
+	NOUN_GAZE_IN = 0x94,
+	NOUN_GLANCE_AT = 0x95,
+	NOUN_GLOVE = 0x96,
+	NOUN_GNARLY_SHRUB = 0x97,
+	NOUN_GNAW_ON = 0x98,
+	NOUN_GORGE_ON = 0x99,
+	NOUN_GRAIN_ALCHOHOL = 0x9A,
+	NOUN_GRASSLAND_TO_EAST = 0x9B,
+	NOUN_GRASSLAND_TO_SOUTH = 0x9C,
+	NOUN_GRASSY_AREA = 0x9D,
+	NOUN_GRASSY_AREA_TO_NORTH = 0x9E,
+	NOUN_GRASSY_KNOLL = 0x9F,
+	NOUN_GRIND = 0xA0,
+	NOUN_GROOVILACTIC_TREE = 0xA1,
+	NOUN_GUARDS_ARM = 0xA2,
+	NOUN_HATCHWAY = 0xA3,
+	NOUN_HOOK_UP = 0xA4,
+	NOUN_HORIZON = 0xA5,
+	NOUN_HOSE_DOWN = 0xA6,
+	NOUN_HOTPANTS = 0xA7,
+	NOUN_HULL = 0xA8,
+	NOUN_HURL = 0xA9,
+	NOUN_HUT = 0xAA,
+	NOUN_HUT_AREA = 0xAB,
+	NOUN_HUT_TO_EAST = 0xAC,
+	NOUN_HUT_TO_SOUTH = 0xAD,
+	NOUN_HUT_TO_THE_SOUTH = 0xAE,
+	NOUN_HUT_TO_WEST = 0xAF,
+	NOUN_HUTS_TO_NORTH = 0xB0,
+	NOUN_HYDROSPANNER = 0xB1,
+	NOUN_HYPERDRIVE_JUMP_UNIT = 0xB2,
+	NOUN_ID_CARD = 0xB3,
+	NOUN_IGNITE = 0xB4,
+	NOUN_INFLATE = 0xB5,
+	NOUN_INSERT = 0xB6,
+	NOUN_INSPECT = 0xB7,
+	NOUN_JUNGLE = 0xB8,
+	NOUN_JUNGLE_TO_EAST = 0xB9,
+	NOUN_JUNGLE_TO_WEST = 0xBA,
+	NOUN_KEY_1 = 0xBB,
+	NOUN_KEY_2 = 0xBC,
+	NOUN_KEY_3 = 0xBD,
+	NOUN_KEY_4 = 0xBE,
+	NOUN_KEY_5 = 0xBF,
+	NOUN_KEY_6 = 0xC0,
+	NOUN_KEY_7 = 0xC1,
+	NOUN_KEY_8 = 0xC2,
+	NOUN_KEY_9 = 0xC3,
+	NOUN_KEYPAD = 0xC4,
+	NOUN_KNEELING_WOMAN = 0xC5,
+	NOUN_KNIFE = 0xC6,
+	NOUN_LADDER = 0xC7,
+	NOUN_LARGE_STALAGMITE = 0xC8,
+	NOUN_LEER_AT = 0xC9,
+	NOUN_LIBRARY_COMPUTER = 0xCA,
+	NOUN_LICK = 0xCB,
+	NOUN_LIFE_SUPPORT_SECTION = 0xCC,
+	NOUN_LIGHT = 0xCD,
+	NOUN_LOAD = 0xCE,
+	NOUN_LOCK = 0xCF,
+	NOUN_LOG = 0xD0,
+	NOUN_LOOK_AT = 0xD1,
+	NOUN_LOOK_IN = 0xD2,
+	NOUN_LOOK_THROUGH = 0xD3,
+	NOUN_LOUNGE_AREA = 0xD4,
+	NOUN_LOVE_ALTAR = 0xD5,
+	NOUN_LOWLANDS = 0xD6,
+	NOUN_MACHINE = 0xD7,
+	NOUN_MAGNET = 0xD8,
+	NOUN_MAIN_AIRLOCK = 0xD9,
+	NOUN_MANTA_RAY = 0xDA,
+	NOUN_MARSHY_WETLANDS = 0xDB,
+	NOUN_MATCH = 0xDC,
+	NOUN_MEDICAL_WASTE = 0xDD,
+	NOUN_MEDICINE_CABINET = 0xDE,
+	NOUN_MEN_WHO_CAME_BEFORE = 0xDF,
+	NOUN_MINE = 0xE0,
+	NOUN_MIRROR = 0xE1,
+	NOUN_MONITOR = 0xE2,
+	NOUN_MONKEY = 0xE3,
+	NOUN_MONKEY_LIVER_JUICE = 0xE4,
+	NOUN_MONSTER_SLUDGE = 0xE5,
+	NOUN_MOUNTAIN = 0xE6,
+	NOUN_MOUNTAIN_RANGE = 0xE7,
+	NOUN_MOUNTAINS = 0xE8,
+	NOUN_MTAM = 0xE9,
+	NOUN_MUSHROOMS = 0xEA,
+	NOUN_NAVIGATION_CONTROLS = 0xEB,
+	NOUN_NORTH_PATH = 0xEC,
+	NOUN_NORTHERN_EXPOSURE = 0xED,
+	NOUN_NORTHERN_SEA_CLIFF = 0xEE,
+	NOUN_OBSTACLE = 0xEF,
+	NOUN_OCEAN_FLOOR = 0xF0,
+	NOUN_ODD_ROCK_FORMATION = 0xF1,
+	NOUN_OOGLY_BOOGLY_JUICE = 0xF2,
+	NOUN_OPEN_AREA_TO_EAST = 0xF3,
+	NOUN_OPEN_AREA_TO_NORTH = 0xF4,
+	NOUN_OPEN_AREA_TO_SOUTH = 0xF5,
+	NOUN_OPEN_AREA_TO_WEST = 0xF6,
+	NOUN_OPEN_FIELD = 0xF7,
+	NOUN_OUTER_HULL = 0xF8,
+	NOUN_OUTSIDE = 0xF9,
+	NOUN_OVEN = 0xFA,
+	NOUN_OVERHANG_TO_EAST = 0xFB,
+	NOUN_OVERHANG_TO_WEST = 0xFC,
+	NOUN_OVERHEAD_LAMP = 0xFD,
+	NOUN_PAD_OF_PAPER = 0xFE,
+	NOUN_PADLOCK_KEY = 0xFF,
+	NOUN_PALM_TREE = 0x100,
+	NOUN_PASSAGE_WAY_TO_SOUTH = 0x101,
+	NOUN_PASSION_PUSS = 0x102,
+	NOUN_PEER_THROUGH = 0x103,
+	NOUN_PENCIL = 0x104,
+	NOUN_PENDULOUS_CRAG = 0x105,
+	NOUN_PENLIGHT = 0x106,
+	NOUN_PHONE_CELLS = 0x107,
+	NOUN_PHONE_HANDSET = 0x108,
+	NOUN_PILE_OF_ROCKS = 0x109,
+	NOUN_PILLOW = 0x10A,
+	NOUN_PILOTS_CHAIR = 0x10B,
+	NOUN_PIPE = 0x10C,
+	NOUN_PIRANHA = 0x10D,
+	NOUN_PLANT = 0x10E,
+	NOUN_PLANT_STALK = 0x10F,
+	NOUN_PLANTS = 0x110,
+	NOUN_PLASTIC_JESUS = 0x111,
+	NOUN_PLAY = 0x112,
+	NOUN_PLUNGER = 0x113,
+	NOUN_POISON_DARTS = 0x114,
+	NOUN_POLYCEMENT = 0x115,
+	NOUN_POOL = 0x116,
+	NOUN_POSTER = 0x117,
+	NOUN_POWER_STATUS_PANEL = 0x118,
+	NOUN_PRECIPICE = 0x119,
+	NOUN_PRESS = 0x11A,
+	NOUN_PRESSURE_GAUGE = 0x11B,
+	NOUN_PRY = 0x11C,
+	NOUN_RAGING_RIVER = 0x11D,
+	NOUN_RAMOLYAN_RUGBY_RATS = 0x11E,
+	NOUN_READ = 0x11F,
+	NOUN_REARVIEW_MIRROR = 0x120,
+	NOUN_REBREATHER = 0x121,
+	NOUN_REFRIGERATOR = 0x122,
+	NOUN_REMOTE = 0x123,
+	NOUN_REPAIR_LIST = 0x124,
+	NOUN_RIVER = 0x125,
+	NOUN_RIVER_TO_WEST = 0x126,
+	NOUN_ROBO_KITCHEN = 0x127,
+	NOUN_ROCK = 0x128,
+	NOUN_ROCKS = 0x129,
+	NOUN_ROCKY_AREA = 0x12A,
+	NOUN_ROLLING_HILL = 0x12B,
+	NOUN_SCALPEL = 0x12C,
+	NOUN_SCENIC_MOUNTAINS = 0x12D,
+	NOUN_SEA_CLIFF = 0x12E,
+	NOUN_SEAWEED = 0x12F,
+	NOUN_SEAWEED_BANK = 0x130,
+	NOUN_SECURITY_CARD = 0x131,
+	NOUN_SET = 0x132,
+	NOUN_SHAKE_HANDS = 0x133,
+	NOUN_SHARPEN = 0x134,
+	NOUN_SHIELD_ACCESS_PANEL = 0x135,
+	NOUN_SHIELD_GENERATOR = 0x136,
+	NOUN_SHIELD_MODULATOR = 0x137,
+	NOUN_SHIELD_STATUS_PANEL = 0x138,
+	NOUN_SHIP = 0x139,
+	NOUN_SHOOT = 0x13A,
+	NOUN_SHOVEL = 0x13B,
+	NOUN_SHRED = 0x13C,
+	NOUN_SHRUNKEN_HEADS = 0x13D,
+	NOUN_SINGED_MEAT = 0x13E,
+	NOUN_SIT_IN = 0x13F,
+	NOUN_SKULL = 0x140,
+	NOUN_SKULL_AND_CROSSBONES = 0x141,
+	NOUN_SKY = 0x142,
+	NOUN_SLEEP_ON = 0x143,
+	NOUN_SLITHERING_SNAKE = 0x144,
+	NOUN_SLUG_SECRETION = 0x145,
+	NOUN_SMALL_HOLE = 0x146,
+	NOUN_SMELL = 0x147,
+	NOUN_SNAKE = 0x148,
+	NOUN_SNIFF = 0x149,
+	NOUN_SOAK = 0x14A,
+	NOUN_SPECIAL_KEY_1 = 0x14B,
+	NOUN_SPECIAL_KEY_2 = 0x14C,
+	NOUN_SPIDER = 0x14D,
+	NOUN_SPILT_MILK = 0x14E,
+	NOUN_SPIT_FIRE = 0x14F,
+	NOUN_SPRAY = 0x150,
+	NOUN_STAB = 0x151,
+	NOUN_STAIRS = 0x152,
+	NOUN_STALAGMITES = 0x153,
+	NOUN_STAND_INSIDE = 0x154,
+	NOUN_STARE_AT = 0x155,
+	NOUN_STEPS = 0x156,
+	NOUN_STUFFED_FISH = 0x157,
+	NOUN_SURFACE = 0x158,
+	NOUN_SWIM_ACROSS = 0x159,
+	NOUN_SWIM_INTO = 0x15A,
+	NOUN_SWIM_THROUGH = 0x15B,
+	NOUN_SWIM_TO = 0x15C,
+	NOUN_SWIM_TOWARDS = 0x15D,
+	NOUN_SWIM_UNDER = 0x15E,
+	NOUN_SWOOPING_CREATURE = 0x15F,
+	NOUN_TABLE = 0x160,
+	NOUN_TAKE_LIVER = 0x161,
+	NOUN_TAKE_OFF = 0x162,
+	NOUN_TAKE_PAGE = 0x163,
+	NOUN_TALL_GRASS = 0x164,
+	NOUN_TAPE_PLAYER = 0x165,
+	NOUN_TARGET_COMPUTER = 0x166,
+	NOUN_TARGET_MODULE = 0x167,
+	NOUN_TARGETTING_COMPUTER = 0x168,
+	NOUN_TASMANIAN_DEVIL = 0x169,
+	NOUN_TASTY_TURKEY = 0x16A,
+	NOUN_TELEPORT_DEVICE = 0x16B,
+	NOUN_TELEPORTER = 0x16C,
+	NOUN_THATCHED_ROOF = 0x16D,
+	NOUN_THORNS = 0x16E,
+	NOUN_THORNY_BUSH = 0x16F,
+	NOUN_TIE = 0x170,
+	NOUN_TIMEBOMB = 0x171,
+	NOUN_TIMER = 0x172,
+	NOUN_TIMER_MODULE = 0x173,
+	NOUN_TREE = 0x174,
+	NOUN_TREES = 0x175,
+	NOUN_TRODDEN_PATH = 0x176,
+	NOUN_TUBE = 0x177,
+	NOUN_TUNNEL = 0x178,
+	NOUN_TWINKIE_BUSH = 0x179,
+	NOUN_TWINKIFRUIT = 0x17A,
+	NOUN_UNLOCK = 0x17B,
+	NOUN_UZI = 0x17C,
+	NOUN_VASE = 0x17D,
+	NOUN_VIDEO_GAME = 0x17E,
+	NOUN_VIEW = 0x17F,
+	NOUN_VIEW_SCREEN = 0x180,
+	NOUN_VIEWPORT = 0x181,
+	NOUN_VILLAGE_AREA = 0x182,
+	NOUN_VILLAGE_TO_WEST = 0x183,
+	NOUN_VOLCANO = 0x184,
+	NOUN_VULTURE = 0x185,
+	NOUN_WAD_OF_CATTLE_PARTS = 0x186,
+	NOUN_WALK_ACROSS = 0x187,
+	NOUN_WALK_INSIDE = 0x188,
+	NOUN_WALK_ON = 0x189,
+	NOUN_WALK_OUTSIDE = 0x18A,
+	NOUN_WALK_THROUGH = 0x18B,
+	NOUN_WALK_TOWARDS = 0x18C,
+	NOUN_WALL = 0x18D,
+	NOUN_WATCH_TOWER = 0x18E,
+	NOUN_WATER = 0x18F,
+	NOUN_WEAPONS_DISPLAY = 0x190,
+	NOUN_WEAR = 0x191,
+	NOUN_WEATHER_STATION = 0x192,
+	NOUN_WEATHER_VANE = 0x193,
+	NOUN_WEIGHT_MACHINE = 0x194,
+	NOUN_WESTERN_CLIFF_FACE = 0x195,
+	NOUN_WHEEL = 0x196,
+	NOUN_WINDOW = 0x197,
+	NOUN_WITCHDOCTOR_HUT = 0x198,
+	NOUN_WORKBENCH = 0x199,
+	NOUN_WRITE_ON = 0x19A,
+	NOUN_YELLOW_BIRDY = 0x19B,
+	NOUN_GRASS = 0x19C,
+	NOUN_BOUNCING_REPTILE = 0x19D,
+	NOUN_DEEP_PIT = 0x19E,
+	NOUN_LOWLANDS_TO_NORTH = 0x19F,
+	NOUN_SMALL_BUSH = 0x1A0,
+	NOUN_SMALL_CACTUS = 0x1A1,
+	NOUN_ROCKY_AREA_TO_NORTH = 0x1A2,
+	NOUN_BAMBOO_LIKE_PLANT = 0x1A3,
+	NOUN_MOUNTAINSIDE = 0x1A4,
+	NOUN_FIELD = 0x1A5,
+	NOUN_GRASSY_FIELD = 0x1A6,
+	NOUN_CRAG = 0x1A7,
+	NOUN_HUGE_LEGS = 0x1A8,
+	NOUN_LEAF_COVERED_PIT = 0x1A9,
 	NOUN_PILE_OF_LEAVES = 0x1AA,
+	NOUN_OPEN_FIELD_TO_EAST = 0x1AB,
+	NOUN_LAWN = 0x1AC,
+	NOUN_WALK_DOWN = 0x1AD,
+	NOUN_PATH_TO_WEST = 0x1AE,
+	NOUN_HEDGE = 0x1AF,
+	NOUN_VILLAGE_PATH = 0x1B0,
+	NOUN_PATH_TO_NORTHEAST = 0x1B1,
+	NOUN_JUNGLE_PATH = 0x1B2,
+	NOUN_THICK_UNDERGROWTH = 0x1B3,
+	NOUN_OCEAN = 0x1B4,
+	NOUN_OCEAN_IN_DISTANCE = 0x1B5,
 	NOUN_STRANGE_DEVICE = 0x1B6,
+	NOUN_BUSH = 0x1B7,
+	NOUN_ANEMOMETER = 0x1B8,
+	NOUN_ISLAND_IN_DISTANCE = 0x1B9,
+	NOUN_PATH = 0x1BA,
+	NOUN_TROPHY = 0x1BB,
+	NOUN_SPECIMEN_JARS = 0x1BC,
+	NOUN_BOWL = 0x1BD,
+	NOUN_LARGE_BOWL = 0x1BE,
+	NOUN_PATH_TO_NORTH = 0x1BF,
+	NOUN_HUT_TO_NORTH = 0x1C0,
+	NOUN_PATH_TO_EAST = 0x1C1,
+	NOUN_CHICKEN_ON_SPIT = 0x1C2,
 	NOUN_CAPTIVE_CREATURE = 0x1C3,
-	NOUN_DISPLAY        = 0x1CC,
-	NOUN_DEVICE         = 0x1CF,
-	NOUN_0_KEY          = 0x1D0,
-	NOUN_1_KEY          = 0x1D1,
-	NOUN_2_KEY          = 0x1D2,
-	NOUN_3_KEY          = 0x1D3,
-	NOUN_4_KEY          = 0x1D4,
-	NOUN_5_KEY          = 0x1D5,
-	NOUN_6_KEY          = 0x1D6,
-	NOUN_7_KEY          = 0x1D7,
-	NOUN_8_KEY          = 0x1D8,
-	NOUN_9_KEY          = 0x1D9,
-	NOUN_FROWN_KEY      = 0x1DA,
-	NOUN_SMILE_KEY      = 0x1DB,
-	NOUN_NATIVE_WOMAN	= 0x1DC,
-	NOUN_PLATFORM       = 0x22C,
-	NOUN_ALCOHOL        = 0x310,
+	NOUN_TWINKIFRUIT_BUSH = 0x1C4,
+	NOUN_STREAM = 0x1C5,
+	NOUN_OPPOSITE_SHORE = 0x1C6,
+	NOUN_PATH_TO_SOUTH = 0x1C7,
+	NOUN_OPPOSITE_BANK = 0x1C8,
+	NOUN_BROKEN_LADDER = 0x1C9,
+	NOUN_BAG_OF_TWINKIFRUITS = 0x1CA,
+	NOUN_BED = 0x1CB,
+	NOUN_DISPLAY = 0x1CC,
+	NOUN_LEAVE = 0x1CD,
+	NOUN_EXIT_FROM = 0x1CE,
+	NOUN_DEVICE = 0x1CF,
+	NOUN_0_KEY = 0x1D0,
+	NOUN_1_KEY = 0x1D1,
+	NOUN_2_KEY = 0x1D2,
+	NOUN_3_KEY = 0x1D3,
+	NOUN_4_KEY = 0x1D4,
+	NOUN_5_KEY = 0x1D5,
+	NOUN_6_KEY = 0x1D6,
+	NOUN_7_KEY = 0x1D7,
+	NOUN_8_KEY = 0x1D8,
+	NOUN_9_KEY = 0x1D9,
+	NOUN_FROWN_KEY = 0x1DA,
+	NOUN_SMILE_KEY = 0x1DB,
+	NOUN_NATIVE_WOMAN = 0x1DC,
+	NOUN_YELLOW_BIRD = 0x1DD,
+	NOUN_BLEEPER = 0x1DE,
+	NOUN_SIZEMOMETER = 0x1DF,
+	NOUN_PANEL = 0x1E0,
+	NOUN_PRINTER = 0x1E1,
+	NOUN_HARD_DRIVE = 0x1E2,
+	NOUN_BATHROOM = 0x1E3,
+	NOUN_DESK = 0x1E4,
+	NOUN_PASSAGEWAY = 0x1E5,
+	NOUN_FIRE_HYDRANT = 0x1E6,
+	NOUN_FREEZER = 0x1E7,
+	NOUN_EQUIDIGITIZER = 0x1E8,
+	NOUN_VISION_VIEW = 0x1E9,
+	NOUN_TELEDETECTOR = 0x1EA,
+	NOUN_POLE = 0x1EB,
+	NOUN_TRANSPOSITION_DEVICE = 0x1EC,
+	NOUN_STATUESQUE = 0x1ED,
+	NOUN_TEMPERATURE_GAUGE = 0x1EE,
+	NOUN_CHECK = 0x1EF,
+	NOUN_WATCH = 0x1F0,
+	NOUN_ELECTRO_SCANNER = 0x1F1,
+	NOUN_HALL = 0x1F2,
+	NOUN_SCANNER = 0x1F3,
+	NOUN_PLACE_HAND_ON = 0x1F4,
+	NOUN_SECURITY_MONITOR = 0x1F5,
+	NOUN_DIGITORAMA = 0x1F6,
+	NOUN_RAIL_BEAM = 0x1F7,
+	NOUN_VAULT = 0x1F8,
+	NOUN_HALLWAY = 0x1F9,
+	NOUN_PIPES = 0x1FA,
+	NOUN_AIR_VENT_GRATE = 0x1FB,
+	NOUN_SECURITY_OFFICE = 0x1FC,
+	NOUN_SIGNAL = 0x1FD,
+	NOUN_BLEEP = 0x1FE,
+	NOUN_BLIP = 0x1FF,
+	NOUN_LOFT = 0x200,
+	NOUN_ELECTRONIC_ANT_FARM = 0x201,
+	NOUN_ELECTRIC_WIRING = 0x202,
+	NOUN_SECURITY_PANEL = 0x203,
+	NOUN_CORRIDOR = 0x204,
+	NOUN_CIRCUIT_CONTROLS = 0x205,
+	NOUN_AIR_DUCT = 0x206,
+	NOUN_CELL_WALL = 0x207,
+	NOUN_LIGHTS = 0x208,
+	NOUN_STARE_INTO = 0x209,
+	NOUN_CELL_CONTROLS = 0x20A,
+	NOUN_COMMODE = 0x20B,
+	NOUN_USE = 0x20C,
+	NOUN_BASIN = 0x20D,
+	NOUN_JUMP_INSIDE = 0x20E,
+	NOUN_PREVIOUS_CELL = 0x20F,
+	NOUN_NEXT_ROOM = 0x210,
+	NOUN_ZINK = 0x211,
+	NOUN_GAZE_INTO = 0x212,
+	NOUN_THRONE = 0x213,
+	NOUN_SACK = 0x214,
+	NOUN_LIMB = 0x215,
+	NOUN_SINK = 0x216,
+	NOUN_JOHNNY_ON_THE_SPOT = 0x217,
+	NOUN_DEBRIS = 0x218,
+	NOUN_BUNK = 0x219,
+	NOUN_NEXT_CELL = 0x21A,
+	NOUN_TOILET = 0x21B,
+	NOUN_MONITOR_AREA = 0x21C,
+	NOUN_SIDEWALL = 0x21D,
+	NOUN_COFFEE_MUG = 0x21E,
+	NOUN_SIT_AT = 0x21F,
+	NOUN_LIGHTING_FIXTURE = 0x220,
+	NOUN_MONITORS = 0x221,
+	NOUN_GENDER_CONTROLS = 0x222,
+	NOUN_NEURO_ANALYZER = 0x223,
+	NOUN_MOLECULAR_RECORDER = 0x224,
+	NOUN_MAINTENANCE_PANEL = 0x225,
+	NOUN_RAMP = 0x226,
+	NOUN_WALK_UP = 0x227,
+	NOUN_SUBSONIC_ATOMIZER = 0x228,
+	NOUN_EIGHT_BALL = 0x229,
+	NOUN_DNA_INVERTER = 0x22A,
+	NOUN_DNA_CONVERTER = 0x22B,
+	NOUN_PLATFORM = 0x22C,
+	NOUN_GUINEA_PIG_TEST_BOX = 0x22D,
+	NOUN_GASEOUS_PROBE_WARPER = 0x22E,
+	NOUN_TOOL_CABINET = 0x22F,
+	NOUN_SURGICAL_BOXES = 0x230,
+	NOUN_FETAL_HEART_MONITOR = 0x231,
+	NOUN_XRAY_CABINET = 0x232,
+	NOUN_STERILIZATION_SINK = 0x233,
+	NOUN_DRIPOLATOR = 0x234,
+	NOUN_SHOCK_MACHINE = 0x235,
+	NOUN_INTERROGATION_TABLE = 0x236,
+	NOUN_LIE_DOWN_ON = 0x237,
+	NOUN_DECIPHER = 0x238,
+	NOUN_GUARD = 0x239,
+	NOUN_RIP_IN_FLOOR = 0x23A,
+	NOUN_TELEPORT_AREA = 0x23B,
+	NOUN_BROKEN_BEAM = 0x23C,
+	NOUN_ROCK_CHUNK = 0x23D,
+	NOUN_BLOODY_CELL_WALL = 0x23E,
+	NOUN_WALL_BOARD = 0x23F,
+	NOUN_GENDER_SCANNER = 0x240,
+	NOUN_BAR = 0x241,
+	NOUN_WALK_INTO = 0x242,
+	NOUN_HALLWAY_TO_SOUTH = 0x243,
+	NOUN_SIGN = 0x244,
+	NOUN_HALLWAY_TO_NORTH = 0x245,
+	NOUN_BOTTLES = 0x246,
+	NOUN_UPPER_DANCE_FLOOR = 0x247,
+	NOUN_DANCE_FLOOR = 0x248,
+	NOUN_RAILING = 0x249,
+	NOUN_BAR_STOOL = 0x24A,
+	NOUN_LADY = 0x24B,
+	NOUN_UPPER_LEVEL = 0x24C,
+	NOUN_ALCOVE = 0x24D,
+	NOUN_DISCO_BALL = 0x24E,
+	NOUN_LADIES = 0x24F,
+	NOUN_COACH_LAMP = 0x250,
+	NOUN_CARD_SLOT = 0x251,
+	NOUN_HOOP = 0x252,
+	NOUN_CANNONBALLS = 0x253,
+	NOUN_WATER_FOUNTAIN = 0x254,
+	NOUN_HALLWAY_TO_EAST = 0x255,
+	NOUN_HALLWAY_TO_WEST = 0x256,
+	NOUN_SUPPORT = 0x257,
+	NOUN_BACKBOARD = 0x258,
+	NOUN_WIDE_DOOR = 0x259,
+	NOUN_SIGN_POST = 0x25A,
+	NOUN_FIRE_EXTINGUISHER = 0x25B,
+	NOUN_TRASH = 0x25C,
+	NOUN_MISSILES = 0x25D,
+	NOUN_TANK = 0x25E,
+	NOUN_TWO_TON_WEIGHT = 0x25F,
+	NOUN_ONE_TON_TOMATO = 0x260,
+	NOUN_ANVIL = 0x261,
+	NOUN_MINUTEMAN_IV_ICBM = 0x262,
+	NOUN_CHEST = 0x263,
+	NOUN_ARMOR = 0x264,
+	NOUN_CARTON = 0x265,
+	NOUN_POWDER = 0x266,
+	NOUN_RAFT = 0x267,
+	NOUN_WHATZIT = 0x268,
+	NOUN_CATAPULT = 0x269,
+	NOUN_HAND_GRENADE = 0x26A,
+	NOUN_BARRELS = 0x26B,
+	NOUN_LOADING_RAMP = 0x26C,
+	NOUN_BLIMP = 0x26D,
+	NOUN_FLOUR = 0x26E,
+	NOUN_FLY_PAPER = 0x26F,
+	NOUN_RUG = 0x270,
+	NOUN_CARPET = 0x271,
+	NOUN_CAN = 0x272,
+	NOUN_RUBBER_DUCKIE = 0x273,
+	NOUN_GOLF_CLUBS = 0x274,
+	NOUN_RAT = 0x275,
+	NOUN_BARREL = 0x276,
+	NOUN_BUCKET_OF_TAR = 0x277,
+	NOUN_SACKS = 0x278,
+	NOUN_STORAGE = 0x279,
+	NOUN_120V_3_PHASE_400HZ = 0x27A,
+	NOUN_LAB_EQUIPMENT = 0x27B,
+	NOUN_AIR_HORN = 0x27C,
+	NOUN_JAR = 0x27D,
+	NOUN_SEVERED_CABLE = 0x27E,
+	NOUN_PROBE_ASSEMBLY = 0x27F,
+	NOUN_KNIFE_SWITCH = 0x280,
+	NOUN_WORK_BENCH = 0x281,
+	NOUN_HEATER = 0x282,
+	NOUN_TOXIC_WASTE = 0x283,
+	NOUN_EXPERIMENT = 0x284,
+	NOUN_DRAWING_BOARD = 0x285,
+	NOUN_MISHAP = 0x286,
+	NOUN_AIR_PURIFIER = 0x287,
+	NOUN_DUMMY = 0x288,
+	NOUN_PICTURE = 0x289,
+	NOUN_BAGGAGE_CHECK = 0x28A,
+	NOUN_DEPARTURE_SCHEDULE = 0x28B,
+	NOUN_SHADE_OF_PALE = 0x28C,
+	NOUN_ITINERARY = 0x28D,
+	NOUN_BARGAIN_VAT = 0x28E,
+	NOUN_PENCILS = 0x28F,
+	NOUN_PAD_IF_PAPER = 0x290,
+	NOUN_DEEPEST_DEPTHS = 0x291,
+	NOUN_ROLODEX = 0x292,
+	NOUN_MONA_TISA = 0x293,
+	NOUN_ABSTRACT_ART = 0x294,
+	NOUN_SPACE_QUESTING_VIII = 0x295,
+	NOUN_THEATRICAL_ART = 0x296,
+	NOUN_METAL_POLE = 0x297,
+	NOUN_EXIT = 0x298,
+	NOUN_SWIRLING_LIGHT = 0x299,
+	NOUN_REGISTER = 0x29A,
+	NOUN_PEACHY_BUNS = 0x29B,
+	NOUN_OUR_TOWN = 0x29C,
+	NOUN_EMBROIDERED_ART = 0x29D,
+	NOUN_GEORGE_BUSH_ALIKE = 0x29E,
+	NOUN_COUNTER = 0x29F,
+	NOUN_SENSOR = 0x2A0,
+	NOUN_SOFTWARE_INFORMATION = 0x2A1,
+	NOUN_WALK_BEHIND = 0x2A2,
+	NOUN_BARGAINS = 0x2A3,
+	NOUN_SCAN_LIGHT = 0x2A4,
+	NOUN_OLD_SOFTWARE_STAND = 0x2A5,
+	NOUN_SOFTWARE_SHELF = 0x2A6,
+	NOUN_HOTTEST_SOFTWARE = 0x2A7,
+	NOUN_GREAT_PAINTBALL_ART = 0x2A8,
+	NOUN_SCENIC_VISTA = 0x2A9,
+	NOUN_LASER = 0x2AA,
+	NOUN_LASER_JET = 0x2AB,
+	NOUN_LEVER = 0x2AC,
+	NOUN_BULLSEYE = 0x2AD,
+	NOUN_STAND = 0x2AE,
+	NOUN_CONTROL_STATION = 0x2AF,
+	NOUN_STRANGE_MONSTER = 0x2B0,
+	NOUN_GHASTLY_BEAST = 0x2B1,
+	NOUN_GAWK_AT = 0x2B2,
+	NOUN_CORRIDOR_TO_SOUTH = 0x2B3,
+	NOUN_CORRIDOR_TO_NORTH = 0x2B4,
+	NOUN_WALK_ONTO = 0x2B5,
+	NOUN_ROCK_WALL = 0x2B6,
+	NOUN_WOMAN = 0x2B7,
+	NOUN_WOMEN = 0x2B8,
+	NOUN_CORRIDOR_TO_EAST = 0x2B9,
+	NOUN_CORRIDOR_TO_WEST = 0x2BA,
+	NOUN_AMMUNITION = 0x2BB,
+	NOUN_ARMORED_VEHICLE = 0x2BC,
+	NOUN_TOMATO = 0x2BD,
+	NOUN_MISSILE = 0x2BE,
+	NOUN_SUIT_OF_ARMOR = 0x2BF,
+	NOUN_POWDER_CONTAINER = 0x2C0,
+	NOUN_INFLATABLE_RAFT = 0x2C1,
+	NOUN_GRENADE = 0x2C2,
+	NOUN_FENCE = 0x2C3,
+	NOUN_WOODEN_STATUE = 0x2C4,
+	NOUN_CONVEYER_BELT = 0x2C5,
+	NOUN_CONTROLS = 0x2C6,
+	NOUN_EQUIPMENT = 0x2C7,
+	NOUN_SHELF = 0x2C8,
+	NOUN_CABINETS = 0x2C9,
+	NOUN_CONTROL_CONSOLE = 0x2CA,
+	NOUN_FAUCET = 0x2CB,
+	NOUN_PANEL_BOX = 0x2CC,
+	NOUN_STATUE = 0x2CD,
+	NOUN_GAUGE = 0x2CE,
+	NOUN_CIRCUIT_PANEL = 0x2CF,
+	NOUN_CATWALK = 0x2D0,
+	NOUN_CIRCUITS = 0x2D1,
+	NOUN_BLOOD_STAIN = 0x2D2,
+	NOUN_GRATE = 0x2D3,
+	NOUN_AIR_SHAFT = 0x2D4,
+	NOUN_RETURN_TO = 0x2D5,
+	NOUN_FORMALDEHYDE = 0x2D6,
+	NOUN_PETROX = 0x2D7,
+	NOUN_SODIUM_BENZOATE = 0x2D8,
+	NOUN_GURNEY = 0x2D9,
+	NOUN_IRONING_BOARD = 0x2DA,
+	NOUN_LEFT_MONITOR = 0x2DB,
+	NOUN_RIGHT_MONITOR = 0x2DC,
+	NOUN_RED_BUTTON = 0x2DD,
+	NOUN_GREEN_BUTTON = 0x2DE,
+	NOUN_RIGHT_ONE_KEY = 0x2DF,
+	NOUN_RIGHT_1_KEY = 0x2E0,
+	NOUN_RIGHT_2_KEY = 0x2E1,
+	NOUN_RIGHT_3_KEY = 0x2E2,
+	NOUN_RIGHT_4_KEY = 0x2E3,
+	NOUN_RIGHT_5_KEY = 0x2E4,
+	NOUN_RIGHT_6_KEY = 0x2E5,
+	NOUN_RIGHT_7_KEY = 0x2E6,
+	NOUN_RIGHT_8_KEY = 0x2E7,
+	NOUN_LEFT_1_KEY = 0x2E8,
+	NOUN_LEFT_2_KEY = 0x2E9,
+	NOUN_LEFT_3_KEY = 0x2EA,
+	NOUN_LEFT_4_KEY = 0x2EB,
+	NOUN_CORRIDOR_WALL = 0x2EC,
+	NOUN_MUG = 0x2ED,
+	NOUN_DOUGHNUT = 0x2EE,
+	NOUN_SECURITY_STATION = 0x2EF,
+	NOUN_NEWSPAPER = 0x2F0,
+	NOUN_MAGAZINE = 0x2F1,
+	NOUN_CLIPBOARD = 0x2F2,
+	NOUN_PAPER_FOOTBALL = 0x2F3,
+	NOUN_YOUR_STUFF = 0x2F4,
+	NOUN_OTHER_STUFF = 0x2F5,
+	NOUN_LAMP = 0x2F6,
+	NOUN_CLIMB_INTO = 0x2F7,
+	NOUN_LIGHT_BULB = 0x2F8,
+	NOUN_STEP_INTO = 0x2F9,
+	NOUN_ROOM = 0x2FA,
+	NOUN_CRAWL_TO = 0x2FB,
+	NOUN_FOURTH_CELL = 0x2FC,
+	NOUN_THIRD_CELL = 0x2FD,
+	NOUN_SECOND_CELL = 0x2FE,
+	NOUN_FIRST_CELL = 0x2FF,
+	NOUN_EQUIPMENT_ROOM = 0x300,
+	NOUN_CRAWL_DOWN = 0x301,
+	NOUN_DESCENDING_SHAFT = 0x302,
+	NOUN_SAUROPOD = 0x303,
+	NOUN_MONSTER = 0x304,
+	NOUN_FAKE_ID = 0x305,
+	NOUN_ALIEN_LIQUOR = 0x306,
+	NOUN_INTERN = 0x307,
+	NOUN_INSTRUMENT_TABLE = 0x308,
+	NOUN_WOMAN_ON_BALCONY = 0x309,
+	NOUN_WOMAN_IN_CHAIR = 0x30A,
+	NOUN_SIT_ON = 0x30B,
+	NOUN_WOMAN_IN_ALCOVE = 0x30C,
+	NOUN_KETTLE = 0x30D,
+	NOUN_BARTENDER = 0x30E,
+	NOUN_WHISKEY = 0x30F,
+	NOUN_ALCOHOL = 0x310,
+	NOUN_RIM = 0x311,
+	NOUN_WALK_ALONG = 0x312,
 	NOUN_SUBMERGED_CITY = 0x313,
-	NOUN_CEMENT_PYLON   = 0x316,
-	NOUN_ELEVATOR       = 0x317,
-	NOUN_BUILDING       = 0x323,
-	NOUN_LASER_BEAM     = 0x343,
-	NOUN_BOAT           = 0x345,
-	NOUN_CEMENT_BLOCK   = 0x38E,
-	NOUN_CITY           = 0x38F,
-	NOUN_DOLLOP			= 0x3AC,
-	NOUN_DROP			= 0x3AD,
-	NOUN_DASH			= 0x3AE,
-	NOUN_SPLASH			= 0x3AF,
-	NOUN_HOOK           = 0x467,
-	NOUN_BIRDS          = 0x487,
+	NOUN_GOVERNORS_HOUSE = 0x314,
+	NOUN_RIM_TOWARDS_EAST = 0x315,
+	NOUN_CEMENT_PYLON = 0x316,
+	NOUN_ELEVATOR = 0x317,
+	NOUN_ELEVATOR_SHAFT = 0x318,
+	NOUN_CONVEYOR_BELT = 0x319,
+	NOUN_CANNON_BALLS = 0x31A,
+	NOUN_ELECTRICAL_OVERHANG = 0x31B,
+	NOUN_GUTTER_PIPE = 0x31C,
+	NOUN_SIDEWALK = 0x31D,
+	NOUN_STREET = 0x31E,
+	NOUN_BARRICADE = 0x31F,
+	NOUN_DOOR_CONTROL_SLOT = 0x320,
+	NOUN_STREET_TO_EAST = 0x321,
+	NOUN_SIDEWALK_TO_EAST = 0x322,
+	NOUN_BUILDING = 0x323,
+	NOUN_CAR = 0x324,
+	NOUN_GET_INSIDE = 0x325,
+	NOUN_MARQUEE = 0x326,
+	NOUN_BUILDING_ENTRANCE = 0x327,
+	NOUN_GUARD_STATION = 0x328,
+	NOUN_TECHNICAL_EQUIPMENT = 0x329,
+	NOUN_GUARD_TURRET = 0x32A,
+	NOUN_PILLAR = 0x32B,
+	NOUN_PAPERS = 0x32C,
+	NOUN_FILE_CABINET = 0x32D,
+	NOUN_WINDOWS = 0x32E,
+	NOUN_WALK = 0x32F,
+	NOUN_STORAGE_BOX = 0x330,
+	NOUN_WATER_COOLER = 0x331,
+	NOUN_BOX = 0x332,
+	NOUN_RIFLES = 0x333,
+	NOUN_SLINGSHOT = 0x334,
+	NOUN_MAUSOLEUM = 0x335,
+	NOUN_SOFTWARE_STORE = 0x336,
+	NOUN_CONCRETE_BUILDING = 0x337,
+	NOUN_HUMONGOUS_MONITOR = 0x338,
+	NOUN_SPACE_BIKE = 0x339,
+	NOUN_BILLBOARD = 0x33A,
+	NOUN_LACK_OF_NOOKIE_MOTEL = 0x33B,
+	NOUN_BIDETS_XCREETZA_HUT = 0x33C,
+	NOUN_BUILDINGS = 0x33D,
+	NOUN_SKYSCRAPER = 0x33E,
+	NOUN_SOFTWARE_LOGO = 0x33F,
+	NOUN_GIANT_TELESCOPE = 0x340,
+	NOUN_HANDLE = 0x341,
+	NOUN_HOLE = 0x342,
+	NOUN_LASER_BEAM = 0x343,
+	NOUN_PEDESTAL = 0x344,
+	NOUN_BOAT = 0x345,
+	NOUN_GIANT_MONUMENT = 0x346,
+	NOUN_ROPE = 0x347,
+	NOUN_SAND_BAR_RESTAURANT = 0x348,
+	NOUN_PORTHOLE = 0x349,
+	NOUN_TICKET_BOOTH = 0x34A,
+	NOUN_POLLYS_ENTRANCE = 0x34B,
+	NOUN_RESTAURANT_ENTRANCE = 0x34C,
+	NOUN_THE_PLEASURE_DOME = 0x34D,
+	NOUN_STARFISH = 0x34E,
+	NOUN_FLIPPER = 0x34F,
+	NOUN_SAND_DOLLAR = 0x350,
+	NOUN_SHELL = 0x351,
+	NOUN_GUEST_LIST = 0x352,
+	NOUN_WEIRD_ANIMAL_HEAD = 0x353,
+	NOUN_SHIPS_WHEEL = 0x354,
+	NOUN_HANDICAP_SIGN = 0x355,
+	NOUN_ELEVATOR_CONTROLS = 0x356,
+	NOUN_BRICK_WALL = 0x357,
+	NOUN_BIKE_RACK = 0x358,
+	NOUN_ODONALDS_SIGN = 0x359,
+	NOUN_ELEVATOR_ENTRANCE = 0x35A,
+	NOUN_SPECIAL_SALE_SIGN = 0x35B,
+	NOUN_ATTORNEYS_AT_LAW = 0x35C,
+	NOUN_SLEDGE_MALL = 0x35D,
+	NOUN_SKELETON = 0x35E,
+	NOUN_STRANGE_EQUIPMENT = 0x35F,
+	NOUN_STREET_TO_WEST = 0x360,
+	NOUN_SIDEWALK_TO_WEST = 0x361,
+	NOUN_TELEPORTER_ENTRANCE = 0x362,
+	NOUN_SOFTWARE_DOOR = 0x363,
+	NOUN_SPINACH_PATCH_DOLL = 0x364,
+	NOUN_REFLECT = 0x365,
+	NOUN_REGISTER_DRAWER = 0x366,
+	NOUN_ELEVATOR_DOOR = 0x367,
+	NOUN_HYDRAULIC_SUPPORT = 0x368,
+	NOUN_EQUIPMENT_OVERHEAD = 0x369,
+	NOUN_GET_INTO = 0x36A,
+	NOUN_WARNING_LABEL = 0x36B,
+	NOUN_NUCLEAR_SLINGSHOT = 0x36C,
+	NOUN_DISPLAY_CASE = 0x36D,
+	NOUN_PHOTON_RIFLES = 0x36E,
+	NOUN_MONITORING_EQUIPMENT = 0x36F,
+	NOUN_TELESCOPE = 0x370,
+	NOUN_MOTEL = 0x371,
+	NOUN_RESTAURANT = 0x372,
+	NOUN_SOFTWARE_STORE_SIGN = 0x373,
+	NOUN_ADVERTISING_POSTER = 0x374,
+	NOUN_ADVERTISEMENT = 0x375,
+	NOUN_OLD_SOFTWARE = 0x376,
+	NOUN_CASH_REGISTER = 0x377,
+	NOUN_ENTRANCE = 0x378,
+	NOUN_LASER_CANNON = 0x379,
+	NOUN_SAND_BAGS = 0x37A,
+	NOUN_PLEASURE_DOME = 0x37B,
+	NOUN_DOME_ENTRANCE = 0x37C,
+	NOUN_LABORATORY = 0x37D,
+	NOUN_STREET_TO_SOUTH = 0x37E,
+	NOUN_ELEVATOR_ACCESS_SLOT = 0x37F,
+	NOUN_CAR_CONTROLS = 0x380,
+	NOUN_SCENT_PACKET = 0x381,
+	NOUN_KITTY = 0x382,
+	NOUN_GLOVE_COMPARTMENT = 0x383,
+	NOUN_MOLDY_SOCK = 0x384,
+	NOUN_SODA_CANS = 0x385,
+	NOUN_WINDSHIELD = 0x386,
+	NOUN_DASHBOARD = 0x387,
+	NOUN_INTERIOR_OF_CAR = 0x388,
+	NOUN_VIEW_RIGHT_BUTTON = 0x389,
+	NOUN_BLACK_BUTTON = 0x38A,
+	NOUN_WHITE_BUTTON = 0x38B,
+	NOUN_INSIDE_OF_CAR = 0x38C,
+	NOUN_RIM_TOWARDS_WEST = 0x38D,
+	NOUN_CEMENT_BLOCK = 0x38E,
+	NOUN_CITY = 0x38F,
+	NOUN_SPEAKER = 0x390,
+	NOUN_EYE_CHART = 0x391,
+	NOUN_LAUNCH_PAD = 0x392,
+	NOUN_BUILDING_TO_WEST = 0x393,
+	NOUN_PAD_TO_EAST = 0x394,
+	NOUN_PAD_TO_WEST = 0x395,
+	NOUN_TOWER = 0x396,
+	NOUN_LOOK_OUT = 0x397,
+	NOUN_SERVICE_PANEL = 0x398,
+	NOUN_CRACK = 0x399,
+	NOUN_THROTTLE = 0x39A,
+	NOUN_GRAB = 0x39B,
+	NOUN_INSTRUMENTATION = 0x39C,
+	NOUN_TP = 0x39D,
+	NOUN_SEAT = 0x39E,
+	NOUN_STATUS_PANEL = 0x39F,
+	NOUN_SHIPS_CONTROLS = 0x3A0,
+	NOUN_PROFESSOR = 0x3A1,
+	NOUN_PROFESSORS_GURNEY = 0x3A2,
+	NOUN_WELCOME_MAT = 0x3A3,
+	NOUN_MELON_MUSH = 0x3A4,
+	NOUN_BADMINTON_BRAT = 0x3A5,
+	NOUN_APPLY = 0x3A6,
+	NOUN_COMBINATION = 0x3A7,
+	NOUN_NOTE = 0x3A8,
+	NOUN_LECITHIN = 0x3A9,
+	NOUN_REPAIR_WOMAN = 0x3AA,
+	NOUN_EXPLOSIVES = 0x3AB,
+	NOUN_DOLLOP = 0x3AC,
+	NOUN_DROP = 0x3AD,
+	NOUN_DASH = 0x3AE,
+	NOUN_SPLASH = 0x3AF,
+	NOUN_DOCK_TO_SOUTH = 0x3B0,
+	NOUN_STEER_TOWARDS = 0x3B1,
+	NOUN_BUILDING_TO_NORTH = 0x3B2,
+	NOUN_VOLCANO_RIM = 0x3B3,
+	NOUN_OPEN_WATER_TO_SOUTH = 0x3B4,
+	NOUN_PROJECTOR = 0x3B5,
+	NOUN_GUARDS_ARM2 = 0x3B6,
+	NOUN_NIBBLE_ON = 0x3B7,
+	NOUN_ENTER = 0x3B8,
+	NOUN_ = 0x3B9,
+	NOUN_TIMER_BUTTON_1 = 0x3BA,
+	NOUN_REMOTE_BUTTON_1 = 0x3BB,
+	NOUN_START_BUTTON_2 = 0x3BC,
+	NOUN_REMOTE_BUTTON_2 = 0x3BD,
+	NOUN_TIMER_BUTTON_2 = 0x3BE,
+	NOUN_START_BUTTON_1 = 0x3BF,
+	NOUN_ANTIGRAV_CONTROLS = 0x3C0,
+	NOUN_BRUCES_TREE = 0x3C1,
+	NOUN_COLISEUM = 0x3C2,
+	NOUN_BRUCES_GARDEN_ROOM = 0x3C3,
+	NOUN_FOUNTAIN = 0x3C4,
+	NOUN_HOUSE_OF_BRUCE = 0x3C5,
+	NOUN_CITY_BACKDROP = 0x3C6,
+	NOUN_BRUCES_BALCONY = 0x3C7,
+	NOUN_BRUCES_ENTRANCE = 0x3C8,
+	NOUN_BRUCES_LOGO = 0x3C9,
+	NOUN_LOUNGE_CHAIR = 0x3CA,
+	NOUN_LIVING_ROOM_FLOOR = 0x3CB,
+	NOUN_LIVINGROOM_FLOOR = 0x3CC,
+	NOUN_PERFUME_BOTTLE = 0x3CD,
+	NOUN_COOL_NEON_LIGHT = 0x3CE,
+	NOUN_FLOWER_POT = 0x3CF,
+	NOUN_COFFEE_TABLE = 0x3D0,
+	NOUN_FLOWERS = 0x3D1,
+	NOUN_ART_DECO_CHAIR = 0x3D2,
+	NOUN_SAFE = 0x3D3,
+	NOUN_SPLASHY_DECOR = 0x3D4,
+	NOUN_THEATRICAL_FACES = 0x3D5,
+	NOUN_ART_DECO_PIECE = 0x3D6,
+	NOUN_END_OF_ROOM = 0x3D7,
+	NOUN_FIREPLACE = 0x3D8,
+	NOUN_ARTWORK = 0x3D9,
+	NOUN_COOL_NEON_LIGHTS = 0x3DA,
+	NOUN_GLASS_PLATED_WINDOW = 0x3DB,
+	NOUN_BEDROOM_FLOOR = 0x3DC,
+	NOUN_BAUBLE = 0x3DD,
+	NOUN_SNAPSHOT = 0x3DE,
+	NOUN_PERFUME = 0x3DF,
+	NOUN_CLAPBOARD = 0x3E0,
+	NOUN_BERET = 0x3E1,
+	NOUN_HORSE_WHIP = 0x3E2,
+	NOUN_CORNER_TABLE = 0x3E3,
+	NOUN_BOA = 0x3E4,
+	NOUN_WIG_STAND = 0x3E5,
+	NOUN_PARTITION = 0x3E6,
+	NOUN_MEGAPHONE = 0x3E7,
+	NOUN_SLIP = 0x3E8,
+	NOUN_SCONCE = 0x3E9,
+	NOUN_VANITY = 0x3EA,
+	NOUN_BEDBOARD = 0x3EB,
+	NOUN_LOVE_SEAT = 0x3EC,
+	NOUN_SOUVENIR_TICKETS = 0x3ED,
+	NOUN_REVIEW = 0x3EE,
+	NOUN_BRUCE_AT_THE_GALA = 0x3EF,
+	NOUN_ART_DECO_RUG = 0x3F0,
+	NOUN_LIVINGROOM = 0x3F1,
+	NOUN_SCULPTURE = 0x3F2,
+	NOUN_SPECIMEN_EPITHET = 0x3F3,
+	NOUN_VENT = 0x3F4,
+	NOUN_FLOWER_BOX = 0x3F5,
+	NOUN_LEDGE = 0x3F6,
+	NOUN_BOLT = 0x3F7,
+	NOUN_OBSERVATION_WINDOW = 0x3F8,
+	NOUN_AIR_HOSE = 0x3F9,
+	NOUN_AUTO_SHOP = 0x3FA,
+	NOUN_MANHOLE = 0x3FB,
+	NOUN_AUTO_SHOP_ENTRANCE = 0x3FC,
+	NOUN_BROKEN_WINDOW = 0x3FD,
+	NOUN_WOMANHOLE = 0x3FE,
+	NOUN_GARAGE_DOOR = 0x3FF,
+	NOUN_SCRATCH_PAD = 0x400,
+	NOUN_GAS_PRICES = 0x401,
+	NOUN_UP_BUTTON = 0x402,
+	NOUN_DOWN_BUTTON = 0x403,
+	NOUN_SPARE_PARTS_LIST = 0x404,
+	NOUN_SKYLIGHT = 0x405,
+	NOUN_TOOL_BOX = 0x406,
+	NOUN_CAR_LIFT = 0x407,
+	NOUN_CAR_SEAT = 0x408,
+	NOUN_GARAGE_FLOOR = 0x409,
+	NOUN_GARAGE_DOOR_CONTROLS = 0x40A,
+	NOUN_AMISH_HAT = 0x40B,
+	NOUN_JACK = 0x40C,
+	NOUN_COILS = 0x40D,
+	NOUN_OIL_CAN = 0x40E,
+	NOUN_FAN_BELTS = 0x40F,
+	NOUN_REAR_OF_GARAGE = 0x410,
+	NOUN_FRONT_OF_GARAGE = 0x411,
+	NOUN_MUFFLER = 0x412,
+	NOUN_SPARE_PART = 0x413,
+	NOUN_HUBCAP = 0x414,
+	NOUN_CANDLE = 0x415,
+	NOUN_RATES = 0x416,
+	NOUN_GREASE_CAN = 0x417,
+	NOUN_CALENDAR = 0x418,
+	NOUN_FORK_LIFT = 0x419,
+	NOUN_TRASH_CAN = 0x41A,
+	NOUN_SHAKER_CHAIR = 0x41B,
+	NOUN_QUARTER_PANEL = 0x41C,
+	NOUN_AREA_BEHIND_CAR = 0x41D,
+	NOUN_DANGER_ZONE = 0x41E,
+	NOUN_NEWSSTAND = 0x41F,
+	NOUN_LADY_GODIVA_MONUMENT = 0x420,
+	NOUN_SPOT_A_POT = 0x421,
+	NOUN_GUARD_RAIL = 0x422,
+	NOUN_ALLEY = 0x423,
+	NOUN_DITCH = 0x424,
+	NOUN_VIDEO_STORE_DOOR = 0x425,
+	NOUN_BUCKLUSTER_MARQUEE = 0x426,
+	NOUN_VIDEO_STORE = 0x427,
+	NOUN_HORMONE_BILLBOARD = 0x428,
+	NOUN_PHONE_ANTENNA = 0x429,
+	NOUN_RETURN_SLOT = 0x42A,
+	NOUN_NOOSE = 0x42B,
+	NOUN_COMEDY_VIDEOS = 0x42C,
+	NOUN_SMELLY_SNEAKER = 0x42D,
+	NOUN_PIPPYS_STOCKING = 0x42E,
+	NOUN_PHONE_CRADLE = 0x42F,
+	NOUN_DRAMA_VIDEOS = 0x430,
+	NOUN_SPOTLIGHT = 0x431,
+	NOUN_STOREROOM_FLOOR = 0x432,
+	NOUN_ALL_SALES_FINAL = 0x433,
+	NOUN_MACHOPROSE_TEE_SHIRT = 0x434,
+	NOUN_UNKNOWN_COMIC_HANDS = 0x435,
+	NOUN_WET_CEMENT = 0x436,
+	NOUN_PIPPYS_TINY_IMPRINT = 0x437,
+	NOUN_OBNOXIOUS_DOG_PAWS = 0x438,
+	NOUN_LEG_AND_A_LEG_JEANS = 0x439,
+	NOUN_VIDEO_STORE_EXIT = 0x43A,
+	NOUN_AISLE = 0x43B,
+	NOUN_VIDEO_MONITOR = 0x43C,
+	NOUN_POLLY_PIGS_IMPRINT = 0x43D,
+	NOUN_JOHN_WYNNS_IMPRINT = 0x43E,
+	NOUN_MR_NEDS_IMPRINT = 0x43F,
+	NOUN_PEG_LEG_PETE_IMPRINT = 0x440,
+	NOUN_MARX_BROS_POSTER = 0x441,
+	NOUN_PIPPY_BILLBOARD = 0x442,
+	NOUN_VIDEOS_NOONE_WANTS = 0x443,
+	NOUN_MORE_CLASSIC_VIDEOS = 0x444,
+	NOUN_JOIN_OUR_PRICE_CLUB = 0x445,
+	NOUN_EDUCATIONAL_VIDEOS = 0x446,
+	NOUN_DEEP_DISCOUNT_TITLES = 0x447,
+	NOUN_WORLD_CHAMPS_POSTER = 0x448,
+	NOUN_WORKOUT_VIDEOS = 0x449,
+	NOUN_20_PERCENT_OFF_SIGN = 0x44A,
+	NOUN_CIVILIZATION_AD = 0x44B,
+	NOUN_NEW_RELEASE_VIDEOS = 0x44C,
+	NOUN_PORNO_VIDEOS = 0x44D,
+	NOUN_FOREIGN_VIDEOS = 0x44E,
+	NOUN_CLASSIC_VIDEOS = 0x44F,
+	NOUN_ADVENTURE_VIDEOS = 0x450,
+	NOUN_BUCKLUSTER_LOGO = 0x451,
+	NOUN_WINE_BOTTLE = 0x452,
+	NOUN_DIRT_PILE = 0x453,
+	NOUN_MAMMOTH_PENCIL_HEAD = 0x454,
+	NOUN_WREAKY_PUMPKIN = 0x455,
+	NOUN_MILK_CARTON = 0x456,
+	NOUN_BUCKET = 0x457,
+	NOUN_EMPTY_BOX = 0x458,
+	NOUN_DIAPER_BOX = 0x459,
+	NOUN_HERMIT = 0x45A,
+	NOUN_METAL_PIPE = 0x45B,
+	NOUN_CONCRETE_SUPPORT = 0x45C,
+	NOUN_VARIOUS_TRASH = 0x45D,
+	NOUN_ARMATURE = 0x45E,
+	NOUN_CONTROL_BOX = 0x45F,
+	NOUN_TOP_OF_DOME = 0x460,
+	NOUN_EXPRESSWAY_TO_EAST = 0x461,
+	NOUN_GO_TOWARDS = 0x462,
+	NOUN_EXPRESSWAY_TO_WEST = 0x463,
+	NOUN_DOME = 0x464,
+	NOUN_VIEW_OF_CITY = 0x465,
+	NOUN_EXPRESSWAY = 0x466,
+	NOUN_HOOK = 0x467,
+	NOUN_SEA_MONSTER = 0x468,
+	NOUN_EDGE_OF_VOLCANO = 0x469,
+	NOUN_JUMP_THROUGH = 0x46A,
+	NOUN_OLD_TEA_CUP = 0x46B,
+	NOUN_NAME_PLATE = 0x46C,
+	NOUN_OLD_VASE = 0x46D,
+	NOUN_PORTRAIT = 0x46E,
+	NOUN_PUT_DOWN = 0x46F,
+	NOUN_TALL_BUILDING = 0x470,
+	NOUN_OBNOXIOUS_DOG = 0x471,
+	NOUN_GUTS = 0x472,
+	NOUN_BIG_HEADS = 0x473,
+	NOUN_INSTALL = 0x474,
+	NOUN_LIFE_SUPPORT_MODULE = 0x475,
+	NOUN_REMOVE = 0x476,
+	NOUN_LARGE_BLADE = 0x477,
+	NOUN_SIDE_ENTRANCE = 0x478,
+	NOUN_INDICATOR = 0x479,
+	NOUN_SIGNPOST = 0x47A,
+	NOUN_PIN = 0x47B,
+	NOUN_POWDER_PUFF = 0x47C,
+	NOUN_SHELVES = 0x47D,
+	NOUN_ELECTRODES = 0x47E,
+	NOUN_MISHAP2 = 0x47F,
+	NOUN_ISLD_SUPERSTRUCTURE = 0x480,
+	NOUN_FILE_CABINETS = 0x481,
+	NOUN_CYCLE_SHOP = 0x482,
+	NOUN_AIR_BIKE = 0x483,
+	NOUN_EMERGENCY_LIGHT = 0x484,
+	NOUN_TARGET_AREA = 0x485,
+	NOUN_ICE_CHESTS = 0x486,
+	NOUN_BIRDS = 0x487,
+	NOUN_DOCTORS_OFFICE = 0x488,
+	NOUN_DEFACE = 0x489,
+	NOUN_LARGE_HEADS = 0x48A,
+	NOUN_SMALL_TABLE = 0x48B,
+	NOUN_COLLOSSEUM = 0x48C,
+	NOUN_HOUSE = 0x48D,
+	NOUN_BALCONY = 0x48E,
+	NOUN_GARDEN_ROOM = 0x48F,
+	NOUN_COVE_LIGHTS = 0x490,
+	NOUN_MASKS = 0x491,
+	NOUN_NEON_LIGHTS = 0x492,
+	NOUN_GLASS_BLOCK_WALL = 0x493,
+	NOUN_SCREEN = 0x494,
+	NOUN_SPARE_RIBS = 0x495,
+	NOUN_BANNER = 0x496,
+	NOUN_INSTRUCTIONAL_VIDEOS = 0x497,
+	NOUN_CEMENT = 0x498,
+	NOUN_STORE = 0x499,
+	NOUN_CARDBOARD_BOX = 0x49A,
+	NOUN_GRAFFITTI = 0x49B,
+	NOUN_GRAFFITI = 0x49C,
+	NOUN_PHOTOGRAPH = 0x49D,
+	NOUN_DIRECTORS_SLATE = 0x49E,
+	NOUN_CROP = 0x49F,
+	NOUN_HAT = 0x4A0,
+	NOUN_LOGO = 0x4A1,
+	NOUN_MAINTENANCE_BUILDING = 0x4A2,
+	NOUN_MASSAGE = 0x4A3,
+	NOUN_MANGLE = 0x4A4,
+	NOUN_RUB = 0x4A5,
+	NOUN_JUGGLE = 0x4A6,
+	NOUN_SMASH = 0x4A7,
+	NOUN_GUZZLE = 0x4A8,
 	NOUN_WEST_END_OF_PLATFORM = 0x4A9,
-	NOUN_EAST_END_OF_PLATFORM = 0x4AA
+	NOUN_EAST_END_OF_PLATFORM = 0x4AA,
+	NOUN_FOLD = 0x4AB,
+	NOUN_SPINDLE = 0x4AC,
+	NOUN_MUTILATE = 0x4AD
 };
 
 class SceneFactory {
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 7c4af52..04c646f 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -268,7 +268,7 @@ void Scene101::step() {
 }
 
 void Scene101::preActions() {
-	if (_action.isAction(VERB_LOOK, 0x180))
+	if (_action.isAction(VERB_LOOK, NOUN_VIEW_SCREEN))
 		_game._player._needToWalk = true;
 
 	if (_sittingFl) {
@@ -424,13 +424,13 @@ void Scene101::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_OPEN, 0x135) && _panelOpened) {
+	if (_action.isAction(VERB_OPEN, NOUN_SHIELD_ACCESS_PANEL) && _panelOpened) {
 		_vm->_dialogs->show(10130);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x180) && _sittingFl) {
+	if (_action.isAction(VERB_LOOK, NOUN_VIEW_SCREEN) && _sittingFl) {
 		if (_globals[kWatchedViewScreen]) {
 			sayDang();
 		} else {
@@ -469,7 +469,7 @@ void Scene101::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x47)) {
+	if (_action.isAction(VERB_LOOK, NOUN_CHAIR)) {
 		_vm->_dialogs->show(10101);
 		_action._inProgress = false;
 		return;
@@ -481,115 +481,115 @@ void Scene101::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0xA8) || _action.isAction(VERB_LOOK, 0xF8) || _action.isAction(VERB_EXAMINE, 0xA8) || _action.isAction(VERB_EXAMINE, 0xF8)) {
+	if (_action.isAction(VERB_LOOK, NOUN_HULL) || _action.isAction(VERB_LOOK, NOUN_OUTER_HULL) || _action.isAction(VERB_EXAMINE, NOUN_HULL) || _action.isAction(VERB_EXAMINE, NOUN_OUTER_HULL)) {
 		_vm->_dialogs->show(10103);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x91)) {
+	if (_action.isAction(VERB_LOOK, NOUN_FUZZY_DICE)) {
 		_vm->_dialogs->show(10104);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0xE1) || _action.isAction(VERB_LOOK_IN, 0xE1)) {
+	if (_action.isAction(VERB_LOOK, NOUN_MIRROR) || _action.isAction(VERB_LOOK_IN, NOUN_MIRROR)) {
 		_vm->_dialogs->show(10105);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x60)) {
+	if (_action.isAction(VERB_LOOK, NOUN_CURTAINS)) {
 		_vm->_dialogs->show(10106);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x111)) {
+	if (_action.isAction(VERB_LOOK, NOUN_PLASTIC_JESUS)) {
 		_vm->_dialogs->show(10107);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x7B) || (_action.isAction(VERB_OPEN, 0x7B) && !_game._objects.isInInventory(OBJ_REBREATHER))) {
+	if (_action.isAction(VERB_LOOK, NOUN_ESCAPE_HATCH) || (_action.isAction(VERB_OPEN, NOUN_ESCAPE_HATCH) && !_game._objects.isInInventory(OBJ_REBREATHER))) {
 		_vm->_dialogs->show(10109);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_OPEN, 0x7B)) {
+	if (_action.isAction(VERB_OPEN, NOUN_ESCAPE_HATCH)) {
 		_vm->_dialogs->show(10110);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x166)) {
+	if (_action.isAction(VERB_LOOK, NOUN_TARGET_COMPUTER)) {
 		_vm->_dialogs->show(10111);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0xCA)) {
+	if (_action.isAction(VERB_LOOK, NOUN_LIBRARY_COMPUTER)) {
 		_vm->_dialogs->show(10126);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x63)) {
+	if (_action.isAction(VERB_LOOK, NOUN_DAMAGE_CONTROL_PANEL)) {
 		_vm->_dialogs->show(10112);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0xEB)) {
+	if (_action.isAction(VERB_LOOK, NOUN_NAVIGATION_CONTROLS)) {
 		_vm->_dialogs->show(10113);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x78)) {
+	if (_action.isAction(VERB_LOOK, NOUN_ENGINEERING_CONTROLS)) {
 		_vm->_dialogs->show(10114);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x190)) {
+	if (_action.isAction(VERB_LOOK, NOUN_WEAPONS_DISPLAY)) {
 		_vm->_dialogs->show(10115);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x138)) {
+	if (_action.isAction(VERB_LOOK, NOUN_SHIELD_STATUS_PANEL)) {
 		_vm->_dialogs->show(10116);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_TAKE, 0x111)) {
+	if (_action.isAction(VERB_TAKE, NOUN_PLASTIC_JESUS)) {
 		_vm->_dialogs->show(10118);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_TAKE, 0x91)) {
+	if (_action.isAction(VERB_TAKE, NOUN_FUZZY_DICE)) {
 		_vm->_dialogs->show(10119);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_OPEN, 0x63)) {
+	if (_action.isAction(VERB_OPEN, NOUN_DAMAGE_CONTROL_PANEL)) {
 		_vm->_dialogs->show(10121);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_OPEN, 0x60)) {
+	if (_action.isAction(VERB_OPEN, NOUN_CURTAINS)) {
 		_vm->_dialogs->show(10122);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_CLOSE, 0x60)) {
+	if (_action.isAction(VERB_CLOSE, NOUN_CURTAINS)) {
 		_vm->_dialogs->show(10123);
 		_action._inProgress = false;
 		return;
@@ -875,7 +875,7 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_WALK_THROUGH, 0x6E)) {
+	if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR)) {
 		switch (_game._trigger) {
 		case 0:
 			_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 1, 0, 0);
@@ -892,43 +892,43 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_WALKTO, 0x79)) {
+	if (_action.isAction(VERB_WALKTO, NOUN_ENGINEERING_SECTION)) {
 		_scene->_nextSceneId = 103;
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_WALKTO, 0x117) || _action.isAction(VERB_LOOK, 0x117) || _action.isAction(VERB_WALKTO, 0x27)) {
+	if (_action.isAction(VERB_WALKTO, NOUN_POSTER) || _action.isAction(VERB_LOOK, NOUN_POSTER) || _action.isAction(VERB_WALKTO, NOUN_BINOCULARS)) {
 		addRandomMessage();
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x194)) {
+	if (_action.isAction(VERB_LOOK, NOUN_WEIGHT_MACHINE)) {
 		_vm->_dialogs->show(10212);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x79)) {
+	if (_action.isAction(VERB_LOOK, NOUN_ENGINEERING_SECTION)) {
 		_vm->_dialogs->show(10205);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x6E)) {
+	if (_action.isAction(VERB_LOOK, NOUN_DOOR)) {
 		_vm->_dialogs->show(10204);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_STARE_AT, 0x46) || _action.isAction(VERB_LOOK, 0x46)) {
+	if (_action.isAction(VERB_STARE_AT, NOUN_CEILING) || _action.isAction(VERB_LOOK, NOUN_CEILING)) {
 		_vm->_dialogs->show(10203);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_STARE_AT, 0xFD) || _action.isAction(VERB_LOOK, 0xFD)) {
+	if (_action.isAction(VERB_STARE_AT, NOUN_OVERHEAD_LAMP) || _action.isAction(VERB_LOOK, NOUN_OVERHEAD_LAMP)) {
 		_vm->_dialogs->show(10202);
 		_action._inProgress = false;
 		return;
@@ -964,7 +964,7 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x52)) {
+	if (_action.isAction(VERB_LOOK, NOUN_CLOSET)) {
 		_vm->_dialogs->show(10219);
 		_action._inProgress = false;
 		return;
@@ -1019,19 +1019,19 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x118)) {
+	if (_action.isAction(VERB_LOOK, NOUN_POWER_STATUS_PANEL)) {
 		_vm->_dialogs->show(10226);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x197) || _action.isAction(VERB_LOOK_THROUGH, 0x197)) {
+	if (_action.isAction(VERB_LOOK, NOUN_WINDOW) || _action.isAction(VERB_LOOK_THROUGH, NOUN_WINDOW)) {
 		_vm->_dialogs->show(10227);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x70) || _action.isAction(VERB_WALKTO, 0x70)) {
+	if (_action.isAction(VERB_LOOK, NOUN_DOORWAY) || _action.isAction(VERB_WALKTO, NOUN_DOORWAY)) {
 		_vm->_dialogs->show(10228);
 		_action._inProgress = false;
 		return;
@@ -1056,20 +1056,20 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x47) || (_action.isAction(VERB_SIT_IN, 0x47) && !_chairDescrFl)) {
+	if (_action.isAction(VERB_LOOK, NOUN_CHAIR) || (_action.isAction(VERB_SIT_IN, NOUN_CHAIR) && !_chairDescrFl)) {
 		_chairDescrFl = true;
 		_vm->_dialogs->show(10210);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_SIT_IN, 0x47)) {
+	if (_action.isAction(VERB_SIT_IN, NOUN_CHAIR)) {
 		_vm->_dialogs->show(10211);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0xDE)) {
+	if (_action.isAction(VERB_LOOK, NOUN_MEDICINE_CABINET)) {
 		if (_globals[kMedicineCabinetOpen])
 			_vm->_dialogs->show(10207);
 		else
@@ -1079,7 +1079,7 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_CLOSE, 0xDE) && _globals[kMedicineCabinetOpen]) {
+	if (_action.isAction(VERB_CLOSE, NOUN_MEDICINE_CABINET) && _globals[kMedicineCabinetOpen]) {
 		switch (_game._trigger) {
 		case 0:
 			_scene->_sequences.remove(_globals._sequenceIndexes[8]);
@@ -1103,7 +1103,7 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_OPEN, 0xDE) && !_globals[kMedicineCabinetOpen]) {
+	if (_action.isAction(VERB_OPEN, NOUN_MEDICINE_CABINET) && !_globals[kMedicineCabinetOpen]) {
 		switch (_game._trigger) {
 		case 0:
 			_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 1, 0, 0);
@@ -1133,7 +1133,7 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_TAKE, 0x27) && _game._objects.isInRoom(OBJ_BINOCULARS)) {
+	if (_action.isAction(VERB_TAKE, NOUN_BINOCULARS) && _game._objects.isInRoom(OBJ_BINOCULARS)) {
 		switch (_game._trigger) {
 		case 0:
 			_globals._sequenceIndexes[11] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[11], false, 3, 1, 0, 0);
@@ -1157,7 +1157,7 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_TAKE, 0x35) && _game._objects.isInRoom(OBJ_BURGER)) {
+	if (_action.isAction(VERB_TAKE, NOUN_BURGER) && _game._objects.isInRoom(OBJ_BURGER)) {
 		if (_game._trigger == 0) {
 			_vm->_dialogs->showItem(OBJ_BURGER, 10235);
 			_scene->_sequences.remove(_globals._sequenceIndexes[10]);
@@ -1171,7 +1171,7 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_TAKE, 0x117)) {
+	if (_action.isAction(VERB_TAKE, NOUN_POSTER)) {
 		_vm->_dialogs->show(10224);
 		_action._inProgress = false;
 		return;
@@ -1183,26 +1183,26 @@ void Scene102::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x89)) {
+	if (_action.isAction(VERB_LOOK, NOUN_FLOOR)) {
 		_vm->_dialogs->show(10232);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x27) && !_game._objects.isInInventory(OBJ_BINOCULARS)) {
+	if (_action.isAction(VERB_LOOK, NOUN_BINOCULARS) && !_game._objects.isInInventory(OBJ_BINOCULARS)) {
 		_vm->_dialogs->show(10233);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x35) && (_action._mainObjectSource == 4)) {
+	if (_action.isAction(VERB_LOOK, NOUN_BURGER) && (_action._mainObjectSource == 4)) {
 		_vm->_dialogs->show(801);
 		_action._inProgress = false;
 	}
 }
 
 void Scene102::postActions() {
-	if (_action.isAction(VERB_PUT, 0x127) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
+	if (_action.isAction(VERB_PUT, NOUN_ROBO_KITCHEN) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
 		_vm->_dialogs->show(10217);
 		_action._inProgress = false;
 	}
@@ -1716,23 +1716,23 @@ void Scene104::step() {
 }
 
 void Scene104::preActions() {
-	if (_action.isAction(VERB_SWIM_TOWARDS, 0x74))
+	if (_action.isAction(VERB_SWIM_TOWARDS, NOUN_EASTERN_CLIFF_FACE))
 		_game._player._walkOffScreenSceneId = 105;
 
-	if (_action.isAction(VERB_SWIM_TOWARDS, 0x75))
+	if (_action.isAction(VERB_SWIM_TOWARDS, NOUN_EAT))
 		_game._player._walkOffScreenSceneId = 106;
 }
 
 void Scene104::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(10405);
-	else if (_action.isAction(VERB_LOOK, 0x5E))
+	else if (_action.isAction(VERB_LOOK, NOUN_CURIOUS_WEED_PATCH))
 		_vm->_dialogs->show(10404);
-	else if (_action.isAction(VERB_LOOK, 0x158))
+	else if (_action.isAction(VERB_LOOK, NOUN_SURFACE))
 		_vm->_dialogs->show(10403);
-	else if (_action.isAction(VERB_LOOK, 0x4D))
+	else if (_action.isAction(VERB_LOOK, NOUN_CLIFF_FACE))
 		_vm->_dialogs->show(10401);
-	else if (_action.isAction(VERB_LOOK, 0xF0))
+	else if (_action.isAction(VERB_LOOK, NOUN_OCEAN_FLOOR))
 		_vm->_dialogs->show(10402);
 	else
 		return;
@@ -1843,10 +1843,10 @@ void Scene105::step() {
 }
 
 void Scene105::preActions() {
-	if (_action.isAction(VERB_SWIM_TOWARDS, 0x195))
+	if (_action.isAction(VERB_SWIM_TOWARDS, NOUN_WESTERN_CLIFF_FACE))
 		_game._player._walkOffScreenSceneId = 104;
 
-	if (_action.isAction(VERB_SWIM_TOWARDS, 0xF5))
+	if (_action.isAction(VERB_SWIM_TOWARDS, NOUN_OPEN_AREA_TO_SOUTH))
 		_game._player._walkOffScreenSceneId = 107;
 
 	if (_action.isObject(0xE0) && (_action.isAction(VERB_TALKTO) || _action.isAction(VERB_LOOK)))
@@ -1856,7 +1856,7 @@ void Scene105::preActions() {
 void Scene105::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(10512);
-	else if (_action.isAction(VERB_TAKE, 0x65) && _globals[kFishIn105]) {
+	else if (_action.isAction(VERB_TAKE, NOUN_DEAD_FISH) && _globals[kFishIn105]) {
 		if (_game._objects.isInInventory(OBJ_DEAD_FISH)) {
 			int randVal = _vm->getRandomNumber(74, 76);
 			_scene->_kernelMessages.reset();
@@ -1867,25 +1867,25 @@ void Scene105::actions() {
 			_globals[kFishIn105] = false;
 			_vm->_dialogs->showItem(OBJ_DEAD_FISH, 802, 0);
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x195))
+	} else if (_action.isAction(VERB_LOOK, NOUN_WESTERN_CLIFF_FACE))
 		_vm->_dialogs->show(10501);
-	else if (_action.isAction(VERB_LOOK, 0x4D))
+	else if (_action.isAction(VERB_LOOK, NOUN_CLIFF_FACE))
 		_vm->_dialogs->show(10502);
-	else if (_action.isAction(VERB_LOOK, 0xF0))
+	else if (_action.isAction(VERB_LOOK, NOUN_OCEAN_FLOOR))
 		_vm->_dialogs->show(10503);
-	else if (_action.isAction(VERB_LOOK, 0xDD))
+	else if (_action.isAction(VERB_LOOK, NOUN_MEDICAL_WASTE))
 		_vm->_dialogs->show(10504);
-	else if (_action.isAction(VERB_TAKE, 0xDD))
+	else if (_action.isAction(VERB_TAKE, NOUN_MEDICAL_WASTE))
 		_vm->_dialogs->show(10505);
-	else if (_action.isAction(VERB_LOOK, 0xE0))
+	else if (_action.isAction(VERB_LOOK, NOUN_MINE))
 		_vm->_dialogs->show(10506);
-	else if (_action.isAction(VERB_LOOK, 0x65))
+	else if (_action.isAction(VERB_LOOK, NOUN_DEAD_FISH))
 		_vm->_dialogs->show(10508);
-	else if (_action.isAction(VERB_LOOK, 0x158))
+	else if (_action.isAction(VERB_LOOK, NOUN_SURFACE))
 		_vm->_dialogs->show(10509);
-	else if (_action.isAction(VERB_LOOK, 0xF5))
+	else if (_action.isAction(VERB_LOOK, NOUN_OPEN_AREA_TO_SOUTH))
 		_vm->_dialogs->show(10510);
-	else if (_action.isAction(VERB_LOOK, 0x129))
+	else if (_action.isAction(VERB_LOOK, NOUN_ROCKS))
 		_vm->_dialogs->show(10511);
 	else
 		return;
@@ -2052,20 +2052,20 @@ void Scene106::step() {
 }
 
 void Scene106::preActions() {
-	if (_action.isAction(VERB_SWIM_TOWARDS, 0x12E) || _action.isAction(VERB_SWIM_TOWARDS, 0x130)) {
+	if (_action.isAction(VERB_SWIM_TOWARDS, NOUN_SEA_CLIFF) || _action.isAction(VERB_SWIM_TOWARDS, NOUN_SEAWEED_BANK)) {
 		_game._player._stepEnabled = false;
 		_scene->_sprites[_game._player._spritesStart + 1]->_charInfo->_velocity = 24;
 		_game._player._walkOffScreenSceneId = 104;
 	}
 
-	if (_action.isAction(VERB_SWIM_TOWARDS, 0xF3))
+	if (_action.isAction(VERB_SWIM_TOWARDS, NOUN_OPEN_AREA_TO_EAST))
 		_game._player._walkOffScreenSceneId = 107;
 }
 
 void Scene106::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(10614);
-	else if (_action.isAction(VERB_SWIM_TO, 0xD9)) {
+	else if (_action.isAction(VERB_SWIM_TO, NOUN_MAIN_AIRLOCK)) {
 		_game._player._stepEnabled = false;
 		_game._player._prepareWalkPos = Common::Point(95, 72);
 		_game._player._prepareWalkFacing = FACING_WEST;
@@ -2073,31 +2073,31 @@ void Scene106::actions() {
 		_game._player._readyToWalk = true;
 		_game._player._frameNumber = 9;
 		_backToShipFl = true;
-	} else if (_action.isAction(VERB_LOOK, 0x13) || _action.isAction(VERB_LOOK_AT, 0x13))
+	} else if (_action.isAction(VERB_LOOK, NOUN_ANEMONE) || _action.isAction(VERB_LOOK_AT, NOUN_ANEMONE))
 		_vm->_dialogs->show(10601);
-	else if (_action.isAction(VERB_TAKE, 0x13))
+	else if (_action.isAction(VERB_TAKE, NOUN_ANEMONE))
 		_vm->_dialogs->show(10602);
-	else if (_action.isAction(VERB_LOOK, 0x12F) || _action.isAction(VERB_LOOK, 0x130))
+	else if (_action.isAction(VERB_LOOK, NOUN_SEAWEED) || _action.isAction(VERB_LOOK, NOUN_SEAWEED_BANK))
 		_vm->_dialogs->show(10603);
-	else if (_action.isAction(VERB_TAKE, 0x12F) || _action.isAction(VERB_TAKE, 0x130))
+	else if (_action.isAction(VERB_TAKE, NOUN_SEAWEED) || _action.isAction(VERB_TAKE, NOUN_SEAWEED_BANK))
 		_vm->_dialogs->show(10604);
-	else if (_action.isAction(VERB_LOOK, 0xF3))
+	else if (_action.isAction(VERB_LOOK, NOUN_OPEN_AREA_TO_EAST))
 		_vm->_dialogs->show(10605);
-	else if (_action.isAction(VERB_LOOK, 0x109) || _action.isAction(VERB_LOOK_AT, 0x109))
+	else if (_action.isAction(VERB_LOOK, NOUN_PILE_OF_ROCKS) || _action.isAction(VERB_LOOK_AT, NOUN_PILE_OF_ROCKS))
 		_vm->_dialogs->show(10606);
 	else if (_action.isObject(0x109) && (_action.isAction(VERB_PUSH) || _action.isAction(VERB_PULL) || _action.isAction(VERB_TAKE)))
 		_vm->_dialogs->show(10607);
-	else if (_action.isAction(VERB_LOOK, 0x139) || _action.isAction(VERB_LOOK_AT, 0x139))
+	else if (_action.isAction(VERB_LOOK, NOUN_SHIP) || _action.isAction(VERB_LOOK_AT, NOUN_SHIP))
 		_vm->_dialogs->show(10608);
-	else if (_action.isAction(VERB_LOOK, 0xD9))
+	else if (_action.isAction(VERB_LOOK, NOUN_MAIN_AIRLOCK))
 		_vm->_dialogs->show(10609);
-	else if (_action.isAction(VERB_OPEN, 0xD9))
+	else if (_action.isAction(VERB_OPEN, NOUN_MAIN_AIRLOCK))
 		_vm->_dialogs->show(10610);
-	else if (_action.isAction(VERB_CLOSE, 0xD9))
+	else if (_action.isAction(VERB_CLOSE, NOUN_MAIN_AIRLOCK))
 		_vm->_dialogs->show(10611);
-	else if (_action.isAction(VERB_LOOK, 0x12E))
+	else if (_action.isAction(VERB_LOOK, NOUN_SEA_CLIFF))
 		_vm->_dialogs->show(10612);
-	else if (_action.isAction(VERB_LOOK, 0xF0))
+	else if (_action.isAction(VERB_LOOK, NOUN_OCEAN_FLOOR))
 		_vm->_dialogs->show(10613);
 	else
 		return;
@@ -2178,17 +2178,17 @@ void Scene107::step() {
 }
 
 void Scene107::preActions() {
-	if (_action.isAction(VERB_SWIM_TOWARDS, 0xF6))
+	if (_action.isAction(VERB_SWIM_TOWARDS, NOUN_OPEN_AREA_TO_WEST))
 		_game._player._walkOffScreenSceneId = 106;
 
-	if (_action.isAction(VERB_SWIM_TOWARDS, 0xF5))
+	if (_action.isAction(VERB_SWIM_TOWARDS, NOUN_OPEN_AREA_TO_SOUTH))
 		_game._player._walkOffScreenSceneId = 108;
 }
 
 void Scene107::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(10708);
-	else if (_action.isAction(VERB_TAKE, 0x65) && _globals[kFishIn107]) {
+	else if (_action.isAction(VERB_TAKE, NOUN_DEAD_FISH) && _globals[kFishIn107]) {
 		if (_game._objects.isInInventory(OBJ_DEAD_FISH)) {
 			int randVal = _vm->getRandomNumber(74, 76);
 			_scene->_kernelMessages.reset();
@@ -2199,25 +2199,25 @@ void Scene107::actions() {
 			_globals[kFishIn107] = false;
 			_vm->_dialogs->showItem(OBJ_DEAD_FISH, 802);
 		}
-	} else if (_action.isAction(VERB_SWIM_TOWARDS, 0xEE))
+	} else if (_action.isAction(VERB_SWIM_TOWARDS, NOUN_NORTHERN_SEA_CLIFF))
 		_scene->_nextSceneId = 105;
-	else if (_action.isAction(VERB_LOOK, 0xEE))
+	else if (_action.isAction(VERB_LOOK, NOUN_NORTHERN_SEA_CLIFF))
 		_vm->_dialogs->show(10701);
-	else if (_action.isAction(VERB_LOOK, 0x65) && (_action._mainObjectSource == 4))
+	else if (_action.isAction(VERB_LOOK, NOUN_DEAD_FISH) && (_action._mainObjectSource == 4))
 		_vm->_dialogs->show(10702);
-	else if (_action.isAction(VERB_LOOK, 0x38))
+	else if (_action.isAction(VERB_LOOK, NOUN_BUSH_LIKE_FORMATION))
 		_vm->_dialogs->show(10703);
-	else if (_action.isAction(VERB_LOOK, 0x128))
+	else if (_action.isAction(VERB_LOOK, NOUN_ROCK))
 		_vm->_dialogs->show(10704);
-	else if (_action.isAction(VERB_LOOK, 0x12F))
+	else if (_action.isAction(VERB_LOOK, NOUN_SEAWEED))
 		_vm->_dialogs->show(10705);
-	else if (_action.isAction(VERB_LOOK, 0xF5))
+	else if (_action.isAction(VERB_LOOK, NOUN_OPEN_AREA_TO_SOUTH))
 		_vm->_dialogs->show(10706);
-	else if (_action.isAction(VERB_LOOK, 0x4D))
+	else if (_action.isAction(VERB_LOOK, NOUN_CLIFF_FACE))
 		_vm->_dialogs->show(10707);
-	else if (_action.isAction(VERB_LOOK, 0xDA))
+	else if (_action.isAction(VERB_LOOK, NOUN_MANTA_RAY))
 		_vm->_dialogs->show(10709);
-	else if (_action.isAction(VERB_TAKE, 0xDA))
+	else if (_action.isAction(VERB_TAKE, NOUN_MANTA_RAY))
 		_vm->_dialogs->show(10710);
 	else
 		return;
@@ -2273,14 +2273,14 @@ void Scene108::enter() {
 }
 
 void Scene108::preActions() {
-	if (_action.isAction(VERB_SWIM_UNDER, 0xFB))
+	if (_action.isAction(VERB_SWIM_UNDER, NOUN_OVERHANG_TO_EAST))
 		_game._player._walkOffScreenSceneId = 109;
 }
 
 void Scene108::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(10812);
-	else if (_action.isAction(VERB_TAKE, 0x65) && _globals[kFishIn108]) {
+	else if (_action.isAction(VERB_TAKE, NOUN_DEAD_FISH) && _globals[kFishIn108]) {
 		if (_game._objects.isInInventory(OBJ_DEAD_FISH)) {
 			int randVal = _vm->getRandomNumber(74, 76);
 			_scene->_kernelMessages.reset();
@@ -2291,27 +2291,27 @@ void Scene108::actions() {
 			_globals[kFishIn108] = false;
 			_vm->_dialogs->showItem(OBJ_DEAD_FISH, 10808);
 		}
-	} else if (_action.isAction(VERB_SWIM_TOWARDS, 0xF4))
+	} else if (_action.isAction(VERB_SWIM_TOWARDS, NOUN_OPEN_AREA_TO_NORTH))
 		_scene->_nextSceneId = 107;
-	else if (_action.isAction(VERB_LOOK, 0x4D))
+	else if (_action.isAction(VERB_LOOK, NOUN_CLIFF_FACE))
 		_vm->_dialogs->show(10801);
-	else if (_action.isAction(VERB_LOOK, 0xF0))
+	else if (_action.isAction(VERB_LOOK, NOUN_OCEAN_FLOOR))
 		_vm->_dialogs->show(10802);
-	else if (_action.isAction(VERB_LOOK, 0xF1))
+	else if (_action.isAction(VERB_LOOK, NOUN_ODD_ROCK_FORMATION))
 		_vm->_dialogs->show(10803);
-	else if (_action.isAction(VERB_TAKE, 0xF1))
+	else if (_action.isAction(VERB_TAKE, NOUN_ODD_ROCK_FORMATION))
 		_vm->_dialogs->show(10804);
-	else if (_action.isAction(VERB_LOOK, 0x129))
+	else if (_action.isAction(VERB_LOOK, NOUN_ROCKS))
 		_vm->_dialogs->show(10805);
-	else if (_action.isAction(VERB_TAKE, 0x129))
+	else if (_action.isAction(VERB_TAKE, NOUN_ROCKS))
 		_vm->_dialogs->show(10806);
-	else if (_action.isAction(VERB_LOOK, 0x65))
+	else if (_action.isAction(VERB_LOOK, NOUN_DEAD_FISH))
 		_vm->_dialogs->show(10807);
-	else if (_action.isAction(VERB_LOOK, 0xFB))
+	else if (_action.isAction(VERB_LOOK, NOUN_OVERHANG_TO_EAST))
 		_vm->_dialogs->show(10809);
-	else if (_action.isAction(VERB_LOOK, 0xF4))
+	else if (_action.isAction(VERB_LOOK, NOUN_OPEN_AREA_TO_NORTH))
 		_vm->_dialogs->show(10810);
-	else if (_action.isAction(VERB_LOOK, 0x158))
+	else if (_action.isAction(VERB_LOOK, NOUN_SURFACE))
 		_vm->_dialogs->show(10811);
 	else
 		return;
@@ -2485,7 +2485,7 @@ void Scene109::step() {
 }
 
 void Scene109::preActions() {
-	if (_action.isAction(VERB_SWIM_UNDER, 0xFC))
+	if (_action.isAction(VERB_SWIM_UNDER, NOUN_OVERHANG_TO_WEST))
 		_game._player._walkOffScreenSceneId = 108;
 
 	if ((_action.isAction(VERB_THROW) || _action.isAction(VERB_GIVE) || _action.isAction(VERB_PUT))
@@ -2500,7 +2500,7 @@ void Scene109::preActions() {
 		}
 	}
 
-	if ((_action.isAction(VERB_SWIM_INTO, 0x178) || _action.isAction(VERB_SWIM_TO, 0x146))
+	if ((_action.isAction(VERB_SWIM_INTO, NOUN_TUNNEL) || _action.isAction(VERB_SWIM_TO, NOUN_SMALL_HOLE))
 	&& (!_globals[kHoovicAlive] || _globals[kHoovicSated]) && (_action.isObject(0x178)))
 		_game._player._walkOffScreenSceneId = 110;
 
@@ -2685,33 +2685,33 @@ void Scene109::actions() {
 		}
 	}
 
-	if (_action.isAction(VERB_TAKE, 0x35) && _game._objects.isInRoom(OBJ_BURGER)) {
+	if (_action.isAction(VERB_TAKE, NOUN_BURGER) && _game._objects.isInRoom(OBJ_BURGER)) {
 		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
 		_game._objects.addToInventory(OBJ_BURGER);
-	} else if (_action.isAction(VERB_LOOK, 0xF0))
+	} else if (_action.isAction(VERB_LOOK, NOUN_OCEAN_FLOOR))
 		_vm->_dialogs->show(10901);
-	else if (_action.isAction(VERB_LOOK, 0x5A))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORAL))
 		_vm->_dialogs->show(10902);
 	else if ((_action.isAction(VERB_TAKE) || _action.isAction(VERB_PULL)) && _action.isObject(0x5A))
 		_vm->_dialogs->show(10903);
-	else if (_action.isAction(VERB_LOOK, 0x129))
+	else if (_action.isAction(VERB_LOOK, NOUN_ROCKS))
 		_vm->_dialogs->show(10904);
-	else if (_action.isAction(VERB_TAKE, 0x129))
+	else if (_action.isAction(VERB_TAKE, NOUN_ROCKS))
 		_vm->_dialogs->show(10905);
-	else if (_action.isAction(VERB_LOOK, 0x45))
+	else if (_action.isAction(VERB_LOOK, NOUN_CAVE_WALL))
 		_vm->_dialogs->show(10906);
-	else if (_action.isAction(VERB_LOOK, 0x178)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_TUNNEL)) {
 		if (_globals[kHoovicAlive])
 			_vm->_dialogs->show(10907);
 		else
 			_vm->_dialogs->show(10913);
-	} else if (_action.isAction(VERB_LOOK, 0x146))
+	} else if (_action.isAction(VERB_LOOK, NOUN_SMALL_HOLE))
 		_vm->_dialogs->show(10908);
-	else if (_action.isAction(VERB_LOOK, 0xFC))
+	else if (_action.isAction(VERB_LOOK, NOUN_OVERHANG_TO_WEST))
 		_vm->_dialogs->show(10911);
-	else if (_action.isAction(VERB_PUT, 0x146))
+	else if (_action.isAction(VERB_PUT, NOUN_SMALL_HOLE))
 		_vm->_dialogs->show(10910);
-	else if (_action.isAction(VERB_LOOK, 0x66))
+	else if (_action.isAction(VERB_LOOK, NOUN_DEAD_PURPLE_MONSTER))
 		_vm->_dialogs->show(10914);
 	else
 		return;
@@ -2789,7 +2789,7 @@ void Scene110::step() {
 }
 
 void Scene110::preActions() {
-	if (_action.isAction(VERB_SWIM_THROUGH, 0x41))
+	if (_action.isAction(VERB_SWIM_THROUGH, NOUN_CAVE_ENTRANCE))
 		_game._player._walkOffScreenSceneId = 109;
 
 	if (_crabsFl) {
@@ -2817,7 +2817,7 @@ void Scene110::preActions() {
 }
 
 void Scene110::actions() {
-	if (_action.isAction(VERB_SWIM_THROUGH, 0x178)) {
+	if (_action.isAction(VERB_SWIM_THROUGH, NOUN_TUNNEL)) {
 		switch (_game._trigger) {
 		case 0:
 			_scene->loadAnimation(Resources::formatName(110, 'T', 0, EXT_AA, ""), 1);
@@ -2831,21 +2831,21 @@ void Scene110::actions() {
 			_scene->_nextSceneId = 111;
 			break;
 		}
-	} else if ((_action._lookFlag) || _action.isAction(VERB_LOOK, 0x3F))
+	} else if ((_action._lookFlag) || _action.isAction(VERB_LOOK, NOUN_CAVE))
 		_vm->_dialogs->show(11001);
-	else if (_action.isAction(VERB_LOOK, 0x40) || _action.isAction(VERB_LOOK_AT, 0x40))
+	else if (_action.isAction(VERB_LOOK, NOUN_CAVE_CEILING) || _action.isAction(VERB_LOOK_AT, NOUN_CAVE_CEILING))
 		_vm->_dialogs->show(11002);
-	else if (_action.isAction(VERB_LOOK, 0x129))
+	else if (_action.isAction(VERB_LOOK, NOUN_ROCKS))
 		_vm->_dialogs->show(11003);
-	else if (_action.isAction(VERB_TAKE, 0x129))
+	else if (_action.isAction(VERB_TAKE, NOUN_ROCKS))
 		_vm->_dialogs->show(11004);
-	else if (_action.isAction(VERB_LOOK, 0x178))
+	else if (_action.isAction(VERB_LOOK, NOUN_TUNNEL))
 		_vm->_dialogs->show(11005);
-	else if (_action.isAction(VERB_LOOK, 0x41))
+	else if (_action.isAction(VERB_LOOK, NOUN_CAVE_ENTRANCE))
 		_vm->_dialogs->show(11006);
-	else if (_action.isAction(VERB_LOOK, 0x8F))
+	else if (_action.isAction(VERB_LOOK, NOUN_FUNGOIDS))
 		_vm->_dialogs->show(11007);
-	else if (_action.isAction(VERB_TAKE, 0x8F))
+	else if (_action.isAction(VERB_TAKE, NOUN_FUNGOIDS))
 		_vm->_dialogs->show(11008);
 	else
 		return;
@@ -2964,12 +2964,12 @@ void Scene111::step() {
 }
 
 void Scene111::preActions() {
-	if (_action.isAction(VERB_WALK_THROUGH, 0x41))
+	if (_action.isAction(VERB_WALK_THROUGH, NOUN_CAVE_ENTRANCE))
 		_game._player._walkOffScreenSceneId = 212;
 }
 
 void Scene111::actions() {
-	if (_action.isAction(VERB_DIVE_INTO, 0x116) && _game._objects.isInInventory(OBJ_REBREATHER)) {
+	if (_action.isAction(VERB_DIVE_INTO, NOUN_POOL) && _game._objects.isInInventory(OBJ_REBREATHER)) {
 		switch (_game._trigger) {
 		case 0:
 			_scene->loadAnimation(Resources::formatName(111, 'A', 1, EXT_AA, ""), 1);
@@ -2982,15 +2982,15 @@ void Scene111::actions() {
 			_scene->_nextSceneId = 110;
 			break;
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x43))
+	} else if (_action.isAction(VERB_LOOK, NOUN_CAVE_FLOOR))
 		_vm->_dialogs->show(11101);
-	else if (_action.isAction(VERB_LOOK, 0x116))
+	else if (_action.isAction(VERB_LOOK, NOUN_POOL))
 		_vm->_dialogs->show(11102);
-	else if (_action.isAction(VERB_LOOK, 0x41))
+	else if (_action.isAction(VERB_LOOK, NOUN_CAVE_ENTRANCE))
 		_vm->_dialogs->show(11103);
-	else if (_action.isAction(VERB_LOOK, 0x153))
+	else if (_action.isAction(VERB_LOOK, NOUN_STALAGMITES))
 		_vm->_dialogs->show(11104);
-	else if (_action.isAction(VERB_LOOK, 0xC8))
+	else if (_action.isAction(VERB_LOOK, NOUN_LARGE_STALAGMITE))
 		_vm->_dialogs->show(11105);
 	else if ((_action.isAction(VERB_PULL) || _action.isAction(VERB_TAKE)) && (_action.isObject(0x153) || _action.isObject(0xC8)))
 		_vm->_dialogs->show(11106);
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index cfb261c..173c641 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -121,7 +121,7 @@ void Scene201::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 
-	_scene->addActiveVocab(NOUN_15F);
+	_scene->addActiveVocab(NOUN_SWOOPING_CREATURE);
 	_scene->addActiveVocab(NOUN_BIRDS);
 	_scene->addActiveVocab(VERB_WALKTO);
 }
@@ -280,9 +280,9 @@ void Scene201::step() {
 
 void Scene201::actions() {
 	if (_action._lookFlag == false) {
-		if (_action.isAction(VERB_WALK_TOWARDS, 0x83))
+		if (_action.isAction(VERB_WALK_TOWARDS, NOUN_FIELD_TO_SOUTH))
 			_scene->_nextSceneId = 202;
-		else if ((_action.isAction(VERB_CLIMB_UP, 0x156)) || (_action.isAction(VERB_WALK_INSIDE, NOUN_TELEPORTER)) || (_action.isAction(VERB_WALK_INSIDE, NOUN_STRANGE_DEVICE))) {
+		else if ((_action.isAction(VERB_CLIMB_UP, NOUN_STEPS)) || (_action.isAction(VERB_WALK_INSIDE, NOUN_TELEPORTER)) || (_action.isAction(VERB_WALK_INSIDE, NOUN_STRANGE_DEVICE))) {
 			if (_game._trigger == 0) {
 				_game._player._stepEnabled = false;
 				_game._player._visible = false;
@@ -291,30 +291,30 @@ void Scene201::actions() {
 			} else if (_game._trigger == 1) {
 				_scene->_nextSceneId = 213;
 			}
-		} else if (_action.isAction(VERB_LOOK, 0x1A6)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_GRASSY_FIELD)) {
 			_vm->_dialogs->show(20101);
-		} else if (_action.isAction(VERB_LOOK, 0x129)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_ROCKS)) {
 			_vm->_dialogs->show(20102);
-		} else if (_action.isAction(VERB_LOOK, 0x16F)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_THORNY_BUSH)) {
 			_vm->_dialogs->show(20103);
-		} else if (_action.isAction(VERB_LOOK, 0x142)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_SKY)) {
 			_vm->_dialogs->show(20104);
-		} else if (_action.isAction(VERB_LOOK, 0x18F)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_WATER)) {
 			_vm->_dialogs->show(20105);
-		} else if (_action.isAction(VERB_LOOK, 0x1B9)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_ISLAND_IN_DISTANCE)) {
 			_vm->_dialogs->show(20106);
-		} else if (_action.isAction(VERB_LOOK, 0x192)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_WEATHER_STATION)) {
 			_vm->_dialogs->show(20107);
-		} else if (_action.isAction(VERB_LOOK, 0x1BA)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_PATH)) {
 			_vm->_dialogs->show(20108);
-		} else if (_action.isAction(VERB_LOOK, 0x83)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_FIELD_TO_SOUTH)) {
 			_vm->_dialogs->show(20110);
-		} else if (_action.isAction(VERB_LOOK, 0x1B6)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_STRANGE_DEVICE)) {
 			if (_globals[kMeteorologistEverSeen])
 				_vm->_dialogs->show(20112);
 			else
 				_vm->_dialogs->show(20109);
-		} else if (_action.isAction(VERB_LOOK, 0x16C)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_TELEPORTER)) {
 			_vm->_dialogs->show(20113);
 		} else
 			return;
@@ -731,7 +731,7 @@ void Scene202::preActions() {
 		}
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x27) && (_action._activeAction._indirectObjectId > 0)) {
+	if (_action.isAction(VERB_LOOK, NOUN_BINOCULARS) && (_action._activeAction._indirectObjectId > 0)) {
 		if (!player._readyToWalk || _ladderTopFl)
 			_game._player._needToWalk = false;
 		else
@@ -751,9 +751,9 @@ void Scene202::actions() {
 	if (_action.isAction(VERB_CLIMB_DOWN, NOUN_LADDER)) {
 		_action._inProgress = false;
 		return;
-	} else if (_action.isAction(VERB_WALK_TOWARDS, 0x83)) {
+	} else if (_action.isAction(VERB_WALK_TOWARDS, NOUN_FIELD_TO_SOUTH)) {
 		_scene->_nextSceneId = 203;
-	} else if (_action.isAction(VERB_WALK_TOWARDS, 0x82)) {
+	} else if (_action.isAction(VERB_WALK_TOWARDS, NOUN_FIELD_TO_NORTH)) {
 		if (_globals[kMeteorologistStatus] != METEOROLOGIST_GONE) {
 			if (_scene->_activeAnimation)
 				_globals[kMeteorologistStatus] = METEOROLOGIST_PRESENT;
@@ -930,37 +930,37 @@ void Scene202::actions() {
 				return;
 			}
 		}
-	} else if (_action.isAction(VERB_WALK_INSIDE, 0xAA)) {
+	} else if (_action.isAction(VERB_WALK_INSIDE, NOUN_HUT)) {
 		setRandomKernelMessage();
 	} else if (_action.isAction(VERB_LOOK, NOUN_ROCKS)) {
 		_vm->_dialogs->show(20202);
-	} else if (_action.isAction(VERB_LOOK, 0x86)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_FIRE_PIT)) {
 		_vm->_dialogs->show(20203);
-	} else if (_action.isAction(VERB_LOOK, 0x19C)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_GRASS)) {
 		_vm->_dialogs->show(20204);
-	} else if (_action.isAction(VERB_LOOK, 0x82)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_FIELD_TO_NORTH)) {
 		if ((_globals[kMeteorologistStatus] == METEOROLOGIST_ABSENT) || (_globals[kMeteorologistStatus] == METEOROLOGIST_GONE))
 			_vm->_dialogs->show(20205);
 		else if (_globals[kMeteorologistStatus] == METEOROLOGIST_PRESENT)
 			_vm->_dialogs->show(20220);
-	} else if (_action.isAction(VERB_LOOK, 0x18E)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_WATCH_TOWER)) {
 		_vm->_dialogs->show(20206);
-	} else if (_action.isAction(VERB_LOOK, 0x164)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_TALL_GRASS)) {
 		_vm->_dialogs->show(20207);
-	} else if (_action.isAction(VERB_LOOK, 0x175)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_TREES)) {
 		_vm->_dialogs->show(20208);
-	} else if (_action.isAction(VERB_LOOK, 0x174)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_TREE)) {
 		_vm->_dialogs->show(20209);
-	} else if (_action.isAction(VERB_LOOK, 0x142)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_SKY)) {
 		_vm->_dialogs->show(20210);
-	} else if (_action.isAction(VERB_LOOK, 0xAA)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_HUT)) {
 		if ((_game._player._playerPos == Common::Point(77, 105)) && (_game._player._facing == FACING_NORTH))
 			_vm->_dialogs->show(20212);
 		else
 			_vm->_dialogs->show(20211);
 	} else if (_action.isAction(VERB_LOOK, NOUN_STRANGE_DEVICE)) {
 		_vm->_dialogs->show(20213);
-	} else if (_action.isAction(VERB_LOOK, 0x1B5)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_OCEAN_IN_DISTANCE)) {
 		_vm->_dialogs->show(20214);
 	} else if (_action.isAction(VERB_LOOK, NOUN_SKULL)) {
 		_vm->_dialogs->show(20215);
@@ -1070,34 +1070,34 @@ void Scene203::step() {
 }
 
 void Scene203::preActions() {
-	if (_rhotundaEatFl && !_action.isAction(VERB_WALK_TOWARDS, 0x83)) {
+	if (_rhotundaEatFl && !_action.isAction(VERB_WALK_TOWARDS, NOUN_FIELD_TO_SOUTH)) {
 		_game._player.walk(Common::Point(158, 136), FACING_SOUTH);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_WALKTO, 0xF3))
+	if (_action.isAction(VERB_WALKTO, NOUN_OPEN_AREA_TO_EAST))
 		_game._player._walkOffScreenSceneId = 209;
 }
 
 void Scene203::actions() {
 	if (_action._savedFields._lookFlag) {
 		_vm->_dialogs->show(20307);
-	} else if (_action.isAction(VERB_WALK_TOWARDS, 0x83)) {
+	} else if (_action.isAction(VERB_WALK_TOWARDS, NOUN_FIELD_TO_SOUTH)) {
 		_scene->_nextSceneId = 208;
-	} else if (_action.isAction(VERB_WALK_TOWARDS, 0x82)) {
+	} else if (_action.isAction(VERB_WALK_TOWARDS, NOUN_FIELD_TO_NORTH)) {
 		_scene->_nextSceneId = 202;
-	} else if (_action.isAction(VERB_LOOK, 0x142)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_SKY)) {
 		_vm->_dialogs->show(20301);
-	} else if (_action.isAction(VERB_LOOK, 0x4D)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_CLIFF_FACE)) {
 		_vm->_dialogs->show(20302);
-	} else if (_action.isAction(VERB_LOOK, 0x100)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_PALM_TREE)) {
 		_vm->_dialogs->show(20303);
-	} else if (_action.isAction(VERB_LOOK, 0x82)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_FIELD_TO_NORTH)) {
 		_vm->_dialogs->show(20304);
-	} else if (_action.isAction(VERB_LOOK, 0x1A6)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_GRASSY_FIELD)) {
 		_vm->_dialogs->show(20305);
-	} else if (_action.isAction(VERB_LOOK, 0x30)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_BOULDERS)) {
 		_vm->_dialogs->show(20305);
 	} else
 		return;
@@ -1301,9 +1301,9 @@ void Scene205::actions() {
 		}
 	} else if (_action._lookFlag)
 		_vm->_dialogs->show(20502);
-	else if (_action.isAction(VERB_LOOK, 0x27, 0x1C8))
+	else if (_action.isAction(VERB_LOOK, NOUN_BINOCULARS, 0x1C8))
 		_vm->_dialogs->show(20518);
-	else if (_action.isAction(VERB_TALKTO, 0x1DC)) {
+	else if (_action.isAction(VERB_TALKTO, NOUN_NATIVE_WOMAN)) {
 		if (_game._trigger == 0) {
 			_game._player._stepEnabled = false;
 			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 18, 1, 120, _game.getQuote(0x73));
@@ -1314,14 +1314,14 @@ void Scene205::actions() {
 			_dialog1.write(0x75, true);
 			_dialog1.start();
 		}
-	} else if (_action.isAction(VERB_GIVE, 0x1DC) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
+	} else if (_action.isAction(VERB_GIVE, NOUN_NATIVE_WOMAN) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
 		if (_game._trigger == 0) {
 			_game._player._stepEnabled = false;
 			int rndVal = _vm->getRandomNumber(0xAC, 0xAE);
 			_scene->_kernelMessages.add(Common::Point(186, 27), 0xFBFA, 32, 1, 120, _game.getQuote(rndVal));
 		} else if (_game._trigger == 1)
 			_game._player._stepEnabled = true;
-	} else if (_action.isAction(VERB_WALKTO, 0x1C8)) {
+	} else if (_action.isAction(VERB_WALKTO, NOUN_OPPOSITE_BANK)) {
 		if (_game._trigger == 0) {
 			_game._player._visible   = false;
 			_game._player._stepEnabled = false;
@@ -1342,50 +1342,50 @@ void Scene205::actions() {
 			_scene->_reloadSceneFlag = true;
 		}
 	} else {
-		if (_action.isAction(VERB_WALK_DOWN, 0x1C7))
+		if (_action.isAction(VERB_WALK_DOWN, NOUN_PATH_TO_SOUTH))
 			_scene->_nextSceneId = 210;
 
-		if (_action.isAction(VERB_WALKTO, 0x86) || _action.isAction(VERB_WALKTO, 0x1C2)) {
+		if (_action.isAction(VERB_WALKTO, NOUN_FIRE_PIT) || _action.isAction(VERB_WALKTO, NOUN_CHICKEN_ON_SPIT)) {
 			if (_game._objects.isInRoom(OBJ_CHICKEN)) {
 				_scene->_kernelMessages.reset();
 				_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x6B));
 			}
-		} else if (_action.isAction(VERB_TAKE, 0x1C2) && _globals[kChickenPermitted] && _game._objects.isInRoom(OBJ_CHICKEN)) {
+		} else if (_action.isAction(VERB_TAKE, NOUN_CHICKEN_ON_SPIT) && _globals[kChickenPermitted] && _game._objects.isInRoom(OBJ_CHICKEN)) {
 			_game._objects.addToInventory(OBJ_CHICKEN);
 			_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 			_scene->_hotspots.activate(0x1C2, false);
 			_vm->_dialogs->showItem(OBJ_CHICKEN, 812);
-		} else if (_action.isAction(VERB_TAKE, 0x1C2) && (!_globals[kChickenPermitted]))
+		} else if (_action.isAction(VERB_TAKE, NOUN_CHICKEN_ON_SPIT) && (!_globals[kChickenPermitted]))
 			_scene->_kernelMessages.add(Common::Point(186, 27), 0xFBFA, 32, 0, 120, _game.getQuote(0x80));
-		else if (_action.isAction(VERB_LOOK, 0x1DC))
+		else if (_action.isAction(VERB_LOOK, NOUN_NATIVE_WOMAN))
 			_vm->_dialogs->show(20503);
-		else if (_action.isAction(VERB_LOOK, 0xAA))
+		else if (_action.isAction(VERB_LOOK, NOUN_HUT))
 			_vm->_dialogs->show(20504);
-		else if (_action.isAction(VERB_LOOK, 0x49) && (_action._mainObjectSource == 4))
+		else if (_action.isAction(VERB_LOOK, NOUN_CHICKEN) && (_action._mainObjectSource == 4))
 			_vm->_dialogs->show(20505);
-		else if (_action.isAction(VERB_TAKE, 0x49) && (_action._mainObjectSource == 4))
+		else if (_action.isAction(VERB_TAKE, NOUN_CHICKEN) && (_action._mainObjectSource == 4))
 			_vm->_dialogs->show(20506);
-		else if (_action.isAction(VERB_LOOK, 0x1C2))
+		else if (_action.isAction(VERB_LOOK, NOUN_CHICKEN_ON_SPIT))
 			_vm->_dialogs->show(20507);
-		else if (_action.isAction(VERB_LOOK, 0x86))
+		else if (_action.isAction(VERB_LOOK, NOUN_FIRE_PIT))
 			_vm->_dialogs->show(20508);
-		else if (_action.isAction(VERB_TAKE, 0x86))
+		else if (_action.isAction(VERB_TAKE, NOUN_FIRE_PIT))
 			_vm->_dialogs->show(20509);
-		else if (_action.isAction(VERB_LOOK, 0x1C5))
+		else if (_action.isAction(VERB_LOOK, NOUN_STREAM))
 			_vm->_dialogs->show(20510);
-		else if (_action.isAction(VERB_LOOK, 0x1C8))
+		else if (_action.isAction(VERB_LOOK, NOUN_OPPOSITE_BANK))
 			_vm->_dialogs->show(20511);
 		else if (_game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))
-			&& (   _action.isAction(VERB_GIVE, 0x1C5) || _action.isAction(VERB_THROW, 0x1C5)
-			|| _action.isAction(VERB_GIVE, 0x10D) || _action.isAction(VERB_THROW, 0x10D)))
+			&& (   _action.isAction(VERB_GIVE, NOUN_STREAM) || _action.isAction(VERB_THROW, NOUN_STREAM)
+			|| _action.isAction(VERB_GIVE, NOUN_PIRANHA) || _action.isAction(VERB_THROW, NOUN_PIRANHA)))
 				_vm->_dialogs->show(20512);
-		else if (_action.isAction(VERB_LOOK, 0x10D))
+		else if (_action.isAction(VERB_LOOK, NOUN_PIRANHA))
 			_vm->_dialogs->show(20513);
-		else if (_action.isAction(VERB_LOOK, 0x1C4))
+		else if (_action.isAction(VERB_LOOK, NOUN_TWINKIFRUIT_BUSH))
 			_vm->_dialogs->show(20514);
-		else if (_action.isAction(VERB_TAKE, 0x1C4))
+		else if (_action.isAction(VERB_TAKE, NOUN_TWINKIFRUIT_BUSH))
 			_vm->_dialogs->show(20515);
-		else if (_action.isAction(VERB_TAKE, 0x1DC))
+		else if (_action.isAction(VERB_TAKE, NOUN_NATIVE_WOMAN))
 			_vm->_dialogs->show(20517);
 		else
 			return;
@@ -1519,10 +1519,10 @@ void Scene207::step() {
 }
 
 void Scene207::preActions() {
-	if (_action.isAction(VERB_WALK_DOWN, 0x1AE))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_PATH_TO_WEST))
 		_game._player._walkOffScreenSceneId = 211;
 
-	if (_action.isAction(VERB_WALK_TOWARDS, 0x1AB))
+	if (_action.isAction(VERB_WALK_TOWARDS, NOUN_OPEN_FIELD_TO_EAST))
 		_game._player._walkOffScreenSceneId = 208;
 
 	if ((_action.isAction(VERB_WALKTO)) || (_action.isAction(VERB_LOOK))) {
@@ -1537,7 +1537,7 @@ void Scene207::preActions() {
 void Scene207::actions() {
 	if (_action._savedFields._lookFlag) {
 		_vm->_dialogs->show(20711);
-	} else if (_action.isAction(VERB_WALK_THROUGH, 0x70)) {
+	} else if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOORWAY)) {
 		_scene->_nextSceneId = 214;
 	} else {
 		if ((_game._player._playerPos.x > 150) && (_game._player._playerPos.x < 189) &&
@@ -1555,33 +1555,33 @@ void Scene207::actions() {
 			_eyeFl = false;
 		}
 
-		if (_action.isAction(VERB_LOOK, 0x69)) {
+		if (_action.isAction(VERB_LOOK, NOUN_DENSE_FOREST)) {
 			_vm->_dialogs->show(20701);
-		} else if (_action.isAction(VERB_LOOK, 0x1AF)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_HEDGE)) {
 			_vm->_dialogs->show(20702);
-		} else if (_action.isAction(VERB_LOOK, 0x141)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_SKULL_AND_CROSSBONES)) {
 			_vm->_dialogs->show(20703);
-		} else if (_action.isAction(VERB_LOOK, 0x3E)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_CAULDRON)) {
 			_vm->_dialogs->show(20704);
-		} else if (_action.isAction(VERB_LOOK, 0x198)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_WITCHDOCTOR_HUT)) {
 			_vm->_dialogs->show(20705);
-		} else if (_action.isAction(VERB_LOOK, 0x1AE)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_PATH_TO_WEST)) {
 			_vm->_dialogs->show(20706);
-		} else if (_action.isAction(VERB_LOOK, 0xE8)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_MOUNTAINS)) {
 			_vm->_dialogs->show(20707);
-		} else if (_action.isAction(VERB_LOOK, 0x12)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_ALOE_PLANT)) {
 			_vm->_dialogs->show(20708);
-		} else if (_action.isAction(VERB_LOOK, 0x1AC)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_LAWN)) {
 			_vm->_dialogs->show(20709);
-		} else if (_action.isAction(VERB_LOOK, 0x185)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_VULTURE)) {
 			_vm->_dialogs->show(20710);
-		} else if (_action.isAction(VERB_TAKE, 0x141)) {
+		} else if (_action.isAction(VERB_TAKE, NOUN_SKULL_AND_CROSSBONES)) {
 			_vm->_dialogs->show(20712);
-		} else if (_action.isAction(VERB_TAKE, 0x12)) {
+		} else if (_action.isAction(VERB_TAKE, NOUN_ALOE_PLANT)) {
 			_vm->_dialogs->show(20713);
-		} else if (_action.isAction(VERB_LOOK, 0x14D)) {
+		} else if (_action.isAction(VERB_LOOK, NOUN_SPIDER)) {
 			_vm->_dialogs->show(20714);
-		} else if (_action.isAction(VERB_TAKE, 0x14D)) {
+		} else if (_action.isAction(VERB_TAKE, NOUN_SPIDER)) {
 			_vm->_dialogs->show(20715);
 		} else
 			return;
@@ -1725,10 +1725,10 @@ void Scene208::preActions() {
 	if (_action.isAction(VERB_LOOK) && player._readyToWalk)
 		player._needToWalk = true;
 
-	if (_action.isAction(VERB_WALK_TOWARDS, 0x9B))
+	if (_action.isAction(VERB_WALK_TOWARDS, NOUN_GRASSLAND_TO_EAST))
 		player._walkOffScreenSceneId = 209;
 
-	if (_action.isAction(VERB_WALK_TOWARDS, 0xF6))
+	if (_action.isAction(VERB_WALK_TOWARDS, NOUN_OPEN_AREA_TO_WEST))
 		player._walkOffScreenSceneId = 207;
 }
 
@@ -1804,7 +1804,7 @@ void Scene208::subAction(int mode) {
 }
 
 void Scene208::actions() {
-	if (_action.isAction(VERB_WALK_TOWARDS, 0x19F)) {
+	if (_action.isAction(VERB_WALK_TOWARDS, NOUN_LOWLANDS_TO_NORTH)) {
 		if (_globals[kRhotundaStatus])
 			_scene->_nextSceneId = 203;
 		else if (_game._trigger == 0) {
@@ -1814,7 +1814,7 @@ void Scene208::actions() {
 		} else if (_game._trigger == 1) {
 			_scene->_nextSceneId = 203;
 		}
-	} else if (_action.isAction(VERB_WALK_TOWARDS, 0x83)) {
+	} else if (_action.isAction(VERB_WALK_TOWARDS, NOUN_FIELD_TO_SOUTH)) {
 		_scene->_nextSceneId = 212;
 	} else if (_action.isAction(VERB_TAKE, NOUN_PILE_OF_LEAVES) && (!_globals[kLeavesStatus] || _game._trigger)) {
 		subAction(1);
@@ -1839,19 +1839,19 @@ void Scene208::actions() {
 		if (_game._player._stepEnabled) {
 			_vm->_dialogs->show(20812);
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x5D)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_CUMULOUS_CLOUD)) {
 		_vm->_dialogs->show(20801);
-	} else if (_action.isAction(VERB_LOOK, 0xF6)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_OPEN_AREA_TO_WEST)) {
 		_vm->_dialogs->show(20802);
-	} else if (_action.isAction(VERB_LOOK, 0x16F)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_THORNY_BUSH)) {
 		_vm->_dialogs->show(20803);
-	} else if (_action.isAction(VERB_LOOK, 0x129)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_ROCKS)) {
 		_vm->_dialogs->show(20804);
-	} else if (_action.isAction(VERB_LOOK, 0x1A1)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_SMALL_CACTUS)) {
 		_vm->_dialogs->show(20805);
-	} else if (_action.isAction(VERB_TAKE, 0x1A1)) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_SMALL_CACTUS)) {
 		_vm->_dialogs->show(20806);
-	} else if (_action.isAction(VERB_LOOK, 0x9B)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_GRASSLAND_TO_EAST)) {
 		_vm->_dialogs->show(20807);
 	} else if (_action.isAction(VERB_LOOK, NOUN_DEEP_PIT)) {
 		_vm->_dialogs->show(20808);
@@ -1862,7 +1862,7 @@ void Scene208::actions() {
 			_vm->_dialogs->show(20810);
 		else
 			_vm->_dialogs->show(20811);
-	} else if (_action.isAction(VERB_LOOK, 0x174) || _action.isAction(VERB_LOOK, 0x175)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_TREE) || _action.isAction(VERB_LOOK, NOUN_TREES)) {
 		_vm->_dialogs->show(20813);
 	} else if (_action.isAction(VERB_TAKE, NOUN_LEAF_COVERED_PIT)) {
 		_vm->_dialogs->show(20814);
@@ -3148,7 +3148,7 @@ void Scene209::step() {
 }
 
 void Scene209::preActions() {
-	if (_action.isAction(VERB_WALK_TOWARDS, 0x84))
+	if (_action.isAction(VERB_WALK_TOWARDS, NOUN_FIELD_TO_WEST))
 		_game._player._walkOffScreenSceneId = 208;
 
 	if (_globals[kMonkeyStatus] == MONKEY_HAS_BINOCULARS) {
@@ -3176,7 +3176,7 @@ void Scene209::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_WALK_TOWARDS, 0x1A2)) {
+	if (_action.isAction(VERB_WALK_TOWARDS, NOUN_ROCKY_AREA_TO_NORTH)) {
 		_scene->_nextSceneId = 203;
 		_action._inProgress = false;
 		return;
@@ -3353,7 +3353,7 @@ void Scene209::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_TAKE, 0x27) && (_game._trigger || _game._objects.isInRoom(OBJ_BINOCULARS))) {
+	if (_action.isAction(VERB_TAKE, NOUN_BINOCULARS) && (_game._trigger || _game._objects.isInRoom(OBJ_BINOCULARS))) {
 		switch (_game._trigger) {
 		case 0:
 			_globals._spriteIndexes[10] = _scene->_sprites.addSprites("*RXMBD_8");
@@ -3386,61 +3386,61 @@ void Scene209::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x142)) {
+	if (_action.isAction(VERB_LOOK, NOUN_SKY)) {
 		_vm->_dialogs->show(20901);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x1A3)) {
+	if (_action.isAction(VERB_LOOK, NOUN_BAMBOO_LIKE_PLANT)) {
 		_vm->_dialogs->show(20902);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x1A4)) {
+	if (_action.isAction(VERB_LOOK, NOUN_MOUNTAINSIDE)) {
 		_vm->_dialogs->show(20903);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x1A6)) {
+	if (_action.isAction(VERB_LOOK, NOUN_GRASSY_FIELD)) {
 		_vm->_dialogs->show(20904);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x84)) {
+	if (_action.isAction(VERB_LOOK, NOUN_FIELD_TO_WEST)) {
 		_vm->_dialogs->show(20905);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x1A2)) {
+	if (_action.isAction(VERB_LOOK, NOUN_ROCKY_AREA_TO_NORTH)) {
 		_vm->_dialogs->show(20906);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x10F) && (_action._savedFields._mainObjectSource == 4)) {
+	if (_action.isAction(VERB_LOOK, NOUN_PLANT_STALK) && (_action._savedFields._mainObjectSource == 4)) {
 		_vm->_dialogs->show(20907);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_GIVE, 0x17A, 0xE3) || _action.isAction(VERB_THROW, 0x17A, 0xE3)) {
+	if (_action.isAction(VERB_GIVE, NOUN_TWINKIFRUIT, 0xE3) || _action.isAction(VERB_THROW, NOUN_TWINKIFRUIT, 0xE3)) {
 		_vm->_dialogs->show(20909);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x175)) {
+	if (_action.isAction(VERB_LOOK, NOUN_TREES)) {
 		_vm->_dialogs->show(20913);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_THROW, 0xE3) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
+	if (_action.isAction(VERB_THROW, NOUN_MONKEY) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
 		if (!_action.isAction(0x114)) {
 			_vm->_dialogs->show(20915);
 		}
@@ -3448,13 +3448,13 @@ void Scene209::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_THROW, 0x114, 0xE3)) {
+	if (_action.isAction(VERB_THROW, NOUN_POISON_DARTS, 0xE3)) {
 		_vm->_dialogs->show(20916);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x100)) {
+	if (_action.isAction(VERB_LOOK, NOUN_PALM_TREE)) {
 		if (_globals[kMonkeyStatus] == MONKEY_HAS_BINOCULARS) {
 			if (_monkeyPosition == 1)
 				_vm->_dialogs->show(20917);
@@ -3470,13 +3470,13 @@ void Scene209::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x3A4)) {
+	if (_action.isAction(VERB_LOOK, NOUN_MELON_MUSH)) {
 		_vm->_dialogs->show(20920);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_TAKE, 0x3A4)) {
+	if (_action.isAction(VERB_TAKE, NOUN_MELON_MUSH)) {
 		_vm->_dialogs->show(20921);
 		_action._inProgress = false;
 		return;
@@ -4321,16 +4321,16 @@ void Scene210::step() {
 void Scene210::preActions() {
 	_stopWalking = false;
 
-	if (_action.isAction(VERB_WALK_DOWN, 0x1C1))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_PATH_TO_EAST))
 		_game._player._walkOffScreenSceneId = 211;
 }
 
 void Scene210::actions() {
-	if (_action.isAction(VERB_LOOK, 0x27, 0x1C0)) {
+	if (_action.isAction(VERB_LOOK, NOUN_BINOCULARS, 0x1C0)) {
 		_vm->_dialogs->show(21017);
 	} else if (_game._screenObjects._inputMode == 1) {
 		handleConversations();
-	} else if (_action.isAction(VERB_TALKTO, 0x1DC) ||
+	} else if (_action.isAction(VERB_TALKTO, NOUN_NATIVE_WOMAN) ||
 		((_game._player._playerPos == Common::Point(214, 150)) && (_game._player._facing == FACING_NORTHWEST) && (_twinkleAnimationType == 1) && _stopWalking)) {
 		switch (_game._trigger) {
 		case 0: {
@@ -4381,7 +4381,7 @@ void Scene210::actions() {
 			_curDialogNode = 1;
 			break;
 		}
-	} else if (_action.isAction(VERB_GIVE, 0x1DC) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
+	} else if (_action.isAction(VERB_GIVE, NOUN_NATIVE_WOMAN) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
 		switch (_game._trigger) {
 		case 0: {
 			int quote = _vm->getRandomNumber(172, 174);
@@ -4397,11 +4397,11 @@ void Scene210::actions() {
 			_shouldMoveHead = false;
 			break;
 		}
-	} else if (_action.isAction(VERB_WALK_DOWN, 0x1BF) || _action.isAction(VERB_WALK_TOWARDS, 0x1C0)) {
+	} else if (_action.isAction(VERB_WALK_DOWN, NOUN_PATH_TO_NORTH) || _action.isAction(VERB_WALK_TOWARDS, NOUN_HUT_TO_NORTH)) {
 		_scene->_nextSceneId = 205;
-	} else if (_action.isAction(VERB_WALK_THROUGH, 0x70)) {
+	} else if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOORWAY)) {
 		_scene->_nextSceneId = 215;
-	} else if ((_action.isAction(VERB_PULL, 0x5F) || _action.isAction(VERB_OPEN, 0x5F)) && !_globals[kCurtainOpen]) {
+	} else if ((_action.isAction(VERB_PULL, NOUN_CURTAIN) || _action.isAction(VERB_OPEN, NOUN_CURTAIN)) && !_globals[kCurtainOpen]) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -4419,7 +4419,7 @@ void Scene210::actions() {
 			_scene->_dynamicHotspots.setCursor(_doorway, CURSOR_GO_UP);
 			break;
 		}
-	} else if ((_action.isAction(VERB_PULL, 0x5F) || _action.isAction(VERB_CLOSE, 0x5F)) && _globals[kCurtainOpen]) {
+	} else if ((_action.isAction(VERB_PULL, NOUN_CURTAIN) || _action.isAction(VERB_CLOSE, NOUN_CURTAIN)) && _globals[kCurtainOpen]) {
 		switch (_game._trigger) {
 		case 0:
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
@@ -4441,7 +4441,7 @@ void Scene210::actions() {
 			_globals[kCurtainOpen] = false;
 			break;
 		}
-	} else if (_action.isAction(VERB_LOOK, 0xAA)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_HUT)) {
 		if (_globals[kTwinklesStatus] == TWINKLES_GONE) {
 			if (_game._storyMode == STORYMODE_NAUGHTY)
 				_vm->_dialogs->show(21003);
@@ -4450,31 +4450,31 @@ void Scene210::actions() {
 		} else {
 			_vm->_dialogs->show(21001);
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x31)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_BRA)) {
 		_vm->_dialogs->show(21004);
-	} else if (_action.isAction(VERB_LOOK, 0xA7)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_HOTPANTS)) {
 		_vm->_dialogs->show(21005);
-	} else if (_action.isAction(VERB_TAKE, 0xA7) || _action.isAction(VERB_TAKE, 0x31)) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_HOTPANTS) || _action.isAction(VERB_TAKE, NOUN_BRA)) {
 		_vm->_dialogs->show(21006);
-	} else if (_action.isAction(VERB_LOOK, 0x1C5)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_STREAM)) {
 		_vm->_dialogs->show(21007);
-	} else if (_action.isAction(VERB_LOOK, 0x3A)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_BUSHY_FERN)) {
 		_vm->_dialogs->show(21008);
-	} else if (_action.isAction(VERB_LOOK, 0x1B0)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_VILLAGE_PATH)) {
 		_vm->_dialogs->show(21009);
-	} else if (_action.isAction(VERB_LOOK, 0x1DC)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_NATIVE_WOMAN)) {
 		_vm->_dialogs->show(21010);
-	} else if (_action.isAction(VERB_SHOOT, 0x1DC) || _action.isAction(VERB_HOSE_DOWN, 0x1DC)) {
+	} else if (_action.isAction(VERB_SHOOT, NOUN_NATIVE_WOMAN) || _action.isAction(VERB_HOSE_DOWN, NOUN_NATIVE_WOMAN)) {
 		_vm->_dialogs->show(21011);
-	} else if (_action.isAction(VERB_LOOK, 0x1BF)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_PATH_TO_NORTH)) {
 		_vm->_dialogs->show(21012);
-	} else if (_action.isAction(VERB_LOOK, 0x5F)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_CURTAIN)) {
 		_vm->_dialogs->show(21013);
-	} else if (_action.isAction(VERB_LOOK, 0x53)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_CLOTHESLINE)) {
 		_vm->_dialogs->show(21014);
-	} else if (_action.isAction(VERB_TAKE, 0x53)) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_CLOTHESLINE)) {
 		_vm->_dialogs->show(21015);
-	} else if (_action.isAction(VERB_LOOK, 0x1C0)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_HUT_TO_NORTH)) {
 		_vm->_dialogs->show(21016);
 	} else {
 		// Not handled
@@ -4721,31 +4721,31 @@ void Scene211::step() {
 }
 
 void Scene211::preActions() {
-	if (_action.isAction(VERB_WALK_DOWN, 0x1B2) && _game._objects.isInInventory(OBJ_BINOCULARS) && (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY)
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_JUNGLE_PATH) && _game._objects.isInInventory(OBJ_BINOCULARS) && (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY)
 	&& (_scene->_customDest.x <= 52) && (_scene->_customDest.y >= 132))
 		_game._player.walk(Common::Point(52, 132), FACING_WEST);
 
-	if (_action.isAction(VERB_WALK_DOWN, 0x1AE)) {
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_PATH_TO_WEST)) {
 		if (_game._objects.isInInventory(OBJ_BINOCULARS) && (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY))
 			_game._player.walk(Common::Point(52, 132), FACING_WEST);
 		else
 			_game._player._walkOffScreenSceneId = 210;
 	}
 
-	if (_action.isAction(VERB_WALK_DOWN, 0x1B1))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_PATH_TO_NORTHEAST))
 		_game._player._walkOffScreenSceneId = 207;
 }
 
 void Scene211::actions() {
 	if (_action._lookFlag && (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY))
 		_vm->_dialogs->show(21111);
-	else if (_action.isAction(VERB_LOOK, 0x27, 0x100))
+	else if (_action.isAction(VERB_LOOK, NOUN_BINOCULARS, 0x100))
 		_vm->_dialogs->show(21116);
-	else if (_action.isAction(VERB_LOOK, 0x3A))
+	else if (_action.isAction(VERB_LOOK, NOUN_BUSHY_FERN))
 		_vm->_dialogs->show(21101);
-	else if (_action.isAction(VERB_LOOK, 0x1B2))
+	else if (_action.isAction(VERB_LOOK, NOUN_JUNGLE_PATH))
 		_vm->_dialogs->show(21102);
-	else if (_action.isAction(VERB_LOOK, 0x100)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_PALM_TREE)) {
 		if (_globals[kMonkeyStatus] == MONKEY_AMBUSH_READY) {
 			if (_game._storyMode == STORYMODE_NAUGHTY)
 				_vm->_dialogs->show(21103);
@@ -4754,22 +4754,22 @@ void Scene211::actions() {
 		} else {
 			_vm->_dialogs->show(21105);
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x1B3)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_THICK_UNDERGROWTH)) {
 		if (_game._storyMode == STORYMODE_NAUGHTY)
 			_vm->_dialogs->show(21106);
 		else
 			_vm->_dialogs->show(21107);
-	} else if (_action.isAction(VERB_LOOK, 0xB8))
+	} else if (_action.isAction(VERB_LOOK, NOUN_JUNGLE))
 		_vm->_dialogs->show(21108);
-	else if (_action.isAction(VERB_LOOK, 0x1B1))
+	else if (_action.isAction(VERB_LOOK, NOUN_PATH_TO_NORTHEAST))
 		_vm->_dialogs->show(21109);
-	else if (_action.isAction(VERB_LOOK, 0x1AE))
+	else if (_action.isAction(VERB_LOOK, NOUN_PATH_TO_WEST))
 		_vm->_dialogs->show(21110);
-	else if (_action.isAction(VERB_LOOK, 0x144))
+	else if (_action.isAction(VERB_LOOK, NOUN_SLITHERING_SNAKE))
 		_vm->_dialogs->show(21113);
-	else if (_action.isAction(VERB_TAKE, 0x144))
+	else if (_action.isAction(VERB_TAKE, NOUN_SLITHERING_SNAKE))
 		_vm->_dialogs->show(21114);
-	else if (_action.isAction(VERB_LOOK, 0x129))
+	else if (_action.isAction(VERB_LOOK, NOUN_ROCKS))
 		_vm->_dialogs->show(21115);
 	else
 		return;
@@ -4815,7 +4815,7 @@ void Scene212::step() {
 }
 
 void Scene212::preActions() {
-	if (_action.isAction(VERB_WALK_THROUGH, 0x41))
+	if (_action.isAction(VERB_WALK_THROUGH, NOUN_CAVE_ENTRANCE))
 		_game._player._walkOffScreenSceneId = 111;
 }
 
@@ -4824,23 +4824,23 @@ void Scene212::actions() {
 		_vm->_dialogs->show(21209);
 	else if (_action.isAction(VERB_WALK_TOWARDS) && (_action.isObject(0x82) || _action.isObject(0xE8)))
 		_scene->_nextSceneId = 208;
-	else if (_action.isAction(VERB_WALK_TOWARDS, 0x3F))
+	else if (_action.isAction(VERB_WALK_TOWARDS, NOUN_CAVE))
 		_scene->_nextSceneId = 111;
-	else if (_action.isAction(VERB_LOOK, 0x19C))
+	else if (_action.isAction(VERB_LOOK, NOUN_GRASS))
 		_vm->_dialogs->show(21201);
-	else if (_action.isAction(VERB_LOOK, 0x129))
+	else if (_action.isAction(VERB_LOOK, NOUN_ROCKS))
 		_vm->_dialogs->show(21202);
-	else if (_action.isAction(VERB_LOOK, 0x41))
+	else if (_action.isAction(VERB_LOOK, NOUN_CAVE_ENTRANCE))
 		_vm->_dialogs->show(21203);
-	else if (_action.isAction(VERB_LOOK, 0x142))
+	else if (_action.isAction(VERB_LOOK, NOUN_SKY))
 		_vm->_dialogs->show(21204);
-	else if (_action.isAction(VERB_LOOK, 0x82))
+	else if (_action.isAction(VERB_LOOK, NOUN_FIELD_TO_NORTH))
 		_vm->_dialogs->show(21205);
-	else if (_action.isAction(VERB_LOOK, 0x175))
+	else if (_action.isAction(VERB_LOOK, NOUN_TREES))
 		_vm->_dialogs->show(21206);
-	else if (_action.isAction(VERB_LOOK, 0x110))
+	else if (_action.isAction(VERB_LOOK, NOUN_PLANTS))
 		_vm->_dialogs->show(21207);
-	else if (_action.isAction(VERB_LOOK, 0xE8))
+	else if (_action.isAction(VERB_LOOK, NOUN_MOUNTAINS))
 		_vm->_dialogs->show(21208);
 	else
 		return;
@@ -4994,7 +4994,7 @@ void Scene214::actions() {
 		_vm->_dialogs->show(21427);
 	else if (_action.isAction(0x18A, 0xAA))
 		_scene->_nextSceneId = 207;
-	else if (_action.isAction(VERB_TAKE, 0x114) && (_game._trigger || _game._objects.isInRoom(OBJ_POISON_DARTS))) {
+	else if (_action.isAction(VERB_TAKE, NOUN_POISON_DARTS) && (_game._trigger || _game._objects.isInRoom(OBJ_POISON_DARTS))) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -5023,7 +5023,7 @@ void Scene214::actions() {
 			_vm->_dialogs->showItem(OBJ_POISON_DARTS, 0x53A5);
 			break;
 		}
-	} else if (_action.isAction(VERB_TAKE, 0x29) && (_game._trigger || _game._objects.isInRoom(OBJ_BLOWGUN))) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_BLOWGUN) && (_game._trigger || _game._objects.isInRoom(OBJ_BLOWGUN))) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -5052,53 +5052,53 @@ void Scene214::actions() {
 			_vm->_dialogs->showItem(OBJ_BLOWGUN, 0x329);
 			break;
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x197))
+	} else if (_action.isAction(VERB_LOOK, NOUN_WINDOW))
 		_vm->_dialogs->show(21401);
-	else if (_action.isAction(VERB_LOOK, 0x7E))
+	else if (_action.isAction(VERB_LOOK, NOUN_EXPERIMENT_CAGE))
 		_vm->_dialogs->show(21402);
-	else if (_action.isAction(VERB_LOOK, 0x1C3))
+	else if (_action.isAction(VERB_LOOK, NOUN_CAPTIVE_CREATURE))
 		_vm->_dialogs->show(21403);
-	else if (_action.isAction(VERB_LOOK, 0x21))
+	else if (_action.isAction(VERB_LOOK, NOUN_BEAR_RUG))
 		_vm->_dialogs->show(21404);
-	else if (_action.isAction(VERB_LOOK, 0x1BB))
+	else if (_action.isAction(VERB_LOOK, NOUN_TROPHY))
 		_vm->_dialogs->show(21405);
-	else if (_action.isAction(VERB_LOOK, 0x1BE)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_LARGE_BOWL)) {
 		if (_game._storyMode == STORYMODE_NAUGHTY) {
 			_vm->_dialogs->show(21406);
 		} else {
 			_vm->_dialogs->show(21407);
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x1BC))
+	} else if (_action.isAction(VERB_LOOK, NOUN_SPECIMEN_JARS))
 		_vm->_dialogs->show(21408);
-	else if (_action.isAction(VERB_TAKE, 0x1BE) || _action.isAction(VERB_TAKE, 0x1BC))
+	else if (_action.isAction(VERB_TAKE, NOUN_LARGE_BOWL) || _action.isAction(VERB_TAKE, NOUN_SPECIMEN_JARS))
 		_vm->_dialogs->show(21409);
-	else if (_action.isAction(VERB_LOOK, 0x13D))
+	else if (_action.isAction(VERB_LOOK, NOUN_SHRUNKEN_HEADS))
 		_vm->_dialogs->show(21410);
-	else if (_action.isAction(VERB_TAKE, 0x13D) || _action.isAction(VERB_TAKE, 0x48A))
+	else if (_action.isAction(VERB_TAKE, NOUN_SHRUNKEN_HEADS) || _action.isAction(VERB_TAKE, NOUN_LARGE_HEADS))
 		_vm->_dialogs->show(21411);
-	else if (_action.isAction(VERB_LOOK, 0x48A))
+	else if (_action.isAction(VERB_LOOK, NOUN_LARGE_HEADS))
 		_vm->_dialogs->show(21428);
-	else if (_action.isAction(VERB_LOOK, 0x114) && (_action._savedFields._mainObjectSource == 4))
+	else if (_action.isAction(VERB_LOOK, NOUN_POISON_DARTS) && (_action._savedFields._mainObjectSource == 4))
 		_vm->_dialogs->show(21412);
-	else if (_action.isAction(VERB_OPEN, 0x7E))
+	else if (_action.isAction(VERB_OPEN, NOUN_EXPERIMENT_CAGE))
 		_vm->_dialogs->show(21414);
-	else if (_action.isAction(VERB_TALKTO, 0x1C3))
+	else if (_action.isAction(VERB_TALKTO, NOUN_CAPTIVE_CREATURE))
 		_vm->_dialogs->show(21415);
-	else if (_action.isAction(VERB_GIVE, 0x17A, 0x1C3))
+	else if (_action.isAction(VERB_GIVE, NOUN_TWINKIFRUIT, 0x1C3))
 		_vm->_dialogs->show(21416);
 	else if (_action.isAction(VERB_SHOOT, 0x29, 0x1C3) || _action.isAction(VERB_HOSE_DOWN, 0x29, 0x1C3))
 		_vm->_dialogs->show(21417);
-	else if (_action.isAction(VERB_LOOK, 0x473))
+	else if (_action.isAction(VERB_LOOK, NOUN_BIG_HEADS))
 		_vm->_dialogs->show(21418);
-	else if (_action.isAction(VERB_TAKE, 0x473))
+	else if (_action.isAction(VERB_TAKE, NOUN_BIG_HEADS))
 		_vm->_dialogs->show(21419);
-	else if (_action.isAction(VERB_TAKE, 0x21))
+	else if (_action.isAction(VERB_TAKE, NOUN_BEAR_RUG))
 		_vm->_dialogs->show(21420);
-	else if (_action.isAction(VERB_LOOK, 0x8A))
+	else if (_action.isAction(VERB_LOOK, NOUN_FLOOR_OF_HUT))
 		_vm->_dialogs->show(21421);
-	else if (_action.isAction(VERB_LOOK, 0x29))
+	else if (_action.isAction(VERB_LOOK, NOUN_BLOWGUN))
 		_vm->_dialogs->show(21422);
-	else if (_action.isAction(VERB_LOOK, 0x160)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_TABLE)) {
 		if (_game._objects.isInRoom(OBJ_POISON_DARTS) && _game._objects.isInRoom(OBJ_BLOWGUN)) {
 			_vm->_dialogs->show(21423);
 		} else if (_game._objects.isInRoom(OBJ_POISON_DARTS) && !_game._objects.isInRoom(OBJ_BLOWGUN)) {
@@ -5174,7 +5174,7 @@ void Scene215::step() {
 void Scene215::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(21509);
-	else if (_action.isAction(VERB_TAKE, 0x17A)) {
+	else if (_action.isAction(VERB_TAKE, NOUN_TWINKIFRUIT)) {
 		if (!_game._objects.isInInventory(OBJ_TWINKIFRUIT) || _game._trigger) {
 			switch (_game._trigger) {
 			case 0:
@@ -5212,29 +5212,29 @@ void Scene215::actions() {
 		}
 	} else if (_action.isAction(0x18A, 0xAA))
 		_scene->_nextSceneId = 210;
-	else if (_action.isAction(VERB_LOOK, 0x21))
+	else if (_action.isAction(VERB_LOOK, NOUN_BEAR_RUG))
 		_vm->_dialogs->show(21501);
-	else if (_action.isAction(VERB_LOOK, 0x1CB))
+	else if (_action.isAction(VERB_LOOK, NOUN_BED))
 		_vm->_dialogs->show(21502);
-	else if (_action.isAction(VERB_LOOK, 0x3A3))
+	else if (_action.isAction(VERB_LOOK, NOUN_WELCOME_MAT))
 		_vm->_dialogs->show(21503);
-	else if (_action.isAction(VERB_LOOK, 0xD5))
+	else if (_action.isAction(VERB_LOOK, NOUN_LOVE_ALTAR))
 		_vm->_dialogs->show(21504);
-	else if (_action.isAction(VERB_LOOK, 0x197))
+	else if (_action.isAction(VERB_LOOK, NOUN_WINDOW))
 		_vm->_dialogs->show(21505);
-	else if (_action.isAction(VERB_LOOK, 0x289))
+	else if (_action.isAction(VERB_LOOK, NOUN_PICTURE))
 		_vm->_dialogs->show(21506);
-	else if (_action.isAction(VERB_LOOK, 0x17A) && (_action._savedFields._mainObjectSource == 4))
+	else if (_action.isAction(VERB_LOOK, NOUN_TWINKIFRUIT) && (_action._savedFields._mainObjectSource == 4))
 		_vm->_dialogs->show(21507);
-	else if (_action.isAction(VERB_TAKE, 0x21))
+	else if (_action.isAction(VERB_TAKE, NOUN_BEAR_RUG))
 		_vm->_dialogs->show(21510);
-	else if (_action.isAction(VERB_TAKE, 0xD5))
+	else if (_action.isAction(VERB_TAKE, NOUN_LOVE_ALTAR))
 		_vm->_dialogs->show(21511);
-	else if (_action.isAction(VERB_LOOK, 0x1CA))
+	else if (_action.isAction(VERB_LOOK, NOUN_BAG_OF_TWINKIFRUITS))
 		_vm->_dialogs->show(21512);
-	else if (_action.isAction(VERB_TAKE, 0x1CA))
+	else if (_action.isAction(VERB_TAKE, NOUN_BAG_OF_TWINKIFRUITS))
 		_vm->_dialogs->show(21513);
-	else if (_action.isAction(VERB_TAKE, 0x3A3))
+	else if (_action.isAction(VERB_TAKE, NOUN_WELCOME_MAT))
 		_vm->_dialogs->show(21514);
 	else
 		return;
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 00de84e..74bc582 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -862,7 +862,7 @@ void Scene307::actions() {
 		_vm->_dialogs->show(30715);
 	else if (_game._screenObjects._inputMode == 1)
 		handleDialog();
-	else if (_action.isAction(VERB_TALKTO, 0x207) || _action.isAction(VERB_TALKTO, 0x18D) || _action.isAction(VERB_TALKTO, 0x21B)) {
+	else if (_action.isAction(VERB_TALKTO, NOUN_CELL_WALL) || _action.isAction(VERB_TALKTO, NOUN_WALL) || _action.isAction(VERB_TALKTO, NOUN_TOILET)) {
 		int node, say;
 		if (_globals[kKnowsBuddyBeast]) {
 			say = 0x10E;
@@ -959,7 +959,7 @@ void Scene307::actions() {
 		default:
 			break;
 		}
-	}else if (_action.isAction(VERB_CLIMB_INTO, 0x11)) {
+	}else if (_action.isAction(VERB_CLIMB_INTO, NOUN_AIR_VENT)) {
 		if (_grateOpenedFl) {
 			switch (_game._trigger) {
 			case 0:
@@ -1042,9 +1042,9 @@ void Scene307::actions() {
 				break;
 			}
 		}
-	} else if (_action.isAction(VERB_USE, 0x21B) && (_game._storyMode != STORYMODE_NAUGHTY))
+	} else if (_action.isAction(VERB_USE, NOUN_TOILET) && (_game._storyMode != STORYMODE_NAUGHTY))
 		_vm->_dialogs->show(30723);
-	else if (_action.isAction(VERB_USE, 0x21B)) {
+	else if (_action.isAction(VERB_USE, NOUN_TOILET)) {
 		if (!_afterPeeingFl) {
 			switch (_game._trigger) {
 			case 0:
@@ -1094,24 +1094,24 @@ void Scene307::actions() {
 			int idx = _scene->_kernelMessages.add(Common::Point(85, 39), 0x1110, 0, 0, 180, _game.getQuote(238));
 			_scene->_kernelMessages.setQuoted(idx, 4, true);
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x11)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_AIR_VENT)) {
 		if (!_grateOpenedFl)
 			_vm->_dialogs->show(30710);
 		else
 			_vm->_dialogs->show(30711);
-	} else if (_action.isAction(VERB_LOOK, 0x1CB))
+	} else if (_action.isAction(VERB_LOOK, NOUN_BED))
 		_vm->_dialogs->show(30712);
-	else if (_action.isAction(VERB_LOOK, 0x216))
+	else if (_action.isAction(VERB_LOOK, NOUN_SINK))
 		_vm->_dialogs->show(30713);
-	else if (_action.isAction(VERB_LOOK, 0x21B))
+	else if (_action.isAction(VERB_LOOK, NOUN_TOILET))
 		_vm->_dialogs->show(30714);
 	else if (_action.isAction(0x134, 0x12C))
 		_vm->_dialogs->show(30716);
-	else if (_action.isAction(VERB_LOOK, 0x207))
+	else if (_action.isAction(VERB_LOOK, NOUN_CELL_WALL))
 		_vm->_dialogs->show(30717);
-	else if (_action.isAction(VERB_LOOK, 0xCD))
+	else if (_action.isAction(VERB_LOOK, NOUN_LIGHT))
 		_vm->_dialogs->show(30718);
-	else if (_action.isAction(VERB_WALK_INTO, 0x204)) {
+	else if (_action.isAction(VERB_WALK_INTO, NOUN_CORRIDOR)) {
 		switch (_fieldCollisionCounter) {
 		case 0:
 			_vm->_dialogs->show(30719);
@@ -1696,9 +1696,9 @@ void Scene311::actions() {
 		_checkGuardFl = false;
 		_scene->_kernelMessages.reset();
 		_scene->_kernelMessages.addQuote(0xFA, 120, 0);
-	} else if (_action.isAction(VERB_SIT_AT, 0x1E4))
+	} else if (_action.isAction(VERB_SIT_AT, NOUN_DESK))
 		_scene->_nextSceneId = 320;
-	else if (_action.isAction(VERB_CLIMB_INTO, 0x11)) {
+	else if (_action.isAction(VERB_CLIMB_INTO, NOUN_AIR_VENT)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1790,25 +1790,25 @@ void Scene311::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x1E4))
+	} else if (_action.isAction(VERB_LOOK, NOUN_DESK))
 		_vm->_dialogs->show(31110);
-	else if (_action.isAction(VERB_LOOK, 0x18D))
+	else if (_action.isAction(VERB_LOOK, NOUN_WALL))
 		_vm->_dialogs->show(31111);
-	else if (_action.isAction(VERB_LOOK, 0x220) || _action.isAction(VERB_STARE_AT, 0x220))
+	else if (_action.isAction(VERB_LOOK, NOUN_LIGHTING_FIXTURE) || _action.isAction(VERB_STARE_AT, NOUN_LIGHTING_FIXTURE))
 		_vm->_dialogs->show(31112);
-	else if (_action.isAction(VERB_LOOK, 0x208) || _action.isAction(VERB_STARE_AT, 0x208))
+	else if (_action.isAction(VERB_LOOK, NOUN_LIGHTS) || _action.isAction(VERB_STARE_AT, NOUN_LIGHTS))
 		_vm->_dialogs->show(31113);
-	else if (_action.isAction(VERB_TAKE, 0x208))
+	else if (_action.isAction(VERB_TAKE, NOUN_LIGHTS))
 		_vm->_dialogs->show(31114);
-	else if (_action.isAction(VERB_LOOK, 0xCD) || _action.isAction(VERB_STARE_AT, 0xCD))
+	else if (_action.isAction(VERB_LOOK, NOUN_LIGHT) || _action.isAction(VERB_STARE_AT, NOUN_LIGHT))
 		_vm->_dialogs->show(31115);
-	else if (_action.isAction(VERB_TAKE, 0xCD))
+	else if (_action.isAction(VERB_TAKE, NOUN_LIGHT))
 		_vm->_dialogs->show(31116);
-	else if (_action.isAction(VERB_LOOK, 0x2BA))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_WEST))
 		_vm->_dialogs->show(31117);
-	else if (_action.isAction(VERB_LOOK, 0x2B9))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_EAST))
 		_vm->_dialogs->show(31118);
-	else if (_action.isAction(VERB_LOOK, 0x11))
+	else if (_action.isAction(VERB_LOOK, NOUN_AIR_VENT))
 		_vm->_dialogs->show(31120);
 	else
 		return;
@@ -1866,24 +1866,24 @@ void Scene313::enter() {
 }
 
 void Scene313::actions() {
-	if (_action.isAction(VERB_CRAWL_TO, 0x2FC))
+	if (_action.isAction(VERB_CRAWL_TO, NOUN_FOURTH_CELL))
 		_scene->_nextSceneId = 387;
-	else if (_action.isAction(VERB_CRAWL_TO, 0x2FD))
+	else if (_action.isAction(VERB_CRAWL_TO, NOUN_THIRD_CELL))
 		_scene->_nextSceneId = 388;
-	else if (_action.isAction(VERB_CRAWL_TO, 0x2FE)) {
+	else if (_action.isAction(VERB_CRAWL_TO, NOUN_SECOND_CELL)) {
 		if (_globals[kAfterHavoc])
 			_scene->_nextSceneId = 399;
 		else
 			_scene->_nextSceneId = 389;
-	} else if (_action.isAction(VERB_CRAWL_TO, 0x2FF))
+	} else if (_action.isAction(VERB_CRAWL_TO, NOUN_FIRST_CELL))
 		_scene->_nextSceneId = 390;
-	else if (_action.isAction(VERB_CRAWL_TO, 0x2EF)) {
+	else if (_action.isAction(VERB_CRAWL_TO, NOUN_SECURITY_STATION)) {
 		if (_globals[kSexOfRex] == REX_FEMALE) {
 			_globals[kSexOfRex] = REX_MALE;
 			_vm->_dialogs->show(31301);
 		}
 		_scene->_nextSceneId = 391;
-	} else if (_action.isAction(VERB_CRAWL_TO, 0x300)) {
+	} else if (_action.isAction(VERB_CRAWL_TO, NOUN_EQUIPMENT_ROOM)) {
 		if (_globals[kSexOfRex] == REX_FEMALE) {
 			_globals[kSexOfRex] = REX_MALE;
 			_vm->_dialogs->show(31301);
@@ -2249,7 +2249,7 @@ void Scene316::step() {
 }
 
 void Scene316::preActions() {
-	if (_action.isAction(VERB_WALK_DOWN, 0x2B9)) {
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_EAST)) {
 		if (_globals[kAfterHavoc])
 			_game._player._walkOffScreenSceneId = 354;
 		else
@@ -2258,12 +2258,12 @@ void Scene316::preActions() {
 }
 
 void Scene316::actions() {
-	if (_action.isAction(VERB_CLIMB_INTO, 0x11)) {
+	if (_action.isAction(VERB_CLIMB_INTO, NOUN_AIR_VENT)) {
 		if (_globals[kSexOfRex] == REX_FEMALE)
 			handleRoxInGrate();
 		else
 			handleRexInGrate();
-	} else if (_action.isAction(VERB_WALK_UP, 0x226) || _action.isAction(VERB_WALK_ONTO, 0x22C)) {
+	} else if (_action.isAction(VERB_WALK_UP, NOUN_RAMP) || _action.isAction(VERB_WALK_ONTO, NOUN_PLATFORM)) {
 		switch (_game._trigger) {
 		case 0:
 			if (_globals[kCityFlooded]) {
@@ -2314,35 +2314,35 @@ void Scene316::actions() {
 			_scene->_nextSceneId = 321;
 			break;
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x22C))
+	} else if (_action.isAction(VERB_LOOK, NOUN_PLATFORM))
 		_vm->_dialogs->show(31610);
-	else if (_action.isAction(VERB_LOOK, 0x1B6)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_STRANGE_DEVICE)) {
 		if (_game._visitedScenes.exists(321))
 			_vm->_dialogs->show(31612);
 		else
 			_vm->_dialogs->show(31611);
-	} else if (_action.isAction(VERB_LOOK, 0x2C6))
+	} else if (_action.isAction(VERB_LOOK, NOUN_CONTROLS))
 		_vm->_dialogs->show(31613);
-	else if (_action.isAction(VERB_LOOK, 0x2C7))
+	else if (_action.isAction(VERB_LOOK, NOUN_EQUIPMENT))
 		_vm->_dialogs->show(31614);
-	else if (_action.isAction(VERB_LOOK, 0x1E0))
+	else if (_action.isAction(VERB_LOOK, NOUN_PANEL))
 		_vm->_dialogs->show(31615);
-	else if (_action.isAction(VERB_LOOK, 0xE2))
+	else if (_action.isAction(VERB_LOOK, NOUN_MONITOR))
 		_vm->_dialogs->show(31616);
-	else if (_action.isAction(VERB_LOOK, 0x226))
+	else if (_action.isAction(VERB_LOOK, NOUN_RAMP))
 		_vm->_dialogs->show(31617);
-	else if (_action.isAction(VERB_LOOK, 0x11))
+	else if (_action.isAction(VERB_LOOK, NOUN_AIR_VENT))
 		_vm->_dialogs->show(31618);
-	else if (_action.isAction(VERB_LOOK, 0x2B9)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_EAST)) {
 		if (!_globals[kAfterHavoc]) {
 			if (_game._difficulty != DIFFICULTY_EASY)
 				_vm->_dialogs->show(31620);
 			else
 				_vm->_dialogs->show(31619);
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x89))
+	} else if (_action.isAction(VERB_LOOK, NOUN_FLOOR))
 		_vm->_dialogs->show(31621);
-	else if (_action.isAction(VERB_LOOK, 0x257))
+	else if (_action.isAction(VERB_LOOK, NOUN_SUPPORT))
 		_vm->_dialogs->show(31622);
 	else
 		return;
@@ -2740,7 +2740,7 @@ void Scene318::preActions() {
 	if (_game._player._needToWalk)
 		_game._player._needToWalk = _game._player._visible;
 
-	if (_action.isAction(VERB_WALK_DOWN, 0x2BA))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_WEST))
 		_game._player._walkOffScreenSceneId = 357;
 }
 
@@ -2751,7 +2751,7 @@ void Scene318::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_TALKTO, 0x307)) {
+	if (_action.isAction(VERB_TALKTO, NOUN_INTERN)) {
 		switch (_game._trigger) {
 		case 0: {
 			_dialogFl = true;
@@ -2790,7 +2790,7 @@ void Scene318::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_TAKE, 0x12C) && (_game._objects.isInRoom(OBJ_SCALPEL) || _game._trigger)) {
+	if (_action.isAction(VERB_TAKE, NOUN_SCALPEL) && (_game._objects.isInRoom(OBJ_SCALPEL) || _game._trigger)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -2832,13 +2832,13 @@ void Scene318::actions() {
 	}
 
 	if (_game._player._visible) {
-		if (_action.isAction(VERB_WALK_DOWN, 0x2B3)) {
+		if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_SOUTH)) {
 			_scene->_nextSceneId = 407;
 			_action._inProgress = false;
 			return;
 		}
 
-		if (_action.isAction(VERB_TAKE, 0x165)) {
+		if (_action.isAction(VERB_TAKE, NOUN_TAPE_PLAYER)) {
 			if (_game._objects.isInRoom(OBJ_AUDIO_TAPE)) {
 				_vm->_dialogs->showItem(OBJ_AUDIO_TAPE, 0x7C5B);
 				_game._objects.addToInventory(OBJ_AUDIO_TAPE);
@@ -2849,7 +2849,7 @@ void Scene318::actions() {
 			return;
 		}
 
-		if (_action.isAction(VERB_LOOK, 0x165)) {
+		if (_action.isAction(VERB_LOOK, NOUN_TAPE_PLAYER)) {
 			if (_game._objects.isInRoom(OBJ_AUDIO_TAPE))
 				_vm->_dialogs->show(31833);
 			else
@@ -2859,68 +2859,68 @@ void Scene318::actions() {
 			return;
 		}
 
-		if (_action.isAction(VERB_WALK_INTO, 0x488)) {
+		if (_action.isAction(VERB_WALK_INTO, NOUN_DOCTORS_OFFICE)) {
 			_vm->_dialogs->show(31831);
 			_action._inProgress = false;
 			return;
 		}
 
-		if (_action.isAction(VERB_LOOK, 0x2D9)) {
+		if (_action.isAction(VERB_LOOK, NOUN_GURNEY)) {
 			_vm->_dialogs->show(31823);
 			_action._inProgress = false;
 			return;
 		}
 
-		if (_action.isAction(VERB_LOOK, 0x308)) {
+		if (_action.isAction(VERB_LOOK, NOUN_INSTRUMENT_TABLE)) {
 			_vm->_dialogs->show(31825);
 			_action._inProgress = false;
 			return;
 		}
 	} else { // Not visible
-		if (_action.isAction(VERB_LOOK, 0x2D9)) {
+		if (_action.isAction(VERB_LOOK, NOUN_GURNEY)) {
 			_vm->_dialogs->show(31822);
 			_action._inProgress = false;
 			return;
 		}
 
-		if (_action.isAction(VERB_LOOK, 0x308)) {
+		if (_action.isAction(VERB_LOOK, NOUN_INSTRUMENT_TABLE)) {
 			_vm->_dialogs->show(31824);
 			_action._inProgress = false;
 			return;
 		}
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x18D))
+	if (_action.isAction(VERB_LOOK, NOUN_WALL))
 		_vm->_dialogs->show(31810);
-	else if (_action.isAction(VERB_LOOK, 0x89))
+	else if (_action.isAction(VERB_LOOK, NOUN_FLOOR))
 		_vm->_dialogs->show(31811);
-	else if (_action.isAction(VERB_LOOK, 0x2BA))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_WEST))
 		_vm->_dialogs->show(31812);
-	else if (_action.isAction(VERB_LOOK, 0x2B3))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_SOUTH))
 		_vm->_dialogs->show(31813);
-	else if (_action.isAction(VERB_LOOK, 0x2CB))
+	else if (_action.isAction(VERB_LOOK, NOUN_FAUCET))
 		_vm->_dialogs->show(31814);
-	else if (_action.isAction(VERB_LOOK, 0x216))
+	else if (_action.isAction(VERB_LOOK, NOUN_SINK))
 		_vm->_dialogs->show(31815);
-	else if (_action.isAction(VERB_LOOK, 0x319))
+	else if (_action.isAction(VERB_LOOK, NOUN_CONVEYOR_BELT))
 		_vm->_dialogs->show(31816);
-	else if (_action.isAction(VERB_LOOK, 0x477))
+	else if (_action.isAction(VERB_LOOK, NOUN_LARGE_BLADE))
 		_vm->_dialogs->show(31817);
-	else if (_action.isAction(VERB_LOOK, 0xE2))
+	else if (_action.isAction(VERB_LOOK, NOUN_MONITOR))
 		_vm->_dialogs->show(31818);
-	else if (_action.isAction(VERB_LOOK, 0x2C9))
+	else if (_action.isAction(VERB_LOOK, NOUN_CABINETS))
 		_vm->_dialogs->show(31819);
-	else if (_action.isAction(VERB_LOOK, 0x2C7))
+	else if (_action.isAction(VERB_LOOK, NOUN_EQUIPMENT))
 		_vm->_dialogs->show(31820);
-	else if (_action.isAction(VERB_LOOK, 0x2C8))
+	else if (_action.isAction(VERB_LOOK, NOUN_SHELF))
 		_vm->_dialogs->show(31821);
-	else if (_action.isAction(VERB_OPEN, 0x2C9))
+	else if (_action.isAction(VERB_OPEN, NOUN_CABINETS))
 		_vm->_dialogs->show(31829);
-	else if (_action.isAction(VERB_LOOK, 0x307))
+	else if (_action.isAction(VERB_LOOK, NOUN_INTERN))
 		_vm->_dialogs->show(31830);
-	else if (_action.isAction(VERB_LOOK, 0x3A1))
+	else if (_action.isAction(VERB_LOOK, NOUN_PROFESSOR))
 		_vm->_dialogs->show(31832);
-	else if (_action.isAction(VERB_LOOK, 0x3A2))
+	else if (_action.isAction(VERB_LOOK, NOUN_PROFESSORS_GURNEY))
 		_vm->_dialogs->show(31836);
 	else if (_action._lookFlag) {
 		if (_game._player._visible || _game._objects.isInInventory(OBJ_SCALPEL))
@@ -3709,39 +3709,39 @@ void Scene320::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_LEAVE, 0x2EF))
+	} else if (_action.isAction(VERB_LEAVE, NOUN_SECURITY_STATION))
 		_scene->_nextSceneId = 311;
-	else if (_action.isAction(VERB_LOOK, 0x2DC))
+	else if (_action.isAction(VERB_LOOK, NOUN_RIGHT_MONITOR))
 		_vm->_dialogs->show(32001);
-	else if (_action.isAction(VERB_LOOK, 0x2DB))
+	else if (_action.isAction(VERB_LOOK, NOUN_LEFT_MONITOR))
 		_vm->_dialogs->show(32002);
-	else if (_action.isAction(VERB_LOOK, 0x1E4))
+	else if (_action.isAction(VERB_LOOK, NOUN_DESK))
 		_vm->_dialogs->show(32003);
-	else if (_action.isAction(VERB_LOOK, 0x2EF))
+	else if (_action.isAction(VERB_LOOK, NOUN_SECURITY_STATION))
 		_vm->_dialogs->show(32004);
-	else if (_action.isAction(VERB_LOOK, 0x2ED))
+	else if (_action.isAction(VERB_LOOK, NOUN_MUG))
 		_vm->_dialogs->show(32005);
-	else if (_action.isAction(VERB_LOOK, 0x2EE))
+	else if (_action.isAction(VERB_LOOK, NOUN_DOUGHNUT))
 		_vm->_dialogs->show(32006);
-	else if (_action.isAction(VERB_LOOK, 0x2F1))
+	else if (_action.isAction(VERB_LOOK, NOUN_MAGAZINE))
 		_vm->_dialogs->show(32006);
-	else if (_action.isAction(VERB_LOOK, 0x2F3))
+	else if (_action.isAction(VERB_LOOK, NOUN_PAPER_FOOTBALL))
 		_vm->_dialogs->show(32008);
-	else if (_action.isAction(VERB_LOOK, 0x2F0))
+	else if (_action.isAction(VERB_LOOK, NOUN_NEWSPAPER))
 		_vm->_dialogs->show(32009);
-	else if (_action.isAction(VERB_LOOK, 0x2F2))
+	else if (_action.isAction(VERB_LOOK, NOUN_CLIPBOARD))
 		_vm->_dialogs->show(32010);
-	else if (_action.isAction(VERB_TAKE, 0x2ED))
+	else if (_action.isAction(VERB_TAKE, NOUN_MUG))
 		_vm->_dialogs->show(32012);
-	else if (_action.isAction(VERB_TAKE, 0x2F2))
+	else if (_action.isAction(VERB_TAKE, NOUN_CLIPBOARD))
 		_vm->_dialogs->show(32013);
-	else if (_action.isAction(VERB_TAKE, 0x2EE) || _action.isAction(VERB_EAT, 0x2EE))
+	else if (_action.isAction(VERB_TAKE, NOUN_DOUGHNUT) || _action.isAction(VERB_EAT, NOUN_DOUGHNUT))
 		_vm->_dialogs->show(32014);
-	else if (_action.isAction(VERB_TAKE, 0x2F3))
+	else if (_action.isAction(VERB_TAKE, NOUN_PAPER_FOOTBALL))
 		_vm->_dialogs->show(32015);
-	else if (_action.isAction(VERB_TAKE, 0x2F1))
+	else if (_action.isAction(VERB_TAKE, NOUN_MAGAZINE))
 		_vm->_dialogs->show(32016);
-	else if (_action.isAction(VERB_TAKE, 0x2F0))
+	else if (_action.isAction(VERB_TAKE, NOUN_NEWSPAPER))
 		_vm->_dialogs->show(32017);
 	else
 		return;
@@ -3838,21 +3838,21 @@ void Scene322::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x181) || _action.isAction(VERB_PEER_THROUGH, 0x181))
+	if (_action.isAction(VERB_LOOK, NOUN_VIEWPORT) || _action.isAction(VERB_PEER_THROUGH, NOUN_VIEWPORT))
 		_vm->_dialogs->show(32210);
-	else if (_action.isAction(VERB_LOOK, 0xC4))
+	else if (_action.isAction(VERB_LOOK, NOUN_KEYPAD))
 		_vm->_dialogs->show(32211);
-	else if (_action.isAction(VERB_LOOK, 0x1CC))
+	else if (_action.isAction(VERB_LOOK, NOUN_DISPLAY))
 		_vm->_dialogs->show(32212);
-	else if (_action.isAction(VERB_LOOK, 0x1D0) || _action.isAction(VERB_LOOK, 0x1D1)
-	 || _action.isAction(VERB_LOOK, 0x1D2) || _action.isAction(VERB_LOOK, 0x1D3)
-	 || _action.isAction(VERB_LOOK, 0x1D4) || _action.isAction(VERB_LOOK, 0x1D5)
-	 || _action.isAction(VERB_LOOK, 0x1D6) || _action.isAction(VERB_LOOK, 0x1D7)
-	 || _action.isAction(VERB_LOOK, 0x1D8) || _action.isAction(VERB_LOOK, 0x1D9)
-	 || _action.isAction(VERB_LOOK, 0x1DB) || _action.isAction(VERB_LOOK, 0x7A)
-	 || _action.isAction(VERB_LOOK, 0x1DA))
+	else if (_action.isAction(VERB_LOOK, NOUN_0_KEY) || _action.isAction(VERB_LOOK, NOUN_1_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_2_KEY) || _action.isAction(VERB_LOOK, NOUN_3_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_4_KEY) || _action.isAction(VERB_LOOK, NOUN_5_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_6_KEY) || _action.isAction(VERB_LOOK, NOUN_7_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_8_KEY) || _action.isAction(VERB_LOOK, NOUN_9_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_SMILE_KEY) || _action.isAction(VERB_LOOK, NOUN_ENTER_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_FROWN_KEY))
 		_vm->_dialogs->show(32213);
-	else if (_action.isAction(VERB_LOOK, 0x1CF))
+	else if (_action.isAction(VERB_LOOK, NOUN_DEVICE))
 		_vm->_dialogs->show(32214);
 	else
 		return;
@@ -3954,11 +3954,11 @@ void Scene351::step() {
 void Scene351::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(35121);
-	else if (_action.isAction(VERB_STEP_INTO, 0x16C))
+	else if (_action.isAction(VERB_STEP_INTO, NOUN_TELEPORTER))
 		_scene->_nextSceneId = 322;
-	else if (_action.isAction(VERB_WALK_DOWN, 0x2B3))
+	else if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_SOUTH))
 		_scene->_nextSceneId = 352;
-	else if (_action.isAction(VERB_TAKE, 0x5C)) {
+	else if (_action.isAction(VERB_TAKE, NOUN_CREDIT_CHIP)) {
 		if (_game._trigger || !_game._objects.isInInventory(0xF)) {
 			switch (_game._trigger) {
 			case 0:
@@ -3990,30 +3990,30 @@ void Scene351::actions() {
 				break;
 			}
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x180))
+	} else if (_action.isAction(VERB_LOOK, NOUN_VIEW_SCREEN))
 		_vm->_dialogs->show(35110);
-	else if (_action.isAction(VERB_LOOK, 0x23A))
+	else if (_action.isAction(VERB_LOOK, NOUN_RIP_IN_FLOOR))
 		_vm->_dialogs->show(35111);
-	else if (_action.isAction(VERB_LOOK, 0x1E6))
+	else if (_action.isAction(VERB_LOOK, NOUN_FIRE_HYDRANT))
 		_vm->_dialogs->show(35112);
-	else if (_action.isAction(VERB_LOOK, 0x239)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_GUARD)) {
 		if (_game._objects[0xF]._roomNumber == 351)
 			_vm->_dialogs->show(35114);
 		else
 			_vm->_dialogs->show(35113);
-	} else if (_action.isAction(VERB_LOOK, 0x2C7))
+	} else if (_action.isAction(VERB_LOOK, NOUN_EQUIPMENT))
 		_vm->_dialogs->show(35115);
-	else if (_action.isAction(VERB_LOOK, 0x1E4))
+	else if (_action.isAction(VERB_LOOK, NOUN_DESK))
 		_vm->_dialogs->show(35116);
-	else if (_action.isAction(VERB_LOOK, 0xD7))
+	else if (_action.isAction(VERB_LOOK, NOUN_MACHINE))
 		_vm->_dialogs->show(35117);
-	else if (_action.isAction(VERB_LOOK, 0x16C))
+	else if (_action.isAction(VERB_LOOK, NOUN_TELEPORTER))
 		_vm->_dialogs->show(35118);
-	else if (_action.isAction(VERB_LOOK, 0x59))
+	else if (_action.isAction(VERB_LOOK, NOUN_CONTROL_PANEL))
 		_vm->_dialogs->show(35119);
-	else if (_action.isAction(VERB_LOOK, 0x2B3))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_SOUTH))
 		_vm->_dialogs->show(35120);
-	else if (_action.isAction(VERB_LOOK, 0x1EB))
+	else if (_action.isAction(VERB_LOOK, NOUN_POLE))
 		_vm->_dialogs->show(35122);
 	else
 		return;
@@ -4171,7 +4171,7 @@ void Scene352::enter() {
 void Scene352::preActions() {
 	_leaveRoomFl = false;
 
-	if (_action.isAction(VERB_OPEN, 0x1F8))
+	if (_action.isAction(VERB_OPEN, NOUN_VAULT))
 		_game._player.walk(Common::Point(266, 111), FACING_NORTHEAST);
 
 	if (_vaultOpenFl && !_action.isAction(0x1F8) && !_action.isAction(0x2F6) && !_action.isAction(0x2F5) && !_action.isAction(0x2F4)) {
@@ -4210,14 +4210,14 @@ void Scene352::preActions() {
 		}
 	}
 
-	if (_action.isAction(VERB_PUT, 0x3B6, 0x1F3)) {
+	if (_action.isAction(VERB_PUT, NOUN_GUARDS_ARM, 0x1F3)) {
 		if (_globals[kSexOfRex] == REX_MALE)
 			_game._player.walk(Common::Point(269, 111), FACING_NORTHEAST);
 		else
 			_game._player.walk(Common::Point(271, 111), FACING_NORTHEAST);
 	}
 
-	if (_action.isAction(VERB_WALK_THROUGH, 0x70) || _action.isAction(VERB_WALK_DOWN, 0x2B3) || _action.isAction(VERB_PUT, 0x3B6, 0x89)) {
+	if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOORWAY) || _action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_SOUTH) || _action.isAction(VERB_PUT, NOUN_GUARDS_ARM, 0x89)) {
 		if (_game._objects.isInInventory(OBJ_GUARDS_ARM))
 			_game._player.walk(Common::Point(230, 117), FACING_NORTHWEST);
 	}
@@ -4230,7 +4230,7 @@ void Scene352::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_OPEN, 0x1F8)) {
+	if (_action.isAction(VERB_OPEN, NOUN_VAULT)) {
 		if (!_vaultOpenFl) {
 			switch (_game._trigger) {
 			case 0:
@@ -4288,15 +4288,15 @@ void Scene352::actions() {
 	bool exit_corridor = false;
 	bool exit_doorway = false;
 
-	if (_action.isAction(VERB_WALK_DOWN, 0x2B3)) {
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_SOUTH)) {
 		exit_corridor = true;
 	}
 
-	if (_action.isAction(VERB_WALK_THROUGH, 0x70)) {
+	if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOORWAY)) {
 		exit_doorway = true;
 	}
 
-	if (_action.isAction(VERB_WALK_DOWN, 0x2B3) || _action.isAction(VERB_WALK_THROUGH, 0x70) || _action.isAction(VERB_PUT, 0x3B6, 0x89)) {
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_SOUTH) || _action.isAction(VERB_WALK_THROUGH, NOUN_DOORWAY) || _action.isAction(VERB_PUT, NOUN_GUARDS_ARM, 0x89)) {
 		if (_mustPutArmDownFl)
 			putArmDown(exit_corridor, exit_doorway);
 		else if (exit_corridor)
@@ -4308,7 +4308,7 @@ void Scene352::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_TAKE, 0x3B6)) {
+	if (_action.isAction(VERB_TAKE, NOUN_GUARDS_ARM)) {
 		if (_game._trigger || !_game._objects.isInInventory(OBJ_GUARDS_ARM)) {
 			switch (_game._trigger) {
 			case 0:
@@ -4344,7 +4344,7 @@ void Scene352::actions() {
 		}
 	}
 
-	if (_action.isAction(VERB_PUT, 0x3B6, 0x1F3)) {
+	if (_action.isAction(VERB_PUT, NOUN_GUARDS_ARM, 0x1F3)) {
 		if (!_vaultOpenFl) {
 			switch (_game._trigger) {
 			case 0:
@@ -4423,7 +4423,7 @@ void Scene352::actions() {
 				break;
 			}
 		}
-	} else if (_action.isAction(VERB_TAKE, 0x2F4)) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_YOUR_STUFF)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -4470,7 +4470,7 @@ void Scene352::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_TAKE, 0x165) && !_game._objects.isInInventory(OBJ_TAPE_PLAYER)) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_TAPE_PLAYER) && !_game._objects.isInInventory(OBJ_TAPE_PLAYER)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -4508,53 +4508,53 @@ void Scene352::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x1F3))
+	} else if (_action.isAction(VERB_LOOK, NOUN_SCANNER))
 		_vm->_dialogs->show(35210);
-	else if (_action.isAction(VERB_LOOK, 0xE2)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_MONITOR)) {
 		if (_game._storyMode == STORYMODE_NAUGHTY)
 			_vm->_dialogs->show(35211);
 		else
 			_vm->_dialogs->show(35212);
-	} else if (_action.isAction(VERB_LOOK, 0x1CC))
+	} else if (_action.isAction(VERB_LOOK, NOUN_DISPLAY))
 		_vm->_dialogs->show(35213);
-	else if (_action.isAction(VERB_LOOK, 0x2CD))
+	else if (_action.isAction(VERB_LOOK, NOUN_STATUE))
 		_vm->_dialogs->show(35214);
-	else if (_action.isAction(VERB_LOOK, 0x165) && (_action._savedFields._mainObjectSource == 4))
+	else if (_action.isAction(VERB_LOOK, NOUN_TAPE_PLAYER) && (_action._savedFields._mainObjectSource == 4))
 		_vm->_dialogs->show(35215);
-	else if (_action.isAction(VERB_LOOK, 0x11))
+	else if (_action.isAction(VERB_LOOK, NOUN_AIR_VENT))
 		_vm->_dialogs->show(35216);
-	else if (_action.isAction(VERB_LOOK, 0x3B6) && (_action._savedFields._mainObjectSource == 4))
+	else if (_action.isAction(VERB_LOOK, NOUN_GUARDS_ARM) && (_action._savedFields._mainObjectSource == 4))
 		_vm->_dialogs->show(35217);
-	else if (_action.isAction(VERB_LOOK, 0x2DA))
+	else if (_action.isAction(VERB_LOOK, NOUN_IRONING_BOARD))
 		_vm->_dialogs->show(35218);
-	else if (_action.isAction(VERB_LOOK, 0x51))
+	else if (_action.isAction(VERB_LOOK, NOUN_CLOCK))
 		_vm->_dialogs->show(35219);
-	else if (_action.isAction(VERB_LOOK, 0x2CE))
+	else if (_action.isAction(VERB_LOOK, NOUN_GAUGE))
 		_vm->_dialogs->show(35220);
-	else if (_action.isAction(VERB_LOOK, 0x1F8)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_VAULT)) {
 		if (!_vaultOpenFl)
 			_vm->_dialogs->show(35221);
-	} else if (_action.isAction(VERB_LOOK, 0x2F4))
+	} else if (_action.isAction(VERB_LOOK, NOUN_YOUR_STUFF))
 		_vm->_dialogs->show(35222);
-	else if (_action.isAction(VERB_LOOK, 0x2F5))
+	else if (_action.isAction(VERB_LOOK, NOUN_OTHER_STUFF))
 		_vm->_dialogs->show(35223);
-	else if (_action.isAction(VERB_LOOK, 0x2B3))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_SOUTH))
 		_vm->_dialogs->show(35224);
-	else if (_action.isAction(VERB_TAKE, 0x2F5))
+	else if (_action.isAction(VERB_TAKE, NOUN_OTHER_STUFF))
 		_vm->_dialogs->show(35226);
-	else if (_action.isAction(VERB_LOOK, 0x1E4))
+	else if (_action.isAction(VERB_LOOK, NOUN_DESK))
 		_vm->_dialogs->show(35229);
-	else if (_action.isAction(VERB_LOOK, 0x239))
+	else if (_action.isAction(VERB_LOOK, NOUN_GUARD))
 		_vm->_dialogs->show(35230);
-	else if (_action.isAction(VERB_LOOK, 0x70))
+	else if (_action.isAction(VERB_LOOK, NOUN_DOORWAY))
 		_vm->_dialogs->show(35231);
-	else if (_action.isAction(VERB_LOOK, 0x160))
+	else if (_action.isAction(VERB_LOOK, NOUN_TABLE))
 		_vm->_dialogs->show(35232);
-	else if (_action.isAction(VERB_LOOK, 0x3B5))
+	else if (_action.isAction(VERB_LOOK, NOUN_PROJECTOR))
 		_vm->_dialogs->show(35233);
-	else if (_action.isAction(VERB_LOOK, 0x257))
+	else if (_action.isAction(VERB_LOOK, NOUN_SUPPORT))
 		_vm->_dialogs->show(35234);
-	else if (_action.isAction(VERB_LOOK, 0x1F5))
+	else if (_action.isAction(VERB_LOOK, NOUN_SECURITY_MONITOR))
 		_vm->_dialogs->show(35235);
 	else
 		return;
@@ -4598,25 +4598,25 @@ void Scene353::enter() {
 void Scene353::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(35315);
-	else if (_action.isAction(VERB_WALK_THROUGH, 0x70))
+	else if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOORWAY))
 		_scene->_nextSceneId = 352;
-	else if (_action.isAction(VERB_WALK_DOWN, 0x2B3))
+	else if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_SOUTH))
 		_scene->_nextSceneId = 354;
-	else if (_action.isAction(VERB_LOOK, 0x23D))
+	else if (_action.isAction(VERB_LOOK, NOUN_ROCK_CHUNK))
 		_vm->_dialogs->show(35310);
-	else if (_action.isAction(VERB_LOOK, 0x1FA) || _action.isAction(VERB_LOOK, 0x10C))
+	else if (_action.isAction(VERB_LOOK, NOUN_PIPES) || _action.isAction(VERB_LOOK, NOUN_PIPE))
 		_vm->_dialogs->show(35311);
-	else if (_action.isAction(VERB_LOOK, 0x23C))
+	else if (_action.isAction(VERB_LOOK, NOUN_BROKEN_BEAM))
 		_vm->_dialogs->show(35312);
-	else if (_action.isAction(VERB_LOOK, 0x70))
+	else if (_action.isAction(VERB_LOOK, NOUN_DOORWAY))
 		_vm->_dialogs->show(35313);
-	else if (_action.isAction(VERB_LOOK, 0x2B3))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_SOUTH))
 		_vm->_dialogs->show(35314);
-	else if (_action.isAction(VERB_LOOK, 0x89))
+	else if (_action.isAction(VERB_LOOK, NOUN_FLOOR))
 		_vm->_dialogs->show(35316);
-	else if (_action.isAction(VERB_LOOK, 0x46))
+	else if (_action.isAction(VERB_LOOK, NOUN_CEILING))
 		_vm->_dialogs->show(35317);
-	else if (_action.isAction(VERB_LOOK, 0x18D))
+	else if (_action.isAction(VERB_LOOK, NOUN_WALL))
 		_vm->_dialogs->show(35318);
 	else
 		return;
@@ -4649,41 +4649,41 @@ void Scene354::enter() {
 }
 
 void Scene354::preActions() {
-	if (_action.isAction(VERB_WALK_DOWN, 0x2B3))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_SOUTH))
 		_game._player._walkOffScreenSceneId = 401;
 }
 
 void Scene354::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(35414);
-	else if (_action.isAction(VERB_WALK_DOWN, 0x2B4)) {
+	else if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_NORTH)) {
 		_game._player.startWalking(Common::Point(208, 0), FACING_NORTHEAST);
 		_game._player._walkOffScreenSceneId = 353;
-	} else if (_action.isAction(VERB_WALK_DOWN, 0x2B9))
+	} else if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_EAST))
 		_scene->_nextSceneId = 361;
-	else if (_action.isAction(VERB_WALK_DOWN, 0x2BA))
+	else if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_WEST))
 		_scene->_nextSceneId = 316;
-	else if (_action.isAction(VERB_WALK_DOWN, 0x2B3))
+	else if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_SOUTH))
 		_scene->_nextSceneId = 401;
-	else if (_action.isAction(VERB_LOOK, 0x2C6))
+	else if (_action.isAction(VERB_LOOK, NOUN_CONTROLS))
 		_vm->_dialogs->show(35410);
-	else if (_action.isAction(VERB_LOOK, 0x1FD))
+	else if (_action.isAction(VERB_LOOK, NOUN_SIGNAL))
 		_vm->_dialogs->show(35411);
-	else if (_action.isAction(VERB_LOOK, 0x2D0))
+	else if (_action.isAction(VERB_LOOK, NOUN_CATWALK))
 		_vm->_dialogs->show(35412);
-	else if (_action.isAction(VERB_LOOK, 0x206))
+	else if (_action.isAction(VERB_LOOK, NOUN_AIR_DUCT))
 		_vm->_dialogs->show(35413);
-	else if (_action.isAction(VERB_LOOK, 0x2B4))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_NORTH))
 		_vm->_dialogs->show(35415);
-	else if (_action.isAction(VERB_LOOK, 0x2B3))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_SOUTH))
 		_vm->_dialogs->show(35416);
-	else if (_action.isAction(VERB_LOOK, 0x2B9))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_EAST))
 		_vm->_dialogs->show(35417);
-	else if (_action.isAction(VERB_LOOK, 0x2BA))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_WEST))
 		_vm->_dialogs->show(35418);
-	else if (_action.isAction(VERB_LOOK, 0x218))
+	else if (_action.isAction(VERB_LOOK, NOUN_DEBRIS))
 		_vm->_dialogs->show(35419);
-	else if (_action.isAction(VERB_LOOK, 0x239))
+	else if (_action.isAction(VERB_LOOK, NOUN_GUARD))
 		_vm->_dialogs->show(35420);
 	else
 		return;
@@ -4716,41 +4716,41 @@ void Scene357::enter() {
 }
 
 void Scene357::preActions() {
-	if (_action.isAction(VERB_WALK_DOWN, 0x2B9))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_EAST))
 		_game._player._walkOffScreenSceneId = 318;
 
-	if (_action.isAction(VERB_WALK_DOWN, 0x2BA))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_WEST))
 		_game._player._walkOffScreenSceneId = 358;
 }
 
 void Scene357::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(35715);
-	else if (_action.isAction(VERB_LOOK, 0x11))
+	else if (_action.isAction(VERB_LOOK, NOUN_AIR_VENT))
 		_vm->_dialogs->show(35710);
-	else if (_action.isAction(VERB_CLIMB_INTO, 0x11))
+	else if (_action.isAction(VERB_CLIMB_INTO, NOUN_AIR_VENT))
 		_vm->_dialogs->show(35711);
-	else if (_action.isAction(VERB_LOOK, 0x1CB))
+	else if (_action.isAction(VERB_LOOK, NOUN_BED))
 		_vm->_dialogs->show(35712);
-	else if (_action.isAction(VERB_LOOK, 0x216))
+	else if (_action.isAction(VERB_LOOK, NOUN_SINK))
 		_vm->_dialogs->show(35713);
-	else if (_action.isAction(VERB_LOOK, 0x21B))
+	else if (_action.isAction(VERB_LOOK, NOUN_TOILET))
 		_vm->_dialogs->show(35714);
-	else if (_action.isAction(VERB_LOOK, 0x207))
+	else if (_action.isAction(VERB_LOOK, NOUN_CELL_WALL))
 		_vm->_dialogs->show(35716);
-	else if (_action.isAction(VERB_LOOK, 0xCD))
+	else if (_action.isAction(VERB_LOOK, NOUN_LIGHT))
 		_vm->_dialogs->show(35717);
-	else if (_action.isAction(VERB_LOOK, 0x23A))
+	else if (_action.isAction(VERB_LOOK, NOUN_RIP_IN_FLOOR))
 		_vm->_dialogs->show(35718);
-	else if (_action.isAction(VERB_LOOK, 0x218))
+	else if (_action.isAction(VERB_LOOK, NOUN_DEBRIS))
 		_vm->_dialogs->show(35719);
-	else if (_action.isAction(VERB_TAKE, 0x218))
+	else if (_action.isAction(VERB_TAKE, NOUN_DEBRIS))
 		_vm->_dialogs->show(35720);
-	else if (_action.isAction(VERB_LOOK, 0x18D))
+	else if (_action.isAction(VERB_LOOK, NOUN_WALL))
 		_vm->_dialogs->show(35721);
-	else if (_action.isAction(VERB_LOOK, 0x2B9))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_EAST))
 		_vm->_dialogs->show(35722);
-	else if (_action.isAction(VERB_LOOK, 0x2BA))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_WEST))
 		_vm->_dialogs->show(35723);
 	else
 		return;
@@ -4780,29 +4780,29 @@ void Scene358::enter() {
 }
 
 void Scene358::preActions() {
-	if (_action.isAction(VERB_WALK_DOWN, 0x2B9))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_EAST))
 		_game._player._walkOffScreenSceneId = 357;
 
-	if (_action.isAction(VERB_WALK_DOWN, 0x2BA))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_WEST))
 		_game._player._walkOffScreenSceneId = 359;
 }
 
 void Scene358::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(35815);
-	else if (_action.isAction(VERB_LOOK, 0x2BA))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_WEST))
 		_vm->_dialogs->show(35810);
-	else if (_action.isAction(VERB_LOOK, 0x2B9))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_EAST))
 		_vm->_dialogs->show(35811);
-	else if (_action.isAction(VERB_LOOK, 0x1CB))
+	else if (_action.isAction(VERB_LOOK, NOUN_BED))
 		_vm->_dialogs->show(35812);
-	else if (_action.isAction(VERB_LOOK, 0x216))
+	else if (_action.isAction(VERB_LOOK, NOUN_SINK))
 		_vm->_dialogs->show(35813);
-	else if (_action.isAction(VERB_LOOK, 0x21B))
+	else if (_action.isAction(VERB_LOOK, NOUN_TOILET))
 		_vm->_dialogs->show(35814);
-	else if (_action.isAction(VERB_LOOK, 0x204) || _action.isAction(VERB_LOOK, 0x18D))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR) || _action.isAction(VERB_LOOK, NOUN_WALL))
 		_vm->_dialogs->show(35816);
-	else if (_action.isAction(VERB_LOOK, 0x11))
+	else if (_action.isAction(VERB_LOOK, NOUN_AIR_VENT))
 		_vm->_dialogs->show(35817);
 	else
 		return;
@@ -4846,10 +4846,10 @@ void Scene359::enter() {
 }
 
 void Scene359::preActions() {
-	if (_action.isAction(VERB_WALK_DOWN, 0x2B9))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_EAST))
 		_game._player._walkOffScreenSceneId = 358;
 
-	if (_action.isAction(VERB_WALK_DOWN, 0x2BA))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_WEST))
 		_game._player._walkOffScreenSceneId = 360;
 }
 
@@ -4859,7 +4859,7 @@ void Scene359::actions() {
 			_vm->_dialogs->show(35914);
 		else
 			_vm->_dialogs->show(35915);
-	} else if (_action.isAction(VERB_TAKE, 0x131)) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_SECURITY_CARD)) {
 		if (_game._trigger || !_game._objects.isInInventory(OBJ_SECURITY_CARD)) {
 			switch (_game._trigger) {
 			case 0:
@@ -4903,43 +4903,43 @@ void Scene359::actions() {
 				break;
 			}
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x23E))
+	} else if (_action.isAction(VERB_LOOK, NOUN_BLOODY_CELL_WALL))
 		_vm->_dialogs->show(35910);
-	else if (_action.isAction(VERB_LOOK, 0x1CB))
+	else if (_action.isAction(VERB_LOOK, NOUN_BED))
 		_vm->_dialogs->show(35911);
-	else if (_action.isAction(VERB_LOOK, 0x216))
+	else if (_action.isAction(VERB_LOOK, NOUN_SINK))
 		_vm->_dialogs->show(35912);
-	else if (_action.isAction(VERB_LOOK, 0x21B))
+	else if (_action.isAction(VERB_LOOK, NOUN_TOILET))
 		_vm->_dialogs->show(35913);
-	else if (_action.isAction(VERB_LOOK, 0x2B9))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_EAST))
 		_vm->_dialogs->show(35916);
-	else if (_action.isAction(VERB_LOOK, 0x2BA))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_WEST))
 		_vm->_dialogs->show(35917);
-	else if (_action.isAction(VERB_LOOK, 0x215))
+	else if (_action.isAction(VERB_LOOK, NOUN_LIMB))
 		_vm->_dialogs->show(35918);
-	else if (_action.isAction(VERB_TAKE, 0x215))
+	else if (_action.isAction(VERB_TAKE, NOUN_LIMB))
 		_vm->_dialogs->show(35919);
-	else if (_action.isAction(VERB_LOOK, 0x131) && (_action._mainObjectSource == 4))
+	else if (_action.isAction(VERB_LOOK, NOUN_SECURITY_CARD) && (_action._mainObjectSource == 4))
 		_vm->_dialogs->show(35921);
-	else if (_action.isAction(VERB_LOOK, 0x2D2)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_BLOOD_STAIN)) {
 		if ((_game._difficulty != DIFFICULTY_HARD) && (_game._objects[OBJ_SECURITY_CARD]._roomNumber == 359))
 			_vm->_dialogs->show(35922);
 		else
 			_vm->_dialogs->show(35923);
-	} else if (_action.isAction(VERB_LOOK, 0x23F))
+	} else if (_action.isAction(VERB_LOOK, NOUN_WALL_BOARD))
 		_vm->_dialogs->show(35924);
-	else if (_action.isAction(VERB_TAKE, 0x23F))
+	else if (_action.isAction(VERB_TAKE, NOUN_WALL_BOARD))
 		_vm->_dialogs->show(35925);
-	else if (_action.isAction(VERB_LOOK, 0x23A))
+	else if (_action.isAction(VERB_LOOK, NOUN_RIP_IN_FLOOR))
 		_vm->_dialogs->show(35926);
-	else if (_action.isAction(VERB_LOOK, 0x204))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR))
 		_vm->_dialogs->show(35927);
-	else if (_action.isAction(VERB_LOOK, 0x89)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_FLOOR)) {
 		if ((_game._difficulty != DIFFICULTY_HARD) && (_game._objects[OBJ_SECURITY_CARD]._roomNumber == 359))
 			_vm->_dialogs->show(35928);
 		else
 			_vm->_dialogs->show(35929);
-	} else if (_action.isAction(VERB_OPEN, 0x11) || _action.isAction(VERB_LOOK, 0x11))
+	} else if (_action.isAction(VERB_OPEN, NOUN_AIR_VENT) || _action.isAction(VERB_LOOK, NOUN_AIR_VENT))
 		_vm->_dialogs->show(36016);
 	else
 		return;
@@ -4976,31 +4976,31 @@ void Scene360::enter() {
 }
 
 void Scene360::preActions() {
-	if (_action.isAction(VERB_WALK_DOWN, 0x2B9))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_EAST))
 		_game._player._walkOffScreenSceneId = 359;
 
-	if (_action.isAction(VERB_WALK_DOWN, 0x2BA))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_WEST))
 		_game._player._walkOffScreenSceneId = 361;
 }
 
 void Scene360::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(36015);
-	else if (_action.isAction(VERB_LOOK, 0x2BA))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_WEST))
 		_vm->_dialogs->show(36010);
-	else if (_action.isAction(VERB_LOOK, 0x2B9))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_EAST))
 		_vm->_dialogs->show(36011);
-	else if (_action.isAction(VERB_LOOK, 0x1CB))
+	else if (_action.isAction(VERB_LOOK, NOUN_BED))
 		_vm->_dialogs->show(36012);
-	else if (_action.isAction(VERB_LOOK, 0x216))
+	else if (_action.isAction(VERB_LOOK, NOUN_SINK))
 		_vm->_dialogs->show(36013);
-	else if (_action.isAction(VERB_LOOK, 0x21B))
+	else if (_action.isAction(VERB_LOOK, NOUN_TOILET))
 		_vm->_dialogs->show(36014);
-	else if (_action.isAction(VERB_LOOK, 0x11))
+	else if (_action.isAction(VERB_LOOK, NOUN_AIR_VENT))
 		_vm->_dialogs->show(36016);
-	else if (_action.isAction(VERB_LOOK, 0x204))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR))
 		_vm->_dialogs->show(36017);
-	else if (_action.isAction(VERB_LOOK, 0x18D))
+	else if (_action.isAction(VERB_LOOK, NOUN_WALL))
 		_vm->_dialogs->show(36018);
 	else
 		return;
@@ -5348,43 +5348,43 @@ void Scene361::step() {
 }
 
 void Scene361::preActions() {
-	if (_action.isAction(VERB_WALK_DOWN, 0x2B9))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_EAST))
 		_game._player._walkOffScreenSceneId = 360;
 
-	if (_action.isAction(VERB_WALK_DOWN, 0x2BA))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_WEST))
 		_game._player._walkOffScreenSceneId = 354;
 }
 
 void Scene361::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(36119);
-	else if (_action.isAction(VERB_SIT_AT, 0x1E4)) {
+	else if (_action.isAction(VERB_SIT_AT, NOUN_DESK)) {
 		_scene->_kernelMessages.reset();
 		_scene->_kernelMessages.addQuote(0xFC, 120, 0);
-	} else if (_action.isAction(VERB_CLIMB_INTO, 0x11)) {
+	} else if (_action.isAction(VERB_CLIMB_INTO, NOUN_AIR_VENT)) {
 		if (_globals[kSexOfRex] == REX_FEMALE)
 			handleRoxAction();
 		else
 			handleRexAction();
-	} else if (_action.isAction(VERB_LOOK, 0x1E4))
+	} else if (_action.isAction(VERB_LOOK, NOUN_DESK))
 		_vm->_dialogs->show(36110);
-	else if (_action.isAction(VERB_LOOK, 0x18D))
+	else if (_action.isAction(VERB_LOOK, NOUN_WALL))
 		_vm->_dialogs->show(36111);
-	else if (_action.isAction(VERB_LOOK, 0x220) || _action.isAction(VERB_STARE_AT, 0x220))
+	else if (_action.isAction(VERB_LOOK, NOUN_LIGHTING_FIXTURE) || _action.isAction(VERB_STARE_AT, NOUN_LIGHTING_FIXTURE))
 		_vm->_dialogs->show(36112);
-	else if (_action.isAction(VERB_LOOK, 0x208) || _action.isAction(VERB_STARE_AT, 0x208))
+	else if (_action.isAction(VERB_LOOK, NOUN_LIGHTS) || _action.isAction(VERB_STARE_AT, NOUN_LIGHTS))
 		_vm->_dialogs->show(36113);
-	else if (_action.isAction(VERB_TAKE, 0x208))
+	else if (_action.isAction(VERB_TAKE, NOUN_LIGHTS))
 		_vm->_dialogs->show(36114);
-	else if (_action.isAction(VERB_LOOK, 0x2F8) || _action.isAction(VERB_STARE_AT, 0x2F8))
+	else if (_action.isAction(VERB_LOOK, NOUN_LIGHT_BULB) || _action.isAction(VERB_STARE_AT, NOUN_LIGHT_BULB))
 		_vm->_dialogs->show(36115);
-	else if (_action.isAction(VERB_TAKE, 0x2F8))
+	else if (_action.isAction(VERB_TAKE, NOUN_LIGHT_BULB))
 		_vm->_dialogs->show(36116);
-	else if (_action.isAction(VERB_LOOK, 0x2BA))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_WEST))
 		_vm->_dialogs->show(36117);
-	else if (_action.isAction(VERB_LOOK, 0x2B9))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_EAST))
 		_vm->_dialogs->show(36118);
-	else if (_action.isAction(VERB_LOOK, 0x11))
+	else if (_action.isAction(VERB_LOOK, NOUN_AIR_VENT))
 		_vm->_dialogs->show(36120);
 	else
 		return;
@@ -5406,15 +5406,15 @@ void Scene366::enter() {
 }
 
 void Scene366::actions() {
-	if (_action.isAction(VERB_RETURN_TO, 0x2D4))
+	if (_action.isAction(VERB_RETURN_TO, NOUN_AIR_SHAFT))
 		_scene->_nextSceneId = 302;
-	else if (_action.isAction(VERB_OPEN, 0x2D3)) {
+	else if (_action.isAction(VERB_OPEN, NOUN_GRATE)) {
 		if (_game._visitedScenes.exists(316))
 			_vm->_dialogs->show(36612);
 		else
 			_vm->_dialogs->show(36613);
 		_scene->_nextSceneId = 316;
-	} else if (_action.isAction(VERB_LOOK_THROUGH, 0x2D3)) {
+	} else if (_action.isAction(VERB_LOOK_THROUGH, NOUN_GRATE)) {
 		if (_game._visitedScenes.exists(321))
 			_vm->_dialogs->show(36611);
 		else
@@ -5441,11 +5441,11 @@ void Scene387::enter() {
 }
 
 void Scene387::actions() {
-	if (_action.isAction(VERB_RETURN_TO, 0x2D4))
+	if (_action.isAction(VERB_RETURN_TO, NOUN_AIR_SHAFT))
 		_scene->_nextSceneId = 313;
-	else if (_action.isAction(VERB_LOOK_THROUGH, 0x2D3))
+	else if (_action.isAction(VERB_LOOK_THROUGH, NOUN_GRATE))
 		_vm->_dialogs->show(38710);
-	else if (_action.isAction(VERB_OPEN, 0x2D3))
+	else if (_action.isAction(VERB_OPEN, NOUN_GRATE))
 		_vm->_dialogs->show(38711);
 	else
 		return;
@@ -5479,9 +5479,9 @@ void Scene388::enter() {
 }
 
 void Scene388::actions() {
-	if (_action.isAction(VERB_RETURN_TO, 0x2D4))
+	if (_action.isAction(VERB_RETURN_TO, NOUN_AIR_SHAFT))
 		_scene->_nextSceneId = 313;
-	else if (_action.isAction(VERB_TALKTO, 0x303)) {
+	else if (_action.isAction(VERB_TALKTO, NOUN_SAUROPOD)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -5503,12 +5503,12 @@ void Scene388::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_LOOK_THROUGH, 0x2D3)) {
+	} else if (_action.isAction(VERB_LOOK_THROUGH, NOUN_GRATE)) {
 		if (_globals[kAfterHavoc])
 			_vm->_dialogs->show(38811);
 		else
 			_vm->_dialogs->show(38810);
-	} else if (_action.isAction(VERB_OPEN, 0x2D3))
+	} else if (_action.isAction(VERB_OPEN, NOUN_GRATE))
 		_vm->_dialogs->show(38812);
 	else
 		return;
@@ -5556,9 +5556,9 @@ void Scene389::step() {
 }
 
 void Scene389::actions() {
-	if (_action.isAction(VERB_RETURN_TO, 0x2D4))
+	if (_action.isAction(VERB_RETURN_TO, NOUN_AIR_SHAFT))
 		_scene->_nextSceneId = 313;
-	else if (_action.isAction(VERB_TALKTO, 0x304)) {
+	else if (_action.isAction(VERB_TALKTO, NOUN_MONSTER)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -5576,7 +5576,7 @@ void Scene389::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_LOOK_THROUGH, 0x2D3)) {
+	} else if (_action.isAction(VERB_LOOK_THROUGH, NOUN_GRATE)) {
 		if (_globals[kAfterHavoc]) {
 			if ((_game._difficulty != DIFFICULTY_HARD) && (_game._objects[OBJ_SECURITY_CARD]._roomNumber == 359))
 				_vm->_dialogs->show(38911);
@@ -5584,7 +5584,7 @@ void Scene389::actions() {
 				_vm->_dialogs->show(38912);
 		} else
 			_vm->_dialogs->show(38910);
-	} else if (_action.isAction(VERB_OPEN, 0x2D3)) {
+	} else if (_action.isAction(VERB_OPEN, NOUN_GRATE)) {
 		if (_globals[kAfterHavoc])
 			_vm->_dialogs->show(38914);
 		else
@@ -5617,11 +5617,11 @@ void Scene390::enter() {
 }
 
 void Scene390::actions() {
-	if (_action.isAction(VERB_RETURN_TO, 0x2D4))
+	if (_action.isAction(VERB_RETURN_TO, NOUN_AIR_SHAFT))
 		_scene->_nextSceneId = 313;
-	else if (_action.isAction(VERB_LOOK_THROUGH, 0x2D3))
+	else if (_action.isAction(VERB_LOOK_THROUGH, NOUN_GRATE))
 		_vm->_dialogs->show(39010);
-	else if (_action.isAction(VERB_OPEN, 0x2D3))
+	else if (_action.isAction(VERB_OPEN, NOUN_GRATE))
 		_vm->_dialogs->show(39011);
 	else
 		return;
@@ -5643,9 +5643,9 @@ void Scene391::enter() {
 }
 
 void Scene391::actions() {
-	if (_action.isAction(VERB_RETURN_TO, 0x2D4))
+	if (_action.isAction(VERB_RETURN_TO, NOUN_AIR_SHAFT))
 		_scene->_nextSceneId = 313;
-	else if (_action.isAction(VERB_OPEN, 0x2D3)) {
+	else if (_action.isAction(VERB_OPEN, NOUN_GRATE)) {
 		if (_globals[kKickedIn391Grate])
 			_vm->_dialogs->show(39113);
 		else {
@@ -5657,7 +5657,7 @@ void Scene391::actions() {
 			_scene->_nextSceneId = 361;
 		else
 			_scene->_nextSceneId = 311;
-	} else if (_action.isAction(VERB_LOOK_THROUGH, 0x2D3)) {
+	} else if (_action.isAction(VERB_LOOK_THROUGH, NOUN_GRATE)) {
 		if (_globals[kAfterHavoc])
 			_vm->_dialogs->show(39111);
 		else
@@ -5682,9 +5682,9 @@ void Scene399::enter() {
 }
 
 void Scene399::actions() {
-	if (_action.isAction(VERB_RETURN_TO, 0x2D4))
+	if (_action.isAction(VERB_RETURN_TO, NOUN_AIR_SHAFT))
 		_scene->_nextSceneId = 313;
-	else if (_action.isAction(VERB_LOOK_THROUGH, 0x2D3)) {
+	else if (_action.isAction(VERB_LOOK_THROUGH, NOUN_GRATE)) {
 		if (_globals[kAfterHavoc]) {
 			if ((_game._difficulty != DIFFICULTY_HARD) && (_game._objects[OBJ_SECURITY_CARD]._roomNumber == 359))
 				_vm->_dialogs->show(38911);
@@ -5692,7 +5692,7 @@ void Scene399::actions() {
 				_vm->_dialogs->show(38912);
 		} else
 			_vm->_dialogs->show(38910);
-	} else if (_action.isAction(VERB_OPEN, 0x2D3)) {
+	} else if (_action.isAction(VERB_OPEN, NOUN_GRATE)) {
 		if (_globals[kAfterHavoc])
 			_vm->_dialogs->show(38914);
 		else
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index d8f3607..dd196b4 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -158,12 +158,12 @@ void Scene401::step() {
 }
 
 void Scene401::preActions() {
-	if (_action.isAction(VERB_WALK_DOWN, 0x2B4)) {
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_NORTH)) {
 		_game._player.walk(Common::Point(149, 89), FACING_NORTH);
 		_northFl = false;
 	}
 
-	if (_action.isAction(VERB_WALK_DOWN, 0x2B3) && !_northFl)
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_SOUTH) && !_northFl)
 		_game._player._walkOffScreenSceneId = 405;
 
 	if (_action.isAction(VERB_TAKE))
@@ -204,23 +204,23 @@ void Scene401::actions() {
 		}
 	}
 
-	if (_action.isAction(VERB_WALK_INTO, 0x241)) {
+	if (_action.isAction(VERB_WALK_INTO, NOUN_BAR)) {
 		if (!_northFl)
 			_scene->_nextSceneId = 402;
-	} else if (_action.isAction(VERB_WALK_DOWN, 0x2B4))
+	} else if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_NORTH))
 		_scene->_nextSceneId = 354;
-	else if (_action.isAction(VERB_LOOK, 0x1F3)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_SCANNER)) {
 		if (_globals[kHasBeenScanned])
 			_vm->_dialogs->show(40111);
 		else
 			_vm->_dialogs->show(40110);
-	} else if (_action.isAction(VERB_LOOK, 0x241))
+	} else if (_action.isAction(VERB_LOOK, NOUN_BAR))
 		_vm->_dialogs->show(40112);
-	else if (_action.isAction(VERB_LOOK, 0x244))
+	else if (_action.isAction(VERB_LOOK, NOUN_SIGN))
 		_vm->_dialogs->show(40113);
-	else if (_action.isAction(VERB_LOOK, 0x2B3))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_SOUTH))
 		_vm->_dialogs->show(40114);
-	else if (_action.isAction(VERB_LOOK, 0x2B4))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_NORTH))
 		_vm->_dialogs->show(40115);
 	else if (_action._lookFlag)
 		_vm->_dialogs->show(40116);
@@ -1977,29 +1977,29 @@ void Scene402::step() {
 }
 
 void Scene402::preActions() {
-	if (_action.isAction(VERB_SIT_ON, 0x24A) && (_game._player._prepareWalkPos.x != 248))
+	if (_action.isAction(VERB_SIT_ON, NOUN_BAR_STOOL) && (_game._player._prepareWalkPos.x != 248))
 		_game._player.walk(Common::Point(232, 112), FACING_EAST);
 
-	if (_action.isAction(VERB_WALKTO, 0x309))
+	if (_action.isAction(VERB_WALKTO, NOUN_WOMAN_ON_BALCONY))
 		_game._player._needToWalk = _game._player._readyToWalk;
 
-	if (!_roxOnStool && _action.isAction(VERB_TAKE, 0x5C) && !_game._objects.isInInventory(OBJ_CREDIT_CHIP))
+	if (!_roxOnStool && _action.isAction(VERB_TAKE, NOUN_CREDIT_CHIP) && !_game._objects.isInInventory(OBJ_CREDIT_CHIP))
 		_game._player.walk(Common::Point(246, 108), FACING_NORTH);
 
 	if (_action.isAction(VERB_TAKE))
 		_game._player._needToWalk = false;
 
-	if (_action.isAction(VERB_TAKE, 0x5C) && !_roxOnStool)
+	if (_action.isAction(VERB_TAKE, NOUN_CREDIT_CHIP) && !_roxOnStool)
 		_game._player._needToWalk = true;
 
 	if (_roxOnStool) {
 		if (_action.isAction(VERB_LOOK) || _action.isAction(0x24A) || _action.isAction(VERB_TALKTO))
 			_game._player._needToWalk = false;
 
-		if (_action.isAction(VERB_TAKE, 0x124) || _action.isAction(VERB_TAKE, 0x5C))
+		if (_action.isAction(VERB_TAKE, NOUN_REPAIR_LIST) || _action.isAction(VERB_TAKE, NOUN_CREDIT_CHIP))
 			_game._player._needToWalk = false;
 
-		if (_action.isAction(VERB_TALKTO, 0x30A) || _action.isAction(VERB_TALKTO, 0x30C))
+		if (_action.isAction(VERB_TALKTO, NOUN_WOMAN_IN_CHAIR) || _action.isAction(VERB_TALKTO, NOUN_WOMAN_IN_ALCOVE))
 			_game._player._needToWalk = _game._player._readyToWalk;
 
 		if (_game._player._needToWalk) {
@@ -2011,22 +2011,22 @@ void Scene402::preActions() {
 		}
 	}
 
-	if (_action.isAction(VERB_TAKE, 0x124) && !_roxOnStool && !_game._objects.isInInventory(OBJ_REPAIR_LIST))
+	if (_action.isAction(VERB_TAKE, NOUN_REPAIR_LIST) && !_roxOnStool && !_game._objects.isInInventory(OBJ_REPAIR_LIST))
 		_game._player.walk(Common::Point(191, 99), FACING_NORTHEAST);
 
-	if (_action.isAction(VERB_TALKTO, 0x30E) && !_roxOnStool)
+	if (_action.isAction(VERB_TALKTO, NOUN_BARTENDER) && !_roxOnStool)
 		_game._player.walk(Common::Point(228, 83), FACING_SOUTH);
 
-	if (_action.isAction(VERB_TALKTO, 0x3AA) && !_roxOnStool)
+	if (_action.isAction(VERB_TALKTO, NOUN_REPAIR_WOMAN) && !_roxOnStool)
 		_game._player.walk(Common::Point(208, 102), FACING_NORTHEAST);
 }
 
 void Scene402::actions() {
-	if (_action.isAction(VERB_TAKE, 0x124) && _game._objects.isInRoom(OBJ_REPAIR_LIST) && _roxOnStool) {
+	if (_action.isAction(VERB_TAKE, NOUN_REPAIR_LIST) && _game._objects.isInRoom(OBJ_REPAIR_LIST) && _roxOnStool) {
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_scene->_sequences.addTimer(1, 77);
 		_game._player._needToWalk = false;
-	} else if (_action.isAction(VERB_TAKE, 0x124) && _game._objects.isInRoom(OBJ_REPAIR_LIST) && !_roxOnStool) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_REPAIR_LIST) && _game._objects.isInRoom(OBJ_REPAIR_LIST) && !_roxOnStool) {
 		if (_game._trigger == 0) {
 			_game._player._stepEnabled = false;
 			_game._player._visible = false;
@@ -2048,11 +2048,11 @@ void Scene402::actions() {
 		_game._player._stepEnabled = true;
 	} else if (_game._screenObjects._inputMode == 1)
 		handleDialogs();
-	else if (_action.isAction(VERB_WALK_INTO, 0x2B3))
+	else if (_action.isAction(VERB_WALK_INTO, NOUN_CORRIDOR_TO_SOUTH))
 		_scene->_nextSceneId = 401;
-	else if (_action.isAction(VERB_WALK_ONTO, 0x248))
+	else if (_action.isAction(VERB_WALK_ONTO, NOUN_DANCE_FLOOR))
 		; // just... nothing
-	else if (_action.isAction(VERB_TALKTO, 0x3AA)) {
+	else if (_action.isAction(VERB_TALKTO, NOUN_REPAIR_WOMAN)) {
 		switch (_game._trigger) {
 		case 0: {
 			_game._player._stepEnabled = false;
@@ -2128,26 +2128,26 @@ void Scene402::actions() {
 			}
 			break;
 		}
-	} else if (_action.isAction(VERB_TALKTO, 0x30A) && !_firstTalkToGirlInChair) {
+	} else if (_action.isAction(VERB_TALKTO, NOUN_WOMAN_IN_CHAIR) && !_firstTalkToGirlInChair) {
 		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x1D7));
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_scene->_sequences.addTimer(150, 39);
 		_game._player._stepEnabled = false;
 		_firstTalkToGirlInChair = true;
-	} else if (_action.isAction(VERB_TALKTO, 0x30A) && _firstTalkToGirlInChair) {
+	} else if (_action.isAction(VERB_TALKTO, NOUN_WOMAN_IN_CHAIR) && _firstTalkToGirlInChair) {
 		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x1DB));
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_scene->_sequences.addTimer(150, 42);
 		_game._player._stepEnabled = false;
-	} else if (_action.isAction(VERB_TALKTO, 0x30C) || _action.isAction(VERB_WALKTO, 0x30C)) {
+	} else if (_action.isAction(VERB_TALKTO, NOUN_WOMAN_IN_ALCOVE) || _action.isAction(VERB_WALKTO, NOUN_WOMAN_IN_ALCOVE)) {
 		_scene->_kernelMessages.add(Common::Point(102, 48), 0xFBFA, 0, 0, 120, _game.getQuote(0x1DE));
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_scene->_sequences.addTimer(120, 44);
 		_game._player._stepEnabled = false;
-	} else if (_action.isAction(VERB_WALK_ALONG, 0x24A) && (_game._player._targetPos.x == 248)){
+	} else if (_action.isAction(VERB_WALK_ALONG, NOUN_BAR_STOOL) && (_game._player._targetPos.x == 248)){
 		_scene->_kernelMessages.add(Common::Point(0, -14), 0x1110, 34, 0, 120, _game.getQuote(0x20D));
 		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x20E));
-	} else if (_action.isAction(VERB_WALK_ALONG, 0x24A) && !_roxOnStool && (_game._player._targetPos.x != 248)) {
+	} else if (_action.isAction(VERB_WALK_ALONG, NOUN_BAR_STOOL) && !_roxOnStool && (_game._player._targetPos.x != 248)) {
 		_game._player._visible = false;
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 7, 1, 0, 0);
@@ -2155,11 +2155,11 @@ void Scene402::actions() {
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 5);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 76);
 		_game._player._stepEnabled = false;
-	} else if (_action.isAction(VERB_TAKE, 0x5C) && !_game._objects.isInInventory(OBJ_CREDIT_CHIP) && _roxOnStool) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_CREDIT_CHIP) && !_game._objects.isInInventory(OBJ_CREDIT_CHIP) && _roxOnStool) {
 		_roxMode = 20;
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_scene->_sequences.addTimer(1, 92);
-	} else if (_action.isAction(VERB_TAKE, 0x5C) && !_game._objects.isInInventory(OBJ_CREDIT_CHIP) && !_roxOnStool) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_CREDIT_CHIP) && !_game._objects.isInInventory(OBJ_CREDIT_CHIP) && !_roxOnStool) {
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
@@ -2170,7 +2170,7 @@ void Scene402::actions() {
 		_scene->_sequences.setScale(_globals._sequenceIndexes[22], 88);
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[22], SEQUENCE_TRIGGER_EXPIRE, 0, 104);
-	} else if (_action.isAction(VERB_TALKTO, 0x30E)) {
+	} else if (_action.isAction(VERB_TALKTO, NOUN_BARTENDER)) {
 		switch (_game._trigger) {
 		case 0: {
 			int centerFlag;
@@ -2281,66 +2281,66 @@ void Scene402::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x248))
+	} else if (_action.isAction(VERB_LOOK, NOUN_DANCE_FLOOR))
 		_vm->_dialogs->show(40210);
-	else if (_action.isAction(VERB_LOOK, 0x16C)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_TELEPORTER)) {
 		if (_globals[kSomeoneHasExploded])
 			_vm->_dialogs->show(40212);
 		else
 			_vm->_dialogs->show(40211);
-	} else if (_action.isAction(VERB_LOOK, 0x241))
+	} else if (_action.isAction(VERB_LOOK, NOUN_BAR))
 		_vm->_dialogs->show(40213);
-	else if (_action.isAction(VERB_LOOK, 0x30E))
+	else if (_action.isAction(VERB_LOOK, NOUN_BARTENDER))
 		_vm->_dialogs->show(40214);
-	else if (_action.isAction(VERB_LOOK, 0x30C))
+	else if (_action.isAction(VERB_LOOK, NOUN_WOMAN_IN_ALCOVE))
 		_vm->_dialogs->show(40215);
-	else if (_action.isAction(VERB_LOOK, 0x309))
+	else if (_action.isAction(VERB_LOOK, NOUN_WOMAN_ON_BALCONY))
 		_vm->_dialogs->show(40216);
-	else if (_action.isAction(VERB_LOOK, 0x30A))
+	else if (_action.isAction(VERB_LOOK, NOUN_WOMAN_IN_CHAIR))
 		_vm->_dialogs->show(40217);
-	else if (_action.isAction(VERB_LOOK, 0x3AA))
+	else if (_action.isAction(VERB_LOOK, NOUN_REPAIR_WOMAN))
 		_vm->_dialogs->show(40218);
-	else if (_action.isAction(VERB_LOOK, 0x2B3))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_SOUTH))
 		_vm->_dialogs->show(40219);
 	else if (_action._lookFlag)
 		_vm->_dialogs->show(40220);
-	else if (_action.isAction(VERB_LOOK, 0x2B8))
+	else if (_action.isAction(VERB_LOOK, NOUN_WOMEN))
 		_vm->_dialogs->show(40221);
-	else if (_action.isAction(VERB_PUSH, 0x3AA) || _action.isAction(VERB_PULL, 0x3AA))
+	else if (_action.isAction(VERB_PUSH, NOUN_REPAIR_WOMAN) || _action.isAction(VERB_PULL, NOUN_REPAIR_WOMAN))
 		_vm->_dialogs->show(40222);
-	else if (_action.isAction(VERB_TALKTO, 0x2B8))
+	else if (_action.isAction(VERB_TALKTO, NOUN_WOMEN))
 		_vm->_dialogs->show(40223);
-	else if (_action.isAction(VERB_TALKTO, 0x309))
+	else if (_action.isAction(VERB_TALKTO, NOUN_WOMAN_ON_BALCONY))
 		_vm->_dialogs->show(40224);
-	else if (_action.isAction(VERB_LOOK, 0x249))
+	else if (_action.isAction(VERB_LOOK, NOUN_RAILING))
 		_vm->_dialogs->show(40225);
-	else if (_action.isAction(VERB_LOOK, 0x160))
+	else if (_action.isAction(VERB_LOOK, NOUN_TABLE))
 		_vm->_dialogs->show(40226);
-	else if (_action.isAction(VERB_TAKE, 0x160))
+	else if (_action.isAction(VERB_TAKE, NOUN_TABLE))
 		_vm->_dialogs->show(40227);
-	else if (_action.isAction(VERB_LOOK, 0x244))
+	else if (_action.isAction(VERB_LOOK, NOUN_SIGN))
 		_vm->_dialogs->show(40228);
-	else if (_action.isAction(VERB_TAKE, 0x244))
+	else if (_action.isAction(VERB_TAKE, NOUN_SIGN))
 		_vm->_dialogs->show(40229);
-	else if (_action.isAction(VERB_LOOK, 0x24A))
+	else if (_action.isAction(VERB_LOOK, NOUN_BAR_STOOL))
 		_vm->_dialogs->show(40230);
-	else if (_action.isAction(VERB_TAKE, 0x24A))
+	else if (_action.isAction(VERB_TAKE, NOUN_BAR_STOOL))
 		_vm->_dialogs->show(40231);
-	else if (_action.isAction(VERB_LOOK, 0x3B))
+	else if (_action.isAction(VERB_LOOK, NOUN_CACTUS))
 		_vm->_dialogs->show(40232);
-	else if (_action.isAction(VERB_TAKE, 0x3B))
+	else if (_action.isAction(VERB_TAKE, NOUN_CACTUS))
 		_vm->_dialogs->show(40233);
-	else if (_action.isAction(VERB_LOOK, 0x24E))
+	else if (_action.isAction(VERB_LOOK, NOUN_DISCO_BALL))
 		_vm->_dialogs->show(40234);
-	else if (_action.isAction(VERB_LOOK, 0x247))
+	else if (_action.isAction(VERB_LOOK, NOUN_UPPER_DANCE_FLOOR))
 		_vm->_dialogs->show(40235);
-	else if (_action.isAction(VERB_LOOK, 0x174))
+	else if (_action.isAction(VERB_LOOK, NOUN_TREE))
 		_vm->_dialogs->show(40236);
-	else if (_action.isAction(VERB_LOOK, 0x10E))
+	else if (_action.isAction(VERB_LOOK, NOUN_PLANT))
 		_vm->_dialogs->show(40237);
-	else if (_action.isAction(VERB_TAKE, 0x10E))
+	else if (_action.isAction(VERB_TAKE, NOUN_PLANT))
 		_vm->_dialogs->show(40238);
-	else if (_action.isAction(VERB_LOOK, 0x124) && _game._objects.isInRoom(OBJ_REPAIR_LIST))
+	else if (_action.isAction(VERB_LOOK, NOUN_REPAIR_LIST) && _game._objects.isInRoom(OBJ_REPAIR_LIST))
 		_vm->_dialogs->show(40239);
 	else
 		return;
@@ -2435,24 +2435,24 @@ void Scene405::preActions() {
 	if (_action.isAction(VERB_TAKE))
 		_game._player._needToWalk = false;
 
-	if (_action.isAction(VERB_WALK_DOWN, 0x2BA))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_WEST))
 		_game._player._walkOffScreenSceneId = 401;
 
-	if (_action.isAction(VERB_WALK_DOWN, 0x2B9))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_EAST))
 		_game._player._walkOffScreenSceneId = 406;
 
-	if (_action.isAction(VERB_CLOSE, 0x259) && _globals[kArmoryDoorOpen])
+	if (_action.isAction(VERB_CLOSE, NOUN_WIDE_DOOR) && _globals[kArmoryDoorOpen])
 		_game._player.walk(Common::Point(212, 113), FACING_NORTH);
 }
 
 void Scene405::actions() {
-	if (_action.isAction(VERB_WALK_THROUGH, 0x6E))
+	if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR))
 		_scene->_nextSceneId = 413;
-	else if (_action.isAction(VERB_WALK_THROUGH, 0x259) && _globals[kArmoryDoorOpen])
+	else if (_action.isAction(VERB_WALK_THROUGH, NOUN_WIDE_DOOR) && _globals[kArmoryDoorOpen])
 		_scene->_nextSceneId = 408;
-	else if (_action.isAction(VERB_WALK_THROUGH, 0x259) && !_globals[kArmoryDoorOpen])
+	else if (_action.isAction(VERB_WALK_THROUGH, NOUN_WIDE_DOOR) && !_globals[kArmoryDoorOpen])
 		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 60, _game.getQuote(0x24F));
-	else if (_action.isAction(VERB_PUT, 0x131, 0x251) && !_globals[kArmoryDoorOpen]) {
+	else if (_action.isAction(VERB_PUT, NOUN_SECURITY_CARD, 0x251) && !_globals[kArmoryDoorOpen]) {
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
@@ -2462,7 +2462,7 @@ void Scene405::actions() {
 		Common::Point msgPos = Common::Point(_game._player._playerPos.x, _game._player._playerPos.y + 1);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], msgPos);
 		_scene->_sequences.setScale(_globals._sequenceIndexes[3], 87);
-	} else if ((_action.isAction(VERB_PUT, 0x131, 0x251) || _action.isAction(VERB_CLOSE, 0x259)) && _globals[kArmoryDoorOpen]) {
+	} else if ((_action.isAction(VERB_PUT, NOUN_SECURITY_CARD, 0x251) || _action.isAction(VERB_CLOSE, NOUN_WIDE_DOOR)) && _globals[kArmoryDoorOpen]) {
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
@@ -2471,7 +2471,7 @@ void Scene405::actions() {
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], _game._player._playerPos);
 		_scene->_sequences.setScale(_globals._sequenceIndexes[3], 87);
-	} else if (_action.isAction(VERB_PUT, 0x251)) {
+	} else if (_action.isAction(VERB_PUT, NOUN_CARD_SLOT)) {
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
@@ -2480,36 +2480,36 @@ void Scene405::actions() {
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], _game._player._playerPos);
 		_scene->_sequences.setScale(_globals._sequenceIndexes[3], 87);
-	} else if (_action.isAction(VERB_LOOK, 0x31A))
+	} else if (_action.isAction(VERB_LOOK, NOUN_CANNON_BALLS))
 		_vm->_dialogs->show(40510);
-	else if (_action.isAction(VERB_TAKE, 0x31A))
+	else if (_action.isAction(VERB_TAKE, NOUN_CANNON_BALLS))
 		_vm->_dialogs->show(40511);
-	else if (_action.isAction(VERB_LOOK, 0x254))
+	else if (_action.isAction(VERB_LOOK, NOUN_WATER_FOUNTAIN))
 		_vm->_dialogs->show(40512);
-	else if (_action.isAction(VERB_LOOK, 0x258) || _action.isAction(VERB_LOOK, 0x252))
+	else if (_action.isAction(VERB_LOOK, NOUN_BACKBOARD) || _action.isAction(VERB_LOOK, NOUN_HOOP))
 		_vm->_dialogs->show(40513);
-	else if (_action.isAction(VERB_LOOK, 0xCD))
+	else if (_action.isAction(VERB_LOOK, NOUN_LIGHT))
 		_vm->_dialogs->show(40514);
-	else if (_action.isAction(VERB_LOOK, 0x251))
+	else if (_action.isAction(VERB_LOOK, NOUN_CARD_SLOT))
 		_vm->_dialogs->show(40515);
-	else if (_action.isAction(VERB_LOOK, 0x2B9))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_EAST))
 		_vm->_dialogs->show(40516);
-	else if (_action.isAction(VERB_LOOK, 0x2BA))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_WEST))
 		_vm->_dialogs->show(40517);
-	else if (_action.isAction(VERB_LOOK, 0xE2))
+	else if (_action.isAction(VERB_LOOK, NOUN_MONITOR))
 		_vm->_dialogs->show(40518);
-	else if (_action.isAction(VERB_LOOK, 0x204) || _action._lookFlag)
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR) || _action._lookFlag)
 		_vm->_dialogs->show(40519);
-	else if (_action.isAction(VERB_LOOK, 0x259)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_WIDE_DOOR)) {
 		if (_globals[kArmoryDoorOpen])
 			_vm->_dialogs->show(40521);
 		else
 			_vm->_dialogs->show(40520);
-	} else if (_action.isAction(VERB_LOOK, 0x6E))
+	} else if (_action.isAction(VERB_LOOK, NOUN_DOOR))
 		_vm->_dialogs->show(40522);
-	else if (_action.isAction(VERB_LOOK, 0x250))
+	else if (_action.isAction(VERB_LOOK, NOUN_COACH_LAMP))
 		_vm->_dialogs->show(40523);
-	else if (_action.isAction(VERB_LOOK, 0x257))
+	else if (_action.isAction(VERB_LOOK, NOUN_SUPPORT))
 		_vm->_dialogs->show(40524);
 	else
 		return;
@@ -2621,36 +2621,36 @@ void Scene406::step() {
 }
 
 void Scene406::preActions() {
-	if (_action.isAction(VERB_WALK_DOWN, 0x2BA))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_WEST))
 		_game._player._walkOffScreenSceneId = 405;
 
-	if (_action.isAction(VERB_WALK_DOWN, 0x2B9))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_EAST))
 		_game._player._walkOffScreenSceneId = 407;
 
 	if (_action.isAction(VERB_TAKE))
 		_game._player._needToWalk = false;
 
-	if (_action.isAction(VERB_LOOK, 0x244) || _action.isAction(VERB_LOOK, 0x25C))
+	if (_action.isAction(VERB_LOOK, NOUN_SIGN) || _action.isAction(VERB_LOOK, NOUN_TRASH))
 		_game._player._needToWalk = true;
 }
 
 void Scene406::actions() {
-	if (_action.isAction(VERB_WALK_THROUGH, 0x6E) && (_game._player._targetPos.x> 100)) {
+	if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR) && (_game._player._targetPos.x> 100)) {
 		_game._player._stepEnabled = false;
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_scene->_sequences.remove(_globals._sequenceIndexes[3]);
 		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 3, 1, 0, 0);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
 		_vm->_sound->command(19);
-	} else if (_action.isAction(VERB_WALK_THROUGH, 0x6E) && _globals[kStorageDoorOpen] && (_game._player._targetPos.x < 100))
+	} else if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR) && _globals[kStorageDoorOpen] && (_game._player._targetPos.x < 100))
 		_scene->_nextSceneId = 410;
-	else if (_action.isAction(VERB_WALK_THROUGH, 0x6E) && !_globals[kStorageDoorOpen] && (_game._player._targetPos.x < 100)) {
+	else if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR) && !_globals[kStorageDoorOpen] && (_game._player._targetPos.x < 100)) {
 		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 60, _game.getQuote(0x24F));
 		if (!_hitStorageDoor) {
 			_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 			_scene->_sequences.addTimer(80, 100);
 		}
-	} else if (_action.isAction(VERB_PUT, 0x131, 0x251) && !_globals[kStorageDoorOpen]) {
+	} else if (_action.isAction(VERB_PUT, NOUN_SECURITY_CARD, 0x251) && !_globals[kStorageDoorOpen]) {
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
@@ -2660,7 +2660,7 @@ void Scene406::actions() {
 		Common::Point msgPos = Common::Point(_game._player._playerPos.x, _game._player._playerPos.y + 1);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], msgPos);
 		_scene->_sequences.setScale(_globals._sequenceIndexes[2], 87);
-	} else if (_action.isAction(VERB_PUT, 0x131, 0x251) && _globals[kStorageDoorOpen]) {
+	} else if (_action.isAction(VERB_PUT, NOUN_SECURITY_CARD, 0x251) && _globals[kStorageDoorOpen]) {
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
@@ -2670,7 +2670,7 @@ void Scene406::actions() {
 		Common::Point msgPos = Common::Point(_game._player._playerPos.x, _game._player._playerPos.y + 1);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], msgPos);
 		_scene->_sequences.setScale(_globals._sequenceIndexes[2], 87);
-	} else if (_action.isAction(VERB_PUT, 0x251)) {
+	} else if (_action.isAction(VERB_PUT, NOUN_CARD_SLOT)) {
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
@@ -2679,42 +2679,42 @@ void Scene406::actions() {
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 110);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], _game._player._playerPos);
 		_scene->_sequences.setScale(_globals._sequenceIndexes[2], 87);
-	} else if (_action.isAction(VERB_LOOK, 0x25C))
+	} else if (_action.isAction(VERB_LOOK, NOUN_TRASH))
 		_vm->_dialogs->show(40610);
-	else if (_action.isAction(VERB_TAKE, 0x25C))
+	else if (_action.isAction(VERB_TAKE, NOUN_TRASH))
 		_vm->_dialogs->show(40611);
-	else if (_action.isAction(VERB_LOOK, 0x251))
+	else if (_action.isAction(VERB_LOOK, NOUN_CARD_SLOT))
 		_vm->_dialogs->show(40612);
-	else if (_action.isAction(VERB_LOOK, 0x25B))
+	else if (_action.isAction(VERB_LOOK, NOUN_FIRE_EXTINGUISHER))
 		_vm->_dialogs->show(40614);
-	else if (_action.isAction(VERB_TAKE, 0x25B))
+	else if (_action.isAction(VERB_TAKE, NOUN_FIRE_EXTINGUISHER))
 		_vm->_dialogs->show(40615);
-	else if (_action.isAction(VERB_LOOK, 0x2B9))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_EAST))
 		_vm->_dialogs->show(40616);
-	else if (_action.isAction(VERB_LOOK, 0x2BA))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_WEST))
 		_vm->_dialogs->show(40617);
-	else if (_action.isAction(VERB_LOOK, 0x204) || _action._lookFlag)
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR) || _action._lookFlag)
 		_vm->_dialogs->show(40618);
-	else if (_action.isAction(VERB_LOOK, 0x18D))
+	else if (_action.isAction(VERB_LOOK, NOUN_WALL))
 		_vm->_dialogs->show(40619);
-	else if (_action.isAction(VERB_LOOK, 0x6E)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_DOOR)) {
 		if (_globals[kStorageDoorOpen])
 			_vm->_dialogs->show(40621);
 		else
 			_vm->_dialogs->show(40620);
-	} else if (_action.isAction(VERB_LOOK, 0xE2))
+	} else if (_action.isAction(VERB_LOOK, NOUN_MONITOR))
 		_vm->_dialogs->show(40623);
-	else if (_action.isAction(VERB_LOOK, 0x47A))
+	else if (_action.isAction(VERB_LOOK, NOUN_SIGNPOST))
 		_vm->_dialogs->show(40624);
-	else if (_action.isAction(VERB_TAKE, 0x47A))
+	else if (_action.isAction(VERB_TAKE, NOUN_SIGNPOST))
 		_vm->_dialogs->show(40625);
-	else if (_action.isAction(VERB_LOOK, 0x2F))
+	else if (_action.isAction(VERB_LOOK, NOUN_BOULDER))
 		_vm->_dialogs->show(40626);
-	else if (_action.isAction(VERB_TAKE, 0x2F))
+	else if (_action.isAction(VERB_TAKE, NOUN_BOULDER))
 		_vm->_dialogs->show(40627);
-	else if (_action.isAction(VERB_LOOK, 0x244))
+	else if (_action.isAction(VERB_LOOK, NOUN_SIGN))
 		_vm->_dialogs->show(40628);
-	else if (_action.isAction(VERB_TAKE, 0x244))
+	else if (_action.isAction(VERB_TAKE, NOUN_SIGN))
 		_vm->_dialogs->show(40629);
 	else
 		return;
@@ -2771,10 +2771,10 @@ void Scene407::preActions() {
 	if (_action.isAction(VERB_TAKE))
 		_game._player._needToWalk = false;
 
-	if (_action.isAction(VERB_LOOK, 0x6E))
+	if (_action.isAction(VERB_LOOK, NOUN_DOOR))
 		_game._player._needToWalk = true;
 
-	if (_action.isAction(VERB_WALK_DOWN, 0x2B4)) {
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_NORTH)) {
 		_game._player.walk(Common::Point(172, 91), FACING_NORTH);
 		_fromNorth = false;
 	}
@@ -2813,20 +2813,20 @@ void Scene407::actions() {
 		}
 	}
 
-	if (_action.isAction(VERB_WALK_DOWN, 0x2B3) && !_fromNorth)
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_SOUTH) && !_fromNorth)
 		_scene->_nextSceneId = 406;
-	else if (_action.isAction(VERB_WALK_DOWN, 0x2B4))
+	else if (_action.isAction(VERB_WALK_DOWN, NOUN_CORRIDOR_TO_NORTH))
 		_scene->_nextSceneId = 318;
-	else if (_action.isAction(VERB_LOOK, 0x1F3)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_SCANNER)) {
 		if (_globals[kHasBeenScanned])
 			_vm->_dialogs->show(40711);
 		else
 			_vm->_dialogs->show(40710);
-	} else if (_action.isAction(VERB_LOOK, 0x6E))
+	} else if (_action.isAction(VERB_LOOK, NOUN_DOOR))
 		_vm->_dialogs->show(40712);
-	else if (_action.isAction(VERB_LOOK, 0x2B3))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_SOUTH))
 		_vm->_dialogs->show(40713);
-	else if (_action.isAction(VERB_LOOK, 0x2B4))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_NORTH))
 		_vm->_dialogs->show(40714);
 	else if (_action._lookFlag)
 		_vm->_dialogs->show(40715);
@@ -2870,18 +2870,18 @@ void Scene408::enter() {
 }
 
 void Scene408::preActions() {
-	if ((_action.isAction(VERB_TAKE) && !_action.isAction(0x167)) || _action.isAction(VERB_PULL, 0x47B) || _action.isAction(VERB_OPEN, 0x265))
+	if ((_action.isAction(VERB_TAKE) && !_action.isAction(0x167)) || _action.isAction(VERB_PULL, NOUN_PIN) || _action.isAction(VERB_OPEN, NOUN_CARTON))
 		_game._player._needToWalk = false;
 
-	if ((_action.isAction(VERB_LOOK, 0x167) && _game._objects.isInRoom(0x17)) || _action.isAction(VERB_LOOK, 0x263))
+	if ((_action.isAction(VERB_LOOK, NOUN_TARGET_MODULE) && _game._objects.isInRoom(0x17)) || _action.isAction(VERB_LOOK, NOUN_CHEST))
 		_game._player._needToWalk = true;
 }
 
 void Scene408::actions() {
-	if (_action.isAction(VERB_WALK_INTO, 0x2B3)) {
+	if (_action.isAction(VERB_WALK_INTO, NOUN_CORRIDOR_TO_SOUTH)) {
 		_scene->_nextSceneId = 405;
 		_vm->_sound->command(58);
-	} else if (_action.isAction(VERB_TAKE, 0x167) && (_game._objects.isInRoom(OBJ_TARGET_MODULE) || _game._trigger)) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_TARGET_MODULE) && (_game._objects.isInRoom(OBJ_TARGET_MODULE) || _game._trigger)) {
 		switch (_game._trigger) {
 		case (0):
 			_vm->_sound->command(57);
@@ -2913,84 +2913,84 @@ void Scene408::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x2BC))
+	} else if (_action.isAction(VERB_LOOK, NOUN_ARMORED_VEHICLE))
 		_vm->_dialogs->show(40810);
-	else if (_action.isAction(VERB_TAKE, 0x2BC) || _action.isAction(VERB_TAKE, 0x261) || _action.isAction(VERB_TAKE, 0x25F))
+	else if (_action.isAction(VERB_TAKE, NOUN_ARMORED_VEHICLE) || _action.isAction(VERB_TAKE, NOUN_ANVIL) || _action.isAction(VERB_TAKE, NOUN_TWO_TON_WEIGHT))
 		_vm->_dialogs->show(40811);
-	else if (_action.isAction(VERB_LOOK, 0x2BE))
+	else if (_action.isAction(VERB_LOOK, NOUN_MISSILE))
 		_vm->_dialogs->show(40812);
-	else if (_action.isAction(VERB_TAKE, 0x2BE))
+	else if (_action.isAction(VERB_TAKE, NOUN_MISSILE))
 		_vm->_dialogs->show(40813);
-	else if (_action.isAction(VERB_LOOK, 0x2C2))
+	else if (_action.isAction(VERB_LOOK, NOUN_GRENADE))
 		_vm->_dialogs->show(40814);
-	else if (_action.isAction(VERB_TAKE, 0x2C2))
+	else if (_action.isAction(VERB_TAKE, NOUN_GRENADE))
 		_vm->_dialogs->show(40815);
-	else if (_action.isAction(VERB_TAKE, 0x47B) || _action.isAction(VERB_PULL, 0x47B))
+	else if (_action.isAction(VERB_TAKE, NOUN_PIN) || _action.isAction(VERB_PULL, NOUN_PIN))
 		_vm->_dialogs->show(40816);
-	else if (_action.isAction(VERB_LOOK, 0x26D))
+	else if (_action.isAction(VERB_LOOK, NOUN_BLIMP))
 		_vm->_dialogs->show(40817);
-	else if (_action.isAction(VERB_TAKE, 0x26D))
+	else if (_action.isAction(VERB_TAKE, NOUN_BLIMP))
 		_vm->_dialogs->show(40818);
-	else if (_action.isAction(VERB_LOOK, 0x2BB))
+	else if (_action.isAction(VERB_LOOK, NOUN_AMMUNITION))
 		_vm->_dialogs->show(40819);
-	else if (_action.isAction(VERB_TAKE, 0x2BB))
+	else if (_action.isAction(VERB_TAKE, NOUN_AMMUNITION))
 		_vm->_dialogs->show(40820);
-	else if (_action.isAction(VERB_LOOK, 0x269))
+	else if (_action.isAction(VERB_LOOK, NOUN_CATAPULT))
 		_vm->_dialogs->show(40821);
-	else if (_action.isAction(VERB_TAKE, 0x269))
+	else if (_action.isAction(VERB_TAKE, NOUN_CATAPULT))
 		_vm->_dialogs->show(40822);
-	else if (_action.isAction(VERB_LOOK, 0x263)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_CHEST)) {
 		if (_game._objects.isInRoom(OBJ_TARGET_MODULE))
 			_vm->_dialogs->show(40823);
 		else
 			_vm->_dialogs->show(40824);
-	} else if (_action.isAction(VERB_TAKE, 0x263))
+	} else if (_action.isAction(VERB_TAKE, NOUN_CHEST))
 		_vm->_dialogs->show(40825);
-	else if (_action.isAction(VERB_LOOK, 0x2BF))
+	else if (_action.isAction(VERB_LOOK, NOUN_SUIT_OF_ARMOR))
 		_vm->_dialogs->show(40826);
-	else if (_action.isAction(VERB_TAKE, 0x2BF))
+	else if (_action.isAction(VERB_TAKE, NOUN_SUIT_OF_ARMOR))
 		_vm->_dialogs->show(40827);
-	else if (_action.isAction(VERB_LOOK, 0x7B))
+	else if (_action.isAction(VERB_LOOK, NOUN_ESCAPE_HATCH))
 		_vm->_dialogs->show(40828);
-	else if (_action.isAction(VERB_OPEN, 0x7B) || _action.isAction(VERB_PULL, 0x7B))
+	else if (_action.isAction(VERB_OPEN, NOUN_ESCAPE_HATCH) || _action.isAction(VERB_PULL, NOUN_ESCAPE_HATCH))
 		_vm->_dialogs->show(40829);
-	else if (_action.isAction(VERB_LOOK, 0x26B))
+	else if (_action.isAction(VERB_LOOK, NOUN_BARRELS))
 		_vm->_dialogs->show(40830);
-	else if (_action.isAction(VERB_TAKE, 0x26B))
+	else if (_action.isAction(VERB_TAKE, NOUN_BARRELS))
 		_vm->_dialogs->show(40831);
-	else if (_action.isAction(VERB_LOOK, 0x2C1))
+	else if (_action.isAction(VERB_LOOK, NOUN_INFLATABLE_RAFT))
 		_vm->_dialogs->show(40832);
-	else if (_action.isAction(VERB_TAKE, 0x2C1))
+	else if (_action.isAction(VERB_TAKE, NOUN_INFLATABLE_RAFT))
 		_vm->_dialogs->show(40833);
-	else if (_action.isAction(VERB_LOOK, 0x2BD))
+	else if (_action.isAction(VERB_LOOK, NOUN_TOMATO))
 		_vm->_dialogs->show(40834);
-	else if (_action.isAction(VERB_TAKE, 0x2BD))
+	else if (_action.isAction(VERB_TAKE, NOUN_TOMATO))
 		_vm->_dialogs->show(40835);
-	else if (_action.isAction(VERB_LOOK, 0x261))
+	else if (_action.isAction(VERB_LOOK, NOUN_ANVIL))
 		_vm->_dialogs->show(40836);
-	else if (_action.isAction(VERB_LOOK, 0x25F))
+	else if (_action.isAction(VERB_LOOK, NOUN_TWO_TON_WEIGHT))
 		_vm->_dialogs->show(40837);
-	else if (_action.isAction(VERB_LOOK, 0x2C0))
+	else if (_action.isAction(VERB_LOOK, NOUN_POWDER_CONTAINER))
 		_vm->_dialogs->show(40838);
-	else if (_action.isAction(VERB_LOOK, 0x47C))
+	else if (_action.isAction(VERB_LOOK, NOUN_POWDER_PUFF))
 		_vm->_dialogs->show(40839);
-	else if (_action.isAction(VERB_TAKE, 0x47C))
+	else if (_action.isAction(VERB_TAKE, NOUN_POWDER_PUFF))
 		_vm->_dialogs->show(40840);
-	else if (_action.isAction(VERB_LOOK, 0x265))
+	else if (_action.isAction(VERB_LOOK, NOUN_CARTON))
 		_vm->_dialogs->show(40841);
-	else if (_action.isAction(VERB_TAKE, 0x265))
+	else if (_action.isAction(VERB_TAKE, NOUN_CARTON))
 		_vm->_dialogs->show(40842);
-	else if (_action.isAction(VERB_OPEN, 0x265))
+	else if (_action.isAction(VERB_OPEN, NOUN_CARTON))
 		_vm->_dialogs->show(40843);
-	else if (_action.isAction(VERB_LOOK, 0x2B3))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_SOUTH))
 		_vm->_dialogs->show(40844);
 	else if (_action._lookFlag)
 		_vm->_dialogs->show(40845);
-	else if (_action.isAction(VERB_LOOK, 0x167) && _game._objects.isInRoom(OBJ_TARGET_MODULE))
+	else if (_action.isAction(VERB_LOOK, NOUN_TARGET_MODULE) && _game._objects.isInRoom(OBJ_TARGET_MODULE))
 		_vm->_dialogs->show(40846);
-	else if (_action.isAction(VERB_LOOK, 0x26C))
+	else if (_action.isAction(VERB_LOOK, NOUN_LOADING_RAMP))
 		_vm->_dialogs->show(40848);
-	else if (_action.isAction(VERB_OPEN, 0x263))
+	else if (_action.isAction(VERB_OPEN, NOUN_CHEST))
 		_vm->_dialogs->show(40849);
 	else
 		return;
@@ -3028,24 +3028,24 @@ void Scene409::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x181))
+	if (_action.isAction(VERB_LOOK, NOUN_VIEWPORT))
 		_vm->_dialogs->show(40910);
-	else if (_action.isAction(VERB_PEER_THROUGH, 0x181))
+	else if (_action.isAction(VERB_PEER_THROUGH, NOUN_VIEWPORT))
 		_vm->_dialogs->show(40910);
-	else if (_action.isAction(VERB_LOOK, 0xC4))
+	else if (_action.isAction(VERB_LOOK, NOUN_KEYPAD))
 		_vm->_dialogs->show(40911);
-	else if (_action.isAction(VERB_INSPECT, 0xC4))
+	else if (_action.isAction(VERB_INSPECT, NOUN_KEYPAD))
 		_vm->_dialogs->show(40911);
-	else if (_action.isAction(VERB_LOOK, 0x1CC))
+	else if (_action.isAction(VERB_LOOK, NOUN_DISPLAY))
 		_vm->_dialogs->show(40912);
-	else if (_action.isAction(VERB_LOOK, 0x1D1) || _action.isAction(VERB_LOOK, 0x1D2)
-		|| _action.isAction(VERB_LOOK, 0x1D3) || _action.isAction(VERB_LOOK, 0x1D4)
-		|| _action.isAction(VERB_LOOK, 0x1D5) || _action.isAction(VERB_LOOK, 0x1D6)
-		|| _action.isAction(VERB_LOOK, 0x1D7) || _action.isAction(VERB_LOOK, 0x1D8)
-		|| _action.isAction(VERB_LOOK, 0x1D9) || _action.isAction(VERB_LOOK, 0x1D0)
-		|| _action.isAction(VERB_LOOK, 0x1DB) || _action.isAction(VERB_LOOK, 0x1DA))
+	else if (_action.isAction(VERB_LOOK, NOUN_1_KEY) || _action.isAction(VERB_LOOK, NOUN_2_KEY)
+		|| _action.isAction(VERB_LOOK, NOUN_3_KEY) || _action.isAction(VERB_LOOK, NOUN_4_KEY)
+		|| _action.isAction(VERB_LOOK, NOUN_5_KEY) || _action.isAction(VERB_LOOK, NOUN_6_KEY)
+		|| _action.isAction(VERB_LOOK, NOUN_7_KEY) || _action.isAction(VERB_LOOK, NOUN_8_KEY)
+		|| _action.isAction(VERB_LOOK, NOUN_9_KEY) || _action.isAction(VERB_LOOK, NOUN_0_KEY)
+		|| _action.isAction(VERB_LOOK, NOUN_SMILE_KEY) || _action.isAction(VERB_LOOK, NOUN_FROWN_KEY))
 		_vm->_dialogs->show(40913);
-	else if (_action.isAction(VERB_LOOK, 0x1CF))
+	else if (_action.isAction(VERB_LOOK, NOUN_DEVICE))
 		_vm->_dialogs->show(40914);
 	else if (_action._lookFlag)
 		_vm->_dialogs->show(40914);
@@ -3116,20 +3116,20 @@ void Scene410::preActions() {
 	if (_action.isAction(VERB_TAKE) && !_action.isAction(0x48))
 		_game._player._needToWalk = false;
 
-	if (_action.isAction(VERB_LOOK, 0x48) && _game._objects.isInRoom(OBJ_CHARGE_CASES))
+	if (_action.isAction(VERB_LOOK, NOUN_CHARGE_CASES) && _game._objects.isInRoom(OBJ_CHARGE_CASES))
 		_game._player._needToWalk = true;
 
-	if (_action.isAction(VERB_OPEN, 0x278) || _action.isAction(VERB_OPEN, 0x214))
+	if (_action.isAction(VERB_OPEN, NOUN_SACKS) || _action.isAction(VERB_OPEN, NOUN_SACK))
 		_game._player._needToWalk = false;
 
-	if (_action.isAction(VERB_LOOK, 0x272))
+	if (_action.isAction(VERB_LOOK, NOUN_CAN))
 		_game._player._needToWalk = true;
 }
 
 void Scene410::actions() {
-	if (_action.isAction(VERB_WALK_INTO, 0x2B3))
+	if (_action.isAction(VERB_WALK_INTO, NOUN_CORRIDOR_TO_SOUTH))
 		_scene->_nextSceneId = 406;
-	else if (_action.isAction(VERB_TAKE, 0x48) && (_game._objects.isInRoom(OBJ_CHARGE_CASES) || _game._trigger)) {
+	else if (_action.isAction(VERB_TAKE, NOUN_CHARGE_CASES) && (_game._objects.isInRoom(OBJ_CHARGE_CASES) || _game._trigger)) {
 		switch (_game._trigger) {
 		case (0):
 			_vm->_sound->command(57);
@@ -3162,52 +3162,52 @@ void Scene410::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x276))
+	} else if (_action.isAction(VERB_LOOK, NOUN_BARREL))
 		_vm->_dialogs->show(41010);
-	else if (_action.isAction(VERB_TAKE, 0x276))
+	else if (_action.isAction(VERB_TAKE, NOUN_BARREL))
 		_vm->_dialogs->show(41011);
-	else if (_action.isAction(VERB_OPEN, 0x276))
+	else if (_action.isAction(VERB_OPEN, NOUN_BARREL))
 		_vm->_dialogs->show(41012);
-	else if (_action.isAction(VERB_LOOK, 0x270))
+	else if (_action.isAction(VERB_LOOK, NOUN_RUG))
 		_vm->_dialogs->show(41013);
-	else if (_action.isAction(VERB_TAKE, 0x270))
+	else if (_action.isAction(VERB_TAKE, NOUN_RUG))
 		_vm->_dialogs->show(41014);
-	else if (_action.isAction(VERB_LOOK, 0x265) || _action.isAction(VERB_OPEN, 0x265)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_CARTON) || _action.isAction(VERB_OPEN, NOUN_CARTON)) {
 		if (_game._objects.isInRoom(OBJ_CHARGE_CASES))
 			_vm->_dialogs->show(41015);
 		else
 			_vm->_dialogs->show(41016);
-	} else if (_action.isAction(VERB_LOOK, 0x26E))
+	} else if (_action.isAction(VERB_LOOK, NOUN_FLOUR))
 		_vm->_dialogs->show(41017);
-	else if (_action.isAction(VERB_TAKE, 0x26E))
+	else if (_action.isAction(VERB_TAKE, NOUN_FLOUR))
 		_vm->_dialogs->show(41018);
-	else if (_action.isAction(VERB_LOOK, 0x278))
+	else if (_action.isAction(VERB_LOOK, NOUN_SACKS))
 		_vm->_dialogs->show(41019);
-	else if (_action.isAction(VERB_LOOK, 0x214))
+	else if (_action.isAction(VERB_LOOK, NOUN_SACK))
 		_vm->_dialogs->show(41019);
-	else if (_action.isAction(VERB_OPEN, 0x278))
+	else if (_action.isAction(VERB_OPEN, NOUN_SACKS))
 		_vm->_dialogs->show(41020);
-	else if (_action.isAction(VERB_OPEN, 0x214))
+	else if (_action.isAction(VERB_OPEN, NOUN_SACK))
 		_vm->_dialogs->show(41020);
-	else if (_action.isAction(VERB_LOOK, 0x277))
+	else if (_action.isAction(VERB_LOOK, NOUN_BUCKET_OF_TAR))
 		_vm->_dialogs->show(41021);
-	else if (_action.isAction(VERB_TAKE, 0x277))
+	else if (_action.isAction(VERB_TAKE, NOUN_BUCKET_OF_TAR))
 		_vm->_dialogs->show(41022);
-	else if (_action.isAction(VERB_LOOK, 0x272))
+	else if (_action.isAction(VERB_LOOK, NOUN_CAN))
 		_vm->_dialogs->show(41023);
-	else if (_action.isAction(VERB_TAKE, 0x272))
+	else if (_action.isAction(VERB_TAKE, NOUN_CAN))
 		_vm->_dialogs->show(41024);
-	else if (_action.isAction(VERB_LOOK, 0x48) && _game._objects.isInRoom(OBJ_CHARGE_CASES))
+	else if (_action.isAction(VERB_LOOK, NOUN_CHARGE_CASES) && _game._objects.isInRoom(OBJ_CHARGE_CASES))
 		_vm->_dialogs->show(41025);
-	else if (_action.isAction(VERB_LOOK, 0x2C3))
+	else if (_action.isAction(VERB_LOOK, NOUN_FENCE))
 		_vm->_dialogs->show(41027);
-	else if (_action.isAction(VERB_LOOK, 0x47D))
+	else if (_action.isAction(VERB_LOOK, NOUN_SHELVES))
 		_vm->_dialogs->show(41028);
-	else if (_action.isAction(VERB_LOOK, 0x275))
+	else if (_action.isAction(VERB_LOOK, NOUN_RAT))
 		_vm->_dialogs->show(41029);
-	else if (_action.isAction(VERB_TAKE, 0x275))
+	else if (_action.isAction(VERB_TAKE, NOUN_RAT))
 		_vm->_dialogs->show(41030);
-	else if (_action.isAction(VERB_THROW, 0x275))
+	else if (_action.isAction(VERB_THROW, NOUN_RAT))
 		_vm->_dialogs->show(41031);
 	else if (_action._lookFlag)
 		_vm->_dialogs->show(41033);
@@ -3679,21 +3679,21 @@ void Scene411::step() {
 }
 
 void Scene411::preActions() {
-	if (_action.isAction(VERB_LOOK, 0x2D7) && (_game._objects.isInRoom(OBJ_PETROX)))
+	if (_action.isAction(VERB_LOOK, NOUN_PETROX) && (_game._objects.isInRoom(OBJ_PETROX)))
 		_game._player._needToWalk = true;
 
-	if (_action.isAction(VERB_LOOK, 0x3A9) && (_game._objects.isInRoom(OBJ_LECITHIN)))
+	if (_action.isAction(VERB_LOOK, NOUN_LECITHIN) && (_game._objects.isInRoom(OBJ_LECITHIN)))
 		_game._player._needToWalk = true;
 
-	if (_action.isAction(VERB_LOOK, 0x2D6) && (_game._objects.isInRoom(OBJ_FORMALDEHYDE)))
+	if (_action.isAction(VERB_LOOK, NOUN_FORMALDEHYDE) && (_game._objects.isInRoom(OBJ_FORMALDEHYDE)))
 		_game._player._needToWalk = true;
 
-	if (_action.isAction(VERB_LOOK, 0x3AB) || _action.isAction(VERB_LOOK, 0x30D) || _action.isAction(VERB_LOOK, 0x47F) ||
-		_action.isAction(VERB_LOOK, 0x24D) || _action.isAction(VERB_LOOK, 0x216) || _action.isAction(VERB_PUT, 0x216) ||
-		_action.isAction(VERB_LOOK, 0x284) || _action.isAction(VERB_LOOK, 0x285))
+	if (_action.isAction(VERB_LOOK, NOUN_EXPLOSIVES) || _action.isAction(VERB_LOOK, NOUN_KETTLE) || _action.isAction(VERB_LOOK, NOUN_MISHAP) ||
+		_action.isAction(VERB_LOOK, NOUN_ALCOVE) || _action.isAction(VERB_LOOK, NOUN_SINK) || _action.isAction(VERB_PUT, NOUN_SINK) ||
+		_action.isAction(VERB_LOOK, NOUN_EXPERIMENT) || _action.isAction(VERB_LOOK, NOUN_DRAWING_BOARD))
 		_game._player._needToWalk = true;
 
-	if (_action.isAction(VERB_PULL, 0x280) || _action.isAction(VERB_PUSH, 0x280))
+	if (_action.isAction(VERB_PULL, NOUN_KNIFE_SWITCH) || _action.isAction(VERB_PUSH, NOUN_KNIFE_SWITCH))
 		_game._player._needToWalk = false;
 }
 
@@ -3704,14 +3704,14 @@ void Scene411::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_WALK_INTO, 0x2B3)) {
+	if (_action.isAction(VERB_WALK_INTO, NOUN_CORRIDOR_TO_SOUTH)) {
 		_scene->_nextSceneId = 406;
 		_vm->_sound->command(10);
 		_action._inProgress = false;
 		return;
 	}
 
-	if ((_globals[kNextIngredient] >= 4) && (_action.isAction(VERB_TAKE, 0x3AB) || _action.isAction(VERB_PUT, 0x48, 0x3AB)) 
+	if ((_globals[kNextIngredient] >= 4) && (_action.isAction(VERB_TAKE, NOUN_EXPLOSIVES) || _action.isAction(VERB_PUT, NOUN_CHARGE_CASES, 0x3AB)) 
 			&& !_game._objects[OBJ_CHARGE_CASES].getQuality(3) 
 			&& _game._objects.isInInventory(OBJ_CHARGE_CASES)) {
 		switch (_game._trigger) {
@@ -3759,13 +3759,13 @@ void Scene411::actions() {
 		}
 		_action._inProgress = false;
 		return;
-	} else if (!_game._objects.isInInventory(OBJ_CHARGE_CASES) && _action.isAction(VERB_TAKE, 0x3AB)) {
+	} else if (!_game._objects.isInInventory(OBJ_CHARGE_CASES) && _action.isAction(VERB_TAKE, NOUN_EXPLOSIVES)) {
 		_vm->_dialogs->show(41143);
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_TAKE, 0x2D7) && (_game._objects.isInRoom(OBJ_PETROX) || _game._trigger)) {
+	if (_action.isAction(VERB_TAKE, NOUN_PETROX) && (_game._objects.isInRoom(OBJ_PETROX) || _game._trigger)) {
 		switch (_game._trigger) {
 		case (0):
 			_vm->_sound->command(57);
@@ -3802,7 +3802,7 @@ void Scene411::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_TAKE, 0x3A9) && (_game._objects.isInRoom(OBJ_LECITHIN) || _game._trigger)) {
+	if (_action.isAction(VERB_TAKE, NOUN_LECITHIN) && (_game._objects.isInRoom(OBJ_LECITHIN) || _game._trigger)) {
 		switch (_game._trigger) {
 		case (0):
 			_vm->_sound->command(57);
@@ -3838,7 +3838,7 @@ void Scene411::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_TAKE, 0x2D6) && _game._objects.isInRoom(OBJ_FORMALDEHYDE) && (_game._trigger == 0)) {
+	if (_action.isAction(VERB_TAKE, NOUN_FORMALDEHYDE) && _game._objects.isInRoom(OBJ_FORMALDEHYDE) && (_game._trigger == 0)) {
 		_vm->_sound->command(57);
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
@@ -3862,7 +3862,7 @@ void Scene411::actions() {
 	if (_game._trigger == 10)
 		_vm->_dialogs->showItem(OBJ_FORMALDEHYDE, 41124);
 
-	if (_action.isAction(VERB_PUT, 0x30D)) {
+	if (_action.isAction(VERB_PUT, NOUN_KETTLE)) {
 		if (_action.isAction(0x2D7) || _action.isAction(0x2D6) || _action.isAction(0x3A9) || _action.isAction(0x306)) {
 			_newIngredient = _game._objects.getIdFromDesc(_action._activeAction._objectNameId);
 			switch (_newIngredient) {
@@ -3889,67 +3889,67 @@ void Scene411::actions() {
 	}
 
 
-	if (_action.isAction(VERB_LOOK, 0xE2))
+	if (_action.isAction(VERB_LOOK, NOUN_MONITOR))
 		_vm->_dialogs->show(41110);
-	else if (_action.isAction(VERB_LOOK, 0x287))
+	else if (_action.isAction(VERB_LOOK, NOUN_AIR_PURIFIER))
 		_vm->_dialogs->show(41111);
-	else if (_action.isAction(VERB_LOOK, 0x27B))
+	else if (_action.isAction(VERB_LOOK, NOUN_LAB_EQUIPMENT))
 		_vm->_dialogs->show(41112);
-	else if (_action.isAction(VERB_LOOK, 0x280))
+	else if (_action.isAction(VERB_LOOK, NOUN_KNIFE_SWITCH))
 		_vm->_dialogs->show(41113);
-	else if (_action.isAction(VERB_PUSH, 0x280) || _action.isAction(VERB_PULL, 0x280))
+	else if (_action.isAction(VERB_PUSH, NOUN_KNIFE_SWITCH) || _action.isAction(VERB_PULL, NOUN_KNIFE_SWITCH))
 		_vm->_dialogs->show(41114);
-	else if (_action.isAction(VERB_LOOK, 0x283))
+	else if (_action.isAction(VERB_LOOK, NOUN_TOXIC_WASTE))
 		_vm->_dialogs->show(41115);
-	else if (_action.isAction(VERB_TAKE, 0x283))
+	else if (_action.isAction(VERB_TAKE, NOUN_TOXIC_WASTE))
 		_vm->_dialogs->show(41116);
-	else if (_action.isAction(VERB_LOOK, 0x285))
+	else if (_action.isAction(VERB_LOOK, NOUN_DRAWING_BOARD))
 		_vm->_dialogs->show(41117);
-	else if (_action.isAction(VERB_LOOK, 0x284))
+	else if (_action.isAction(VERB_LOOK, NOUN_EXPERIMENT))
 		_vm->_dialogs->show(41118);
-	else if (_action.isAction(VERB_LOOK, 0x2D7) && _game._objects.isInRoom(OBJ_PETROX))
+	else if (_action.isAction(VERB_LOOK, NOUN_PETROX) && _game._objects.isInRoom(OBJ_PETROX))
 		_vm->_dialogs->show(41119);
-	else if (_action.isAction(VERB_LOOK, 0x24D))
+	else if (_action.isAction(VERB_LOOK, NOUN_ALCOVE))
 		_vm->_dialogs->show(41121);
-	else if ((_action.isAction(VERB_LOOK, 0x2D6)) && (_game._objects.isInRoom(OBJ_FORMALDEHYDE)))
+	else if ((_action.isAction(VERB_LOOK, NOUN_FORMALDEHYDE)) && (_game._objects.isInRoom(OBJ_FORMALDEHYDE)))
 		_vm->_dialogs->show(41122);
-	else if ((_action.isAction(VERB_LOOK, 0x3A9)) && (_game._objects.isInRoom(OBJ_LECITHIN)))
+	else if ((_action.isAction(VERB_LOOK, NOUN_LECITHIN)) && (_game._objects.isInRoom(OBJ_LECITHIN)))
 		_vm->_dialogs->show(41123);
-	else if (_action.isAction(VERB_LOOK, 0x30D)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_KETTLE)) {
 		if (_globals[kNextIngredient] > 0 && !_game._objects[OBJ_CHARGE_CASES].getQuality(3)) {
 			_vm->_dialogs->show(41126);
 		} else if (_globals[kNextIngredient] == 0 || _game._objects[OBJ_CHARGE_CASES].getQuality(3)) {
 			_vm->_dialogs->show(41125);
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x3AB) && _game._objects[OBJ_CHARGE_CASES].getQuality(3) == 0) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_EXPLOSIVES) && _game._objects[OBJ_CHARGE_CASES].getQuality(3) == 0) {
 		_vm->_dialogs->show(41127);
-	} else if (_action.isAction(VERB_TAKE, 0x30D))
+	} else if (_action.isAction(VERB_TAKE, NOUN_KETTLE))
 		_vm->_dialogs->show(41128);
-	else if (_action.isAction(VERB_LOOK, 0x59))
+	else if (_action.isAction(VERB_LOOK, NOUN_CONTROL_PANEL))
 		_vm->_dialogs->show(41129);
-	else if (_action.isAction(VERB_LOOK, 0x47F))
+	else if (_action.isAction(VERB_LOOK, NOUN_MISHAP))
 		_vm->_dialogs->show(41130);
-	else if (_action.isAction(VERB_LOOK, 0x2B3))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_SOUTH))
 		_vm->_dialogs->show(41131);
 	else if (_action._lookFlag)
 		_vm->_dialogs->show(41132);
-	else if (_action.isAction(VERB_LOOK, 0x27C))
+	else if (_action.isAction(VERB_LOOK, NOUN_AIR_HORN))
 		_vm->_dialogs->show(41133);
-	else if (_action.isAction(VERB_LOOK, 0x218))
+	else if (_action.isAction(VERB_LOOK, NOUN_DEBRIS))
 		_vm->_dialogs->show(41134);
-	else if (_action.isAction(VERB_LOOK, 0x282))
+	else if (_action.isAction(VERB_LOOK, NOUN_HEATER))
 		_vm->_dialogs->show(41135);
-	else if (_action.isAction(VERB_LOOK, 0x10C))
+	else if (_action.isAction(VERB_LOOK, NOUN_PIPE))
 		_vm->_dialogs->show(41136);
-	else if (_action.isAction(VERB_LOOK, 0x216))
+	else if (_action.isAction(VERB_LOOK, NOUN_SINK))
 		_vm->_dialogs->show(41137);
-	else if (_action.isAction(VERB_PUT, 0x216))
+	else if (_action.isAction(VERB_PUT, NOUN_SINK))
 		_vm->_dialogs->show(41138);
-	else if (_action.isAction(VERB_TAKE, 0x284))
+	else if (_action.isAction(VERB_TAKE, NOUN_EXPERIMENT))
 		_vm->_dialogs->show(41139);
-	else if (_action.isAction(VERB_LOOK, 0x47E))
+	else if (_action.isAction(VERB_LOOK, NOUN_ELECTRODES))
 		_vm->_dialogs->show(41140);
-	else if (_action.isAction(VERB_TAKE, 0x47E))
+	else if (_action.isAction(VERB_TAKE, NOUN_ELECTRODES))
 		_vm->_dialogs->show(41141);
 	else
 		return;
@@ -4076,41 +4076,41 @@ void Scene413::step() {
 }
 
 void Scene413::preActions() {
-	if (_action.isAction(VERB_TAKE) || _action.isAction(VERB_PUT, 0x319))
+	if (_action.isAction(VERB_TAKE) || _action.isAction(VERB_PUT, NOUN_CONVEYOR_BELT))
 		_game._player._needToWalk = false;
 
-	if (_action.isAction(VERB_LOOK, 0x2C4) || _action.isAction(VERB_LOOK, 0x1CC)
-	 || _action.isAction(VERB_LOOK, 0x289) || _action.isAction(VERB_LOOK, 0x10E)) {
+	if (_action.isAction(VERB_LOOK, NOUN_WOODEN_STATUE) || _action.isAction(VERB_LOOK, NOUN_DISPLAY)
+	 || _action.isAction(VERB_LOOK, NOUN_PICTURE) || _action.isAction(VERB_LOOK, NOUN_PLANT)) {
 		_game._player._needToWalk = true;
 	}
 }
 
 void Scene413::actions() {
-	if (_action.isAction(VERB_WALK_INSIDE, 0x16C)) {
+	if (_action.isAction(VERB_WALK_INSIDE, NOUN_TELEPORTER)) {
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
 		_scene->_nextSceneId = 409;
-	} else if (_action.isAction(VERB_WALK_INSIDE, 0x2B3))
+	} else if (_action.isAction(VERB_WALK_INSIDE, NOUN_CORRIDOR_TO_SOUTH))
 		_scene->_nextSceneId = 405;
-	else if (_action.isAction(VERB_LOOK, 0x2C4))
+	else if (_action.isAction(VERB_LOOK, NOUN_WOODEN_STATUE))
 		_vm->_dialogs->show(41310);
-	else if (_action.isAction(VERB_TAKE, 0x2C4))
+	else if (_action.isAction(VERB_TAKE, NOUN_WOODEN_STATUE))
 		_vm->_dialogs->show(41311);
-	else if (_action.isAction(VERB_LOOK, 0x319))
+	else if (_action.isAction(VERB_LOOK, NOUN_CONVEYOR_BELT))
 		_vm->_dialogs->show(41312);
-	else if (_action.isAction(VERB_PUT, 0x319))
+	else if (_action.isAction(VERB_PUT, NOUN_CONVEYOR_BELT))
 		_vm->_dialogs->show(41313);
-	else if (_action.isAction(VERB_LOOK, 0x16C))
+	else if (_action.isAction(VERB_LOOK, NOUN_TELEPORTER))
 		_vm->_dialogs->show(41314);
-	else if (_action.isAction(VERB_LOOK, 0x1CC))
+	else if (_action.isAction(VERB_LOOK, NOUN_DISPLAY))
 		_vm->_dialogs->show(41315);
-	else if (_action.isAction(VERB_LOOK, 0x2B3))
+	else if (_action.isAction(VERB_LOOK, NOUN_CORRIDOR_TO_SOUTH))
 		_vm->_dialogs->show(41316);
-	else if (_action.isAction(VERB_LOOK, 0x289))
+	else if (_action.isAction(VERB_LOOK, NOUN_PICTURE))
 		_vm->_dialogs->show(41317);
-	else if (_action.isAction(VERB_LOOK, 0x10E))
+	else if (_action.isAction(VERB_LOOK, NOUN_PLANT))
 		_vm->_dialogs->show(41318);
-	else if (_action.isAction(VERB_TAKE, 0x10E))
+	else if (_action.isAction(VERB_TAKE, NOUN_PLANT))
 		_vm->_dialogs->show(41319);
 	else if (_action._lookFlag)
 		_vm->_dialogs->show(41320);
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index ef50e12..02dc90d 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -279,7 +279,7 @@ void Scene501::preActions() {
 }
 
 void Scene501::actions() {
-	if (_action.isAction(VERB_GET_INTO, 0x324)) {
+	if (_action.isAction(VERB_GET_INTO, NOUN_CAR)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -326,9 +326,9 @@ void Scene501::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_PUT, 0x131, 0x251))
+	} else if (_action.isAction(VERB_PUT, NOUN_SECURITY_CARD, 0x251))
 		_vm->_dialogs->show(50113);
-	else if (_action.isAction(VERB_PUT, 0x305, 0x251)) {
+	else if (_action.isAction(VERB_PUT, NOUN_FAKE_ID, 0x251)) {
 		switch (_game._trigger) {
 		case 0:
 		case 1:
@@ -372,7 +372,7 @@ void Scene501::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_PUT, 0xB3, 0x251)) {
+	} else if (_action.isAction(VERB_PUT, NOUN_ID_CARD, 0x251)) {
 		switch (_game._trigger) {
 		case 0:
 		case 1:
@@ -417,34 +417,34 @@ void Scene501::actions() {
 		default:
 			break;
 		}
-	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x31E))
+	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, NOUN_STREET))
 		_vm->_dialogs->show(50121);
-	else if (_action.isAction(VERB_LOOK, 0x6E))
+	else if (_action.isAction(VERB_LOOK, NOUN_DOOR))
 		_vm->_dialogs->show(50110);
-	else if (_action.isAction(VERB_LOOK, 0x251))
+	else if (_action.isAction(VERB_LOOK, NOUN_CARD_SLOT))
 		_vm->_dialogs->show(50112);
-	else if (_action.isAction(VERB_LOOK, 0x244))
+	else if (_action.isAction(VERB_LOOK, NOUN_SIGN))
 		_vm->_dialogs->show(50114);
-	else if (_action.isAction(VERB_TAKE, 0x244))
+	else if (_action.isAction(VERB_TAKE, NOUN_SIGN))
 		_vm->_dialogs->show(50115);
-	else if (_action.isAction(VERB_LOOK, 0x322))
+	else if (_action.isAction(VERB_LOOK, NOUN_SIDEWALK_TO_EAST))
 		_vm->_dialogs->show(50118);
-	else if (_action.isAction(VERB_LOOK, 0x361) || _action.isAction(VERB_LOOK, 0x360)
-		|| _action.isAction(VERB_WALK_DOWN, 0x361) || _action.isAction(VERB_WALK_DOWN, 0x360))
+	else if (_action.isAction(VERB_LOOK, NOUN_SIDEWALK_TO_WEST) || _action.isAction(VERB_LOOK, NOUN_STREET_TO_WEST)
+		|| _action.isAction(VERB_WALK_DOWN, NOUN_SIDEWALK_TO_WEST) || _action.isAction(VERB_WALK_DOWN, NOUN_STREET_TO_WEST))
 		_vm->_dialogs->show(50119);
-	else if (_action.isAction(VERB_LOOK, 0x323))
+	else if (_action.isAction(VERB_LOOK, NOUN_BUILDING))
 		_vm->_dialogs->show(50120);
-	else if (_action.isAction(VERB_OPEN, 0x6E))
+	else if (_action.isAction(VERB_OPEN, NOUN_DOOR))
 		_vm->_dialogs->show(50122);
-	else if (_action.isAction(VERB_LOOK, 0x1E6))
+	else if (_action.isAction(VERB_LOOK, NOUN_FIRE_HYDRANT))
 		_vm->_dialogs->show(50123);
-	else if (_action.isAction(VERB_OPEN, 0x1E6))
+	else if (_action.isAction(VERB_OPEN, NOUN_FIRE_HYDRANT))
 		_vm->_dialogs->show(50124);
-	else if (_action.isAction(VERB_LOOK, 0x369))
+	else if (_action.isAction(VERB_LOOK, NOUN_EQUIPMENT_OVERHEAD))
 		_vm->_dialogs->show(50125);
-	else if (_action.isAction(VERB_LOOK, 0x1FA) || _action.isAction(VERB_LOOK, 0x10C))
+	else if (_action.isAction(VERB_LOOK, NOUN_PIPES) || _action.isAction(VERB_LOOK, NOUN_PIPE))
 		_vm->_dialogs->show(50126);
-	else if (_action.isAction(VERB_LOOK, 0x324)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_CAR)) {
 		if (!_game._visitedScenes.exists(504))
 			_vm->_dialogs->show(50116);
 		else
@@ -490,21 +490,21 @@ void Scene502::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x181) || _action.isAction(VERB_PEER_THROUGH, 0x181))
+	if (_action.isAction(VERB_LOOK, NOUN_VIEWPORT) || _action.isAction(VERB_PEER_THROUGH, NOUN_VIEWPORT))
 		_vm->_dialogs->show(50210);
-	else if (_action.isAction(VERB_LOOK, 0xC4))
+	else if (_action.isAction(VERB_LOOK, NOUN_KEYPAD))
 		_vm->_dialogs->show(50211);
-	else if (_action.isAction(VERB_LOOK, 0x1CC))
+	else if (_action.isAction(VERB_LOOK, NOUN_DISPLAY))
 		_vm->_dialogs->show(50212);
-	else if (_action.isAction(VERB_LOOK, 0x1D0) || _action.isAction(VERB_LOOK, 0x1D1)
-	 || _action.isAction(VERB_LOOK, 0x1D2) || _action.isAction(VERB_LOOK, 0x1D3)
-	 || _action.isAction(VERB_LOOK, 0x1D4) || _action.isAction(VERB_LOOK, 0x1D5)
-	 || _action.isAction(VERB_LOOK, 0x1D6) || _action.isAction(VERB_LOOK, 0x1D7)
-	 || _action.isAction(VERB_LOOK, 0x1D8) || _action.isAction(VERB_LOOK, 0x1D9)
-	 || _action.isAction(VERB_LOOK, 0x1DB) || _action.isAction(VERB_LOOK, 0x7A)
-	 || _action.isAction(VERB_LOOK, 0x1DA))
+	else if (_action.isAction(VERB_LOOK, NOUN_0_KEY) || _action.isAction(VERB_LOOK, NOUN_1_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_2_KEY) || _action.isAction(VERB_LOOK, NOUN_3_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_4_KEY) || _action.isAction(VERB_LOOK, NOUN_5_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_6_KEY) || _action.isAction(VERB_LOOK, NOUN_7_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_8_KEY) || _action.isAction(VERB_LOOK, NOUN_9_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_SMILE_KEY) || _action.isAction(VERB_LOOK, NOUN_ENTER_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_FROWN_KEY))
 		_vm->_dialogs->show(50213);
-	else if (_action.isAction(VERB_LOOK, 0x1CF) || _action._lookFlag)
+	else if (_action.isAction(VERB_LOOK, NOUN_DEVICE) || _action._lookFlag)
 		_vm->_dialogs->show(50214);
 	else
 		return;
@@ -544,9 +544,9 @@ void Scene503::enter() {
 }
 
 void Scene503::actions() {
-	if (_action.isAction(VERB_WALK, 0xF9))
+	if (_action.isAction(VERB_WALK, NOUN_OUTSIDE))
 		_scene->_nextSceneId = 501;
-	else if (_action.isAction(VERB_TAKE, 0x6A)) {
+	else if (_action.isAction(VERB_TAKE, NOUN_DETONATORS)) {
 		if ( _game._trigger || !_game._objects.isInInventory(OBJ_DETONATORS)) {
 			switch (_game._trigger) {
 			case 0:
@@ -591,42 +591,42 @@ void Scene503::actions() {
 		}
 	} else if (_action._lookFlag)
 		_vm->_dialogs->show(50328);
-	else if (_action.isAction(VERB_LOOK, 0x36F))
+	else if (_action.isAction(VERB_LOOK, NOUN_MONITORING_EQUIPMENT))
 		_vm->_dialogs->show(50310);
-	else if (_action.isAction(VERB_LOOK, 0x36E))
+	else if (_action.isAction(VERB_LOOK, NOUN_PHOTON_RIFLES))
 		_vm->_dialogs->show(50311);
-	else if (_action.isAction(VERB_TAKE, 0x36E) || _action.isAction(VERB_TAKE, 0x36C))
+	else if (_action.isAction(VERB_TAKE, NOUN_PHOTON_RIFLES) || _action.isAction(VERB_TAKE, NOUN_NUCLEAR_SLINGSHOT))
 		_vm->_dialogs->show(50312);
-	else if (_action.isAction(VERB_LOOK, 0x36D))
+	else if (_action.isAction(VERB_LOOK, NOUN_DISPLAY_CASE))
 		_vm->_dialogs->show(50313);
-	else if (_action.isAction(VERB_LOOK, 0x36C))
+	else if (_action.isAction(VERB_LOOK, NOUN_NUCLEAR_SLINGSHOT))
 		_vm->_dialogs->show(50314);
-	else if (_action.isAction(VERB_LOOK, 0x331))
+	else if (_action.isAction(VERB_LOOK, NOUN_WATER_COOLER))
 		_vm->_dialogs->show(50315);
-	else if (_action.isAction(VERB_LOOK, 0x330))
+	else if (_action.isAction(VERB_LOOK, NOUN_STORAGE_BOX))
 		_vm->_dialogs->show(50316);
-	else if (_action.isAction(VERB_OPEN, 0x330))
+	else if (_action.isAction(VERB_OPEN, NOUN_STORAGE_BOX))
 		_vm->_dialogs->show(50317);
-	else if (_action.isAction(VERB_LOOK, 0x36B))
+	else if (_action.isAction(VERB_LOOK, NOUN_WARNING_LABEL))
 		_vm->_dialogs->show(50318);
-	else if (_action.isAction(VERB_LOOK, 0x1E4))
+	else if (_action.isAction(VERB_LOOK, NOUN_DESK))
 		_vm->_dialogs->show(50319);
-	else if (_action.isAction(VERB_LOOK, 0xE2))
+	else if (_action.isAction(VERB_LOOK, NOUN_MONITOR))
 		_vm->_dialogs->show(50320);
-	else if (_action.isAction(VERB_LOOK, 0x481))
+	else if (_action.isAction(VERB_LOOK, NOUN_FILE_CABINETS))
 		_vm->_dialogs->show(50322);
-	else if (_action.isAction(VERB_LOOK, 0x332)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_BOX)) {
 		if (_game._objects.isInRoom(OBJ_DETONATORS))
 			_vm->_dialogs->show(50323);
 		else
 			_vm->_dialogs->show(50324);
-	} else if (_action.isAction(VERB_LOOK, 0x6A) && (_action._savedFields._mainObjectSource == 4))
+	} else if (_action.isAction(VERB_LOOK, NOUN_DETONATORS) && (_action._savedFields._mainObjectSource == 4))
 		_vm->_dialogs->show(50325);
-	else if (_action.isAction(VERB_LOOK, 0x32E))
+	else if (_action.isAction(VERB_LOOK, NOUN_WINDOWS))
 		_vm->_dialogs->show(50327);
-	else if (_action.isAction(VERB_OPEN, 0x36D))
+	else if (_action.isAction(VERB_OPEN, NOUN_DISPLAY_CASE))
 		_vm->_dialogs->show(50329);
-	else if (_action.isAction(VERB_THROW, 0x36D) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId)))
+	else if (_action.isAction(VERB_THROW, NOUN_DISPLAY_CASE) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId)))
 		_vm->_dialogs->show(50330);
 	else
 		return;
@@ -742,10 +742,10 @@ void Scene504::preActions() {
 }
 
 void Scene504::actions() {
-	if (_action.isAction(VERB_EXIT_FROM, 0x324)) {
+	if (_action.isAction(VERB_EXIT_FROM, NOUN_CAR)) {
 		_vm->_sound->command(15);
 		_scene->_nextSceneId = _globals[kHoverCarLocation];
-	} else if (_action.isAction(VERB_ACTIVATE, 0x380)) {
+	} else if (_action.isAction(VERB_ACTIVATE, NOUN_CAR_CONTROLS)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -803,27 +803,27 @@ void Scene504::actions() {
 		default:
 			break;
 		}
-	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x388))
+	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, NOUN_INTERIOR_OF_CAR))
 		_vm->_dialogs->show(50412);
-	else if (_action.isAction(VERB_LOOK, 0x383))
+	else if (_action.isAction(VERB_LOOK, NOUN_GLOVE_COMPARTMENT))
 		_vm->_dialogs->show(50410);
-	else if (_action.isAction(VERB_LOOK, 0x380) || _action.isAction(VERB_LOOK, 0x387))
+	else if (_action.isAction(VERB_LOOK, NOUN_CAR_CONTROLS) || _action.isAction(VERB_LOOK, NOUN_DASHBOARD))
 		_vm->_dialogs->show(50411);
-	else if (_action.isAction(VERB_LOOK, 0x381))
+	else if (_action.isAction(VERB_LOOK, NOUN_SCENT_PACKET))
 		_vm->_dialogs->show(50413);
-	else if (_action.isAction(VERB_LOOK, 0x385))
+	else if (_action.isAction(VERB_LOOK, NOUN_SODA_CANS))
 		_vm->_dialogs->show(50414);
-	else if (_action.isAction(VERB_LOOK, 0x382))
+	else if (_action.isAction(VERB_LOOK, NOUN_KITTY))
 		_vm->_dialogs->show(50415);
-	else if (_action.isAction(VERB_LOOK, 0x386) || _action.isAction(VERB_LOOK_THROUGH, 0x386))
+	else if (_action.isAction(VERB_LOOK, NOUN_WINDSHIELD) || _action.isAction(VERB_LOOK_THROUGH, NOUN_WINDSHIELD))
 		_vm->_dialogs->show(50416);
-	else if (_action.isAction(VERB_LOOK, 0x120))
+	else if (_action.isAction(VERB_LOOK, NOUN_REARVIEW_MIRROR))
 		_vm->_dialogs->show(50417);
-	else if (_action.isAction(VERB_TAKE, 0x120))
+	else if (_action.isAction(VERB_TAKE, NOUN_REARVIEW_MIRROR))
 		_vm->_dialogs->show(50418);
-	else if (_action.isAction(VERB_LOOK, 0x384))
+	else if (_action.isAction(VERB_LOOK, NOUN_MOLDY_SOCK))
 		_vm->_dialogs->show(50419);
-	else if (_action.isAction(VERB_TAKE, 0x384))
+	else if (_action.isAction(VERB_TAKE, NOUN_MOLDY_SOCK))
 		_vm->_dialogs->show(50420);
 	else
 		return;
@@ -1073,11 +1073,11 @@ void Scene505::step() {
 void Scene505::actions() {
 	if (_action.isAction(VERB_PRESS))
 		_nextButtonId = _action._activeAction._objectNameId;
-	else if (_action.isAction(VERB_RETURN_TO, 0x38C))
+	else if (_action.isAction(VERB_RETURN_TO, NOUN_INSIDE_OF_CAR))
 		_scene->_nextSceneId = 504;
-	else if (_action.isAction(VERB_LOOK, 0x180))
+	else if (_action.isAction(VERB_LOOK, NOUN_VIEW_SCREEN))
 		_vm->_dialogs->show(50510);
-	else if (_action.isAction(VERB_LOOK, 0x59))
+	else if (_action.isAction(VERB_LOOK, NOUN_CONTROL_PANEL))
 		_vm->_dialogs->show(50511);
 	else
 		return;
@@ -1186,7 +1186,7 @@ void Scene506::room_506_door_sequences() {
 	_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 
 	if (_firstDoorFl) {
-		if (_action.isAction(VERB_WALK_INTO, 0x336) || ((_scene->_priorSceneId == 507) && !_actionFl)) {
+		if (_action.isAction(VERB_WALK_INTO, NOUN_SOFTWARE_STORE) || ((_scene->_priorSceneId == 507) && !_actionFl)) {
 			_doorDepth = 13;
 			_doorSpriteIdx = _globals._spriteIndexes[2];
 			_doorSequenceIdx = _globals._sequenceIndexes[2];
@@ -1266,21 +1266,21 @@ void Scene506::room_506_door_sequences() {
 }
 
 void Scene506::actions() {
-	if (_action.isAction(VERB_WALK_INTO, 0x37D)) {
+	if (_action.isAction(VERB_WALK_INTO, NOUN_LABORATORY)) {
 		if (_firstDoorFl) {
 			_heroFacing = FACING_NORTHWEST;
 			_doorPos = Common::Point(16, 111);
 		}
 		_actionFl = true;
 		room_506_door_sequences();
-	} else if (_action.isAction(VERB_WALK_INTO, 0x336)) {
+	} else if (_action.isAction(VERB_WALK_INTO, NOUN_SOFTWARE_STORE)) {
 		if (_firstDoorFl) {
 			_heroFacing = FACING_NORTHWEST;
 			_doorPos = Common::Point(80, 102);
 		}
 		_actionFl = true;
 		room_506_door_sequences();
-	} else if (_action.isAction(VERB_GET_INTO, 0x324)) {
+	} else if (_action.isAction(VERB_GET_INTO, NOUN_CAR)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1317,29 +1317,29 @@ void Scene506::actions() {
 		default:
 			break;
 		}
-	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x31E))
+	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, NOUN_STREET))
 		_vm->_dialogs->show(50618);
-	else if (_action.isAction(VERB_LOOK, 0x372))
+	else if (_action.isAction(VERB_LOOK, NOUN_RESTAURANT))
 		_vm->_dialogs->show(50610);
-	else if (_action.isAction(VERB_LOOK, 0x371))
+	else if (_action.isAction(VERB_LOOK, NOUN_MOTEL))
 		_vm->_dialogs->show(50611);
-	else if (_action.isAction(VERB_LOOK, 0x482))
+	else if (_action.isAction(VERB_LOOK, NOUN_CYCLE_SHOP))
 		_vm->_dialogs->show(50612);
-	else if (_action.isAction(VERB_LOOK, 0x483))
+	else if (_action.isAction(VERB_LOOK, NOUN_AIR_BIKE))
 		_vm->_dialogs->show(50613);
-	else if (_action.isAction(VERB_TAKE, 0x483))
+	else if (_action.isAction(VERB_TAKE, NOUN_AIR_BIKE))
 		_vm->_dialogs->show(50614);
-	else if (_action.isAction(VERB_LOOK, 0x336))
+	else if (_action.isAction(VERB_LOOK, NOUN_SOFTWARE_STORE))
 		_vm->_dialogs->show(50615);
-	else if (_action.isAction(VERB_LOOK, 0x37D))
+	else if (_action.isAction(VERB_LOOK, NOUN_LABORATORY))
 		_vm->_dialogs->show(50616);
-	else if (_action.isAction(VERB_LOOK, 0x360) || _action.isAction(VERB_WALK_DOWN, 0x360))
+	else if (_action.isAction(VERB_LOOK, NOUN_STREET_TO_WEST) || _action.isAction(VERB_WALK_DOWN, NOUN_STREET_TO_WEST))
 		_vm->_dialogs->show(50617);
-	else if (_action.isAction(VERB_LOOK, 0x373))
+	else if (_action.isAction(VERB_LOOK, NOUN_SOFTWARE_STORE_SIGN))
 		_vm->_dialogs->show(50619);
-	else if (_action.isAction(VERB_LOOK, 0x324))
+	else if (_action.isAction(VERB_LOOK, NOUN_CAR))
 		_vm->_dialogs->show(50620);
-	else if (_action.isAction(VERB_LOOK, 0x142))
+	else if (_action.isAction(VERB_LOOK, NOUN_SKY))
 		_vm->_dialogs->show(50621);
 	else
 		return;
@@ -1374,9 +1374,9 @@ void Scene507::enter() {
 	sceneEntrySound();
 }
 void Scene507::actions() {
-	if (_action.isAction(VERB_WALK_THROUGH, 0x378))
+	if (_action.isAction(VERB_WALK_THROUGH, NOUN_ENTRANCE))
 		_scene->_nextSceneId = 506;
-	else if (_action.isAction(VERB_TAKE, 0x106)) {
+	else if (_action.isAction(VERB_TAKE, NOUN_PENLIGHT)) {
 		if (_game._trigger || !_game._objects.isInInventory(OBJ_PENLIGHT)) {
 			switch (_game._trigger) {
 			case 0:
@@ -1409,48 +1409,48 @@ void Scene507::actions() {
 		}
 	} else if (_action._lookFlag)
 		_vm->_dialogs->show(50722);
-	else if (_action.isAction(VERB_LOOK, 0x299))
+	else if (_action.isAction(VERB_LOOK, NOUN_SWIRLING_LIGHT))
 		_vm->_dialogs->show(50710);
-	else if (_action.isAction(VERB_TAKE, 0x299))
+	else if (_action.isAction(VERB_TAKE, NOUN_SWIRLING_LIGHT))
 		_vm->_dialogs->show(50711);
-	else if (_action.isAction(VERB_LOOK, 0x376))
+	else if (_action.isAction(VERB_LOOK, NOUN_OLD_SOFTWARE))
 		_vm->_dialogs->show(50712);
-	else if (_action.isAction(VERB_TAKE, 0x376))
+	else if (_action.isAction(VERB_TAKE, NOUN_OLD_SOFTWARE))
 		_vm->_dialogs->show(50713);
-	else if (_action.isAction(VERB_LOOK, 0x375))
+	else if (_action.isAction(VERB_LOOK, NOUN_ADVERTISEMENT))
 		_vm->_dialogs->show(50714);
-	else if (_action.isAction(VERB_LOOK, 0x374))
+	else if (_action.isAction(VERB_LOOK, NOUN_ADVERTISING_POSTER))
 		_vm->_dialogs->show(50715);
-	else if (_action.isAction(VERB_LOOK, 0x244)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_SIGN)) {
 		if (_scene->_customDest.x < 100)
 			_vm->_dialogs->show(50726);
 		else
 			_vm->_dialogs->show(50716);
-	} else if (_action.isAction(VERB_LOOK, 0x2A7))
+	} else if (_action.isAction(VERB_LOOK, NOUN_HOTTEST_SOFTWARE))
 		_vm->_dialogs->show(50717);
-	else if (_action.isAction(VERB_LOOK, 0x2A6))
+	else if (_action.isAction(VERB_LOOK, NOUN_SOFTWARE_SHELF))
 		_vm->_dialogs->show(50718);
-	else if (_action.isAction(VERB_LOOK, 0x2A0))
+	else if (_action.isAction(VERB_LOOK, NOUN_SENSOR))
 		_vm->_dialogs->show(50719);
-	else if (_action.isAction(VERB_LOOK, 0x377))
+	else if (_action.isAction(VERB_LOOK, NOUN_CASH_REGISTER))
 		_vm->_dialogs->show(50720);
-	else if (_action.isAction(VERB_LOOK, 0xFE))
+	else if (_action.isAction(VERB_LOOK, NOUN_PAD_OF_PAPER))
 		_vm->_dialogs->show(50721);
-	else if (_action.isAction(VERB_OPEN, 0x377))
+	else if (_action.isAction(VERB_OPEN, NOUN_CASH_REGISTER))
 		_vm->_dialogs->show(50723);
-	else if (_action.isAction(VERB_LOOK, 0x28E))
+	else if (_action.isAction(VERB_LOOK, NOUN_BARGAIN_VAT))
 		_vm->_dialogs->show(50724);
-	else if (_action.isAction(VERB_LOOK, 0x197))
+	else if (_action.isAction(VERB_LOOK, NOUN_WINDOW))
 		_vm->_dialogs->show(50725);
-	else if (_action.isAction(VERB_LOOK, 0x29F)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_COUNTER)) {
 		if (_game._objects.isInRoom(OBJ_PENLIGHT))
 			_vm->_dialogs->show(50728);
 		else
 			_vm->_dialogs->show(50727);
-	} else if (_action.isAction(VERB_LOOK, 0x106) && !_game._objects.isInInventory(OBJ_PENLIGHT)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_PENLIGHT) && !_game._objects.isInInventory(OBJ_PENLIGHT)) {
 		if (_game._objects.isInRoom(OBJ_PENLIGHT))
 			_vm->_dialogs->show(50729);
-	} else if (_action.isAction(VERB_LOOK, 0x484))
+	} else if (_action.isAction(VERB_LOOK, NOUN_EMERGENCY_LIGHT))
 		_vm->_dialogs->show(50731);
 	else
 		return;
@@ -1528,7 +1528,7 @@ void Scene508::enter() {
 }
 
 void Scene508::preActions() {
-	if (_action.isAction(VERB_WALK, 0xF9))
+	if (_action.isAction(VERB_WALK, NOUN_OUTSIDE))
 		_game._player._walkOffScreenSceneId = 506;
 }
 
@@ -1586,7 +1586,7 @@ void Scene508::handlePedestral() {
 }
 
 void Scene508::actions() {
-	if (_action.isAction(VERB_PULL, 0x2AC)) {
+	if (_action.isAction(VERB_PULL, NOUN_LEVER)) {
 		if (!_globals[kLaserOn]) {
 			switch (_game._trigger) {
 			case 0:
@@ -1651,60 +1651,60 @@ void Scene508::actions() {
 		} else {
 			_vm->_dialogs->show(50837);
 		}
-	} else if (_action.isAction(VERB_REFLECT, 0x120, 0x343) || _action.isAction(VERB_PUT, 0x120, 0x344) || _action.isAction(VERB_PUT, 0x120, 0x343)) {
+	} else if (_action.isAction(VERB_REFLECT, 0x120, 0x343) || _action.isAction(VERB_PUT, NOUN_REARVIEW_MIRROR, 0x344) || _action.isAction(VERB_PUT, NOUN_REARVIEW_MIRROR, 0x343)) {
 		_chosenObject = 1;
 		handlePedestral();
-	} else if (_action.isAction(VERB_PUT, 0x57, 0x344) || _action.isAction(VERB_PUT, 0x57, 0x343) || _action.isAction(VERB_REFLECT, 0x57, 0x343)) {
+	} else if (_action.isAction(VERB_PUT, NOUN_COMPACT_CASE, 0x344) || _action.isAction(VERB_PUT, NOUN_COMPACT_CASE, 0x343) || _action.isAction(VERB_REFLECT, 0x57, 0x343)) {
 		_chosenObject = 2;
 		handlePedestral();
 	} else if (_action._lookFlag)
 		_vm->_dialogs->show(50822);
-	else if (_action.isAction(VERB_LOOK, 0x485))
+	else if (_action.isAction(VERB_LOOK, NOUN_TARGET_AREA))
 		_vm->_dialogs->show(50810);
-	else if (_action.isAction(VERB_LOOK, 0x364))
+	else if (_action.isAction(VERB_LOOK, NOUN_SPINACH_PATCH_DOLL))
 		_vm->_dialogs->show(50811);
-	else if (_action.isAction(VERB_TAKE, 0x364))
+	else if (_action.isAction(VERB_TAKE, NOUN_SPINACH_PATCH_DOLL))
 		_vm->_dialogs->show(50812);
-	else if (_action.isAction(VERB_LOOK, 0x37A))
+	else if (_action.isAction(VERB_LOOK, NOUN_SAND_BAGS))
 		_vm->_dialogs->show(50816);
-	else if (_action.isAction(VERB_TAKE, 0x37A))
+	else if (_action.isAction(VERB_TAKE, NOUN_SAND_BAGS))
 		_vm->_dialogs->show(50817);
-	else if (_action.isAction(VERB_LOOK, 0x2AF))
+	else if (_action.isAction(VERB_LOOK, NOUN_CONTROL_STATION))
 		_vm->_dialogs->show(50818);
-	else if (_action.isAction(VERB_LOOK, 0xE2)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_MONITOR)) {
 		if (_globals[kLaserOn])
 			_vm->_dialogs->show(50820);
 		else
 			_vm->_dialogs->show(50819);
-	} else if (_action.isAction(VERB_LOOK, 0x379)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_LASER_CANNON)) {
 		if (_globals[kLaserOn])
 			_vm->_dialogs->show(50822);
 		else
 			_vm->_dialogs->show(50821);
-	} else if (_action.isAction(VERB_TAKE, 0x379))
+	} else if (_action.isAction(VERB_TAKE, NOUN_LASER_CANNON))
 		_vm->_dialogs->show(50823);
-	else if (_action.isAction(VERB_LOOK, 0x2AC)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_LEVER)) {
 		if (_globals[kLaserOn])
 			_vm->_dialogs->show(50825);
 		else
 			_vm->_dialogs->show(50824);
-	} else if (_action.isAction(VERB_PUSH, 0x2AC))
+	} else if (_action.isAction(VERB_PUSH, NOUN_LEVER))
 		_vm->_dialogs->show(50826);
-	else if (_action.isAction(VERB_LOOK, 0x343)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_LASER_BEAM)) {
 		if (_globals[kLaserHoleIsThere])
 			_vm->_dialogs->show(50828);
 		else
 			_vm->_dialogs->show(50827);
-	} else if (_action.isAction(VERB_TAKE, 0x343))
+	} else if (_action.isAction(VERB_TAKE, NOUN_LASER_BEAM))
 		_vm->_dialogs->show(50829);
-	else if (_action.isAction(VERB_LOOK, 0x46)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_CEILING)) {
 		if (_globals[kLaserHoleIsThere])
 			_vm->_dialogs->show(50831);
 		else
 			_vm->_dialogs->show(50830);
-	} else if (_action.isAction(VERB_LOOK, 0x18D))
+	} else if (_action.isAction(VERB_LOOK, NOUN_WALL))
 		_vm->_dialogs->show(50832);
-	else if (_action.isAction(VERB_LOOK, 0x344)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_PEDESTAL)) {
 		if (!_globals[kLaserOn])
 			_vm->_dialogs->show(50813);
 		else if (!_globals[kLaserHoleIsThere])
@@ -1882,9 +1882,9 @@ void Scene511::preActions() {
 }
 
 void Scene511::actions() {
-	if (_action.isAction(VERB_WALK_INTO, 0x372))
+	if (_action.isAction(VERB_WALK_INTO, NOUN_RESTAURANT))
 		_scene->_nextSceneId = 512;
-	else if (_action.isAction(VERB_GET_INTO, 0x324)) {
+	else if (_action.isAction(VERB_GET_INTO, NOUN_CAR)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1922,7 +1922,7 @@ void Scene511::actions() {
 		default:
 			break;
 		}
-	} else 	if (_action.isAction(VERB_TAKE, 0x87)) {
+	} else 	if (_action.isAction(VERB_TAKE, NOUN_FISHING_LINE)) {
 		if (!_globals[kBoatRaised]) {
 			if (_globals[kLineStatus] == 2) {
 				if (_globals[kLineStatus] != 3) {
@@ -1983,7 +1983,7 @@ void Scene511::actions() {
 				}
 			}
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x31E) || _action._lookFlag) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_STREET) || _action._lookFlag) {
 		if (_globals[kLineStatus] == 2)
 			_vm->_dialogs->show(51110);
 		else {
@@ -1992,17 +1992,17 @@ void Scene511::actions() {
 			else
 				_vm->_dialogs->show(51112);
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x324))
+	} else if (_action.isAction(VERB_LOOK, NOUN_CAR))
 		_vm->_dialogs->show(51113);
-	else if (_action.isAction(VERB_LOOK, 0x31D))
+	else if (_action.isAction(VERB_LOOK, NOUN_SIDEWALK))
 		_vm->_dialogs->show(51114);
-	else if (_action.isAction(VERB_WALK_DOWN, 0x322) || _action.isAction(VERB_WALK_DOWN, 0x361) || _action.isAction(VERB_WALK_DOWN, 0x321))
+	else if (_action.isAction(VERB_WALK_DOWN, NOUN_SIDEWALK_TO_EAST) || _action.isAction(VERB_WALK_DOWN, NOUN_SIDEWALK_TO_WEST) || _action.isAction(VERB_WALK_DOWN, NOUN_STREET_TO_EAST))
 		_vm->_dialogs->show(51115);
-	else if (_action.isAction(VERB_LOOK, 0x37B))
+	else if (_action.isAction(VERB_LOOK, NOUN_PLEASURE_DOME))
 		_vm->_dialogs->show(51116);
-	else if (_action.isAction(VERB_LOOK, 0x34A))
+	else if (_action.isAction(VERB_LOOK, NOUN_TICKET_BOOTH))
 		_vm->_dialogs->show(51117);
-	else if (_action.isAction(VERB_LOOK, 0x37C))
+	else if (_action.isAction(VERB_LOOK, NOUN_DOME_ENTRANCE))
 		_vm->_dialogs->show(51118);
 	else if (_action.isAction(VERB_UNLOCK, 0xFF, 0x37C) || _action.isAction(VERB_UNLOCK, 0x6F, 0x37C))
 		_vm->_dialogs->show(51119);
@@ -2010,27 +2010,27 @@ void Scene511::actions() {
 		 && (_action.isAction(0x171) || _action.isAction(0x2A) || _action.isAction(0x2B))
 		 && _action.isAction(0x37C))
 		_vm->_dialogs->show(51120);
-	else if (_action.isAction(VERB_LOOK, 0x372)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_RESTAURANT)) {
 		if (_globals[kBoatRaised])
 			_vm->_dialogs->show(51121);
 		else
 			_vm->_dialogs->show(51128);
-	} else if (_action.isAction(VERB_LOOK, 0x349))
+	} else if (_action.isAction(VERB_LOOK, NOUN_PORTHOLE))
 		_vm->_dialogs->show(51122);
-	else if (_action.isAction(VERB_LOOK, 0x87) && (_action._mainObjectSource == 4) && (_globals[kLineStatus] == 2))
+	else if (_action.isAction(VERB_LOOK, NOUN_FISHING_LINE) && (_action._mainObjectSource == 4) && (_globals[kLineStatus] == 2))
 		_vm->_dialogs->show(51126);
-	else if (_action.isAction(VERB_LOOK, 0x87) && (_action._mainObjectSource == 4) && (_globals[kLineStatus] == 3))
+	else if (_action.isAction(VERB_LOOK, NOUN_FISHING_LINE) && (_action._mainObjectSource == 4) && (_globals[kLineStatus] == 3))
 		_vm->_dialogs->show(51133);
-	else if (_action.isAction(VERB_LOOK, 0x2CD))
+	else if (_action.isAction(VERB_LOOK, NOUN_STATUE))
 		_vm->_dialogs->show(51127);
-	else if (_action.isAction(VERB_LOOK, 0x345))
+	else if (_action.isAction(VERB_LOOK, NOUN_BOAT))
 		if (_globals[kBoatRaised])
 			_vm->_dialogs->show(51123);
 		else if (_globals[kLineStatus] != 3)
 			_vm->_dialogs->show(51124);
 		else
 			_vm->_dialogs->show(51125);
-	else if (_action.isAction(VERB_LOOK, 0x87) && (_globals[kLineStatus] == 3))
+	else if (_action.isAction(VERB_LOOK, NOUN_FISHING_LINE) && (_globals[kLineStatus] == 3))
 		_vm->_dialogs->show(51125);
 	else
 		return;
@@ -2102,9 +2102,9 @@ void Scene512::enter() {
 }
 
 void Scene512::actions() {
-	if (_action.isAction(VERB_WALK, 0xF9))
+	if (_action.isAction(VERB_WALK, NOUN_OUTSIDE))
 		_scene->_nextSceneId = 511;
-	else if (_action.isAction(VERB_TAKE, 0x88)) {
+	else if (_action.isAction(VERB_TAKE, NOUN_FISHING_ROD)) {
 		if (_game._trigger || !_game._objects.isInInventory(OBJ_FISHING_ROD)) {
 			switch (_game._trigger) {
 			case 0:
@@ -2134,7 +2134,7 @@ void Scene512::actions() {
 				break;
 			}
 		}
-	} else if (_action.isAction(VERB_OPEN, 0x377)) {
+	} else if (_action.isAction(VERB_OPEN, NOUN_CASH_REGISTER)) {
 		if (!_globals[kRegisterOpen]) {
 			switch (_game._trigger) {
 			case 0:
@@ -2195,7 +2195,7 @@ void Scene512::actions() {
 			}
 		} else
 			_vm->_dialogs->show(51239);
-	} else if (_action.isAction(VERB_CLOSE, 0x377) && _globals[kRegisterOpen]) {
+	} else if (_action.isAction(VERB_CLOSE, NOUN_CASH_REGISTER) && _globals[kRegisterOpen]) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -2231,7 +2231,7 @@ void Scene512::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_TAKE, 0xFF)) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_PADLOCK_KEY)) {
 		if (_game._trigger || !_game._objects.isInInventory(OBJ_PADLOCK_KEY)) {
 			switch (_game._trigger) {
 			case 0:
@@ -2278,48 +2278,48 @@ void Scene512::actions() {
 		}
 	} else if (_action._lookFlag)
 		_vm->_dialogs->show(51225);
-	else if (_action.isAction(VERB_LOOK, 0xFF) && _game._objects.isInRoom(OBJ_PADLOCK_KEY))
+	else if (_action.isAction(VERB_LOOK, NOUN_PADLOCK_KEY) && _game._objects.isInRoom(OBJ_PADLOCK_KEY))
 		_vm->_dialogs->show(51215);
-	else if (_action.isAction(VERB_LOOK, 0x88) && (_scene->_activeAnimation->getCurrentFrame() == 4))
+	else if (_action.isAction(VERB_LOOK, NOUN_FISHING_ROD) && (_scene->_activeAnimation->getCurrentFrame() == 4))
 		_vm->_dialogs->show(51216);
-	else if (_action.isAction(VERB_LOOK, 0x354))
+	else if (_action.isAction(VERB_LOOK, NOUN_SHIPS_WHEEL))
 		_vm->_dialogs->show(51218);
-	else if (_action.isAction(VERB_TAKE, 0x354))
+	else if (_action.isAction(VERB_TAKE, NOUN_SHIPS_WHEEL))
 		_vm->_dialogs->show(51219);
-	else if (_action.isAction(VERB_LOOK, 0x349) || _action.isAction(VERB_PEER_THROUGH, 0x349))
+	else if (_action.isAction(VERB_LOOK, NOUN_PORTHOLE) || _action.isAction(VERB_PEER_THROUGH, NOUN_PORTHOLE))
 		_vm->_dialogs->show(51220);
-	else if (_action.isAction(VERB_LOOK, 0x160))
+	else if (_action.isAction(VERB_LOOK, NOUN_TABLE))
 		_vm->_dialogs->show(51221);
-	else if (_action.isAction(VERB_LOOK, 0x34E))
+	else if (_action.isAction(VERB_LOOK, NOUN_STARFISH))
 		_vm->_dialogs->show(51222);
-	else if (_action.isAction(VERB_TAKE, 0x34E))
+	else if (_action.isAction(VERB_TAKE, NOUN_STARFISH))
 		_vm->_dialogs->show(51223);
-	else if (_action.isAction(VERB_LOOK, 0xF9))
+	else if (_action.isAction(VERB_LOOK, NOUN_OUTSIDE))
 		_vm->_dialogs->show(51224);
-	else if (_action.isAction(VERB_LOOK, 0x117))
+	else if (_action.isAction(VERB_LOOK, NOUN_POSTER))
 		_vm->_dialogs->show(51227);
-	else if (_action.isAction(VERB_TAKE, 0x117))
+	else if (_action.isAction(VERB_TAKE, NOUN_POSTER))
 		_vm->_dialogs->show(51228);
-	else if (_action.isAction(VERB_LOOK, 0x1BB)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_TROPHY)) {
 		if (_game._visitedScenes.exists(604))
 			_vm->_dialogs->show(51229);
 		else
 			_vm->_dialogs->show(51230);
-	} if (_action.isAction(VERB_LOOK, 0x47))
+	} if (_action.isAction(VERB_LOOK, NOUN_CHAIR))
 		_vm->_dialogs->show(51231);
-	else if (_action.isAction(VERB_LOOK, 0x347))
+	else if (_action.isAction(VERB_LOOK, NOUN_ROPE))
 		_vm->_dialogs->show(51232);
-	else if (_action.isAction(VERB_TAKE, 0x347))
+	else if (_action.isAction(VERB_TAKE, NOUN_ROPE))
 		_vm->_dialogs->show(51233);
-	else if (_action.isAction(VERB_LOOK, 0x2F6))
+	else if (_action.isAction(VERB_LOOK, NOUN_LAMP))
 		_vm->_dialogs->show(51234);
-	else if (_action.isAction(VERB_LOOK, 0x29F))
+	else if (_action.isAction(VERB_LOOK, NOUN_COUNTER))
 		_vm->_dialogs->show(51235);
-	else if (_action.isAction(VERB_LOOK, 0x486))
+	else if (_action.isAction(VERB_LOOK, NOUN_ICE_CHESTS))
 		_vm->_dialogs->show(51237);
-	else if (_action.isAction(VERB_OPEN, 0x486))
+	else if (_action.isAction(VERB_OPEN, NOUN_ICE_CHESTS))
 		_vm->_dialogs->show(51238);
-	else if (_action.isAction(VERB_LOOK, 0x377)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_CASH_REGISTER)) {
 		if (!_globals[kRegisterOpen])
 			_vm->_dialogs->show(51212);
 		else if (_game._objects.isInRoom(OBJ_PADLOCK_KEY))
@@ -2436,7 +2436,7 @@ void Scene513::step() {
 }
 
 void Scene513::actions() {
-	if (_action.isAction(VERB_GET_INTO, 0x324)) {
+	if (_action.isAction(VERB_GET_INTO, NOUN_CAR)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -2474,7 +2474,7 @@ void Scene513::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_PUT, 0xB3, 0x251) || _action.isAction(VERB_PUT, 0x305, 0x251)) {
+	} else if (_action.isAction(VERB_PUT, NOUN_ID_CARD, 0x251) || _action.isAction(VERB_PUT, NOUN_FAKE_ID, 0x251)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -2523,31 +2523,31 @@ void Scene513::actions() {
 		default:
 			break;
 		}
-	} else if ((_action._lookFlag) || _action.isAction(VERB_LOOK, 0x31E))
+	} else if ((_action._lookFlag) || _action.isAction(VERB_LOOK, NOUN_STREET))
 		_vm->_dialogs->show(51318);
-	else if (_action.isAction(VERB_LOOK, 0x317))
+	else if (_action.isAction(VERB_LOOK, NOUN_ELEVATOR))
 		_vm->_dialogs->show(51310);
-	else if (_action.isAction(VERB_LOOK, 0x367))
+	else if (_action.isAction(VERB_LOOK, NOUN_ELEVATOR_DOOR))
 		_vm->_dialogs->show(51311);
-	else if (_action.isAction(VERB_LOOK, 0x251))
+	else if (_action.isAction(VERB_LOOK, NOUN_CARD_SLOT))
 		_vm->_dialogs->show(51312);
-	else if (_action.isAction(VERB_LOOK, 0x355))
+	else if (_action.isAction(VERB_LOOK, NOUN_HANDICAP_SIGN))
 		_vm->_dialogs->show(51313);
-	else if (_action.isAction(VERB_LOOK, 0x358))
+	else if (_action.isAction(VERB_LOOK, NOUN_BIKE_RACK))
 		_vm->_dialogs->show(51314);
-	else if (_action.isAction(VERB_LOOK, 0x323))
+	else if (_action.isAction(VERB_LOOK, NOUN_BUILDING))
 		_vm->_dialogs->show(51315);
-	else if (_action.isAction(VERB_LOOK, 0x244))
+	else if (_action.isAction(VERB_LOOK, NOUN_SIGN))
 		_vm->_dialogs->show(51316);
-	else if (_action.isAction(VERB_LOOK, 0x360) || _action.isAction(VERB_WALK_DOWN, 0x360))
+	else if (_action.isAction(VERB_LOOK, NOUN_STREET_TO_WEST) || _action.isAction(VERB_WALK_DOWN, NOUN_STREET_TO_WEST))
 		_vm->_dialogs->show(51317);
-	else if (_action.isAction(VERB_OPEN, 0x367) || _action.isAction(VERB_OPEN, 0x317))
+	else if (_action.isAction(VERB_OPEN, NOUN_ELEVATOR_DOOR) || _action.isAction(VERB_OPEN, NOUN_ELEVATOR))
 		_vm->_dialogs->show(51319);
-	else if (_action.isAction(VERB_LOOK, 0x324))
+	else if (_action.isAction(VERB_LOOK, NOUN_CAR))
 		_vm->_dialogs->show(51321);
-	else if (_action.isAction(VERB_LOOK, 0x357))
+	else if (_action.isAction(VERB_LOOK, NOUN_BRICK_WALL))
 		_vm->_dialogs->show(51322);
-	else if (_action.isAction(VERB_PUT, 0x131, 0x251))
+	else if (_action.isAction(VERB_PUT, NOUN_SECURITY_CARD, 0x251))
 		_vm->_dialogs->show(51320);
 	else
 		return;
@@ -2686,32 +2686,32 @@ void Scene551::preActions() {
 }
 
 void Scene551::actions() {
-	if (_action.isAction(VERB_STEP_INTO, 0x16C))
+	if (_action.isAction(VERB_STEP_INTO, NOUN_TELEPORTER))
 		_scene->_nextSceneId = 502;
 	else if ((_action._lookFlag))
 		_vm->_dialogs->show(55117);
-	else if (_action.isAction(VERB_LOOK, 0x35E))
+	else if (_action.isAction(VERB_LOOK, NOUN_SKELETON))
 		_vm->_dialogs->show(55110);
-	else if (_action.isAction(VERB_LOOK, 0x318))
+	else if (_action.isAction(VERB_LOOK, NOUN_ELEVATOR_SHAFT))
 		_vm->_dialogs->show(55111);
-	else if (_action.isAction(VERB_WALKTO, 0x318))
+	else if (_action.isAction(VERB_WALKTO, NOUN_ELEVATOR_SHAFT))
 		_vm->_dialogs->show(55112);
-	else if (_action.isAction(VERB_LOOK, 0x323))
+	else if (_action.isAction(VERB_LOOK, NOUN_BUILDING))
 		_vm->_dialogs->show(55113);
-	else if (_action.isAction(VERB_LOOK, 0x16C))
+	else if (_action.isAction(VERB_LOOK, NOUN_TELEPORTER))
 		_vm->_dialogs->show(55114);
-	else if (_action.isAction(VERB_LOOK, 0x323))
+	else if (_action.isAction(VERB_LOOK, NOUN_BUILDING))
 		_vm->_dialogs->show(55115);
-	else if (_action.isAction(VERB_LOOK, 0x361)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_SIDEWALK_TO_WEST)) {
 		if (_game._visitedScenes.exists(505))
 			_vm->_dialogs->show(55116);
 		else
 			_vm->_dialogs->show(55115);
-	} else if (_action.isAction(VERB_LOOK, 0x31D))
+	} else if (_action.isAction(VERB_LOOK, NOUN_SIDEWALK))
 		_vm->_dialogs->show(55118);
-	else if (_action.isAction(VERB_LOOK, 0x369))
+	else if (_action.isAction(VERB_LOOK, NOUN_EQUIPMENT_OVERHEAD))
 		_vm->_dialogs->show(55119);
-	else if (_action.isAction(VERB_LOOK, 0x249))
+	else if (_action.isAction(VERB_LOOK, NOUN_RAILING))
 		_vm->_dialogs->show(55120);
 	else
 		return;
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index a8f9ac1..acadb82 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -147,7 +147,7 @@ void Scene601::step() {
 }
 
 void Scene601::actions() {
-	if (_action.isAction(VERB_WALK_THROUGH, 0x378))
+	if (_action.isAction(VERB_WALK_THROUGH, NOUN_ENTRANCE))
 		_scene->_nextSceneId = 602;
 	else if (_action.isAction(0x325, 0x324)) {
 		switch (_game._trigger) {
@@ -186,28 +186,28 @@ void Scene601::actions() {
 		default:
 			break;
 		}
-	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x31E)) {
+	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, NOUN_STREET)) {
 		if (!_globals[kLaserHoleIsThere])
 			_vm->_dialogs->show(60110);
 		else
 			_vm->_dialogs->show(60111);
-	} else if (_action.isAction(VERB_LOOK, 0x324))
+	} else if (_action.isAction(VERB_LOOK, NOUN_CAR))
 		_vm->_dialogs->show(60112);
-	else if (_action.isAction(VERB_LOOK, 0x32C))
+	else if (_action.isAction(VERB_LOOK, NOUN_PAPERS))
 		_vm->_dialogs->show(60113);
-	else if (_action.isAction(VERB_LOOK, 0x323))
+	else if (_action.isAction(VERB_LOOK, NOUN_BUILDING))
 		_vm->_dialogs->show(60114);
-	else if (_action.isAction(VERB_WALK_DOWN, 0x31E))
+	else if (_action.isAction(VERB_WALK_DOWN, NOUN_STREET))
 		_vm->_dialogs->show(60115);
-	else if (_action.isAction(VERB_LOOK, 0x48E))
+	else if (_action.isAction(VERB_LOOK, NOUN_BALCONY))
 		_vm->_dialogs->show(60116);
-	else if (_action.isAction(VERB_LOOK, 0x378))
+	else if (_action.isAction(VERB_LOOK, NOUN_ENTRANCE))
 		_vm->_dialogs->show(60117);
-	else if (_action.isAction(VERB_LOOK, 0x18D))
+	else if (_action.isAction(VERB_LOOK, NOUN_WALL))
 		_vm->_dialogs->show(60118);
-	else if (_action.isAction(VERB_LOOK, 0x38F))
+	else if (_action.isAction(VERB_LOOK, NOUN_CITY))
 		_vm->_dialogs->show(60119);
-	else if (_action.isAction(VERB_LOOK, 0x3C4))
+	else if (_action.isAction(VERB_LOOK, NOUN_FOUNTAIN))
 		_vm->_dialogs->show(60120);
 	else
 		return;
@@ -383,15 +383,15 @@ void Scene602::handleSafeActions() {
 }
 
 void Scene602::actions() {
-	if (_action.isAction(VERB_WALK_THROUGH, 0x1F9))
+	if (_action.isAction(VERB_WALK_THROUGH, NOUN_HALLWAY))
 		_scene->_nextSceneId = 601;
-	else if (_action.isAction(VERB_WALK_THROUGH, 0x70))
+	else if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOORWAY))
 		_scene->_nextSceneId = 603;
-	else if (_action.isAction(VERB_OPEN, 0x3D3) && ((_globals[kSafeStatus] == 0) || (_globals[kSafeStatus] == 2))) {
+	else if (_action.isAction(VERB_OPEN, NOUN_SAFE) && ((_globals[kSafeStatus] == 0) || (_globals[kSafeStatus] == 2))) {
 		_safeMode = 1;
 		_cycleIndex = -2;
 		handleSafeActions();
-	} else if (_action.isAction(VERB_CLOSE, 0x3D3) && ((_globals[kSafeStatus] == 1) || (_globals[kSafeStatus] == 3))) {
+	} else if (_action.isAction(VERB_CLOSE, NOUN_SAFE) && ((_globals[kSafeStatus] == 1) || (_globals[kSafeStatus] == 3))) {
 		_safeMode = 2;
 		_cycleIndex = -1;
 		handleSafeActions();
@@ -401,7 +401,7 @@ void Scene602::actions() {
 			_cycleIndex = -2;
 			handleSafeActions();
 		}
-	} else if ((_action.isAction(VERB_PUT, 0x120, 0x343) || _action.isAction(VERB_PUT, 0x57, 0x343)
+	} else if ((_action.isAction(VERB_PUT, NOUN_REARVIEW_MIRROR, 0x343) || _action.isAction(VERB_PUT, NOUN_COMPACT_CASE, 0x343)
 		|| _action.isAction(VERB_REFLECT, 0x57, 0x343) || _action.isAction(VERB_REFLECT, 0x120, 0x343)) && (_globals[kSafeStatus] == 0)) {
 		switch (_game._trigger) {
 		case 0:
@@ -439,7 +439,7 @@ void Scene602::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_TAKE, 0x6F) && (_game._trigger || _game._objects.isInRoom(OBJ_DOOR_KEY))) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_DOOR_KEY) && (_game._trigger || _game._objects.isInRoom(OBJ_DOOR_KEY))) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -470,29 +470,29 @@ void Scene602::actions() {
 		}
 	} else if (_action._lookFlag)
 		_vm->_dialogs->show(60210);
-	else if (_action.isAction(VERB_LOOK, 0x89))
+	else if (_action.isAction(VERB_LOOK, NOUN_FLOOR))
 		_vm->_dialogs->show(60211);
-	else if (_action.isAction(VERB_LOOK, 0x1F9))
+	else if (_action.isAction(VERB_LOOK, NOUN_HALLWAY))
 		_vm->_dialogs->show(60212);
-	else if (_action.isAction(VERB_LOOK, 0x160))
+	else if (_action.isAction(VERB_LOOK, NOUN_TABLE))
 		_vm->_dialogs->show(60213);
-	else if (_action.isAction(VERB_LOOK, 0x47) || _action.isAction(VERB_LOOK, 0x3CA))
+	else if (_action.isAction(VERB_LOOK, NOUN_CHAIR) || _action.isAction(VERB_LOOK, NOUN_LOUNGE_CHAIR))
 		_vm->_dialogs->show(60214);
-	else if (_action.isAction(VERB_LOOK, 0x492))
+	else if (_action.isAction(VERB_LOOK, NOUN_NEON_LIGHTS))
 		_vm->_dialogs->show(60215);
-	else if (_action.isAction(VERB_LOOK, 0x3D8))
+	else if (_action.isAction(VERB_LOOK, NOUN_FIREPLACE))
 		_vm->_dialogs->show(60216);
-	else if (_action.isAction(VERB_LOOK, 0x289))
+	else if (_action.isAction(VERB_LOOK, NOUN_PICTURE))
 		_vm->_dialogs->show(60217);
-	else if (_action.isAction(VERB_LOOK, 0x2F6))
+	else if (_action.isAction(VERB_LOOK, NOUN_LAMP))
 		_vm->_dialogs->show(60218);
-	else if (_action.isAction(VERB_LOOK, 0x491))
+	else if (_action.isAction(VERB_LOOK, NOUN_MASKS))
 		_vm->_dialogs->show(60219);
-	else if (_action.isAction(VERB_LOOK, 0x493))
+	else if (_action.isAction(VERB_LOOK, NOUN_GLASS_BLOCK_WALL))
 		_vm->_dialogs->show(60220);
-	else if (_action.isAction(VERB_LOOK, 0x70))
+	else if (_action.isAction(VERB_LOOK, NOUN_DOORWAY))
 		_vm->_dialogs->show(60221);
-	else if (_action.isAction(VERB_LOOK, 0x3D3)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_SAFE)) {
 		if (_globals[kSafeStatus] == 0)
 			_vm->_dialogs->show(60222);
 		else if (_globals[kSafeStatus] == 1) {
@@ -508,19 +508,19 @@ void Scene602::actions() {
 			_vm->_dialogs->show(60236);
 	} else if (_action.isAction(VERB_UNLOCK, 0x6F, 0x3D3) || _action.isAction(VERB_UNLOCK, 0xFF, 0x3D3))
 		_vm->_dialogs->show(60225);
-	else if (_action.isAction(VERB_PULL, 0x3D3))
+	else if (_action.isAction(VERB_PULL, NOUN_SAFE))
 		_vm->_dialogs->show(60226);
-	else if (_action.isAction(VERB_PUT, 0x3D8) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId)))
+	else if (_action.isAction(VERB_PUT, NOUN_FIREPLACE) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId)))
 		_vm->_dialogs->show(60227);
-	else if (_action.isAction(VERB_LOOK, 0x342))
+	else if (_action.isAction(VERB_LOOK, NOUN_HOLE))
 		_vm->_dialogs->show(60228);
-	else if (_action.isAction(VERB_LOOK, 0x343))
+	else if (_action.isAction(VERB_LOOK, NOUN_LASER_BEAM))
 		_vm->_dialogs->show(60229);
-	else if (_action.isAction(VERB_LOOK, 0x3F5))
+	else if (_action.isAction(VERB_LOOK, NOUN_FLOWER_BOX))
 		_vm->_dialogs->show(60231);
-	else if (_action.isAction(VERB_THROW, 0x2A, 0x3D3) || _action.isAction(VERB_THROW, 0x2B, 0x3D3))
+	else if (_action.isAction(VERB_THROW, NOUN_BOMB, 0x3D3) || _action.isAction(VERB_THROW, NOUN_BOMBS, 0x3D3))
 		_vm->_dialogs->show(60232);
-	else if (_action.isAction(VERB_PUT, 0x171))
+	else if (_action.isAction(VERB_PUT, NOUN_TIMEBOMB))
 		_vm->_dialogs->show(60233);
 	else
 		return;
@@ -564,9 +564,9 @@ void Scene603::enter() {
 }
 
 void Scene603::actions() {
-	if (_action.isAction(VERB_WALK_TOWARDS, 0x3F1))
+	if (_action.isAction(VERB_WALK_TOWARDS, NOUN_LIVINGROOM))
 		_scene->_nextSceneId = 602;
-	else if (_action.isAction(VERB_TAKE, 0x57)) {
+	else if (_action.isAction(VERB_TAKE, NOUN_COMPACT_CASE)) {
 		if ( _game._trigger || !_game._objects.isInInventory(OBJ_COMPACT_CASE)) {
 			switch (_game._trigger) {
 			case 0:
@@ -597,7 +597,7 @@ void Scene603::actions() {
 				break;
 			}
 		}
-	} else if (_action.isAction(VERB_TAKE, 0x3A8)) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_NOTE)) {
 		if ( _game._trigger || !_game._objects.isInInventory(OBJ_NOTE)) {
 			if (_game._trigger == 0) {
 				_game._player._stepEnabled = false;
@@ -618,46 +618,46 @@ void Scene603::actions() {
 		}
 	} else if (_action._lookFlag)
 		_vm->_dialogs->show(60310);
-	else if (_action.isAction(VERB_LOOK, 0x1CB))
+	else if (_action.isAction(VERB_LOOK, NOUN_BED))
 		_vm->_dialogs->show(60311);
-	else if (_action.isAction(VERB_LOOK, 0x3E5))
+	else if (_action.isAction(VERB_LOOK, NOUN_WIG_STAND))
 		_vm->_dialogs->show(60312);
-	else if (_action.isAction(VERB_TAKE, 0x3E5))
+	else if (_action.isAction(VERB_TAKE, NOUN_WIG_STAND))
 		_vm->_dialogs->show(60313);
-	else if (_action.isAction(VERB_LOOK, 0x3EE))
+	else if (_action.isAction(VERB_LOOK, NOUN_REVIEW))
 		_vm->_dialogs->show(60314);
-	else if (_action.isAction(VERB_LOOK, 0x3ED))
+	else if (_action.isAction(VERB_LOOK, NOUN_SOUVENIR_TICKETS))
 		_vm->_dialogs->show(60315);
-	else if (_action.isAction(VERB_LOOK, 0x49D))
+	else if (_action.isAction(VERB_LOOK, NOUN_PHOTOGRAPH))
 		_vm->_dialogs->show(60316);
-	else if (_action.isAction(VERB_LOOK, 0x2F6))
+	else if (_action.isAction(VERB_LOOK, NOUN_LAMP))
 		_vm->_dialogs->show(60317);
-	else if (_action.isAction(VERB_LOOK, 0x49E) || _action.isAction(VERB_LOOK, 0x49F) || _action.isAction(VERB_LOOK, 0x3E7))
+	else if (_action.isAction(VERB_LOOK, NOUN_DIRECTORS_SLATE) || _action.isAction(VERB_LOOK, NOUN_CROP) || _action.isAction(VERB_LOOK, NOUN_MEGAPHONE))
 		_vm->_dialogs->show(60318);
-	else if (_action.isAction(VERB_LOOK, 0x3DE))
+	else if (_action.isAction(VERB_LOOK, NOUN_SNAPSHOT))
 		_vm->_dialogs->show(60319);
-	else if (_action.isAction(VERB_TAKE, 0x3DE))
+	else if (_action.isAction(VERB_TAKE, NOUN_SNAPSHOT))
 		_vm->_dialogs->show(60320);
-	else if (_action.isAction(VERB_LOOK, 0x3DF))
+	else if (_action.isAction(VERB_LOOK, NOUN_PERFUME))
 		_vm->_dialogs->show(60321);
-	else if (_action.isAction(VERB_TAKE, 0x3DF))
+	else if (_action.isAction(VERB_TAKE, NOUN_PERFUME))
 		_vm->_dialogs->show(60322);
-	else if (_action.isAction(VERB_TAKE, 0x3A8))
+	else if (_action.isAction(VERB_TAKE, NOUN_NOTE))
 		_vm->_dialogs->show(60323);
-	else if (_action.isAction(VERB_LOOK, 0x3A8)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_NOTE)) {
 		if (_game._objects[OBJ_NOTE]._roomNumber == _scene->_currentSceneId)
 			_vm->_dialogs->show(60324);
-	} else if (_action.isAction(VERB_LOOK, 0x3E3)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_CORNER_TABLE)) {
 		if (_game._objects[OBJ_NOTE]._roomNumber == _scene->_currentSceneId)
 			_vm->_dialogs->show(60326);
 		else
 			_vm->_dialogs->show(60325);
-	} else if (_action.isAction(VERB_LOOK, 0x3EA)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_VANITY)) {
 		if (_game._objects[OBJ_COMPACT_CASE]._roomNumber == _scene->_currentSceneId)
 			_vm->_dialogs->show(60327);
 		else
 			_vm->_dialogs->show(60328);
-	} else if (_action.isAction(VERB_LOOK, 0x57) && (_action._mainObjectSource == 4))
+	} else if (_action.isAction(VERB_LOOK, NOUN_COMPACT_CASE) && (_action._mainObjectSource == 4))
 		_vm->_dialogs->show(60329);
 	// For the next two checks, the second part of the check wasn't surrounded par parenthesis, which was obviously wrong
 	else if (_action.isAction(VERB_LOOK) && (_action.isAction(0x31) || _action.isAction(0x3EA) || _action.isAction(0x3E8)))
@@ -890,10 +890,10 @@ void Scene604::actions() {
 		default:
 			break;
 		}
-	} else if ((_action.isAction(VERB_PUT, 0x3F6) || _action.isAction(VERB_PUT, 0x181) || _action.isAction(VERB_THROW, 0x181))
+	} else if ((_action.isAction(VERB_PUT, NOUN_LEDGE) || _action.isAction(VERB_PUT, NOUN_VIEWPORT) || _action.isAction(VERB_THROW, NOUN_VIEWPORT))
 		&& (_action.isAction(0x2A) || _action.isAction(0x2B)))
 		_vm->_dialogs->show(60420);
-	else if (_action.isAction(VERB_PUT, 0x171, 0x3F6) || _action.isAction(VERB_PUT, 0x171, 0x181)) {
+	else if (_action.isAction(VERB_PUT, NOUN_TIMEBOMB, 0x3F6) || _action.isAction(VERB_PUT, NOUN_TIMEBOMB, 0x181)) {
 		_bombMode = 1;
 		if ((_game._difficulty == DIFFICULTY_HARD) || _globals[kWarnedFloodCity])
 			handleBombActions();
@@ -906,30 +906,30 @@ void Scene604::actions() {
 			_vm->_dialogs->show(60425);
 			_globals[kWarnedFloodCity] = true;
 		}
-	} else if (_action.isAction(VERB_TAKE, 0x171)) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_TIMEBOMB)) {
 		if (_game._trigger || !_game._objects.isInInventory(OBJ_TIMEBOMB)) {
 			_bombMode = 2;
 			handleBombActions();
 		}
 	} else if (_action._lookFlag)
 		_vm->_dialogs->show(60411);
-	else if (_action.isAction(VERB_LOOK, 0x181)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_VIEWPORT)) {
 		if (_monsterActive) {
 			_vm->_dialogs->show(60413);
 		} else {
 			_vm->_dialogs->show(60412);
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x18D))
+	} else if (_action.isAction(VERB_LOOK, NOUN_WALL))
 		_vm->_dialogs->show(60414);
-	else if (_action.isAction(VERB_LOOK, 0x3F4))
+	else if (_action.isAction(VERB_LOOK, NOUN_VENT))
 		_vm->_dialogs->show(60415);
-	else if (_action.isAction(VERB_LOOK, 0x479))
+	else if (_action.isAction(VERB_LOOK, NOUN_INDICATOR))
 		_vm->_dialogs->show(60416);
-	else if (_action.isAction(VERB_LOOK, 0x3F2))
+	else if (_action.isAction(VERB_LOOK, NOUN_SCULPTURE))
 		_vm->_dialogs->show(60417);
-	else if (_action.isAction(VERB_LOOK, 0x324))
+	else if (_action.isAction(VERB_LOOK, NOUN_CAR))
 		_vm->_dialogs->show(60418);
-	else if (_action.isAction(VERB_LOOK, 0x3C4))
+	else if (_action.isAction(VERB_LOOK, NOUN_FOUNTAIN))
 		_vm->_dialogs->show(60419);
 	else
 		return;
@@ -1293,23 +1293,23 @@ void Scene607::handleThrowingBone() {
 }
 
 void Scene607::preActions() {
-	if (_action.isAction(VERB_TALKTO, 0x471))
+	if (_action.isAction(VERB_TALKTO, NOUN_OBNOXIOUS_DOG))
 		_game._player._needToWalk = false;
 
-	if (_action.isAction(VERB_WALK_THROUGH, 0x478) && (_globals[kDogStatus] == 2) && (_game._difficulty != DIFFICULTY_EASY)) {
+	if (_action.isAction(VERB_WALK_THROUGH, NOUN_SIDE_ENTRANCE) && (_globals[kDogStatus] == 2) && (_game._difficulty != DIFFICULTY_EASY)) {
 		_shopAvailable = true;
 		_dogTimer = 0;
 	}
 
-	if (_action.isAction(VERB_THROW, 0x2D, 0x471) || _action.isAction(VERB_THROW, 0x2C, 0x471))
+	if (_action.isAction(VERB_THROW, NOUN_BONES, 0x471) || _action.isAction(VERB_THROW, NOUN_BONE, 0x471))
 		_game._player.walk(Common::Point(193, 100), FACING_NORTHEAST);
 
-	if (_action.isAction(VERB_THROW, 0x2D, 0x2C3) || _action.isAction(VERB_THROW, 0x2C, 0x2C3))
+	if (_action.isAction(VERB_THROW, NOUN_BONES, 0x2C3) || _action.isAction(VERB_THROW, NOUN_BONE, 0x2C3))
 		_game._player.walk(Common::Point(201, 107), FACING_SOUTHEAST);
 }
 
 void Scene607::actions() {
-	if (_action.isAction(VERB_WALK_THROUGH, 0x478))
+	if (_action.isAction(VERB_WALK_THROUGH, NOUN_SIDE_ENTRANCE))
 		_scene->_nextSceneId = 608;
 	else if (_action.isAction(0x325, 0x324)) {
 		switch (_game._trigger) {
@@ -1348,7 +1348,7 @@ void Scene607::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_THROW, 0x2D, 0x471) || _action.isAction(VERB_THROW, 0x2C, 0x471)) {
+	} else if (_action.isAction(VERB_THROW, NOUN_BONES, 0x471) || _action.isAction(VERB_THROW, NOUN_BONE, 0x471)) {
 		if (_game._difficulty != DIFFICULTY_EASY) {
 			_animationMode = 1;
 			_scene->_kernelMessages.reset();
@@ -1357,7 +1357,7 @@ void Scene607::actions() {
 
 			handleThrowingBone();
 		}
-	} else if ((_action.isAction(VERB_THROW, 0x2D, 0x2C3) || _action.isAction(VERB_THROW, 0x2C, 0x2C3)) && (_game._difficulty != DIFFICULTY_EASY)
+	} else if ((_action.isAction(VERB_THROW, NOUN_BONES, 0x2C3) || _action.isAction(VERB_THROW, NOUN_BONE, 0x2C3)) && (_game._difficulty != DIFFICULTY_EASY)
 		 && ((_globals[kDogStatus] == 1) || _game._trigger)) {
 		_animationMode = 2;
 		if (_game._trigger == 0) {
@@ -1365,48 +1365,48 @@ void Scene607::actions() {
 			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x2F6));
 		}
 		handleThrowingBone();
-	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x31E)) {
+	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, NOUN_STREET)) {
 		if ((_globals[kDogStatus] == 1) || (_game._difficulty == DIFFICULTY_EASY))
 			_vm->_dialogs->show(60710);
 		else
 			_vm->_dialogs->show(60711);
-	} else if (_action.isAction(VERB_LOOK, 0x18D))
+	} else if (_action.isAction(VERB_LOOK, NOUN_WALL))
 		_vm->_dialogs->show(60712);
-	else if (_action.isAction(VERB_LOOK, 0x2C3))
+	else if (_action.isAction(VERB_LOOK, NOUN_FENCE))
 		_vm->_dialogs->show(60713);
-	else if (_action.isAction(VERB_LOOK, 0x324))
+	else if (_action.isAction(VERB_LOOK, NOUN_CAR))
 		_vm->_dialogs->show(60714);
-	else if (_action.isAction(VERB_LOOK, 0x3FB))
+	else if (_action.isAction(VERB_LOOK, NOUN_MANHOLE))
 		_vm->_dialogs->show(60715);
-	else if (_action.isAction(VERB_LOOK, 0x1E6) && (_globals[kDogStatus] == 1))
+	else if (_action.isAction(VERB_LOOK, NOUN_FIRE_HYDRANT) && (_globals[kDogStatus] == 1))
 		_vm->_dialogs->show(60716);
-	else if (_action.isAction(VERB_LOOK, 0x244))
+	else if (_action.isAction(VERB_LOOK, NOUN_SIGN))
 		_vm->_dialogs->show(60717);
-	else if (_action.isAction(VERB_LOOK, 0x3FD))
+	else if (_action.isAction(VERB_LOOK, NOUN_BROKEN_WINDOW))
 		_vm->_dialogs->show(60718);
-	else if (_action.isAction(VERB_LOOK, 0x3FF))
+	else if (_action.isAction(VERB_LOOK, NOUN_GARAGE_DOOR))
 		_vm->_dialogs->show(60719);
-	else if (_action.isAction(VERB_LOOK, 0x31D))
+	else if (_action.isAction(VERB_LOOK, NOUN_SIDEWALK))
 		_vm->_dialogs->show(60720);
-	else if (_action.isAction(VERB_LOOK, 0x3F9))
+	else if (_action.isAction(VERB_LOOK, NOUN_AIR_HOSE))
 		_vm->_dialogs->show(60721);
-	else if (_action.isAction(VERB_LOOK, 0x3FA)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_AUTO_SHOP)) {
 		if (_globals[kDogStatus] == 1)
 			_vm->_dialogs->show(60723);
 		else
 			_vm->_dialogs->show(60722);
-	} else if (_action.isAction(VERB_LOOK, 0x478)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_SIDE_ENTRANCE)) {
 		if (_globals[kDogStatus] == 1)
 			_vm->_dialogs->show(60725);
 		else
 			_vm->_dialogs->show(60724);
-	} else if (_action.isAction(VERB_LOOK, 0x471))
+	} else if (_action.isAction(VERB_LOOK, NOUN_OBNOXIOUS_DOG))
 		_vm->_dialogs->show(60726);
-	else if (_action.isAction(VERB_TALKTO, 0x471))
+	else if (_action.isAction(VERB_TALKTO, NOUN_OBNOXIOUS_DOG))
 		_vm->_dialogs->show(60727);
-	else if (_action.isAction(VERB_LOOK, 0x31F))
+	else if (_action.isAction(VERB_LOOK, NOUN_BARRICADE))
 		_vm->_dialogs->show(60728);
-	else if (_action.isAction(VERB_WALK_DOWN, 0x31E))
+	else if (_action.isAction(VERB_WALK_DOWN, NOUN_STREET))
 		_vm->_dialogs->show(60730);
 	else if (_action.isAction(0x3FF) && (_action.isAction(VERB_OPEN) || _action.isAction(VERB_PUSH) || _action.isAction(VERB_PULL)))
 		_vm->_dialogs->show(60731);
@@ -2070,20 +2070,20 @@ void Scene608::step() {
 void Scene608::preActions() {
 	_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 
-	if ((_action.isAction(VERB_THROW, 0x2C, 0x410) || _action.isAction(VERB_THROW, 0x2D, 0x410)
-		|| _action.isAction(VERB_THROW, 0x2C, 0x411) || _action.isAction(VERB_THROW, 0x2D, 0x411)
-		|| _action.isAction(VERB_THROW, 0x2D, 0x471) || _action.isAction(VERB_THROW, 0x2C, 0x471)) && _dogActiveFl) {
+	if ((_action.isAction(VERB_THROW, NOUN_BONE, 0x410) || _action.isAction(VERB_THROW, NOUN_BONES, 0x410)
+		|| _action.isAction(VERB_THROW, NOUN_BONE, 0x411) || _action.isAction(VERB_THROW, NOUN_BONES, 0x411)
+		|| _action.isAction(VERB_THROW, NOUN_BONES, 0x471) || _action.isAction(VERB_THROW, NOUN_BONE, 0x471)) && _dogActiveFl) {
 		_game._player._stepEnabled = false;
 		_game._player.walk(Common::Point(56, 146), FACING_EAST);
 	}
 
-	if ((_action.isAction(VERB_THROW, 0x2D, 0x41D) || _action.isAction(VERB_THROW, 0x2C, 0x41D)
-		|| _action.isAction(VERB_THROW, 0x2D, 0x41E) || _action.isAction(VERB_THROW, 0x2C, 0x41E)) && _dogActiveFl) {
+	if ((_action.isAction(VERB_THROW, NOUN_BONES, 0x41D) || _action.isAction(VERB_THROW, NOUN_BONE, 0x41D)
+		|| _action.isAction(VERB_THROW, NOUN_BONES, 0x41E) || _action.isAction(VERB_THROW, NOUN_BONE, 0x41E)) && _dogActiveFl) {
 		_game._player._stepEnabled = false;
 		_game._player.walk(Common::Point(75, 136), FACING_EAST);
 	}
 
-	if (_action.isAction(VERB_PUSH, 0x403) && _dogUnderCar) {
+	if (_action.isAction(VERB_PUSH, NOUN_DOWN_BUTTON) && _dogUnderCar) {
 		_buttonPressedonTimeFl = true;
 		_dogDeathMode = 1;
 	} else
@@ -2091,9 +2091,9 @@ void Scene608::preActions() {
 }
 
 void Scene608::actions() {
-	if (_action.isAction(VERB_WALK_THROUGH, 0x70))
+	if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOORWAY))
 		_scene->_nextSceneId = 607;
-	else if (_action.isAction(VERB_PUSH, 0x403)) {
+	else if (_action.isAction(VERB_PUSH, NOUN_DOWN_BUTTON)) {
 		_game._player._stepEnabled = true;
 		switch (_game._trigger) {
 		case 0:
@@ -2168,7 +2168,7 @@ void Scene608::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_PUSH, 0x402)) {
+	} else if (_action.isAction(VERB_PUSH, NOUN_UP_BUTTON)) {
 		switch (_game._trigger) {
 		case 0:
 			if ((_globals[kCarStatus] == 3) || (_globals[kCarStatus] == 4)) {
@@ -2217,8 +2217,8 @@ void Scene608::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_THROW, 0x2C, 0x410) || _action.isAction(VERB_THROW, 0x2D, 0x410)
-					|| _action.isAction(VERB_THROW, 0x2D, 0x471) || _action.isAction(VERB_THROW, 0x2C, 0x471)) {
+	} else if (_action.isAction(VERB_THROW, NOUN_BONE, 0x410) || _action.isAction(VERB_THROW, NOUN_BONES, 0x410)
+					|| _action.isAction(VERB_THROW, NOUN_BONES, 0x471) || _action.isAction(VERB_THROW, NOUN_BONE, 0x471)) {
 		_game._player._stepEnabled = true;
 		if (_dogActiveFl) {
 			if (_game._trigger == 0) {
@@ -2229,7 +2229,7 @@ void Scene608::actions() {
 			handleThrowingBone();
 		} else
 			_vm->_dialogs->show(60841);
-	} else if (_action.isAction(VERB_THROW, 0x2C, 0x411) || _action.isAction(VERB_THROW, 0x2D, 0x411)) {
+	} else if (_action.isAction(VERB_THROW, NOUN_BONE, 0x411) || _action.isAction(VERB_THROW, NOUN_BONES, 0x411)) {
 		_game._player._stepEnabled = true;
 		if (_dogActiveFl) {
 			if (_game._trigger == 0) {
@@ -2240,8 +2240,8 @@ void Scene608::actions() {
 			handleThrowingBone();
 		} else
 			_vm->_dialogs->show(60841);
-	} else if (_action.isAction(VERB_THROW, 0x2D, 0x41D) || _action.isAction(VERB_THROW, 0x2C, 0x41D)
-					|| _action.isAction(VERB_THROW, 0x2D, 0x41E) || _action.isAction(VERB_THROW, 0x2C, 0x41E)) {
+	} else if (_action.isAction(VERB_THROW, NOUN_BONES, 0x41D) || _action.isAction(VERB_THROW, NOUN_BONE, 0x41D)
+					|| _action.isAction(VERB_THROW, NOUN_BONES, 0x41E) || _action.isAction(VERB_THROW, NOUN_BONE, 0x41E)) {
 		_game._player._stepEnabled = true;
 		if ((_globals[kCarStatus] == 0) && _dogActiveFl) {
 			if (_dogActiveFl) {
@@ -2255,7 +2255,7 @@ void Scene608::actions() {
 				_vm->_dialogs->show(60841);
 		} else
 			_vm->_dialogs->show(60842);
-	} else if (_action.isAction(VERB_TAKE, 0x115) && (_game._trigger || !_game._objects.isInInventory(OBJ_POLYCEMENT))) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_POLYCEMENT) && (_game._trigger || !_game._objects.isInInventory(OBJ_POLYCEMENT))) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -2283,7 +2283,7 @@ void Scene608::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_TAKE, 0x120) && (_game._trigger || !_game._objects.isInInventory(OBJ_REARVIEW_MIRROR))) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_REARVIEW_MIRROR) && (_game._trigger || !_game._objects.isInInventory(OBJ_REARVIEW_MIRROR))) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -2324,51 +2324,51 @@ void Scene608::actions() {
 	else if (_action.isAction(VERB_TAKE) && (_action.isAction(0x412) || _action.isAction(0x408) || _action.isAction(0x414)
 					|| _action.isAction(0x40D) || _action.isAction(0x41C)))
 		_vm->_dialogs->show(60814);
-	else if (_action.isAction(VERB_LOOK, 0x409) || _action.isAction(VERB_LOOK, 0x411) || _action.isAction(VERB_LOOK, 0x410)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_GARAGE_FLOOR) || _action.isAction(VERB_LOOK, NOUN_FRONT_OF_GARAGE) || _action.isAction(VERB_LOOK, NOUN_REAR_OF_GARAGE)) {
 		if (_dogActiveFl)
 			_vm->_dialogs->show(60815);
 		else
 			_vm->_dialogs->show(60816);
-	} else if (_action.isAction(VERB_LOOK, 0x495))
+	} else if (_action.isAction(VERB_LOOK, NOUN_SPARE_RIBS))
 		_vm->_dialogs->show(60817);
-	else if (_action.isAction(VERB_TAKE, 0x495)) {
+	else if (_action.isAction(VERB_TAKE, NOUN_SPARE_RIBS)) {
 		if (_game._difficulty == DIFFICULTY_HARD)
 			_vm->_dialogs->show(60818);
 		else
 			_vm->_dialogs->show(60819);
-	} else if (_action.isAction(VERB_LOOK, 0x402))
+	} else if (_action.isAction(VERB_LOOK, NOUN_UP_BUTTON))
 		_vm->_dialogs->show(60820);
-	else if (_action.isAction(VERB_LOOK, 0x403))
+	else if (_action.isAction(VERB_LOOK, NOUN_DOWN_BUTTON))
 		_vm->_dialogs->show(60821);
-	else if (_action.isAction(VERB_LOOK, 0x41A))
+	else if (_action.isAction(VERB_LOOK, NOUN_TRASH_CAN))
 		_vm->_dialogs->show(60822);
-	else if (_action.isAction(VERB_LOOK, 0x418))
+	else if (_action.isAction(VERB_LOOK, NOUN_CALENDAR))
 		_vm->_dialogs->show(60823);
-	else if (_action.isAction(VERB_LOOK, 0x330)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_STORAGE_BOX)) {
 		if (_game._objects[OBJ_REARVIEW_MIRROR]._roomNumber == _scene->_currentSceneId)
 			_vm->_dialogs->show(60825);
 		else
 			_vm->_dialogs->show(60824);
-	} else if (_action.isAction(VERB_OPEN, 0x330))
+	} else if (_action.isAction(VERB_OPEN, NOUN_STORAGE_BOX))
 		_vm->_dialogs->show(60826);
-	else if (_action.isAction(VERB_LOOK, 0x120) && (_action._mainObjectSource == 4))
+	else if (_action.isAction(VERB_LOOK, NOUN_REARVIEW_MIRROR) && (_action._mainObjectSource == 4))
 		_vm->_dialogs->show(60828);
-	else if (_action.isAction(VERB_LOOK, 0x406)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_TOOL_BOX)) {
 		if (_game._objects[OBJ_POLYCEMENT]._roomNumber == _scene->_currentSceneId)
 			_vm->_dialogs->show(60829);
 		else
 			_vm->_dialogs->show(60830);
-	} else if (_action.isAction(VERB_OPEN, 0x406))
+	} else if (_action.isAction(VERB_OPEN, NOUN_TOOL_BOX))
 		_vm->_dialogs->show(60831);
-	else if ((_action.isAction(VERB_LOOK, 0x115)) && (_game._objects.isInRoom(OBJ_POLYCEMENT)))
+	else if ((_action.isAction(VERB_LOOK, NOUN_POLYCEMENT)) && (_game._objects.isInRoom(OBJ_POLYCEMENT)))
 		_vm->_dialogs->show(60832);
-	else if (_action.isAction(VERB_LOOK, 0x417) || _action.isAction(VERB_LOOK, 0x40E))
+	else if (_action.isAction(VERB_LOOK, NOUN_GREASE_CAN) || _action.isAction(VERB_LOOK, NOUN_OIL_CAN))
 		_vm->_dialogs->show(60834);
-	else if (_action.isAction(VERB_LOOK, 0x407))
+	else if (_action.isAction(VERB_LOOK, NOUN_CAR_LIFT))
 		_vm->_dialogs->show(60835);
-	else if (_action.isAction(VERB_LOOK, 0x47) || _action.isAction(VERB_LOOK, 0x4A0))
+	else if (_action.isAction(VERB_LOOK, NOUN_CHAIR) || _action.isAction(VERB_LOOK, NOUN_HAT))
 		_vm->_dialogs->show(60836);
-	else if (_action.isAction(VERB_LOOK, 0x41E))
+	else if (_action.isAction(VERB_LOOK, NOUN_DANGER_ZONE))
 		_vm->_dialogs->show(60838);
 	else
 		return;
@@ -2586,9 +2586,9 @@ void Scene609::preActions() {
 }
 
 void Scene609::actions() {
-	if (_action.isAction(VERB_WALK_TOWARDS, 0x423))
+	if (_action.isAction(VERB_WALK_TOWARDS, NOUN_ALLEY))
 		_scene->_nextSceneId = 611;
-	else if (_action.isAction(VERB_WALK_THROUGH, 0x425)) {
+	else if (_action.isAction(VERB_WALK_THROUGH, NOUN_VIDEO_STORE_DOOR)) {
 		if (!_globals[kBeenInVideoStore]) {
 			switch (_game._trigger) {
 			case 0:
@@ -2672,26 +2672,26 @@ void Scene609::actions() {
 		}
 	} else if (_action._lookFlag)
 		_vm->_dialogs->show(60910);
-	else if (_action.isAction(VERB_LOOK, 0x31E))
+	else if (_action.isAction(VERB_LOOK, NOUN_STREET))
 		_vm->_dialogs->show(60911);
-	else if (_action.isAction(VERB_LOOK, 0x421))
+	else if (_action.isAction(VERB_LOOK, NOUN_SPOT_A_POT))
 		_vm->_dialogs->show(60912);
-	else if (_action.isAction(VERB_LOOK, 0x427))
+	else if (_action.isAction(VERB_LOOK, NOUN_VIDEO_STORE))
 		_vm->_dialogs->show(60913);
-	else if (_action.isAction(VERB_LOOK, 0x33A))
+	else if (_action.isAction(VERB_LOOK, NOUN_BILLBOARD))
 		_vm->_dialogs->show(60914);
-	else if (_action.isAction(VERB_LOOK, 0x2CD))
+	else if (_action.isAction(VERB_LOOK, NOUN_STATUE))
 		_vm->_dialogs->show(60915);
-	else if (_action.isAction(VERB_LOOK, 0x324))
+	else if (_action.isAction(VERB_LOOK, NOUN_CAR))
 		_vm->_dialogs->show(60916);
-	else if (_action.isAction(VERB_LOOK, 0x41F))
+	else if (_action.isAction(VERB_LOOK, NOUN_NEWSSTAND))
 		_vm->_dialogs->show(60917);
-	else if (_action.isAction(VERB_LOOK, 0x425)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_VIDEO_STORE_DOOR)) {
 		if (!_globals[kBeenInVideoStore])
 			_vm->_dialogs->show(60918);
 		else
 			_vm->_dialogs->show(60919);
-	} else if (_action.isAction(VERB_WALK_DOWN, 0x31E))
+	} else if (_action.isAction(VERB_WALK_DOWN, NOUN_STREET))
 		_vm->_dialogs->show(60730);
 	else
 		return;
@@ -2763,9 +2763,9 @@ void Scene610::step() {
 }
 
 void Scene610::actions() {
-	if (_action.isAction(VERB_EXIT_FROM, 0x427))
+	if (_action.isAction(VERB_EXIT_FROM, NOUN_VIDEO_STORE))
 		_scene->_nextSceneId = 609;
-	else if (_action.isAction(VERB_TAKE, 0x108)) {
+	else if (_action.isAction(VERB_TAKE, NOUN_PHONE_HANDSET)) {
 		if ( _game._trigger || !_game._objects.isInInventory(OBJ_PHONE_HANDSET)) {
 			switch (_game._trigger) {
 			case 0:
@@ -2796,7 +2796,7 @@ void Scene610::actions() {
 				break;
 			}
 		}
-	} else if (_action.isAction(VERB_PUT, 0x108, 0x42F)) {
+	} else if (_action.isAction(VERB_PUT, NOUN_PHONE_HANDSET, 0x42F)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -2828,42 +2828,42 @@ void Scene610::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_LOOK, 0x442))
+	} else if (_action.isAction(VERB_LOOK, NOUN_PIPPY_BILLBOARD))
 		_vm->_dialogs->show(61010);
-	else if (_action.isAction(VERB_LOOK, 0x44B))
+	else if (_action.isAction(VERB_LOOK, NOUN_CIVILIZATION_AD))
 		_vm->_dialogs->show(61011);
-	else if (_action.isAction(VERB_LOOK, 0x441))
+	else if (_action.isAction(VERB_LOOK, NOUN_MARX_BROS_POSTER))
 		_vm->_dialogs->show(61012);
-	else if (_action.isAction(VERB_LOOK, 0x43C))
+	else if (_action.isAction(VERB_LOOK, NOUN_VIDEO_MONITOR))
 		_vm->_dialogs->show(61013);
-	else if (_action.isAction(VERB_LOOK, 0x427))
+	else if (_action.isAction(VERB_LOOK, NOUN_VIDEO_STORE))
 		_vm->_dialogs->show(61014);
 	else if (_action._lookFlag)
 		_vm->_dialogs->show(61015);
-	else if (_action.isAction(VERB_LOOK, 0x4A1))
+	else if (_action.isAction(VERB_LOOK, NOUN_LOGO))
 		_vm->_dialogs->show(61018);
-	else if (_action.isAction(VERB_LOOK, 0x498)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_CEMENT)) {
 		if (_game._visitedScenes.exists(601))
 			_vm->_dialogs->show(61020);
 		else
 			_vm->_dialogs->show(61019);
-	} else if (_action.isAction(VERB_LOOK, 0x29F))
+	} else if (_action.isAction(VERB_LOOK, NOUN_COUNTER))
 		_vm->_dialogs->show(61021);
-	else if (_action.isAction(VERB_LOOK, 0x429))
+	else if (_action.isAction(VERB_LOOK, NOUN_PHONE_ANTENNA))
 		_vm->_dialogs->show(61022);
-	else if (_action.isAction(VERB_LOOK, 0x42D))
+	else if (_action.isAction(VERB_LOOK, NOUN_SMELLY_SNEAKER))
 		_vm->_dialogs->show(61023);
-	else if (_action.isAction(VERB_TAKE, 0x42D))
+	else if (_action.isAction(VERB_TAKE, NOUN_SMELLY_SNEAKER))
 		_vm->_dialogs->show(61024);
-	else if (_action.isAction(VERB_LOOK, 0x431))
+	else if (_action.isAction(VERB_LOOK, NOUN_SPOTLIGHT))
 		_vm->_dialogs->show(61025);
-	else if (_action.isAction(VERB_LOOK, 0x108) && (_action._mainObjectSource == 4))
+	else if (_action.isAction(VERB_LOOK, NOUN_PHONE_HANDSET) && (_action._mainObjectSource == 4))
 		_vm->_dialogs->show(61026);
-	else if (_action.isAction(VERB_LOOK, 0x42F))
+	else if (_action.isAction(VERB_LOOK, NOUN_PHONE_CRADLE))
 		_vm->_dialogs->show(61027);
-	else if (_action.isAction(VERB_LOOK, 0x42A))
+	else if (_action.isAction(VERB_LOOK, NOUN_RETURN_SLOT))
 		_vm->_dialogs->show(61028);
-	else if (_action.isAction(VERB_PUT, 0x42A)
+	else if (_action.isAction(VERB_PUT, NOUN_RETURN_SLOT)
 		&& _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId)))
 		_vm->_dialogs->show(61029);
 	else if ( _action.isAction(0x44F) || _action.isAction(0x444) || _action.isAction(0x430)
@@ -4130,7 +4130,7 @@ void Scene611::step() {
 }
 
 void Scene611::preActions() {
-	if (_action.isAction(VERB_WALK_DOWN, 0x423))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_ALLEY))
 		_game._player._walkOffScreenSceneId = 609;
 
 	if (_resetBatterieText)
@@ -4140,11 +4140,11 @@ void Scene611::preActions() {
 void Scene611::actions() {
 	if (_game._screenObjects._inputMode == 1)
 		handleDialog();
-	else if ((_action.isAction(VERB_GIVE, 0x107, 0x45A)) || (_action.isAction(VERB_GIVE, 0x73, 0x45A))) {
+	else if ((_action.isAction(VERB_GIVE, NOUN_PHONE_CELLS, 0x45A)) || (_action.isAction(VERB_GIVE, NOUN_DURAFAIL_CELLS, 0x45A))) {
 		_action._activeAction._verbId = 0x294;
 		_giveBatteriesFl = true;
 		handleSubDialog1();
-	} else if (_action.isAction(VERB_GIVE, 0x45A)) {
+	} else if (_action.isAction(VERB_GIVE, NOUN_HERMIT)) {
 		_scene->_kernelMessages.reset();
 
 		Common::String curQuote = _game.getQuote(0x323);
@@ -4182,7 +4182,7 @@ void Scene611::actions() {
 			_dialog2.start();
 			_duringDialogFl = true;
 		}
-	} else if (_action.isAction(VERB_TALKTO, 0x45A)) {
+	} else if (_action.isAction(VERB_TALKTO, NOUN_HERMIT)) {
 		if (!_dialog1.read(0x287)) {
 			_scene->_kernelMessages.reset();
 			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x27A));
@@ -4227,29 +4227,29 @@ void Scene611::actions() {
 			_vm->_dialogs->show(61111);
 		else
 			_vm->_dialogs->show(61110);
-	} else if (_action.isAction(VERB_LOOK, 0x45A))
+	} else if (_action.isAction(VERB_LOOK, NOUN_HERMIT))
 		_vm->_dialogs->show(61112);
-	else if (_action.isAction(VERB_LOOK, 0x25C))
+	else if (_action.isAction(VERB_LOOK, NOUN_TRASH))
 		_vm->_dialogs->show(61113);
-	else if (_action.isAction(VERB_TAKE, 0x25C))
+	else if (_action.isAction(VERB_TAKE, NOUN_TRASH))
 		_vm->_dialogs->show(61114);
-	else if (_action.isAction(VERB_LOOK, 0x49A))
+	else if (_action.isAction(VERB_LOOK, NOUN_CARDBOARD_BOX))
 		_vm->_dialogs->show(61115);
-	else if (_action.isAction(VERB_TAKE, 0x49A))
+	else if (_action.isAction(VERB_TAKE, NOUN_CARDBOARD_BOX))
 		_vm->_dialogs->show(61116);
-	else if (_action.isAction(VERB_OPEN, 0x49A))
+	else if (_action.isAction(VERB_OPEN, NOUN_CARDBOARD_BOX))
 		_vm->_dialogs->show(61117);
-	else if (_action.isAction(VERB_LOOK, 0x122))
+	else if (_action.isAction(VERB_LOOK, NOUN_REFRIGERATOR))
 		_vm->_dialogs->show(61118);
-	else if (_action.isAction(VERB_OPEN, 0x122))
+	else if (_action.isAction(VERB_OPEN, NOUN_REFRIGERATOR))
 		_vm->_dialogs->show(61119);
-	else if (_action.isAction(VERB_TAKE, 0x122))
+	else if (_action.isAction(VERB_TAKE, NOUN_REFRIGERATOR))
 		_vm->_dialogs->show(61120);
-	else if (_action.isAction(VERB_LOOK, 0x323))
+	else if (_action.isAction(VERB_LOOK, NOUN_BUILDING))
 		_vm->_dialogs->show(61121);
-	else if (_action.isAction(VERB_LOOK, 0x49C))
+	else if (_action.isAction(VERB_LOOK, NOUN_GRAFFITI))
 		_vm->_dialogs->show(61122);
-	else if (_action.isAction(VERB_LOOK, 0x45B))
+	else if (_action.isAction(VERB_LOOK, NOUN_METAL_PIPE))
 		_vm->_dialogs->show(61123);
 	else
 		return;
@@ -4428,37 +4428,37 @@ void Scene612::actions() {
 		_cycleIndex = -2;
 		action = 1;
 		handleWinchMovement();
-	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x466))
+	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, NOUN_EXPRESSWAY))
 		_vm->_dialogs->show(61210);
-	else if (_action.isAction(VERB_LOOK, 0x347) || _action.isAction(VERB_LOOK, 0x45E)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_ROPE) || _action.isAction(VERB_LOOK, NOUN_ARMATURE)) {
 		if (_globals[kBoatRaised])
 			_vm->_dialogs->show(61211);
 		else
 			_vm->_dialogs->show(61212);
-	} else if (_action.isAction(VERB_TAKE, 0x347))
+	} else if (_action.isAction(VERB_TAKE, NOUN_ROPE))
 		_vm->_dialogs->show(61213);
-	else if (_action.isAction(VERB_LOOK, 0x45F)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_CONTROL_BOX)) {
 		if (_globals[kBoatRaised])
 			_vm->_dialogs->show(61214);
 		else
 			_vm->_dialogs->show(61216);
-	} else if (_action.isAction(VERB_OPEN, 0x45F))
+	} else if (_action.isAction(VERB_OPEN, NOUN_CONTROL_BOX))
 		_vm->_dialogs->show(61215);
-	else if (_action.isAction(VERB_LOOK, 0x33D))
+	else if (_action.isAction(VERB_LOOK, NOUN_BUILDINGS))
 		_vm->_dialogs->show(61218);
-	else if (_action.isAction(VERB_LOOK, 0x464))
+	else if (_action.isAction(VERB_LOOK, NOUN_DOME))
 		_vm->_dialogs->show(61219);
-	else if (_action.isAction(VERB_LOOK, 0x2CD))
+	else if (_action.isAction(VERB_LOOK, NOUN_STATUE))
 		_vm->_dialogs->show(61220);
-	else if (_action.isAction(VERB_LOOK, 0x4A2))
+	else if (_action.isAction(VERB_LOOK, NOUN_MAINTENANCE_BUILDING))
 		_vm->_dialogs->show(61221);
-	else if (_action.isAction(VERB_OPEN, 0x4A2))
+	else if (_action.isAction(VERB_OPEN, NOUN_MAINTENANCE_BUILDING))
 		_vm->_dialogs->show(61222);
-	else if (_action.isAction(VERB_LOOK, 0x18D))
+	else if (_action.isAction(VERB_LOOK, NOUN_WALL))
 		_vm->_dialogs->show(61223);
-	else if (_action.isAction(VERB_LOOK, 0x257))
+	else if (_action.isAction(VERB_LOOK, NOUN_SUPPORT))
 		_vm->_dialogs->show(61224);
-	else if (_action.isAction(VERB_WALK_DOWN, 0x461) || _action.isAction(VERB_WALK_DOWN, 0x463))
+	else if (_action.isAction(VERB_WALK_DOWN, NOUN_EXPRESSWAY_TO_EAST) || _action.isAction(VERB_WALK_DOWN, NOUN_EXPRESSWAY_TO_WEST))
 		_vm->_dialogs->show(61225);
 	else
 		return;
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 2d85b2e..a4dd432 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -1010,57 +1010,57 @@ void Scene703::actions() {
 			_curSequence = 4;
 		else
 			_curSequence = 1;
-	} else if (_action.isAction(VERB_THROW, 0x2C, 0x468) || _action.isAction(VERB_THROW, 0x2D, 0x468)) {
+	} else if (_action.isAction(VERB_THROW, NOUN_BONE, 0x468) || _action.isAction(VERB_THROW, NOUN_BONES, 0x468)) {
 		_game._player._stepEnabled = false;
 		_scene->freeAnimation();
 		_monsterMode = 2;
 		_scene->loadAnimation(formAnimName('C', -1));
 		_scene->_activeAnimation->setCurrentFrame(19);
-	} else if (_action.isAction(VERB_THROW, 0x49, 0x468)) {
+	} else if (_action.isAction(VERB_THROW, NOUN_CHICKEN, 0x468)) {
 		_game._player._stepEnabled = false;
 		_scene->freeAnimation();
 		_monsterMode = 2;
 		_scene->loadAnimation(formAnimName('C', -1));
-	} else if (_action.isAction(VERB_THROW, 0x17A, 0x468)) {
+	} else if (_action.isAction(VERB_THROW, NOUN_TWINKIFRUIT, 0x468)) {
 		_game._player._stepEnabled = false;
 		_scene->freeAnimation();
 		_monsterMode = 2;
 		_scene->loadAnimation(formAnimName('C', -1));
 		_scene->_activeAnimation->setCurrentFrame(39);
-	} else if (_action.isAction(VERB_THROW, 0x2A, 0x468)) {
+	} else if (_action.isAction(VERB_THROW, NOUN_BOMB, 0x468)) {
 		_game._player._stepEnabled = false;
 		_scene->freeAnimation();
 		_monsterMode = 2;
 		_scene->loadAnimation(formAnimName('C', -1));
 		_scene->_activeAnimation->setCurrentFrame(59);
-	} else if (_action.isAction(VERB_THROW, 0x4A, 0x468)) {
+	} else if (_action.isAction(VERB_THROW, NOUN_CHICKEN_BOMB, 0x468)) {
 		_useBomb = true;
 		_game._player._stepEnabled = false;
 		_scene->freeAnimation();
 		_monsterMode = 2;
 		_scene->loadAnimation(formAnimName('C', -1));
-	} else if (_action.isAction(VERB_PUT, 0x2E, 0x18F) || _action.isAction(0x85, 0x2E, 0x18F)) {
+	} else if (_action.isAction(VERB_PUT, NOUN_BOTTLE, 0x18F) || _action.isAction(0x85, 0x2E, 0x18F)) {
 		if (_globals[kBottleStatus] != 4) {
 			handleBottleInterface();
 			_dialog1.start();
 		} else
 			_vm->_dialogs->show(70323);
-	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x468)) {
+	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, NOUN_SEA_MONSTER)) {
 		if (_globals[kMonsterAlive])
 			_vm->_dialogs->show(70310);
-	} else if (_action.isAction(VERB_LOOK, 0x18F)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_WATER)) {
 		if (!_globals[kMonsterAlive])
 			_vm->_dialogs->show(70311);
 		else
 			_vm->_dialogs->show(70312);
-	} else if (_action.isAction(VERB_LOOK, 0x3B2)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_BUILDING_TO_NORTH)) {
 		if (_globals[kMonsterAlive])
 			_vm->_dialogs->show(70313);
 		else if (_game._visitedScenes.exists(710))
 			_vm->_dialogs->show(70314);
 		else
 			_vm->_dialogs->show(70315);
-	} else if (_action.isAction(VERB_LOOK, 0x3B3))
+	} else if (_action.isAction(VERB_LOOK, NOUN_VOLCANO_RIM))
 		_vm->_dialogs->show(70316);
 	else
 		return;
@@ -1367,7 +1367,7 @@ void Scene704::actions() {
 			_animationMode = 4;
 		else
 			_animationMode = 1;
-	} else if (_action.isAction(VERB_TAKE, 0x2E)) {
+	} else if (_action.isAction(VERB_TAKE, NOUN_BOTTLE)) {
 		if (!_game._objects.isInInventory(OBJ_BOTTLE)) {
 			_game._player._stepEnabled = false;
 			_takeBottleFl = true;
@@ -1377,7 +1377,7 @@ void Scene704::actions() {
 				_animationMode = 7;
 			}
 		}
-	} else if (_action.isAction(VERB_PUT, 0x2E, 0x18F) || _action.isAction(0x85, 0x2E, 0x18F)) {
+	} else if (_action.isAction(VERB_PUT, NOUN_BOTTLE, 0x18F) || _action.isAction(0x85, 0x2E, 0x18F)) {
 		if (_game._objects.isInInventory(OBJ_BOTTLE)) {
 			if (_globals[kBottleStatus] != 4) {
 				_takeBottleFl = false;
@@ -1386,20 +1386,20 @@ void Scene704::actions() {
 			} else
 				_vm->_dialogs->show(70323);
 		}
-	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x18F))
+	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, NOUN_WATER))
 		_vm->_dialogs->show(70410);
-	else if (_action.isAction(VERB_LOOK, 0x3B2)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_BUILDING_TO_NORTH)) {
 		if (_game._visitedScenes.exists(710))
 			_vm->_dialogs->show(70411);
 		else
 			_vm->_dialogs->show(70412);
-	} else if (_action.isAction(VERB_LOOK, 0x3B3))
+	} else if (_action.isAction(VERB_LOOK, NOUN_VOLCANO_RIM))
 		_vm->_dialogs->show(70413);
-	else if (_action.isAction(VERB_LOOK, 0x2E) && (_action._mainObjectSource == 4))
+	else if (_action.isAction(VERB_LOOK, NOUN_BOTTLE) && (_action._mainObjectSource == 4))
 		_vm->_dialogs->show(70414);
-	else if (_action.isAction(VERB_LOOK, 0x3B4))
+	else if (_action.isAction(VERB_LOOK, NOUN_OPEN_WATER_TO_SOUTH))
 		_vm->_dialogs->show(70416);
-	else if (_action.isAction(VERB_LOOK, 0x142))
+	else if (_action.isAction(VERB_LOOK, NOUN_SKY))
 		_vm->_dialogs->show(70417);
 	else
 		return;
@@ -1625,7 +1625,7 @@ void Scene705::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_CLIMB_THROUGH, 0x197)) {
+	} else if (_action.isAction(VERB_CLIMB_THROUGH, NOUN_WINDOW)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1647,23 +1647,23 @@ void Scene705::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(0x85, 0x2E, 0x18F) || _action.isAction(VERB_PUT, 0x2E, 0x18F)) {
+	} else if (_action.isAction(0x85, 0x2E, 0x18F) || _action.isAction(VERB_PUT, NOUN_BOTTLE, 0x18F)) {
 		if (_globals[kBottleStatus] != 4) {
 			handleBottleInterface();
 			_dialog1.start();
 		} else
 			_vm->_dialogs->show(70323);
-	} if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x18F))
+	} if (_action._lookFlag || _action.isAction(VERB_LOOK, NOUN_WATER))
 		_vm->_dialogs->show(70511);
-	else if (_action.isAction(VERB_LOOK, 0x3B3))
+	else if (_action.isAction(VERB_LOOK, NOUN_VOLCANO_RIM))
 		_vm->_dialogs->show(70512);
-	else if (_action.isAction(VERB_LOOK, 0x3B4))
+	else if (_action.isAction(VERB_LOOK, NOUN_OPEN_WATER_TO_SOUTH))
 		_vm->_dialogs->show(70513);
-	else if (_action.isAction(VERB_LOOK, 0x142))
+	else if (_action.isAction(VERB_LOOK, NOUN_SKY))
 		_vm->_dialogs->show(70514);
-	else if (_action.isAction(VERB_LOOK, 0x323))
+	else if (_action.isAction(VERB_LOOK, NOUN_BUILDING))
 		_vm->_dialogs->show(70515);
-	else if (_action.isAction(VERB_LOOK, 0x197))
+	else if (_action.isAction(VERB_LOOK, NOUN_WINDOW))
 		_vm->_dialogs->show(70516);
 	else
 		return;
@@ -1845,12 +1845,12 @@ void Scene706::step() {
 }
 
 void Scene706::preActions() {
-	if (_action.isAction(VERB_LOOK, 0x46E))
+	if (_action.isAction(VERB_LOOK, NOUN_PORTRAIT))
 		_game._player._needToWalk = true;
 }
 
 void Scene706::actions() {
-	if (_action.isAction(VERB_WALK_INSIDE, 0x16C)) {
+	if (_action.isAction(VERB_WALK_INSIDE, NOUN_TELEPORTER)) {
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
 		_scene->_nextSceneId = 707;
@@ -1858,13 +1858,13 @@ void Scene706::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_EXIT, 0x2FA)) {
+	if (_action.isAction(VERB_EXIT, NOUN_ROOM)) {
 		_scene->_nextSceneId = 705;
 		_action._inProgress = false;
 		return;
 	}
 
-	if (_action.isAction(VERB_TAKE, 0x17D)) {
+	if (_action.isAction(VERB_TAKE, NOUN_VASE)) {
 		if (_game._difficulty != DIFFICULTY_EASY) {
 			_animationMode = 1;
 			handleRexDeath();
@@ -1876,7 +1876,7 @@ void Scene706::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_PUT, 0x2E, 0x344)) {
+	if (_action.isAction(VERB_PUT, NOUN_BOTTLE, 0x344)) {
 		if ((_globals[kBottleStatus] == 2 && _game._difficulty == DIFFICULTY_HARD) ||
 			 (_globals[kBottleStatus] != 0 && _game._difficulty != DIFFICULTY_HARD)) {
 			if (!_game._objects.isInInventory(OBJ_VASE) || _game._trigger) {
@@ -1893,47 +1893,47 @@ void Scene706::actions() {
 		}
 	}
 
-	if (_action.isAction(VERB_PUT, 0x344) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
+	if (_action.isAction(VERB_PUT, NOUN_PEDESTAL) && _game._objects.isInInventory(_game._objects.getIdFromDesc(_action._activeAction._objectNameId))) {
 		int objectId = _game._objects.getIdFromDesc(_action._activeAction._objectNameId);
 		if (_game._objects[objectId].hasQuality(10))
 			_vm->_dialogs->show(70626);
 		else
 			_vm->_dialogs->show(70627);
-	} else if (_action.isAction(VERB_TAKE, 0x2E) && _game._objects.isInInventory(OBJ_VASE))
+	} else if (_action.isAction(VERB_TAKE, NOUN_BOTTLE) && _game._objects.isInInventory(OBJ_VASE))
 		_vm->_dialogs->show(70631);
 	else if (_action._lookFlag) {
 		if (_game._objects[OBJ_VASE]._roomNumber == _scene->_currentSceneId)
 			_vm->_dialogs->show(70610);
 		else
 			_vm->_dialogs->show(70611);
-	} else if (_action.isAction(VERB_LOOK, 0x89))
+	} else if (_action.isAction(VERB_LOOK, NOUN_FLOOR))
 		_vm->_dialogs->show(70612);
-	else if (_action.isAction(VERB_LOOK, 0x32B))
+	else if (_action.isAction(VERB_LOOK, NOUN_PILLAR))
 		_vm->_dialogs->show(70613);
-	else if (_action.isAction(VERB_LOOK, 0x46B))
+	else if (_action.isAction(VERB_LOOK, NOUN_OLD_TEA_CUP))
 		_vm->_dialogs->show(70614);
-	else if (_action.isAction(VERB_TAKE, 0x46B))
+	else if (_action.isAction(VERB_TAKE, NOUN_OLD_TEA_CUP))
 		_vm->_dialogs->show(70615);
-	else if (_action.isAction(VERB_LOOK, 0x46D))
+	else if (_action.isAction(VERB_LOOK, NOUN_OLD_VASE))
 		_vm->_dialogs->show(70616);
-	else if (_action.isAction(VERB_LOOK, 0x46E))
+	else if (_action.isAction(VERB_LOOK, NOUN_PORTRAIT))
 		_vm->_dialogs->show(70617);
-	else if (_action.isAction(VERB_LOOK, 0x46C))
+	else if (_action.isAction(VERB_LOOK, NOUN_NAME_PLATE))
 		_vm->_dialogs->show(70618);
-	else if (_action.isAction(VERB_LOOK, 0x18D))
+	else if (_action.isAction(VERB_LOOK, NOUN_WALL))
 		_vm->_dialogs->show(70619);
-	else if (_action.isAction(VERB_LOOK, 0x344)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_PEDESTAL)) {
 		if (_game._objects[OBJ_VASE]._roomNumber == _scene->_currentSceneId)
 			_vm->_dialogs->show(70620);
 		else if (_game._objects[OBJ_BOTTLE]._roomNumber == _scene->_currentSceneId)
 			_vm->_dialogs->show(70622);
 		else
 			_vm->_dialogs->show(70621);
-	} else if (_action.isAction(VERB_LOOK, 0x16C))
+	} else if (_action.isAction(VERB_LOOK, NOUN_TELEPORTER))
 		_vm->_dialogs->show(70623);
-	else if (_action.isAction(VERB_LOOK, 0x17D) && (_game._objects[OBJ_VASE]._roomNumber == _scene->_currentSceneId))
+	else if (_action.isAction(VERB_LOOK, NOUN_VASE) && (_game._objects[OBJ_VASE]._roomNumber == _scene->_currentSceneId))
 		_vm->_dialogs->show(70624);
-	else if (_action.isAction(VERB_LOOK, 0x2E) && (_action._mainObjectSource == 4))
+	else if (_action.isAction(VERB_LOOK, NOUN_BOTTLE) && (_action._mainObjectSource == 4))
 		_vm->_dialogs->show(70632);
 	else
 		return;
@@ -1970,21 +1970,21 @@ void Scene707::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x181) || _action.isAction(VERB_PEER_THROUGH, 0x181))
+	if (_action.isAction(VERB_LOOK, NOUN_VIEWPORT) || _action.isAction(VERB_PEER_THROUGH, NOUN_VIEWPORT))
 		_vm->_dialogs->show(70710);
-	else if (_action.isAction(VERB_LOOK, 0xC4))
+	else if (_action.isAction(VERB_LOOK, NOUN_KEYPAD))
 		_vm->_dialogs->show(70711);
-	else if (_action.isAction(VERB_LOOK, 0x1CC))
+	else if (_action.isAction(VERB_LOOK, NOUN_DISPLAY))
 		_vm->_dialogs->show(70712);
-	else if (_action.isAction(VERB_LOOK, 0x1D0) || _action.isAction(VERB_LOOK, 0x1D1)
-	 || _action.isAction(VERB_LOOK, 0x1D2) || _action.isAction(VERB_LOOK, 0x1D3)
-	 || _action.isAction(VERB_LOOK, 0x1D4) || _action.isAction(VERB_LOOK, 0x1D5)
-	 || _action.isAction(VERB_LOOK, 0x1D6) || _action.isAction(VERB_LOOK, 0x1D7)
-	 || _action.isAction(VERB_LOOK, 0x1D8) || _action.isAction(VERB_LOOK, 0x1D9)
-	 || _action.isAction(VERB_LOOK, 0x1DB) || _action.isAction(VERB_LOOK, 0x7A)
-	 || _action.isAction(VERB_LOOK, 0x1DA))
+	else if (_action.isAction(VERB_LOOK, NOUN_0_KEY) || _action.isAction(VERB_LOOK, NOUN_1_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_2_KEY) || _action.isAction(VERB_LOOK, NOUN_3_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_4_KEY) || _action.isAction(VERB_LOOK, NOUN_5_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_6_KEY) || _action.isAction(VERB_LOOK, NOUN_7_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_8_KEY) || _action.isAction(VERB_LOOK, NOUN_9_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_SMILE_KEY) || _action.isAction(VERB_LOOK, NOUN_ENTER_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_FROWN_KEY))
 		_vm->_dialogs->show(70713);
-	else if (_action.isAction(VERB_LOOK, 0x1CF) || _action._lookFlag)
+	else if (_action.isAction(VERB_LOOK, NOUN_DEVICE) || _action._lookFlag)
 		_vm->_dialogs->show(70714);
 	else
 		return;
@@ -2214,13 +2214,13 @@ void Scene751::step() {
 }
 
 void Scene751::preActions() {
-	if (_action.isAction(VERB_LOOK, 0x470))
+	if (_action.isAction(VERB_LOOK, NOUN_TALL_BUILDING))
 		_game._player.walk(Common::Point(154, 129), FACING_NORTHEAST);
 
-	if (_action.isAction(VERB_LOOK, 0x27, 0x470))
+	if (_action.isAction(VERB_LOOK, NOUN_BINOCULARS, 0x470))
 		_game._player.walk(Common::Point(154, 129), FACING_NORTH);
 
-	if (_action.isAction(VERB_WALKTO, 0x4AA))
+	if (_action.isAction(VERB_WALKTO, NOUN_EAST_END_OF_PLATFORM))
 		_game._player._walkOffScreenSceneId = 752;
 
 	if (!_rexHandingLine)
@@ -2229,7 +2229,7 @@ void Scene751::preActions() {
 	if (_action.isAction(VERB_LOOK) || _action.isAction(0x87) || _action.isAction(VERB_TALKTO))
 		_game._player._needToWalk = false;
 
-	if ((!_action.isAction(VERB_PUT, 0x87, 0x467) || !_action.isAction(0x170, 0x87, 0x467) || !_action.isAction(0x19, 0x87, 0x467))
+	if ((!_action.isAction(VERB_PUT, NOUN_FISHING_LINE, 0x467) || !_action.isAction(0x170, 0x87, 0x467) || !_action.isAction(0x19, 0x87, 0x467))
 	&& (_game._player._needToWalk)) {
 		switch (_game._trigger) {
 		case 0:
@@ -2256,9 +2256,9 @@ void Scene751::preActions() {
 }
 
 void Scene751::actions() {
-	if (_action.isAction(VERB_WALK_ALONG, 0x22C))
+	if (_action.isAction(VERB_WALK_ALONG, NOUN_PLATFORM))
 		; // Nothing
-	else if (_action.isAction(VERB_LOOK, 0x27, 0x470)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_BINOCULARS, 0x470)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -2284,7 +2284,7 @@ void Scene751::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_STEP_INTO, 0x317)) {
+	} else if (_action.isAction(VERB_STEP_INTO, NOUN_ELEVATOR)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -2326,7 +2326,7 @@ void Scene751::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_PUT, 0x87, 0x467) || _action.isAction(0x170, 0x87, 0x467) || _action.isAction(0x19, 0x87, 0x467)) {
+	} else if (_action.isAction(VERB_PUT, NOUN_FISHING_LINE, 0x467) || _action.isAction(0x170, 0x87, 0x467) || _action.isAction(0x19, 0x87, 0x467)) {
 		if (_globals[kLineStatus] == 1) {
 			switch (_game._trigger) {
 			case 0:
@@ -2374,28 +2374,28 @@ void Scene751::actions() {
 				break;
 			}
 		}
-	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, 0x38F))
+	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, NOUN_CITY))
 		_vm->_dialogs->show(75110);
-	else if (_action.isAction(VERB_LOOK, 0x317))
+	else if (_action.isAction(VERB_LOOK, NOUN_ELEVATOR))
 		_vm->_dialogs->show(75112);
-	else if (_action.isAction(VERB_LOOK, 0x22C))
+	else if (_action.isAction(VERB_LOOK, NOUN_PLATFORM))
 		_vm->_dialogs->show(75113);
-	else if (_action.isAction(VERB_LOOK, 0x316))
+	else if (_action.isAction(VERB_LOOK, NOUN_CEMENT_PYLON))
 		_vm->_dialogs->show(75114);
-	else if ((_action.isAction(VERB_LOOK, 0x467) || _action.isAction(VERB_LOOK, 0x87))
+	else if ((_action.isAction(VERB_LOOK, NOUN_HOOK) || _action.isAction(VERB_LOOK, NOUN_FISHING_LINE))
 		&& (_globals[kLineStatus] == 2 || _globals[kLineStatus] == 3))
 		_vm->_dialogs->show(75116);
-	else if (_action.isAction(VERB_LOOK, 0x467))
+	else if (_action.isAction(VERB_LOOK, NOUN_HOOK))
 		_vm->_dialogs->show(75115);
-	else if (_action.isAction(VERB_LOOK, 0x128))
+	else if (_action.isAction(VERB_LOOK, NOUN_ROCK))
 		_vm->_dialogs->show(75117);
-	else if (_action.isAction(VERB_TAKE, 0x128))
+	else if (_action.isAction(VERB_TAKE, NOUN_ROCK))
 		_vm->_dialogs->show(75118);
-	else if (_action.isAction(VERB_LOOK, 0x4AA))
+	else if (_action.isAction(VERB_LOOK, NOUN_EAST_END_OF_PLATFORM))
 		_vm->_dialogs->show(75119);
-	else if (_action.isAction(VERB_TAKE, 0x87) && (_globals[kLineStatus] == 3 || _globals[kLineStatus] == 2))
+	else if (_action.isAction(VERB_TAKE, NOUN_FISHING_LINE) && (_globals[kLineStatus] == 3 || _globals[kLineStatus] == 2))
 		_vm->_dialogs->show(75121);
-	else if (_action.isAction(VERB_LOOK, 0x470))
+	else if (_action.isAction(VERB_LOOK, NOUN_TALL_BUILDING))
 		_vm->_dialogs->show(75122);
 	else if (_action.isAction(0x170, 0x87, 0x316) || _action.isAction(0x19, 0x87, 0x316))
 		_vm->_dialogs->show(75123);
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 6ecde8a..3604c8b 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -243,13 +243,13 @@ void Scene801::step() {
 }
 
 void Scene801::preActions() {
-	if (_action.isAction(VERB_LOOK, 0x59)) {
+	if (_action.isAction(VERB_LOOK, NOUN_CONTROL_PANEL)) {
 		_game._player.walk(Common::Point(148, 110), FACING_NORTH);
 		_game._player._needToWalk = true;
 		_game._player._readyToWalk = true;
 	}
 
-	if (_action.isAction(VERB_WALK_INSIDE, 0x16C) && _globals[kBeamIsUp]) {
+	if (_action.isAction(VERB_WALK_INSIDE, NOUN_TELEPORTER) && _globals[kBeamIsUp]) {
 		_globals[kCutX] = _game._player._playerPos.x;
 		_globals[kCutY] = _game._player._playerPos.y;
 		_globals[kCutFacing] = _game._player._facing;
@@ -260,13 +260,13 @@ void Scene801::preActions() {
 }
 
 void Scene801::actions() {
-	if (_action.isAction(VERB_LOOK, 0x59))
+	if (_action.isAction(VERB_LOOK, NOUN_CONTROL_PANEL))
 		_scene->_nextSceneId = 808;
-	else if (_action.isAction(VERB_WALK_INSIDE, 0x16C)) {
+	else if (_action.isAction(VERB_WALK_INSIDE, NOUN_TELEPORTER)) {
 		_game._player._stepEnabled = false;
 		_game._player._visible = false;
 		_scene->_nextSceneId = 807;
-	} else if (_action.isAction(VERB_WALK_THROUGH, 0x6E) && (_game._player._playerPos == Common::Point(270, 118))) {
+	} else if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR) && (_game._player._playerPos == Common::Point(270, 118))) {
 		_game._player._stepEnabled = false;
 		_game._player._facing = FACING_EAST;
 		_game._player.selectSeries();
@@ -278,21 +278,21 @@ void Scene801::actions() {
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 5);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 13);
 		_vm->_sound->command(11);
-	} else if (_action.isAction(VERB_LOOK, 0x46))
+	} else if (_action.isAction(VERB_LOOK, NOUN_CEILING))
 		_vm->_dialogs->show(80110);
-	else if (_action.isAction(VERB_LOOK, 0xE2))
+	else if (_action.isAction(VERB_LOOK, NOUN_MONITOR))
 		_vm->_dialogs->show(80111);
-	else if (_action.isAction(VERB_LOOK, 0x16C))
+	else if (_action.isAction(VERB_LOOK, NOUN_TELEPORTER))
 		_vm->_dialogs->show(80112);
-	else if (_action.isAction(VERB_LOOK, 0x2C7) || _action._lookFlag)
+	else if (_action.isAction(VERB_LOOK, NOUN_EQUIPMENT) || _action._lookFlag)
 		_vm->_dialogs->show(80113);
-	else if (_action.isAction(VERB_LOOK, 0x390))
+	else if (_action.isAction(VERB_LOOK, NOUN_SPEAKER))
 		_vm->_dialogs->show(80114);
-	else if (_action.isAction(VERB_LOOK, 0x391))
+	else if (_action.isAction(VERB_LOOK, NOUN_EYE_CHART))
 		_vm->_dialogs->show(80115);
-	else if (_action.isAction(VERB_LOOK, 0x18D))
+	else if (_action.isAction(VERB_LOOK, NOUN_WALL))
 		_vm->_dialogs->show(80116);
-	else if (_action.isAction(VERB_LOOK, 0x6E))
+	else if (_action.isAction(VERB_LOOK, NOUN_DOOR))
 		_vm->_dialogs->show(80117);
 	else
 		return;
@@ -391,20 +391,20 @@ void Scene802::step() {
 }
 
 void Scene802::preActions() {
-	if (_action.isAction(VERB_WALK_TOWARDS, 0x393))
+	if (_action.isAction(VERB_WALK_TOWARDS, NOUN_BUILDING_TO_WEST))
 		_game._player._walkOffScreenSceneId = 801;
 
-	if (_action.isAction(VERB_WALK_DOWN, 0x1C1)) {
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_PATH_TO_EAST)) {
 		_game._player._walkOffScreenSceneId = 803;
 		_globals[kForceBeamDown] = false;
 	}
 
-	if (_action.isAction(VERB_TAKE, 0x139))
+	if (_action.isAction(VERB_TAKE, NOUN_SHIP))
 		_game._player._needToWalk = false;
 }
 
 void Scene802::actions() {
-	if (_action.isAction(VERB_TAKE, 0x137) && !_game._objects.isInInventory(OBJ_SHIELD_MODULATOR)) {
+	if (_action.isAction(VERB_TAKE, NOUN_SHIELD_MODULATOR) && !_game._objects.isInInventory(OBJ_SHIELD_MODULATOR)) {
 		switch (_game._trigger) {
 		case (0):
 			_game._player._stepEnabled = false;
@@ -436,7 +436,7 @@ void Scene802::actions() {
 		default:
 			break;
 		}
-	} else if ((_action.isAction(VERB_TAKE, 0x123)) && (!_game._objects.isInInventory(OBJ_REMOTE))) {
+	} else if ((_action.isAction(VERB_TAKE, NOUN_REMOTE)) && (!_game._objects.isInInventory(OBJ_REMOTE))) {
 		switch (_game._trigger) {
 		case (0):
 			_game._player._stepEnabled = false;
@@ -470,37 +470,37 @@ void Scene802::actions() {
 			break;
 		}
 	} else if (!_globals[kRemoteOnGround] && (_game._objects.isInInventory(OBJ_SHIELD_MODULATOR) || _globals[kShieldModInstalled])
-		&& (_action.isAction(VERB_LOOK, 0x392) || _action._lookFlag))
+		&& (_action.isAction(VERB_LOOK, NOUN_LAUNCH_PAD) || _action._lookFlag))
 		_vm->_dialogs->show(80210);
 	else if (!_globals[kRemoteOnGround]&& !_game._objects.isInInventory(OBJ_SHIELD_MODULATOR) && !_globals[kShieldModInstalled]
-		&& (_action.isAction(VERB_LOOK, 0x392) || _action._lookFlag))
+		&& (_action.isAction(VERB_LOOK, NOUN_LAUNCH_PAD) || _action._lookFlag))
 		_vm->_dialogs->show(80211);
 	else if (_globals[kRemoteOnGround] && !_game._objects.isInInventory(OBJ_SHIELD_MODULATOR) && !_globals[kShieldModInstalled]
-		&& (_action.isAction(VERB_LOOK, 0x392) || _action._lookFlag))
+		&& (_action.isAction(VERB_LOOK, NOUN_LAUNCH_PAD) || _action._lookFlag))
 		_vm->_dialogs->show(80213);
 	else if (_globals[kRemoteOnGround] && (_game._objects.isInInventory(OBJ_SHIELD_MODULATOR) || _globals[kShieldModInstalled])
-		&& (_action.isAction(VERB_LOOK, 0x392) || _action._lookFlag))
+		&& (_action.isAction(VERB_LOOK, NOUN_LAUNCH_PAD) || _action._lookFlag))
 		_vm->_dialogs->show(80212);
-	else if (!_game._objects.isInInventory(OBJ_SHIELD_MODULATOR) && !_globals[kShieldModInstalled] && _action.isAction(VERB_LOOK, 0x137))
+	else if (!_game._objects.isInInventory(OBJ_SHIELD_MODULATOR) && !_globals[kShieldModInstalled] && _action.isAction(VERB_LOOK, NOUN_SHIELD_MODULATOR))
 		_vm->_dialogs->show(80214);
-	else if (_globals[kRemoteOnGround] && _action.isAction(VERB_LOOK, 0x123))
+	else if (_globals[kRemoteOnGround] && _action.isAction(VERB_LOOK, NOUN_REMOTE))
 		_vm->_dialogs->show(80216);
-	else if (_action.isAction(VERB_LOOK, 0x139)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_SHIP)) {
 		if ((!_game._objects.isInInventory(OBJ_SHIELD_MODULATOR)) && (!_globals[kShieldModInstalled]))
 			_vm->_dialogs->show(80218);
 		else
 			_vm->_dialogs->show(80217);
-	} else if (_action.isAction(VERB_LOOK, 0x39))
+	} else if (_action.isAction(VERB_LOOK, NOUN_BUSHES))
 		_vm->_dialogs->show(80219);
-	else if (_action.isAction(VERB_LOOK, 0x1C1))
+	else if (_action.isAction(VERB_LOOK, NOUN_PATH_TO_EAST))
 		_vm->_dialogs->show(80220);
-	else if (_action.isAction(VERB_LOOK, 0x142))
+	else if (_action.isAction(VERB_LOOK, NOUN_SKY))
 		_vm->_dialogs->show(80221);
-	else if (_action.isAction(VERB_TAKE, 0x139))
+	else if (_action.isAction(VERB_TAKE, NOUN_SHIP))
 		_vm->_dialogs->show(80222);
-	else if (_action.isAction(VERB_LOOK, 0x174) || _action.isAction(VERB_LOOK, 0x175))
+	else if (_action.isAction(VERB_LOOK, NOUN_TREE) || _action.isAction(VERB_LOOK, NOUN_TREES))
 		_vm->_dialogs->show(80224);
-	else if (_action.isAction(VERB_LOOK, 0x393))
+	else if (_action.isAction(VERB_LOOK, NOUN_BUILDING_TO_WEST))
 		_vm->_dialogs->show(80225);
 	else
 		return;
@@ -731,15 +731,15 @@ void Scene803::step() {
 }
 
 void Scene803::preActions() {
-	if (_action.isAction(VERB_WALK_DOWN, 0x1AE))
+	if (_action.isAction(VERB_WALK_DOWN, NOUN_PATH_TO_WEST))
 		_game._player._walkOffScreenSceneId = 802;
 
-	if (_action.isAction(VERB_TAKE, 0x139))
+	if (_action.isAction(VERB_TAKE, NOUN_SHIP))
 		_game._player._needToWalk = false;
 }
 
 void Scene803::actions() {
-	if (_action.isAction(VERB_TAKE, 0x472)) {
+	if (_action.isAction(VERB_TAKE, NOUN_GUTS)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -783,7 +783,7 @@ void Scene803::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_ENTER, 0x139)) {
+	} else if (_action.isAction(VERB_ENTER, NOUN_SHIP)) {
 		_vm->_sound->command(17);
 		_game._player._stepEnabled = false;
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
@@ -792,28 +792,28 @@ void Scene803::actions() {
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 4);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 120);
 		_globals[kBeamIsUp] = false;
-	} else if (_action.isAction(VERB_LOOK, 0x392))
+	} else if (_action.isAction(VERB_LOOK, NOUN_LAUNCH_PAD))
 		_vm->_dialogs->show(80310);
 	else if (_action._lookFlag)
 		_vm->_dialogs->show(80310);
-	else if (_action.isAction(VERB_LOOK, 0x395))
+	else if (_action.isAction(VERB_LOOK, NOUN_PAD_TO_WEST))
 		_vm->_dialogs->show(80311);
-	else if (_action.isAction(VERB_LOOK, 0x472)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_GUTS)) {
 		if (_game._storyMode == STORYMODE_NICE)
 			_vm->_dialogs->show(80312);
 		else
 			_vm->_dialogs->show(80313);
-	} else if (_action.isAction(VERB_LOOK, 0x39))
+	} else if (_action.isAction(VERB_LOOK, NOUN_BUSHES))
 		_vm->_dialogs->show(80315);
-	else if (_action.isAction(VERB_LOOK, 0x139))
+	else if (_action.isAction(VERB_LOOK, NOUN_SHIP))
 		_vm->_dialogs->show(80317);
-	else if (_action.isAction(VERB_LOOK, 0x396))
+	else if (_action.isAction(VERB_LOOK, NOUN_TOWER))
 		_vm->_dialogs->show(80318);
-	else if (_action.isAction(VERB_LOOK, 0x174) || _action.isAction(VERB_LOOK, 0x175))
+	else if (_action.isAction(VERB_LOOK, NOUN_TREE) || _action.isAction(VERB_LOOK, NOUN_TREES))
 		_vm->_dialogs->show(80319);
-	else if (_action.isAction(VERB_LOOK, 0x142))
+	else if (_action.isAction(VERB_LOOK, NOUN_SKY))
 		_vm->_dialogs->show(80320);
-	else if (_action.isAction(VERB_TAKE, 0x139))
+	else if (_action.isAction(VERB_TAKE, NOUN_SHIP))
 		_vm->_dialogs->show(80321);
 	else
 		return;
@@ -1132,39 +1132,39 @@ void Scene805::preActions() {
 }
 
 void Scene805::actions() {
-	if (_action.isAction(VERB_EXIT, 0x398))
+	if (_action.isAction(VERB_EXIT, NOUN_SERVICE_PANEL))
 		_scene->_nextSceneId = 804;
-	else if (_action.isAction(VERB_INSTALL, 0x137) && _game._objects.isInInventory(OBJ_SHIELD_MODULATOR)) {
+	else if (_action.isAction(VERB_INSTALL, NOUN_SHIELD_MODULATOR) && _game._objects.isInInventory(OBJ_SHIELD_MODULATOR)) {
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 7, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], -1, -2);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
 		_game._player._stepEnabled = false;
-	} else if (_action.isAction(VERB_INSTALL, 0x167) && _game._objects.isInInventory(OBJ_TARGET_MODULE)) {
+	} else if (_action.isAction(VERB_INSTALL, NOUN_TARGET_MODULE) && _game._objects.isInInventory(OBJ_TARGET_MODULE)) {
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, -2);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
 		_game._player._stepEnabled = false;
-	} else if (_action.isAction(VERB_REMOVE, 0x137) && _globals[kShieldModInstalled]) {
+	} else if (_action.isAction(VERB_REMOVE, NOUN_SHIELD_MODULATOR) && _globals[kShieldModInstalled]) {
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 7, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], -1, -2);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
 		_game._player._stepEnabled = false;
-	} else if (_action.isAction(VERB_REMOVE, 0x167) && _globals[kTargetModInstalled]) {
+	} else if (_action.isAction(VERB_REMOVE, NOUN_TARGET_MODULE) && _globals[kTargetModInstalled]) {
 		_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 		_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -1, -2);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 81);
 		_game._player._stepEnabled = false;
-	} else if (_action.isAction(VERB_INSTALL, 0x137) && !_game._objects.isInInventory(OBJ_SHIELD_MODULATOR))
+	} else if (_action.isAction(VERB_INSTALL, NOUN_SHIELD_MODULATOR) && !_game._objects.isInInventory(OBJ_SHIELD_MODULATOR))
 		_vm->_dialogs->show(80511);
-	else if (_action.isAction(VERB_INSTALL, 0x167) && !_game._objects.isInInventory(OBJ_TARGET_MODULE))
+	else if (_action.isAction(VERB_INSTALL, NOUN_TARGET_MODULE) && !_game._objects.isInInventory(OBJ_TARGET_MODULE))
 		_vm->_dialogs->show(80510);
-	else if (_action.isAction(VERB_REMOVE, 0x475))
+	else if (_action.isAction(VERB_REMOVE, NOUN_LIFE_SUPPORT_MODULE))
 		_vm->_dialogs->show(80512);
 	else
 		return;
@@ -1205,22 +1205,22 @@ void Scene807::actions() {
 		return;
 	}
 
-	if (_action.isAction(VERB_LOOK, 0x181))
+	if (_action.isAction(VERB_LOOK, NOUN_VIEWPORT))
 		_vm->_dialogs->show(80710);
-	else if (_action.isAction(VERB_PEER_THROUGH, 0x181))
+	else if (_action.isAction(VERB_PEER_THROUGH, NOUN_VIEWPORT))
 		_vm->_dialogs->show(80710);
-	else if (_action.isAction(VERB_LOOK, 0xC4) && _action.isAction(VERB_INSPECT, 0xC4))
+	else if (_action.isAction(VERB_LOOK, NOUN_KEYPAD) && _action.isAction(VERB_INSPECT, NOUN_KEYPAD))
 		_vm->_dialogs->show(80711);
-	else if (_action.isAction(VERB_LOOK, 0x1CC))
+	else if (_action.isAction(VERB_LOOK, NOUN_DISPLAY))
 		_vm->_dialogs->show(80712);
-	else if (_action.isAction(VERB_LOOK, 0x1D1) || _action.isAction(VERB_LOOK, 0x1D2)
-	 || _action.isAction(VERB_LOOK, 0x1D3) || _action.isAction(VERB_LOOK, 0x1D4)
-	 || _action.isAction(VERB_LOOK, 0x1D5) || _action.isAction(VERB_LOOK, 0x1D6)
-	 || _action.isAction(VERB_LOOK, 0x1D7) || _action.isAction(VERB_LOOK, 0x1D8)
-	 || _action.isAction(VERB_LOOK, 0x1D9) || _action.isAction(VERB_LOOK, 0x1D0)
-	 || _action.isAction(VERB_LOOK, 0x1DB) || _action.isAction(VERB_LOOK, 0x1DA))
+	else if (_action.isAction(VERB_LOOK, NOUN_1_KEY) || _action.isAction(VERB_LOOK, NOUN_2_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_3_KEY) || _action.isAction(VERB_LOOK, NOUN_4_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_5_KEY) || _action.isAction(VERB_LOOK, NOUN_6_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_7_KEY) || _action.isAction(VERB_LOOK, NOUN_8_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_9_KEY) || _action.isAction(VERB_LOOK, NOUN_0_KEY)
+	 || _action.isAction(VERB_LOOK, NOUN_SMILE_KEY) || _action.isAction(VERB_LOOK, NOUN_FROWN_KEY))
 		_vm->_dialogs->show(80713);
-	else if (_action.isAction(VERB_LOOK, 0x1CF) && _action._lookFlag)
+	else if (_action.isAction(VERB_LOOK, NOUN_DEVICE) && _action._lookFlag)
 		_vm->_dialogs->show(80714);
 	else
 		return;
@@ -1277,7 +1277,7 @@ void Scene808::enter() {
 }
 
 void Scene808::actions() {
-	if (_action.isAction(VERB_PRESS, 0x3BC)) {
+	if (_action.isAction(VERB_PRESS, NOUN_START_BUTTON_2)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1313,7 +1313,7 @@ void Scene808::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_PRESS, 0x3BE)) {
+	} else if (_action.isAction(VERB_PRESS, NOUN_TIMER_BUTTON_2)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1343,7 +1343,7 @@ void Scene808::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_PRESS, 0x3BD)) {
+	} else if (_action.isAction(VERB_PRESS, NOUN_REMOTE_BUTTON_2)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1374,7 +1374,7 @@ void Scene808::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_PRESS, 0x3BF)) {
+	} else if (_action.isAction(VERB_PRESS, NOUN_START_BUTTON_1)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1391,7 +1391,7 @@ void Scene808::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_PRESS, 0x3BB)) {
+	} else if (_action.isAction(VERB_PRESS, NOUN_REMOTE_BUTTON_1)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1408,7 +1408,7 @@ void Scene808::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_PRESS, 0x3BA)) {
+	} else if (_action.isAction(VERB_PRESS, NOUN_TIMER_BUTTON_1)) {
 		switch (_game._trigger) {
 		case 0:
 			_game._player._stepEnabled = false;
@@ -1425,7 +1425,7 @@ void Scene808::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_EXIT, 0x1E0)) {
+	} else if (_action.isAction(VERB_EXIT, NOUN_PANEL)) {
 		_scene->_nextSceneId = 801;
 		_globals[kBetweenRooms] = true;
 	} else


Commit: 5a87fd42f06eae1f19671ea6e32b9f5bd6b1f60d
    https://github.com/scummvm/scummvm/commit/5a87fd42f06eae1f19671ea6e32b9f5bd6b1f60d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T07:31:56+03:00

Commit Message:
MADS: Add more debugger commands for items

Changed paths:
    engines/mads/debugger.cpp
    engines/mads/debugger.h



diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp
index 8baafdd..0b69ee8 100644
--- a/engines/mads/debugger.cpp
+++ b/engines/mads/debugger.cpp
@@ -41,6 +41,8 @@ Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) {
 	DCmd_Register("show_quote", WRAP_METHOD(Debugger, Cmd_ShowQuote));
 	DCmd_Register("show_vocab", WRAP_METHOD(Debugger, Cmd_ShowVocab));
 	DCmd_Register("dump_vocab", WRAP_METHOD(Debugger, Cmd_DumpVocab));
+	DCmd_Register("show_item", WRAP_METHOD(Debugger, Cmd_ShowItem));
+	DCmd_Register("dump_items", WRAP_METHOD(Debugger, Cmd_DumpItems));
 	DCmd_Register("item", WRAP_METHOD(Debugger, Cmd_Item));
 }
 
@@ -242,6 +244,52 @@ bool Debugger::Cmd_DumpVocab(int argc, const char **argv) {
 	return true;
 }
 
+bool Debugger::Cmd_ShowItem(int argc, const char **argv) {
+	InventoryObjects &objects = _vm->_game->_objects;
+
+	if (argc != 2) {
+		for (uint32 i = 0; i < objects.size(); i++) {
+			Common::String desc = _vm->_game->_scene.getVocab(objects[i]._descId);
+			DebugPrintf("%03d: '%s'\n", i, desc.c_str());
+		}
+	} else {
+		int vocabId = strToInt(argv[1]);
+		Common::String desc = _vm->_game->_scene.getVocab(objects[vocabId]._descId);
+		DebugPrintf("%03d: '%s'\n", vocabId, desc.c_str());
+	}
+
+	return true;
+}
+
+bool Debugger::Cmd_DumpItems(int argc, const char **argv) {
+	InventoryObjects &objects = _vm->_game->_objects;
+
+	Common::DumpFile outFile;
+	outFile.open("items.txt");
+
+	for (uint32 i = 0; i < objects.size(); i++) {
+		Common::String curId = Common::String::format("%d", i);
+		Common::String desc = _vm->_game->_scene.getVocab(objects[i]._descId);
+		desc.toUppercase();
+
+		for (uint j = 0; j < desc.size(); j++) {
+			if (desc[j] == ' ' || desc[j] == '-')
+				desc.setChar('_', j);
+		}
+
+		Common::String cur = "\tOBJ_" + desc + " = " + curId + ",\n";
+		
+		outFile.writeString(cur.c_str());
+	}
+
+	outFile.flush();
+	outFile.close();
+
+	DebugPrintf("Game items dumped\n");
+
+	return true;
+}
+
 bool Debugger::Cmd_Item(int argc, const char **argv) {
 	InventoryObjects &objects = _vm->_game->_objects;
 
diff --git a/engines/mads/debugger.h b/engines/mads/debugger.h
index 0c048f2..9059f3f 100644
--- a/engines/mads/debugger.h
+++ b/engines/mads/debugger.h
@@ -45,6 +45,8 @@ protected:
 	bool Cmd_ShowQuote(int argc, const char **argv);
 	bool Cmd_ShowVocab(int argc, const char **argv);
 	bool Cmd_DumpVocab(int argc, const char **argv);
+	bool Cmd_ShowItem(int argc, const char **argv);
+	bool Cmd_DumpItems(int argc, const char **argv);
 	bool Cmd_Item(int argc, const char **argv);
 public:
 	bool _showMousePos;


Commit: 4f4be954ed1a096540ec708b3b626ca1a0a3e53d
    https://github.com/scummvm/scummvm/commit/4f4be954ed1a096540ec708b3b626ca1a0a3e53d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T07:32:39+03:00

Commit Message:
MADS: Don't error out in the SoundManager in MADS v2 games

Changed paths:
    engines/mads/sound.cpp



diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index 64144bb..bd99aed 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -81,7 +81,9 @@ void SoundManager::init(int sectionNumber) {
 		break;
 
 	default:
-		error("Unknown game");
+		warning("SoundManager: Unknown game");
+		_driver = nullptr;
+		break;
 	}
 }
 


Commit: 3aaf4e48c23a5ad90e341939823345d0f66c5192
    https://github.com/scummvm/scummvm/commit/3aaf4e48c23a5ad90e341939823345d0f66c5192
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T07:33:07+03:00

Commit Message:
MADS: Add the inventory item names for Dragonsphere

Changed paths:
    engines/mads/dragonsphere/game_dragonsphere.h



diff --git a/engines/mads/dragonsphere/game_dragonsphere.h b/engines/mads/dragonsphere/game_dragonsphere.h
index cd7ac57..c5d6c0d 100644
--- a/engines/mads/dragonsphere/game_dragonsphere.h
+++ b/engines/mads/dragonsphere/game_dragonsphere.h
@@ -35,8 +35,57 @@ namespace Dragonsphere {
 // TODO: Adapt for Dragonsphere's difficulty setting
 enum StoryMode { STORYMODE_NAUGHTY = 1, STORYMODE_NICE = 2 };
 
-enum InventoryObject { OBJ_NONE = -1
-	// TODO
+enum InventoryObject {
+	OBJ_NONE = -1,
+	OBJ_SIGNET_RING = 0,
+	OBJ_BIRD_FIGURINE = 1,
+	OBJ_BIRDCALL = 2,
+	OBJ_SHIELDSTONE = 3,
+	OBJ_SWORD = 4,
+	OBJ_GOBLET = 5,
+	OBJ_BONE = 6,
+	OBJ_FRUIT = 7,
+	OBJ_DOLL = 8,
+	OBJ_POLYSTONE = 9,
+	OBJ_RED_STONE = 10,
+	OBJ_YELLOW_STONE = 11,
+	OBJ_BLUE_STONE = 12,
+	OBJ_KEY_CROWN = 13,
+	OBJ_DATES = 14,
+	OBJ_STATUE = 15,
+	OBJ_FLIES = 16,
+	OBJ_SOUL_EGG = 17,
+	OBJ_MAGIC_BELT = 18,
+	OBJ_AMULET = 19,
+	OBJ_MUD = 20,
+	OBJ_FEATHERS = 21,
+	OBJ_TORCH = 22,
+	OBJ_FLASK = 23,
+	OBJ_FLASK_OF_ACID = 24,
+	OBJ_ROPE = 25,
+	OBJ_VORTEX_STONE = 26,
+	OBJ_DEAD_RAT = 27,
+	OBJ_MAP = 28,
+	OBJ_CRYSTAL_BALL = 29,
+	OBJ_BLACK_SPHERE = 30,
+	OBJ_SOPORIFIC = 31,
+	OBJ_SHIFTER_RING = 32,
+	OBJ_SPIRIT_BUNDLE = 33,
+	OBJ_PARTIAL_BUNDLE = 34,
+	OBJ_RATSICLE = 35,
+	OBJ_TENTACLE_PARTS = 36,
+	OBJ_TELEPORT_DOOR = 37,
+	OBJ_RARE_COIN = 38,
+	OBJ_CRYSTAL_FLOWER = 39,
+	OBJ_DIAMOND_DUST = 40,
+	OBJ_RUBY_RING = 41,
+	OBJ_GOLD_NUGGET = 42,
+	OBJ_MUSIC_BOX = 43,
+	OBJ_EMERALD = 44,
+	OBJ_PARCHMENT = 45,
+	OBJ_GAME = 46,
+	OBJ_GAME2 = 47,
+	OBJ_NEW_BUNDLE = 48
 };
 
 // HACK: A stub for now, remove from here once it's implemented properly


Commit: facbe1b177a4dc9cbf2ca26ff8c8f070aac5f066
    https://github.com/scummvm/scummvm/commit/facbe1b177a4dc9cbf2ca26ff8c8f070aac5f066
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T07:33:18+03:00

Commit Message:
MADS: Add the inventory item names for Phantom

Changed paths:
    engines/mads/phantom/game_phantom.h



diff --git a/engines/mads/phantom/game_phantom.h b/engines/mads/phantom/game_phantom.h
index 3043e53..600c584 100644
--- a/engines/mads/phantom/game_phantom.h
+++ b/engines/mads/phantom/game_phantom.h
@@ -35,8 +35,33 @@ namespace Phantom {
 // TODO: Adapt for Phantom's difficulty setting
 enum StoryMode { STORYMODE_NAUGHTY = 1, STORYMODE_NICE = 2 };
 
-enum InventoryObject { OBJ_NONE = -1
-	// TODO
+enum InventoryObject {
+	OBJ_NONE = -1,
+	OBJ_KEY = 0,
+	OBJ_LANTERN = 1,
+	OBJ_RED_FRAME = 2,
+	OBJ_SANDBAG = 3,
+	OBJ_YELLOW_FRAME = 4,
+	OBJ_FIRE_AXE = 5,
+	OBJ_SMALL_NOTE = 6,
+	OBJ_ROPE = 7,
+	OBJ_SWORD = 8,
+	OBJ_ENVELOPE = 9,
+	OBJ_TICKET = 10,
+	OBJ_PIECE_OF_PAPER = 11,
+	OBJ_PARCHMENT = 12,
+	OBJ_LETTER = 13,
+	OBJ_NOTICE = 14,
+	OBJ_BOOK = 15,
+	OBJ_CRUMPLED_NOTE = 16,
+	OBJ_BLUE_FRAME = 17,
+	OBJ_LARGE_NOTE = 18,
+	OBJ_GREEN_FRAME = 19,
+	OBJ_MUSIC_SCORE = 20,
+	OBJ_WEDDING_RING = 21,
+	OBJ_CABLE_HOOK = 22,
+	OBJ_ROPE_WITH_HOOK = 23,
+	OBJ_OAR = 24
 };
 
 // HACK: A stub for now, remove from here once it's implemented properly


Commit: 3aa9dc3947900799bf69d5918eb36cc5d855506f
    https://github.com/scummvm/scummvm/commit/3aa9dc3947900799bf69d5918eb36cc5d855506f
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-20T07:20:31+02:00

Commit Message:
MADS: Add synchronize in scene 501

Changed paths:
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes5.h



diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index 02dc90d..b218784 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -99,6 +99,15 @@ void Scene501::setup() {
 	_scene->addActiveVocab(0x18B);
 }
 
+void Scene501::synchronize(Common::Serializer &s) {
+	Scene5xx::synchronize(s);
+
+	s.syncAsSint16LE(_mainSequenceId);
+	s.syncAsSint16LE(_mainSpriteId);
+	s.syncAsSint16LE(_doorHotspotid);
+	s.syncAsByte(_rexPunched);
+}
+
 void Scene501::handleSlotActions() {
 	switch (_game._trigger) {
 	case 0:
diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
index bc22a62..c49532d 100644
--- a/engines/mads/nebular/nebular_scenes5.h
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -61,6 +61,7 @@ private:
 
 public:
 	Scene501(MADSEngine *vm) : Scene5xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();


Commit: c548b70e914acee473bd1ec427cabddcc0258e7d
    https://github.com/scummvm/scummvm/commit/c548b70e914acee473bd1ec427cabddcc0258e7d
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T12:31:10+03:00

Commit Message:
MADS: Add more friendly names for nouns

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes8.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 04c646f..5187b78 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -160,7 +160,7 @@ void Scene101::enter() {
 	_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, 0, 10, 4);
 	_globals._sequenceIndexes[10] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[10], false, 6, 0, 32, 47);
 
-	_scene->_hotspots.activate(0x137, false);
+	_scene->_hotspots.activate(NOUN_SHIELD_MODULATOR, false);
 	_panelOpened = false;
 
 	// HACK: set the prior scene to 102 for now when the game starts, to avoid Rex's getting up animation
@@ -180,7 +180,7 @@ void Scene101::enter() {
 		_game._player._facing = FACING_NORTHEAST;
 		_globals._sequenceIndexes[11] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 0, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], 17, 17);
-		_scene->_hotspots.activate(0x47, false);
+		_scene->_hotspots.activate(NOUN_CHAIR, false);
 		_chairHotspotId = _scene->_dynamicHotspots.add(0x47, 0x13F, -1, Common::Rect(159, 84, 159 + 33, 84 + 36));
 		if (_scene->_priorSceneId == 112)
 			sayDang();
@@ -317,7 +317,7 @@ void Scene101::preActions() {
 		case 1:
 			_game._player._stepEnabled = true;
 			_panelOpened = false;
-			_scene->_hotspots.activate(0x137, false);
+			_scene->_hotspots.activate(NOUN_SHIELD_MODULATOR, false);
 			break;
 		}
 	}
@@ -378,7 +378,7 @@ void Scene101::actions() {
 	if (((_action.isAction(VERB_WALKTO, NOUN_SHIELD_ACCESS_PANEL) || _action.isAction(VERB_OPEN, NOUN_SHIELD_ACCESS_PANEL))) && !_panelOpened) {
 		switch (_game._trigger) {
 		case 0:
-			_shieldSpriteIdx = _game._objects.isInRoom(0x18) ? 13 : 14;
+			_shieldSpriteIdx = _game._objects.isInRoom(OBJ_SHIELD_MODULATOR) ? 13 : 14;
 			_globals._sequenceIndexes[13] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[_shieldSpriteIdx], false, 6, 1, 0, 0);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			_game._player._stepEnabled = false;
@@ -391,8 +391,8 @@ void Scene101::actions() {
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[13], -2, -2);
 			_game._player._stepEnabled = true;
 			_panelOpened = true;
-			if (_game._objects.isInRoom(0x18))
-				_scene->_hotspots.activate(0x137, true);
+			if (_game._objects.isInRoom(OBJ_SHIELD_MODULATOR))
+				_scene->_hotspots.activate(NOUN_SHIELD_MODULATOR, true);
 			break;
 		}
 		_action._inProgress = false;
@@ -595,7 +595,7 @@ void Scene101::actions() {
 		return;
 	}
 
-	if ((_action.isAction(VERB_LOOK) || _action.isAction(VERB_PLAY)) && _action.isObject(0x17E)) {
+	if ((_action.isAction(VERB_LOOK) || _action.isAction(VERB_PLAY)) && _action.isObject(NOUN_VIDEO_GAME)) {
 		_vm->_dialogs->show(10124);
 		_action._inProgress = false;
 		return;
@@ -657,9 +657,9 @@ void Scene102::enter() {
 	if (_game._objects.isInRoom(OBJ_BINOCULARS))
 		_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 24, 0, 0, 24);
 	else
-		_scene->_hotspots.activate(0x27, false);
+		_scene->_hotspots.activate(NOUN_BINOCULARS, false);
 
-	_scene->_hotspots.activate(0x35, false);
+	_scene->_hotspots.activate(NOUN_BURGER, false);
 
 	if (_globals[kMedicineCabinetOpen]) {
 		_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 6, 0, 0);
@@ -758,10 +758,10 @@ void Scene102::step() {
 }
 
 void Scene102::preActions() {
-	if (_action.isObject(0x122) || _action.isObject(0x117))
+	if (_action.isObject(NOUN_REFRIGERATOR) || _action.isObject(NOUN_POSTER))
 		_game._player._needToWalk = _game._player._readyToWalk;
 
-	if (_fridgeOpenedFl && !_action.isObject(0x122)) {
+	if (_fridgeOpenedFl && !_action.isObject(NOUN_REFRIGERATOR)) {
 		switch (_game._trigger) {
 		case 0:
 			if (_game._player._needToWalk) {
@@ -777,7 +777,7 @@ void Scene102::preActions() {
 		case 1:
 			if (_game._objects.isInRoom(OBJ_BURGER)) {
 				_scene->_sequences.remove(_globals._sequenceIndexes[10]);
-				_scene->_hotspots.activate(0x35, false);
+				_scene->_hotspots.activate(NOUN_BURGER, false);
 			}
 			_fridgeOpenedFl = false;
 			_game._player._stepEnabled = true;
@@ -833,7 +833,7 @@ void Scene102::actions() {
 			_game._player._stepEnabled = true;
 			justOpenedFl = true;
 			if (_game._objects.isInRoom(OBJ_BURGER))
-				_scene->_hotspots.activate(0x35, true);
+				_scene->_hotspots.activate(NOUN_BURGER, true);
 			break;
 		}
 	}
@@ -970,7 +970,7 @@ void Scene102::actions() {
 		return;
 	}
 
-	if ((_action.isObject(NOUN_LADDER) || _action.isObject(0xA3)) && (_action.isAction(VERB_LOOK) || _action.isAction(VERB_CLIMB_UP) || _action.isAction(VERB_CLIMB_THROUGH))) {
+	if ((_action.isObject(NOUN_LADDER) || _action.isObject(NOUN_HATCHWAY)) && (_action.isAction(VERB_LOOK) || _action.isAction(VERB_CLIMB_UP) || _action.isAction(VERB_CLIMB_THROUGH))) {
 		if (_game._objects.isInInventory(OBJ_REBREATHER)) {
 			if (!_action.isAction(VERB_CLIMB_UP) && !_action.isAction(VERB_CLIMB_THROUGH)) {
 				_vm->_dialogs->show(10231);
@@ -984,7 +984,7 @@ void Scene102::actions() {
 		}
 	}
 
-	if ((_action.isObject(NOUN_LADDER) || _action.isObject(0xA3)) && (_action.isAction(VERB_CLIMB_UP) || _action.isAction(VERB_CLIMB_THROUGH)) ) {
+	if ((_action.isObject(NOUN_LADDER) || _action.isObject(NOUN_HATCHWAY)) && (_action.isAction(VERB_CLIMB_UP) || _action.isAction(VERB_CLIMB_THROUGH)) ) {
 		switch (_game._trigger) {
 		case 0:
 			_scene->loadAnimation(formAnimName('A', -1), 1);
@@ -1146,7 +1146,7 @@ void Scene102::actions() {
 		case 1:
 			_game._objects.addToInventory(OBJ_BINOCULARS);
 			_scene->_sequences.remove(_globals._sequenceIndexes[9]);
-			_scene->_hotspots.activate(0x27, false);
+			_scene->_hotspots.activate(NOUN_BINOCULARS, false);
 			_game._player._visible = true;
 			_game._player._stepEnabled = true;
 			_vm->_sound->command(22);
@@ -1162,7 +1162,7 @@ void Scene102::actions() {
 			_vm->_dialogs->showItem(OBJ_BURGER, 10235);
 			_scene->_sequences.remove(_globals._sequenceIndexes[10]);
 			_game._objects.addToInventory(OBJ_BURGER);
-			_scene->_hotspots.activate(0x35, false);
+			_scene->_hotspots.activate(NOUN_BURGER, false);
 			_vm->_sound->command(22);
 			_game._player._visible = true;
 			_game._player._stepEnabled = true;
@@ -1177,7 +1177,7 @@ void Scene102::actions() {
 		return;
 	}
 
-	if ((_action.isAction(VERB_PUSH) || _action.isAction(VERB_PULL)) && _action.isObject(0x194)) {
+	if ((_action.isAction(VERB_PUSH) || _action.isAction(VERB_PULL)) && _action.isObject(NOUN_WEIGHT_MACHINE)) {
 		_vm->_dialogs->show(10225);
 		_action._inProgress = false;
 		return;
@@ -1849,7 +1849,7 @@ void Scene105::preActions() {
 	if (_action.isAction(VERB_SWIM_TOWARDS, NOUN_OPEN_AREA_TO_SOUTH))
 		_game._player._walkOffScreenSceneId = 107;
 
-	if (_action.isObject(0xE0) && (_action.isAction(VERB_TALKTO) || _action.isAction(VERB_LOOK)))
+	if (_action.isObject(NOUN_MINE) && (_action.isAction(VERB_TALKTO) || _action.isAction(VERB_LOOK)))
 		_game._player._needToWalk = false;
 }
 
@@ -2085,7 +2085,7 @@ void Scene106::actions() {
 		_vm->_dialogs->show(10605);
 	else if (_action.isAction(VERB_LOOK, NOUN_PILE_OF_ROCKS) || _action.isAction(VERB_LOOK_AT, NOUN_PILE_OF_ROCKS))
 		_vm->_dialogs->show(10606);
-	else if (_action.isObject(0x109) && (_action.isAction(VERB_PUSH) || _action.isAction(VERB_PULL) || _action.isAction(VERB_TAKE)))
+	else if (_action.isObject(NOUN_PILE_OF_ROCKS) && (_action.isAction(VERB_PUSH) || _action.isAction(VERB_PULL) || _action.isAction(VERB_TAKE)))
 		_vm->_dialogs->show(10607);
 	else if (_action.isAction(VERB_LOOK, NOUN_SHIP) || _action.isAction(VERB_LOOK_AT, NOUN_SHIP))
 		_vm->_dialogs->show(10608);
@@ -2119,7 +2119,7 @@ void Scene107::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 
-	_scene->addActiveVocab(0xDA);
+	_scene->addActiveVocab(NOUN_MANTA_RAY);
 }
 
 void Scene107::enter() {
@@ -2333,8 +2333,8 @@ Scene109::Scene109(MADSEngine *vm) : Scene1xx(vm) {
 }
 
 void Scene109::setup() {
-	_scene->addActiveVocab(0x66);
-	_scene->addActiveVocab(0xE5);
+	_scene->addActiveVocab(NOUN_DEAD_PURPLE_MONSTER);
+	_scene->addActiveVocab(NOUN_MONSTER_SLUDGE);
 
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -2489,8 +2489,8 @@ void Scene109::preActions() {
 		_game._player._walkOffScreenSceneId = 108;
 
 	if ((_action.isAction(VERB_THROW) || _action.isAction(VERB_GIVE) || _action.isAction(VERB_PUT))
-	&& (_action.isObject(0x146) || _action.isObject(0x178))
-	&& (_action.isObject(0x65) || _action.isObject(0x157) || _action.isObject(0x35))) {
+	&& (_action.isObject(NOUN_SMALL_HOLE) || _action.isObject(NOUN_TUNNEL))
+	&& (_action.isObject(NOUN_DEAD_FISH) || _action.isObject(NOUN_STUFFED_FISH) || _action.isObject(NOUN_BURGER))) {
 		int idx = _game._objects.getIdFromDesc(_action._activeAction._objectNameId);
 		if ((idx >= 0) && _game._objects.isInInventory(idx)) {
 			_game._player._prepareWalkPos = Common::Point(106, 38);
@@ -2501,7 +2501,7 @@ void Scene109::preActions() {
 	}
 
 	if ((_action.isAction(VERB_SWIM_INTO, NOUN_TUNNEL) || _action.isAction(VERB_SWIM_TO, NOUN_SMALL_HOLE))
-	&& (!_globals[kHoovicAlive] || _globals[kHoovicSated]) && (_action.isObject(0x178)))
+	&& (!_globals[kHoovicAlive] || _globals[kHoovicSated]) && (_action.isObject(NOUN_TUNNEL)))
 		_game._player._walkOffScreenSceneId = 110;
 
 	_hungryFl = false;
@@ -2515,7 +2515,7 @@ void Scene109::actions() {
 	}
 
 	if ((_action.isAction(VERB_THROW) || _action.isAction(VERB_GIVE)) && (_action.isTarget(0x146) || _action.isTarget(0x178))) {
-		if (_action.isObject(0x65) || _action.isObject(0x157) || _action.isObject(0x35)) {
+		if (_action.isObject(NOUN_DEAD_FISH) || _action.isObject(NOUN_STUFFED_FISH) || _action.isObject(NOUN_BURGER)) {
 			_throwingObjectId = _game._objects.getIdFromDesc(_action._activeAction._objectNameId);
 			if (_throwingObjectId >= 0) {
 				if ((_game._objects.isInInventory(_throwingObjectId) && _globals[kHoovicAlive]) || _rexThrowingObject) {
@@ -2692,7 +2692,7 @@ void Scene109::actions() {
 		_vm->_dialogs->show(10901);
 	else if (_action.isAction(VERB_LOOK, NOUN_CORAL))
 		_vm->_dialogs->show(10902);
-	else if ((_action.isAction(VERB_TAKE) || _action.isAction(VERB_PULL)) && _action.isObject(0x5A))
+	else if ((_action.isAction(VERB_TAKE) || _action.isAction(VERB_PULL)) && _action.isObject(NOUN_CORAL))
 		_vm->_dialogs->show(10903);
 	else if (_action.isAction(VERB_LOOK, NOUN_ROCKS))
 		_vm->_dialogs->show(10904);
@@ -2737,7 +2737,7 @@ void Scene110::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 
-	_scene->addActiveVocab(0x5B);
+	_scene->addActiveVocab(NOUN_CRAB);
 }
 
 void Scene110::enter() {
@@ -2861,7 +2861,7 @@ void Scene110::synchronize(Common::Serializer &s) {
 /*------------------------------------------------------------------------*/
 
 void Scene111::setup() {
-	_scene->addActiveVocab(0x1F);
+	_scene->addActiveVocab(NOUN_BATS);
 
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -2992,7 +2992,7 @@ void Scene111::actions() {
 		_vm->_dialogs->show(11104);
 	else if (_action.isAction(VERB_LOOK, NOUN_LARGE_STALAGMITE))
 		_vm->_dialogs->show(11105);
-	else if ((_action.isAction(VERB_PULL) || _action.isAction(VERB_TAKE)) && (_action.isObject(0x153) || _action.isObject(0xC8)))
+	else if ((_action.isAction(VERB_PULL) || _action.isAction(VERB_TAKE)) && (_action.isObject(NOUN_STALAGMITES) || _action.isObject(NOUN_LARGE_STALAGMITE)))
 		_vm->_dialogs->show(11106);
 	else
 		return;
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 173c641..083b649 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1353,7 +1353,7 @@ void Scene205::actions() {
 		} else if (_action.isAction(VERB_TAKE, NOUN_CHICKEN_ON_SPIT) && _globals[kChickenPermitted] && _game._objects.isInRoom(OBJ_CHICKEN)) {
 			_game._objects.addToInventory(OBJ_CHICKEN);
 			_scene->_sequences.remove(_globals._sequenceIndexes[4]);
-			_scene->_hotspots.activate(0x1C2, false);
+			_scene->_hotspots.activate(NOUN_CHICKEN_ON_SPIT, false);
 			_vm->_dialogs->showItem(OBJ_CHICKEN, 812);
 		} else if (_action.isAction(VERB_TAKE, NOUN_CHICKEN_ON_SPIT) && (!_globals[kChickenPermitted]))
 			_scene->_kernelMessages.add(Common::Point(186, 27), 0xFBFA, 32, 0, 120, _game.getQuote(0x80));
@@ -1409,9 +1409,9 @@ void Scene205::synchronize(Common::Serializer &s) {
 void Scene207::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x185);
+	_scene->addActiveVocab(NOUN_VULTURE);
 	_scene->addActiveVocab(VERB_WALKTO);
-	_scene->addActiveVocab(0x14D);
+	_scene->addActiveVocab(NOUN_SPIDER);
 	_scene->addActiveVocab(VERB_WALKTO);
 }
 
@@ -1896,7 +1896,7 @@ void Scene208::synchronize(Common::Serializer &s) {
 void Scene209::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x10F);
+	_scene->addActiveVocab(NOUN_PLANT_STALK);
 }
 
 void Scene209::handlePause() {
@@ -3517,7 +3517,7 @@ void Scene209::synchronize(Common::Serializer &s) {
 void Scene210::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x70);
+	_scene->addActiveVocab(NOUN_DOORWAY);
 	_scene->addActiveVocab(VERB_WALK_THROUGH);
 }
 
@@ -4517,7 +4517,7 @@ void Scene211::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 
-	_scene->addActiveVocab(0x144);
+	_scene->addActiveVocab(NOUN_SLITHERING_SNAKE);
 }
 
 void Scene211::enter() {
@@ -4793,7 +4793,7 @@ void Scene212::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 
-	_scene->addActiveVocab(0x19D);
+	_scene->addActiveVocab(NOUN_BOUNCING_REPTILE);
 }
 
 void Scene212::enter() {
@@ -4822,7 +4822,7 @@ void Scene212::preActions() {
 void Scene212::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(21209);
-	else if (_action.isAction(VERB_WALK_TOWARDS) && (_action.isObject(0x82) || _action.isObject(0xE8)))
+	else if (_action.isAction(VERB_WALK_TOWARDS) && (_action.isObject(NOUN_FIELD_TO_NORTH) || _action.isObject(NOUN_MOUNTAINS)))
 		_scene->_nextSceneId = 208;
 	else if (_action.isAction(VERB_WALK_TOWARDS, NOUN_CAVE))
 		_scene->_nextSceneId = 111;
@@ -4916,8 +4916,8 @@ void Scene213::actions() {
 void Scene214::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x1C3);
-	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(NOUN_CAPTIVE_CREATURE);
+	_scene->addActiveVocab(NOUN_WALK_TO);
 }
 
 void Scene214::enter() {
@@ -4934,7 +4934,7 @@ void Scene214::enter() {
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(103, 86));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 11);
 	} else {
-		_scene->_hotspots.activate(0x114, false);
+		_scene->_hotspots.activate(NOUN_POISON_DARTS, false);
 	}
 
 	if (_game._objects.isInRoom(OBJ_BLOWGUN)) {
@@ -4942,7 +4942,7 @@ void Scene214::enter() {
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(90, 87));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 13);
 	} else {
-		_scene->_hotspots.activate(0x29, false);
+		_scene->_hotspots.activate(NOUN_BLOWGUN, false);
 	}
 
 	if (_scene->_priorSceneId != -2)
@@ -5010,7 +5010,7 @@ void Scene214::actions() {
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_game._objects.addToInventory(OBJ_POISON_DARTS);
-			_scene->_hotspots.activate(0x114, false);
+			_scene->_hotspots.activate(NOUN_POISON_DARTS, false);
 			break;
 
 		case 2:
@@ -5039,7 +5039,7 @@ void Scene214::actions() {
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 			_game._objects.addToInventory(OBJ_BLOWGUN);
-			_scene->_hotspots.activate(0x29, false);
+			_scene->_hotspots.activate(NOUN_BLOWGUN, false);
 			break;
 
 		case 2:
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 74bc582..95fdd00 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -470,8 +470,8 @@ void Scene304::synchronize(Common::Serializer &s) {
 void Scene307::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x11);
-	_scene->addActiveVocab(0x2F7);
+	_scene->addActiveVocab(NOUN_AIR_VENT);
+	_scene->addActiveVocab(NOUN_CLIMB_INTO);
 }
 
 void Scene307::handleRexDialog(int quote) {
@@ -2510,9 +2510,9 @@ void Scene318::enter() {
 		_scene->loadAnimation(formAnimName('f', -1));
 		_scene->_activeAnimation->_resetFlag = true;
 	} else if (!_globals[kHasSeenProfPyro]) {
-		_scene->_hotspots.activate(0x3A2, false);
-		_scene->_hotspots.activate(0x3A1, false);
-		_scene->_hotspots.activate(0x165, false);
+		_scene->_hotspots.activate(NOUN_PROFESSORS_GURNEY, false);
+		_scene->_hotspots.activate(NOUN_PROFESSOR, false);
+		_scene->_hotspots.activate(NOUN_TAPE_PLAYER, false);
 	}
 
 	if (_game._objects.isInRoom(OBJ_SCALPEL)) {
@@ -2542,7 +2542,7 @@ void Scene318::enter() {
 	}
 
 	_lastFrame = 0;
-	_scene->_hotspots.activate(0x307, false);
+	_scene->_hotspots.activate(NOUN_INTERN, false);
 
 	if (_scene->_priorSceneId != -2) {
 		_dialogFl = false;
@@ -2572,7 +2572,7 @@ void Scene318::enter() {
 				_dialogFl = false;
 			} else {
 				_scene->loadAnimation(formAnimName('b', -1), 61);
-				_scene->_hotspots.activate(0x307, true);
+				_scene->_hotspots.activate(NOUN_INTERN, true);
 			}
 
 			if (_dialogFl) {
@@ -2658,7 +2658,7 @@ void Scene318::step() {
 
 				if (nextFrame == 184) {
 					handleInternDialog(0x1D1, 3, 240);
-					_scene->_hotspots.activate(0x307, false);
+					_scene->_hotspots.activate(NOUN_INTERN, false);
 					_internVisibleFl = false;
 				}
 				break;
@@ -3642,10 +3642,10 @@ void Scene320::actions() {
 	if (_action._lookFlag)
 		_vm->_dialogs->show(32011);
 	else if ((_action.isAction(VERB_PRESS) || _action.isAction(VERB_PUSH)) &&
-		(_action.isObject(0x2E8) || _action.isObject(0x2E9) || _action.isObject(0x2EA) || _action.isObject(0x2EB) ||
-		 _action.isObject(0x2DE) || _action.isObject(0x2DD) || _action.isObject(0x2E0) || _action.isObject(0x2E1) ||
-		 _action.isObject(0x2E2) || _action.isObject(0x2E3) || _action.isObject(0x2E4) || _action.isObject(0x2E5) ||
-		 _action.isObject(0x2E6) || _action.isObject(0x2E7)
+		(_action.isObject(NOUN_LEFT_1_KEY) || _action.isObject(NOUN_LEFT_2_KEY) || _action.isObject(NOUN_LEFT_3_KEY) || _action.isObject(NOUN_LEFT_4_KEY) ||
+		 _action.isObject(NOUN_GREEN_BUTTON) || _action.isObject(NOUN_RED_BUTTON) || _action.isObject(NOUN_RIGHT_1_KEY) || _action.isObject(NOUN_RIGHT_2_KEY) ||
+		 _action.isObject(NOUN_RIGHT_3_KEY) || _action.isObject(NOUN_RIGHT_4_KEY) || _action.isObject(NOUN_RIGHT_5_KEY) || _action.isObject(NOUN_RIGHT_6_KEY) ||
+		 _action.isObject(NOUN_RIGHT_7_KEY) || _action.isObject(NOUN_RIGHT_8_KEY)
 		)) {
 		switch (_game._trigger) {
 		case 0:
@@ -3868,7 +3868,7 @@ void Scene351::setup() {
 
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(NOUN_WALK_TO);
 }
 
 void Scene351::enter() {
@@ -3879,11 +3879,11 @@ void Scene351::enter() {
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*ROXRC_7");
 	_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RXRD_7");
 
-	if (_game._objects.isInRoom(0xF)) {
+	if (_game._objects.isInRoom(OBJ_CREDIT_CHIP)) {
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 4);
 	} else
-		_scene->_hotspots.activate(0x5C, false);
+		_scene->_hotspots.activate(NOUN_CREDIT_CHIP, false);
 
 	if (_scene->_priorSceneId == 352)
 		_game._player._playerPos = Common::Point(148, 152);
@@ -3978,7 +3978,7 @@ void Scene351::actions() {
 				break;
 
 			case 1:
-				_scene->_hotspots.activate(0x5C, false);
+				_scene->_hotspots.activate(NOUN_CREDIT_CHIP, false);
 				_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 				_game._objects.addToInventory(OBJ_CREDIT_CHIP);
 				break;
@@ -4027,10 +4027,10 @@ void Scene352::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 
-	_scene->addActiveVocab(0xD);
-	_scene->addActiveVocab(0x2F4);
-	_scene->addActiveVocab(0x2F5);
-	_scene->addActiveVocab(0x2F6);
+	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(NOUN_YOUR_STUFF);
+	_scene->addActiveVocab(NOUN_OTHER_STUFF);
+	_scene->addActiveVocab(NOUN_LAMP);
 }
 
 void Scene352::putArmDown(bool corridorExit, bool doorwayExit) {
@@ -4815,7 +4815,7 @@ void Scene358::actions() {
 void Scene359::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(NOUN_WALK_TO);
 }
 
 void Scene359::enter() {
@@ -5464,7 +5464,7 @@ void Scene388::enter() {
 	_scene->_userInterface.setup(kInputLimitedSentences);
 
 	if (_globals[kAfterHavoc])
-		_scene->_hotspots.activate(0x303, false);
+		_scene->_hotspots.activate(NOUN_SAUROPOD, false);
 	else {
 		_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('b', 0));
 		_globals._sequenceIndexes[0] = _scene->_sequences.startCycle(_globals._spriteIndexes[0], false, 1);
@@ -5529,7 +5529,7 @@ void Scene389::enter() {
 	_circularQuoteId = 0x159;
 
 	if (_globals[kAfterHavoc])
-		_scene->_hotspots.activate(0x304, false);
+		_scene->_hotspots.activate(NOUN_MONSTER, false);
 	else {
 		_globals._spriteIndexes[0] = _scene->_sprites.addSprites(formAnimName('m', -1));
 		_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 6, 0, 0, 0);
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index dd196b4..5a68887 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -235,15 +235,15 @@ void Scene402::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 
-	_scene->addActiveVocab(0x30E);
-	_scene->addActiveVocab(0x306);
-	_scene->addActiveVocab(0x72);
-	_scene->addActiveVocab(0x27);
-	_scene->addActiveVocab(0xD);
-	_scene->addActiveVocab(0x5C);
-	_scene->addActiveVocab(0x4);
-	_scene->addActiveVocab(0x124);
-	_scene->addActiveVocab(0xD1);
+	_scene->addActiveVocab(NOUN_BARTENDER);
+	_scene->addActiveVocab(NOUN_ALIEN_LIQUOR);
+	_scene->addActiveVocab(NOUN_DRINK);
+	_scene->addActiveVocab(NOUN_BINOCULARS);
+	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(NOUN_CREDIT_CHIP);
+	_scene->addActiveVocab(NOUN_TAKE);
+	_scene->addActiveVocab(NOUN_REPAIR_LIST);
+	_scene->addActiveVocab(NOUN_LOOK_AT);
 }
 
 void Scene402::synchronize(Common::Serializer &s) {
@@ -2849,8 +2849,8 @@ void Scene407::synchronize(Common::Serializer &s) {
 void Scene408::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x167);
-	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(NOUN_TARGET_MODULE);
+	_scene->addActiveVocab(NOUN_WALK_TO);
 }
 
 void Scene408::enter() {
@@ -2873,7 +2873,7 @@ void Scene408::preActions() {
 	if ((_action.isAction(VERB_TAKE) && !_action.isAction(0x167)) || _action.isAction(VERB_PULL, NOUN_PIN) || _action.isAction(VERB_OPEN, NOUN_CARTON))
 		_game._player._needToWalk = false;
 
-	if ((_action.isAction(VERB_LOOK, NOUN_TARGET_MODULE) && _game._objects.isInRoom(0x17)) || _action.isAction(VERB_LOOK, NOUN_CHEST))
+	if ((_action.isAction(VERB_LOOK, NOUN_TARGET_MODULE) && _game._objects.isInRoom(OBJ_TARGET_MODULE)) || _action.isAction(VERB_LOOK, NOUN_CHEST))
 		_game._player._needToWalk = true;
 }
 
@@ -3069,7 +3069,7 @@ void Scene410::enter() {
 	if (_game._objects.isInRoom(OBJ_CHARGE_CASES))
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
 	else
-		_scene->_hotspots.activate(0x48, false);
+		_scene->_hotspots.activate(NOUN_CHARGE_CASES, false);
 
 	if (_scene->_priorSceneId != -2) {
 		_game._player._playerPos = Common::Point(155, 150);
@@ -3144,7 +3144,7 @@ void Scene410::actions() {
 
 		case 1:
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
-			_scene->_hotspots.activate(0x48, false);
+			_scene->_hotspots.activate(NOUN_CHARGE_CASES, false);
 			_game._objects.addToInventory(OBJ_CHARGE_CASES);
 			_vm->_dialogs->showItem(OBJ_CHARGE_CASES, 41032);
 			break;
@@ -3464,11 +3464,11 @@ void Scene411::giveToRex(int object) {
 void Scene411::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0xD);
-	_scene->addActiveVocab(0x306);
-	_scene->addActiveVocab(0x2D6);
-	_scene->addActiveVocab(0x2D7);
-	_scene->addActiveVocab(0x3A9);
+	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(NOUN_ALIEN_LIQUOR);
+	_scene->addActiveVocab(NOUN_FORMALDEHYDE);
+	_scene->addActiveVocab(NOUN_PETROX);
+	_scene->addActiveVocab(NOUN_LECITHIN);
 }
 
 void Scene411::enter() {
@@ -3507,11 +3507,11 @@ void Scene411::enter() {
 	_dialog4.setup(0x5E, 0x255, 0x261, 0x25D, 0x259, 0x262, -1);
 
 	if (_globals[kNextIngredient] >= 4 && _game._objects[OBJ_CHARGE_CASES].getQuality(3)) {
-		_scene->_hotspots.activate(0x3AB, false);
-		_scene->_hotspots.activate(0x30D, true);
+		_scene->_hotspots.activate(NOUN_EXPLOSIVES, false);
+		_scene->_hotspots.activate(NOUN_KETTLE, true);
 	} else {
-		_scene->_hotspots.activate(0x30D, false);
-		_scene->_hotspots.activate(0x3AB, true);
+		_scene->_hotspots.activate(NOUN_KETTLE, false);
+		_scene->_hotspots.activate(NOUN_EXPLOSIVES, true);
 	}
 
 	if (_globals[kNextIngredient] >= 4 && _game._objects[OBJ_CHARGE_CASES].getQuality(3)) {
@@ -3649,8 +3649,8 @@ void Scene411::step() {
 				if (_makeMushroomCloud) {
 					_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 5, 1, 0, 0);
 					_makeMushroomCloud = false;
-					_scene->_hotspots.activate(0x3AB, false);
-					_scene->_hotspots.activate(0x30D, true);
+					_scene->_hotspots.activate(NOUN_EXPLOSIVES, false);
+					_scene->_hotspots.activate(NOUN_KETTLE, true);
 				}
 				break;
 
@@ -3736,8 +3736,8 @@ void Scene411::actions() {
 			break;
 
 		case 111:
-			_scene->_hotspots.activate(0x30D, true);
-			_scene->_hotspots.activate(0x3AB, false);
+			_scene->_hotspots.activate(NOUN_KETTLE, true);
+			_scene->_hotspots.activate(NOUN_EXPLOSIVES, false);
 			_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 			_scene->_sequences.remove(_globals._sequenceIndexes[10]);
 
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index b218784..b55262c 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -95,8 +95,8 @@ void Scene5xx::sceneEntrySound() {
 void Scene501::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x6E);
-	_scene->addActiveVocab(0x18B);
+	_scene->addActiveVocab(NOUN_DOOR);
+	_scene->addActiveVocab(NOUN_WALK_THROUGH);
 }
 
 void Scene501::synchronize(Common::Serializer &s) {
@@ -283,7 +283,7 @@ void Scene501::step() {
 }
 
 void Scene501::preActions() {
-	if (_action.isAction(VERB_WALK_DOWN) && (_action.isObject(0x321) || _action.isObject(0x322)))
+	if (_action.isAction(VERB_WALK_DOWN) && (_action.isObject(NOUN_STREET_TO_EAST) || _action.isObject(NOUN_SIDEWALK_TO_EAST)))
 		_game._player._walkOffScreenSceneId = 551;
 }
 
@@ -526,8 +526,8 @@ void Scene502::actions() {
 void Scene503::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x6A);
-	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(NOUN_DETONATORS);
+	_scene->addActiveVocab(NOUN_WALK_TO);
 }
 
 void Scene503::enter() {
@@ -1099,9 +1099,9 @@ void Scene505::actions() {
 void Scene506::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x242);
-	_scene->addActiveVocab(0x336);
-	_scene->addActiveVocab(0x37D);
+	_scene->addActiveVocab(NOUN_WALK_INTO);
+	_scene->addActiveVocab(NOUN_SOFTWARE_STORE);
+	_scene->addActiveVocab(NOUN_LABORATORY);
 }
 
 void Scene506::enter() {
@@ -1361,8 +1361,8 @@ void Scene506::actions() {
 void Scene507::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x106);
-	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(NOUN_PENLIGHT);
+	_scene->addActiveVocab(NOUN_WALK_TO);
 }
 
 void Scene507::enter() {
@@ -1472,9 +1472,9 @@ void Scene507::actions() {
 void Scene508::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x364);
-	_scene->addActiveVocab(0xD);
-	_scene->addActiveVocab(0x343);
+	_scene->addActiveVocab(NOUN_SPINACH_PATCH_DOLL);
+	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(NOUN_LASER_BEAM);
 }
 
 void Scene508::enter() {
@@ -1497,8 +1497,8 @@ void Scene508::enter() {
 		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, -2);
 		int idx = _scene->_dynamicHotspots.add(0x343, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(57, 116), FACING_NORTHEAST);
-		_scene->_hotspots.activate(0x342, false);
-		_scene->_hotspots.activate(0x343, false);
+		_scene->_hotspots.activate(NOUN_HOLE, false);
+		_scene->_hotspots.activate(NOUN_LASER_BEAM, false);
 	} else {
 		_scene->changeVariant(1);
 		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
@@ -1512,8 +1512,8 @@ void Scene508::enter() {
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 6);
 		if (_globals[kLaserHoleIsThere]) {
 			_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, -2);
-			_scene->_hotspots.activate(0x342, true);
-			_scene->_hotspots.activate(0x343, true);
+			_scene->_hotspots.activate(NOUN_HOLE, true);
+			_scene->_hotspots.activate(NOUN_LASER_BEAM, true);
 		}
 		_vm->_sound->command(21);
 	}
@@ -1572,8 +1572,8 @@ void Scene508::handlePedestral() {
 
 		case 2:
 			_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, -2);
-			_scene->_hotspots.activate(0x342, true);
-			_scene->_hotspots.activate(0x343, true);
+			_scene->_hotspots.activate(NOUN_HOLE, true);
+			_scene->_hotspots.activate(NOUN_LASER_BEAM, true);
 			break;
 
 		case 3:
@@ -1731,9 +1731,9 @@ void Scene508::actions() {
 void Scene511::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x345);
-	_scene->addActiveVocab(0x87);
-	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(NOUN_BOAT);
+	_scene->addActiveVocab(NOUN_FISHING_LINE);
+	_scene->addActiveVocab(NOUN_WALK_TO);
 }
 
 void Scene511::enter() {
@@ -1747,10 +1747,10 @@ void Scene511::enter() {
 		_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('b', 0));
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 3);
-		_scene->_hotspots.activate(0x345, false);
+		_scene->_hotspots.activate(NOUN_BOAT, false);
 		int idx = _scene->_dynamicHotspots.add(0x345, VERB_WALKTO, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(75, 124), FACING_NORTH);
-		_scene->_hotspots.activate(0x347, false);
+		_scene->_hotspots.activate(NOUN_ROPE, false);
 	} else {
 		_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('b', 2));
 		_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('b', 3));
@@ -1765,8 +1765,8 @@ void Scene511::enter() {
 		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[6],5);
 
-		_scene->_hotspots.activate(0x347, true);
-		_scene->_hotspots.activate(0x345, true);
+		_scene->_hotspots.activate(NOUN_ROPE, true);
+		_scene->_hotspots.activate(NOUN_BOAT, true);
 		_scene->changeVariant(1);
 	}
 
@@ -2052,10 +2052,10 @@ void Scene511::actions() {
 void Scene512::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x88);
-	_scene->addActiveVocab(0xD);
-	_scene->addActiveVocab(0xFF);
-	_scene->addActiveVocab(0x366);
+	_scene->addActiveVocab(NOUN_FISHING_ROD);
+	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(NOUN_PADLOCK_KEY);
+	_scene->addActiveVocab(NOUN_REGISTER_DRAWER);
 }
 
 void Scene512::enter() {
@@ -2076,7 +2076,7 @@ void Scene512::enter() {
 	if (!_game._visitedScenes._sceneRevisited)
 		_globals[kRegisterOpen] = false;
 
-	_scene->_hotspots.activate(0xFF, false);
+	_scene->_hotspots.activate(NOUN_PADLOCK_KEY, false);
 	if (_game._difficulty == DIFFICULTY_EASY) {
 		if (_game._objects[OBJ_PADLOCK_KEY]._roomNumber == _scene->_currentSceneId) {
 			_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 10, 0, 0, 0);
@@ -2087,20 +2087,20 @@ void Scene512::enter() {
 		if (_globals[kRegisterOpen]) {
 			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
-			_scene->_hotspots.activate(0xFF, false);
+			_scene->_hotspots.activate(NOUN_PADLOCK_KEY, false);
 		}
 	} else if (_globals[kRegisterOpen]) {
 		if (_game._objects[OBJ_PADLOCK_KEY]._roomNumber == _scene->_currentSceneId) {
-			_scene->_hotspots.activate(0xFF, true);
+			_scene->_hotspots.activate(NOUN_PADLOCK_KEY, true);
 			_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, -2);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 3);
 		} else {
-			_scene->_hotspots.activate(0xFF, false);
+			_scene->_hotspots.activate(NOUN_PADLOCK_KEY, false);
 			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
 		}
 	} else
-		_scene->_hotspots.activate(0xFF, false);
+		_scene->_hotspots.activate(NOUN_PADLOCK_KEY, false);
 
 	if (_scene->_priorSceneId != -2) {
 		_game._player._playerPos = Common::Point(144, 152);
@@ -2190,7 +2190,7 @@ void Scene512::actions() {
 			case 5:
 				_globals._sequenceIndexes[5] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], false, 14, 0, 0, 0);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 3);
-				_scene->_hotspots.activate(0xFF, true);
+				_scene->_hotspots.activate(NOUN_PADLOCK_KEY, true);
 				_scene->_sequences.addTimer(60, 6);
 				break;
 
@@ -2227,7 +2227,7 @@ void Scene512::actions() {
 				_scene->_sequences.remove(_globals._sequenceIndexes[5]);
 				_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 12, 1, 0, 0);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 3);
-				_scene->_hotspots.activate(0xFF, false);
+				_scene->_hotspots.activate(NOUN_PADLOCK_KEY, false);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 			}
 			break;
@@ -2268,7 +2268,7 @@ void Scene512::actions() {
 					_scene->_sequences.remove(_globals._sequenceIndexes[5]);
 					_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
 					_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 3);
-					_scene->_hotspots.activate(0xFF, false);
+					_scene->_hotspots.activate(NOUN_PADLOCK_KEY, false);
 				}
 				_vm->_sound->command(9);
 				_game._objects.addToInventory(OBJ_PADLOCK_KEY);
@@ -2346,8 +2346,8 @@ void Scene512::actions() {
 void Scene513::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x367);
-	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(NOUN_ELEVATOR_DOOR);
+	_scene->addActiveVocab(NOUN_WALK_TO);
 }
 
 void Scene513::enter() {
@@ -2690,7 +2690,7 @@ void Scene551::step() {
 }
 
 void Scene551::preActions() {
-	if (_action.isAction(VERB_WALK_DOWN) && (_action.isObject(0x360) || _action.isObject(0x361)))
+	if (_action.isAction(VERB_WALK_DOWN) && (_action.isObject(NOUN_STREET_TO_WEST) || _action.isObject(NOUN_SIDEWALK_TO_WEST)))
 		_game._player._walkOffScreenSceneId = 501;
 }
 
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index acadb82..6cea5cb 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -86,8 +86,8 @@ void Scene6xx::sceneEntrySound() {
 void Scene601::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x343);
-	_scene->addActiveVocab(0xD1);
+	_scene->addActiveVocab(NOUN_LASER_BEAM);
+	_scene->addActiveVocab(NOUN_LOOK_AT);
 }
 
 void Scene601::enter() {
@@ -220,9 +220,9 @@ void Scene601::actions() {
 void Scene602::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0xD);
-	_scene->addActiveVocab(0x3D3);
-	_scene->addActiveVocab(0x343);
+	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(NOUN_SAFE);
+	_scene->addActiveVocab(NOUN_LASER_BEAM);
 }
 
 void Scene602::enter() {
@@ -244,7 +244,7 @@ void Scene602::enter() {
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(80, 134), FACING_NORTHEAST);
 		_scene->changeVariant(1);
 	} else
-		_scene->_hotspots.activate(0x342, false);
+		_scene->_hotspots.activate(NOUN_HOLE, false);
 
 	if (_globals[kSafeStatus] == 0) {
 		_lastSpriteIdx = _globals._spriteIndexes[2];
@@ -270,9 +270,9 @@ void Scene602::enter() {
 		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, -1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 15);
 		if (_globals[kSafeStatus] == 0 || _globals[kSafeStatus] == 2)
-			_scene->_hotspots.activate(0x6F, false);
+			_scene->_hotspots.activate(NOUN_DOOR_KEY, false);
 	} else
-		_scene->_hotspots.activate(0x6F, false);
+		_scene->_hotspots.activate(NOUN_DOOR_KEY, false);
 
 	if (_scene->_priorSceneId == 603) {
 		_game._player._playerPos = Common::Point(228, 126);
@@ -320,7 +320,7 @@ void Scene602::handleSafeActions() {
 				_lastSequenceIdx = _scene->_sequences.addSpriteCycle(_lastSpriteIdx, false, 12, 1, 0, 0);
 				_scene->_sequences.setDepth(_lastSequenceIdx, 14);
 				if (_game._objects[OBJ_DOOR_KEY]._roomNumber == _scene->_currentSceneId)
-					_scene->_hotspots.activate(0x6F, true);
+					_scene->_hotspots.activate(NOUN_DOOR_KEY, true);
 
 				_scene->_sequences.addSubEntry(_lastSequenceIdx,
 					SEQUENCE_TRIGGER_EXPIRE, 0, 2);
@@ -335,7 +335,7 @@ void Scene602::handleSafeActions() {
 			_lastSequenceIdx = _scene->_sequences.startReverseCycle(_lastSpriteIdx, false, 12, 1, 0, 0);
 			_scene->_sequences.setDepth(_lastSequenceIdx, 14);
 			if (_game._objects[OBJ_DOOR_KEY]._roomNumber == _scene->_currentSceneId)
-				_scene->_hotspots.activate(0x6F, false);
+				_scene->_hotspots.activate(NOUN_DOOR_KEY, false);
 
 			_scene->_sequences.addSubEntry(_lastSequenceIdx, SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 		}
@@ -453,7 +453,7 @@ void Scene602::actions() {
 
 		case 1:
 			_scene->_sequences.remove(_globals._sequenceIndexes[6]);
-			_scene->_hotspots.activate(0x6F, false);
+			_scene->_hotspots.activate(NOUN_DOOR_KEY, false);
 			_vm->_sound->command(9);
 			_game._objects.addToInventory(OBJ_DOOR_KEY);
 			break;
@@ -533,9 +533,9 @@ void Scene602::actions() {
 void Scene603::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0xD);
-	_scene->addActiveVocab(0x57);
-	_scene->addActiveVocab(0x3A8);
+	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(NOUN_COMPACT_CASE);
+	_scene->addActiveVocab(NOUN_NOTE);
 }
 
 void Scene603::enter() {
@@ -675,9 +675,9 @@ void Scene603::actions() {
 void Scene604::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x468);
+	_scene->addActiveVocab(NOUN_SEA_MONSTER);
 	_scene->addActiveVocab(VERB_WALKTO);
-	_scene->addActiveVocab(0x171);
+	_scene->addActiveVocab(NOUN_TIMEBOMB);
 }
 
 void Scene604::enter() {
@@ -988,7 +988,7 @@ void Scene605::actions() {
 void Scene607::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x471);
+	_scene->addActiveVocab(NOUN_OBNOXIOUS_DOG);
 	_scene->addActiveVocab(VERB_WALKTO);
 }
 
@@ -1017,7 +1017,7 @@ void Scene607::enter() {
 		_dogEatsRex = false;
 		_dogTimer = 0;
 	} else
-		_scene->_hotspots.activate(0x471, false);
+		_scene->_hotspots.activate(NOUN_OBNOXIOUS_DOG, false);
 
 	_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -2);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
@@ -1076,7 +1076,7 @@ void Scene607::step() {
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 6);
 		_dogBarking = false;
 		_globals[kDogStatus] = 1;
-		_scene->_hotspots.activate(0x471, true);
+		_scene->_hotspots.activate(NOUN_OBNOXIOUS_DOG, true);
 	}
 
 	if (!_dogEatsRex && (_game._difficulty != DIFFICULTY_EASY) && !_animationActive && (_globals[kDogStatus] == 1)
@@ -1247,7 +1247,7 @@ void Scene607::handleThrowingBone() {
 		_game._player._priorTimer = _scene->_activeAnimation->getNextFrameTimer() - _game._player._ticksAmount;
 
 		if (_animationMode != 1)
-			_scene->_hotspots.activate(0x471, false);
+			_scene->_hotspots.activate(NOUN_OBNOXIOUS_DOG, false);
 		else {
 			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 6);
@@ -1421,10 +1421,10 @@ void Scene607::actions() {
 void Scene608::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0xD);
-	_scene->addActiveVocab(0x115);
-	_scene->addActiveVocab(0x324);
-	_scene->addActiveVocab(0x471);
+	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(NOUN_POLYCEMENT);
+	_scene->addActiveVocab(NOUN_CAR);
+	_scene->addActiveVocab(NOUN_OBNOXIOUS_DOG);
 }
 
 void Scene608::resetDogVariables() {
@@ -2438,7 +2438,7 @@ void Scene609::step() {
 		break;
 
 	case 61:
-		_scene->_hotspots.activate(0x425, false);
+		_scene->_hotspots.activate(NOUN_VIDEO_STORE_DOOR, false);
 		_game._player.walk(Common::Point(101, 100), FACING_EAST);
 		_scene->_sequences.addTimer(180, 62);
 		break;
@@ -2446,7 +2446,7 @@ void Scene609::step() {
 	case 62:
 		_scene->_sequences.remove( _globals._sequenceIndexes[2]);
 		_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 7, 1, 0, 0);
-		_scene->_hotspots.activate(0x425, true);
+		_scene->_hotspots.activate(NOUN_VIDEO_STORE_DOOR, true);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 9);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 63);
 		break;
@@ -2550,7 +2550,7 @@ void Scene609::enterStore() {
 		break;
 
 	case 6:
-		_scene->_hotspots.activate(0x425, false);
+		_scene->_hotspots.activate(NOUN_VIDEO_STORE_DOOR, false);
 		if (_videoDoorMode == 1) {
 			_scene->_kernelMessages.reset();
 			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 180, _game.getQuote(0x307));
@@ -2567,7 +2567,7 @@ void Scene609::enterStore() {
 		break;
 
 	case 8:
-		_scene->_hotspots.activate(0x425, true);
+		_scene->_hotspots.activate(NOUN_VIDEO_STORE_DOOR, true);
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 9);
 		_globals[kBeenInVideoStore] = true;
@@ -2704,8 +2704,8 @@ void Scene609::actions() {
 void Scene610::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x108);
-	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(NOUN_PHONE_HANDSET);
+	_scene->addActiveVocab(NOUN_WALK_TO);
 }
 
 void Scene610::enter() {
@@ -2887,8 +2887,8 @@ void Scene610::actions() {
 void Scene611::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x275);
-	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(NOUN_RAT);
+	_scene->addActiveVocab(NOUN_WALK_TO);
 }
 
 void Scene611::handleRatMoves() {
@@ -3756,7 +3756,7 @@ void Scene611::enter() {
 		_stickFingerFl = false;
 	} else {
 		_hermitMode = 0;
-		_scene->_hotspots.activate(0x45A, false);
+		_scene->_hotspots.activate(NOUN_HERMIT, false);
 	}
 
 	// CHECKME: The last line of the block looks extremely useless
@@ -4117,7 +4117,7 @@ void Scene611::step() {
 			_startTradingFl = false;
 			_nextFrame = 52;
 			_globals[kHasTalkedToHermit] = true;
-			_scene->_hotspots.activate(0x45A, false);
+			_scene->_hotspots.activate(NOUN_HERMIT, false);
 		} else {
 			_game._player._stepEnabled = true;
 			_hermitMode = 1;
@@ -4262,8 +4262,8 @@ void Scene611::actions() {
 void Scene612::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x87);
-	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(NOUN_FISHING_LINE);
+	_scene->addActiveVocab(NOUN_WALK_TO);
 }
 
 void Scene612::handleWinchMovement() {
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index a4dd432..c0755e8 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -646,7 +646,7 @@ void Scene703::enter() {
 	_boatFrame = -1;
 
 	if (!_globals[kMonsterAlive])
-		_scene->_hotspots.activate(0x468, false);
+		_scene->_hotspots.activate(NOUN_SEA_MONSTER, false);
 
 	if (_scene->_priorSceneId == 704) {
 		_game._player._stepEnabled = false;
@@ -960,7 +960,7 @@ void Scene703::step() {
 				break;
 
 			case 126:
-				_scene->_hotspots.activate(0x468, false);
+				_scene->_hotspots.activate(NOUN_SEA_MONSTER, false);
 				_globals[kMonsterAlive] = false;
 				_scene->freeAnimation();
 				_monsterMode = 0;
@@ -1073,8 +1073,8 @@ void Scene703::actions() {
 void Scene704::setup() {
 	_game._player._spritesPrefix = "";
 	setAAName();
-	_scene->addActiveVocab(0x2E);
-	_scene->addActiveVocab(0xD1);
+	_scene->addActiveVocab(NOUN_BOTTLE);
+	_scene->addActiveVocab(NOUN_LOOK_AT);
 }
 
 void Scene704::handleBottleInterface() {
@@ -1676,9 +1676,9 @@ void Scene705::actions() {
 void Scene706::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x2E);
-	_scene->addActiveVocab(0x17D);
-	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(NOUN_BOTTLE);
+	_scene->addActiveVocab(NOUN_VASE);
+	_scene->addActiveVocab(NOUN_WALK_TO);
 }
 
 void Scene706::handleRexDeath() {
@@ -2085,8 +2085,8 @@ void Scene711::actions() {
 void Scene751::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x87);
-	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(NOUN_FISHING_LINE);
+	_scene->addActiveVocab(NOUN_WALK_TO);
 }
 
 void Scene751::enter() {
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 3604c8b..9c53855 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -305,9 +305,9 @@ void Scene801::actions() {
 void Scene802::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x137);
-	_scene->addActiveVocab(0xD);
-	_scene->addActiveVocab(0x123);
+	_scene->addActiveVocab(NOUN_SHIELD_MODULATOR);
+	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(NOUN_REMOTE);
 }
 
 void Scene802::enter() {
@@ -513,8 +513,8 @@ void Scene802::actions() {
 void Scene803::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x472);
-	_scene->addActiveVocab(0xD);
+	_scene->addActiveVocab(NOUN_GUTS);
+	_scene->addActiveVocab(NOUN_WALK_TO);
 
 	if ((!_globals[kFromCockpit] && _globals[kReturnFromCut] && !_globals[kBeamIsUp])
 		|| (_globals[kFromCockpit] && !_globals[kExitShip])) {
@@ -1060,9 +1060,9 @@ void Scene804::step() {
 void Scene805::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(0x476);
-	_scene->addActiveVocab(0x167);
-	_scene->addActiveVocab(0x137);
+	_scene->addActiveVocab(NOUN_REMOVE);
+	_scene->addActiveVocab(NOUN_TARGET_MODULE);
+	_scene->addActiveVocab(NOUN_SHIELD_MODULATOR);
 }
 
 void Scene805::enter() {


Commit: e2a67595338edc7ae11257099fb8140599d2f471
    https://github.com/scummvm/scummvm/commit/e2a67595338edc7ae11257099fb8140599d2f471
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T12:56:05+03:00

Commit Message:
MADS: Fix a bug in scene 104

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 5187b78..6492006 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -1719,7 +1719,7 @@ void Scene104::preActions() {
 	if (_action.isAction(VERB_SWIM_TOWARDS, NOUN_EASTERN_CLIFF_FACE))
 		_game._player._walkOffScreenSceneId = 105;
 
-	if (_action.isAction(VERB_SWIM_TOWARDS, NOUN_EAT))
+	if (_action.isAction(VERB_SWIM_TOWARDS, NOUN_OPEN_AREA_TO_SOUTH))
 		_game._player._walkOffScreenSceneId = 106;
 }
 


Commit: 5aa63bc71a2e559fea6ce62e4b995a6ece47e495
    https://github.com/scummvm/scummvm/commit/5aa63bc71a2e559fea6ce62e4b995a6ece47e495
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T12:56:21+03:00

Commit Message:
MADS: Rename several nouns to verbs

Changed paths:
    engines/mads/nebular/nebular_scenes.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes8.cpp



diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index d97fa4b..ec06a1b 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -40,11 +40,17 @@ enum {
 
 enum Verb {
 	VERB_ACTIVATE       = 0x00E,
+	VERB_ATTACH         = 0x019,
+	VERB_BREAK          = 0x032,
+	VERB_BREATHE_AIR    = 0x033,
 	VERB_CAST           = 0x03D,
 	VERB_CLIMB_DOWN     = 0x04E,
 	VERB_CLIMB_THROUGH  = 0x04F,
 	VERB_CLIMB_UP       = 0x050,
+	VERB_CUT            = 0x061,
+	VERB_DAMPEN         = 0x064,
 	VERB_DIVE_INTO      = 0x06D,
+	NOUN_DRINK          = 0x072,
 	VERB_EAT            = 0x075,
 	VERB_EXAMINE        = 0x07D,
 	VERB_HOSE_DOWN      = 0x0A6,
@@ -98,21 +104,21 @@ enum Verb {
 };
 
 enum Noun {
-	NOUN_GAME = 0x1,
-	NOUN_QSAVE = 0x2,
-	NOUN_LOOK = 0x3,
-	NOUN_TAKE = 0x4,
-	NOUN_PUSH = 0x5,
-	NOUN_OPEN = 0x6,
-	NOUN_PUT = 0x7,
-	NOUN_TALK_TO = 0x8,
-	NOUN_GIVE = 0x9,
-	NOUN_PULL = 0xA,
-	NOUN_CLOSE = 0xB,
-	NOUN_THROW = 0xC,
-	NOUN_WALK_TO = 0xD,
-	NOUN_ACTIVATE = 0xE,
-	NOUN_ADMIRE = 0xF,
+	//NOUN_GAME = 0x1,
+	//NOUN_QSAVE = 0x2,
+	//NOUN_LOOK = 0x3,
+	//NOUN_TAKE = 0x4,
+	//NOUN_PUSH = 0x5,
+	//NOUN_OPEN = 0x6,
+	//NOUN_PUT = 0x7,
+	//NOUN_TALK_TO = 0x8,
+	//NOUN_GIVE = 0x9,
+	//NOUN_PULL = 0xA,
+	//NOUN_CLOSE = 0xB,
+	//NOUN_THROW = 0xC,
+	//NOUN_WALK_TO = 0xD,
+	//NOUN_ACTIVATE = 0xE,
+	//NOUN_ADMIRE = 0xF,
 	NOUN_ADSM = 0x10,
 	NOUN_AIR_VENT = 0x11,
 	NOUN_ALOE_PLANT = 0x12,
@@ -122,7 +128,7 @@ enum Noun {
 	NOUN_AREA_TO_SOUTH = 0x16,
 	NOUN_AREA_TO_WEST = 0x17,
 	NOUN_AROMATIC_MEAT = 0x18,
-	NOUN_ATTACH = 0x19,
+	//NOUN_ATTACH = 0x19,
 	NOUN_AUDIO_TAPE = 0x1A,
 	NOUN_AUXILIARY_POWER = 0x1B,
 	NOUN_BADMITTON_BRAT = 0x1C,
@@ -147,8 +153,8 @@ enum Noun {
 	NOUN_BOULDER = 0x2F,
 	NOUN_BOULDERS = 0x30,
 	NOUN_BRA = 0x31,
-	NOUN_BREAK = 0x32,
-	NOUN_BREATHE_AIR = 0x33,
+	//NOUN_BREAK = 0x32,
+	//NOUN_BREATHE_AIR = 0x33,
 	NOUN_BULKHEAD = 0x34,
 	NOUN_BURGER = 0x35,
 	NOUN_BURN = 0x36,
@@ -158,7 +164,7 @@ enum Noun {
 	NOUN_BUSHY_FERN = 0x3A,
 	NOUN_CACTUS = 0x3B,
 	NOUN_CARD = 0x3C,
-	NOUN_CAST = 0x3D,
+	//NOUN_CAST = 0x3D,
 	NOUN_CAULDRON = 0x3E,
 	NOUN_CAVE = 0x3F,
 	NOUN_CAVE_CEILING = 0x40,
@@ -194,10 +200,10 @@ enum Noun {
 	NOUN_CURIOUS_WEED_PATCH = 0x5E,
 	NOUN_CURTAIN = 0x5F,
 	NOUN_CURTAINS = 0x60,
-	NOUN_CUT = 0x61,
+	//NOUN_CUT = 0x61,
 	NOUN_DAMAGE_CONTROL = 0x62,
 	NOUN_DAMAGE_CONTROL_PANEL = 0x63,
-	NOUN_DAMPEN = 0x64,
+	//NOUN_DAMPEN = 0x64,
 	NOUN_DEAD_FISH = 0x65,
 	NOUN_DEAD_PURPLE_MONSTER = 0x66,
 	NOUN_DECLIVITOUS_CHASM = 0x67,
@@ -205,24 +211,24 @@ enum Noun {
 	NOUN_DENSE_FOREST = 0x69,
 	NOUN_DETONATORS = 0x6A,
 	NOUN_DINO_MITE = 0x6B,
-	NOUN_DISASSEMBLE = 0x6C,
-	NOUN_DIVE_INTO = 0x6D,
+	//NOUN_DISASSEMBLE = 0x6C,
+	//NOUN_DIVE_INTO = 0x6D,
 	NOUN_DOOR = 0x6E,
 	NOUN_DOOR_KEY = 0x6F,
 	NOUN_DOORWAY = 0x70,
 	NOUN_DRAWER = 0x71,
-	NOUN_DRINK = 0x72,
+	//NOUN_DRINK = 0x72,
 	NOUN_DURAFAIL_CELLS = 0x73,
 	NOUN_EASTERN_CLIFF_FACE = 0x74,
-	NOUN_EAT = 0x75,
-	NOUN_EJECT = 0x76,
-	NOUN_EMPTY = 0x77,
+	//NOUN_EAT = 0x75,
+	//NOUN_EJECT = 0x76,
+	//NOUN_EMPTY = 0x77,
 	NOUN_ENGINEERING_CONTROLS = 0x78,
 	NOUN_ENGINEERING_SECTION = 0x79,
 	NOUN_ENTER_KEY = 0x7A,
 	NOUN_ESCAPE_HATCH = 0x7B,
 	NOUN_ESTROTOXIN = 0x7C,
-	NOUN_EXAMINE = 0x7D,
+	//NOUN_EXAMINE = 0x7D,
 	NOUN_EXPERIMENT_CAGE = 0x7E,
 	NOUN_EXTINGUISH = 0x7F,
 	NOUN_FACE_ID = 0x80,
@@ -237,36 +243,36 @@ enum Noun {
 	NOUN_FLOOR = 0x89,
 	NOUN_FLOOR_OF_HUT = 0x8A,
 	NOUN_FLOOR_TILE = 0x8B,
-	NOUN_FONDLE = 0x8C,
+	//NOUN_FONDLE = 0x8C,
 	NOUN_FOREST_TO_EAST = 0x8D,
 	NOUN_FRONT_WINDOW = 0x8E,
 	NOUN_FUNGOIDS = 0x8F,
 	NOUN_FURNACE = 0x90,
 	NOUN_FUZZY_DICE = 0x91,
-	NOUN_GAZE = 0x92,
-	NOUN_GAZE_AT = 0x93,
-	NOUN_GAZE_IN = 0x94,
-	NOUN_GLANCE_AT = 0x95,
+	//NOUN_GAZE = 0x92,
+	//NOUN_GAZE_AT = 0x93,
+	//NOUN_GAZE_IN = 0x94,
+	//NOUN_GLANCE_AT = 0x95,
 	NOUN_GLOVE = 0x96,
 	NOUN_GNARLY_SHRUB = 0x97,
-	NOUN_GNAW_ON = 0x98,
-	NOUN_GORGE_ON = 0x99,
+	//NOUN_GNAW_ON = 0x98,
+	//NOUN_GORGE_ON = 0x99,
 	NOUN_GRAIN_ALCHOHOL = 0x9A,
 	NOUN_GRASSLAND_TO_EAST = 0x9B,
 	NOUN_GRASSLAND_TO_SOUTH = 0x9C,
 	NOUN_GRASSY_AREA = 0x9D,
 	NOUN_GRASSY_AREA_TO_NORTH = 0x9E,
 	NOUN_GRASSY_KNOLL = 0x9F,
-	NOUN_GRIND = 0xA0,
+	//NOUN_GRIND = 0xA0,
 	NOUN_GROOVILACTIC_TREE = 0xA1,
 	NOUN_GUARDS_ARM = 0xA2,
 	NOUN_HATCHWAY = 0xA3,
-	NOUN_HOOK_UP = 0xA4,
+	//NOUN_HOOK_UP = 0xA4,
 	NOUN_HORIZON = 0xA5,
-	NOUN_HOSE_DOWN = 0xA6,
+	//NOUN_HOSE_DOWN = 0xA6,
 	NOUN_HOTPANTS = 0xA7,
 	NOUN_HULL = 0xA8,
-	NOUN_HURL = 0xA9,
+	//NOUN_HURL = 0xA9,
 	NOUN_HUT = 0xAA,
 	NOUN_HUT_AREA = 0xAB,
 	NOUN_HUT_TO_EAST = 0xAC,
@@ -277,10 +283,10 @@ enum Noun {
 	NOUN_HYDROSPANNER = 0xB1,
 	NOUN_HYPERDRIVE_JUMP_UNIT = 0xB2,
 	NOUN_ID_CARD = 0xB3,
-	NOUN_IGNITE = 0xB4,
-	NOUN_INFLATE = 0xB5,
-	NOUN_INSERT = 0xB6,
-	NOUN_INSPECT = 0xB7,
+	//NOUN_IGNITE = 0xB4,
+	//NOUN_INFLATE = 0xB5,
+	//NOUN_INSERT = 0xB6,
+	//NOUN_INSPECT = 0xB7,
 	NOUN_JUNGLE = 0xB8,
 	NOUN_JUNGLE_TO_EAST = 0xB9,
 	NOUN_JUNGLE_TO_WEST = 0xBA,
@@ -298,17 +304,17 @@ enum Noun {
 	NOUN_KNIFE = 0xC6,
 	NOUN_LADDER = 0xC7,
 	NOUN_LARGE_STALAGMITE = 0xC8,
-	NOUN_LEER_AT = 0xC9,
+	//NOUN_LEER_AT = 0xC9,
 	NOUN_LIBRARY_COMPUTER = 0xCA,
-	NOUN_LICK = 0xCB,
+	//NOUN_LICK = 0xCB,
 	NOUN_LIFE_SUPPORT_SECTION = 0xCC,
 	NOUN_LIGHT = 0xCD,
-	NOUN_LOAD = 0xCE,
-	NOUN_LOCK = 0xCF,
+	//NOUN_LOAD = 0xCE,
+	//NOUN_LOCK = 0xCF,
 	NOUN_LOG = 0xD0,
-	NOUN_LOOK_AT = 0xD1,
-	NOUN_LOOK_IN = 0xD2,
-	NOUN_LOOK_THROUGH = 0xD3,
+	//NOUN_LOOK_AT = 0xD1,
+	//NOUN_LOOK_IN = 0xD2,
+	//NOUN_LOOK_THROUGH = 0xD3,
 	NOUN_LOUNGE_AREA = 0xD4,
 	NOUN_LOVE_ALTAR = 0xD5,
 	NOUN_LOWLANDS = 0xD6,
@@ -371,7 +377,7 @@ enum Noun {
 	NOUN_PLANT_STALK = 0x10F,
 	NOUN_PLANTS = 0x110,
 	NOUN_PLASTIC_JESUS = 0x111,
-	NOUN_PLAY = 0x112,
+	//NOUN_PLAY = 0x112,
 	NOUN_PLUNGER = 0x113,
 	NOUN_POISON_DARTS = 0x114,
 	NOUN_POLYCEMENT = 0x115,
@@ -379,12 +385,12 @@ enum Noun {
 	NOUN_POSTER = 0x117,
 	NOUN_POWER_STATUS_PANEL = 0x118,
 	NOUN_PRECIPICE = 0x119,
-	NOUN_PRESS = 0x11A,
+	//NOUN_PRESS = 0x11A,
 	NOUN_PRESSURE_GAUGE = 0x11B,
-	NOUN_PRY = 0x11C,
+	//NOUN_PRY = 0x11C,
 	NOUN_RAGING_RIVER = 0x11D,
 	NOUN_RAMOLYAN_RUGBY_RATS = 0x11E,
-	NOUN_READ = 0x11F,
+	//NOUN_READ = 0x11F,
 	NOUN_REARVIEW_MIRROR = 0x120,
 	NOUN_REBREATHER = 0x121,
 	NOUN_REFRIGERATOR = 0x122,
@@ -403,7 +409,7 @@ enum Noun {
 	NOUN_SEAWEED = 0x12F,
 	NOUN_SEAWEED_BANK = 0x130,
 	NOUN_SECURITY_CARD = 0x131,
-	NOUN_SET = 0x132,
+	//NOUN_SET = 0x132,
 	NOUN_SHAKE_HANDS = 0x133,
 	NOUN_SHARPEN = 0x134,
 	NOUN_SHIELD_ACCESS_PANEL = 0x135,
@@ -411,48 +417,48 @@ enum Noun {
 	NOUN_SHIELD_MODULATOR = 0x137,
 	NOUN_SHIELD_STATUS_PANEL = 0x138,
 	NOUN_SHIP = 0x139,
-	NOUN_SHOOT = 0x13A,
+	//NOUN_SHOOT = 0x13A,
 	NOUN_SHOVEL = 0x13B,
-	NOUN_SHRED = 0x13C,
+	//NOUN_SHRED = 0x13C,
 	NOUN_SHRUNKEN_HEADS = 0x13D,
 	NOUN_SINGED_MEAT = 0x13E,
-	NOUN_SIT_IN = 0x13F,
+	//NOUN_SIT_IN = 0x13F,
 	NOUN_SKULL = 0x140,
 	NOUN_SKULL_AND_CROSSBONES = 0x141,
 	NOUN_SKY = 0x142,
-	NOUN_SLEEP_ON = 0x143,
+	//NOUN_SLEEP_ON = 0x143,
 	NOUN_SLITHERING_SNAKE = 0x144,
 	NOUN_SLUG_SECRETION = 0x145,
 	NOUN_SMALL_HOLE = 0x146,
-	NOUN_SMELL = 0x147,
+	//NOUN_SMELL = 0x147,
 	NOUN_SNAKE = 0x148,
-	NOUN_SNIFF = 0x149,
-	NOUN_SOAK = 0x14A,
+	//NOUN_SNIFF = 0x149,
+	//NOUN_SOAK = 0x14A,
 	NOUN_SPECIAL_KEY_1 = 0x14B,
 	NOUN_SPECIAL_KEY_2 = 0x14C,
 	NOUN_SPIDER = 0x14D,
 	NOUN_SPILT_MILK = 0x14E,
 	NOUN_SPIT_FIRE = 0x14F,
-	NOUN_SPRAY = 0x150,
-	NOUN_STAB = 0x151,
+	//NOUN_SPRAY = 0x150,
+	//NOUN_STAB = 0x151,
 	NOUN_STAIRS = 0x152,
 	NOUN_STALAGMITES = 0x153,
-	NOUN_STAND_INSIDE = 0x154,
-	NOUN_STARE_AT = 0x155,
+	//NOUN_STAND_INSIDE = 0x154,
+	//NOUN_STARE_AT = 0x155,
 	NOUN_STEPS = 0x156,
 	NOUN_STUFFED_FISH = 0x157,
 	NOUN_SURFACE = 0x158,
-	NOUN_SWIM_ACROSS = 0x159,
-	NOUN_SWIM_INTO = 0x15A,
-	NOUN_SWIM_THROUGH = 0x15B,
-	NOUN_SWIM_TO = 0x15C,
-	NOUN_SWIM_TOWARDS = 0x15D,
-	NOUN_SWIM_UNDER = 0x15E,
+	//NOUN_SWIM_ACROSS = 0x159,
+	//NOUN_SWIM_INTO = 0x15A,
+	//NOUN_SWIM_THROUGH = 0x15B,
+	//NOUN_SWIM_TO = 0x15C,
+	//NOUN_SWIM_TOWARDS = 0x15D,
+	//NOUN_SWIM_UNDER = 0x15E,
 	NOUN_SWOOPING_CREATURE = 0x15F,
 	NOUN_TABLE = 0x160,
-	NOUN_TAKE_LIVER = 0x161,
-	NOUN_TAKE_OFF = 0x162,
-	NOUN_TAKE_PAGE = 0x163,
+	//NOUN_TAKE_LIVER = 0x161,
+	//NOUN_TAKE_OFF = 0x162,
+	//NOUN_TAKE_PAGE = 0x163,
 	NOUN_TALL_GRASS = 0x164,
 	NOUN_TAPE_PLAYER = 0x165,
 	NOUN_TARGET_COMPUTER = 0x166,
@@ -465,7 +471,7 @@ enum Noun {
 	NOUN_THATCHED_ROOF = 0x16D,
 	NOUN_THORNS = 0x16E,
 	NOUN_THORNY_BUSH = 0x16F,
-	NOUN_TIE = 0x170,
+	//NOUN_TIE = 0x170,
 	NOUN_TIMEBOMB = 0x171,
 	NOUN_TIMER = 0x172,
 	NOUN_TIMER_MODULE = 0x173,
@@ -476,11 +482,11 @@ enum Noun {
 	NOUN_TUNNEL = 0x178,
 	NOUN_TWINKIE_BUSH = 0x179,
 	NOUN_TWINKIFRUIT = 0x17A,
-	NOUN_UNLOCK = 0x17B,
+	//NOUN_UNLOCK = 0x17B,
 	NOUN_UZI = 0x17C,
 	NOUN_VASE = 0x17D,
 	NOUN_VIDEO_GAME = 0x17E,
-	NOUN_VIEW = 0x17F,
+	//NOUN_VIEW = 0x17F,
 	NOUN_VIEW_SCREEN = 0x180,
 	NOUN_VIEWPORT = 0x181,
 	NOUN_VILLAGE_AREA = 0x182,
@@ -488,17 +494,17 @@ enum Noun {
 	NOUN_VOLCANO = 0x184,
 	NOUN_VULTURE = 0x185,
 	NOUN_WAD_OF_CATTLE_PARTS = 0x186,
-	NOUN_WALK_ACROSS = 0x187,
-	NOUN_WALK_INSIDE = 0x188,
-	NOUN_WALK_ON = 0x189,
-	NOUN_WALK_OUTSIDE = 0x18A,
-	NOUN_WALK_THROUGH = 0x18B,
-	NOUN_WALK_TOWARDS = 0x18C,
+	//NOUN_WALK_ACROSS = 0x187,
+	//NOUN_WALK_INSIDE = 0x188,
+	//NOUN_WALK_ON = 0x189,
+	//NOUN_WALK_OUTSIDE = 0x18A,
+	//NOUN_WALK_THROUGH = 0x18B,
+	//NOUN_WALK_TOWARDS = 0x18C,
 	NOUN_WALL = 0x18D,
 	NOUN_WATCH_TOWER = 0x18E,
 	NOUN_WATER = 0x18F,
 	NOUN_WEAPONS_DISPLAY = 0x190,
-	NOUN_WEAR = 0x191,
+	//NOUN_WEAR = 0x191,
 	NOUN_WEATHER_STATION = 0x192,
 	NOUN_WEATHER_VANE = 0x193,
 	NOUN_WEIGHT_MACHINE = 0x194,
@@ -507,7 +513,7 @@ enum Noun {
 	NOUN_WINDOW = 0x197,
 	NOUN_WITCHDOCTOR_HUT = 0x198,
 	NOUN_WORKBENCH = 0x199,
-	NOUN_WRITE_ON = 0x19A,
+	//NOUN_WRITE_ON = 0x19A,
 	NOUN_YELLOW_BIRDY = 0x19B,
 	NOUN_GRASS = 0x19C,
 	NOUN_BOUNCING_REPTILE = 0x19D,
@@ -526,7 +532,7 @@ enum Noun {
 	NOUN_PILE_OF_LEAVES = 0x1AA,
 	NOUN_OPEN_FIELD_TO_EAST = 0x1AB,
 	NOUN_LAWN = 0x1AC,
-	NOUN_WALK_DOWN = 0x1AD,
+	//NOUN_WALK_DOWN = 0x1AD,
 	NOUN_PATH_TO_WEST = 0x1AE,
 	NOUN_HEDGE = 0x1AF,
 	NOUN_VILLAGE_PATH = 0x1B0,
@@ -558,8 +564,8 @@ enum Noun {
 	NOUN_BAG_OF_TWINKIFRUITS = 0x1CA,
 	NOUN_BED = 0x1CB,
 	NOUN_DISPLAY = 0x1CC,
-	NOUN_LEAVE = 0x1CD,
-	NOUN_EXIT_FROM = 0x1CE,
+	//NOUN_LEAVE = 0x1CD,
+	//NOUN_EXIT_FROM = 0x1CE,
 	NOUN_DEVICE = 0x1CF,
 	NOUN_0_KEY = 0x1D0,
 	NOUN_1_KEY = 0x1D1,
@@ -597,7 +603,7 @@ enum Noun {
 	NOUN_ELECTRO_SCANNER = 0x1F1,
 	NOUN_HALL = 0x1F2,
 	NOUN_SCANNER = 0x1F3,
-	NOUN_PLACE_HAND_ON = 0x1F4,
+	//NOUN_PLACE_HAND_ON = 0x1F4,
 	NOUN_SECURITY_MONITOR = 0x1F5,
 	NOUN_DIGITORAMA = 0x1F6,
 	NOUN_RAIL_BEAM = 0x1F7,
@@ -618,16 +624,16 @@ enum Noun {
 	NOUN_AIR_DUCT = 0x206,
 	NOUN_CELL_WALL = 0x207,
 	NOUN_LIGHTS = 0x208,
-	NOUN_STARE_INTO = 0x209,
+	//NOUN_STARE_INTO = 0x209,
 	NOUN_CELL_CONTROLS = 0x20A,
 	NOUN_COMMODE = 0x20B,
-	NOUN_USE = 0x20C,
+	//NOUN_USE = 0x20C,
 	NOUN_BASIN = 0x20D,
-	NOUN_JUMP_INSIDE = 0x20E,
+	//NOUN_JUMP_INSIDE = 0x20E,
 	NOUN_PREVIOUS_CELL = 0x20F,
 	NOUN_NEXT_ROOM = 0x210,
 	NOUN_ZINK = 0x211,
-	NOUN_GAZE_INTO = 0x212,
+	//NOUN_GAZE_INTO = 0x212,
 	NOUN_THRONE = 0x213,
 	NOUN_SACK = 0x214,
 	NOUN_LIMB = 0x215,
@@ -640,7 +646,7 @@ enum Noun {
 	NOUN_MONITOR_AREA = 0x21C,
 	NOUN_SIDEWALL = 0x21D,
 	NOUN_COFFEE_MUG = 0x21E,
-	NOUN_SIT_AT = 0x21F,
+	//NOUN_SIT_AT = 0x21F,
 	NOUN_LIGHTING_FIXTURE = 0x220,
 	NOUN_MONITORS = 0x221,
 	NOUN_GENDER_CONTROLS = 0x222,
@@ -648,7 +654,7 @@ enum Noun {
 	NOUN_MOLECULAR_RECORDER = 0x224,
 	NOUN_MAINTENANCE_PANEL = 0x225,
 	NOUN_RAMP = 0x226,
-	NOUN_WALK_UP = 0x227,
+	//NOUN_WALK_UP = 0x227,
 	NOUN_SUBSONIC_ATOMIZER = 0x228,
 	NOUN_EIGHT_BALL = 0x229,
 	NOUN_DNA_INVERTER = 0x22A,
@@ -665,7 +671,7 @@ enum Noun {
 	NOUN_SHOCK_MACHINE = 0x235,
 	NOUN_INTERROGATION_TABLE = 0x236,
 	NOUN_LIE_DOWN_ON = 0x237,
-	NOUN_DECIPHER = 0x238,
+	//NOUN_DECIPHER = 0x238,
 	NOUN_GUARD = 0x239,
 	NOUN_RIP_IN_FLOOR = 0x23A,
 	NOUN_TELEPORT_AREA = 0x23B,
@@ -675,7 +681,7 @@ enum Noun {
 	NOUN_WALL_BOARD = 0x23F,
 	NOUN_GENDER_SCANNER = 0x240,
 	NOUN_BAR = 0x241,
-	NOUN_WALK_INTO = 0x242,
+	//NOUN_WALK_INTO = 0x242,
 	NOUN_HALLWAY_TO_SOUTH = 0x243,
 	NOUN_SIGN = 0x244,
 	NOUN_HALLWAY_TO_NORTH = 0x245,
@@ -787,7 +793,7 @@ enum Noun {
 	NOUN_CONTROL_STATION = 0x2AF,
 	NOUN_STRANGE_MONSTER = 0x2B0,
 	NOUN_GHASTLY_BEAST = 0x2B1,
-	NOUN_GAWK_AT = 0x2B2,
+	//NOUN_GAWK_AT = 0x2B2,
 	NOUN_CORRIDOR_TO_SOUTH = 0x2B3,
 	NOUN_CORRIDOR_TO_NORTH = 0x2B4,
 	NOUN_WALK_ONTO = 0x2B5,
@@ -822,7 +828,7 @@ enum Noun {
 	NOUN_BLOOD_STAIN = 0x2D2,
 	NOUN_GRATE = 0x2D3,
 	NOUN_AIR_SHAFT = 0x2D4,
-	NOUN_RETURN_TO = 0x2D5,
+	//NOUN_RETURN_TO = 0x2D5,
 	NOUN_FORMALDEHYDE = 0x2D6,
 	NOUN_PETROX = 0x2D7,
 	NOUN_SODIUM_BENZOATE = 0x2D8,
@@ -858,15 +864,15 @@ enum Noun {
 	NOUN_LAMP = 0x2F6,
 	NOUN_CLIMB_INTO = 0x2F7,
 	NOUN_LIGHT_BULB = 0x2F8,
-	NOUN_STEP_INTO = 0x2F9,
+	//NOUN_STEP_INTO = 0x2F9,
 	NOUN_ROOM = 0x2FA,
-	NOUN_CRAWL_TO = 0x2FB,
+	//NOUN_CRAWL_TO = 0x2FB,
 	NOUN_FOURTH_CELL = 0x2FC,
 	NOUN_THIRD_CELL = 0x2FD,
 	NOUN_SECOND_CELL = 0x2FE,
 	NOUN_FIRST_CELL = 0x2FF,
 	NOUN_EQUIPMENT_ROOM = 0x300,
-	NOUN_CRAWL_DOWN = 0x301,
+	//NOUN_CRAWL_DOWN = 0x301,
 	NOUN_DESCENDING_SHAFT = 0x302,
 	NOUN_SAUROPOD = 0x303,
 	NOUN_MONSTER = 0x304,
@@ -876,14 +882,14 @@ enum Noun {
 	NOUN_INSTRUMENT_TABLE = 0x308,
 	NOUN_WOMAN_ON_BALCONY = 0x309,
 	NOUN_WOMAN_IN_CHAIR = 0x30A,
-	NOUN_SIT_ON = 0x30B,
+	//NOUN_SIT_ON = 0x30B,
 	NOUN_WOMAN_IN_ALCOVE = 0x30C,
 	NOUN_KETTLE = 0x30D,
 	NOUN_BARTENDER = 0x30E,
 	NOUN_WHISKEY = 0x30F,
 	NOUN_ALCOHOL = 0x310,
 	NOUN_RIM = 0x311,
-	NOUN_WALK_ALONG = 0x312,
+	//NOUN_WALK_ALONG = 0x312,
 	NOUN_SUBMERGED_CITY = 0x313,
 	NOUN_GOVERNORS_HOUSE = 0x314,
 	NOUN_RIM_TOWARDS_EAST = 0x315,
@@ -902,7 +908,7 @@ enum Noun {
 	NOUN_SIDEWALK_TO_EAST = 0x322,
 	NOUN_BUILDING = 0x323,
 	NOUN_CAR = 0x324,
-	NOUN_GET_INSIDE = 0x325,
+	//NOUN_GET_INSIDE = 0x325,
 	NOUN_MARQUEE = 0x326,
 	NOUN_BUILDING_ENTRANCE = 0x327,
 	NOUN_GUARD_STATION = 0x328,
@@ -912,7 +918,7 @@ enum Noun {
 	NOUN_PAPERS = 0x32C,
 	NOUN_FILE_CABINET = 0x32D,
 	NOUN_WINDOWS = 0x32E,
-	NOUN_WALK = 0x32F,
+	//NOUN_WALK = 0x32F,
 	NOUN_STORAGE_BOX = 0x330,
 	NOUN_WATER_COOLER = 0x331,
 	NOUN_BOX = 0x332,
@@ -966,12 +972,12 @@ enum Noun {
 	NOUN_TELEPORTER_ENTRANCE = 0x362,
 	NOUN_SOFTWARE_DOOR = 0x363,
 	NOUN_SPINACH_PATCH_DOLL = 0x364,
-	NOUN_REFLECT = 0x365,
+	//NOUN_REFLECT = 0x365,
 	NOUN_REGISTER_DRAWER = 0x366,
 	NOUN_ELEVATOR_DOOR = 0x367,
 	NOUN_HYDRAULIC_SUPPORT = 0x368,
 	NOUN_EQUIPMENT_OVERHEAD = 0x369,
-	NOUN_GET_INTO = 0x36A,
+	//NOUN_GET_INTO = 0x36A,
 	NOUN_WARNING_LABEL = 0x36B,
 	NOUN_NUCLEAR_SLINGSHOT = 0x36C,
 	NOUN_DISPLAY_CASE = 0x36D,
@@ -1031,7 +1037,7 @@ enum Noun {
 	NOUN_WELCOME_MAT = 0x3A3,
 	NOUN_MELON_MUSH = 0x3A4,
 	NOUN_BADMINTON_BRAT = 0x3A5,
-	NOUN_APPLY = 0x3A6,
+	//NOUN_APPLY = 0x3A6,
 	NOUN_COMBINATION = 0x3A7,
 	NOUN_NOTE = 0x3A8,
 	NOUN_LECITHIN = 0x3A9,
@@ -1048,8 +1054,8 @@ enum Noun {
 	NOUN_OPEN_WATER_TO_SOUTH = 0x3B4,
 	NOUN_PROJECTOR = 0x3B5,
 	NOUN_GUARDS_ARM2 = 0x3B6,
-	NOUN_NIBBLE_ON = 0x3B7,
-	NOUN_ENTER = 0x3B8,
+	//NOUN_NIBBLE_ON = 0x3B7,
+	//NOUN_ENTER = 0x3B8,
 	NOUN_ = 0x3B9,
 	NOUN_TIMER_BUTTON_1 = 0x3BA,
 	NOUN_REMOTE_BUTTON_1 = 0x3BB,
@@ -1293,8 +1299,8 @@ enum Noun {
 	NOUN_WEST_END_OF_PLATFORM = 0x4A9,
 	NOUN_EAST_END_OF_PLATFORM = 0x4AA,
 	NOUN_FOLD = 0x4AB,
-	NOUN_SPINDLE = 0x4AC,
-	NOUN_MUTILATE = 0x4AD
+	NOUN_SPINDLE = 0x4AC
+	//NOUN_MUTILATE = 0x4AD
 };
 
 class SceneFactory {
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 083b649..b2076a2 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -4917,7 +4917,7 @@ void Scene214::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 	_scene->addActiveVocab(NOUN_CAPTIVE_CREATURE);
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 }
 
 void Scene214::enter() {
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 95fdd00..8209f0c 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -3868,7 +3868,7 @@ void Scene351::setup() {
 
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 }
 
 void Scene351::enter() {
@@ -4027,7 +4027,7 @@ void Scene352::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 	_scene->addActiveVocab(NOUN_YOUR_STUFF);
 	_scene->addActiveVocab(NOUN_OTHER_STUFF);
 	_scene->addActiveVocab(NOUN_LAMP);
@@ -4815,7 +4815,7 @@ void Scene358::actions() {
 void Scene359::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 }
 
 void Scene359::enter() {
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index 5a68887..195bba5 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -237,13 +237,13 @@ void Scene402::setup() {
 
 	_scene->addActiveVocab(NOUN_BARTENDER);
 	_scene->addActiveVocab(NOUN_ALIEN_LIQUOR);
-	_scene->addActiveVocab(NOUN_DRINK);
+	_scene->addActiveVocab(VERB_DRINK);
 	_scene->addActiveVocab(NOUN_BINOCULARS);
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 	_scene->addActiveVocab(NOUN_CREDIT_CHIP);
-	_scene->addActiveVocab(NOUN_TAKE);
+	_scene->addActiveVocab(VERB_TAKE);
 	_scene->addActiveVocab(NOUN_REPAIR_LIST);
-	_scene->addActiveVocab(NOUN_LOOK_AT);
+	_scene->addActiveVocab(VERB_LOOK_AT);
 }
 
 void Scene402::synchronize(Common::Serializer &s) {
@@ -2850,7 +2850,7 @@ void Scene408::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 	_scene->addActiveVocab(NOUN_TARGET_MODULE);
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 }
 
 void Scene408::enter() {
@@ -3464,7 +3464,7 @@ void Scene411::giveToRex(int object) {
 void Scene411::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 	_scene->addActiveVocab(NOUN_ALIEN_LIQUOR);
 	_scene->addActiveVocab(NOUN_FORMALDEHYDE);
 	_scene->addActiveVocab(NOUN_PETROX);
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index b55262c..fb79492 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -96,7 +96,7 @@ void Scene501::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 	_scene->addActiveVocab(NOUN_DOOR);
-	_scene->addActiveVocab(NOUN_WALK_THROUGH);
+	_scene->addActiveVocab(VERB_WALK_THROUGH);
 }
 
 void Scene501::synchronize(Common::Serializer &s) {
@@ -527,7 +527,7 @@ void Scene503::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 	_scene->addActiveVocab(NOUN_DETONATORS);
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 }
 
 void Scene503::enter() {
@@ -1099,7 +1099,7 @@ void Scene505::actions() {
 void Scene506::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(NOUN_WALK_INTO);
+	_scene->addActiveVocab(VERB_WALK_INTO);
 	_scene->addActiveVocab(NOUN_SOFTWARE_STORE);
 	_scene->addActiveVocab(NOUN_LABORATORY);
 }
@@ -1362,7 +1362,7 @@ void Scene507::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 	_scene->addActiveVocab(NOUN_PENLIGHT);
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 }
 
 void Scene507::enter() {
@@ -1473,7 +1473,7 @@ void Scene508::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 	_scene->addActiveVocab(NOUN_SPINACH_PATCH_DOLL);
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 	_scene->addActiveVocab(NOUN_LASER_BEAM);
 }
 
@@ -1733,7 +1733,7 @@ void Scene511::setup() {
 	setAAName();
 	_scene->addActiveVocab(NOUN_BOAT);
 	_scene->addActiveVocab(NOUN_FISHING_LINE);
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 }
 
 void Scene511::enter() {
@@ -2053,7 +2053,7 @@ void Scene512::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 	_scene->addActiveVocab(NOUN_FISHING_ROD);
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 	_scene->addActiveVocab(NOUN_PADLOCK_KEY);
 	_scene->addActiveVocab(NOUN_REGISTER_DRAWER);
 }
@@ -2347,7 +2347,7 @@ void Scene513::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 	_scene->addActiveVocab(NOUN_ELEVATOR_DOOR);
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 }
 
 void Scene513::enter() {
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index 6cea5cb..e9c4473 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -87,7 +87,7 @@ void Scene601::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 	_scene->addActiveVocab(NOUN_LASER_BEAM);
-	_scene->addActiveVocab(NOUN_LOOK_AT);
+	_scene->addActiveVocab(VERB_LOOK_AT);
 }
 
 void Scene601::enter() {
@@ -220,7 +220,7 @@ void Scene601::actions() {
 void Scene602::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 	_scene->addActiveVocab(NOUN_SAFE);
 	_scene->addActiveVocab(NOUN_LASER_BEAM);
 }
@@ -533,7 +533,7 @@ void Scene602::actions() {
 void Scene603::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 	_scene->addActiveVocab(NOUN_COMPACT_CASE);
 	_scene->addActiveVocab(NOUN_NOTE);
 }
@@ -1421,7 +1421,7 @@ void Scene607::actions() {
 void Scene608::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 	_scene->addActiveVocab(NOUN_POLYCEMENT);
 	_scene->addActiveVocab(NOUN_CAR);
 	_scene->addActiveVocab(NOUN_OBNOXIOUS_DOG);
@@ -2705,7 +2705,7 @@ void Scene610::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 	_scene->addActiveVocab(NOUN_PHONE_HANDSET);
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 }
 
 void Scene610::enter() {
@@ -2888,7 +2888,7 @@ void Scene611::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 	_scene->addActiveVocab(NOUN_RAT);
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 }
 
 void Scene611::handleRatMoves() {
@@ -4263,7 +4263,7 @@ void Scene612::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 	_scene->addActiveVocab(NOUN_FISHING_LINE);
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 }
 
 void Scene612::handleWinchMovement() {
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index c0755e8..5c1f7bf 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -1074,7 +1074,7 @@ void Scene704::setup() {
 	_game._player._spritesPrefix = "";
 	setAAName();
 	_scene->addActiveVocab(NOUN_BOTTLE);
-	_scene->addActiveVocab(NOUN_LOOK_AT);
+	_scene->addActiveVocab(VERB_LOOK_AT);
 }
 
 void Scene704::handleBottleInterface() {
@@ -1678,7 +1678,7 @@ void Scene706::setup() {
 	setAAName();
 	_scene->addActiveVocab(NOUN_BOTTLE);
 	_scene->addActiveVocab(NOUN_VASE);
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 }
 
 void Scene706::handleRexDeath() {
@@ -2086,7 +2086,7 @@ void Scene751::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 	_scene->addActiveVocab(NOUN_FISHING_LINE);
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 }
 
 void Scene751::enter() {
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 9c53855..e6f8701 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -306,7 +306,7 @@ void Scene802::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 	_scene->addActiveVocab(NOUN_SHIELD_MODULATOR);
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 	_scene->addActiveVocab(NOUN_REMOTE);
 }
 
@@ -514,7 +514,7 @@ void Scene803::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
 	_scene->addActiveVocab(NOUN_GUTS);
-	_scene->addActiveVocab(NOUN_WALK_TO);
+	_scene->addActiveVocab(VERB_WALKTO);
 
 	if ((!_globals[kFromCockpit] && _globals[kReturnFromCut] && !_globals[kBeamIsUp])
 		|| (_globals[kFromCockpit] && !_globals[kExitShip])) {


Commit: cca6d19b2af3ab9161cdfa05b984b4e7fdab954b
    https://github.com/scummvm/scummvm/commit/cca6d19b2af3ab9161cdfa05b984b4e7fdab954b
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T12:58:18+03:00

Commit Message:
MADS: Fix typo

Changed paths:
    engines/mads/nebular/nebular_scenes.h



diff --git a/engines/mads/nebular/nebular_scenes.h b/engines/mads/nebular/nebular_scenes.h
index ec06a1b..8df43e9 100644
--- a/engines/mads/nebular/nebular_scenes.h
+++ b/engines/mads/nebular/nebular_scenes.h
@@ -50,7 +50,7 @@ enum Verb {
 	VERB_CUT            = 0x061,
 	VERB_DAMPEN         = 0x064,
 	VERB_DIVE_INTO      = 0x06D,
-	NOUN_DRINK          = 0x072,
+	VERB_DRINK          = 0x072,
 	VERB_EAT            = 0x075,
 	VERB_EXAMINE        = 0x07D,
 	VERB_HOSE_DOWN      = 0x0A6,


Commit: 645d0d92adee850830cb3233acda631a9b128654
    https://github.com/scummvm/scummvm/commit/645d0d92adee850830cb3233acda631a9b128654
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T13:09:56+03:00

Commit Message:
MADS: Add nouns for Phantom

Changed paths:
    engines/mads/phantom/phantom_scenes.h



diff --git a/engines/mads/phantom/phantom_scenes.h b/engines/mads/phantom/phantom_scenes.h
index d93ccfc..e585ead 100644
--- a/engines/mads/phantom/phantom_scenes.h
+++ b/engines/mads/phantom/phantom_scenes.h
@@ -35,8 +35,405 @@ namespace MADS {
 namespace Phantom {
 
 enum Noun {
-	VERB_LOOK_AT		= 0x0D1
-	// TODO
+	NOUN_GAME = 0x1,
+	NOUN_QSAVE = 0x2,
+	NOUN_LOOK = 0x3,
+	NOUN_TAKE = 0x4,
+	NOUN_PUSH = 0x5,
+	NOUN_OPEN = 0x6,
+	NOUN_PUT = 0x7,
+	NOUN_TALK_TO = 0x8,
+	NOUN_GIVE = 0x9,
+	NOUN_PULL = 0xA,
+	NOUN_CLOSE = 0xB,
+	NOUN_THROW = 0xC,
+	NOUN_WALK_TO = 0xD,
+	NOUN_ = 0xE,
+	NOUN_IN_ONE = 0xF,
+	NOUN_IN_TWO = 0x10,
+	NOUN_ACT_CURTAIN = 0x11,
+	NOUN_AISLE = 0x12,
+	NOUN_APRON = 0x13,
+	NOUN_ATTACK = 0x14,
+	NOUN_BACKSTAGE = 0x15,
+	NOUN_BEAR_PROP = 0x16,
+	NOUN_BLUE_FRAME = 0x17,
+	NOUN_BOOK = 0x18,
+	NOUN_BUST = 0x19,
+	NOUN_CABLE = 0x1A,
+	NOUN_CARPET = 0x1B,
+	NOUN_CARTON = 0x1C,
+	NOUN_CARTONS = 0x1D,
+	NOUN_CEILING = 0x1E,
+	NOUN_CHAIR = 0x1F,
+	NOUN_CIRCULAR_STAIRCASE = 0x20,
+	NOUN_CLIMB_DOWN = 0x21,
+	NOUN_CLIMB_INTO = 0x22,
+	NOUN_CLIMB_THROUGH = 0x23,
+	NOUN_COLUMN_PROP = 0x24,
+	NOUN_CONDUCTORS_STAND = 0x25,
+	NOUN_CORRIDOR = 0x26,
+	NOUN_COUCH = 0x27,
+	NOUN_COUNTERWEIGHT_SYSTEM = 0x28,
+	NOUN_CRATE = 0x29,
+	NOUN_CRATES = 0x2A,
+	NOUN_CRUMPLED_NOTE = 0x2B,
+	NOUN_CYCLORAMA = 0x2C,
+	NOUN_CYLINDER = 0x2D,
+	NOUN_DOOR = 0x2E,
+	NOUN_DRESSING_ROOM_DOOR = 0x2F,
+	NOUN_DRESSING_SCREEN = 0x30,
+	NOUN_DRESSING_TABLE = 0x31,
+	NOUN_ELEPHANT_PROP = 0x32,
+	NOUN_ENVELOPE = 0x33,
+	NOUN_EXIT = 0x34,
+	NOUN_EXIT_DOWN = 0x35,
+	NOUN_EXIT_SIGN = 0x36,
+	NOUN_EXIT_TO = 0x37,
+	NOUN_EXIT_TO_BACKSTAGE = 0x38,
+	NOUN_EXIT_TO_CELLAR = 0x39,
+	NOUN_EXIT_TO_CORRIDOR = 0x3A,
+	NOUN_EXIT_TO_DRESSING_RMS = 0x3B,
+	NOUN_EXIT_TO_LEFT_WING = 0x3C,
+	NOUN_EXIT_TO_PIT = 0x3D,
+	NOUN_EXIT_TO_RIGHT_WING = 0x3E,
+	NOUN_EXIT_TO_STAGE = 0x3F,
+	NOUN_EXIT_TO_STAIRWELL = 0x40,
+	NOUN_EXIT_TO_TRAP_ROOM = 0x41,
+	NOUN_EXIT_UP = 0x42,
+	NOUN_EXPOSED_BRICK = 0x43,
+	NOUN_FAN = 0x44,
+	NOUN_FIRE_AXE = 0x45,
+	NOUN_FL = 0x46,
+	NOUN_FLAT = 0x47,
+	NOUN_FLATS = 0x48,
+	NOUN_FLOOR = 0x49,
+	NOUN_FOLDING_CHAIRS = 0x4A,
+	NOUN_GARBAGE_CAN = 0x4B,
+	NOUN_GRAFFITI = 0x4C,
+	NOUN_GREEN_FRAME = 0x4D,
+	NOUN_HEMP = 0x4E,
+	NOUN_HOLE = 0x4F,
+	NOUN_HOUSE = 0x50,
+	NOUN_IN_ONE2 = 0x51,
+	NOUN_IN_TWO2 = 0x52,
+	NOUN_JUMP_INTO = 0x53,
+	NOUN_JUNK = 0x54,
+	NOUN_KEY = 0x55,
+	NOUN_LAMP = 0x56,
+	NOUN_LANTERN = 0x57,
+	NOUN_LARGE_NOTE = 0x58,
+	NOUN_LASSO = 0x59,
+	NOUN_LEG = 0x5A,
+	NOUN_LETTER = 0x5B,
+	NOUN_LIGHT_FIXTURE = 0x5C,
+	NOUN_LOCK = 0x5D,
+	NOUN_LOCKING_RAIL = 0x5E,
+	NOUN_LOCKRAIL = 0x5F,
+	NOUN_LOOK_AT = 0x60,
+	NOUN_LOOK_THROUGH = 0x61,
+	NOUN_MANNEQUINS = 0x62,
+	NOUN_MIRROR = 0x63,
+	NOUN_MUMMY_PROP = 0x64,
+	NOUN_MURAL = 0x65,
+	NOUN_MUSIC_SCORE = 0x66,
+	NOUN_MUSIC_STAND = 0x67,
+	NOUN_MUSIC_STANDS = 0x68,
+	NOUN_NOTHING = 0x69,
+	NOUN_NOTICE = 0x6A,
+	NOUN_ORCHESTRA_DOOR = 0x6B,
+	NOUN_ORCHESTRA_PIT = 0x6C,
+	NOUN_PAINTING = 0x6D,
+	NOUN_PARCHMENT = 0x6E,
+	NOUN_PIECE_OF_PAPER = 0x6F,
+	NOUN_PIPE = 0x70,
+	NOUN_PIT = 0x71,
+	NOUN_PLANT = 0x72,
+	NOUN_POSTER = 0x73,
+	NOUN_PROMPTERS_BOX = 0x74,
+	NOUN_PROP_TABLE = 0x75,
+	NOUN_PROPS = 0x76,
+	NOUN_PROSCENIUM_ARCH = 0x77,
+	NOUN_PURCHASE_LINES = 0x78,
+	NOUN_RAILING = 0x79,
+	NOUN_READ = 0x7A,
+	NOUN_RED_FRAME = 0x7B,
+	NOUN_REMOVE = 0x7C,
+	NOUN_ROPE = 0x7D,
+	NOUN_RUG = 0x7E,
+	NOUN_SANDBAG = 0x7F,
+	NOUN_SCAFFOLDING = 0x80,
+	NOUN_SEATS = 0x81,
+	NOUN_SIDE_WALL = 0x82,
+	NOUN_SMALL_NOTE = 0x83,
+	NOUN_STAGE = 0x84,
+	NOUN_STAGE_EXIT = 0x85,
+	NOUN_STAGE_LEFT = 0x86,
+	NOUN_STAGE_RIGHT = 0x87,
+	NOUN_STAGEMANAGERS_POST = 0x88,
+	NOUN_STAIR_UNIT = 0x89,
+	NOUN_STAIRCASE = 0x8A,
+	NOUN_STAIRWELL = 0x8B,
+	NOUN_STOOL = 0x8C,
+	NOUN_STRIKE = 0x8D,
+	NOUN_SWORD = 0x8E,
+	NOUN_TABLE = 0x8F,
+	NOUN_THE_HOUSE = 0x90,
+	NOUN_THUNDER_MACHINE = 0x91,
+	NOUN_TICKET = 0x92,
+	NOUN_TRAP_CEILING = 0x93,
+	NOUN_TRAP_DOOR = 0x94,
+	NOUN_TURN_OFF = 0x95,
+	NOUN_TURN_ON = 0x96,
+	NOUN_UNLOCK = 0x97,
+	NOUN_URN = 0x98,
+	NOUN_WALK_ACROSS = 0x99,
+	NOUN_WALK_DOWN = 0x9A,
+	NOUN_WALK_THROUGH = 0x9B,
+	NOUN_WALK_UP = 0x9C,
+	NOUN_WALL = 0x9D,
+	NOUN_WARDROBE = 0x9E,
+	NOUN_WASTE_BASKET = 0x9F,
+	NOUN_WATER_PIPE = 0xA0,
+	NOUN_WEAR = 0xA1,
+	NOUN_WEDDING_RING = 0xA2,
+	NOUN_YELLOW_FRAME = 0xA3,
+	NOUN_PROP = 0xA4,
+	NOUN_CLIMB_UP = 0xA5,
+	NOUN_WALK_ONTO = 0xA6,
+	NOUN_WALK = 0xA7,
+	NOUN_LEFT_DOOR = 0xA8,
+	NOUN_RIGHT_DOOR = 0xA9,
+	NOUN_DOOR_TO_PIT = 0xAA,
+	NOUN_HEADPHONES = 0xAB,
+	NOUN_BOXES = 0xAC,
+	NOUN_MUG = 0xAD,
+	NOUN_DINETTE_SET = 0xAE,
+	NOUN_BOX = 0xAF,
+	NOUN_CASES = 0xB0,
+	NOUN_TRASH_BUCKET = 0xB1,
+	NOUN_CORK_BOARD = 0xB2,
+	NOUN_HEADSET = 0xB3,
+	NOUN_GRAND_FOYER = 0xB4,
+	NOUN_BACK_WALL = 0xB5,
+	NOUN_BALLET_BAR = 0xB6,
+	NOUN_THROW_RUGS = 0xB7,
+	NOUN_COSTUME_RACK = 0xB8,
+	NOUN_COAT_RACK = 0xB9,
+	NOUN_PAINTINGS = 0xBA,
+	NOUN_UMBRELLA = 0xBB,
+	NOUN_SHELF = 0xBC,
+	NOUN_CONTAINER = 0xBD,
+	NOUN_TORN_POSTER = 0xBE,
+	NOUN_REVIEW = 0xBF,
+	NOUN_REVIEWS = 0xC0,
+	NOUN_STAGE_RIGHT_WING = 0xC1,
+	NOUN_STAGE_LEFT_WING = 0xC2,
+	NOUN_PEDESTAL = 0xC3,
+	NOUN_PLANT_PROP = 0xC4,
+	NOUN_STATUE = 0xC5,
+	NOUN_BATTEN = 0xC6,
+	NOUN_BIG_PROP = 0xC7,
+	NOUN_VENTILATION_DUCT = 0xC8,
+	NOUN_CHANDELIER = 0xC9,
+	NOUN_BARRIER = 0xCA,
+	NOUN_PLACARD = 0xCB,
+	NOUN_TICKET_WINDOW = 0xCC,
+	NOUN_ARCHWAY = 0xCD,
+	NOUN_COLUMN = 0xCE,
+	NOUN_RAIL = 0xCF,
+	NOUN_SEAT = 0xD0,
+	NOUN_LOGE_CORRIDOR = 0xD1,
+	NOUN_HOUSE_LIGHT = 0xD2,
+	NOUN_FLOV = 0xD3,
+	NOUN_LEFT_COLUMN = 0xD4,
+	NOUN_RIGHT_COLUMN = 0xD5,
+	NOUN_BOOKCASE = 0xD6,
+	NOUN_DOORWAY = 0xD7,
+	NOUN_COMFY_CHAIR = 0xD8,
+	NOUN_DESK = 0xD9,
+	NOUN_MANAGERS_CHAIR = 0xDA,
+	NOUN_DESK_LAMP = 0xDB,
+	NOUN_WINDOW = 0xDC,
+	NOUN_SHEERS = 0xDD,
+	NOUN_TAPESTRY = 0xDE,
+	NOUN_OVERDOOR_MEDALLION = 0xDF,
+	NOUN_LATTICEWORK = 0xE0,
+	NOUN_DECORATIVE_MOLDING = 0xE1,
+	NOUN_LEFT_DOORWAY = 0xE2,
+	NOUN_LEFT_ARCHWAY = 0xE3,
+	NOUN_RIGHT_DOORWAY = 0xE4,
+	NOUN_RIGHT_ARCHWAY = 0xE5,
+	NOUN_SOFA = 0xE6,
+	NOUN_END_TABLE = 0xE7,
+	NOUN_COFFEE_TABLE = 0xE8,
+	NOUN_DECORATIVE_VASE = 0xE9,
+	NOUN_MARBLE_COLUMN = 0xEA,
+	NOUN_BOX_FIVE = 0xEB,
+	NOUN_ENTER = 0xEC,
+	NOUN_BOX_SIX = 0xED,
+	NOUN_BOX_SEVEN = 0xEE,
+	NOUN_BOX_EIGHT = 0xEF,
+	NOUN_BOX_NINE = 0xF0,
+	NOUN_STEP = 0xF1,
+	NOUN_PANEL = 0xF2,
+	NOUN_WALK_BEHIND = 0xF3,
+	NOUN_MIDDLE_DOORWAY = 0xF4,
+	NOUN_LIGHT = 0xF5,
+	NOUN_CANDLE = 0xF6,
+	NOUN_CASE = 0xF7,
+	NOUN_HANDLE = 0xF8,
+	NOUN_AXE = 0xF9,
+	NOUN_DOOR_CHUNKS = 0xFA,
+	NOUN_FLO = 0xFB,
+	NOUN_BULLETIN_BOARD = 0xFC,
+	NOUN_JULIE = 0xFD,
+	NOUN_GLASS_CASE = 0xFE,
+	NOUN_KEYHOLE = 0xFF,
+	NOUN_MIDDLE_DOOR = 0x100,
+	NOUN_DRESSING_GOWN = 0x101,
+	NOUN_MONSIEUR_BRIE = 0x102,
+	NOUN_CATWALK = 0x103,
+	NOUN_GRID = 0x104,
+	NOUN_GIRDER = 0x105,
+	NOUN_GRIDWORK = 0x106,
+	NOUN_DUCTWORK = 0x107,
+	NOUN_OPENING = 0x108,
+	NOUN_DOME = 0x109,
+	NOUN_ALCOVE = 0x10A,
+	NOUN_CHRISTINE_DAAE = 0x10B,
+	NOUN_CHRISTINE = 0x10C,
+	NOUN_WOMAN = 0x10D,
+	NOUN_PROMPTERS_STAND = 0x10E,
+	NOUN_SUPPORT = 0x10F,
+	NOUN_OTHER_CATWALK = 0x110,
+	NOUN_SLOT = 0x111,
+	NOUN_BEAM_POSITION = 0x112,
+	NOUN_LIGHTING_INSTRUMENT = 0x113,
+	NOUN_TARP = 0x114,
+	NOUN_FACE = 0x115,
+	NOUN_CATWALK_OVER_HOUSE = 0x116,
+	NOUN_STAIRCASE_POST = 0x117,
+	NOUN_JACQUES = 0x118,
+	NOUN_GENTLEMAN = 0x119,
+	NOUN_BODY = 0x11A,
+	NOUN_HOLLOW_COLUMN = 0x11B,
+	NOUN_UPPER_LEVEL = 0x11C,
+	NOUN_MIDDLE_LEVEL = 0x11D,
+	NOUN_LOWER_LEVEL = 0x11E,
+	NOUN_LADDER = 0x11F,
+	NOUN_CLIMB = 0x120,
+	NOUN_CHANDELIER_TRAP = 0x121,
+	NOUN_PIECE_OF_WOOD = 0x122,
+	NOUN_CUT_HEMP = 0x123,
+	NOUN_STONE_WALL = 0x124,
+	NOUN_LAKE = 0x125,
+	NOUN_STONE_COLUMN = 0x126,
+	NOUN_EXIT_THROUGH = 0x127,
+	NOUN_STONE_FLOOR = 0x128,
+	NOUN_STONE_ARCHWAY = 0x129,
+	NOUN_CHARLES = 0x12A,
+	NOUN_SWITCH = 0x12B,
+	NOUN_PROMPTERS_SEAT = 0x12C,
+	NOUN_LEVER = 0x12D,
+	NOUN_MONSIEUR_RICHARD = 0x12E,
+	NOUN_JULIE2 = 0x12F,
+	NOUN_CABLE_HOOK = 0x130,
+	NOUN_ATTACH = 0x131,
+	NOUN_ROPE_WITH_HOOK = 0x132,
+	NOUN_GRAPPLE = 0x133,
+	NOUN_OAR = 0x134,
+	NOUN_ORGAN = 0x135,
+	NOUN_SIT_AT = 0x136,
+	NOUN_ORGAN_BENCH = 0x137,
+	NOUN_SIT_ON = 0x138,
+	NOUN_LARGE_CHAIR = 0x139,
+	NOUN_SIT_IN = 0x13A,
+	NOUN_SARCOPHAGUS = 0x13B,
+	NOUN_SKULL = 0x13C,
+	NOUN_SKULLS = 0x13D,
+	NOUN_TOTEM = 0x13E,
+	NOUN_POLE = 0x13F,
+	NOUN_CURTAIN = 0x140,
+	NOUN_TORCH = 0x141,
+	NOUN_RAMP = 0x142,
+	NOUN_MADAME_GIRY = 0x143,
+	NOUN_PANELS = 0x144,
+	NOUN_MORE_CATACOMBS = 0x145,
+	NOUN_BLOCKED_ARCHWAY = 0x146,
+	NOUN_GRATE = 0x147,
+	NOUN_CATACOMBS = 0x148,
+	NOUN_TICKET_SELLER = 0x149,
+	NOUN_USHER = 0x14A,
+	NOUN_UNLUCKY_ADVENTURER = 0x14B,
+	NOUN_SWITCH_PANEL = 0x14C,
+	NOUN_SKULL_SWITCH = 0x14D,
+	NOUN_TOGGLE = 0x14E,
+	NOUN_CATACOMB_ROOM = 0x14F,
+	NOUN_BOX_TEN = 0x150,
+	NOUN_FOYER = 0x151,
+	NOUN_WALK_DOWN_STAIRCASE = 0x152,
+	NOUN_WALK_DOWN_STAIRS_TO = 0x153,
+	NOUN_HAT_RACK = 0x154,
+	NOUN_VASE = 0x155,
+	NOUN_CLOTHES_DUMMY = 0x156,
+	NOUN_NOTICES = 0x157,
+	NOUN_ARCHWAY_TO_NORTH = 0x158,
+	NOUN_ARCHWAY_TO_WEST = 0x159,
+	NOUN_ARCHWAY_TO_EAST = 0x15A,
+	NOUN_GATE = 0x15B,
+	NOUN_NEST = 0x15C,
+	NOUN_POT = 0x15D,
+	NOUN_PUDDLE = 0x15E,
+	NOUN_WEB = 0x15F,
+	NOUN_PLANK = 0x160,
+	NOUN_BLOCK = 0x161,
+	NOUN_RATS_NEST = 0x162,
+	NOUN_BROKEN_POT = 0x163,
+	NOUN_STONE = 0x164,
+	NOUN_DRAIN = 0x165,
+	NOUN_FATE = 0x166,
+	NOUN_SKULL_SWITCH_1 = 0x167,
+	NOUN_SKULL_SWITCH_2 = 0x168,
+	NOUN_SKULL_SWITCH_3 = 0x169,
+	NOUN_SKULL_SWITCH_4 = 0x16A,
+	NOUN_SKULL_SWITCH_5 = 0x16B,
+	NOUN_SKULL_SWITCH_6 = 0x16C,
+	NOUN_SKULL_SWITCH_7 = 0x16D,
+	NOUN_SKULL_SWITCH_8 = 0x16E,
+	NOUN_SKULL_SWITCH_9 = 0x16F,
+	NOUN_SKULL_SWITCH_10 = 0x170,
+	NOUN_SKULL_SWITCH_11 = 0x171,
+	NOUN_SKULL_SWITCH_12 = 0x172,
+	NOUN_SKULL_SWITCH_13 = 0x173,
+	NOUN_SKULL_SWITCH_14 = 0x174,
+	NOUN_SKULL_SWITCH_15 = 0x175,
+	NOUN_SKULL_SWITCH_16 = 0x176,
+	NOUN_SKULL_SWITCH_17 = 0x177,
+	NOUN_SKULL_SWITCH_18 = 0x178,
+	NOUN_SKULL_SWITCH_19 = 0x179,
+	NOUN_SKULL_SWITCH_20 = 0x17A,
+	NOUN_SKULL_SWITCH_21 = 0x17B,
+	NOUN_SKULL_SWITCH_22 = 0x17C,
+	NOUN_SKULL_SWITCH_23 = 0x17D,
+	NOUN_SKULL_SWITCH_24 = 0x17E,
+	NOUN_SKULL_SWITCH_25 = 0x17F,
+	NOUN_SKULL_SWITCH_26 = 0x180,
+	NOUN_EDGAR_DEGAS = 0x181,
+	NOUN_CHANDELIER_CABLE = 0x182,
+	NOUN_COB_WEB = 0x183,
+	NOUN_SKULL_FACE = 0x184,
+	NOUN_BOAT = 0x185,
+	NOUN_HOOK = 0x186,
+	NOUN_AROUND = 0x187,
+	NOUN_CANE = 0x188,
+	NOUN_MASK = 0x189,
+	NOUN_COVER = 0x18A,
+	NOUN_PADLOCK = 0x18B,
+	NOUN_LID = 0x18C,
+	NOUN_COBWEB = 0x18D,
+	NOUN_PHANTOM = 0x18E,
+	NOUN_PAPER = 0x18F
 };
 
 class SceneFactory {


Commit: 5e1eaaa6f3aac17348d640666c4d0757714e9460
    https://github.com/scummvm/scummvm/commit/5e1eaaa6f3aac17348d640666c4d0757714e9460
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T13:10:12+03:00

Commit Message:
MADS: Add nouns for Dragonsphere

Changed paths:
    engines/mads/dragonsphere/dragonsphere_scenes.h



diff --git a/engines/mads/dragonsphere/dragonsphere_scenes.h b/engines/mads/dragonsphere/dragonsphere_scenes.h
index d6af608..2d23381 100644
--- a/engines/mads/dragonsphere/dragonsphere_scenes.h
+++ b/engines/mads/dragonsphere/dragonsphere_scenes.h
@@ -35,8 +35,579 @@ namespace MADS {
 namespace Dragonsphere {
 
 enum Noun {
-	VERB_LOOK_AT		= 0x0D1
-	// TODO
+	NOUN_GAME = 0x1,
+	NOUN_QSAVE = 0x2,
+	NOUN_LOOK = 0x3,
+	NOUN_TAKE = 0x4,
+	NOUN_PUSH = 0x5,
+	NOUN_OPEN = 0x6,
+	NOUN_PUT = 0x7,
+	NOUN_TALK_TO = 0x8,
+	NOUN_GIVE = 0x9,
+	NOUN_PULL = 0xA,
+	NOUN_CLOSE = 0xB,
+	NOUN_THROW = 0xC,
+	NOUN_WALK_TO = 0xD,
+	NOUN_NOTHING = 0xE,
+	NOUN_ = 0xF,
+	NOUN_FLOOR = 0x10,
+	NOUN_WALK_ACROSS = 0x11,
+	NOUN_RUG = 0x12,
+	NOUN_CARPET = 0x13,
+	NOUN_WALL = 0x14,
+	NOUN_BED = 0x15,
+	NOUN_PILLOW = 0x16,
+	NOUN_CHEST = 0x17,
+	NOUN_WINDOW = 0x18,
+	NOUN_NIGHTSTAND = 0x19,
+	NOUN_TAPESTRY = 0x1A,
+	NOUN_DRESSING_SCREEN = 0x1B,
+	NOUN_WALK_BEHIND = 0x1C,
+	NOUN_ROYAL_CREST = 0x1D,
+	NOUN_LOOK_AT = 0x1E,
+	NOUN_WASHBASIN = 0x1F,
+	NOUN_WASH_AT = 0x20,
+	NOUN_BOOK = 0x21,
+	NOUN_FIREPLACE = 0x22,
+	NOUN_FIREPLACE_SCREEN = 0x23,
+	NOUN_DOOR_TO_QUEENS_ROOM = 0x24,
+	NOUN_WALK_THROUGH = 0x25,
+	NOUN_HALL_TO_SOUTH = 0x26,
+	NOUN_WALK_INTO = 0x27,
+	NOUN_WALL_PLAQUE = 0x28,
+	NOUN_DECORATION = 0x29,
+	NOUN_SWORDS = 0x2A,
+	NOUN_WALL_SCONCE = 0x2B,
+	NOUN_BUST_ON_WALL = 0x2C,
+	NOUN_WALL_ARCH = 0x2D,
+	NOUN_SIGNET_RING = 0x2E,
+	NOUN_INVOKE = 0x2F,
+	NOUN_POLISH = 0x30,
+	NOUN_GANGBANG = 0x31,
+	NOUN_BIRD_FIGURINE = 0x32,
+	NOUN_RUB = 0x33,
+	NOUN_BIRDCALL = 0x34,
+	NOUN_USE = 0x35,
+	NOUN_MAKE_NOISE = 0x36,
+	NOUN_SHIELDSTONE = 0x37,
+	NOUN_SWORD = 0x38,
+	NOUN_ATTACK = 0x39,
+	NOUN_CARVE_UP = 0x3A,
+	NOUN_GOBLET = 0x3B,
+	NOUN_FILL = 0x3C,
+	NOUN_DRINK_FROM = 0x3D,
+	NOUN_BONE = 0x3E,
+	NOUN_GNAW = 0x3F,
+	NOUN_FRUIT = 0x40,
+	NOUN_EAT = 0x41,
+	NOUN_DOLL = 0x42,
+	NOUN_PLAY_WITH = 0x43,
+	NOUN_HEAL = 0x44,
+	NOUN_HEAL_THYSELF = 0x45,
+	NOUN_HEAL_SELF = 0x46,
+	NOUN_POLYSTONE = 0x47,
+	NOUN_MIMIC = 0x48,
+	NOUN_RED_POWERSTONE = 0x49,
+	NOUN_YELLOW_POWERSTONE = 0x4A,
+	NOUN_BLUE_POWERSTONE = 0x4B,
+	NOUN_KEY_CROWN = 0x4C,
+	NOUN_WEAR = 0x4D,
+	NOUN_DATES = 0x4E,
+	NOUN_STATUE = 0x4F,
+	NOUN_BOTTLE_OF_FLIES = 0x50,
+	NOUN_LISTEN_TO = 0x51,
+	NOUN_SOUL_EGG = 0x52,
+	NOUN_BREAK = 0x53,
+	NOUN_MAGIC_BELT = 0x54,
+	NOUN_ADJUST = 0x55,
+	NOUN_AMULET = 0x56,
+	NOUN_THRUST = 0x57,
+	NOUN_MUD = 0x58,
+	NOUN_FEEL = 0x59,
+	NOUN_TASTE = 0x5A,
+	NOUN_FEATHERS = 0x5B,
+	NOUN_TICKLE = 0x5C,
+	NOUN_TORCH = 0x5D,
+	NOUN_WAVE = 0x5E,
+	NOUN_FLASK = 0x5F,
+	NOUN_FLASK_FULL_OF_ACID = 0x60,
+	NOUN_POUR_CONTENTS = 0x61,
+	NOUN_POUR = 0x62,
+	NOUN_POUR_CONTENTS_OF = 0x63,
+	NOUN_DRINK = 0x64,
+	NOUN_ROPE = 0x65,
+	NOUN_TIE = 0x66,
+	NOUN_POWER_VACUUM_STONE = 0x67,
+	NOUN_TAKE_MAGIC_FROM = 0x68,
+	NOUN_DEAD_RAT = 0x69,
+	NOUN_PET = 0x6A,
+	NOUN_MAP = 0x6B,
+	NOUN_FOLD = 0x6C,
+	NOUN_CRYSTAL_BALL = 0x6D,
+	NOUN_GAZE_INTO = 0x6E,
+	NOUN_INVOKE_POWER_OF = 0x6F,
+	NOUN_BLACK_SPHERE = 0x70,
+	NOUN_SOPTUS_SOPORIFIC = 0x71,
+	NOUN_SHIFTER_RING = 0x72,
+	NOUN_SHIFT_SELF = 0x73,
+	NOUN_SHIFT_INTO_BEAR = 0x74,
+	NOUN_SHIFT_INTO_SEAL = 0x75,
+	NOUN_SHIFT_INTO_SNAKE = 0x76,
+	NOUN_REVERT = 0x77,
+	NOUN_MEDICINE_BUNDLE = 0x78,
+	NOUN_SHAKE = 0x79,
+	NOUN_PARTLY_BUILT_BUNDLE = 0x7A,
+	NOUN_RATSICLE = 0x7B,
+	NOUN_LICK = 0x7C,
+	NOUN_TENTACLE_PARTS = 0x7D,
+	NOUN_CHEW = 0x7E,
+	NOUN_TELEPORT_DOOR = 0x7F,
+	NOUN_UNROLL = 0x80,
+	NOUN_RARE_COIN = 0x81,
+	NOUN_ADMIRE = 0x82,
+	NOUN_CRYSTAL_FLOWER = 0x83,
+	NOUN_DIAMOND_DUST = 0x84,
+	NOUN_RUBY_RING = 0x85,
+	NOUN_GOLD_NUGGET = 0x86,
+	NOUN_MAGIC_MUSIC_BOX = 0x87,
+	NOUN_EMERALD = 0x88,
+	NOUN_PIECE_OF_PAPER = 0x89,
+	NOUN_SPEAK_WORDS_ON = 0x8A,
+	NOUN_VORTEX_STONE = 0x8B,
+	NOUN_RUG2 = 0x8C,
+	NOUN_FIREPLACE_SCREEN2 = 0x8D,
+	NOUN_BUST_ON_WALL2 = 0x8E,
+	NOUN_LOOK_AT2 = 0x8F,
+	NOUN_DRAGON = 0x90,
+	NOUN_DRAGONSPHERE = 0x91,
+	NOUN_TOUCH = 0x92,
+	NOUN_THRONE_ROOM = 0x93,
+	NOUN_RETURN_TO = 0x94,
+	NOUN_CAVE = 0x95,
+	NOUN_PASSAGEWAY_TO_WEST = 0x96,
+	NOUN_PASSAGEWAY_TO_EAST = 0x97,
+	NOUN_CAVE_FLOOR = 0x98,
+	NOUN_STONE_COLUMN = 0x99,
+	NOUN_ABYSS = 0x9A,
+	NOUN_LOOK_INTO = 0x9B,
+	NOUN_CASTLE = 0x9C,
+	NOUN_CASTLE_GATE = 0x9D,
+	NOUN_GROUND = 0x9E,
+	NOUN_BARREL = 0x9F,
+	NOUN_BARRELS = 0xA0,
+	NOUN_HAYSTACK = 0xA1,
+	NOUN_ROOT_THROUGH = 0xA2,
+	NOUN_BATTLEMENTS = 0xA3,
+	NOUN_GATE_TO_THRONE_ROOM = 0xA4,
+	NOUN_CASTLE_WALL = 0xA5,
+	NOUN_DOOR = 0xA6,
+	NOUN_WALL_SWITCH = 0xA7,
+	NOUN_STAIRS = 0xA8,
+	NOUN_WALK_DOWN = 0xA9,
+	NOUN_EDGE_OF_ABYSS = 0xAA,
+	NOUN_COURTYARD = 0xAB,
+	NOUN_ROCK = 0xAC,
+	NOUN_CAVE_CEILING = 0xAD,
+	NOUN_CAVE_WALL = 0xAE,
+	NOUN_BRAZIER = 0xAF,
+	NOUN_DOOR_TO_THRONE_ROOM = 0xB0,
+	NOUN_GO_THROUGH = 0xB1,
+	NOUN_DINING_TABLE = 0xB2,
+	NOUN_ACTIVATE = 0xB3,
+	NOUN_BATTLEMENT = 0xB4,
+	NOUN_DOOR_TO_GAURDROOM = 0xB5,
+	NOUN_DUNGEON_FLOOR = 0xB6,
+	NOUN_DUNGEON_WALLS = 0xB7,
+	NOUN_DUNGEON_CEILING = 0xB8,
+	NOUN_BEDDING = 0xB9,
+	NOUN_FLOOR_GRATE = 0xBA,
+	NOUN_MANACLES = 0xBB,
+	NOUN_CALENDAR = 0xBC,
+	NOUN_DOOR_TO_GUARDROOM = 0xBD,
+	NOUN_DOOR_TO_COUNCIL_ROOM = 0xBE,
+	NOUN_GUARD_STATION = 0xBF,
+	NOUN_DOOR_TO_DUNGEON_CELL = 0xC0,
+	NOUN_DOORWAY_TO_CELL = 0xC1,
+	NOUN_DUNGEON_DOOR = 0xC2,
+	NOUN_DUNGEON_WALL = 0xC3,
+	NOUN_CEILING = 0xC4,
+	NOUN_DOOR_TO_HALLWAY = 0xC5,
+	NOUN_TABLE = 0xC6,
+	NOUN_BOOKSHELF = 0xC7,
+	NOUN_TROPHY = 0xC8,
+	NOUN_READING_BENCH = 0xC9,
+	NOUN_CHAIR = 0xCA,
+	NOUN_LOVESEAT = 0xCB,
+	NOUN_WOOD_BASKET = 0xCC,
+	NOUN_STOOL = 0xCD,
+	NOUN_GUARD_STOOL = 0xCE,
+	NOUN_ROCKS = 0xCF,
+	NOUN_DIVIDING_WALL = 0xD0,
+	NOUN_ARCHWAY = 0xD1,
+	NOUN_MARKET_GROUNDS = 0xD2,
+	NOUN_HEDGE = 0xD3,
+	NOUN_SKY = 0xD4,
+	NOUN_PLAINS = 0xD5,
+	NOUN_FIELDS = 0xD6,
+	NOUN_GATE_TO_COURTYARD = 0xD7,
+	NOUN_ROAD_TO_EAST = 0xD8,
+	NOUN_TREES = 0xD9,
+	NOUN_CLOUDS = 0xDA,
+	NOUN_MERCHANTS_STALL = 0xDB,
+	NOUN_WELL = 0xDC,
+	NOUN_DOWN_WELL = 0xDD,
+	NOUN_GO = 0xDE,
+	NOUN_GO_DOWN = 0xDF,
+	NOUN_CRANK = 0xE0,
+	NOUN_BUCKET = 0xE1,
+	NOUN_JUMP_DOWN = 0xE2,
+	NOUN_WALLS = 0xE3,
+	NOUN_DOORWAY_TO_SOUTH = 0xE4,
+	NOUN_PEDESTAL = 0xE5,
+	NOUN_DOOR_TO_NORTH = 0xE6,
+	NOUN_PAINTING = 0xE7,
+	NOUN_DOCUMENT = 0xE8,
+	NOUN_INK_BOTTLE = 0xE9,
+	NOUN_QUILL_PEN = 0xEA,
+	NOUN_CHANDELIER = 0xEB,
+	NOUN_COUNCIL_TABLE = 0xEC,
+	NOUN_CANDLESTICK = 0xED,
+	NOUN_DESK = 0xEE,
+	NOUN_TURN = 0xEF,
+	NOUN_POLE = 0xF0,
+	NOUN_THE_SCENE = 0xF1,
+	NOUN_LEAVE = 0xF2,
+	NOUN_END_TABLE = 0xF3,
+	NOUN_BATTLE_AXES = 0xF4,
+	NOUN_DOOR_TO_KINGS_ROOM = 0xF5,
+	NOUN_COAT_OF_ARMS = 0xF6,
+	NOUN_LARGE_WINDOW = 0xF7,
+	NOUN_SMALL_WINDOW = 0xF8,
+	NOUN_DOOR_TO_MEETING_ROOM = 0xF9,
+	NOUN_DOOR_TO_BALLROOM = 0xFA,
+	NOUN_FLOWERS = 0xFB,
+	NOUN_SHUTTERS = 0xFC,
+	NOUN_BOOKCASE = 0xFD,
+	NOUN_DOOR_TO_COURTYARD = 0xFE,
+	NOUN_PLATFORM = 0xFF,
+	NOUN_STEP = 0x100,
+	NOUN_RED_CARPET = 0x101,
+	NOUN_KINGS_THRONE = 0x102,
+	NOUN_SIT_IN = 0x103,
+	NOUN_QUEENS_THRONE = 0x104,
+	NOUN_TRAPDOOR = 0x105,
+	NOUN_GRATE = 0x106,
+	NOUN_RIVER = 0x107,
+	NOUN_DIARIES = 0x108,
+	NOUN_SWIM_DOWN = 0x109,
+	NOUN_SCULLERY_MAID = 0x10A,
+	NOUN_DOORWAY_TO_DUNGEON = 0x10B,
+	NOUN_WARD = 0x10C,
+	NOUN_DARKNESS_BEAST = 0x10D,
+	NOUN_BEAST = 0x10E,
+	NOUN_PUT_MAGIC_INTO = 0x10F,
+	NOUN_GUARD = 0x110,
+	NOUN_CROWN = 0x111,
+	NOUN_BOOKS = 0x112,
+	NOUN_SECRET_DOOR = 0x113,
+	NOUN_WALL_PANEL = 0x114,
+	NOUN_DOORWAY = 0x115,
+	NOUN_FAERIE = 0x116,
+	NOUN_SOPTUS_ECLIPTUS = 0x117,
+	NOUN_GUARD_CAPTAIN = 0x118,
+	NOUN_MERCHANT = 0x119,
+	NOUN_SHAPECHANGER = 0x11A,
+	NOUN_RED_STONE = 0x11B,
+	NOUN_YELLOW_STONE = 0x11C,
+	NOUN_BLUE_STONE = 0x11D,
+	NOUN_FLIES = 0x11E,
+	NOUN_FLASK_OF_ACID = 0x11F,
+	NOUN_PARTIAL_BUNDLE = 0x120,
+	NOUN_SOPORIFIC = 0x121,
+	NOUN_PARCHMENT = 0x122,
+	NOUN_KING = 0x123,
+	NOUN_MACMORN = 0x124,
+	NOUN_MOUNTAINSIDE = 0x125,
+	NOUN_PATH_TO_SOUTH = 0x126,
+	NOUN_ROUGH_STONE = 0x127,
+	NOUN_CLIMB_UP = 0x128,
+	NOUN_LARGE_ROCK = 0x129,
+	NOUN_SMALL_ROCK = 0x12A,
+	NOUN_PATH_TO_WEST = 0x12B,
+	NOUN_CAVE_ENTRANCE = 0x12C,
+	NOUN_PALLET = 0x12D,
+	NOUN_BLANKET = 0x12E,
+	NOUN_FIREPIT = 0x12F,
+	NOUN_FLAT_STONE = 0x130,
+	NOUN_MOVE = 0x131,
+	NOUN_SPIRIT_BUNDLE = 0x132,
+	NOUN_TRAIL_LEADING_UP = 0x133,
+	NOUN_FOLLOW = 0x134,
+	NOUN_TRAIL_LEADING_DOWN = 0x135,
+	NOUN_NEST = 0x136,
+	NOUN_REACH_IN = 0x137,
+	NOUN_TRAIL_LEADING_WEST = 0x138,
+	NOUN_PATH_TO_EAST = 0x139,
+	NOUN_WATERFALL = 0x13A,
+	NOUN_PUDDLE = 0x13B,
+	NOUN_EDGE_OF_CLIFF = 0x13C,
+	NOUN_LEDGE = 0x13D,
+	NOUN_CLIMB_DOWN = 0x13E,
+	NOUN_LANDING = 0x13F,
+	NOUN_BOULDERS = 0x140,
+	NOUN_ROCK_TUMBLE = 0x141,
+	NOUN_ROCK_TREE = 0x142,
+	NOUN_PILLAR = 0x143,
+	NOUN_JUMP_TO = 0x144,
+	NOUN_CLIFF = 0x145,
+	NOUN_PILLARS = 0x146,
+	NOUN_SPECIAL_ROCK = 0x147,
+	NOUN_GAZE_UPON = 0x148,
+	NOUN_SCONCE = 0x149,
+	NOUN_LADDER = 0x14A,
+	NOUN_STAIRWAY = 0x14B,
+	NOUN_MECHANISM = 0x14C,
+	NOUN_SPEARHEADS = 0x14D,
+	NOUN_TRAP_DOOR = 0x14E,
+	NOUN_SWIM = 0x14F,
+	NOUN_DOWN_RIVER = 0x150,
+	NOUN_SWIM_UP = 0x151,
+	NOUN_UP_RIVER = 0x152,
+	NOUN_SHORE = 0x153,
+	NOUN_SWIM_TO = 0x154,
+	NOUN_SWIM_TOWARDS = 0x155,
+	NOUN_KING_CALLASH = 0x156,
+	NOUN_KINGS_THRONE2 = 0x157,
+	NOUN_KING2 = 0x158,
+	NOUN_GROTTO = 0x159,
+	NOUN_CLIMB_THROUGH = 0x15A,
+	NOUN_QUEEN_MOTHER = 0x15B,
+	NOUN_MACMORN2 = 0x15C,
+	NOUN_SMALL_LEDGE = 0x15D,
+	NOUN_MACMORN3 = 0x15E,
+	NOUN_TO_110 = 0x15F,
+	NOUN_TO_KITTY_HEAVEN = 0x160,
+	NOUN_KITTY_HEAVEN = 0x161,
+	NOUN_ROOM_110 = 0x162,
+	NOUN_LLANIE = 0x163,
+	NOUN_CW = 0x164,
+	NOUN_HERMIT = 0x165,
+	NOUN_TROU = 0x166,
+	NOUN_SHAK = 0x167,
+	NOUN_ROOM_501 = 0x168,
+	NOUN_MOON = 0x169,
+	NOUN_UFO = 0x16A,
+	NOUN_SIT_ON = 0x16B,
+	NOUN_STRANGER = 0x16C,
+	NOUN_TOWER_DOOR = 0x16D,
+	NOUN_DOOR_TO_EAST = 0x16E,
+	NOUN_DOOR_TO_WEST = 0x16F,
+	NOUN_EYE = 0x170,
+	NOUN_DOORWAY_TO_EAST = 0x171,
+	NOUN_DOORWAY_TO_WEST = 0x172,
+	NOUN_SKULL = 0x173,
+	NOUN_DOOR_TO_MAGIC_ROOM = 0x174,
+	NOUN_ANCIENT_BARREL = 0x175,
+	NOUN_COBWEBS = 0x176,
+	NOUN_SHELF = 0x177,
+	NOUN_MUSTY_CHART = 0x178,
+	NOUN_LAB_TABLE = 0x179,
+	NOUN_PETCOCK = 0x17A,
+	NOUN_NOZZLE = 0x17B,
+	NOUN_TUBING = 0x17C,
+	NOUN_BEAKER = 0x17D,
+	NOUN_FLAME = 0x17E,
+	NOUN_METAL_PLATE = 0x17F,
+	NOUN_SHAFT_OF_LIGHT = 0x180,
+	NOUN_CABINET = 0x181,
+	NOUN_BALANCE = 0x182,
+	NOUN_CAGE = 0x183,
+	NOUN_FREEZER = 0x184,
+	NOUN_CONTENTS_OF_FREEZER = 0x185,
+	NOUN_CAGE_WITH_RATS = 0x186,
+	NOUN_DOOR_TO_SOUTH = 0x187,
+	NOUN_TRAIL_OF_GREEN_SLIME = 0x188,
+	NOUN_NECK_LOCK = 0x189,
+	NOUN_BENCH = 0x18A,
+	NOUN_SKELETON = 0x18B,
+	NOUN_LEG_CLAMPS = 0x18C,
+	NOUN_LEG_LOCK = 0x18D,
+	NOUN_WAIST_LOCK = 0x18E,
+	NOUN_NER_TOM = 0x18F,
+	NOUN_BELT = 0x190,
+	NOUN_JUMP_INTO = 0x191,
+	NOUN_CLOSET = 0x192,
+	NOUN_DOOR_TO_EYE_CHAMBER = 0x193,
+	NOUN_DRESSER = 0x194,
+	NOUN_SCROLL = 0x195,
+	NOUN_WITCH_PARAPHERNALIA = 0x196,
+	NOUN_SHELVES = 0x197,
+	NOUN_MAGIC_TOMES = 0x198,
+	NOUN_MAGIC_PARAPHERNALIA = 0x199,
+	NOUN_BOOK_OF_MAGIC = 0x19A,
+	NOUN_HOURGLASS = 0x19B,
+	NOUN_STONE_SPHERE = 0x19C,
+	NOUN_SHADOW_OF_WINDOW = 0x19D,
+	NOUN_MUSIC_BOX = 0x19E,
+	NOUN_LARGE_SPIDER_WEB = 0x19F,
+	NOUN_INFERNAL_MACHINE = 0x1A0,
+	NOUN_WATER_SOURCE = 0x1A1,
+	NOUN_FLOW_OF_WATER = 0x1A2,
+	NOUN_RETORT = 0x1A3,
+	NOUN_DOORWAY_TO_CORRIDOR = 0x1A4,
+	NOUN_TELESCOPE = 0x1A5,
+	NOUN_STRANGE_MAP = 0x1A6,
+	NOUN_CIRCLE_OF_SPHERES = 0x1A7,
+	NOUN_STONE_BED = 0x1A8,
+	NOUN_DRAGON_SCULPTURE = 0x1A9,
+	NOUN_RAT = 0x1AA,
+	NOUN_RAT_CAGE = 0x1AB,
+	NOUN_DOWN_BUTTON = 0x1AC,
+	NOUN_DOOR_TO_MACHINE_ROOM = 0x1AD,
+	NOUN_STRANGE_PORTAL = 0x1AE,
+	NOUN_DOOR_FRAME = 0x1AF,
+	NOUN_ELEVATOR_HOLE = 0x1B0,
+	NOUN_UP_BUTTON = 0x1B1,
+	NOUN_DOORWAY_TO_DARK_ROOM = 0x1B2,
+	NOUN_BIG_SKULL = 0x1B3,
+	NOUN_ELEVATOR_PLATFORM = 0x1B4,
+	NOUN_BUTTON = 0x1B5,
+	NOUN_TOP_BUTTON = 0x1B6,
+	NOUN_BOTTOM_BUTTON = 0x1B7,
+	NOUN_TELEPORTAL = 0x1B8,
+	NOUN_EYE_CHAMBER_DOORWAY = 0x1B9,
+	NOUN_MACHINE_ROOM_DOORWAY = 0x1BA,
+	NOUN_GLOWING_FLOOR = 0x1BB,
+	NOUN_BRYNN_FANN = 0x1BC,
+	NOUN_GRAN_CALLAHACH = 0x1BD,
+	NOUN_SLATHAN_NI_PATAN = 0x1BE,
+	NOUN_HIGHTOWER = 0x1BF,
+	NOUN_SOPTUS_ECLIPTUS2 = 0x1C0,
+	NOUN_TOWER = 0x1C1,
+	NOUN_MOUNTAIN_PATH = 0x1C2,
+	NOUN_PATH_BEHIND_TOWER = 0x1C3,
+	NOUN_VINES = 0x1C4,
+	NOUN_SLATHAN_NI_PATAN2 = 0x1C5,
+	NOUN_SICK = 0x1C6,
+	NOUN_PATH_AROUND_TOWER = 0x1C7,
+	NOUN_PATH_TO_HIGHTOWER = 0x1C8,
+	NOUN_SPIRIT_PLANE = 0x1C9,
+	NOUN_SPIRIT_TREE = 0x1CA,
+	NOUN_WALK = 0x1CB,
+	NOUN_REMAINS = 0x1CC,
+	NOUN_DOORWAY_TO_ELEVATOR = 0x1CD,
+	NOUN_DRAGON_DOOR = 0x1CE,
+	NOUN_DRAGON_BONES = 0x1CF,
+	NOUN_IRON_FLOOR = 0x1D0,
+	NOUN_HOLE = 0x1D1,
+	NOUN_STONE = 0x1D2,
+	NOUN_HOMEMADE_BUNDLE = 0x1D3,
+	NOUN_LEFT = 0x1D4,
+	NOUN_RIGHT = 0x1D5,
+	NOUN_UP = 0x1D6,
+	NOUN_DOWN = 0x1D7,
+	NOUN_WEST = 0x1D8,
+	NOUN_DESERT_TO_WEST = 0x1D9,
+	NOUN_CROSS = 0x1DA,
+	NOUN_DESERT_TO_EAST = 0x1DB,
+	NOUN_DESERT_TO_SOUTH = 0x1DC,
+	NOUN_DESERT_TO_NORTH = 0x1DD,
+	NOUN_DESERT = 0x1DE,
+	NOUN_POWERSTONE = 0x1DF,
+	NOUN_BONES = 0x1E0,
+	NOUN_TENT = 0x1E1,
+	NOUN_BUSH = 0x1E2,
+	NOUN_SANWE = 0x1E3,
+	NOUN_TANGLE = 0x1E4,
+	NOUN_SAND = 0x1E5,
+	NOUN_MAGIC_GRAPES = 0x1E6,
+	NOUN_ROCS_NEST = 0x1E7,
+	NOUN_GRAPE_VINE = 0x1E8,
+	NOUN_STRANGE_SQUARE = 0x1E9,
+	NOUN_WATER_SPHERE = 0x1EA,
+	NOUN_EAST_END_OF_ISLAND = 0x1EB,
+	NOUN_ISLAND = 0x1EC,
+	NOUN_SECRET_MESSAGE = 0x1ED,
+	NOUN_FIND = 0x1EE,
+	NOUN_SAND_NEAR_STONES = 0x1EF,
+	NOUN_DESERT_SKY = 0x1F0,
+	NOUN_POOL = 0x1F1,
+	NOUN_PALM_TREE = 0x1F2,
+	NOUN_OASIS = 0x1F3,
+	NOUN_LEAN_TO = 0x1F4,
+	NOUN_TRADER = 0x1F5,
+	NOUN_SIGN = 0x1F6,
+	NOUN_WATER_FLOW = 0x1F7,
+	NOUN_FLOATING_DISK = 0x1F8,
+	NOUN_GNARLED_ROOT = 0x1F9,
+	NOUN_SNAKE_PIT = 0x1FA,
+	NOUN_MARKER = 0x1FB,
+	NOUN_SHAMAN = 0x1FC,
+	NOUN_GUARDHOUSE = 0x1FD,
+	NOUN_BONE_TREE = 0x1FE,
+	NOUN_EAR_ROCK = 0x1FF,
+	NOUN_MOUTH_ROCK = 0x200,
+	NOUN_NOSE_ROCK = 0x201,
+	NOUN_NEW_BUNDLE = 0x202,
+	NOUN_LIZARD = 0x203,
+	NOUN_ROC = 0x204,
+	NOUN_ROCS_NEST2 = 0x205,
+	NOUN_SELECT = 0x206,
+	NOUN_PURPLE_GEM = 0x207,
+	NOUN_PURPLE_STONE = 0x208,
+	NOUN_GREEN_STONE = 0x209,
+	NOUN_PATH = 0x20A,
+	NOUN_GUARDS = 0x20B,
+	NOUN_LAMP = 0x20C,
+	NOUN_SCIMITAR = 0x20D,
+	NOUN_SITTING_PILLOW = 0x20E,
+	NOUN_WATER_GOURD = 0x20F,
+	NOUN_JAR = 0x210,
+	NOUN_TENT_POLE = 0x211,
+	NOUN_EXIT = 0x212,
+	NOUN_PARAPHERNALIA = 0x213,
+	NOUN_SLATHAN_NI_PATAN3 = 0x214,
+	NOUN_EYE_ROCK = 0x215,
+	NOUN_BODY_TREE = 0x216,
+	NOUN_CLEARING = 0x217,
+	NOUN_TENTACLES = 0x218,
+	NOUN_SPELL_SHIELD = 0x219,
+	NOUN_POOL_MONSTER = 0x21A,
+	NOUN_SHIFTER_BOULDER = 0x21B,
+	NOUN_DEAD_TREE = 0x21C,
+	NOUN_PIT = 0x21D,
+	NOUN_SHIFTER_VILLAGE = 0x21E,
+	NOUN_SLATHAN_SKY = 0x21F,
+	NOUN_SHIFTER = 0x220,
+	NOUN_WALK_AROUND = 0x221,
+	NOUN_WRECKED_BRIDGE = 0x222,
+	NOUN_SHACK = 0x223,
+	NOUN_WRECKED_SHACK = 0x224,
+	NOUN_WISE_SHIFTER = 0x225,
+	NOUN_GRASS = 0x226,
+	NOUN_ENTRANCE_TO_MAZE = 0x227,
+	NOUN_TOPIARY_TOAD = 0x228,
+	NOUN_BOULDER = 0x229,
+	NOUN_MUSHROOM = 0x22A,
+	NOUN_SLATHAN_SKY2 = 0x22B,
+	NOUN_GRETA = 0x22C,
+	NOUN_TREE_STUMP = 0x22D,
+	NOUN_SANCTUARY_WOODS = 0x22E,
+	NOUN_TOADS = 0x22F,
+	NOUN_DOOFUS = 0x230,
+	NOUN_SHIFTING_MONSTER = 0x231,
+	NOUN_SPRITE = 0x232,
+	NOUN_MAZE = 0x233,
+	NOUN_TOPIARY_TOADSTOOL = 0x234,
+	NOUN_TOPIARY_GARGOYLE = 0x235,
+	NOUN_TOPIARY_DRAGON = 0x236,
+	NOUN_GUARDIAN = 0x237,
+	NOUN_BUTTERFLY_KING = 0x238,
+	NOUN_ROBE = 0x239,
+	NOUN_CEDAR_CHEST = 0x23A,
+	NOUN_DRAGONSPHERE2 = 0x23B,
+	NOUN_PATH_TO_HIGHTOWER2 = 0x23C,
+	NOUN_CALIPH = 0x23D
 };
 
 class SceneFactory {


Commit: 60b9876d8187d735ac933f5be2de61a9142115e2
    https://github.com/scummvm/scummvm/commit/60b9876d8187d735ac933f5be2de61a9142115e2
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T13:19:43+03:00

Commit Message:
MADS: Add more friendly names for nouns

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes8.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 6492006..ab73398 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -181,7 +181,7 @@ void Scene101::enter() {
 		_globals._sequenceIndexes[11] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[11], false, 3, 0, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[11], 17, 17);
 		_scene->_hotspots.activate(NOUN_CHAIR, false);
-		_chairHotspotId = _scene->_dynamicHotspots.add(0x47, 0x13F, -1, Common::Rect(159, 84, 159 + 33, 84 + 36));
+		_chairHotspotId = _scene->_dynamicHotspots.add(NOUN_CHAIR, 0x13F, -1, Common::Rect(159, 84, 159 + 33, 84 + 36));
 		if (_scene->_priorSceneId == 112)
 			sayDang();
 	} else {
@@ -2887,11 +2887,11 @@ void Scene111::enter() {
 	_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 	_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
 
-	int idx = _scene->_dynamicHotspots.add(0x1F, 0xD1, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+	int idx = _scene->_dynamicHotspots.add(NOUN_BATS, 0xD1, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
 	_scene->_dynamicHotspots.setPosition(idx, Common::Point(-2, 0), FACING_NONE);
-	idx = _scene->_dynamicHotspots.add(0x1F, 0xD1, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+	idx = _scene->_dynamicHotspots.add(NOUN_BATS, 0xD1, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 	_scene->_dynamicHotspots.setPosition(idx, Common::Point(-2, 0), FACING_NONE);
-	idx = _scene->_dynamicHotspots.add(0x1F, 0xD1, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+	idx = _scene->_dynamicHotspots.add(NOUN_BATS, 0xD1, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
 	_scene->_dynamicHotspots.setPosition(idx, Common::Point(-2, 0), FACING_NONE);
 
 	_launch1Fl = false;
@@ -2942,14 +2942,14 @@ void Scene111::step() {
 		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 5, 1, 0, 0);
 		_launch1Fl = true;
-		int idx = _scene->_dynamicHotspots.add(0x1F, 0xD1, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_BATS, 0xD1, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(-2, 0), FACING_NONE);
 	}
 
 	if (!_launched2Fl && (_vm->getRandomNumber(1, 30000) == 1)) {
 		_scene->_sequences.remove(_globals._sequenceIndexes[5]);
 		_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 5, 1, 0, 0);
-		int idx = _scene->_dynamicHotspots.add(0x1F, 0xD1, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_BATS, 0xD1, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(-2, 0), FACING_NONE);
 		_launched2Fl = true;
 	}
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 8209f0c..4cf1a2d 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -2518,7 +2518,7 @@ void Scene318::enter() {
 	if (_game._objects.isInRoom(OBJ_SCALPEL)) {
 		_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 0, 120);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 4);
-		_scene->_dynamicHotspots.add(0x12C, VERB_TAKE, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.add(NOUN_SCALPEL, VERB_TAKE, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
 	}
 
 	if (_scene->_priorSceneId == 357)
@@ -4058,7 +4058,7 @@ void Scene352::putArmDown(bool corridorExit, bool doorwayExit) {
 
 	case 2: {
 		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 0);
-		int idx = _scene->_dynamicHotspots.add(0x3B6, 0xD, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_GUARDS_ARM, 0xD, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(230, 117), FACING_NORTHWEST);
 		_scene->changeVariant(0);
 		}
@@ -4139,7 +4139,7 @@ void Scene352::enter() {
 	if (_game._objects.isInRoom(OBJ_TAPE_PLAYER)) {
 		_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 12, 0, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 5);
-		int idx = _scene->_dynamicHotspots.add(0x165, 0xD, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_TAPE_PLAYER, 0xD, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
 		_tapePlayerHotspotIdx = _scene->_dynamicHotspots.setPosition(idx, Common::Point(84, 145), FACING_WEST);
 	}
 
@@ -4153,7 +4153,7 @@ void Scene352::enter() {
 
 	if (_game._objects.isInRoom(OBJ_GUARDS_ARM)) {
 		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 0);
-		int idx = _scene->_dynamicHotspots.add(0x3B6, 0xD, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_GUARDS_ARM, 0xD, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(230, 117), FACING_NORTHWEST);
 	} else
 		_mustPutArmDownFl = true;
@@ -4405,7 +4405,7 @@ void Scene352::actions() {
 				_vaultOpenFl = true;
 				int idx;
 				if (!_globals[kHaveYourStuff]) {
-					idx = _scene->_dynamicHotspots.add(0x2F4, 0xD, -1, Common::Rect(282, 87, 282 + 13, 87 + 7));
+					idx = _scene->_dynamicHotspots.add(NOUN_YOUR_STUFF, 0xD, -1, Common::Rect(282, 87, 282 + 13, 87 + 7));
 					_hotspot2Idx = _scene->_dynamicHotspots.setPosition(idx, Common::Point(280, 111), FACING_NORTHEAST);
 					_globals._sequenceIndexes[1] = _commonSequenceIdx;
 					_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x102));
@@ -4414,9 +4414,9 @@ void Scene352::actions() {
 					_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x103));
 				}
 
-				idx = _scene->_dynamicHotspots.add(0x2F5, 0xD, -1, Common::Rect(282, 48, 282 + 36, 48 + 27));
+				idx = _scene->_dynamicHotspots.add(NOUN_OTHER_STUFF, 0xD, -1, Common::Rect(282, 48, 282 + 36, 48 + 27));
 				_hotspot1Idx = _scene->_dynamicHotspots.setPosition(idx, Common::Point(287, 115), FACING_NORTHEAST);
-				idx = _scene->_dynamicHotspots.add(0x2F6, 0xD, -1, Common::Rect(296, 76, 296 + 11, 76 + 17));
+				idx = _scene->_dynamicHotspots.add(NOUN_LAMP, 0xD, -1, Common::Rect(296, 76, 296 + 11, 76 + 17));
 				_lampHostpotIdx = _scene->_dynamicHotspots.setPosition(idx, Common::Point(287, 115), FACING_NORTHEAST);
 				_game._player._stepEnabled = true;
 				}
@@ -4833,7 +4833,7 @@ void Scene359::enter() {
 
 	if (_game._objects.isInRoom(OBJ_SECURITY_CARD)) {
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 9, 0, 0, 0);
-		_cardHotspotId = _scene->_dynamicHotspots.add(0x131, 0xD, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_cardHotspotId = _scene->_dynamicHotspots.add(NOUN_SECURITY_CARD, 0xD, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(_cardHotspotId, Common::Point(107, 107), FACING_SOUTH);
 	}
 
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index 195bba5..586d59d 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -849,14 +849,14 @@ void Scene402::enter() {
 		_globals._sequenceIndexes[14] = _scene->_sequences.startCycle(_globals._spriteIndexes[14], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[14], 7);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[14], Common::Point(210, 80));
-		int idx = _scene->_dynamicHotspots.add(0x124, 0xD1, _globals._sequenceIndexes[14], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_REPAIR_LIST, 0xD1, _globals._sequenceIndexes[14], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(0, 0), FACING_NONE);
 	}
 
 	{
 		_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
-		int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_BARTENDER, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
 	}
 
@@ -864,7 +864,7 @@ void Scene402::enter() {
 		_globals._sequenceIndexes[15] = _scene->_sequences.startCycle(_globals._spriteIndexes[15], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[15], 8);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[15], Common::Point(250, 80));
-		int idx = _scene->_dynamicHotspots.add(0x5C, 0x4, _globals._sequenceIndexes[15], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_CREDIT_CHIP, 0x4, _globals._sequenceIndexes[15], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(0, 0), FACING_NONE);
 	}
 
@@ -926,7 +926,7 @@ void Scene402::step() {
 			_globals._sequenceIndexes[10] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[10], false, 7, 0, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 3, 4);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 8);
-			int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[10], Common::Rect(0, 0, 0, 0));
+			int idx = _scene->_dynamicHotspots.add(NOUN_BARTENDER, 0xD, _globals._sequenceIndexes[10], Common::Rect(0, 0, 0, 0));
 			_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
 			_bartenderTalking = true;
 			if (_talkTimer > 1000)
@@ -939,7 +939,7 @@ void Scene402::step() {
 	if ((_game._trigger == 101) && _bartenderTalking) {
 		_scene->_sequences.remove(_globals._sequenceIndexes[10]);
 		_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
-		int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_BARTENDER, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
 		_bartenderSteady = true;
@@ -1068,7 +1068,7 @@ void Scene402::step() {
 			_globals._sequenceIndexes[15] = _scene->_sequences.startCycle(_globals._spriteIndexes[15], false, 1);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[15], 8);
 			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[15], Common::Point(250, 80));
-			int idx = _scene->_dynamicHotspots.add(0x5C, 0x4, _globals._sequenceIndexes[15], Common::Rect(0, 0, 0, 0));
+			int idx = _scene->_dynamicHotspots.add(NOUN_CREDIT_CHIP, 0x4, _globals._sequenceIndexes[15], Common::Rect(0, 0, 0, 0));
 			_scene->_dynamicHotspots.setPosition(idx, Common::Point(0, 0), FACING_NONE);
 			}
 			break;
@@ -1101,7 +1101,7 @@ void Scene402::step() {
 		int seqIdx = _globals._sequenceIndexes[12];
 		_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
 		_bartenderSteady = true;
-		int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_BARTENDER, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[9], seqIdx);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
@@ -1179,7 +1179,7 @@ void Scene402::step() {
 	case 91: {
 		_scene->_sequences.remove(_globals._sequenceIndexes[9]);
 		_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
-		int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_BARTENDER, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
 		_bartenderSteady = true;
@@ -1271,7 +1271,7 @@ void Scene402::step() {
 			case 1: {
 				_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[10], false, 4);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 8);
-				int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[10], Common::Rect(0, 0, 0, 0));
+				int idx = _scene->_dynamicHotspots.add(NOUN_BARTENDER, 0xD, _globals._sequenceIndexes[10], Common::Rect(0, 0, 0, 0));
 				_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
 				_bartenderHandsHips = true;
 				}
@@ -1280,7 +1280,7 @@ void Scene402::step() {
 			case 2: {
 				_globals._sequenceIndexes[11] = _scene->_sequences.startCycle(_globals._spriteIndexes[11], false, 2);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[11], 8);
-				int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[11], Common::Rect(0, 0, 0, 0));
+				int idx = _scene->_dynamicHotspots.add(NOUN_BARTENDER, 0xD, _globals._sequenceIndexes[11], Common::Rect(0, 0, 0, 0));
 				_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
 				_bartenderLooksLeft = true;
 				}
@@ -1289,7 +1289,7 @@ void Scene402::step() {
 			case 3: {
 				_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
-				int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
+				int idx = _scene->_dynamicHotspots.add(NOUN_BARTENDER, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
 				_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
 				_bartenderSteady = true;
 				}
@@ -1582,7 +1582,7 @@ void Scene402::step() {
 			_scene->_sequences.remove(_globals._sequenceIndexes[10]);
 			_bartenderHandsHips = false;
 			_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
-			int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
+			int idx = _scene->_dynamicHotspots.add(NOUN_BARTENDER, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
 			_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
 			_bartenderSteady = true;
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
@@ -1590,7 +1590,7 @@ void Scene402::step() {
 			_scene->_sequences.remove(_globals._sequenceIndexes[11]);
 			_bartenderLooksLeft = false;
 			_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
-			int idx = _scene->_dynamicHotspots.add(0x30E, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
+			int idx = _scene->_dynamicHotspots.add(NOUN_BARTENDER, 0xD, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
 			_scene->_dynamicHotspots.setPosition(idx, Common::Point(228, 83), FACING_SOUTH);
 			_bartenderSteady = true;
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
@@ -2863,7 +2863,7 @@ void Scene408::enter() {
 	if (_game._objects.isInRoom(OBJ_TARGET_MODULE)) {
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 3);
-		int idx = _scene->_dynamicHotspots.add(0x167, 0xD, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_TARGET_MODULE, 0xD, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(283, 128), FACING_NORTHEAST);
 	}
 	sceneEntrySound();
@@ -3557,21 +3557,21 @@ void Scene411::enter() {
 	if (_game._objects.isInRoom(OBJ_FORMALDEHYDE)) {
 		_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 1);
-		int idx = _scene->_dynamicHotspots.add(0x2D6, VERB_WALKTO, _globals._sequenceIndexes[7], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_FORMALDEHYDE, VERB_WALKTO, _globals._sequenceIndexes[7], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(206, 145), FACING_SOUTHEAST);
 	}
 
 	if (_game._objects.isInRoom(OBJ_PETROX)) {
 		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 8);
-		int idx = _scene->_dynamicHotspots.add(0x2D7, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_PETROX, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(186, 112), FACING_NORTHEAST);
 	}
 
 	if (_game._objects.isInRoom(OBJ_LECITHIN)) {
 		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 8);
-		int idx = _scene->_dynamicHotspots.add(0x3A9, VERB_WALKTO, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_LECITHIN, VERB_WALKTO, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(220, 121), FACING_NORTHEAST);
 	}
 
diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index fb79492..1ad29a3 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -166,7 +166,7 @@ void Scene501::enter() {
 	}
 
 	_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
-	int idx = _scene->_dynamicHotspots.add(0x6E, 0x18B, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+	int idx = _scene->_dynamicHotspots.add(NOUN_DOOR, 0x18B, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
 	_doorHotspotid = _scene->_dynamicHotspots.setPosition(idx,Common::Point(282, 110), FACING_NORTH);
 	_scene->_dynamicHotspots.setCursor(_doorHotspotid, CURSOR_GO_UP);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 7);
@@ -233,7 +233,7 @@ void Scene501::step() {
 			_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 9, 1, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 7);
 			_vm->_sound->command(12);
-			_doorHotspotid = _scene->_dynamicHotspots.add(0x6E, 0x18B, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+			_doorHotspotid = _scene->_dynamicHotspots.add(NOUN_DOOR, 0x18B, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
 			_scene->_dynamicHotspots.setPosition(_globals._sequenceIndexes[3], Common::Point(282, 110), FACING_NORTH);
 			_scene->_dynamicHotspots.setCursor(_doorHotspotid, CURSOR_GO_UP);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 83);
@@ -540,7 +540,7 @@ void Scene503::enter() {
 
 	if (_game._objects[OBJ_DETONATORS]._roomNumber == _scene->_currentSceneId) {
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 9, 0, 0, 0);
-		_detonatorHotspotId = _scene->_dynamicHotspots.add(0x6A, 0xD, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_detonatorHotspotId = _scene->_dynamicHotspots.add(NOUN_DETONATORS, 0xD, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(_detonatorHotspotId, Common::Point(254, 135), FACING_SOUTH);
 	}
 
@@ -1111,12 +1111,12 @@ void Scene506::enter() {
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXCD_3");
 
 	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
-	int idx = _scene->_dynamicHotspots.add(0x37D, 0x242, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+	int idx = _scene->_dynamicHotspots.add(NOUN_LABORATORY, 0x242, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 	int hotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(65, 125), FACING_NORTHWEST);
 	_scene->_dynamicHotspots.setCursor(hotspotId, CURSOR_GO_LEFT);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 	_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
-	idx = _scene->_dynamicHotspots.add(0x336, 0x242, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+	idx = _scene->_dynamicHotspots.add(NOUN_SOFTWARE_STORE, 0x242, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
 	hotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(112, 102), FACING_NORTHWEST);
 	_scene->_dynamicHotspots.setCursor(hotspotId, CURSOR_GO_LEFT);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 13);
@@ -1371,7 +1371,7 @@ void Scene507::enter() {
 
 	if ((_game._difficulty != DIFFICULTY_EASY) && (_game._objects[OBJ_PENLIGHT]._roomNumber == _scene->_currentSceneId)) {
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 9, 0, 0, 0);
-		_penlightHotspotId = _scene->_dynamicHotspots.add(0x106, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_penlightHotspotId = _scene->_dynamicHotspots.add(NOUN_PENLIGHT, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(_penlightHotspotId, Common::Point(233, 152), FACING_SOUTHEAST);
 	}
 
@@ -1495,7 +1495,7 @@ void Scene508::enter() {
 		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -2);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 8);
 		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, -2);
-		int idx = _scene->_dynamicHotspots.add(0x343, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_LASER_BEAM, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(57, 116), FACING_NORTHEAST);
 		_scene->_hotspots.activate(NOUN_HOLE, false);
 		_scene->_hotspots.activate(NOUN_LASER_BEAM, false);
@@ -1505,7 +1505,7 @@ void Scene508::enter() {
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 8);
 		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, -2);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 11);
-		int idx = _scene->_dynamicHotspots.add(0x343, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_LASER_BEAM, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(57, 116), FACING_NORTHEAST);
 		_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 15, 0, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 6, 8);
@@ -1640,7 +1640,7 @@ void Scene508::actions() {
 				_vm->_sound->command(22);
 				_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, -2);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 11);
-				int idx = _scene->_dynamicHotspots.add(0x343, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+				int idx = _scene->_dynamicHotspots.add(NOUN_LASER_BEAM, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 				_scene->_dynamicHotspots.setPosition(idx, Common::Point(57, 116), FACING_NORTHEAST);
 				_scene->_kernelMessages.reset();
 				_scene->changeVariant(1);
@@ -1748,7 +1748,7 @@ void Scene511::enter() {
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 3);
 		_scene->_hotspots.activate(NOUN_BOAT, false);
-		int idx = _scene->_dynamicHotspots.add(0x345, VERB_WALKTO, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_BOAT, VERB_WALKTO, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(75, 124), FACING_NORTH);
 		_scene->_hotspots.activate(NOUN_ROPE, false);
 	} else {
@@ -1779,7 +1779,7 @@ void Scene511::enter() {
 	if (_globals[kLineStatus] == 2 || _globals[kLineStatus] == 3) {
 		_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('b', 4));
 		_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, frame);
-		int idx = _scene->_dynamicHotspots.add(0x87, VERB_WALKTO, _globals._sequenceIndexes[7], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_FISHING_LINE, VERB_WALKTO, _globals._sequenceIndexes[7], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(26, 153), FACING_NORTHEAST);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 3);
 		if (_globals[kBoatRaised])
@@ -1981,7 +1981,7 @@ void Scene511::actions() {
 						_game._player._priorTimer = _scene->_frameStartTime - _game._player._ticksAmount;
 						_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, -2);
 						_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 4);
-						int idx = _scene->_dynamicHotspots.add(0x87, VERB_WALKTO, _globals._sequenceIndexes[7], Common::Rect(0, 0, 0, 0));
+						int idx = _scene->_dynamicHotspots.add(NOUN_FISHING_LINE, VERB_WALKTO, _globals._sequenceIndexes[7], Common::Rect(0, 0, 0, 0));
 						_scene->_dynamicHotspots.setPosition(idx, Common::Point(26, 153), FACING_NORTHEAST);
 						_game._objects.removeFromInventory(OBJ_FISHING_LINE, 1);
 						_handingLine = false;
@@ -2069,7 +2069,7 @@ void Scene512::enter() {
 
 	if (_game._objects[OBJ_FISHING_ROD]._roomNumber == _scene->_currentSceneId) {
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 9, 0, 0, 0);
-		_fishingRodHotspotId = _scene->_dynamicHotspots.add(0x88, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_fishingRodHotspotId = _scene->_dynamicHotspots.add(NOUN_FISHING_ROD, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(_fishingRodHotspotId, Common::Point(199, 101), FACING_NORTHEAST);
 	}
 
@@ -2081,7 +2081,7 @@ void Scene512::enter() {
 		if (_game._objects[OBJ_PADLOCK_KEY]._roomNumber == _scene->_currentSceneId) {
 			_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 10, 0, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 3);
-			_keyHotspotId = _scene->_dynamicHotspots.add(0xFF, VERB_WALKTO, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
+			_keyHotspotId = _scene->_dynamicHotspots.add(NOUN_PADLOCK_KEY, VERB_WALKTO, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
 			_scene->_dynamicHotspots.setPosition(_keyHotspotId, Common::Point(218, 152), FACING_NORTHEAST);
 		}
 		if (_globals[kRegisterOpen]) {
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index e9c4473..53e187a 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -97,7 +97,7 @@ void Scene601::enter() {
 
 	if (_globals[kLaserHoleIsThere]) {
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2);
-		_scene->_dynamicHotspots.add(0x343, 0xD1, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_scene->_dynamicHotspots.add(NOUN_LASER_BEAM, 0xD1, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 	}
 
 	_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
@@ -240,7 +240,7 @@ void Scene602::enter() {
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 9);
 		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 9);
-		int idx = _scene->_dynamicHotspots.add(0x343, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_LASER_BEAM, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(80, 134), FACING_NORTHEAST);
 		_scene->changeVariant(1);
 	} else
@@ -262,7 +262,7 @@ void Scene602::enter() {
 
 	_lastSequenceIdx = _scene->_sequences.startCycle(_lastSpriteIdx, false, _cycleIndex);
 	_scene->_sequences.setDepth(_lastSequenceIdx, 14);
-	int idx = _scene->_dynamicHotspots.add(0x3D3, VERB_WALKTO, _lastSequenceIdx, Common::Rect(0, 0, 0, 0));
+	int idx = _scene->_dynamicHotspots.add(NOUN_SAFE, VERB_WALKTO, _lastSequenceIdx, Common::Rect(0, 0, 0, 0));
 	_scene->_dynamicHotspots.setPosition(idx, Common::Point(185, 113), FACING_NORTHWEST);
 
 	if (_game._objects.isInRoom(OBJ_DOOR_KEY)) {
@@ -346,7 +346,7 @@ void Scene602::handleSafeActions() {
 		_lastSequenceIdx = _scene->_sequences.startCycle(_lastSpriteIdx, false, _cycleIndex);
 		_scene->_sequences.setDepth(_lastSequenceIdx, 14);
 		_scene->_sequences.updateTimeout(_lastSequenceIdx, synxIdx);
-		int idx = _scene->_dynamicHotspots.add(0x3D3, VERB_WALKTO, _lastSequenceIdx, Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_SAFE, VERB_WALKTO, _lastSequenceIdx, Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(185, 113), FACING_NORTHWEST);
 		if (_safeMode == 3) {
 			_scene->_kernelMessages.reset();
@@ -419,11 +419,11 @@ void Scene602::actions() {
 			_lastSpriteIdx = _globals._spriteIndexes[3];
 			_lastSequenceIdx = _scene->_sequences.startCycle(_lastSpriteIdx, false, -1);
 			_scene->_sequences.setDepth(_lastSequenceIdx, 14);
-			int idx = _scene->_dynamicHotspots.add(0x3D3, VERB_WALKTO, _lastSequenceIdx, Common::Rect(0, 0, 0, 0));
+			int idx = _scene->_dynamicHotspots.add(NOUN_SAFE, VERB_WALKTO, _lastSequenceIdx, Common::Rect(0, 0, 0, 0));
 			_scene->_dynamicHotspots.setPosition(idx, Common::Point(185, 113), FACING_NORTHWEST);
 			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 9);
-			idx = _scene->_dynamicHotspots.add(0x343, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+			idx = _scene->_dynamicHotspots.add(NOUN_LASER_BEAM, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 			_scene->_dynamicHotspots.setPosition(idx, Common::Point(80, 134), FACING_NORTHEAST);
 			_scene->_sequences.addTimer(60, 2);
 			}
@@ -544,7 +544,7 @@ void Scene603::enter() {
 		_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', -1));
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
-		_compactCaseHotspotId = _scene->_dynamicHotspots.add(0x57, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_compactCaseHotspotId = _scene->_dynamicHotspots.add(NOUN_COMPACT_CASE, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(_compactCaseHotspotId, Common::Point(250, 152), FACING_SOUTHEAST);
 	}
 
@@ -553,7 +553,7 @@ void Scene603::enter() {
 		_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('p', -1));
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 14);
-		_noteHotspotId = _scene->_dynamicHotspots.add(0x3A8, VERB_WALKTO, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+		_noteHotspotId = _scene->_dynamicHotspots.add(NOUN_NOTE, VERB_WALKTO, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(_noteHotspotId, Common::Point(242, 118), FACING_NORTHEAST);
 	}
 
@@ -688,7 +688,7 @@ void Scene604::enter() {
 
 	if (_globals[kTimebombStatus] == 1) {
 		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, -1);
-		_timebombHotspotId = _scene->_dynamicHotspots.add(0x171, VERB_WALKTO, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
+		_timebombHotspotId = _scene->_dynamicHotspots.add(NOUN_TIMEBOMB, VERB_WALKTO, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(_timebombHotspotId, Common::Point(166, 118), FACING_NORTHEAST);
 	}
 
@@ -820,7 +820,7 @@ void Scene604::handleBombActions() {
 
 	case 1:
 		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, -1);
-		_timebombHotspotId = _scene->_dynamicHotspots.add(0x171, VERB_WALKTO, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
+		_timebombHotspotId = _scene->_dynamicHotspots.add(NOUN_TIMEBOMB, VERB_WALKTO, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(_timebombHotspotId, Common::Point(166, 118), FACING_NORTHEAST);
 		_game._objects.setRoom(OBJ_TIMEBOMB, _scene->_currentSceneId);
 		break;
@@ -1429,7 +1429,7 @@ void Scene608::setup() {
 
 void Scene608::resetDogVariables() {
 	_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
-	int idx = _scene->_dynamicHotspots.add(0x471, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+	int idx = _scene->_dynamicHotspots.add(NOUN_OBNOXIOUS_DOG, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
 	_scene->_dynamicHotspots.setPosition(idx, Common::Point(194, 142), FACING_EAST);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 4);
 	_dogBarkingFl = false;
@@ -1542,7 +1542,7 @@ void Scene608::enter() {
 	if (_game._objects.isInRoom(OBJ_POLYCEMENT)) {
 		_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('g', -1));
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
-		int idx = _scene->_dynamicHotspots.add(0x115, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_POLYCEMENT, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_polycementHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(249, 129), FACING_NORTHEAST);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 6);
 	}
@@ -1550,7 +1550,7 @@ void Scene608::enter() {
 	if (_game._objects.isInRoom(OBJ_REARVIEW_MIRROR)) {
 		_globals._spriteIndexes[12] = _scene->_sprites.addSprites(formAnimName('m', -1));
 		_globals._sequenceIndexes[12] = _scene->_sequences.startCycle(_globals._spriteIndexes[12], false, 1);
-		int idx = _scene->_dynamicHotspots.add(0x120, VERB_WALKTO, _globals._sequenceIndexes[12], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_REARVIEW_MIRROR, VERB_WALKTO, _globals._sequenceIndexes[12], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(71, 113), FACING_NORTHEAST);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[12], 15);
 	}
@@ -1594,14 +1594,14 @@ void Scene608::enter() {
 		_carMode = 0;
 		_dogDeathMode = 0;
 		_resetPositionsFl = false;
-		int idx = _scene->_dynamicHotspots.add(0x324, VERB_WALKTO, -1, Common::Rect(99, 69, 99 + 82, 69 + 25));
+		int idx = _scene->_dynamicHotspots.add(NOUN_CAR, VERB_WALKTO, -1, Common::Rect(99, 69, 99 + 82, 69 + 25));
 		_carHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(96, 132), FACING_NORTHEAST);
 		_scene->loadAnimation(formAnimName('A', -1));
 	} else if (_globals[kCarStatus] == 3) {
 		_carMode = 0;
 		_dogDeathMode = 0;
 		_resetPositionsFl = false;
-		int idx = _scene->_dynamicHotspots.add(0x324, VERB_WALKTO, -1, Common::Rect(100, 100, 100 + 82, 100 + 25));
+		int idx = _scene->_dynamicHotspots.add(NOUN_CAR, VERB_WALKTO, -1, Common::Rect(100, 100, 100 + 82, 100 + 25));
 		_carHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(96, 132), FACING_NORTHEAST);
 		_scene->loadAnimation(formAnimName('A', -1));
 		_scene->_activeAnimation->setCurrentFrame(6);
@@ -1609,21 +1609,21 @@ void Scene608::enter() {
 		_carMode = 2;
 		_dogDeathMode = 0;
 		_resetPositionsFl = false;
-		int idx = _scene->_dynamicHotspots.add(0x324, VERB_WALKTO, -1, Common::Rect(99, 69, 99 + 82, 69 + 25));
+		int idx = _scene->_dynamicHotspots.add(NOUN_CAR, VERB_WALKTO, -1, Common::Rect(99, 69, 99 + 82, 69 + 25));
 		_carHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(96, 132), FACING_NORTHEAST);
 		_scene->loadAnimation(formAnimName('C', -1));
 	} else if (_globals[kCarStatus] == 2) {
 		_carMode = 1;
 		_dogDeathMode = 2;
 		_resetPositionsFl = true;
-		int idx = _scene->_dynamicHotspots.add(0x324, VERB_WALKTO, -1, Common::Rect(99, 69, 99 + 82, 69 + 25));
+		int idx = _scene->_dynamicHotspots.add(NOUN_CAR, VERB_WALKTO, -1, Common::Rect(99, 69, 99 + 82, 69 + 25));
 		_carHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(96, 132), FACING_NORTHEAST);
 		_scene->loadAnimation(formAnimName('B', -1));
 	} else {
 		_carMode = 3;
 		_dogDeathMode = 2;
 		_resetPositionsFl = true;
-		int idx = _scene->_dynamicHotspots.add(0x324, VERB_WALKTO, -1, Common::Rect(100, 100, 100 + 82, 100 + 25));
+		int idx = _scene->_dynamicHotspots.add(NOUN_CAR, VERB_WALKTO, -1, Common::Rect(100, 100, 100 + 82, 100 + 25));
 		_carHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(96, 132), FACING_NORTHEAST);
 		_scene->loadAnimation(formAnimName('D', -1));
 	}
@@ -1688,7 +1688,7 @@ void Scene608::step() {
 				_scene->_sequences.remove(_globals._sequenceIndexes[5]);
 				_globals._sequenceIndexes[5] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], false, 5, 8, 0, 0);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 4);
-				int idx = _scene->_dynamicHotspots.add(0x471, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+				int idx = _scene->_dynamicHotspots.add(NOUN_OBNOXIOUS_DOG, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
 				_scene->_dynamicHotspots.setPosition(idx, Common::Point(194, 142), FACING_EAST);
 				_barkCount = 0;
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_SPRITE, 2, 100);
@@ -2140,7 +2140,7 @@ void Scene608::actions() {
 				_scene->_sequences.addTimer(1, 2);
 			else {
 				_scene->_dynamicHotspots.remove(_carHotspotId);
-				int idx = _scene->_dynamicHotspots.add(0x324, VERB_WALKTO, -1, Common::Rect(100, 100, 100 + 82, 100 + 25));
+				int idx = _scene->_dynamicHotspots.add(NOUN_CAR, VERB_WALKTO, -1, Common::Rect(100, 100, 100 + 82, 100 + 25));
 				_carHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(96, 132), FACING_NORTHEAST);
 				if (_globals[kCarStatus] == 1)
 					_scene->_sequences.addTimer(120, 3);
@@ -2208,7 +2208,7 @@ void Scene608::actions() {
 				_dogDeathMode = 2;
 			}
 			_scene->_dynamicHotspots.remove(_carHotspotId);
-			int idx = _scene->_dynamicHotspots.add(0x324, VERB_WALKTO, -1, Common::Rect(99, 69, 99 + 82, 69 + 25));
+			int idx = _scene->_dynamicHotspots.add(NOUN_CAR, VERB_WALKTO, -1, Common::Rect(99, 69, 99 + 82, 69 + 25));
 			_carHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(96, 132), FACING_NORTHEAST);
 			_game._player._stepEnabled = true;
 			}
@@ -2724,7 +2724,7 @@ void Scene610::enter() {
 
 	if (_game._objects[OBJ_PHONE_HANDSET]._roomNumber == _scene->_currentSceneId) {
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 9, 0, 0, 0);
-		_handsetHotspotId = _scene->_dynamicHotspots.add(0x108, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		_handsetHotspotId = _scene->_dynamicHotspots.add(NOUN_PHONE_HANDSET, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(_handsetHotspotId, Common::Point(132, 121), FACING_NORTHWEST);
 		if ((_globals[kHandsetCellStatus] == 2) && (_game._difficulty == DIFFICULTY_HARD) && !_globals[kDurafailRecharged])
 			_globals[kHandsetCellStatus] = 1;
@@ -2810,7 +2810,7 @@ void Scene610::actions() {
 
 		case 1:
 			_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 9, 0, 0, 0);
-			_handsetHotspotId = _scene->_dynamicHotspots.add(0x108, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+			_handsetHotspotId = _scene->_dynamicHotspots.add(NOUN_PHONE_HANDSET, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 			_scene->_dynamicHotspots.setPosition(_handsetHotspotId, Common::Point(132, 121), FACING_NORTHWEST);
 			_game._objects.setRoom(OBJ_PHONE_HANDSET, _scene->_currentSceneId);
 			break;
@@ -3808,7 +3808,7 @@ void Scene611::step() {
 	} else if (_game._trigger == 81) {
 		int syncId = _globals._sequenceIndexes[1];
 		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 20, 0, 0, 0);
-		int idx = _scene->_dynamicHotspots.add(0x275, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_RAT, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_ratHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(272, 154), FACING_SOUTHEAST);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 9, 10);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[1], syncId);
@@ -4329,7 +4329,7 @@ void Scene612::enter() {
 		_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('f', -1));
 		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, -1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[5], 1);
-		int idx = _scene->_dynamicHotspots.add(0x87, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_FISHING_LINE, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(34, 117), FACING_SOUTHEAST);
 	}
 
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 5c1f7bf..541e22e 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -1168,7 +1168,7 @@ void Scene704::enter() {
 			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(190, 122));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 2);
 		}
-		int idx = _scene->_dynamicHotspots.add(0x2D, 0xD1, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_BONES, 0xD1, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_bottleHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(-2, 0), FACING_NONE);
 	}
 
@@ -1730,7 +1730,7 @@ void Scene706::handleTakeVase() {
 			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 4);
 			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(195, 99));
-			int idx = _scene->_dynamicHotspots.add(0x2E, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+			int idx = _scene->_dynamicHotspots.add(NOUN_BOTTLE, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 			_scene->_dynamicHotspots.setPosition(idx, Common::Point(175, 124), FACING_SOUTHEAST);
 			_game._objects.setRoom(OBJ_BOTTLE, _scene->_currentSceneId);
 		}
@@ -1756,13 +1756,13 @@ void Scene706::enter() {
 		_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('v', -1));
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 4);
-		int idx = _scene->_dynamicHotspots.add(0x17D, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_VASE, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_vaseHotspotId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(175, 124), FACING_SOUTHEAST);
 	} else if (_game._objects.isInRoom(OBJ_BOTTLE)) {
 		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 4);
 		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(195, 99));
-		int idx = _scene->_dynamicHotspots.add(0x2E, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_BOTTLE, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(175, 124), FACING_SOUTHEAST);
 	}
 
@@ -1836,7 +1836,7 @@ void Scene706::step() {
 					_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 					_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 4);
 					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(195, 99));
-					int idx = _scene->_dynamicHotspots.add(0x2E, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+					int idx = _scene->_dynamicHotspots.add(NOUN_BOTTLE, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 					_scene->_dynamicHotspots.setPosition(idx, Common::Point(175, 124), FACING_SOUTHEAST);
 				}
 			}
@@ -2101,7 +2101,7 @@ void Scene751::enter() {
 	if (_globals[kLineStatus] == 2 || _globals[kLineStatus] == 3) {
 		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 7);
-		int idx = _scene->_dynamicHotspots.add(0x87, 0xD, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_FISHING_LINE, 0xD, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(268, 140), FACING_NORTHWEST);
 	}
 
@@ -2135,7 +2135,7 @@ void Scene751::enter() {
 	} else if (_globals[kLineStatus] == 2) {
 		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 7);
-		int idx = _scene->_dynamicHotspots.add(0x87, 0xD, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_FISHING_LINE, 0xD, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(268, 140), FACING_NORTHWEST);
 	}
 
@@ -2359,7 +2359,7 @@ void Scene751::actions() {
 				_game._player._visible = true;
 				_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -1);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 7);
-				int idx = _scene->_dynamicHotspots.add(0x87, 0xD, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
+				int idx = _scene->_dynamicHotspots.add(NOUN_FISHING_LINE, 0xD, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
 				_scene->_dynamicHotspots.setPosition(idx, Common::Point(268, 140), FACING_NORTHWEST);
 				_scene->_kernelMessages.reset();
 				_game._objects.setRoom(OBJ_FISHING_LINE, _scene->_currentSceneId);
@@ -2435,7 +2435,7 @@ void Scene752::enter() {
 		_globals._spriteIndexes[13] = _scene->_sprites.addSprites(formAnimName('i', -1));
 		_globals._sequenceIndexes[13] = _scene->_sequences.startCycle(_globals._spriteIndexes[13], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[13], 8);
-		int idx = _scene->_dynamicHotspots.add(0xB3, VERB_WALKTO, _globals._sequenceIndexes[13], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_ID_CARD, VERB_WALKTO, _globals._sequenceIndexes[13], Common::Rect(0, 0, 0, 0));
 		_cardId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(234, 135), FACING_NORTH);
 	}
 
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index e6f8701..dc5a4cd 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -353,14 +353,14 @@ void Scene802::enter() {
 	if ((_globals[kRemoteOnGround]) && (!_game._objects.isInInventory(OBJ_REMOTE))) {
 		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 8);
-		int idx = _scene->_dynamicHotspots.add(0x123, 0xD,_globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_REMOTE, 0xD,_globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(107, 99), FACING_NORTH);
 	}
 
 	if (!_game._objects.isInInventory(OBJ_SHIELD_MODULATOR) && !_globals[kShieldModInstalled]) {
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 8);
-		int idx = _scene->_dynamicHotspots.add(0x137, 0xD, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_SHIELD_MODULATOR, 0xD, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(93, 97), FACING_NORTH);
 	}
 	sceneEntrySound();
@@ -378,7 +378,7 @@ void Scene802::step() {
 	if (_game._trigger == 71) {
 		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 8);
-		int idx = _scene->_dynamicHotspots.add(0x123, 0xD, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_REMOTE, 0xD, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(107, 99), FACING_NORTH);
 
 		_globals[kRemoteSequenceRan] = true;
@@ -535,7 +535,7 @@ void Scene803::enter() {
 	if (_globals[kHoppyDead]) {
 		_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('e', 1));
 		_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, 1);
-		int idx = _scene->_dynamicHotspots.add(0x472, 0xD, _globals._sequenceIndexes[7], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_GUTS, 0xD, _globals._sequenceIndexes[7], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(66, 123), FACING_SOUTH);
 	}
 
@@ -627,7 +627,7 @@ void Scene803::step() {
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5],SEQUENCE_TRIGGER_EXPIRE, 0, 101);
 		} else {
 			_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, -2);
-			int idx = _scene->_dynamicHotspots.add(0x472, 0xD, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+			int idx = _scene->_dynamicHotspots.add(NOUN_GUTS, 0xD, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
 			_scene->_dynamicHotspots.setPosition(idx, Common::Point(66, 123), FACING_SOUTH);
 			_vm->_sound->command(16);
 			_globals[kCameFromCut] = true;
@@ -646,7 +646,7 @@ void Scene803::step() {
 
 	if (_game._trigger == 101) {
 		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, -2);
-		int idx = _scene->_dynamicHotspots.add(0x472, 0xD, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_GUTS, 0xD, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(66, 123), FACING_SOUTH);
 		_vm->_sound->command(16);
 		_globals[kCameFromCut] = true;
@@ -1075,14 +1075,14 @@ void Scene805::enter() {
 	if (_globals[kShieldModInstalled]) {
 		_scene->_hotspots.activate(OBJ_SHIELD_MODULATOR, false);
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 25);
-		int idx = _scene->_dynamicHotspots.add(0x137, 0x476, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_SHIELD_MODULATOR, 0x476, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(0, 0), FACING_DUMMY);
 	}
 
 	if (_globals[kTargetModInstalled]) {
 		_scene->_hotspots.activate(OBJ_TARGET_MODULE, false);
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 12);
-		int idx = _scene->_dynamicHotspots.add(0x167, 0x476, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_TARGET_MODULE, 0x476, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(0, 0), FACING_DUMMY);
 	}
 
@@ -1093,7 +1093,7 @@ void Scene805::step() {
 	if (_game._trigger == 70) {
 		_scene->_hotspots.activate(OBJ_SHIELD_MODULATOR, false);
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 25);
-		int idx = _scene->_dynamicHotspots.add(0x137, 0x476, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_SHIELD_MODULATOR, 0x476, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(0, 0), FACING_DUMMY);
 		_globals[kShieldModInstalled] = true;
 		_game._objects.setRoom(OBJ_SHIELD_MODULATOR, NOWHERE);
@@ -1104,7 +1104,7 @@ void Scene805::step() {
 	if (_game._trigger == 80) {
 		_scene->_hotspots.activate(OBJ_TARGET_MODULE, false);
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 12);
-		int idx = _scene->_dynamicHotspots.add(0x167, 0x476, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
+		int idx = _scene->_dynamicHotspots.add(NOUN_TARGET_MODULE, 0x476, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(0, 0), FACING_DUMMY);
 		_globals[kTargetModInstalled] = true;
 		_game._objects.setRoom(OBJ_TARGET_MODULE, NOWHERE);


Commit: 1b34888b26d460cd7f36b6a5b280f931f97e6464
    https://github.com/scummvm/scummvm/commit/1b34888b26d460cd7f36b6a5b280f931f97e6464
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T13:52:23+03:00

Commit Message:
MADS: Fix the GMM menu for V2 games

Changed paths:
    engines/mads/dragonsphere/game_dragonsphere.h
    engines/mads/phantom/game_phantom.h



diff --git a/engines/mads/dragonsphere/game_dragonsphere.h b/engines/mads/dragonsphere/game_dragonsphere.h
index c5d6c0d..259c416 100644
--- a/engines/mads/dragonsphere/game_dragonsphere.h
+++ b/engines/mads/dragonsphere/game_dragonsphere.h
@@ -91,7 +91,9 @@ enum InventoryObject {
 // HACK: A stub for now, remove from here once it's implemented properly
 class DragonsphereGlobals: public Globals {
 public:
-	DragonsphereGlobals() {}
+	DragonsphereGlobals() {
+		resize(210);	// Rex has 210 globals
+	}
 	virtual ~DragonsphereGlobals() {}
 };
 
diff --git a/engines/mads/phantom/game_phantom.h b/engines/mads/phantom/game_phantom.h
index 600c584..c99e81e 100644
--- a/engines/mads/phantom/game_phantom.h
+++ b/engines/mads/phantom/game_phantom.h
@@ -67,7 +67,10 @@ enum InventoryObject {
 // HACK: A stub for now, remove from here once it's implemented properly
 class PhantomGlobals: public Globals {
 public:
-	PhantomGlobals() {}
+	PhantomGlobals() {
+		resize(210);	// Rex has 210 globals
+	}
+	virtual ~PhantomGlobals() {}
 };
 
 class GamePhantom: public Game {


Commit: eb7d018b4acc4c0d0614ed185b632c618636d727
    https://github.com/scummvm/scummvm/commit/eb7d018b4acc4c0d0614ed185b632c618636d727
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T14:31:10+03:00

Commit Message:
MADS: Add a debug command to show messages

Changed paths:
    engines/mads/debugger.cpp
    engines/mads/debugger.h



diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp
index 0b69ee8..9f5735f 100644
--- a/engines/mads/debugger.cpp
+++ b/engines/mads/debugger.cpp
@@ -41,6 +41,7 @@ Debugger::Debugger(MADSEngine *vm) : GUI::Debugger(), _vm(vm) {
 	DCmd_Register("show_quote", WRAP_METHOD(Debugger, Cmd_ShowQuote));
 	DCmd_Register("show_vocab", WRAP_METHOD(Debugger, Cmd_ShowVocab));
 	DCmd_Register("dump_vocab", WRAP_METHOD(Debugger, Cmd_DumpVocab));
+	DCmd_Register("show_message", WRAP_METHOD(Debugger, Cmd_ShowMessage));
 	DCmd_Register("show_item", WRAP_METHOD(Debugger, Cmd_ShowItem));
 	DCmd_Register("dump_items", WRAP_METHOD(Debugger, Cmd_DumpItems));
 	DCmd_Register("item", WRAP_METHOD(Debugger, Cmd_Item));
@@ -244,6 +245,21 @@ bool Debugger::Cmd_DumpVocab(int argc, const char **argv) {
 	return true;
 }
 
+bool Debugger::Cmd_ShowMessage(int argc, const char **argv) {
+	if (argc != 2) {
+		DebugPrintf("Usage: %s <message number>\n", argv[0]);
+	} else {
+		int messageId = strToInt(argv[1]);
+		Common::StringArray msg = _vm->_game->getMessage(messageId);
+		for (uint idx = 0; idx < msg.size(); ++idx) {
+			Common::String srcLine = msg[idx];
+			DebugPrintf("%s\n", srcLine.c_str());
+		}
+	}
+
+	return true;
+}
+
 bool Debugger::Cmd_ShowItem(int argc, const char **argv) {
 	InventoryObjects &objects = _vm->_game->_objects;
 
diff --git a/engines/mads/debugger.h b/engines/mads/debugger.h
index 9059f3f..351eb13 100644
--- a/engines/mads/debugger.h
+++ b/engines/mads/debugger.h
@@ -45,6 +45,7 @@ protected:
 	bool Cmd_ShowQuote(int argc, const char **argv);
 	bool Cmd_ShowVocab(int argc, const char **argv);
 	bool Cmd_DumpVocab(int argc, const char **argv);
+	bool Cmd_ShowMessage(int argc, const char **argv);
 	bool Cmd_ShowItem(int argc, const char **argv);
 	bool Cmd_DumpItems(int argc, const char **argv);
 	bool Cmd_Item(int argc, const char **argv);


Commit: 555b4dfd6e076dd5ef5cfc982fb5dbf3e211d198
    https://github.com/scummvm/scummvm/commit/555b4dfd6e076dd5ef5cfc982fb5dbf3e211d198
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-05-20T15:07:45+03:00

Commit Message:
MADS: Load scene speech resources for V2 CD games

Changed paths:
    engines/mads/resources.cpp



diff --git a/engines/mads/resources.cpp b/engines/mads/resources.cpp
index 83077b6..0d5aee1 100644
--- a/engines/mads/resources.cpp
+++ b/engines/mads/resources.cpp
@@ -149,7 +149,7 @@ Common::SeekableReadStream *HagArchive::createReadStreamForMember(const Common::
 void HagArchive::loadIndex(MADSEngine *vm) {
 	Common::File hagFile;
 
-	for (int sectionIndex = -1; sectionIndex < 10; ++sectionIndex) {
+	for (int sectionIndex = -1; sectionIndex < 11; ++sectionIndex) {
 		if (sectionIndex == 0)
 			continue;
 
@@ -167,6 +167,13 @@ void HagArchive::loadIndex(MADSEngine *vm) {
 
 		Common::String filename = (sectionIndex == -1) ? "GLOBAL.HAG" :
 			Common::String::format("SECTION%d.HAG", sectionIndex);
+		if (sectionIndex == 10) {
+			// Speech
+			if (!Common::File::exists("SPEECH.HAG"))
+				break;
+			else
+				filename = "SPEECH.HAG";
+		}
 		if (!hagFile.open(filename))
 			error("Could not locate HAG file - %s", filename.c_str());
 


Commit: 8a08a19097b4338c73dc9456622b75233b9b0194
    https://github.com/scummvm/scummvm/commit/8a08a19097b4338c73dc9456622b75233b9b0194
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-20T08:37:42-04:00

Commit Message:
Merge branch 'master' into mads

Changed paths:
  A backends/platform/ps2/Makefile.ps2.dev
  A backends/platform/ps2/README.PS2
  A devtools/create_kyradat/resources.cpp
  A devtools/create_kyradat/resources.h
  A devtools/create_kyradat/resources/eob1_dos.h
  A devtools/create_kyradat/resources/eob1_dos_english.h
  A devtools/create_kyradat/resources/eob1_dos_german.h
  A devtools/create_kyradat/resources/eob2_dos.h
  A devtools/create_kyradat/resources/eob2_dos_english.h
  A devtools/create_kyradat/resources/eob2_dos_german.h
  A devtools/create_kyradat/resources/hof_dos.h
  A devtools/create_kyradat/resources/hof_dos_cd.h
  A devtools/create_kyradat/resources/hof_dos_cd_english.h
  A devtools/create_kyradat/resources/hof_dos_cd_french.h
  A devtools/create_kyradat/resources/hof_dos_cd_german.h
  A devtools/create_kyradat/resources/hof_dos_cd_italian.h
  A devtools/create_kyradat/resources/hof_dos_cd_russian.h
  A devtools/create_kyradat/resources/hof_dos_cddemo.h
  A devtools/create_kyradat/resources/hof_dos_cddemo_english.h
  A devtools/create_kyradat/resources/hof_dos_cddemo_french.h
  A devtools/create_kyradat/resources/hof_dos_cddemo_german.h
  A devtools/create_kyradat/resources/hof_dos_demo.h
  A devtools/create_kyradat/resources/hof_dos_english.h
  A devtools/create_kyradat/resources/hof_dos_french.h
  A devtools/create_kyradat/resources/hof_dos_german.h
  A devtools/create_kyradat/resources/hof_dos_italian.h
  A devtools/create_kyradat/resources/hof_dos_russian.h
  A devtools/create_kyradat/resources/hof_fmtowns.h
  A devtools/create_kyradat/resources/hof_fmtowns_english.h
  A devtools/create_kyradat/resources/hof_fmtowns_japanese.h
  A devtools/create_kyradat/resources/hof_pc98.h
  A devtools/create_kyradat/resources/hof_pc98_english.h
  A devtools/create_kyradat/resources/hof_pc98_japanese.h
  A devtools/create_kyradat/resources/lok_amiga.h
  A devtools/create_kyradat/resources/lok_amiga_english.h
  A devtools/create_kyradat/resources/lok_amiga_german.h
  A devtools/create_kyradat/resources/lok_dos.h
  A devtools/create_kyradat/resources/lok_dos_cd.h
  A devtools/create_kyradat/resources/lok_dos_cd_english.h
  A devtools/create_kyradat/resources/lok_dos_cd_french.h
  A devtools/create_kyradat/resources/lok_dos_cd_german.h
  R backends/platform/ps2/Makefile.gdb
  R devtools/create_kyradat/extract.cpp
  R devtools/create_kyradat/extract.h
  R devtools/create_kyradat/tables.h
    .gitignore
    Makefile.common
    NEWS
    audio/decoders/quicktime.cpp
    audio/mixer.cpp
    audio/rate_arm_asm.s
    backends/fs/ps2/ps2-fs.cpp
    backends/fs/ps2/ps2-fs.h
    backends/midi/camd.cpp
    backends/platform/android/gfx.cpp
    backends/platform/ps2/DmaPipe.cpp
    backends/platform/ps2/Gs2dScreen.cpp
    backends/platform/ps2/Gs2dScreen.h
    backends/platform/ps2/GsDefs.h
    backends/platform/ps2/Makefile.ps2
    backends/platform/ps2/asyncfio.cpp
    backends/platform/ps2/asyncfio.h
    backends/platform/ps2/cd.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/rpcfs.c
    backends/platform/ps2/iop/rpckbd/include/ps2kbd.h
    backends/platform/ps2/iop/rpckbd/src/ps2kbd.c
    backends/platform/ps2/irxboot.cpp
    backends/platform/ps2/irxboot.h
    backends/platform/ps2/module.mk
    backends/platform/ps2/ps2debug.cpp
    backends/platform/ps2/ps2debug.h
    backends/platform/ps2/ps2input.cpp
    backends/platform/ps2/ps2input.h
    backends/platform/ps2/ps2pad.cpp
    backends/platform/ps2/ps2time.cpp
    backends/platform/ps2/rpckbd.c
    backends/platform/ps2/savefilemgr.cpp
    backends/platform/ps2/sysdefs.h
    backends/platform/ps2/systemps2.cpp
    backends/platform/ps2/systemps2.h
    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/S60v3/scummvm-CVS-SymbianS60v3_split.pkg
    backends/platform/symbian/help/ScummVM.rtf
    backends/platform/symbian/mmp/scummvm_agi.mmp.in
    backends/platform/symbian/mmp/scummvm_agos.mmp.in
    backends/platform/symbian/mmp/scummvm_avalanche.mmp.in
    backends/platform/symbian/mmp/scummvm_base.mmp.in
    backends/platform/symbian/mmp/scummvm_cge.mmp.in
    backends/platform/symbian/mmp/scummvm_cine.mmp.in
    backends/platform/symbian/mmp/scummvm_composer.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_dreamweb.mmp.in
    backends/platform/symbian/mmp/scummvm_fullpipe.mmp.in
    backends/platform/symbian/mmp/scummvm_gob.mmp.in
    backends/platform/symbian/mmp/scummvm_groovie.mmp.in
    backends/platform/symbian/mmp/scummvm_hopkins.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_mortevielle.mmp.in
    backends/platform/symbian/mmp/scummvm_neverhood.mmp.in
    backends/platform/symbian/mmp/scummvm_parallaction.mmp.in
    backends/platform/symbian/mmp/scummvm_pegasus.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_sword25.mmp.in
    backends/platform/symbian/mmp/scummvm_teenagent.mmp.in
    backends/platform/symbian/mmp/scummvm_testbed.mmp.in
    backends/platform/symbian/mmp/scummvm_tinsel.mmp.in
    backends/platform/symbian/mmp/scummvm_toltecs.mmp.in
    backends/platform/symbian/mmp/scummvm_tony.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/mmp/scummvm_wintermute.mmp.in
    backends/platform/symbian/mmp/scummvm_zvision.mmp.in
    backends/platform/tizen/system.cpp
    backends/platform/tizen/system.h
    backends/platform/wii/osystem_gfx.cpp
    backends/plugins/elf/version.cpp
    base/version.cpp
    common/EventMapper.cpp
    common/quicktime.cpp
    common/quicktime.h
    common/scummsys.h
    common/zlib.cpp
    configure
    devtools/create_kyradat/create_kyradat.cpp
    devtools/create_kyradat/create_kyradat.h
    devtools/create_kyradat/games.cpp
    devtools/create_kyradat/module.mk





Commit: 6804c085461fdaddf58e7885ed83b70662afbfae
    https://github.com/scummvm/scummvm/commit/6804c085461fdaddf58e7885ed83b70662afbfae
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-20T17:30:41+02:00

Commit Message:
MADS: Fix compilation warning reported by digitall

Changed paths:
    engines/mads/nebular/nebular_scenes3.cpp



diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 4cf1a2d..9237c62 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -2697,7 +2697,7 @@ void Scene318::step() {
 	}
 
 	uint32 tmpFrame = _vm->_events->getFrameCounter();
-	uint32 diffFrame = tmpFrame - _lastFrameCounter;
+	long diffFrame = tmpFrame - _lastFrameCounter;
 	_lastFrameCounter = tmpFrame;
 
 	if ((_animMode == 2) && !_internVisibleFl && _game._player._stepEnabled) {


Commit: c494781645bcdadce84052798f6194eaaefc728c
    https://github.com/scummvm/scummvm/commit/c494781645bcdadce84052798f6194eaaefc728c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-20T19:48:08+02:00

Commit Message:
MADS: Add synchronize where useful in scene group 5

Changed paths:
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes5.h



diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index 1ad29a3..cc8cdbd 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -530,6 +530,12 @@ void Scene503::setup() {
 	_scene->addActiveVocab(VERB_WALKTO);
 }
 
+void Scene503::synchronize(Common::Serializer &s) {
+	Scene5xx::synchronize(s);
+
+	s.syncAsSint16LE(_detonatorHotspotId);
+}
+
 void Scene503::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', -1));
 
@@ -650,6 +656,13 @@ void Scene504::setup() {
 	setAAName();
 }
 
+void Scene504::synchronize(Common::Serializer &s) {
+	Scene5xx::synchronize(s);
+
+	s.syncAsSint16LE(_carAnimationMode);
+	s.syncAsSint16LE(_carFrame);
+}
+
 void Scene504::enter() {
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 2));
 
@@ -847,6 +860,19 @@ void Scene505::setup() {
 	setAAName();
 }
 
+void Scene505::synchronize(Common::Serializer &s) {
+	Scene5xx::synchronize(s);
+
+	s.syncAsSint16LE(_frame);
+	s.syncAsSint16LE(_nextButtonId);
+	s.syncAsSint16LE(_homeSelectedId);
+	s.syncAsSint16LE(_selectedId);
+	s.syncAsSint16LE(_activeCars);
+
+	for (int i = 0; i < 9; i++)
+		s.syncAsSint16LE(_carLocations[i]);
+}
+
 void Scene505::enter() {
 	for (int i = 0; i < 9; i++)
 		_globals._spriteIndexes[i] = _scene->_sprites.addSprites(formAnimName('a', i + 1));
@@ -1104,6 +1130,24 @@ void Scene506::setup() {
 	_scene->addActiveVocab(NOUN_LABORATORY);
 }
 
+void Scene506::synchronize(Common::Serializer &s) {
+	Scene5xx::synchronize(s);
+
+	s.syncAsSint16LE(_doorPos.x);
+	s.syncAsSint16LE(_doorPos.y);
+
+	s.syncAsByte(_heroFacing);
+
+	s.syncAsSint16LE(_doorDepth);
+	s.syncAsSint16LE(_doorSpriteIdx);
+	s.syncAsSint16LE(_doorSequenceIdx);
+	s.syncAsSint16LE(_doorWord);
+
+	s.syncAsByte(_labDoorFl);
+	s.syncAsByte(_firstDoorFl);
+	s.syncAsByte(_actionFl);
+}
+
 void Scene506::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('q', 0));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('q', 1));
@@ -1161,7 +1205,7 @@ void Scene506::step() {
 				_doorWord = 0x37D;
 			}
 		}
-		room_506_door_sequences();
+		handleDoorSequences();
 	}
 
 	if (_game._trigger >= 70) {
@@ -1191,7 +1235,7 @@ void Scene506::step() {
 	}
 }
 
-void Scene506::room_506_door_sequences() {
+void Scene506::handleDoorSequences() {
 	_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
 
 	if (_firstDoorFl) {
@@ -1281,14 +1325,14 @@ void Scene506::actions() {
 			_doorPos = Common::Point(16, 111);
 		}
 		_actionFl = true;
-		room_506_door_sequences();
+		handleDoorSequences();
 	} else if (_action.isAction(VERB_WALK_INTO, NOUN_SOFTWARE_STORE)) {
 		if (_firstDoorFl) {
 			_heroFacing = FACING_NORTHWEST;
 			_doorPos = Common::Point(80, 102);
 		}
 		_actionFl = true;
-		room_506_door_sequences();
+		handleDoorSequences();
 	} else if (_action.isAction(VERB_GET_INTO, NOUN_CAR)) {
 		switch (_game._trigger) {
 		case 0:
@@ -1365,6 +1409,12 @@ void Scene507::setup() {
 	_scene->addActiveVocab(VERB_WALKTO);
 }
 
+void Scene507::synchronize(Common::Serializer &s) {
+	Scene5xx::synchronize(s);
+
+	s.syncAsSint16LE(_penlightHotspotId);
+}
+
 void Scene507::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('p', -1));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RXMRD_3");
@@ -1477,6 +1527,12 @@ void Scene508::setup() {
 	_scene->addActiveVocab(NOUN_LASER_BEAM);
 }
 
+void Scene508::synchronize(Common::Serializer &s) {
+	Scene5xx::synchronize(s);
+
+	s.syncAsSint16LE(_chosenObject);
+}
+
 void Scene508::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('a', 0));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('m', 0));
@@ -1736,6 +1792,17 @@ void Scene511::setup() {
 	_scene->addActiveVocab(VERB_WALKTO);
 }
 
+void Scene511::synchronize(Common::Serializer &s) {
+	Scene5xx::synchronize(s);
+
+	s.syncAsByte(_handingLine);
+	s.syncAsByte(_lineMoving);
+
+	s.syncAsSint16LE(_lineAnimationMode);
+	s.syncAsSint16LE(_lineFrame);
+	s.syncAsSint16LE(_lineAnimationPosition);
+}
+
 void Scene511::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', 0));
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXCD_6");
@@ -2058,6 +2125,13 @@ void Scene512::setup() {
 	_scene->addActiveVocab(NOUN_REGISTER_DRAWER);
 }
 
+void Scene512::synchronize(Common::Serializer &s) {
+	Scene5xx::synchronize(s);
+
+	s.syncAsSint16LE(_fishingRodHotspotId);
+	s.syncAsSint16LE(_keyHotspotId);
+}
+
 void Scene512::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('r', -1));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RXMRC_9");
diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
index c49532d..7c21fba 100644
--- a/engines/mads/nebular/nebular_scenes5.h
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -86,6 +86,7 @@ private:
 
 public:
 	Scene503(MADSEngine *vm) : Scene5xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -99,6 +100,7 @@ private:
 
 public:
 	Scene504(MADSEngine *vm) : Scene5xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -119,6 +121,7 @@ private:
 
 public:
 	Scene505(MADSEngine *vm) : Scene5xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -128,8 +131,6 @@ public:
 
 class Scene506: public Scene5xx{
 private:
-	int _actionFl;             /* Flag to note daemon is running vs. parser */   
-
 	Common::Point _doorPos;
 	Facing _heroFacing;
 
@@ -140,11 +141,13 @@ private:
 
 	bool _labDoorFl;
 	bool _firstDoorFl;
+	bool _actionFl;
 
-	void room_506_door_sequences();
+	void handleDoorSequences();
 
 public:
 	Scene506(MADSEngine *vm) : Scene5xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -158,6 +161,7 @@ private:
 
 public:
 	Scene507(MADSEngine *vm) : Scene5xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -172,6 +176,7 @@ private:
 
 public:
 	Scene508(MADSEngine *vm) : Scene5xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -190,6 +195,7 @@ private:
 
 public:
 	Scene511(MADSEngine *vm) : Scene5xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -205,6 +211,7 @@ private:
 
 public:
 	Scene512(MADSEngine *vm) : Scene5xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();


Commit: 39068bb1eded8e4933701534eb19d559d45c63fd
    https://github.com/scummvm/scummvm/commit/39068bb1eded8e4933701534eb19d559d45c63fd
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-20T22:46:09+02:00

Commit Message:
MADS: Add synchronize where useful in scene group 6

Changed paths:
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes6.h



diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index 53e187a..6f802b2 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -225,6 +225,15 @@ void Scene602::setup() {
 	_scene->addActiveVocab(NOUN_LASER_BEAM);
 }
 
+void Scene602::synchronize(Common::Serializer &s) {
+	Scene6xx::synchronize(s);
+
+	s.syncAsSint16LE(_lastSpriteIdx);
+	s.syncAsSint16LE(_lastSequenceIdx);
+	s.syncAsSint16LE(_cycleIndex);
+	s.syncAsSint16LE(_safeMode);
+}
+
 void Scene602::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('h', -1));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 0));
@@ -538,6 +547,13 @@ void Scene603::setup() {
 	_scene->addActiveVocab(NOUN_NOTE);
 }
 
+void Scene603::synchronize(Common::Serializer &s) {
+	Scene6xx::synchronize(s);
+
+	s.syncAsSint16LE(_compactCaseHotspotId);
+	s.syncAsSint16LE(_noteHotspotId);
+}
+
 void Scene603::enter() {
 	if (_game._objects[OBJ_COMPACT_CASE]._roomNumber == _scene->_currentSceneId) {
 		_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXMRD_3");
@@ -680,6 +696,19 @@ void Scene604::setup() {
 	_scene->addActiveVocab(NOUN_TIMEBOMB);
 }
 
+void Scene604::synchronize(Common::Serializer &s) {
+	Scene6xx::synchronize(s);
+
+	s.syncAsSint16LE(_timebombHotspotId);
+	s.syncAsSint16LE(_bombMode);
+	s.syncAsSint16LE(_monsterFrame);
+
+	s.syncAsUint32LE(_monsterTimer);
+
+	s.syncAsByte(_monsterActive);
+	s.syncAsByte(_animationActiveFl);
+}
+
 void Scene604::enter() {
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('c', 0));
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXCD_9");
@@ -992,6 +1021,22 @@ void Scene607::setup() {
 	_scene->addActiveVocab(VERB_WALKTO);
 }
 
+void Scene607::synchronize(Common::Serializer &s) {
+	Scene6xx::synchronize(s);
+
+	s.syncAsUint32LE(_dogTimer);
+	s.syncAsUint32LE(_lastFrameTime);
+
+	s.syncAsByte(_dogLoop);
+	s.syncAsByte(_dogEatsRex);
+	s.syncAsByte(_dogBarking);
+	s.syncAsByte(_shopAvailable);
+
+	s.syncAsSint16LE(_animationMode);
+	s.syncAsSint16LE(_animationActive);
+	s.syncAsSint16LE(_counter);
+}
+
 void Scene607::enter() {
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('c', 0));
 	_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RXCD_3");
@@ -1427,6 +1472,40 @@ void Scene608::setup() {
 	_scene->addActiveVocab(NOUN_OBNOXIOUS_DOG);
 }
 
+void Scene608::synchronize(Common::Serializer &s) {
+	Scene6xx::synchronize(s);
+
+	s.syncAsSint16LE(_carMode);
+	s.syncAsSint16LE(_carFrame);
+	s.syncAsSint16LE(_carMoveMode);
+	s.syncAsSint16LE(_dogDeathMode);
+	s.syncAsSint16LE(_carHotspotId);
+	s.syncAsSint16LE(_barkCount);
+	s.syncAsSint16LE(_polycementHotspotId);
+	s.syncAsSint16LE(_animationMode);
+	s.syncAsSint16LE(_nextTrigger);
+	s.syncAsSint16LE(_throwMode);
+
+	s.syncAsByte(_resetPositionsFl);
+	s.syncAsByte(_dogActiveFl);
+	s.syncAsByte(_dogBarkingFl);
+	s.syncAsByte(_dogFirstEncounter);
+	s.syncAsByte(_rexBeingEaten);
+	s.syncAsByte(_dogHitWindow);
+	s.syncAsByte(_checkFl);
+	s.syncAsByte(_dogSquashFl);
+	s.syncAsByte(_dogSafeFl);
+	s.syncAsByte(_buttonPressedonTimeFl);
+	s.syncAsByte(_dogUnderCar);
+	s.syncAsByte(_dogYelping);
+
+	s.syncAsSint32LE(_dogWindowTimer);
+	s.syncAsSint32LE(_dogRunTimer);
+
+	s.syncAsUint32LE(_dogTimer1);
+	s.syncAsUint32LE(_dogTimer2);
+}
+
 void Scene608::resetDogVariables() {
 	_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
 	int idx = _scene->_dynamicHotspots.add(NOUN_OBNOXIOUS_DOG, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
@@ -2383,6 +2462,12 @@ void Scene609::setup() {
 	setAAName();
 }
 
+void Scene609::synchronize(Common::Serializer &s) {
+	Scene6xx::synchronize(s);
+
+	s.syncAsSint16LE(_videoDoorMode);
+}
+
 void Scene609::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', 0));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 0));
@@ -2708,6 +2793,18 @@ void Scene610::setup() {
 	_scene->addActiveVocab(VERB_WALKTO);
 }
 
+void Scene610::synchronize(Common::Serializer &s) {
+	Scene6xx::synchronize(s);
+
+	s.syncAsSint16LE(_handsetHotspotId);
+	s.syncAsSint16LE(_checkVal);
+
+	s.syncAsByte(_cellCharging);
+
+	s.syncAsSint32LE(_cellChargingTimer);
+	s.syncAsUint32LE(_lastFrameTimer);
+}
+
 void Scene610::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('p', -1));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RXMRC_9");
@@ -2891,6 +2988,39 @@ void Scene611::setup() {
 	_scene->addActiveVocab(VERB_WALKTO);
 }
 
+void Scene611::synchronize(Common::Serializer &s) {
+	Scene6xx::synchronize(s);
+
+	s.syncAsByte(_seenRatFl);
+	s.syncAsByte(_eyesRunningFl);
+	s.syncAsByte(_shouldRemoveEyes);
+	s.syncAsByte(_ratPresentFl);
+	s.syncAsByte(_duringDialogFl);
+	s.syncAsByte(_resetBatterieText);
+	s.syncAsByte(_hermitTalkingFl);
+	s.syncAsByte(_hermitMovingFl);
+	s.syncAsByte(_alreadyTalkingFl);
+	s.syncAsByte(_giveBatteriesFl);
+	s.syncAsByte(_startTradingFl);
+	s.syncAsByte(_check1Fl);
+	s.syncAsByte(_stickFingerFl);
+
+	s.syncAsSint16LE(_randVal);
+	s.syncAsSint16LE(_ratHotspotId);
+	s.syncAsSint16LE(_hermitDialogNode);
+	s.syncAsSint16LE(_hermitDisplayedQuestion);
+	s.syncAsSint16LE(_nextFrame);
+	s.syncAsSint16LE(_hermitMode);
+
+	s.syncAsUint32LE(_ratTimer);
+
+	s.syncAsSint16LE(_defaultDialogPos.x);
+	s.syncAsSint16LE(_defaultDialogPos.y);
+
+	_dialog1.synchronize(s);
+	_dialog2.synchronize(s);
+}
+
 void Scene611::handleRatMoves() {
 	_ratPresentFl = false;
 	_scene->_sequences.remove(_globals._sequenceIndexes[1]);
@@ -4266,6 +4396,13 @@ void Scene612::setup() {
 	_scene->addActiveVocab(VERB_WALKTO);
 }
 
+void Scene612::synchronize(Common::Serializer &s) {
+	Scene6xx::synchronize(s);
+
+	s.syncAsSint16LE(_actionMode);
+	s.syncAsSint16LE(_cycleIndex);
+}
+
 void Scene612::handleWinchMovement() {
 	switch (_game._trigger) {
 	case 0:
@@ -4281,7 +4418,7 @@ void Scene612::handleWinchMovement() {
 	case 1:
 		// CHECKME: Is the "else" block useful as action is always equal to 1 at this point?
 		// Or is it a missing bit of code we could fix?
-		if (action == 1) {
+		if (_actionMode == 1) {
 			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 17, 7, 0, 0);
 			_vm->_sound->command(19);
@@ -4426,7 +4563,7 @@ void Scene612::actions() {
 		}
 	} else if (_action.isAction(VERB_UNLOCK, 0xFF, 0x45F)) {
 		_cycleIndex = -2;
-		action = 1;
+		_actionMode = 1;
 		handleWinchMovement();
 	} else if (_action._lookFlag || _action.isAction(VERB_LOOK, NOUN_EXPRESSWAY))
 		_vm->_dialogs->show(61210);
diff --git a/engines/mads/nebular/nebular_scenes6.h b/engines/mads/nebular/nebular_scenes6.h
index 731b220..680d006 100644
--- a/engines/mads/nebular/nebular_scenes6.h
+++ b/engines/mads/nebular/nebular_scenes6.h
@@ -71,6 +71,7 @@ private:
 
 public:
 	Scene602(MADSEngine *vm) : Scene6xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -84,6 +85,7 @@ private:
 
 public:
 	Scene603(MADSEngine *vm) : Scene6xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -105,6 +107,7 @@ private:
 
 public:
 	Scene604(MADSEngine *vm) : Scene6xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -140,6 +143,7 @@ private:
 
 public:
 	Scene607(MADSEngine *vm) : Scene6xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -187,6 +191,7 @@ private:
 
 public:
 	Scene608(MADSEngine *vm) : Scene6xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -203,6 +208,7 @@ private:
 
 public:
 	Scene609(MADSEngine *vm) : Scene6xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -223,6 +229,7 @@ private:
 
 public:
 	Scene610(MADSEngine *vm) : Scene6xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -274,6 +281,7 @@ private:
 
 public:
 	Scene611(MADSEngine *vm) : Scene6xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -284,13 +292,14 @@ public:
 
 class Scene612: public Scene6xx{
 private:
-	int action;
+	int _actionMode;
 	int _cycleIndex;
 
 	void handleWinchMovement();
 
 public:
 	Scene612(MADSEngine *vm) : Scene6xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();


Commit: 6f66459f4ab89aeb152d7b13b4289ab7ba8cfca4
    https://github.com/scummvm/scummvm/commit/6f66459f4ab89aeb152d7b13b4289ab7ba8cfca4
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-21T00:04:38+02:00

Commit Message:
MADS: Add synchronize where useful in scene group 7

Changed paths:
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes7.h



diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 541e22e..b769939 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -99,6 +99,12 @@ void Scene701::setup() {
 	_scene->addActiveVocab(VERB_WALKTO);
 }
 
+void Scene701::synchronize(Common::Serializer &s) {
+	Scene7xx::synchronize(s);
+
+	s.syncAsSint16LE(_fishingLineId);
+}
+
 void Scene701::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('b', 5));
@@ -549,6 +555,25 @@ void Scene703::setup() {
 	setAAName();
 }
 
+void Scene703::synchronize(Common::Serializer &s) {
+	Scene7xx::synchronize(s);
+
+	s.syncAsSint16LE(_monsterMode);
+	s.syncAsSint16LE(_boatFrame);
+	s.syncAsSint16LE(_curSequence);
+	s.syncAsSint16LE(_boatDir);
+
+	s.syncAsByte(_useBomb);
+	s.syncAsByte(_startMonsterTimer);
+	s.syncAsByte(_rexDeathFl);
+	s.syncAsByte(_restartTrigger70Fl);
+
+	s.syncAsUint32LE(_lastFrameTime);
+	s.syncAsUint32LE(_monsterTime);
+
+	_dialog1.synchronize(s);
+}
+
 void Scene703::handleBottleInterface() {
 	switch (_globals[kBottleStatus]) {
 	case 0:
@@ -1077,6 +1102,19 @@ void Scene704::setup() {
 	_scene->addActiveVocab(VERB_LOOK_AT);
 }
 
+void Scene704::synchronize(Common::Serializer &s) {
+	Scene7xx::synchronize(s);
+
+	s.syncAsSint16LE(_bottleHotspotId);
+	s.syncAsSint16LE(_boatCurrentFrame);
+	s.syncAsSint16LE(_animationMode);
+	s.syncAsSint16LE(_boatDirection);
+
+	s.syncAsByte(_takeBottleFl);
+
+	_dialog1.synchronize(s);
+}
+
 void Scene704::handleBottleInterface() {
 	switch (_globals[kBottleStatus]) {
 	case 0:
@@ -1414,6 +1452,12 @@ void Scene705::setup() {
 	setAAName();
 }
 
+void Scene705::synchronize(Common::Serializer &s) {
+	Scene7xx::synchronize(s);
+
+	_dialog1.synchronize(s);
+}
+
 void Scene705::handleBottleInterface() {
 	switch (_globals[kBottleStatus]) {
 	case 0:
@@ -1681,6 +1725,17 @@ void Scene706::setup() {
 	_scene->addActiveVocab(VERB_WALKTO);
 }
 
+void Scene706::synchronize(Common::Serializer &s) {
+	Scene7xx::synchronize(s);
+
+	s.syncAsSint16LE(_vaseHotspotId);
+	s.syncAsSint16LE(_vaseMode);
+	s.syncAsSint16LE(_animationMode);
+	s.syncAsSint16LE(_animationFrame);
+
+	s.syncAsByte(_emptyPedestral);
+}
+
 void Scene706::handleRexDeath() {
 	switch (_game._trigger) {
 	case 0:
@@ -2089,6 +2144,12 @@ void Scene751::setup() {
 	_scene->addActiveVocab(VERB_WALKTO);
 }
 
+void Scene751::synchronize(Common::Serializer &s) {
+	Scene7xx::synchronize(s);
+
+	s.syncAsByte(_rexHandingLine);
+}
+
 void Scene751::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites("*RM701X0");
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 0));
@@ -2417,6 +2478,12 @@ void Scene752::setup() {
 	_scene->addActiveVocab(NOUN_LASER_BEAM);
 }
 
+void Scene752::synchronize(Common::Serializer &s) {
+	Scene7xx::synchronize(s);
+
+	s.syncAsByte(_cardId);
+}
+
 void Scene752::enter() {
 	_globals._spriteIndexes[14] = _scene->_sprites.addSprites(formAnimName('l', -1));
 	_globals._spriteIndexes[12] = _scene->_sprites.addSprites("*RXMBD_8");
diff --git a/engines/mads/nebular/nebular_scenes7.h b/engines/mads/nebular/nebular_scenes7.h
index 0223fe2..150c598 100644
--- a/engines/mads/nebular/nebular_scenes7.h
+++ b/engines/mads/nebular/nebular_scenes7.h
@@ -56,6 +56,7 @@ private:
 
 public:
 	Scene701(MADSEngine *vm) : Scene7xx(vm), _fishingLineId(-1) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -97,6 +98,7 @@ private:
 
 public:
 	Scene703(MADSEngine *vm) : Scene7xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -121,6 +123,7 @@ private:
 
 public:
 	Scene704(MADSEngine *vm) : Scene7xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -138,6 +141,7 @@ private:
 
 public:
 	Scene705(MADSEngine *vm) : Scene7xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -159,6 +163,7 @@ private:
 
 public:
 	Scene706(MADSEngine *vm) : Scene7xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -203,6 +208,7 @@ private:
 
 public:
 	Scene751(MADSEngine *vm) : Scene7xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -217,6 +223,7 @@ private:
 
 public:
 	Scene752(MADSEngine *vm) : Scene7xx(vm), _cardId(-1) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();


Commit: df23dff5177ece670f2fd8222337faa80baf12bd
    https://github.com/scummvm/scummvm/commit/df23dff5177ece670f2fd8222337faa80baf12bd
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-20T21:11:53-04:00

Commit Message:
MADS: Change the animation _animMode to an enum'ed _bgType

Changed paths:
    engines/mads/animation.cpp
    engines/mads/animation.h



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index f006d1f..f55e485 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -36,7 +36,7 @@ void AAHeader::load(Common::SeekableReadStream *f) {
 	_flags = f->readByte();
 
 	f->skip(2);
-	_animMode = f->readUint16LE();
+	_bgType = (AnimBgType)f->readUint16LE();
 	_roomNumber = f->readUint16LE();
 	f->skip(2);
 	_manualFlag = f->readUint16LE() != 0;
@@ -186,7 +186,7 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
 	_header.load(stream);
 	delete stream;
 
-	if (_header._animMode == 4)
+	if (_header._bgType == ANIMBG_INTERFACE)
 		flags |= PALFLAG_RESERVED;
 
 	if (flags & ANIMFLAG_LOAD_BACKGROUND) {
@@ -296,7 +296,7 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
 	if (usageList.size() > 0)
 		_vm->_palette->_paletteUsage.updateUsage(usageList, _header._messagesCount);
 
-	if (_header._animMode == 4) {
+	if (_header._bgType == ANIMBG_INTERFACE) {
 		// Remaps the sprite list indexes for frames to the loaded sprite list indexes
 		for (uint i = 0; i < _frameEntries.size(); ++i) {
 			int spriteListIndex = _frameEntries[i]._spriteSlot._spritesIndex;
@@ -377,7 +377,7 @@ bool Animation::drawFrame(SpriteAsset &spriteSet, const Common::Point &pt, int f
 void Animation::loadInterface(UserInterface &interfaceSurface, MSurface &depthSurface,
 		AAHeader &header, int flags, Common::Array<PaletteCycle> *palCycles, SceneInfo *sceneInfo) {
 	_scene->_depthStyle = 0;
-	if (header._animMode <= 2) {
+	if (header._bgType <= ANIMBG_FULL_SIZE) {
 		_vm->_palette->_paletteUsage.setEmpty();
 		sceneInfo->load(header._roomNumber, flags, header._interfaceFile, 0, depthSurface, interfaceSurface);
 		_scene->_depthStyle = sceneInfo->_depthStyle == 2 ? 1 : 0;
@@ -386,7 +386,7 @@ void Animation::loadInterface(UserInterface &interfaceSurface, MSurface &depthSu
 			for (uint i = 0; i < sceneInfo->_paletteCycles.size(); ++i)
 				palCycles->push_back(sceneInfo->_paletteCycles[i]);
 		}
-	} else if (header._animMode == 4) {
+	} else if (header._bgType == ANIMBG_INTERFACE) {
 		// Load a scene interface
 		Common::String resourceName = "*" + header._interfaceFile;
 		interfaceSurface.load(resourceName);
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index a1d957e..715f6e4 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -40,6 +40,11 @@ enum AnimFlag {
 	ANIMFLAG_LOAD_BACKGROUND_ONLY = 0x0200	// Load background only
 };
 
+enum AnimBgType {
+	ANIMBG_ROOM = 1, ANIMBG_FULL_SIZE = 2, ANIMBG_BLACK_SCREEN = 3,
+	ANIMBG_INTERFACE = 4
+};
+
 class MADSEngine;
 class Scene;
 
@@ -112,7 +117,7 @@ public:
 	int _frameEntriesCount;
 	int _messagesCount;
 	byte _flags;
-	int _animMode;
+	AnimBgType _bgType;
 	int _roomNumber;
 	bool _manualFlag;
 	int _spritesIndex;
@@ -215,7 +220,6 @@ public:
 	int getCurrentFrame() const { return _currentFrame; }
 
 	bool freeFlag() const { return _freeFlag; }
-	bool getAnimMode() const { return _header._animMode; }
 	int roomNumber() const { return _header._roomNumber; }
 
 	void resetSpriteSetsCount() { _header._spriteSetsCount = 0; } // CHECKME: See if it doesn't leak the memory when the destructor is called


Commit: 6bfc9ce8f25d5d08e3a0aa1d5fa55e3dfe93b97f
    https://github.com/scummvm/scummvm/commit/6bfc9ce8f25d5d08e3a0aa1d5fa55e3dfe93b97f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-20T21:22:01-04:00

Commit Message:
MADS: Completely remove synchronizeString in favour of syncString

Changed paths:
    engines/mads/action.cpp
    engines/mads/game.cpp
    engines/mads/player.cpp
    engines/mads/resources.cpp
    engines/mads/resources.h



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index f26a999..df9da12 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -678,7 +678,7 @@ void MADSAction::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_statusTextIndex);
 	s.syncAsSint16LE(_hotspotId);
 	_savedFields.synchronize(s);
-	synchronizeString(s, _sentence);
+	s.syncString(_sentence);
 
 	s.syncAsSint16LE(_verbType);
 	s.syncAsSint16LE(_prepType);
diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index 118dc82..f8d6c36 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -457,7 +457,7 @@ void Game::synchronize(Common::Serializer &s, bool phase1) {
 		s.syncAsSint16LE(_trigger);
 		s.syncAsUint16LE(_triggerSetupMode);
 		s.syncAsUint16LE(_triggerMode);
-		synchronizeString(s, _aaName);
+		s.syncString(_aaName);
 		s.syncAsSint16LE(_lastSave);
 
 		_scene.synchronize(s);
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index 3672c80..a9c9f11 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -755,7 +755,7 @@ void Player::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_totalDistance);
 	s.syncAsSint16LE(_velocity);
 	s.syncAsUint16LE(_frameCount);
-	synchronizeString(s, _spritesPrefix);
+	s.syncString(_spritesPrefix);
 	s.syncAsUint32LE(_priorTimer);
 	s.syncAsByte(_loadsFirst);
 	s.syncAsByte(_loadedFirst);
diff --git a/engines/mads/resources.cpp b/engines/mads/resources.cpp
index 0d5aee1..745583b 100644
--- a/engines/mads/resources.cpp
+++ b/engines/mads/resources.cpp
@@ -413,23 +413,4 @@ void SynchronizedList::synchronize(Common::Serializer &s) {
 	}
 }
 
-/*------------------------------------------------------------------------*/
-
-void synchronizeString(Common::Serializer &s, Common::String &str) {
-	int len = str.size();
-	s.syncAsUint16LE(len);
-
-	if (s.isSaving()) {
-		s.syncBytes((byte *)str.c_str(), len);
-	} else {
-		str.clear();
-		char c;
-		for (int i = 0; i < len; ++i) {
-			s.syncAsByte(c);
-			str += c;
-		}
-	}
-}
-
-
 } // End of namespace MADS
diff --git a/engines/mads/resources.h b/engines/mads/resources.h
index 137eb7a..003684e 100644
--- a/engines/mads/resources.h
+++ b/engines/mads/resources.h
@@ -84,11 +84,6 @@ public:
 	void synchronize(Common::Serializer &s);
 };
 
-/**
-* Synchronize string support method
-*/
-void synchronizeString(Common::Serializer &s, Common::String &str);
-
 } // End of namespace MADS
 
 #endif /* MADS_RESOURCES_H */


Commit: 876ef49a3a7596ff2d26195923d43b1a886ca065
    https://github.com/scummvm/scummvm/commit/876ef49a3a7596ff2d26195923d43b1a886ca065
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-20T22:07:53-04:00

Commit Message:
MADS: Fix loading sprite in scene 701

Changed paths:
    engines/mads/compression.cpp
    engines/mads/compression.h
    engines/mads/nebular/nebular_scenes7.cpp



diff --git a/engines/mads/compression.cpp b/engines/mads/compression.cpp
index 6563de5..de893e7 100644
--- a/engines/mads/compression.cpp
+++ b/engines/mads/compression.cpp
@@ -69,18 +69,20 @@ void MadsPack::initialise(Common::SeekableReadStream *stream) {
 		_items[i].size = READ_LE_UINT32(header + 2);
 		_items[i].compressedSize = READ_LE_UINT32(header + 6);
 
-		_items[i].data = new byte[_items[i].size];
-		if (_items[i].size == _items[i].compressedSize) {
+		byte *sourceData = new byte[_items[i].compressedSize];
+		stream->read(sourceData, _items[i].compressedSize);
+
+		if (_items[i].size == _items[i].compressedSize &&
+				!FabDecompressor::isCompressed(sourceData)) {
 			// Entry isn't compressed
-			stream->read(_items[i].data, _items[i].size);
+			_items[i].data = sourceData;
 		} else {
 			// Decompress the entry
-			byte *compressedData = new byte[_items[i].compressedSize];
-			stream->read(compressedData, _items[i].compressedSize);
+			_items[i].data = new byte[_items[i].size];
 
 			FabDecompressor fab;
-			fab.decompress(compressedData, _items[i].compressedSize, _items[i].data, _items[i].size);
-			delete[] compressedData;
+			fab.decompress(sourceData, _items[i].compressedSize, _items[i].data, _items[i].size);
+			delete[] sourceData;
 		}
 	}
 
@@ -96,6 +98,10 @@ MadsPack::~MadsPack() {
 
 //--------------------------------------------------------------------------
 
+bool FabDecompressor::isCompressed(const byte *srcData) {
+	return strncmp((const char *)srcData, "FAB", 3) == 0;
+}
+
 void FabDecompressor::decompress(const byte *srcData, int srcSize, byte *destData, int destSize) {
 	byte copyLen, copyOfsShift, copyOfsMask, copyLenMask;
 	unsigned long copyOfs;
diff --git a/engines/mads/compression.h b/engines/mads/compression.h
index c752b57..43a966f 100644
--- a/engines/mads/compression.h
+++ b/engines/mads/compression.h
@@ -79,6 +79,8 @@ private:
 	int getBit();
 public:
 	void decompress(const byte *srcData, int srcSize, byte *destData, int destSize);
+
+	static bool isCompressed(const byte *srcData);
 };
 
 } // End of namespace MADS
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index b769939..8e04c45 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -109,7 +109,7 @@ void Scene701::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('b', 5));
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('b', 0));
-//	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('b', 1));	// TODO: FIXME: Broken sprite?
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('b', 1));	// TODO: FIXME: Broken sprite?
 	_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RM202A1");
 	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('b', 8));
 
@@ -162,15 +162,12 @@ void Scene701::enter() {
 		break;
 	}
 
-// TODO: Enable once sprite 3 can be loaded properly
-/*
 	if (_globals[kLineStatus] == LINE_DROPPED || _globals[kLineStatus] == LINE_TIED) {
 		_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, -1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 8);
 		int idx = _scene->_dynamicHotspots.add(NOUN_FISHING_LINE, VERB_WALKTO, _globals._sequenceIndexes[3], Common::Rect(0, 0, 0, 0));
 		_fishingLineId = _scene->_dynamicHotspots.setPosition(idx, Common::Point(234, 129), FACING_NORTHEAST);
 	}
-*/
 
 	if (_scene->_priorSceneId == 702) {
 		_game._player._playerPos = Common::Point(309, 138);


Commit: 17012de54b900400548d598fe051343924838565
    https://github.com/scummvm/scummvm/commit/17012de54b900400548d598fe051343924838565
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-20T22:34:26-04:00

Commit Message:
MADS: Remove redundant frame entry remap block in animation loading

Changed paths:
    engines/mads/animation.cpp



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index f55e485..25fa4a8 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -296,18 +296,10 @@ void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
 	if (usageList.size() > 0)
 		_vm->_palette->_paletteUsage.updateUsage(usageList, _header._messagesCount);
 
-	if (_header._bgType == ANIMBG_INTERFACE) {
-		// Remaps the sprite list indexes for frames to the loaded sprite list indexes
-		for (uint i = 0; i < _frameEntries.size(); ++i) {
-			int spriteListIndex = _frameEntries[i]._spriteSlot._spritesIndex;
-			_frameEntries[i]._spriteSlot._spritesIndex = _spriteListIndexes[spriteListIndex];
-		}
-	} else {
-		// Remaps the sprite list indexes for frames to the loaded sprite list indexes
-		for (uint i = 0; i < _frameEntries.size(); ++i) {
-			int spriteListIndex = _frameEntries[i]._spriteSlot._spritesIndex;
-			_frameEntries[i]._spriteSlot._spritesIndex = _spriteListIndexes[spriteListIndex];
-		}
+	// Remaps the sprite list indexes for frames to the loaded sprite list indexes
+	for (uint i = 0; i < _frameEntries.size(); ++i) {
+		int spriteListIndex = _frameEntries[i]._spriteSlot._spritesIndex;
+		_frameEntries[i]._spriteSlot._spritesIndex = _spriteListIndexes[spriteListIndex];
 	}
 
 	f.close();


Commit: 6a468994fa8243b235cfef16357a970a3c486653
    https://github.com/scummvm/scummvm/commit/6a468994fa8243b235cfef16357a970a3c486653
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-21T07:19:42+02:00

Commit Message:
MADS: Fix synchronize in scene 752

Changed paths:
    engines/mads/nebular/nebular_scenes7.cpp



diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 8e04c45..7f35117 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -2478,7 +2478,7 @@ void Scene752::setup() {
 void Scene752::synchronize(Common::Serializer &s) {
 	Scene7xx::synchronize(s);
 
-	s.syncAsByte(_cardId);
+	s.syncAsSint16LE(_cardId);
 }
 
 void Scene752::enter() {


Commit: c0b9a5a58f5c8468cdd9cc360bc8699173f0f902
    https://github.com/scummvm/scummvm/commit/c0b9a5a58f5c8468cdd9cc360bc8699173f0f902
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-21T07:21:18+02:00

Commit Message:
MADS: Remove obsolete comment

Changed paths:
    engines/mads/nebular/nebular_scenes7.cpp



diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 7f35117..895c4ec 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -109,7 +109,7 @@ void Scene701::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('b', 5));
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('b', 0));
-	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('b', 1));	// TODO: FIXME: Broken sprite?
+	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('b', 1));
 	_globals._spriteIndexes[5] = _scene->_sprites.addSprites("*RM202A1");
 	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('b', 8));
 


Commit: 057f239ed6f701da4e4a1c6a6624bc41e4d8c93c
    https://github.com/scummvm/scummvm/commit/057f239ed6f701da4e4a1c6a6624bc41e4d8c93c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-21T08:32:39-04:00

Commit Message:
MADS: Remove some redundant TODOs

Changed paths:
    engines/mads/msurface.cpp
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/palette.cpp
    engines/mads/scene.cpp
    engines/mads/user_interface.cpp
    engines/mads/user_interface.h



diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 4fae799..3ebbc6b 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -310,7 +310,7 @@ void MSurface::copyFrom(MSurface *src, const Common::Point &destPos, int depth,
 
 	int destRight = this->getWidth() - 1;
 	int destBottom = this->getHeight() - 1;
-	bool normalFrame = true;	// TODO: false for negative frame numbers
+	bool normalFrame = true;
 	int frameWidth = src->getWidth();
 	int frameHeight = src->getHeight();
 
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index b2076a2..9505521 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -1400,8 +1400,6 @@ void Scene205::synchronize(Common::Serializer &s) {
 	s.syncAsUint32LE(_chickenTime);
 	s.syncAsByte(_beingKicked);
 	s.syncAsSint16LE(_kernelMessage);
-
-	_dialog1.synchronize(s);
 }
 
 /*****************************************************************************/
@@ -4501,14 +4499,6 @@ void Scene210::synchronize(Common::Serializer &s) {
 	s.syncAsSint32LE(_doorway);
 
 	s.syncString(_subQuote2);
-
-	_conv1.synchronize(s);
-	_conv2.synchronize(s);
-	_conv3.synchronize(s);
-	_conv5.synchronize(s);
-	_conv6.synchronize(s);
-	_conv7.synchronize(s);
-	_conv8.synchronize(s);
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 9237c62..5391b5f 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -1157,9 +1157,6 @@ void Scene307::synchronize(Common::Serializer &s) {
 	s.syncAsUint32LE(_prisonerTimer);
 
 	s.syncString(_subQuote2);
-
-	_dialog1.synchronize(s);
-	_dialog2.synchronize(s);
 }
 
 /*------------------------------------------------------------------------*/
@@ -2954,8 +2951,6 @@ void Scene318::synchronize(Common::Serializer &s) {
 	s.syncAsUint32LE(_lastFrameCounter);
 
 	s.syncString(_subQuote2);
-
-	_dialog1.synchronize(s);
 }
 
 /*------------------------------------------------------------------------*/
@@ -3421,10 +3416,6 @@ void Scene319::actions() {
 void Scene319::synchronize(Common::Serializer &s) {
 	Scene3xx::synchronize(s);
 
-	_dialog1.synchronize(s);
-	_dialog2.synchronize(s);
-	_dialog3.synchronize(s);
-
 	s.syncAsUint32LE(_animMode);
 	s.syncAsUint32LE(_animFrame);
 	s.syncAsUint32LE(_nextAction1);
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index 586d59d..4156842 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -284,11 +284,6 @@ void Scene402::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_roxMode);
 	s.syncAsSint16LE(_rexMode);
 	s.syncAsSint16LE(_talkTimer);
-
-	_dialog1.synchronize(s);
-	_dialog2.synchronize(s);
-	_dialog3.synchronize(s);
-	_dialog4.synchronize(s);
 }
 
 void Scene402::setDialogNode(int node) {
@@ -3968,11 +3963,6 @@ void Scene411::synchronize(Common::Serializer &s) {
 
 	s.syncAsByte(_killRox);
 	s.syncAsByte(_makeMushroomCloud);
-
-	_dialog1.synchronize(s);
-	_dialog2.synchronize(s);
-	_dialog3.synchronize(s);
-	_dialog4.synchronize(s);
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index 6f802b2..4313366 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -3016,9 +3016,6 @@ void Scene611::synchronize(Common::Serializer &s) {
 
 	s.syncAsSint16LE(_defaultDialogPos.x);
 	s.syncAsSint16LE(_defaultDialogPos.y);
-
-	_dialog1.synchronize(s);
-	_dialog2.synchronize(s);
 }
 
 void Scene611::handleRatMoves() {
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 895c4ec..e9d8f7f 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -567,8 +567,6 @@ void Scene703::synchronize(Common::Serializer &s) {
 
 	s.syncAsUint32LE(_lastFrameTime);
 	s.syncAsUint32LE(_monsterTime);
-
-	_dialog1.synchronize(s);
 }
 
 void Scene703::handleBottleInterface() {
@@ -1108,8 +1106,6 @@ void Scene704::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_boatDirection);
 
 	s.syncAsByte(_takeBottleFl);
-
-	_dialog1.synchronize(s);
 }
 
 void Scene704::handleBottleInterface() {
@@ -1451,8 +1447,6 @@ void Scene705::setup() {
 
 void Scene705::synchronize(Common::Serializer &s) {
 	Scene7xx::synchronize(s);
-
-	_dialog1.synchronize(s);
 }
 
 void Scene705::handleBottleInterface() {
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 23e8895..c34f2c6 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -400,7 +400,6 @@ void Fader::fadeToGrey(byte palette[PALETTE_SIZE], byte *paletteMap,
 
 		setFullPalette(palette);
 
-		// TODO: Adjust waiting
 		_vm->_events->waitForNextFrame();
 	}
 
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 0c241eb..0e3960c 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -187,8 +187,6 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 
 	_vm->_game->_screenObjects._category = CAT_NONE;
 	_vm->_events->showCursor();
-
-	warning("TODO: inventory_anim_allocate");
 }
 
 void Scene::loadHotspots() {
diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 4d8ed82..3fab30a 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -838,7 +838,6 @@ void UserInterface::addConversationMessage(int vocabId, const Common::String &ms
 void UserInterface::loadInventoryAnim(int objectId) {
 	Scene &scene = _vm->_game->_scene;
 	noInventoryAnim();
-	bool flag = true;
 
 	if (_vm->_invObjectsAnimated) {
 		Common::String resName = Common::String::format("*OB%.3dI", objectId);
@@ -846,13 +845,8 @@ void UserInterface::loadInventoryAnim(int objectId) {
 		_invSpritesIndex = scene._sprites.add(asset, 1);
 		if (_invSpritesIndex >= 0) {
 			_invFrameNumber = 1;
-			flag = false;
 		}
 	}
-
-	if (flag) {
-		// TODO: Use of inv_object_data?
-	}
 }
 
 void UserInterface::noInventoryAnim() {
diff --git a/engines/mads/user_interface.h b/engines/mads/user_interface.h
index 2fdc80b..827fa30 100644
--- a/engines/mads/user_interface.h
+++ b/engines/mads/user_interface.h
@@ -128,12 +128,6 @@ public:
 	 * Starts the conversation
 	 */
 	void start();
-
-	/**
-	 * Synchronize the conversation
-	 */
-	void synchronize(Common::Serializer &s) { warning("TODO: Synchronize Conversation"); };
-
 };
 
 class UserInterface : public MSurface {


Commit: 4804be16c222e847b0f5a37d0c58cbbcede94a3f
    https://github.com/scummvm/scummvm/commit/4804be16c222e847b0f5a37d0c58cbbcede94a3f
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-21T17:27:28+02:00

Commit Message:
MADS: Add synchronize functions in scene group 8

Changed paths:
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/nebular/nebular_scenes8.h



diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index dc5a4cd..1fef270 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -83,6 +83,13 @@ void Scene801::setup() {
 	setAAName();
 }
 
+void Scene801::synchronize(Common::Serializer &s) {
+	Scene8xx::synchronize(s);
+
+	s.syncAsByte(_walkThroughDoor);
+}
+
+
 void Scene801::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 1));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 0));
@@ -829,6 +836,21 @@ void Scene804::setup() {
 	Scene8xx::setAAName();
 }
 
+void Scene804::synchronize(Common::Serializer &s) {
+	Scene8xx::synchronize(s);
+
+	s.syncAsByte(_messWithThrottle);
+	s.syncAsByte(_movingThrottle);
+	s.syncAsByte(_throttleGone);
+	s.syncAsByte(_dontPullThrottleAgain);
+	s.syncAsByte(_pullThrottleReally);
+	s.syncAsByte(_alreadyOrgan);
+	s.syncAsByte(_alreadyPop);
+
+	s.syncAsSint16LE(_resetFrame);
+	s.syncAsUint32LE(_throttleCounter);
+}
+
 void Scene804::enter() {
 	_messWithThrottle = false;
 	_throttleCounter = 0;
@@ -1235,6 +1257,12 @@ void Scene808::setup() {
 	setAAName();
 }
 
+void Scene808::synchronize(Common::Serializer &s) {
+	Scene8xx::synchronize(s);
+
+	s.syncAsByte(_goingTo803);
+}
+
 void Scene808::enter() {
 	_scene->_userInterface.setup(kInputLimitedSentences);
 
@@ -1441,6 +1469,12 @@ void Scene810::setup() {
 	setAAName();
 }
 
+void Scene810::synchronize(Common::Serializer &s) {
+	Scene8xx::synchronize(s);
+
+	s.syncAsByte(_moveAllowed);
+}
+
 void Scene810::enter() {
 	_scene->_userInterface.setup(kInputLimitedSentences);
 	_game._player._visible = false;
diff --git a/engines/mads/nebular/nebular_scenes8.h b/engines/mads/nebular/nebular_scenes8.h
index 590f31c..f926d1e 100644
--- a/engines/mads/nebular/nebular_scenes8.h
+++ b/engines/mads/nebular/nebular_scenes8.h
@@ -58,6 +58,7 @@ private:
 
 public:
 	Scene801(MADSEngine *vm) : Scene8xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -101,6 +102,7 @@ private:
 	bool _alreadyPop;
 public:
 	Scene804(MADSEngine *vm) : Scene8xx(vm), _throttleCounter(0) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -135,6 +137,7 @@ private:
 
 public:
 	Scene808(MADSEngine *vm) : Scene8xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -147,6 +150,7 @@ private:
 
 public:
 	Scene810(MADSEngine *vm) : Scene8xx(vm) {}
+	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();


Commit: 39f5f0a093c8bbf7b6962d2c58b7ef9062687d58
    https://github.com/scummvm/scummvm/commit/39f5f0a093c8bbf7b6962d2c58b7ef9062687d58
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-21T19:43:28+02:00

Commit Message:
MADS: Move some contructors from .h to .cpp in scene group 1

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index ab73398..0277af2 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -99,6 +99,16 @@ void Scene1xx::setPlayerSpritesPrefix() {
 
 /*------------------------------------------------------------------------*/
 
+Scene101::Scene101(MADSEngine *vm) : Scene1xx(vm) {
+	_sittingFl = false;
+	_panelOpened = false;
+	_messageNum = 0;
+	_posY = 0;
+	_shieldSpriteIdx = 0;
+	_chairHotspotId = 0;
+	_oldSpecial = 0;
+}
+
 void Scene101::setup() {
 	_scene->_animationData->preLoad(formAnimName('A', -1), 3);
 	setPlayerSpritesPrefix();
@@ -617,6 +627,16 @@ void Scene101::synchronize(Common::Serializer &s) {
 
 /*------------------------------------------------------------------------*/
 
+Scene102::Scene102(MADSEngine *vm) : Scene1xx(vm) {
+	_fridgeOpenedFl = false;
+	_fridgeOpenedDescr = false;
+	_fridgeFirstOpenFl = false;
+	_chairDescrFl = false;
+	_drawerDescrFl = false;
+	_activeMsgFl = false;
+	_fridgeCommentCount = 0;
+}
+
 void Scene102::setup() {
 	_scene->_animationData->preLoad(formAnimName('A', -1), 3);
 	setPlayerSpritesPrefix();
@@ -1223,6 +1243,11 @@ void Scene102::synchronize(Common::Serializer &s) {
 
 /*------------------------------------------------------------------------*/
 
+Scene103::Scene103(MADSEngine *vm) : Scene1xx(vm) {
+	_sayHiToBinky = false;
+	_updateClock = 0;
+}
+
 void Scene103::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -1548,6 +1573,11 @@ void Scene103::synchronize(Common::Serializer &s) {
 
 /*------------------------------------------------------------------------*/
 
+Scene104::Scene104(MADSEngine *vm) : Scene1xx(vm) {
+	_kargShootingFl = false;
+	_loseFl = false;
+}
+
 void Scene104::setup() {
 	// Preloading has been skipped
 	setPlayerSpritesPrefix();
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index 80df7f9..1535772 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -66,8 +66,7 @@ private:
 
 	void sayDang();
 public:
-	Scene101(MADSEngine *vm) : Scene1xx(vm), _sittingFl(false), _panelOpened(false), _messageNum(0),
-		_posY(0), _shieldSpriteIdx(0), _chairHotspotId(0), _oldSpecial(0) {}
+	Scene101(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();
@@ -91,8 +90,7 @@ private:
 	void addRandomMessage();
 
 public:
-	Scene102(MADSEngine *vm) : Scene1xx(vm), _fridgeOpenedFl(false), _fridgeOpenedDescr(false), _fridgeFirstOpenFl(false),
-		_chairDescrFl(false), _drawerDescrFl(false), _activeMsgFl(false), _fridgeCommentCount(0) {}
+	Scene102(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();
@@ -108,7 +106,7 @@ private:
 	bool _sayHiToBinky;
 	uint32 _updateClock;
 public:
-	Scene103(MADSEngine *vm) : Scene1xx(vm) {}
+	Scene103(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();
@@ -124,7 +122,7 @@ private:
 	bool _loseFl;
 
 public:
-	Scene104(MADSEngine *vm) : Scene1xx(vm), _kargShootingFl(false), _loseFl(false) {}
+	Scene104(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();


Commit: b9ccb8a1ec871c86407642aa8b290db06089abff
    https://github.com/scummvm/scummvm/commit/b9ccb8a1ec871c86407642aa8b290db06089abff
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-21T19:45:30+02:00

Commit Message:
MADS: Remove useless variable in scene 103

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 0277af2..e6f8d4f 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -1244,7 +1244,6 @@ void Scene102::synchronize(Common::Serializer &s) {
 /*------------------------------------------------------------------------*/
 
 Scene103::Scene103(MADSEngine *vm) : Scene1xx(vm) {
-	_sayHiToBinky = false;
 	_updateClock = 0;
 }
 
@@ -1322,7 +1321,6 @@ void Scene103::enter() {
 
 	_vm->_palette->setEntry(252, 63, 63, 10);
 	_vm->_palette->setEntry(253, 45, 45, 10);
-	_sayHiToBinky = false;
 	_updateClock = _scene->_frameStartTime;
 }
 
@@ -1493,7 +1491,6 @@ void Scene103::actions() {
 		case 1: {
 			Common::String msg = _game.getQuote(72);
 			_scene->_kernelMessages.add(Common::Point(310, 132), 0xFDFC, 16, 2, 120, msg);
-			_sayHiToBinky = false;
 			break;
 		}
 
@@ -1567,7 +1564,8 @@ void Scene103::postActions() {
 
 void Scene103::synchronize(Common::Serializer &s) {
 	Scene1xx::synchronize(s);
-	s.syncAsByte(_sayHiToBinky);
+	byte dummy = 0;
+	s.syncAsByte(dummy); // In order to avoid to break savegame compatibility
 	s.syncAsUint32LE(_updateClock);
 }
 
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index 1535772..318773e 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -103,7 +103,6 @@ public:
 
 class Scene103 : public Scene1xx {
 private:
-	bool _sayHiToBinky;
 	uint32 _updateClock;
 public:
 	Scene103(MADSEngine *vm);


Commit: 7260ad19d57db2f6f93c1313a0b69d7e61096c0d
    https://github.com/scummvm/scummvm/commit/7260ad19d57db2f6f93c1313a0b69d7e61096c0d
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-21T21:12:19+02:00

Commit Message:
MADS: Move the remaining contructors out of the header in scene group 1

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index e6f8d4f..66da49c 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -1777,6 +1777,10 @@ void Scene104::synchronize(Common::Serializer &s) {
 
 /*------------------------------------------------------------------------*/
 
+Scene105::Scene105(MADSEngine *vm) : Scene1xx(vm) {
+	_explosionFl = false;
+}
+
 void Scene105::setup() {
 	// Preloading has been skipped
 	setPlayerSpritesPrefix();
@@ -1928,6 +1932,13 @@ void Scene105::synchronize(Common::Serializer &s) {
 
 /*------------------------------------------------------------------------*/
 
+Scene106::Scene106(MADSEngine *vm) : Scene1xx(vm) {
+	_backToShipFl = false;
+	_shadowFl = false;
+	_firstEmergingFl = false;
+	_msgPosY = 0;
+}
+
 void Scene106::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -2143,6 +2154,10 @@ void Scene106::synchronize(Common::Serializer &s) {
 
 /*------------------------------------------------------------------------*/
 
+Scene107::Scene107(MADSEngine *vm) : Scene1xx(vm) {
+	_shootingFl = false;
+}
+
 void Scene107::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -2348,6 +2363,7 @@ void Scene108::actions() {
 }
 
 /*------------------------------------------------------------------------*/
+
 Scene109::Scene109(MADSEngine *vm) : Scene1xx(vm) {
 	_rexThrowingObject = false;
 	_hoovicDifficultFl = false;
@@ -2761,6 +2777,10 @@ void Scene109::synchronize(Common::Serializer &s) {
 
 /*------------------------------------------------------------------------*/
 
+Scene110::Scene110(MADSEngine *vm) : Scene1xx(vm) {
+	_crabsFl = false;
+}
+
 void Scene110::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -2888,6 +2908,13 @@ void Scene110::synchronize(Common::Serializer &s) {
 
 /*------------------------------------------------------------------------*/
 
+Scene111::Scene111(MADSEngine *vm) : Scene1xx(vm) {
+	_stampedFl = false;
+	_launch1Fl = false;
+	_launched2Fl = false;
+	_rexDivingFl = false;
+}
+
 void Scene111::setup() {
 	_scene->addActiveVocab(NOUN_BATS);
 
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index 318773e..3cb4d43 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -136,7 +136,7 @@ private:
 	bool _explosionFl;
 
 public:
-	Scene105(MADSEngine *vm) : Scene1xx(vm), _explosionFl(false) {}
+	Scene105(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();
@@ -155,7 +155,7 @@ private:
 	int _msgPosY;
 
 public:
-	Scene106(MADSEngine *vm) : Scene1xx(vm), _backToShipFl(false), _shadowFl(false), _firstEmergingFl(false), _msgPosY(0) {}
+	Scene106(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();
@@ -170,7 +170,7 @@ private:
 	bool _shootingFl;
 
 public:
-	Scene107(MADSEngine *vm) : Scene1xx(vm), _shootingFl(false) {}
+	Scene107(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();
@@ -218,7 +218,7 @@ private:
 	bool _crabsFl;
 
 public:
-	Scene110(MADSEngine *vm) : Scene1xx(vm), _crabsFl(false) {}
+	Scene110(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();
@@ -236,7 +236,7 @@ private:
 	bool _rexDivingFl;
 
 public:
-	Scene111(MADSEngine *vm) : Scene1xx(vm), _stampedFl(false), _launch1Fl(false), _launched2Fl(false), _rexDivingFl(false) {}
+	Scene111(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();


Commit: 69acf34cba882ba3be28b780a871c055c7ca45a2
    https://github.com/scummvm/scummvm/commit/69acf34cba882ba3be28b780a871c055c7ca45a2
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-21T21:48:21+02:00

Commit Message:
MADS: Some refactoring in group scene 1

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 66da49c..131ee6e 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -72,21 +72,21 @@ void Scene1xx::setPlayerSpritesPrefix() {
 	_vm->_sound->command(5);
 	Common::String oldName = _game._player._spritesPrefix;
 	if (_scene->_nextSceneId <= 103 || _scene->_nextSceneId == 111) {
-		if (_globals[kSexOfRex] == SEX_FEMALE) {
+		if (_globals[kSexOfRex] == SEX_FEMALE)
 			_game._player._spritesPrefix = "ROX";
-		} else {
+		else {
 			_game._player._spritesPrefix = "RXM";
 			_globals[kSexOfRex] = SEX_MALE;
 		}
 	} else if (_scene->_nextSceneId <= 110) {
 		_game._player._spritesPrefix = "RXSW";
 		_globals[kSexOfRex] = SEX_UNKNOWN;
-	} else if (_scene->_nextSceneId == 112) {
+	} else if (_scene->_nextSceneId == 112)
 		_game._player._spritesPrefix = "";
-	}
 
 	if (oldName == _game._player._spritesPrefix)
 		_game._player._spritesChanged = true;
+
 	if (_scene->_nextSceneId == 105 || (_scene->_nextSceneId == 109 && _globals[kHoovicAlive])) {
 		_game._player._spritesChanged = true;
 		_game._player._loadsFirst = false;
@@ -109,6 +109,19 @@ Scene101::Scene101(MADSEngine *vm) : Scene1xx(vm) {
 	_oldSpecial = 0;
 }
 
+void Scene101::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+
+	s.syncAsByte(_sittingFl);
+	s.syncAsByte(_panelOpened);
+
+	s.syncAsSint16LE(_messageNum);
+	s.syncAsSint16LE(_posY);
+	s.syncAsSint16LE(_shieldSpriteIdx);
+	s.syncAsSint16LE(_chairHotspotId);
+	s.syncAsSint16LE(_oldSpecial);
+}
+
 void Scene101::setup() {
 	_scene->_animationData->preLoad(formAnimName('A', -1), 3);
 	setPlayerSpritesPrefix();
@@ -140,6 +153,9 @@ void Scene101::sayDang() {
 		_vm->_dialogs->show(10117);
 		_game._player._stepEnabled = true;
 		break;
+
+	default:
+		break;
 	}
 }
 
@@ -242,6 +258,9 @@ void Scene101::step() {
 	case 73:
 		sayDang();
 		break;
+
+	default:
+		break;
 	}
 
 	if (_scene->_activeAnimation != nullptr) {
@@ -307,6 +326,9 @@ void Scene101::preActions() {
 				_globals._sequenceIndexes[12] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[12], false, 6, 0, 0, 0);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[12], 4);
 				break;
+
+			default:
+				break;
 			}
 		}
 	}
@@ -329,6 +351,9 @@ void Scene101::preActions() {
 			_panelOpened = false;
 			_scene->_hotspots.activate(NOUN_SHIELD_MODULATOR, false);
 			break;
+
+		default:
+			break;
 		}
 	}
 }
@@ -377,6 +402,9 @@ void Scene101::actions() {
 				}
 				_game._trigger = 0;
 				break;
+
+			default:
+				break;
 			}
 		} else {
 			_vm->_dialogs->show(10131);
@@ -385,7 +413,7 @@ void Scene101::actions() {
 		}
 	}
 
-	if (((_action.isAction(VERB_WALKTO, NOUN_SHIELD_ACCESS_PANEL) || _action.isAction(VERB_OPEN, NOUN_SHIELD_ACCESS_PANEL))) && !_panelOpened) {
+	if ((_action.isAction(VERB_WALKTO, NOUN_SHIELD_ACCESS_PANEL) || _action.isAction(VERB_OPEN, NOUN_SHIELD_ACCESS_PANEL)) && !_panelOpened) {
 		switch (_game._trigger) {
 		case 0:
 			_shieldSpriteIdx = _game._objects.isInRoom(OBJ_SHIELD_MODULATOR) ? 13 : 14;
@@ -404,6 +432,9 @@ void Scene101::actions() {
 			if (_game._objects.isInRoom(OBJ_SHIELD_MODULATOR))
 				_scene->_hotspots.activate(NOUN_SHIELD_MODULATOR, true);
 			break;
+
+		default:
+			break;
 		}
 		_action._inProgress = false;
 		return;
@@ -427,9 +458,9 @@ void Scene101::actions() {
 				_vm->_dialogs->show(10128);
 			else
 				_vm->_dialogs->show(10129);
-		} else {
+		} else
 			_vm->_dialogs->show(10127);
-		}
+
 		_action._inProgress = false;
 		return;
 	}
@@ -441,9 +472,9 @@ void Scene101::actions() {
 	}
 
 	if (_action.isAction(VERB_LOOK, NOUN_VIEW_SCREEN) && _sittingFl) {
-		if (_globals[kWatchedViewScreen]) {
+		if (_globals[kWatchedViewScreen])
 			sayDang();
-		} else {
+		else {
 			switch (_game._trigger) {
 			case 0:
 				_game._player._stepEnabled = false;
@@ -473,6 +504,9 @@ void Scene101::actions() {
 				_sittingFl = true;
 				_scene->_nextSceneId = 112;
 				break;
+
+			default:
+				break;
 			}
 		}
 		_action._inProgress = false;
@@ -612,19 +646,6 @@ void Scene101::actions() {
 	}
 }
 
-void Scene101::synchronize(Common::Serializer &s) {
-	Scene1xx::synchronize(s);
-
-	s.syncAsByte(_sittingFl);
-	s.syncAsByte(_panelOpened);
-
-	s.syncAsSint16LE(_messageNum);
-	s.syncAsSint16LE(_posY);
-	s.syncAsSint16LE(_shieldSpriteIdx);
-	s.syncAsSint16LE(_chairHotspotId);
-	s.syncAsSint16LE(_oldSpecial);
-}
-
 /*------------------------------------------------------------------------*/
 
 Scene102::Scene102(MADSEngine *vm) : Scene1xx(vm) {
@@ -637,6 +658,19 @@ Scene102::Scene102(MADSEngine *vm) : Scene1xx(vm) {
 	_fridgeCommentCount = 0;
 }
 
+void Scene102::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+
+	s.syncAsByte(_fridgeOpenedFl);
+	s.syncAsByte(_fridgeOpenedDescr);
+	s.syncAsByte(_fridgeFirstOpenFl);
+	s.syncAsByte(_chairDescrFl);
+	s.syncAsByte(_drawerDescrFl);
+	s.syncAsByte(_activeMsgFl);
+
+	s.syncAsSint16LE(_fridgeCommentCount);
+}
+
 void Scene102::setup() {
 	_scene->_animationData->preLoad(formAnimName('A', -1), 3);
 	setPlayerSpritesPrefix();
@@ -659,7 +693,6 @@ void Scene102::enter() {
 	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('x', 3));
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('x', 4));
 	_globals._spriteIndexes[5] = _scene->_sprites.addSprites(formAnimName('x', 5));
-
 	_globals._spriteIndexes[6] = _scene->_sprites.addSprites(formAnimName('b', -1));
 	_globals._spriteIndexes[7] = _scene->_sprites.addSprites(formAnimName('c', -1));
 	_globals._spriteIndexes[8] = _scene->_sprites.addSprites(formAnimName('e', -1));
@@ -691,9 +724,9 @@ void Scene102::enter() {
 		_game._player._stepEnabled = false;
 		_globals._sequenceIndexes[6] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[6], false, 6, 1, 2, 0);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
-	} else if (_scene->_priorSceneId == 103) {
+	} else if (_scene->_priorSceneId == 103)
 		_game._player._playerPos = Common::Point(47, 152);
-	} else if (_scene->_priorSceneId != -2) {
+	else if (_scene->_priorSceneId != -2) {
 		_game._player._facing = FACING_NORTHWEST;
 		_game._player._playerPos = Common::Point(32, 129);
 	}
@@ -802,6 +835,9 @@ void Scene102::preActions() {
 			_fridgeOpenedFl = false;
 			_game._player._stepEnabled = true;
 			break;
+
+		default:
+			break;
 		}
 	}
 
@@ -810,14 +846,13 @@ void Scene102::preActions() {
 }
 
 void Scene102::actions() {
-	bool justOpenedFl = false;
-
 	if (_action._lookFlag) {
 		_vm->_dialogs->show(10234);
 		_action._inProgress = false;
 		return;
 	}
 
+	bool justOpenedFl = false;
 	if (_action.isObject(NOUN_REFRIGERATOR) && !_fridgeOpenedFl) {
 		switch (_game._trigger) {
 		case 0:
@@ -855,6 +890,9 @@ void Scene102::actions() {
 			if (_game._objects.isInRoom(OBJ_BURGER))
 				_scene->_hotspots.activate(NOUN_BURGER, true);
 			break;
+
+		default:
+			break;
 		}
 	}
 
@@ -907,6 +945,9 @@ void Scene102::actions() {
 		case 1:
 			_scene->_nextSceneId = 101;
 			break;
+
+		default:
+			break;
 		}
 		_action._inProgress = false;
 		return;
@@ -1034,6 +1075,9 @@ void Scene102::actions() {
 				_vm->_dialogs->show(10237);
 			_scene->_nextSceneId = 106;
 			break;
+
+		default:
+			break;
 		}
 		_action._inProgress = false;
 		return;
@@ -1118,6 +1162,9 @@ void Scene102::actions() {
 			_globals[kMedicineCabinetOpen] = false;
 			_vm->_dialogs->show(10209);
 			break;
+
+		default:
+			break;
 		}
 		_action._inProgress = false;
 		return;
@@ -1148,6 +1195,9 @@ void Scene102::actions() {
 			}
 			_globals[kMedicineCabinetVirgin] = false;
 			break;
+
+		default:
+			break;
 		}
 		_action._inProgress = false;
 		return;
@@ -1172,6 +1222,9 @@ void Scene102::actions() {
 			_vm->_sound->command(22);
 			_vm->_dialogs->showItem(OBJ_BINOCULARS, 10201);
 			break;
+
+		default:
+			break;
 		}
 		_action._inProgress = false;
 		return;
@@ -1228,25 +1281,19 @@ void Scene102::postActions() {
 	}
 }
 
-void Scene102::synchronize(Common::Serializer &s) {
-	Scene1xx::synchronize(s);
-
-	s.syncAsByte(_fridgeOpenedFl);
-	s.syncAsByte(_fridgeOpenedDescr);
-	s.syncAsByte(_fridgeFirstOpenFl);
-	s.syncAsByte(_chairDescrFl);
-	s.syncAsByte(_drawerDescrFl);
-	s.syncAsByte(_activeMsgFl);
-
-	s.syncAsSint16LE(_fridgeCommentCount);
-}
-
 /*------------------------------------------------------------------------*/
 
 Scene103::Scene103(MADSEngine *vm) : Scene1xx(vm) {
 	_updateClock = 0;
 }
 
+void Scene103::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+	byte dummy = 0;
+	s.syncAsByte(dummy); // In order to avoid to break savegame compatibility
+	s.syncAsUint32LE(_updateClock);
+}
+
 void Scene103::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -1265,15 +1312,16 @@ void Scene103::enter() {
 	_globals._spriteIndexes[9] = _scene->_sprites.addSprites(formAnimName('t', -1));
 	_globals._spriteIndexes[10] = _scene->_sprites.addSprites(formAnimName('r', -1));
 	_globals._spriteIndexes[11] = _scene->_sprites.addSprites(formAnimName('c', -1));
-
 	_globals._spriteIndexes[12] = _scene->_sprites.addSprites("*RXMBD_2");
 	_globals._spriteIndexes[13] = _scene->_sprites.addSprites("*RXMRD_3");
 	_globals._spriteIndexes[15] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], false, 7, 0, 1, 0);
+
 	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 2, 0);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 0);
 
 	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 25);
 	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 2, 72);
+
 	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 1, 37);
 	_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_SPRITE, 2, 73);
 
@@ -1303,7 +1351,6 @@ void Scene103::enter() {
 
 	if (_scene->_priorSceneId == 102) {
 		_game._player._stepEnabled = false;
-
 		_globals._sequenceIndexes[6] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[6], false, 6, 1, 0, 0);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[6], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
 	}
@@ -1325,24 +1372,23 @@ void Scene103::enter() {
 }
 
 void Scene103::step() {
-	Common::Point pt;
-	int dist;
-
 	switch (_vm->_game->_trigger) {
 	case 70:
 		_vm->_game->_player._stepEnabled = true;
 		break;
 
-	case 72:
-		pt = _vm->_game->_player._playerPos;
-		dist = _vm->hypotenuse(pt.x - 58, pt.y - 93);
+	case 72: {
+		Common::Point pt = _vm->_game->_player._playerPos;
+		int dist = _vm->hypotenuse(pt.x - 58, pt.y - 93);
 		_vm->_sound->command(27, (dist * -128 / 378) + 127);
+		}
 		break;
 
-	case 73:
-		pt = _vm->_game->_player._playerPos;
-		dist = _vm->hypotenuse(pt.x - 266, pt.y - 81);
+	case 73: {
+		Common::Point pt = _vm->_game->_player._playerPos;
+		int dist = _vm->hypotenuse(pt.x - 266, pt.y - 81);
 		_vm->_sound->command(27, (dist * -127 / 378) + 127);
+		}
 		break;
 
 	default:
@@ -1350,8 +1396,8 @@ void Scene103::step() {
 	}
 
 	if (_scene->_frameStartTime >= _updateClock) {
-		pt = _vm->_game->_player._playerPos;
-		dist = _vm->hypotenuse(pt.x - 79, pt.y - 137);
+		Common::Point pt = _vm->_game->_player._playerPos;
+		int dist = _vm->hypotenuse(pt.x - 79, pt.y - 137);
 		_vm->_sound->command(29, (dist * -127 / 378) + 127);
 
 		pt = _vm->_game->_player._playerPos;
@@ -1367,9 +1413,9 @@ void Scene103::step() {
 }
 
 void Scene103::actions() {
-	if (_action._savedFields._lookFlag) {
+	if (_action._savedFields._lookFlag)
 		_vm->_dialogs->show(10322);
-	} else if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR)) {
+	else if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOOR)) {
 		switch (_vm->_game->_trigger) {
 		case 0:
 			_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 1);
@@ -1445,9 +1491,9 @@ void Scene103::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_LOOK, 362)) {
+	} else if (_action.isAction(VERB_LOOK, 362))
 		_vm->_dialogs->show(10301);
-	} else if (_action.isAction(VERB_TAKE, 362)) {
+	else if (_action.isAction(VERB_TAKE, 362)) {
 		// Take Turkey
 		if (!_vm->_game->_trigger)
 			_vm->_sound->command(31);
@@ -1477,9 +1523,9 @@ void Scene103::actions() {
 			_vm->_dialogs->show(10302);
 			_scene->_hotspots.activate(362, false);
 		}
-	} else if (_action.isAction(VERB_LOOK, 250)) {
+	} else if (_action.isAction(VERB_LOOK, 250))
 		_vm->_dialogs->show(!_globals[kTurkeyExploded] ? 10323 : 10303);
-	} else if (_action.isAction(VERB_TALKTO, 27)) {
+	else if (_action.isAction(VERB_TALKTO, 27)) {
 		switch (_vm->_game->_trigger) {
 		case 0: {
 			_game._player._stepEnabled = false;
@@ -1507,43 +1553,40 @@ void Scene103::actions() {
 		default:
 			break;
 		}
-	} else if (_action.isAction(VERB_LOOK, 27)) {
+	} else if (_action.isAction(VERB_LOOK, 27))
 		_vm->_dialogs->show(10304);
-	} else if (_action.isAction(VERB_LOOK, 36)) {
+	else if (_action.isAction(VERB_LOOK, 36))
 		_vm->_dialogs->show(10307);
-	} else if (_action.isAction(VERB_LOOK, 55)) {
+	else if (_action.isAction(VERB_LOOK, 55))
 		_vm->_dialogs->show(10308);
-	} else if (_action.isAction(VERB_TAKE, 315)) {
+	else if (_action.isAction(VERB_TAKE, 315))
 		_vm->_dialogs->show(10309);
-	} else if (_action.isAction(VERB_TAKE, 85)) {
+	else if (_action.isAction(VERB_TAKE, 85))
 		_vm->_dialogs->show(10310);
-	} else if (_action.isAction(VERB_LOOK, 144)) {
+	else if (_action.isAction(VERB_LOOK, 144))
 		_vm->_dialogs->show(10312);
-	} else if (_action.isAction(VERB_OPEN, 144)) {
+	else if (_action.isAction(VERB_OPEN, 144))
 		_vm->_dialogs->show(10313);
-	} else if (_action.isAction(VERB_CLOSE, 27)) {
+	else if (_action.isAction(VERB_CLOSE, 27))
 		_vm->_dialogs->show(10314);
-	} else if (_action.isAction(VERB_LOOK, 310)) {
+	else if (_action.isAction(VERB_LOOK, 310))
 		_vm->_dialogs->show(10315);
-	} else if (_action.isAction(VERB_LOOK, 178)) {
+	else if (_action.isAction(VERB_LOOK, 178))
 		_vm->_dialogs->show(10316);
-	} else if (_action.isAction(VERB_LOOK, 283)) {
+	else if (_action.isAction(VERB_LOOK, 283))
 		_vm->_dialogs->show(10317);
-	} else if (_action.isAction(VERB_LOOK, 120)) {
+	else if (_action.isAction(VERB_LOOK, 120))
 		_vm->_dialogs->show(10318);
-	} else if (_action.isAction(VERB_LOOK, 289) &&
-			_game._objects.isInInventory(OBJ_REBREATHER)) {
+	else if (_action.isAction(VERB_LOOK, 289) && _game._objects.isInInventory(OBJ_REBREATHER))
 		_vm->_dialogs->show(10319);
-	} else if (_action.isAction(VERB_LOOK, 371) &&
-			_game._objects.isInInventory(OBJ_TIMER_MODULE)) {
+	else if (_action.isAction(VERB_LOOK, 371) && _game._objects.isInInventory(OBJ_TIMER_MODULE))
 		_vm->_dialogs->show(10320);
-	} else if (_action.isAction(VERB_LOOK, 137)) {
+	else if (_action.isAction(VERB_LOOK, 137))
 		_vm->_dialogs->show(10321);
-	} else if (_action.isAction(VERB_LOOK, 409)) {
+	else if (_action.isAction(VERB_LOOK, 409))
 		_vm->_dialogs->show(_game._objects.isInInventory(OBJ_TIMER_MODULE) ? 10324 : 10325);
-	} else {
+	else
 		return;
-	}
 
 	_action._inProgress = false;
 }
@@ -1552,23 +1595,13 @@ void Scene103::postActions() {
 	if (_action.isAction(27) && !_action.isAction(VERB_WALKTO)) {
 		_vm->_dialogs->show(10305);
 		_action._inProgress = false;
-	} else {
-		if (_action.isAction(VERB_PUT, 85, 144)) {
-			Common::String msg = _game.getQuote(73);
-			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110,
-				34, 0, 120, msg);
-			_action._inProgress = false;
-		}
+	} else if (_action.isAction(VERB_PUT, 85, 144)) {
+		Common::String msg = _game.getQuote(73);
+		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, msg);
+		_action._inProgress = false;
 	}
 }
 
-void Scene103::synchronize(Common::Serializer &s) {
-	Scene1xx::synchronize(s);
-	byte dummy = 0;
-	s.syncAsByte(dummy); // In order to avoid to break savegame compatibility
-	s.syncAsUint32LE(_updateClock);
-}
-
 /*------------------------------------------------------------------------*/
 
 Scene104::Scene104(MADSEngine *vm) : Scene1xx(vm) {
@@ -1576,6 +1609,13 @@ Scene104::Scene104(MADSEngine *vm) : Scene1xx(vm) {
 	_loseFl = false;
 }
 
+void Scene104::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+
+	s.syncAsByte(_kargShootingFl);
+	s.syncAsByte(_loseFl);
+}
+
 void Scene104::setup() {
 	// Preloading has been skipped
 	setPlayerSpritesPrefix();
@@ -1647,6 +1687,9 @@ void Scene104::step() {
 				_vm->_dialogs->show(10406);
 				_scene->_reloadSceneFlag = true;
 				break;
+
+			default:
+				break;
 			}
 			break;
 
@@ -1686,6 +1729,9 @@ void Scene104::step() {
 				_vm->_dialogs->show(10406);
 				_scene->_reloadSceneFlag = true;
 				break;
+
+			default:
+				break;
 			}
 			break;
 
@@ -1718,6 +1764,9 @@ void Scene104::step() {
 				_vm->_dialogs->show(10406);
 				_scene->_reloadSceneFlag = true;
 				break;
+
+			default:
+				break;
 			}
 			break;
 		default:
@@ -1768,19 +1817,17 @@ void Scene104::actions() {
 	_action._inProgress = false;
 }
 
-void Scene104::synchronize(Common::Serializer &s) {
-	Scene1xx::synchronize(s);
-
-	s.syncAsByte(_kargShootingFl);
-	s.syncAsByte(_loseFl);
-}
-
 /*------------------------------------------------------------------------*/
 
 Scene105::Scene105(MADSEngine *vm) : Scene1xx(vm) {
 	_explosionFl = false;
 }
 
+void Scene105::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+	s.syncAsByte(_explosionFl);
+}
+
 void Scene105::setup() {
 	// Preloading has been skipped
 	setPlayerSpritesPrefix();
@@ -1861,6 +1908,9 @@ void Scene105::step() {
 			_scene->_reloadSceneFlag = true;
 			_scene->_sequences.addTimer(90, 4);
 			break;
+
+		default:
+			break;
 		}
 	}
 
@@ -1925,11 +1975,6 @@ void Scene105::actions() {
 	_action._inProgress = false;
 }
 
-void Scene105::synchronize(Common::Serializer &s) {
-	Scene1xx::synchronize(s);
-	s.syncAsByte(_explosionFl);
-}
-
 /*------------------------------------------------------------------------*/
 
 Scene106::Scene106(MADSEngine *vm) : Scene1xx(vm) {
@@ -1939,6 +1984,14 @@ Scene106::Scene106(MADSEngine *vm) : Scene1xx(vm) {
 	_msgPosY = 0;
 }
 
+void Scene106::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+	s.syncAsByte(_backToShipFl);
+	s.syncAsByte(_shadowFl);
+	s.syncAsByte(_firstEmergingFl);
+	s.syncAsSint32LE(_msgPosY);
+}
+
 void Scene106::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -2144,20 +2197,17 @@ void Scene106::actions() {
 	_action._inProgress = false;
 }
 
-void Scene106::synchronize(Common::Serializer &s) {
-	Scene1xx::synchronize(s);
-	s.syncAsByte(_backToShipFl);
-	s.syncAsByte(_shadowFl);
-	s.syncAsByte(_firstEmergingFl);
-	s.syncAsSint32LE(_msgPosY);
-}
-
 /*------------------------------------------------------------------------*/
 
 Scene107::Scene107(MADSEngine *vm) : Scene1xx(vm) {
 	_shootingFl = false;
 }
 
+void Scene107::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+	s.syncAsByte(_shootingFl);
+}
+
 void Scene107::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -2268,12 +2318,6 @@ void Scene107::actions() {
 	_action._inProgress = false;
 }
 
-void Scene107::synchronize(Common::Serializer &s) {
-	Scene1xx::synchronize(s);
-	s.syncAsByte(_shootingFl);
-}
-
-
 /*------------------------------------------------------------------------*/
 
 void Scene108::setup() {
@@ -2376,6 +2420,18 @@ Scene109::Scene109(MADSEngine *vm) : Scene1xx(vm) {
 	_hoovicTrigger = 0;
 }
 
+void Scene109::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+	s.syncAsByte(_rexThrowingObject);
+	s.syncAsByte(_hoovicDifficultFl);
+	s.syncAsByte(_beforeEatingRex);
+	s.syncAsByte(_eatingRex);
+	s.syncAsByte(_hungryFl);
+	s.syncAsByte(_eatingFirstFish);
+	s.syncAsSint32LE(_throwingObjectId);
+	s.syncAsSint32LE(_hoovicTrigger);
+}
+
 void Scene109::setup() {
 	_scene->addActiveVocab(NOUN_DEAD_PURPLE_MONSTER);
 	_scene->addActiveVocab(NOUN_MONSTER_SLUDGE);
@@ -2763,24 +2819,17 @@ void Scene109::actions() {
 	_action._inProgress = false;
 }
 
-void Scene109::synchronize(Common::Serializer &s) {
-	Scene1xx::synchronize(s);
-	s.syncAsByte(_rexThrowingObject);
-	s.syncAsByte(_hoovicDifficultFl);
-	s.syncAsByte(_beforeEatingRex);
-	s.syncAsByte(_eatingRex);
-	s.syncAsByte(_hungryFl);
-	s.syncAsByte(_eatingFirstFish);
-	s.syncAsSint32LE(_throwingObjectId);
-	s.syncAsSint32LE(_hoovicTrigger);
-}
-
 /*------------------------------------------------------------------------*/
 
 Scene110::Scene110(MADSEngine *vm) : Scene1xx(vm) {
 	_crabsFl = false;
 }
 
+void Scene110::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+	s.syncAsByte(_crabsFl);
+}
+
 void Scene110::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -2901,11 +2950,6 @@ void Scene110::actions() {
 	_action._inProgress = false;
 }
 
-void Scene110::synchronize(Common::Serializer &s) {
-	Scene1xx::synchronize(s);
-	s.syncAsByte(_crabsFl);
-}
-
 /*------------------------------------------------------------------------*/
 
 Scene111::Scene111(MADSEngine *vm) : Scene1xx(vm) {
@@ -2915,6 +2959,14 @@ Scene111::Scene111(MADSEngine *vm) : Scene1xx(vm) {
 	_rexDivingFl = false;
 }
 
+void Scene111::synchronize(Common::Serializer &s) {
+	Scene1xx::synchronize(s);
+	s.syncAsByte(_stampedFl);
+	s.syncAsByte(_launch1Fl);
+	s.syncAsByte(_launched2Fl);
+	s.syncAsByte(_rexDivingFl);
+}
+
 void Scene111::setup() {
 	_scene->addActiveVocab(NOUN_BATS);
 
@@ -3055,14 +3107,6 @@ void Scene111::actions() {
 	_action._inProgress = false;
 }
 
-void Scene111::synchronize(Common::Serializer &s) {
-	Scene1xx::synchronize(s);
-	s.syncAsByte(_stampedFl);
-	s.syncAsByte(_launch1Fl);
-	s.syncAsByte(_launched2Fl);
-	s.syncAsByte(_rexDivingFl);
-}
-
 /*------------------------------------------------------------------------*/
 
 void Scene112::setup() {


Commit: 12a70d2ce14531ba983fa39f3831317eb7e17e7d
    https://github.com/scummvm/scummvm/commit/12a70d2ce14531ba983fa39f3831317eb7e17e7d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-21T22:16:21-04:00

Commit Message:
MADS: Fix issues with inventory list scrolling when it shouldn't

Changed paths:
    engines/mads/user_interface.cpp



diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 3fab30a..68f5784 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -497,62 +497,61 @@ void UserInterface::updateInventoryScroller() {
 
 	_scrollbarActive = SCROLLBAR_NONE;
 
-	if ((
-		(screenObjects._category == CAT_INV_SCROLLER) ||
-		// FIXME: This scrolls the inventory up when selecting verbs or attempting to combine items
-		false/*(screenObjects._category != CAT_INV_SCROLLER && _scrollbarOldActive == SCROLLBAR_ELEVATOR)*/
-	) && (_vm->_events->_mouseStatusCopy || _vm->_easyMouse)) {
-		if ((_vm->_events->_mouseClicked || (_vm->_easyMouse && !_vm->_events->_mouseStatusCopy))
-				&& (screenObjects._category == CAT_INV_SCROLLER))
-			_scrollbarStrokeType = (ScrollbarActive)screenObjects._spotId;
-
-		if (screenObjects._spotId == _scrollbarStrokeType || _scrollbarOldActive == SCROLLBAR_ELEVATOR) {
-			_scrollbarActive = _scrollbarStrokeType;
-			uint32 currentMilli = g_system->getMillis();
-			uint32 timeInc = _scrollbarQuickly ? 100 : 380;
-
-			if (_vm->_events->_mouseStatus && (_scrollbarMilliTime + timeInc) <= currentMilli) {
-				_scrollbarQuickly = _vm->_events->_vD2 < 1;
-				_scrollbarMilliTime = currentMilli;
-
-				switch (_scrollbarStrokeType) {
-				case SCROLLBAR_UP:
-					// Scroll up
-					if (_inventoryTopIndex > 0 && inventoryList.size() > 0) {
-						--_inventoryTopIndex;
-						_inventoryChanged = true;
+	if ((screenObjects._category == CAT_INV_SCROLLER) || (screenObjects._category != CAT_INV_SCROLLER 
+			&& _scrollbarOldActive == SCROLLBAR_ELEVATOR && _vm->_events->_mouseStatusCopy)) {
+		if (_vm->_events->_mouseStatusCopy || _vm->_easyMouse) {
+			if ((_vm->_events->_mouseClicked || (_vm->_easyMouse && !_vm->_events->_mouseStatusCopy))
+					&& (screenObjects._category == CAT_INV_SCROLLER))
+				_scrollbarStrokeType = (ScrollbarActive)screenObjects._spotId;
+
+			if (screenObjects._spotId == _scrollbarStrokeType || _scrollbarOldActive == SCROLLBAR_ELEVATOR) {
+				_scrollbarActive = _scrollbarStrokeType;
+				uint32 currentMilli = g_system->getMillis();
+				uint32 timeInc = _scrollbarQuickly ? 100 : 380;
+
+				if (_vm->_events->_mouseStatus && (_scrollbarMilliTime + timeInc) <= currentMilli) {
+					_scrollbarQuickly = _vm->_events->_vD2 < 1;
+					_scrollbarMilliTime = currentMilli;
+
+					switch (_scrollbarStrokeType) {
+					case SCROLLBAR_UP:
+						// Scroll up
+						if (_inventoryTopIndex > 0 && inventoryList.size() > 0) {
+							--_inventoryTopIndex;
+							_inventoryChanged = true;
+						}
+						break;
+
+					case SCROLLBAR_DOWN:
+						// Scroll down
+						if (_inventoryTopIndex < ((int)inventoryList.size() - 1) && inventoryList.size() > 1) {
+							++_inventoryTopIndex;
+							_inventoryChanged = true;
+						}
+						break;
+
+					case SCROLLBAR_ELEVATOR: {
+						// Inventory slider
+						int newIndex = CLIP((int)_vm->_events->currentPos().y - 170, 0, 17)
+							* inventoryList.size() / 10;
+						if (newIndex >= (int)inventoryList.size())
+							newIndex = inventoryList.size() - 1;
+
+						if (inventoryList.size() > 0) {
+							_inventoryChanged = newIndex != _inventoryTopIndex;
+							_inventoryTopIndex = newIndex;
+						}
+						break;
 					}
-					break;
 
-				case SCROLLBAR_DOWN:
-					// Scroll down
-					if (_inventoryTopIndex < ((int)inventoryList.size() - 1) && inventoryList.size() > 1) {
-						++_inventoryTopIndex;
-						_inventoryChanged = true;
-					}
-					break;
-
-				case SCROLLBAR_ELEVATOR: {
-					// Inventory slider
-					int newIndex = CLIP((int)_vm->_events->currentPos().y - 170, 0, 17)
-						* inventoryList.size() / 10;
-					if (newIndex >= (int)inventoryList.size())
-						newIndex = inventoryList.size() - 1;
-
-					if (inventoryList.size() > 0) {
-						_inventoryChanged = newIndex != _inventoryTopIndex;
-						_inventoryTopIndex = newIndex;
+					default:
+						break;
 					}
-					break;
-				}
 
-				default:
-					break;
-				}
-
-				if (_inventoryChanged) {
-					int dummy;
-					updateSelection(CAT_INV_LIST, 0, &dummy);
+					if (_inventoryChanged) {
+						int dummy;
+						updateSelection(CAT_INV_LIST, 0, &dummy);
+					}
 				}
 			}
 		}


Commit: e8cbe9e7dea0a9ccf4982c8c6b045f2cd6c8a92c
    https://github.com/scummvm/scummvm/commit/e8cbe9e7dea0a9ccf4982c8c6b045f2cd6c8a92c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-22T17:06:59+02:00

Commit Message:
MADS: Move contructors out of the header in scene group 2

Changed paths:
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h



diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 9505521..2c26e88 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -117,6 +117,15 @@ void Scene2xx::sceneEntrySound() {
 
 /*------------------------------------------------------------------------*/
 
+Scene201::Scene201(MADSEngine *vm) : Scene2xx(vm) {
+	_pterodactylFlag = false;
+}
+
+void Scene201::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+	s.syncAsByte(_pterodactylFlag);
+}
+
 void Scene201::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -324,12 +333,41 @@ void Scene201::actions() {
 	_action._inProgress = false;
 }
 
-void Scene201::synchronize(Common::Serializer &s) {
-	Scene2xx::synchronize(s);
-	s.syncAsByte(_pterodactylFlag);
+/*------------------------------------------------------------------------*/
+
+Scene202::Scene202(MADSEngine *vm) : Scene2xx(vm) {
+	_activeMsgFl = false;
+	_ladderTopFl = false;
+	_waitingMeteoFl = false;
+	_ladderHotspotId = -1;
+	_meteoClock1 = 0;
+	_meteoClock2 = 0;
+	_toStationFl = false;
+	_toTeleportFl = false;
+	_lastRoute = 0;
+	_stationCounter = 0;
+	_meteoFrame = 0;
 }
 
-/*------------------------------------------------------------------------*/
+void Scene202::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+	s.syncAsByte(_activeMsgFl);
+	s.syncAsByte(_ladderTopFl);
+	s.syncAsByte(_waitingMeteoFl);
+	s.syncAsByte(_toStationFl);
+	s.syncAsByte(_toTeleportFl);
+
+	s.syncAsSint32LE(_ladderHotspotId);
+	s.syncAsSint32LE(_lastRoute);
+	s.syncAsSint32LE(_stationCounter);
+	s.syncAsSint32LE(_meteoFrame);
+
+	s.syncAsUint32LE(_meteoClock1);
+	s.syncAsUint32LE(_meteoClock2);
+	s.syncAsUint32LE(_startTime);
+
+	s.syncAsByte(_meteorologistSpecial);
+}
 
 void Scene202::setup() {
 	setPlayerSpritesPrefix();
@@ -973,27 +1011,18 @@ void Scene202::actions() {
 	_action._inProgress = false;
 }
 
-void Scene202::synchronize(Common::Serializer &s) {
-	Scene2xx::synchronize(s);
-	s.syncAsByte(_activeMsgFl);
-	s.syncAsByte(_ladderTopFl);
-	s.syncAsByte(_waitingMeteoFl);
-	s.syncAsByte(_toStationFl);
-	s.syncAsByte(_toTeleportFl);
-
-	s.syncAsSint32LE(_ladderHotspotId);
-	s.syncAsSint32LE(_lastRoute);
-	s.syncAsSint32LE(_stationCounter);
-	s.syncAsSint32LE(_meteoFrame);
-
-	s.syncAsUint32LE(_meteoClock1);
-	s.syncAsUint32LE(_meteoClock2);
-	s.syncAsUint32LE(_startTime);
+/*****************************************************************************/
 
-	s.syncAsByte(_meteorologistSpecial);
+Scene203::Scene203(MADSEngine *vm) : Scene2xx(vm) {
+	_rhotundaEat2Fl = false;
+	_rhotundaEatFl = false;
 }
 
-/*****************************************************************************/
+void Scene203::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+	s.syncAsByte(_rhotundaEat2Fl);
+	s.syncAsByte(_rhotundaEatFl);
+}
 
 void Scene203::setup() {
 	setPlayerSpritesPrefix();
@@ -1105,12 +1134,6 @@ void Scene203::actions() {
 	_action._inProgress = false;
 }
 
-void Scene203::synchronize(Common::Serializer &s) {
-	Scene2xx::synchronize(s);
-	s.syncAsByte(_rhotundaEat2Fl);
-	s.syncAsByte(_rhotundaEatFl);
-}
-
 /*****************************************************************************/
 
 void Scene205::setup() {
@@ -1121,6 +1144,22 @@ void Scene205::setup() {
 	_scene->addActiveVocab(NOUN_PIRANHA);
 }
 
+Scene205::Scene205(MADSEngine *vm) : Scene2xx(vm) {
+	_lastFishTime = 0;
+	_chickenTime = 0;
+	_beingKicked = false;
+	_kernelMessage = -1;
+}
+
+void Scene205::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+
+	s.syncAsUint32LE(_lastFishTime);
+	s.syncAsUint32LE(_chickenTime);
+	s.syncAsByte(_beingKicked);
+	s.syncAsSint16LE(_kernelMessage);
+}
+
 void Scene205::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 1));
@@ -1394,15 +1433,30 @@ void Scene205::actions() {
 	_action._inProgress = false;
 }
 
-void Scene205::synchronize(Common::Serializer &s) {
-	Scene2xx::synchronize(s);
-	s.syncAsUint32LE(_lastFishTime);
-	s.syncAsUint32LE(_chickenTime);
-	s.syncAsByte(_beingKicked);
-	s.syncAsSint16LE(_kernelMessage);
+/*****************************************************************************/
+
+Scene207::Scene207(MADSEngine *vm) : Scene2xx(vm) {
+	_vultureFl = false;
+	_spiderFl = false;
+	_eyeFl = false;
+	_spiderHotspotId = -1;
+	_vultureHotspotId = -1;
+	_spiderTime = 0;
+	_vultureTime = 0;
 }
 
-/*****************************************************************************/
+void Scene207::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+
+	s.syncAsByte(_vultureFl);
+	s.syncAsByte(_spiderFl);
+	s.syncAsByte(_eyeFl);
+
+	s.syncAsSint32LE(_spiderHotspotId);
+	s.syncAsSint32LE(_vultureHotspotId);
+	s.syncAsSint32LE(_spiderTime);
+	s.syncAsSint32LE(_vultureTime);
+}
 
 void Scene207::setup() {
 	setPlayerSpritesPrefix();
@@ -1533,11 +1587,11 @@ void Scene207::preActions() {
 }
 
 void Scene207::actions() {
-	if (_action._savedFields._lookFlag) {
+	if (_action._savedFields._lookFlag)
 		_vm->_dialogs->show(20711);
-	} else if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOORWAY)) {
+	else if (_action.isAction(VERB_WALK_THROUGH, NOUN_DOORWAY))
 		_scene->_nextSceneId = 214;
-	} else {
+	else {
 		if ((_game._player._playerPos.x > 150) && (_game._player._playerPos.x < 189) &&
 		    (_game._player._playerPos.y > 111) && (_game._player._playerPos.y < 130)) {
 			if ((_game._player._playerPos.x <= 162) || (_game._player._playerPos.x >= 181) ||
@@ -1553,54 +1607,55 @@ void Scene207::actions() {
 			_eyeFl = false;
 		}
 
-		if (_action.isAction(VERB_LOOK, NOUN_DENSE_FOREST)) {
+		if (_action.isAction(VERB_LOOK, NOUN_DENSE_FOREST))
 			_vm->_dialogs->show(20701);
-		} else if (_action.isAction(VERB_LOOK, NOUN_HEDGE)) {
+		else if (_action.isAction(VERB_LOOK, NOUN_HEDGE))
 			_vm->_dialogs->show(20702);
-		} else if (_action.isAction(VERB_LOOK, NOUN_SKULL_AND_CROSSBONES)) {
+		else if (_action.isAction(VERB_LOOK, NOUN_SKULL_AND_CROSSBONES))
 			_vm->_dialogs->show(20703);
-		} else if (_action.isAction(VERB_LOOK, NOUN_CAULDRON)) {
+		else if (_action.isAction(VERB_LOOK, NOUN_CAULDRON))
 			_vm->_dialogs->show(20704);
-		} else if (_action.isAction(VERB_LOOK, NOUN_WITCHDOCTOR_HUT)) {
+		else if (_action.isAction(VERB_LOOK, NOUN_WITCHDOCTOR_HUT))
 			_vm->_dialogs->show(20705);
-		} else if (_action.isAction(VERB_LOOK, NOUN_PATH_TO_WEST)) {
+		else if (_action.isAction(VERB_LOOK, NOUN_PATH_TO_WEST))
 			_vm->_dialogs->show(20706);
-		} else if (_action.isAction(VERB_LOOK, NOUN_MOUNTAINS)) {
+		else if (_action.isAction(VERB_LOOK, NOUN_MOUNTAINS))
 			_vm->_dialogs->show(20707);
-		} else if (_action.isAction(VERB_LOOK, NOUN_ALOE_PLANT)) {
+		else if (_action.isAction(VERB_LOOK, NOUN_ALOE_PLANT))
 			_vm->_dialogs->show(20708);
-		} else if (_action.isAction(VERB_LOOK, NOUN_LAWN)) {
+		else if (_action.isAction(VERB_LOOK, NOUN_LAWN))
 			_vm->_dialogs->show(20709);
-		} else if (_action.isAction(VERB_LOOK, NOUN_VULTURE)) {
+		else if (_action.isAction(VERB_LOOK, NOUN_VULTURE))
 			_vm->_dialogs->show(20710);
-		} else if (_action.isAction(VERB_TAKE, NOUN_SKULL_AND_CROSSBONES)) {
+		else if (_action.isAction(VERB_TAKE, NOUN_SKULL_AND_CROSSBONES))
 			_vm->_dialogs->show(20712);
-		} else if (_action.isAction(VERB_TAKE, NOUN_ALOE_PLANT)) {
+		else if (_action.isAction(VERB_TAKE, NOUN_ALOE_PLANT))
 			_vm->_dialogs->show(20713);
-		} else if (_action.isAction(VERB_LOOK, NOUN_SPIDER)) {
+		else if (_action.isAction(VERB_LOOK, NOUN_SPIDER))
 			_vm->_dialogs->show(20714);
-		} else if (_action.isAction(VERB_TAKE, NOUN_SPIDER)) {
+		else if (_action.isAction(VERB_TAKE, NOUN_SPIDER))
 			_vm->_dialogs->show(20715);
-		} else
+		else
 			return;
 	}
 
 	_action._inProgress = false;
 }
 
-void Scene207::synchronize(Common::Serializer &s) {
-	Scene2xx::synchronize(s);
-	s.syncAsByte(_vultureFl);
-	s.syncAsByte(_spiderFl);
-	s.syncAsByte(_eyeFl);
+/*****************************************************************************/
 
-	s.syncAsSint32LE(_spiderHotspotId);
-	s.syncAsSint32LE(_vultureHotspotId);
-	s.syncAsSint32LE(_spiderTime);
-	s.syncAsSint32LE(_vultureTime);
+Scene208::Scene208(MADSEngine *vm) : Scene2xx(vm) {
+	_rhotundaTurnFl = false;
+	_boundingFl = false;
+	_rhotundaTime = 0;
 }
 
-/*****************************************************************************/
+void Scene208::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+	s.syncAsByte(_rhotundaTurnFl);
+	s.syncAsByte(_boundingFl);
+	s.syncAsSint32LE(_rhotundaTime);
+}
 
 void Scene208::setup() {
 	setPlayerSpritesPrefix();
@@ -1758,6 +1813,7 @@ void Scene208::subAction(int mode) {
 		_vm->_sound->command(20);
 		}
 		break;
+
 	case 2: {
 		switch (mode) {
 		case 1:
@@ -1765,25 +1821,32 @@ void Scene208::subAction(int mode) {
 			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 			_globals[kLeavesStatus] = 1;
 			break;
+
 		case 2:
 			_game._objects.setRoom(OBJ_BIG_LEAVES, 1);
 			_globals[kLeavesStatus] = 2;
 			updateTrap();
 			break;
+
 		case 3:
 			_scene->_sequences.remove(_globals._sequenceIndexes[3]);
 			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 			_game._objects.removeFromInventory(OBJ_TWINKIFRUIT, 1);
 			_vm->_sound->command(34);
 			break;
+
 		case 4:
 			_game._objects.removeFromInventory(OBJ_BURGER, 1);
 			_vm->_sound->command(33);
 			break;
+
 		case 5:
 			_game._objects.removeFromInventory(OBJ_DEAD_FISH, 1);
 			_vm->_sound->command(33);
 			break;
+
+		default:
+			break;
 		}
 
 		int oldVal = _globals._sequenceIndexes[5];
@@ -1794,10 +1857,14 @@ void Scene208::subAction(int mode) {
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
 		}
 		break;
+
 	case 3:
 		_game._player._visible = true;
 		_game._player._stepEnabled = true;
 		break;
+
+	default:
+		break;
 	}
 }
 
@@ -1809,18 +1876,17 @@ void Scene208::actions() {
 			_game._player._stepEnabled = false;
 			int msgIndex = _scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 1, 120, _game.getQuote(70));
 			_scene->_kernelMessages.setQuoted(msgIndex, 4, true);
-		} else if (_game._trigger == 1) {
+		} else if (_game._trigger == 1)
 			_scene->_nextSceneId = 203;
-		}
-	} else if (_action.isAction(VERB_WALK_TOWARDS, NOUN_FIELD_TO_SOUTH)) {
+	} else if (_action.isAction(VERB_WALK_TOWARDS, NOUN_FIELD_TO_SOUTH))
 		_scene->_nextSceneId = 212;
-	} else if (_action.isAction(VERB_TAKE, NOUN_PILE_OF_LEAVES) && (!_globals[kLeavesStatus] || _game._trigger)) {
+	else if (_action.isAction(VERB_TAKE, NOUN_PILE_OF_LEAVES) && (!_globals[kLeavesStatus] || _game._trigger)) {
 		subAction(1);
 		if (_game._player._stepEnabled)
 			_vm->_dialogs->showItem(OBJ_BIG_LEAVES, 0x326, 0);
-	} else if (_action.isAction(VERB_PUT, NOUN_BIG_LEAVES, NOUN_DEEP_PIT) && (_globals[kLeavesStatus] == 1 || _game._trigger)) {
+	} else if (_action.isAction(VERB_PUT, NOUN_BIG_LEAVES, NOUN_DEEP_PIT) && (_globals[kLeavesStatus] == 1 || _game._trigger))
 		subAction(2);
-	} else if (_action.isAction(VERB_PUT, NOUN_TWINKIFRUIT, NOUN_LEAF_COVERED_PIT)) {
+	else if (_action.isAction(VERB_PUT, NOUN_TWINKIFRUIT, NOUN_LEAF_COVERED_PIT)) {
 		subAction(3);
 		if (_game._player._stepEnabled) {
 			_game._player._stepEnabled = false;
@@ -1829,67 +1895,108 @@ void Scene208::actions() {
 		}
 	} else if (_action.isAction(VERB_PUT, NOUN_BURGER, NOUN_LEAF_COVERED_PIT)) {
 		subAction(4);
-		if (_game._player._stepEnabled) {
+		if (_game._player._stepEnabled)
 			_vm->_dialogs->show(20812);
-		}
 	} else if (_action.isAction(VERB_PUT, NOUN_DEAD_FISH, NOUN_LEAF_COVERED_PIT)) {
 		subAction(5);
-		if (_game._player._stepEnabled) {
+		if (_game._player._stepEnabled)
 			_vm->_dialogs->show(20812);
-		}
-	} else if (_action.isAction(VERB_LOOK, NOUN_CUMULOUS_CLOUD)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_CUMULOUS_CLOUD))
 		_vm->_dialogs->show(20801);
-	} else if (_action.isAction(VERB_LOOK, NOUN_OPEN_AREA_TO_WEST)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_OPEN_AREA_TO_WEST))
 		_vm->_dialogs->show(20802);
-	} else if (_action.isAction(VERB_LOOK, NOUN_THORNY_BUSH)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_THORNY_BUSH))
 		_vm->_dialogs->show(20803);
-	} else if (_action.isAction(VERB_LOOK, NOUN_ROCKS)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_ROCKS))
 		_vm->_dialogs->show(20804);
-	} else if (_action.isAction(VERB_LOOK, NOUN_SMALL_CACTUS)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_SMALL_CACTUS))
 		_vm->_dialogs->show(20805);
-	} else if (_action.isAction(VERB_TAKE, NOUN_SMALL_CACTUS)) {
+	else if (_action.isAction(VERB_TAKE, NOUN_SMALL_CACTUS))
 		_vm->_dialogs->show(20806);
-	} else if (_action.isAction(VERB_LOOK, NOUN_GRASSLAND_TO_EAST)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_GRASSLAND_TO_EAST))
 		_vm->_dialogs->show(20807);
-	} else if (_action.isAction(VERB_LOOK, NOUN_DEEP_PIT)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_DEEP_PIT))
 		_vm->_dialogs->show(20808);
-	} else if (_action.isAction(VERB_LOOK, NOUN_PILE_OF_LEAVES)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_PILE_OF_LEAVES))
 		_vm->_dialogs->show(20809);
-	} else if (_action.isAction(VERB_LOOK, NOUN_LEAF_COVERED_PIT)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_LEAF_COVERED_PIT)) {
 		if (_game._difficulty == DIFFICULTY_EASY)
 			_vm->_dialogs->show(20810);
 		else
 			_vm->_dialogs->show(20811);
-	} else if (_action.isAction(VERB_LOOK, NOUN_TREE) || _action.isAction(VERB_LOOK, NOUN_TREES)) {
+	} else if (_action.isAction(VERB_LOOK, NOUN_TREE) || _action.isAction(VERB_LOOK, NOUN_TREES))
 		_vm->_dialogs->show(20813);
-	} else if (_action.isAction(VERB_TAKE, NOUN_LEAF_COVERED_PIT)) {
+	else if (_action.isAction(VERB_TAKE, NOUN_LEAF_COVERED_PIT))
 		_vm->_dialogs->show(20814);
-	} else if (_action.isAction(VERB_LOOK, NOUN_HUGE_LEGS)) {
+	else if (_action.isAction(VERB_LOOK, NOUN_HUGE_LEGS))
 		_vm->_dialogs->show(20815);
-	} else if (_action.isAction(VERB_TAKE, NOUN_HUGE_LEGS) || _action.isAction(VERB_PULL, NOUN_HUGE_LEGS)) {
+	else if (_action.isAction(VERB_TAKE, NOUN_HUGE_LEGS) || _action.isAction(VERB_PULL, NOUN_HUGE_LEGS))
 		_vm->_dialogs->show(20816);
-	} else if (_action._savedFields._lookFlag == 0) {
-		return;
-	} else if (_globals[kRhotundaStatus] == 1) {
+	else if (_action._savedFields._lookFlag && (_globals[kRhotundaStatus] == 1))
 		_vm->_dialogs->show(20819);
-	} else if (_globals[kLeavesStatus] == 2) {
+	else if (_action._savedFields._lookFlag && (_globals[kLeavesStatus] == 2))
 		_vm->_dialogs->show(20818);
-	} else {
+	else if (_action._savedFields._lookFlag)
 		_vm->_dialogs->show(20817);
-	}
+	else
+		return;
 
 	_action._inProgress = false;
 }
 
-void Scene208::synchronize(Common::Serializer &s) {
-	Scene2xx::synchronize(s);
-	s.syncAsByte(_rhotundaTurnFl);
-	s.syncAsByte(_boundingFl);
+/*****************************************************************************/
 
-	s.syncAsSint32LE(_rhotundaTime);
+Scene209::Scene209(MADSEngine *vm) : Scene2xx(vm) {
+	_dodgeFl = false;
+	_forceDodgeFl = false;
+	_pitchFl = false;
+	_fallFl = false;
+	_forceFallFl = false;
+	_playingAnimFl = false;
+	_shouldFallFl = false;
+	_shouldDodgeFl = false;
+	_monkeyPosition = 0;
+	_counter = 0;
+	_pauseMode = 0;
+	_binocularsDroppedFl = false;
+	_startShootingInTimerFl = false;
+	_dialogAbortVal = 0;
+	_playingDialogFl = false;
+	_shootMissedLastFl = false;
+	_removeMonkeyFl = false;
+	_shootReadyFl = false;
+	_pauseCounterThreshold = 0;
+	_pauseCounter = 0;
 }
 
-/*****************************************************************************/
+void Scene209::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+	s.syncAsByte(_dodgeFl);
+	s.syncAsByte(_forceDodgeFl);
+	s.syncAsByte(_shouldDodgeFl);
+	s.syncAsByte(_pitchFl);
+	s.syncAsByte(_fallFl);
+	s.syncAsByte(_forceFallFl);
+	s.syncAsByte(_shouldFallFl);
+	s.syncAsByte(_playingAnimFl);
+	s.syncAsByte(_playingDialogFl);
+
+	s.syncAsSint32LE(_pauseMode);
+	s.syncAsSint32LE(_pauseCounterThreshold);
+	s.syncAsSint32LE(_pauseCounter);
+
+	s.syncAsByte(_removeMonkeyFl);
+
+	s.syncAsSint32LE(_monkeyPosition);
+
+	s.syncAsByte(_shootReadyFl);
+	s.syncAsByte(_startShootingInTimerFl);
+	s.syncAsByte(_shootMissedLastFl);
+	s.syncAsByte(_binocularsDroppedFl);
+
+	s.syncAsSint32LE(_dialogAbortVal);
+	s.syncAsSint32LE(_counter);
+}
 
 void Scene209::setup() {
 	setPlayerSpritesPrefix();
@@ -3481,37 +3588,42 @@ void Scene209::actions() {
 	}
 }
 
-void Scene209::synchronize(Common::Serializer &s) {
-	Scene2xx::synchronize(s);
-	s.syncAsByte(_dodgeFl);
-	s.syncAsByte(_forceDodgeFl);
-	s.syncAsByte(_shouldDodgeFl);
-	s.syncAsByte(_pitchFl);
-	s.syncAsByte(_fallFl);
-	s.syncAsByte(_forceFallFl);
-	s.syncAsByte(_shouldFallFl);
-	s.syncAsByte(_playingAnimFl);
-	s.syncAsByte(_playingDialogFl);
+/*****************************************************************************/
 
-	s.syncAsSint32LE(_pauseMode);
-	s.syncAsSint32LE(_pauseCounterThreshold);
-	s.syncAsSint32LE(_pauseCounter);
+Scene210::Scene210(MADSEngine *vm) : Scene2xx(vm) {
+	_curDialogNode = -1;
+	_nextHandsPlace = 0;
+	_twinkleAnimationType = 0;
+	_twinklesCurrentFrame = 0;
+	_shouldTalk = false;
+	_shouldFaceRex = false;
+	_shouldMoveHead = false;
+	_stopWalking = false;
+	_twinklesTalking = false;
+	_twinklesTalk2 = false;
+	_doorway = 0;
+	_subQuote2 = "";
+}
 
-	s.syncAsByte(_removeMonkeyFl);
+void Scene210::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+	s.syncAsSint32LE(_curDialogNode);
+	s.syncAsSint32LE(_nextHandsPlace);
+	s.syncAsSint32LE(_twinkleAnimationType);
+	s.syncAsSint32LE(_twinklesCurrentFrame);
 
-	s.syncAsSint32LE(_monkeyPosition);
+	s.syncAsByte(_shouldTalk);
+	s.syncAsByte(_shouldFaceRex);
+	s.syncAsByte(_shouldMoveHead);
+	s.syncAsByte(_stopWalking);
+	s.syncAsByte(_twinklesTalking);
+	s.syncAsByte(_twinklesTalk2);
 
-	s.syncAsByte(_shootReadyFl);
-	s.syncAsByte(_startShootingInTimerFl);
-	s.syncAsByte(_shootMissedLastFl);
-	s.syncAsByte(_binocularsDroppedFl);
+	s.syncAsSint32LE(_doorway);
 
-	s.syncAsSint32LE(_dialogAbortVal);
-	s.syncAsSint32LE(_counter);
+	s.syncString(_subQuote2);
 }
 
-/*****************************************************************************/
-
 void Scene210::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -4482,27 +4594,26 @@ void Scene210::actions() {
 	_action._inProgress = false;
 }
 
-void Scene210::synchronize(Common::Serializer &s) {
-	Scene2xx::synchronize(s);
-	s.syncAsSint32LE(_curDialogNode);
-	s.syncAsSint32LE(_nextHandsPlace);
-	s.syncAsSint32LE(_twinkleAnimationType);
-	s.syncAsSint32LE(_twinklesCurrentFrame);
+/*------------------------------------------------------------------------*/
 
-	s.syncAsByte(_shouldTalk);
-	s.syncAsByte(_shouldFaceRex);
-	s.syncAsByte(_shouldMoveHead);
-	s.syncAsByte(_stopWalking);
-	s.syncAsByte(_twinklesTalking);
-	s.syncAsByte(_twinklesTalk2);
+Scene211::Scene211(MADSEngine *vm) : Scene2xx(vm) {
+	_ambushFl = false;
+	_wakeFl = false;
+	_monkeyFrame = 0;
+	_scrollY = 0;
+	_monkeyTime = 0;
+}
 
-	s.syncAsSint32LE(_doorway);
+void Scene211::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+	s.syncAsByte(_ambushFl);
+	s.syncAsByte(_wakeFl);
 
-	s.syncString(_subQuote2);
+	s.syncAsSint32LE(_monkeyFrame);
+	s.syncAsSint32LE(_scrollY);
+	s.syncAsUint32LE(_monkeyTime);
 }
 
-/*------------------------------------------------------------------------*/
-
 void Scene211::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -4767,16 +4878,6 @@ void Scene211::actions() {
 	_action._inProgress = false;
 }
 
-void Scene211::synchronize(Common::Serializer &s) {
-	Scene2xx::synchronize(s);
-	s.syncAsByte(_ambushFl);
-	s.syncAsByte(_wakeFl);
-
-	s.syncAsSint32LE(_monkeyFrame);
-	s.syncAsSint32LE(_scrollY);
-	s.syncAsUint32LE(_monkeyTime);
-}
-
 /*------------------------------------------------------------------------*/
 
 void Scene212::setup() {
@@ -4903,6 +5004,18 @@ void Scene213::actions() {
 
 /*------------------------------------------------------------------------*/
 
+Scene214::Scene214(MADSEngine *vm) : Scene2xx(vm) {
+	_devilTime = 0;
+	_devilRunningFl = false;
+}
+
+void Scene214::synchronize(Common::Serializer &s) {
+	Scene2xx::synchronize(s);
+
+	s.syncAsUint32LE(_devilTime);
+	s.syncAsByte(_devilRunningFl);
+}
+
 void Scene214::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -5104,13 +5217,6 @@ void Scene214::actions() {
 	_action._inProgress = false;
 }
 
-void Scene214::synchronize(Common::Serializer &s) {
-	Scene2xx::synchronize(s);
-	s.syncAsUint32LE(_devilTime);
-
-	s.syncAsByte(_devilRunningFl);
-}
-
 /*------------------------------------------------------------------------*/
 
 void Scene215::setup() {
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index b4f4866..750d45e 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -54,7 +54,8 @@ private:
 	bool _pterodactylFlag;
 
 public:
-	Scene201(MADSEngine *vm) : Scene2xx(vm), _pterodactylFlag(false) {}
+	Scene201(MADSEngine *vm);
+
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
@@ -75,9 +76,8 @@ private:
 	int subStep4(int randVal);
 
 public:
-	Scene202(MADSEngine *vm) : Scene2xx(vm), _activeMsgFl(false), _ladderTopFl(false), _waitingMeteoFl(false),
-		_ladderHotspotId(-1), _meteoClock1(0), _meteoClock2(0), _toStationFl(false), _toTeleportFl(false),
-		_lastRoute(0), _stationCounter(0), _meteoFrame(0) {}
+	Scene202(MADSEngine *vm);
+
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
@@ -93,7 +93,8 @@ private:
 	bool _rhotundaEat2Fl, _rhotundaEatFl;
 
 public:
-	Scene203(MADSEngine *vm) : Scene2xx(vm), _rhotundaEat2Fl(false), _rhotundaEatFl(false) {}
+	Scene203(MADSEngine *vm);
+
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
@@ -112,7 +113,7 @@ private:
 	void handleWomanSpeech(int quoteId);
 
 public:
-	Scene205(MADSEngine *vm) : Scene2xx(vm), _lastFishTime(0), _chickenTime(0) {}
+	Scene205(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();
@@ -131,7 +132,8 @@ private:
 	void moveSpider();
 
 public:
-	Scene207(MADSEngine *vm) : Scene2xx(vm), _vultureFl(false), _spiderFl(false), _spiderHotspotId(-1), _vultureHotspotId(-1), _spiderTime(0), _vultureTime(0) {}
+	Scene207(MADSEngine *vm);
+
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
@@ -149,7 +151,8 @@ private:
 	void subAction(int mode);
 
 public:
-	Scene208(MADSEngine *vm) : Scene2xx(vm), _rhotundaTurnFl(false), _boundingFl(false), _rhotundaTime(0) {}
+	Scene208(MADSEngine *vm);
+
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
@@ -194,10 +197,8 @@ private:
 	void handleMonkey2();
 
 public:
-	Scene209(MADSEngine *vm) : Scene2xx(vm), _dodgeFl(false), _forceDodgeFl(false), _pitchFl(false), _fallFl(false), _forceFallFl(false),
-	   _playingAnimFl(false), _shouldFallFl(false), _shouldDodgeFl(false), _monkeyPosition(0), _counter(0), _pauseMode(0),
-	   _binocularsDroppedFl(false), _startShootingInTimerFl(false), _dialogAbortVal(0), _playingDialogFl(false),_shootMissedLastFl(false),
-	   _removeMonkeyFl(false), _shootReadyFl(false), _pauseCounterThreshold(0), _pauseCounter(0) {}
+	Scene209(MADSEngine *vm);
+
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
@@ -234,9 +235,8 @@ private:
 	void newNode(int node);
 	void restoreDialogNode(int node, int msgId, int posY);
 public:
-	Scene210(MADSEngine *vm) : Scene2xx(vm), _curDialogNode(-1), _nextHandsPlace(0), _twinkleAnimationType(0), _twinklesCurrentFrame(0),
-		_shouldTalk(false), _shouldFaceRex(false), _shouldMoveHead(false), _stopWalking(false), _twinklesTalking(false),
-		_twinklesTalk2(false), _doorway(0), _subQuote2("") {}
+	Scene210(MADSEngine *vm);
+
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
@@ -252,7 +252,8 @@ private:
 	uint32 _monkeyTime;
 
 public:
-	Scene211(MADSEngine *vm) : Scene2xx(vm), _ambushFl(false), _wakeFl(false), _monkeyFrame(0), _scrollY(0), _monkeyTime(0) {}
+	Scene211(MADSEngine *vm);
+
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
@@ -287,7 +288,7 @@ private:
 	bool _devilRunningFl;
 
 public:
-	Scene214(MADSEngine *vm) : Scene2xx(vm), _devilTime(0), _devilRunningFl(false) {}
+	Scene214(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();


Commit: 904796f3a5dfb965995082614d69542452387bbc
    https://github.com/scummvm/scummvm/commit/904796f3a5dfb965995082614d69542452387bbc
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-22T18:08:56+02:00

Commit Message:
MADS: Move contructors out of the header in scene group 3

Changed paths:
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 5391b5f..06c4eb6 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -266,6 +266,16 @@ void Scene301::step() {
 
 /*------------------------------------------------------------------------*/
 
+Scene302::Scene302(MADSEngine *vm) : Scene3xx(vm) {
+	_oldFrame = 0;
+}
+
+void Scene302::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+
+	s.syncAsSint32LE(_oldFrame);
+}
+
 void Scene302::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -302,11 +312,6 @@ void Scene302::step() {
 	}
 }
 
-void Scene302::synchronize(Common::Serializer &s) {
-	Scene3xx::synchronize(s);
-	s.syncAsSint32LE(_oldFrame);
-}
-
 /*------------------------------------------------------------------------*/
 
 void Scene303::setup() {
@@ -336,6 +341,16 @@ void Scene303::step() {
 
 /*------------------------------------------------------------------------*/
 
+Scene304::Scene304(MADSEngine *vm) : Scene3xx(vm) {
+	_explosionSpriteId = -1;
+}
+
+void Scene304::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+
+	s.syncAsSint32LE(_explosionSpriteId);
+}
+
 void Scene304::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -460,12 +475,45 @@ void Scene304::step() {
 	}
 }
 
-void Scene304::synchronize(Common::Serializer &s) {
-	Scene3xx::synchronize(s);
-	s.syncAsSint32LE(_explosionSpriteId);
+/*------------------------------------------------------------------------*/
+
+Scene307::Scene307(MADSEngine *vm) : Scene3xx(vm) {
+	_afterPeeingFl = false;
+	_duringPeeingFl = false;
+	_grateOpenedFl = false;
+	_activePrisonerFl = false;
+
+	_animationMode = -1;
+	_prisonerMessageId = -1;
+	_fieldCollisionCounter = -1;
+
+	_lastFrameTime = 0;
+	_guardTime = 0;
+	_prisonerTimer = 0;
+
+	_subQuote2 = "";
 }
 
-/*------------------------------------------------------------------------*/
+void Scene307::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+
+	_forceField.synchronize(s);
+
+	s.syncAsByte(_afterPeeingFl);
+	s.syncAsByte(_duringPeeingFl);
+	s.syncAsByte(_grateOpenedFl);
+	s.syncAsByte(_activePrisonerFl);
+
+	s.syncAsSint32LE(_animationMode);
+	s.syncAsSint32LE(_prisonerMessageId);
+	s.syncAsSint32LE(_fieldCollisionCounter);
+
+	s.syncAsUint32LE(_lastFrameTime);
+	s.syncAsUint32LE(_guardTime);
+	s.syncAsUint32LE(_prisonerTimer);
+
+	s.syncString(_subQuote2);
+}
 
 void Scene307::setup() {
 	setPlayerSpritesPrefix();
@@ -1138,27 +1186,6 @@ void Scene307::actions() {
 	_action._inProgress = false;
 }
 
-void Scene307::synchronize(Common::Serializer &s) {
-	Scene3xx::synchronize(s);
-
-	_forceField.synchronize(s);
-
-	s.syncAsByte(_afterPeeingFl);
-	s.syncAsByte(_duringPeeingFl);
-	s.syncAsByte(_grateOpenedFl);
-	s.syncAsByte(_activePrisonerFl);
-
-	s.syncAsSint32LE(_animationMode);
-	s.syncAsSint32LE(_prisonerMessageId);
-	s.syncAsSint32LE(_fieldCollisionCounter);
-
-	s.syncAsUint32LE(_lastFrameTime);
-	s.syncAsUint32LE(_guardTime);
-	s.syncAsUint32LE(_prisonerTimer);
-
-	s.syncString(_subQuote2);
-}
-
 /*------------------------------------------------------------------------*/
 
 void Scene308::setup() {
@@ -1290,6 +1317,27 @@ void Scene308::synchronize(Common::Serializer &s) {
 
 /*------------------------------------------------------------------------*/
 
+Scene309::Scene309(MADSEngine *vm) : Scene3xx(vm) {
+	for (int i = 0; i < 3; i++) {
+		_characterSpriteIndexes[i] = -1;
+		_messagesIndexes[i] = -1;
+	}
+	
+	_lastFrame = -1;
+}
+
+void Scene309::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+
+	_forceField.synchronize(s);
+
+	for (int i = 0; i < 3; ++i)
+		s.syncAsSint32LE(_characterSpriteIndexes[i]);
+	for (int i = 0; i < 3; ++i)
+		s.syncAsSint32LE(_messagesIndexes[i]);
+	s.syncAsSint32LE(_lastFrame);
+}
+
 void Scene309::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -1473,18 +1521,6 @@ void Scene309::step() {
 		_scene->_nextSceneId = 308;
 }
 
-void Scene309::synchronize(Common::Serializer &s) {
-	Scene3xx::synchronize(s);
-
-	_forceField.synchronize(s);
-
-	for (int i = 0; i < 3; ++i)
-		s.syncAsSint32LE(_characterSpriteIndexes[i]);
-	for (int i = 0; i < 3; ++i)
-		s.syncAsSint32LE(_messagesIndexes[i]);
-	s.syncAsSint32LE(_lastFrame);
-}
-
 /*------------------------------------------------------------------------*/
 
 void Scene310::setup() {
@@ -1526,6 +1562,16 @@ void Scene310::synchronize(Common::Serializer &s) {
 
 /*------------------------------------------------------------------------*/
 
+Scene311::Scene311(MADSEngine *vm) : Scene3xx(vm) {
+	_checkGuardFl = false;
+}
+
+void Scene311::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+
+	s.syncAsByte(_checkGuardFl);
+}
+
 void Scene311::setup() {
 	if (_scene->_currentSceneId == 391)
 		_globals[kSexOfRex] = REX_MALE;
@@ -1813,12 +1859,6 @@ void Scene311::actions() {
 	_action._inProgress = false;
 }
 
-void Scene311::synchronize(Common::Serializer &s) {
-	Scene3xx::synchronize(s);
-
-	s.syncAsByte(_checkGuardFl);
-}
-
 /*------------------------------------------------------------------------*/
 
 void Scene313::setup() {
@@ -2350,6 +2390,46 @@ void Scene316::actions() {
 
 /*------------------------------------------------------------------------*/
 
+Scene318::Scene318(MADSEngine *vm) : Scene3xx(vm) {
+	_dropTimer = 0;
+
+	_lastFrame = -1;
+	_animMode = -1;
+	_internCounter = -1;
+	_counter = -1;
+
+	_dialogFl = false;
+	_internTalkingFl = false;
+	_internWalkingFl = false;
+	_internVisibleFl = false;
+	_explosionFl = false;
+
+	_lastFrameCounter = 0;
+
+	_subQuote2 = "";
+}
+
+void Scene318::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+
+	s.syncAsUint32LE(_dropTimer);
+
+	s.syncAsSint32LE(_lastFrame);
+	s.syncAsSint32LE(_animMode);
+	s.syncAsSint32LE(_internCounter);
+	s.syncAsSint32LE(_counter);
+
+	s.syncAsByte(_dialogFl);
+	s.syncAsByte(_internTalkingFl);
+	s.syncAsByte(_internWalkingFl);
+	s.syncAsByte(_internVisibleFl);
+	s.syncAsByte(_explosionFl);
+
+	s.syncAsUint32LE(_lastFrameCounter);
+
+	s.syncString(_subQuote2);
+}
+
 void Scene318::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -2932,29 +3012,42 @@ void Scene318::actions() {
 	_action._inProgress = false;
 }
 
-void Scene318::synchronize(Common::Serializer &s) {
-	Scene3xx::synchronize(s);
+/*------------------------------------------------------------------------*/
 
-	s.syncAsUint32LE(_dropTimer);
+Scene319::Scene319(MADSEngine *vm) : Scene3xx(vm) {
+	_animMode = -1;
+	_animFrame = -1;
+	_nextAction1 = -1;
+	_nextAction2 = -1;
+	_slacheMode = -1;
+	_slacheTopic = -1;
+	_slachePosY = -1;
 
-	s.syncAsSint32LE(_lastFrame);
-	s.syncAsSint32LE(_animMode);
-	s.syncAsSint32LE(_internCounter);
-	s.syncAsSint32LE(_counter);
+	_slacheTalkingFl = false;
+	_slacheReady = false;
+	_slacheInitFl = false;
 
-	s.syncAsByte(_dialogFl);
-	s.syncAsByte(_internTalkingFl);
-	s.syncAsByte(_internWalkingFl);
-	s.syncAsByte(_internVisibleFl);
-	s.syncAsByte(_explosionFl);
+	_subQuote2 = "";
+}
 
-	s.syncAsUint32LE(_lastFrameCounter);
+void Scene319::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+
+	s.syncAsUint32LE(_animMode);
+	s.syncAsUint32LE(_animFrame);
+	s.syncAsUint32LE(_nextAction1);
+	s.syncAsUint32LE(_nextAction2);
+	s.syncAsUint32LE(_slacheMode);
+	s.syncAsUint32LE(_slacheTopic);
+	s.syncAsUint32LE(_slachePosY);
+
+	s.syncAsByte(_slacheTalkingFl);
+	s.syncAsByte(_slacheReady);
+	s.syncAsByte(_slacheInitFl);
 
 	s.syncString(_subQuote2);
 }
 
-/*------------------------------------------------------------------------*/
-
 void Scene319::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -3413,26 +3506,31 @@ void Scene319::actions() {
 	_action._inProgress = false;
 }
 
-void Scene319::synchronize(Common::Serializer &s) {
-	Scene3xx::synchronize(s);
-
-	s.syncAsUint32LE(_animMode);
-	s.syncAsUint32LE(_animFrame);
-	s.syncAsUint32LE(_nextAction1);
-	s.syncAsUint32LE(_nextAction2);
-	s.syncAsUint32LE(_slacheMode);
-	s.syncAsUint32LE(_slacheTopic);
-	s.syncAsUint32LE(_slachePosY);
+/*------------------------------------------------------------------------*/
 
-	s.syncAsByte(_slacheTalkingFl);
-	s.syncAsByte(_slacheReady);
-	s.syncAsByte(_slacheInitFl);
+Scene320::Scene320(MADSEngine *vm) : Scene300s(vm) {
+	_blinkFl = false;
+	_flippedFl = false;
 
-	s.syncString(_subQuote2);
+	_buttonId = -1;
+	_lastFrame = -1;
+	_leftItemId = -1;
+	_posX = -1;
+	_rightItemId = -1;
 }
 
+void Scene320::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
 
-/*------------------------------------------------------------------------*/
+	s.syncAsByte(_blinkFl);
+	s.syncAsByte(_flippedFl);
+
+	s.syncAsSint32LE(_buttonId);
+	s.syncAsSint32LE(_lastFrame);
+	s.syncAsSint32LE(_leftItemId);
+	s.syncAsSint32LE(_posX);
+	s.syncAsSint32LE(_rightItemId);
+}
 
 void Scene320::setup() {
 	setPlayerSpritesPrefix();
@@ -3740,19 +3838,6 @@ void Scene320::actions() {
 	_action._inProgress = false;
 }
 
-void Scene320::synchronize(Common::Serializer &s) {
-	Scene3xx::synchronize(s);
-
-	s.syncAsByte(_blinkFl);
-	s.syncAsByte(_flippedFl);
-
-	s.syncAsSint32LE(_buttonId);
-	s.syncAsSint32LE(_lastFrame);
-	s.syncAsSint32LE(_leftItemId);
-	s.syncAsSint32LE(_posX);
-	s.syncAsSint32LE(_rightItemId);
-}
-
 /*------------------------------------------------------------------------*/
 
 void Scene321::setup() {
@@ -4014,6 +4099,34 @@ void Scene351::actions() {
 
 /*------------------------------------------------------------------------*/
 
+Scene352::Scene352(MADSEngine *vm) : Scene3xx(vm) {
+	_vaultOpenFl = false;
+	_mustPutArmDownFl = false;
+	_leaveRoomFl = false;
+
+	_tapePlayerHotspotIdx = -1;
+	_hotspot1Idx = -1;
+	_hotspot2Idx = -1;
+	_lampHostpotIdx = -1;
+	_commonSequenceIdx = -1;
+	_commonSpriteIndex = -1;
+}
+
+void Scene352::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+
+	s.syncAsByte(_vaultOpenFl);
+	s.syncAsByte(_mustPutArmDownFl);
+	s.syncAsByte(_leaveRoomFl);
+
+	s.syncAsSint32LE(_tapePlayerHotspotIdx);
+	s.syncAsSint32LE(_hotspot1Idx);
+	s.syncAsSint32LE(_hotspot2Idx);
+	s.syncAsSint32LE(_lampHostpotIdx);
+	s.syncAsSint32LE(_commonSequenceIdx);
+	s.syncAsSint32LE(_commonSpriteIndex);
+}
+
 void Scene352::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -4551,21 +4664,6 @@ void Scene352::actions() {
 		return;
 }
 
-void Scene352::synchronize(Common::Serializer &s) {
-	Scene3xx::synchronize(s);
-
-	s.syncAsByte(_vaultOpenFl);
-	s.syncAsByte(_mustPutArmDownFl);
-	s.syncAsByte(_leaveRoomFl);
-
-	s.syncAsSint32LE(_tapePlayerHotspotIdx);
-	s.syncAsSint32LE(_hotspot1Idx);
-	s.syncAsSint32LE(_hotspot2Idx);
-	s.syncAsSint32LE(_lampHostpotIdx);
-	s.syncAsSint32LE(_commonSequenceIdx);
-	s.syncAsSint32LE(_commonSpriteIndex);
-}
-
 /*------------------------------------------------------------------------*/
 
 void Scene353::setup() {
@@ -4803,6 +4901,16 @@ void Scene358::actions() {
 
 /*------------------------------------------------------------------------*/
 
+Scene359::Scene359(MADSEngine *vm) : Scene3xx(vm) {
+	_cardHotspotId = -1;
+}
+
+void Scene359::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+
+	s.syncAsSint32LE(_cardHotspotId);
+}
+
 void Scene359::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -4938,13 +5046,6 @@ void Scene359::actions() {
 	_action._inProgress = false;
 }
 
-void Scene359::synchronize(Common::Serializer &s) {
-	Scene3xx::synchronize(s);
-
-	s.syncAsSint32LE(_cardHotspotId);
-}
-
-
 /*------------------------------------------------------------------------*/
 
 void Scene360::setup() {
@@ -5509,6 +5610,18 @@ void Scene388::actions() {
 
 /*------------------------------------------------------------------------*/
 
+Scene389::Scene389(MADSEngine *vm) : Scene300s(vm) {
+	_monsterTime = 0;
+	_circularQuoteId = -1;
+}
+
+void Scene389::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+
+	s.syncAsUint32LE(_monsterTime);
+	s.syncAsSint32LE(_circularQuoteId);
+}
+
 void Scene389::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -5586,13 +5699,6 @@ void Scene389::actions() {
 	_action._inProgress = false;
 }
 
-void Scene389::synchronize(Common::Serializer &s) {
-	Scene3xx::synchronize(s);
-
-	s.syncAsUint32LE(_monsterTime);
-	s.syncAsSint32LE(_circularQuoteId);
-}
-
 /*------------------------------------------------------------------------*/
 
 void Scene390::setup() {
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index b42238d..84c8fe7 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -94,7 +94,7 @@ private:
 	int _oldFrame;
 
 public:
-	Scene302(MADSEngine *vm) : Scene3xx(vm), _oldFrame(0) {}
+	Scene302(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();
@@ -116,7 +116,7 @@ private:
 	int _explosionSpriteId;
 
 public:
-	Scene304(MADSEngine *vm) : Scene3xx(vm), _explosionSpriteId(-1) {}
+	Scene304(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();
@@ -153,7 +153,7 @@ private:
 	void handlePrisonerSpeech(int firstQuoteId, int number, long timeout);
 
 public:
-	Scene307(MADSEngine *vm) : Scene3xx(vm) {}
+	Scene307(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();
@@ -183,7 +183,7 @@ private:
 	int _lastFrame;
 
 public:
-	Scene309(MADSEngine *vm) : Scene3xx(vm) {}
+	Scene309(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();
@@ -209,7 +209,7 @@ private:
 	bool _checkGuardFl;
 
 public:
-	Scene311(MADSEngine *vm) : Scene3xx(vm) {}
+	Scene311(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();
@@ -268,7 +268,7 @@ private:
 	void handleInternDialog(int quoteId, int quoteNum, uint32 timeout);
 
 public:
-	Scene318(MADSEngine *vm) : Scene3xx(vm) {}
+	Scene318(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();
@@ -297,7 +297,7 @@ private:
 	void handleRexDialogues(int quote);
 	void handleSlacheDialogs(int quoteId, int counter, uint32 timer);
 public:
-	Scene319(MADSEngine *vm) : Scene3xx(vm) {}
+	Scene319(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();
@@ -322,7 +322,7 @@ private:
 	int _rightItemId;
 
 public:
-	Scene320(MADSEngine *vm) : Scene300s(vm) {}
+	Scene320(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();
@@ -376,7 +376,7 @@ private:
 	void putArmDown(bool corridorExit, bool doorwayExit);
 
 public:
-	Scene352(MADSEngine *vm) : Scene3xx(vm) {}
+	Scene352(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();
@@ -429,7 +429,7 @@ private:
 	int _cardHotspotId;
 
 public:
-	Scene359(MADSEngine *vm) : Scene3xx(vm) {}
+	Scene359(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();
@@ -497,7 +497,7 @@ private:
 	int _circularQuoteId;
 
 public:
-	Scene389(MADSEngine *vm) : Scene300s(vm) {}
+	Scene389(MADSEngine *vm);
 
 	virtual void setup();
 	virtual void enter();


Commit: 542adf8ba441ccfbff621b303e2d4916f487d8af
    https://github.com/scummvm/scummvm/commit/542adf8ba441ccfbff621b303e2d4916f487d8af
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-22T18:39:59+02:00

Commit Message:
MADS: Move contructors out of the header in scene group 4

Changed paths:
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes4.h



diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index 4156842..cb5363b 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -93,9 +93,9 @@ void Scene4xx::sceneEntrySound() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene401::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
+Scene401::Scene401(MADSEngine *vm) : Scene4xx(vm), _destPos(0, 0) {
+	_northFl = false;
+	_timer = 0;
 }
 
 void Scene401::synchronize(Common::Serializer &s) {
@@ -107,6 +107,11 @@ void Scene401::synchronize(Common::Serializer &s) {
 	s.syncAsUint32LE(_timer);
 }
 
+void Scene401::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
 void Scene401::enter() {
 	if (_scene->_priorSceneId != -2)
 		_northFl = false;
@@ -231,19 +236,43 @@ void Scene401::actions() {
 }
 
 /*------------------------------------------------------------------------*/
-void Scene402::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
 
-	_scene->addActiveVocab(NOUN_BARTENDER);
-	_scene->addActiveVocab(NOUN_ALIEN_LIQUOR);
-	_scene->addActiveVocab(VERB_DRINK);
-	_scene->addActiveVocab(NOUN_BINOCULARS);
-	_scene->addActiveVocab(VERB_WALKTO);
-	_scene->addActiveVocab(NOUN_CREDIT_CHIP);
-	_scene->addActiveVocab(VERB_TAKE);
-	_scene->addActiveVocab(NOUN_REPAIR_LIST);
-	_scene->addActiveVocab(VERB_LOOK_AT);
+Scene402::Scene402(MADSEngine *vm) : Scene4xx(vm) {
+	_lightOn = false;
+	_blowingSmoke = false;
+	_leftWomanMoving = false;
+	_rightWomanMoving = false;
+	_firstTalkToGirlInChair = false;
+	_waitingGinnyMove = false;
+	_ginnyLooking = false;
+	_bigBeatFl = false;
+	_roxOnStool = false;
+	_bartenderSteady = false;
+	_bartenderHandsHips = false;
+	_bartenderLooksLeft = false;
+	_bartenderReady = false;
+	_bartenderTalking = false;
+	_bartenderCalled = false;
+	_conversationFl = false;
+	_activeTeleporter = false;
+	_activeArrows = false;
+	_activeArrow1 = false;
+	_activeArrow2 = false;
+	_activeArrow3 = false;
+	_cutSceneReady = false;
+	_cutSceneNeeded = false;
+	_helgaReady = false;
+	_refuseAlienLiquor = false;
+
+	_drinkTimer = -1;
+	_beatCounter = -1;
+	_bartenderMode = -1;
+	_bartenderDialogNode = -1;
+	_bartenderCurrentQuestion = -1;
+	_helgaTalkMode = -1;
+	_roxMode = -1;
+	_rexMode = -1;
+	_talkTimer = -1;
 }
 
 void Scene402::synchronize(Common::Serializer &s) {
@@ -286,6 +315,21 @@ void Scene402::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_talkTimer);
 }
 
+void Scene402::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+
+	_scene->addActiveVocab(NOUN_BARTENDER);
+	_scene->addActiveVocab(NOUN_ALIEN_LIQUOR);
+	_scene->addActiveVocab(VERB_DRINK);
+	_scene->addActiveVocab(NOUN_BINOCULARS);
+	_scene->addActiveVocab(VERB_WALKTO);
+	_scene->addActiveVocab(NOUN_CREDIT_CHIP);
+	_scene->addActiveVocab(VERB_TAKE);
+	_scene->addActiveVocab(NOUN_REPAIR_LIST);
+	_scene->addActiveVocab(VERB_LOOK_AT);
+}
+
 void Scene402::setDialogNode(int node) {
 	if (node > 0)
 		_bartenderDialogNode = node;
@@ -2514,6 +2558,16 @@ void Scene405::actions() {
 
 /*------------------------------------------------------------------------*/
 
+Scene406::Scene406(MADSEngine *vm) : Scene4xx(vm) {
+	_hitStorageDoor = false;
+}
+
+void Scene406::synchronize(Common::Serializer &s) {
+	Scene4xx::synchronize(s);
+
+	s.syncAsByte(_hitStorageDoor);
+}
+
 void Scene406::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -2717,13 +2771,19 @@ void Scene406::actions() {
 	_action._inProgress = false;
 }
 
-void Scene406::synchronize(Common::Serializer &s) {
-	Scene4xx::synchronize(s);
+/*------------------------------------------------------------------------*/
 
-	s.syncAsByte(_hitStorageDoor);
+Scene407::Scene407(MADSEngine *vm) : Scene4xx(vm), _destPos(0, 0) {
+	_fromNorth = false;
 }
 
-/*------------------------------------------------------------------------*/
+void Scene407::synchronize(Common::Serializer &s) {
+	Scene4xx::synchronize(s);
+
+	s.syncAsByte(_fromNorth);
+	s.syncAsSint16LE(_destPos.x);
+	s.syncAsSint16LE(_destPos.y);
+}
 
 void Scene407::setup() {
 	setPlayerSpritesPrefix();
@@ -2831,14 +2891,6 @@ void Scene407::actions() {
 	_action._inProgress = false;
 }
 
-void Scene407::synchronize(Common::Serializer &s) {
-	Scene4xx::synchronize(s);
-
-	s.syncAsByte(_fromNorth);
-	s.syncAsSint16LE(_destPos.x);
-	s.syncAsSint16LE(_destPos.y);
-}
-
 /*------------------------------------------------------------------------*/
 
 void Scene408::setup() {
@@ -3214,6 +3266,30 @@ void Scene410::actions() {
 
 /*------------------------------------------------------------------------*/
 
+Scene411::Scene411(MADSEngine *vm) : Scene4xx(vm) {
+	_curAnimationFrame = -1;
+	_newIngredient = -1;
+	_newQuantity = -1;
+	_resetFrame = -1;
+	_badThreshold = -1;
+
+	_killRox = false;
+	_makeMushroomCloud = false;
+}
+
+void Scene411::synchronize(Common::Serializer &s) {
+	Scene4xx::synchronize(s);
+
+	s.syncAsSint32LE(_curAnimationFrame);
+	s.syncAsSint32LE(_newIngredient);
+	s.syncAsSint32LE(_newQuantity);
+	s.syncAsSint32LE(_resetFrame);
+	s.syncAsSint32LE(_badThreshold);
+
+	s.syncAsByte(_killRox);
+	s.syncAsByte(_makeMushroomCloud);
+}
+
 bool Scene411::addIngredient() {
 	bool retVal = false;
 
@@ -3952,20 +4028,19 @@ void Scene411::actions() {
 	_action._inProgress = false;
 }
 
-void Scene411::synchronize(Common::Serializer &s) {
-	Scene4xx::synchronize(s);
-
-	s.syncAsSint32LE(_curAnimationFrame);
-	s.syncAsSint32LE(_newIngredient);
-	s.syncAsSint32LE(_newQuantity);
-	s.syncAsSint32LE(_resetFrame);
-	s.syncAsSint32LE(_badThreshold);
+/*------------------------------------------------------------------------*/
 
-	s.syncAsByte(_killRox);
-	s.syncAsByte(_makeMushroomCloud);
+Scene413::Scene413(MADSEngine *vm) : Scene4xx(vm) {
+	_rexDeath = -1;
+	_canMove = -1;
 }
 
-/*------------------------------------------------------------------------*/
+void Scene413::synchronize(Common::Serializer &s) {
+	Scene4xx::synchronize(s);
+
+	s.syncAsSint32LE(_rexDeath);
+	s.syncAsSint32LE(_canMove);
+}
 
 void Scene413::setup() {
 	setPlayerSpritesPrefix();
@@ -4110,13 +4185,6 @@ void Scene413::actions() {
 	_action._inProgress = false;
 }
 
-void Scene413::synchronize(Common::Serializer &s) {
-	Scene4xx::synchronize(s);
-
-	s.syncAsSint32LE(_rexDeath);
-	s.syncAsSint32LE(_canMove);
-}
-
 /*------------------------------------------------------------------------*/
 
 } // End of namespace Nebular
diff --git a/engines/mads/nebular/nebular_scenes4.h b/engines/mads/nebular/nebular_scenes4.h
index bacab8a..4544e08 100644
--- a/engines/mads/nebular/nebular_scenes4.h
+++ b/engines/mads/nebular/nebular_scenes4.h
@@ -57,7 +57,7 @@ private:
 	uint32 _timer;
 
 public:
-	Scene401(MADSEngine *vm) : Scene4xx(vm) {}
+	Scene401(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -118,7 +118,7 @@ private:
 	void handleDialogs();
 
 public:
-	Scene402(MADSEngine *vm) : Scene4xx(vm) {}
+	Scene402(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -144,7 +144,7 @@ private:
 	bool _hitStorageDoor;
 
 public:
-	Scene406(MADSEngine *vm) : Scene4xx(vm) {}
+	Scene406(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -160,7 +160,7 @@ private:
 	Common::Point _destPos;
 
 public:
-	Scene407(MADSEngine *vm) : Scene4xx(vm) {}
+	Scene407(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -227,7 +227,7 @@ private:
 	bool addIngredient();
 
 public:
-	Scene411(MADSEngine *vm) : Scene4xx(vm) {}
+	Scene411(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -243,7 +243,7 @@ private:
 	int _canMove;
 
 public:
-	Scene413(MADSEngine *vm) : Scene4xx(vm) {}
+	Scene413(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();


Commit: 77d85a63f1a96bdf5611595166b02ec3713c853d
    https://github.com/scummvm/scummvm/commit/77d85a63f1a96bdf5611595166b02ec3713c853d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-22T21:03:08-04:00

Commit Message:
MADS: Fix ending of turkey explosion sequence in scene 103

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 131ee6e..ff75f70 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -1502,7 +1502,7 @@ void Scene103::actions() {
 			_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, _vm->_game->_trigger < 1 ? 1 : 0);
 			if (_vm->_game->_trigger) {
 				// Lock the turkey into a permanent "exploded" frame
-				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[9], -1, -1);
+				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[9], -2, -2);
 
 				// Rex says "Gads.."
 				Common::String msg = _game.getQuote(51);


Commit: 27d4573edf104911758f235e8a4cf85795cd66dd
    https://github.com/scummvm/scummvm/commit/27d4573edf104911758f235e8a4cf85795cd66dd
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-23T07:15:15+02:00

Commit Message:
MADS: Move contructors out of the header in scene group 5

Changed paths:
    engines/mads/nebular/nebular_scenes5.cpp
    engines/mads/nebular/nebular_scenes5.h



diff --git a/engines/mads/nebular/nebular_scenes5.cpp b/engines/mads/nebular/nebular_scenes5.cpp
index cc8cdbd..a8c6b22 100644
--- a/engines/mads/nebular/nebular_scenes5.cpp
+++ b/engines/mads/nebular/nebular_scenes5.cpp
@@ -92,11 +92,12 @@ void Scene5xx::sceneEntrySound() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene501::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
-	_scene->addActiveVocab(NOUN_DOOR);
-	_scene->addActiveVocab(VERB_WALK_THROUGH);
+Scene501::Scene501(MADSEngine *vm) : Scene5xx(vm) {
+	_mainSequenceId = -1;
+	_mainSpriteId = -1;
+	_doorHotspotid = -1;
+
+	_rexPunched = false;
 }
 
 void Scene501::synchronize(Common::Serializer &s) {
@@ -108,6 +109,13 @@ void Scene501::synchronize(Common::Serializer &s) {
 	s.syncAsByte(_rexPunched);
 }
 
+void Scene501::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(NOUN_DOOR);
+	_scene->addActiveVocab(VERB_WALK_THROUGH);
+}
+
 void Scene501::handleSlotActions() {
 	switch (_game._trigger) {
 	case 0:
@@ -523,11 +531,8 @@ void Scene502::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene503::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
-	_scene->addActiveVocab(NOUN_DETONATORS);
-	_scene->addActiveVocab(VERB_WALKTO);
+Scene503::Scene503(MADSEngine *vm) : Scene5xx(vm) {
+	_detonatorHotspotId = -1;
 }
 
 void Scene503::synchronize(Common::Serializer &s) {
@@ -536,6 +541,13 @@ void Scene503::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_detonatorHotspotId);
 }
 
+void Scene503::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(NOUN_DETONATORS);
+	_scene->addActiveVocab(VERB_WALKTO);
+}
+
 void Scene503::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', -1));
 
@@ -651,9 +663,9 @@ void Scene503::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene504::setup() {
-	_game._player._spritesPrefix = "";
-	setAAName();
+Scene504::Scene504(MADSEngine *vm) : Scene5xx(vm) {
+	_carAnimationMode = -1;
+	_carFrame = -1;
 }
 
 void Scene504::synchronize(Common::Serializer &s) {
@@ -663,6 +675,11 @@ void Scene504::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_carFrame);
 }
 
+void Scene504::setup() {
+	_game._player._spritesPrefix = "";
+	setAAName();
+}
+
 void Scene504::enter() {
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 2));
 
@@ -855,9 +872,15 @@ void Scene504::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene505::setup() {
-	_game._player._spritesPrefix = "";
-	setAAName();
+Scene505::Scene505(MADSEngine *vm) : Scene5xx(vm) {
+	_frame = -1;
+	_nextButtonId = -1;
+	_homeSelectedId = -1;
+	_selectedId = -1;
+	_activeCars = -1;
+
+	for (int i = 0; i < 9; i++)
+		_carLocations[i] = -1;
 }
 
 void Scene505::synchronize(Common::Serializer &s) {
@@ -873,6 +896,11 @@ void Scene505::synchronize(Common::Serializer &s) {
 		s.syncAsSint16LE(_carLocations[i]);
 }
 
+void Scene505::setup() {
+	_game._player._spritesPrefix = "";
+	setAAName();
+}
+
 void Scene505::enter() {
 	for (int i = 0; i < 9; i++)
 		_globals._spriteIndexes[i] = _scene->_sprites.addSprites(formAnimName('a', i + 1));
@@ -1122,12 +1150,17 @@ void Scene505::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene506::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
-	_scene->addActiveVocab(VERB_WALK_INTO);
-	_scene->addActiveVocab(NOUN_SOFTWARE_STORE);
-	_scene->addActiveVocab(NOUN_LABORATORY);
+Scene506::Scene506(MADSEngine *vm) : Scene5xx(vm), _doorPos(0, 0) {
+	_heroFacing = FACING_DUMMY;
+
+	_doorDepth = -1;
+	_doorSpriteIdx = -1;
+	_doorSequenceIdx = -1;
+	_doorWord = -1;
+
+	_labDoorFl = false;
+	_firstDoorFl = false;
+	_actionFl = false;
 }
 
 void Scene506::synchronize(Common::Serializer &s) {
@@ -1148,6 +1181,14 @@ void Scene506::synchronize(Common::Serializer &s) {
 	s.syncAsByte(_actionFl);
 }
 
+void Scene506::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(VERB_WALK_INTO);
+	_scene->addActiveVocab(NOUN_SOFTWARE_STORE);
+	_scene->addActiveVocab(NOUN_LABORATORY);
+}
+
 void Scene506::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('q', 0));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('q', 1));
@@ -1402,11 +1443,8 @@ void Scene506::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene507::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
-	_scene->addActiveVocab(NOUN_PENLIGHT);
-	_scene->addActiveVocab(VERB_WALKTO);
+Scene507::Scene507(MADSEngine *vm) : Scene5xx(vm) {
+	_penlightHotspotId = -1;
 }
 
 void Scene507::synchronize(Common::Serializer &s) {
@@ -1415,6 +1453,13 @@ void Scene507::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_penlightHotspotId);
 }
 
+void Scene507::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(NOUN_PENLIGHT);
+	_scene->addActiveVocab(VERB_WALKTO);
+}
+
 void Scene507::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('p', -1));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RXMRD_3");
@@ -1519,12 +1564,8 @@ void Scene507::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene508::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
-	_scene->addActiveVocab(NOUN_SPINACH_PATCH_DOLL);
-	_scene->addActiveVocab(VERB_WALKTO);
-	_scene->addActiveVocab(NOUN_LASER_BEAM);
+Scene508::Scene508(MADSEngine *vm) : Scene5xx(vm) {
+	_chosenObject = -1;
 }
 
 void Scene508::synchronize(Common::Serializer &s) {
@@ -1533,6 +1574,14 @@ void Scene508::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_chosenObject);
 }
 
+void Scene508::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(NOUN_SPINACH_PATCH_DOLL);
+	_scene->addActiveVocab(VERB_WALKTO);
+	_scene->addActiveVocab(NOUN_LASER_BEAM);
+}
+
 void Scene508::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('a', 0));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('m', 0));
@@ -1784,12 +1833,13 @@ void Scene508::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene511::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
-	_scene->addActiveVocab(NOUN_BOAT);
-	_scene->addActiveVocab(NOUN_FISHING_LINE);
-	_scene->addActiveVocab(VERB_WALKTO);
+Scene511::Scene511(MADSEngine *vm) : Scene5xx(vm) {
+	_handingLine = false;
+	_lineMoving = false;
+
+	_lineAnimationMode = -1;
+	_lineFrame = -1;
+	_lineAnimationPosition = -1;
 }
 
 void Scene511::synchronize(Common::Serializer &s) {
@@ -1803,6 +1853,14 @@ void Scene511::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_lineAnimationPosition);
 }
 
+void Scene511::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(NOUN_BOAT);
+	_scene->addActiveVocab(NOUN_FISHING_LINE);
+	_scene->addActiveVocab(VERB_WALKTO);
+}
+
 void Scene511::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', 0));
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXCD_6");
@@ -2116,13 +2174,9 @@ void Scene511::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene512::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
-	_scene->addActiveVocab(NOUN_FISHING_ROD);
-	_scene->addActiveVocab(VERB_WALKTO);
-	_scene->addActiveVocab(NOUN_PADLOCK_KEY);
-	_scene->addActiveVocab(NOUN_REGISTER_DRAWER);
+Scene512::Scene512(MADSEngine *vm) : Scene5xx(vm) {
+	_fishingRodHotspotId = -1;
+	_keyHotspotId = -1;
 }
 
 void Scene512::synchronize(Common::Serializer &s) {
@@ -2132,6 +2186,15 @@ void Scene512::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_keyHotspotId);
 }
 
+void Scene512::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(NOUN_FISHING_ROD);
+	_scene->addActiveVocab(VERB_WALKTO);
+	_scene->addActiveVocab(NOUN_PADLOCK_KEY);
+	_scene->addActiveVocab(NOUN_REGISTER_DRAWER);
+}
+
 void Scene512::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('r', -1));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RXMRC_9");
diff --git a/engines/mads/nebular/nebular_scenes5.h b/engines/mads/nebular/nebular_scenes5.h
index 7c21fba..4022f1c 100644
--- a/engines/mads/nebular/nebular_scenes5.h
+++ b/engines/mads/nebular/nebular_scenes5.h
@@ -60,7 +60,7 @@ private:
 	void handleSlotActions();
 
 public:
-	Scene501(MADSEngine *vm) : Scene5xx(vm) {}
+	Scene501(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -85,7 +85,7 @@ private:
 	int _detonatorHotspotId;
 
 public:
-	Scene503(MADSEngine *vm) : Scene5xx(vm) {}
+	Scene503(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -99,7 +99,7 @@ private:
 	int _carFrame;
 
 public:
-	Scene504(MADSEngine *vm) : Scene5xx(vm) {}
+	Scene504(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -120,7 +120,7 @@ private:
 	int _carLocations[9];
 
 public:
-	Scene505(MADSEngine *vm) : Scene5xx(vm) {}
+	Scene505(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -146,7 +146,7 @@ private:
 	void handleDoorSequences();
 
 public:
-	Scene506(MADSEngine *vm) : Scene5xx(vm) {}
+	Scene506(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -160,7 +160,7 @@ private:
 	int _penlightHotspotId;
 
 public:
-	Scene507(MADSEngine *vm) : Scene5xx(vm) {}
+	Scene507(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -175,7 +175,7 @@ private:
 	void handlePedestral();
 
 public:
-	Scene508(MADSEngine *vm) : Scene5xx(vm) {}
+	Scene508(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -194,7 +194,7 @@ private:
 	int _lineAnimationPosition;
 
 public:
-	Scene511(MADSEngine *vm) : Scene5xx(vm) {}
+	Scene511(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -210,7 +210,7 @@ private:
   int _keyHotspotId;
 
 public:
-	Scene512(MADSEngine *vm) : Scene5xx(vm) {}
+	Scene512(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();


Commit: cdbf1349275637b1d022ffe2ae83f37a2cd83e21
    https://github.com/scummvm/scummvm/commit/cdbf1349275637b1d022ffe2ae83f37a2cd83e21
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-23T17:13:12+02:00

Commit Message:
MADS: Move contructors out of the header in scene group 6

Changed paths:
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes6.h



diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index 4313366..9413350 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -217,12 +217,11 @@ void Scene601::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene602::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
-	_scene->addActiveVocab(VERB_WALKTO);
-	_scene->addActiveVocab(NOUN_SAFE);
-	_scene->addActiveVocab(NOUN_LASER_BEAM);
+Scene602::Scene602(MADSEngine *vm) : Scene6xx(vm) {
+	_lastSpriteIdx = -1;
+	_lastSequenceIdx = -1;
+	_cycleIndex = -1;
+	_safeMode = -1;
 }
 
 void Scene602::synchronize(Common::Serializer &s) {
@@ -234,6 +233,14 @@ void Scene602::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_safeMode);
 }
 
+void Scene602::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(VERB_WALKTO);
+	_scene->addActiveVocab(NOUN_SAFE);
+	_scene->addActiveVocab(NOUN_LASER_BEAM);
+}
+
 void Scene602::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('h', -1));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 0));
@@ -539,12 +546,9 @@ void Scene602::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene603::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
-	_scene->addActiveVocab(VERB_WALKTO);
-	_scene->addActiveVocab(NOUN_COMPACT_CASE);
-	_scene->addActiveVocab(NOUN_NOTE);
+Scene603::Scene603(MADSEngine *vm) : Scene6xx(vm) {
+	_compactCaseHotspotId = -1;
+	_noteHotspotId = -1;
 }
 
 void Scene603::synchronize(Common::Serializer &s) {
@@ -554,6 +558,14 @@ void Scene603::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_noteHotspotId);
 }
 
+void Scene603::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(VERB_WALKTO);
+	_scene->addActiveVocab(NOUN_COMPACT_CASE);
+	_scene->addActiveVocab(NOUN_NOTE);
+}
+
 void Scene603::enter() {
 	if (_game._objects[OBJ_COMPACT_CASE]._roomNumber == _scene->_currentSceneId) {
 		_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXMRD_3");
@@ -688,12 +700,15 @@ void Scene603::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene604::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
-	_scene->addActiveVocab(NOUN_SEA_MONSTER);
-	_scene->addActiveVocab(VERB_WALKTO);
-	_scene->addActiveVocab(NOUN_TIMEBOMB);
+Scene604::Scene604(MADSEngine *vm) : Scene6xx(vm) {
+	_timebombHotspotId = -1;
+	_bombMode = -1;
+	_monsterFrame = -1;
+
+	_monsterTimer = 0;
+
+	_monsterActive = false;
+	_animationActiveFl = false;
 }
 
 void Scene604::synchronize(Common::Serializer &s) {
@@ -709,6 +724,14 @@ void Scene604::synchronize(Common::Serializer &s) {
 	s.syncAsByte(_animationActiveFl);
 }
 
+void Scene604::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(NOUN_SEA_MONSTER);
+	_scene->addActiveVocab(VERB_WALKTO);
+	_scene->addActiveVocab(NOUN_TIMEBOMB);
+}
+
 void Scene604::enter() {
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('c', 0));
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*RXCD_9");
@@ -1014,11 +1037,18 @@ void Scene605::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene607::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
-	_scene->addActiveVocab(NOUN_OBNOXIOUS_DOG);
-	_scene->addActiveVocab(VERB_WALKTO);
+Scene607::Scene607(MADSEngine *vm) : Scene6xx(vm) {
+	_dogTimer = 0;
+	_lastFrameTime = 0;
+
+	_dogLoop = false;
+	_dogEatsRex = false;
+	_dogBarking = false;
+	_shopAvailable = false;
+
+	_animationMode = -1;
+	_animationActive = -1;
+	_counter = -1;
 }
 
 void Scene607::synchronize(Common::Serializer &s) {
@@ -1037,6 +1067,13 @@ void Scene607::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_counter);
 }
 
+void Scene607::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(NOUN_OBNOXIOUS_DOG);
+	_scene->addActiveVocab(VERB_WALKTO);
+}
+
 void Scene607::enter() {
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('c', 0));
 	_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RXCD_3");
@@ -1463,13 +1500,36 @@ void Scene607::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene608::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
-	_scene->addActiveVocab(VERB_WALKTO);
-	_scene->addActiveVocab(NOUN_POLYCEMENT);
-	_scene->addActiveVocab(NOUN_CAR);
-	_scene->addActiveVocab(NOUN_OBNOXIOUS_DOG);
+Scene608::Scene608(MADSEngine *vm) : Scene6xx(vm) {
+	_carMode = -1;
+	_carFrame = -1;
+	_carMoveMode = -1;
+	_dogDeathMode = -1;
+	_carHotspotId = -1;
+	_barkCount = -1;
+	_polycementHotspotId = -1;
+	_animationMode = -1;
+	_nextTrigger = -1;
+	_throwMode = -1;
+
+	_resetPositionsFl = false;
+	_dogActiveFl = false;
+	_dogBarkingFl = false;
+	_dogFirstEncounter = false;
+	_rexBeingEaten = false;
+	_dogHitWindow = false;
+	_checkFl = false;
+	_dogSquashFl = false;
+	_dogSafeFl = false;
+	_buttonPressedonTimeFl = false;
+	_dogUnderCar = false;
+	_dogYelping = false;
+
+	_dogWindowTimer = -1;
+	_dogRunTimer = -1;
+
+	_dogTimer1 = 0;
+	_dogTimer2 = 0;
 }
 
 void Scene608::synchronize(Common::Serializer &s) {
@@ -1506,6 +1566,15 @@ void Scene608::synchronize(Common::Serializer &s) {
 	s.syncAsUint32LE(_dogTimer2);
 }
 
+void Scene608::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(VERB_WALKTO);
+	_scene->addActiveVocab(NOUN_POLYCEMENT);
+	_scene->addActiveVocab(NOUN_CAR);
+	_scene->addActiveVocab(NOUN_OBNOXIOUS_DOG);
+}
+
 void Scene608::resetDogVariables() {
 	_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
 	int idx = _scene->_dynamicHotspots.add(NOUN_OBNOXIOUS_DOG, VERB_WALKTO, _globals._sequenceIndexes[5], Common::Rect(0, 0, 0, 0));
@@ -2457,9 +2526,8 @@ void Scene608::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene609::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
+Scene609::Scene609(MADSEngine *vm) : Scene6xx(vm) {
+	_videoDoorMode = -1;
 }
 
 void Scene609::synchronize(Common::Serializer &s) {
@@ -2468,6 +2536,11 @@ void Scene609::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_videoDoorMode);
 }
 
+void Scene609::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
 void Scene609::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('c', 0));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('x', 0));
@@ -2786,11 +2859,14 @@ void Scene609::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene610::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
-	_scene->addActiveVocab(NOUN_PHONE_HANDSET);
-	_scene->addActiveVocab(VERB_WALKTO);
+Scene610::Scene610(MADSEngine *vm) : Scene6xx(vm) {
+	_handsetHotspotId = -1;
+	_checkVal = -1;
+
+	_cellCharging = false;
+
+	_cellChargingTimer = -1;
+	_lastFrameTimer = 0;
 }
 
 void Scene610::synchronize(Common::Serializer &s) {
@@ -2805,6 +2881,13 @@ void Scene610::synchronize(Common::Serializer &s) {
 	s.syncAsUint32LE(_lastFrameTimer);
 }
 
+void Scene610::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(NOUN_PHONE_HANDSET);
+	_scene->addActiveVocab(VERB_WALKTO);
+}
+
 void Scene610::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('p', -1));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites("*RXMRC_9");
@@ -2981,11 +3064,29 @@ void Scene610::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene611::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
-	_scene->addActiveVocab(NOUN_RAT);
-	_scene->addActiveVocab(VERB_WALKTO);
+Scene611::Scene611(MADSEngine *vm) : Scene6xx(vm), _defaultDialogPos(0, 0) {
+	_seenRatFl = false;
+	_eyesRunningFl = false;
+	_shouldRemoveEyes = false;
+	_ratPresentFl = false;
+	_duringDialogFl = false;
+	_resetBatterieText = false;
+	_hermitTalkingFl = false;
+	_hermitMovingFl = false;
+	_alreadyTalkingFl = false;
+	_giveBatteriesFl = false;
+	_startTradingFl = false;
+	_check1Fl = false;
+	_stickFingerFl = false;
+
+	_randVal = -1;
+	_ratHotspotId = -1;
+	_hermitDialogNode = -1;
+	_hermitDisplayedQuestion = -1;
+	_nextFrame = -1;
+	_hermitMode = -1;
+
+	_ratTimer = 0;
 }
 
 void Scene611::synchronize(Common::Serializer &s) {
@@ -3018,6 +3119,13 @@ void Scene611::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_defaultDialogPos.y);
 }
 
+void Scene611::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(NOUN_RAT);
+	_scene->addActiveVocab(VERB_WALKTO);
+}
+
 void Scene611::handleRatMoves() {
 	_ratPresentFl = false;
 	_scene->_sequences.remove(_globals._sequenceIndexes[1]);
@@ -4386,11 +4494,9 @@ void Scene611::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene612::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
-	_scene->addActiveVocab(NOUN_FISHING_LINE);
-	_scene->addActiveVocab(VERB_WALKTO);
+Scene612::Scene612(MADSEngine *vm) : Scene6xx(vm) {
+	_actionMode = -1;
+	_cycleIndex = -1;
 }
 
 void Scene612::synchronize(Common::Serializer &s) {
@@ -4400,6 +4506,13 @@ void Scene612::synchronize(Common::Serializer &s) {
 	s.syncAsSint16LE(_cycleIndex);
 }
 
+void Scene612::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(NOUN_FISHING_LINE);
+	_scene->addActiveVocab(VERB_WALKTO);
+}
+
 void Scene612::handleWinchMovement() {
 	switch (_game._trigger) {
 	case 0:
diff --git a/engines/mads/nebular/nebular_scenes6.h b/engines/mads/nebular/nebular_scenes6.h
index 680d006..7446785 100644
--- a/engines/mads/nebular/nebular_scenes6.h
+++ b/engines/mads/nebular/nebular_scenes6.h
@@ -70,7 +70,7 @@ private:
 	void handleSafeActions();
 
 public:
-	Scene602(MADSEngine *vm) : Scene6xx(vm) {}
+	Scene602(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -84,7 +84,7 @@ private:
 	int _noteHotspotId;
 
 public:
-	Scene603(MADSEngine *vm) : Scene6xx(vm) {}
+	Scene603(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -106,7 +106,7 @@ private:
 	void handleBombActions();
 
 public:
-	Scene604(MADSEngine *vm) : Scene6xx(vm) {}
+	Scene604(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -142,7 +142,7 @@ private:
 	void handleThrowingBone();
 
 public:
-	Scene607(MADSEngine *vm) : Scene6xx(vm) {}
+	Scene607(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -190,7 +190,7 @@ private:
 	void handleThrowingBone();
 
 public:
-	Scene608(MADSEngine *vm) : Scene6xx(vm) {}
+	Scene608(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -207,7 +207,7 @@ private:
 	void enterStore();
 
 public:
-	Scene609(MADSEngine *vm) : Scene6xx(vm) {}
+	Scene609(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -228,7 +228,7 @@ private:
 	uint32 _lastFrameTimer;
 
 public:
-	Scene610(MADSEngine *vm) : Scene6xx(vm) {}
+	Scene610(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -280,7 +280,7 @@ private:
 	bool check4ChargedBatteries();
 
 public:
-	Scene611(MADSEngine *vm) : Scene6xx(vm) {}
+	Scene611(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -298,7 +298,7 @@ private:
 	void handleWinchMovement();
 
 public:
-	Scene612(MADSEngine *vm) : Scene6xx(vm) {}
+	Scene612(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();


Commit: cc65a8d015288e2e79960a659843bc0eb3136c30
    https://github.com/scummvm/scummvm/commit/cc65a8d015288e2e79960a659843bc0eb3136c30
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-23T20:16:07+02:00

Commit Message:
MADS: Move contructors out of the header in scene group 7

Changed paths:
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes7.h



diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index e9d8f7f..585271c 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -89,6 +89,16 @@ void Scene7xx::sceneEntrySound() {
 
 /*------------------------------------------------------------------------*/
 
+Scene701::Scene701(MADSEngine *vm) : Scene7xx(vm) {
+	_fishingLineId = -1;
+}
+
+void Scene701::synchronize(Common::Serializer &s) {
+	Scene7xx::synchronize(s);
+
+	s.syncAsSint16LE(_fishingLineId);
+}
+
 void Scene701::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -99,12 +109,6 @@ void Scene701::setup() {
 	_scene->addActiveVocab(VERB_WALKTO);
 }
 
-void Scene701::synchronize(Common::Serializer &s) {
-	Scene7xx::synchronize(s);
-
-	s.syncAsSint16LE(_fishingLineId);
-}
-
 void Scene701::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 0));
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('b', 5));
@@ -547,9 +551,19 @@ void Scene702::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene703::setup() {
-	_game._player._spritesPrefix = "";
-	setAAName();
+Scene703::Scene703(MADSEngine *vm) : Scene7xx(vm) {
+	_monsterMode = -1;
+	_boatFrame = -1;
+	_curSequence = -1;
+	_boatDir = -1;
+
+	_useBomb = false;
+	_startMonsterTimer = false;
+	_rexDeathFl = false;
+	_restartTrigger70Fl = false;
+
+	_lastFrameTime = 0;
+	_monsterTime = 0;
 }
 
 void Scene703::synchronize(Common::Serializer &s) {
@@ -569,6 +583,11 @@ void Scene703::synchronize(Common::Serializer &s) {
 	s.syncAsUint32LE(_monsterTime);
 }
 
+void Scene703::setup() {
+	_game._player._spritesPrefix = "";
+	setAAName();
+}
+
 void Scene703::handleBottleInterface() {
 	switch (_globals[kBottleStatus]) {
 	case 0:
@@ -1090,11 +1109,13 @@ void Scene703::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene704::setup() {
-	_game._player._spritesPrefix = "";
-	setAAName();
-	_scene->addActiveVocab(NOUN_BOTTLE);
-	_scene->addActiveVocab(VERB_LOOK_AT);
+Scene704::Scene704(MADSEngine *vm) : Scene7xx(vm) {
+	_bottleHotspotId = -1;
+	_boatCurrentFrame = -1;
+	_animationMode = -1;
+	_boatDirection = -1;
+
+	_takeBottleFl = false;
 }
 
 void Scene704::synchronize(Common::Serializer &s) {
@@ -1108,6 +1129,13 @@ void Scene704::synchronize(Common::Serializer &s) {
 	s.syncAsByte(_takeBottleFl);
 }
 
+void Scene704::setup() {
+	_game._player._spritesPrefix = "";
+	setAAName();
+	_scene->addActiveVocab(NOUN_BOTTLE);
+	_scene->addActiveVocab(VERB_LOOK_AT);
+}
+
 void Scene704::handleBottleInterface() {
 	switch (_globals[kBottleStatus]) {
 	case 0:
@@ -1708,12 +1736,13 @@ void Scene705::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene706::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
-	_scene->addActiveVocab(NOUN_BOTTLE);
-	_scene->addActiveVocab(NOUN_VASE);
-	_scene->addActiveVocab(VERB_WALKTO);
+Scene706::Scene706(MADSEngine *vm) : Scene7xx(vm) {
+	_vaseHotspotId = -1;
+	_vaseMode = -1;
+	_animationMode = -1;
+	_animationFrame = -1;
+
+	_emptyPedestral = false;
 }
 
 void Scene706::synchronize(Common::Serializer &s) {
@@ -1727,6 +1756,14 @@ void Scene706::synchronize(Common::Serializer &s) {
 	s.syncAsByte(_emptyPedestral);
 }
 
+void Scene706::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(NOUN_BOTTLE);
+	_scene->addActiveVocab(NOUN_VASE);
+	_scene->addActiveVocab(VERB_WALKTO);
+}
+
 void Scene706::handleRexDeath() {
 	switch (_game._trigger) {
 	case 0:
@@ -2128,11 +2165,8 @@ void Scene711::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene751::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
-	_scene->addActiveVocab(NOUN_FISHING_LINE);
-	_scene->addActiveVocab(VERB_WALKTO);
+Scene751::Scene751(MADSEngine *vm) : Scene7xx(vm) {
+	_rexHandingLine = false;
 }
 
 void Scene751::synchronize(Common::Serializer &s) {
@@ -2141,6 +2175,13 @@ void Scene751::synchronize(Common::Serializer &s) {
 	s.syncAsByte(_rexHandingLine);
 }
 
+void Scene751::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+	_scene->addActiveVocab(NOUN_FISHING_LINE);
+	_scene->addActiveVocab(VERB_WALKTO);
+}
+
 void Scene751::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites("*RM701X0");
 	_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 0));
@@ -2459,6 +2500,16 @@ void Scene751::actions() {
 
 /*------------------------------------------------------------------------*/
 
+Scene752::Scene752(MADSEngine *vm) : Scene7xx(vm) {
+	_cardId = -1;
+}
+
+void Scene752::synchronize(Common::Serializer &s) {
+	Scene7xx::synchronize(s);
+
+	s.syncAsSint16LE(_cardId);
+}
+
 void Scene752::setup() {
 	setPlayerSpritesPrefix();
 	setAAName();
@@ -2469,12 +2520,6 @@ void Scene752::setup() {
 	_scene->addActiveVocab(NOUN_LASER_BEAM);
 }
 
-void Scene752::synchronize(Common::Serializer &s) {
-	Scene7xx::synchronize(s);
-
-	s.syncAsSint16LE(_cardId);
-}
-
 void Scene752::enter() {
 	_globals._spriteIndexes[14] = _scene->_sprites.addSprites(formAnimName('l', -1));
 	_globals._spriteIndexes[12] = _scene->_sprites.addSprites("*RXMBD_8");
diff --git a/engines/mads/nebular/nebular_scenes7.h b/engines/mads/nebular/nebular_scenes7.h
index 150c598..454c76e 100644
--- a/engines/mads/nebular/nebular_scenes7.h
+++ b/engines/mads/nebular/nebular_scenes7.h
@@ -55,7 +55,7 @@ private:
 	int _fishingLineId;
 
 public:
-	Scene701(MADSEngine *vm) : Scene7xx(vm), _fishingLineId(-1) {}
+	Scene701(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -97,7 +97,7 @@ private:
 	void handleFillBottle(int quote);
 
 public:
-	Scene703(MADSEngine *vm) : Scene7xx(vm) {}
+	Scene703(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -122,7 +122,7 @@ private:
 	void handleBottleInterface();
 
 public:
-	Scene704(MADSEngine *vm) : Scene7xx(vm) {}
+	Scene704(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -152,7 +152,7 @@ public:
 class Scene706: public Scene7xx{
 private:
 	int _vaseHotspotId;
-	int _vaseMode;       // CHECKME: Use?
+	int _vaseMode;
 	int _animationMode;
 	int _animationFrame;
 
@@ -162,7 +162,7 @@ private:
 	void handleRexDeath();
 
 public:
-	Scene706(MADSEngine *vm) : Scene7xx(vm) {}
+	Scene706(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -207,7 +207,7 @@ private:
 	bool _rexHandingLine;
 
 public:
-	Scene751(MADSEngine *vm) : Scene7xx(vm) {}
+	Scene751(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -222,7 +222,7 @@ private:
 	int _cardId;
 
 public:
-	Scene752(MADSEngine *vm) : Scene7xx(vm), _cardId(-1) {}
+	Scene752(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();


Commit: 2a73b6c08e98c07e63ef669487aad934da89feb7
    https://github.com/scummvm/scummvm/commit/2a73b6c08e98c07e63ef669487aad934da89feb7
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-23T21:43:00+02:00

Commit Message:
MADS: Move contructors out of the header in scene group 8

Changed paths:
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/nebular/nebular_scenes8.h



diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 1fef270..6f9a46d 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -78,9 +78,8 @@ void Scene8xx::sceneEntrySound() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene801::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
+Scene801::Scene801(MADSEngine *vm) : Scene8xx(vm) {
+	_walkThroughDoor = false;
 }
 
 void Scene801::synchronize(Common::Serializer &s) {
@@ -89,6 +88,10 @@ void Scene801::synchronize(Common::Serializer &s) {
 	s.syncAsByte(_walkThroughDoor);
 }
 
+void Scene801::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
 
 void Scene801::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(formAnimName('x', 1));
@@ -830,10 +833,17 @@ void Scene803::actions() {
 
 /*------------------------------------------------------------------------*/
 
+Scene804::Scene804(MADSEngine *vm) : Scene8xx(vm) {
+	_messWithThrottle = false;
+	_movingThrottle = false;
+	_throttleGone = false;
+	_dontPullThrottleAgain = false;
+	_pullThrottleReally = false;
+	_alreadyOrgan = false;
+	_alreadyPop = false;
 
-void Scene804::setup() {
-	Scene8xx::setPlayerSpritesPrefix();
-	Scene8xx::setAAName();
+	_throttleCounter = 0;
+	_resetFrame = -1;
 }
 
 void Scene804::synchronize(Common::Serializer &s) {
@@ -851,6 +861,11 @@ void Scene804::synchronize(Common::Serializer &s) {
 	s.syncAsUint32LE(_throttleCounter);
 }
 
+void Scene804::setup() {
+	Scene8xx::setPlayerSpritesPrefix();
+	Scene8xx::setAAName();
+}
+
 void Scene804::enter() {
 	_messWithThrottle = false;
 	_throttleCounter = 0;
@@ -1252,9 +1267,8 @@ void Scene807::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene808::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
+Scene808::Scene808(MADSEngine *vm) : Scene8xx(vm) {
+	_goingTo803 = false;
 }
 
 void Scene808::synchronize(Common::Serializer &s) {
@@ -1263,6 +1277,11 @@ void Scene808::synchronize(Common::Serializer &s) {
 	s.syncAsByte(_goingTo803);
 }
 
+void Scene808::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
 void Scene808::enter() {
 	_scene->_userInterface.setup(kInputLimitedSentences);
 
@@ -1464,9 +1483,8 @@ void Scene808::actions() {
 
 /*------------------------------------------------------------------------*/
 
-void Scene810::setup() {
-	setPlayerSpritesPrefix();
-	setAAName();
+Scene810::Scene810(MADSEngine *vm) : Scene8xx(vm) {
+	_moveAllowed = false;
 }
 
 void Scene810::synchronize(Common::Serializer &s) {
@@ -1475,6 +1493,11 @@ void Scene810::synchronize(Common::Serializer &s) {
 	s.syncAsByte(_moveAllowed);
 }
 
+void Scene810::setup() {
+	setPlayerSpritesPrefix();
+	setAAName();
+}
+
 void Scene810::enter() {
 	_scene->_userInterface.setup(kInputLimitedSentences);
 	_game._player._visible = false;
diff --git a/engines/mads/nebular/nebular_scenes8.h b/engines/mads/nebular/nebular_scenes8.h
index f926d1e..150951d 100644
--- a/engines/mads/nebular/nebular_scenes8.h
+++ b/engines/mads/nebular/nebular_scenes8.h
@@ -57,7 +57,7 @@ private:
 	bool _walkThroughDoor;
 
 public:
-	Scene801(MADSEngine *vm) : Scene8xx(vm) {}
+	Scene801(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -92,16 +92,17 @@ public:
 class Scene804: public Scene8xx {
 private:
 	bool _messWithThrottle;
-	uint32 _throttleCounter;
 	bool _movingThrottle;
 	bool _throttleGone;
 	bool _dontPullThrottleAgain;
-	int _resetFrame;
 	bool _pullThrottleReally;
 	bool _alreadyOrgan;
 	bool _alreadyPop;
+	uint32 _throttleCounter;
+	int _resetFrame;
+
 public:
-	Scene804(MADSEngine *vm) : Scene8xx(vm), _throttleCounter(0) {}
+	Scene804(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -136,7 +137,7 @@ private:
 	bool _goingTo803;
 
 public:
-	Scene808(MADSEngine *vm) : Scene8xx(vm) {}
+	Scene808(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();
@@ -149,7 +150,7 @@ private:
 	bool _moveAllowed;
 
 public:
-	Scene810(MADSEngine *vm) : Scene8xx(vm) {}
+	Scene810(MADSEngine *vm);
 	void synchronize(Common::Serializer &s);
 
 	virtual void setup();


Commit: 55e6e2bdb491edc33c41e219ee227dfd05c8460c
    https://github.com/scummvm/scummvm/commit/55e6e2bdb491edc33c41e219ee227dfd05c8460c
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-23T23:54:58+02:00

Commit Message:
MADS: Reorder some Synchronize functions for consistency across scene groups

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes2.h
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes3.h



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index ff75f70..59432c1 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -114,7 +114,6 @@ void Scene101::synchronize(Common::Serializer &s) {
 
 	s.syncAsByte(_sittingFl);
 	s.syncAsByte(_panelOpened);
-
 	s.syncAsSint16LE(_messageNum);
 	s.syncAsSint16LE(_posY);
 	s.syncAsSint16LE(_shieldSpriteIdx);
@@ -1289,6 +1288,7 @@ Scene103::Scene103(MADSEngine *vm) : Scene1xx(vm) {
 
 void Scene103::synchronize(Common::Serializer &s) {
 	Scene1xx::synchronize(s);
+
 	byte dummy = 0;
 	s.syncAsByte(dummy); // In order to avoid to break savegame compatibility
 	s.syncAsUint32LE(_updateClock);
@@ -1825,6 +1825,7 @@ Scene105::Scene105(MADSEngine *vm) : Scene1xx(vm) {
 
 void Scene105::synchronize(Common::Serializer &s) {
 	Scene1xx::synchronize(s);
+
 	s.syncAsByte(_explosionFl);
 }
 
@@ -1986,6 +1987,7 @@ Scene106::Scene106(MADSEngine *vm) : Scene1xx(vm) {
 
 void Scene106::synchronize(Common::Serializer &s) {
 	Scene1xx::synchronize(s);
+
 	s.syncAsByte(_backToShipFl);
 	s.syncAsByte(_shadowFl);
 	s.syncAsByte(_firstEmergingFl);
@@ -2205,6 +2207,7 @@ Scene107::Scene107(MADSEngine *vm) : Scene1xx(vm) {
 
 void Scene107::synchronize(Common::Serializer &s) {
 	Scene1xx::synchronize(s);
+
 	s.syncAsByte(_shootingFl);
 }
 
@@ -2422,6 +2425,7 @@ Scene109::Scene109(MADSEngine *vm) : Scene1xx(vm) {
 
 void Scene109::synchronize(Common::Serializer &s) {
 	Scene1xx::synchronize(s);
+
 	s.syncAsByte(_rexThrowingObject);
 	s.syncAsByte(_hoovicDifficultFl);
 	s.syncAsByte(_beforeEatingRex);
@@ -2827,6 +2831,7 @@ Scene110::Scene110(MADSEngine *vm) : Scene1xx(vm) {
 
 void Scene110::synchronize(Common::Serializer &s) {
 	Scene1xx::synchronize(s);
+
 	s.syncAsByte(_crabsFl);
 }
 
@@ -2961,6 +2966,7 @@ Scene111::Scene111(MADSEngine *vm) : Scene1xx(vm) {
 
 void Scene111::synchronize(Common::Serializer &s) {
 	Scene1xx::synchronize(s);
+
 	s.syncAsByte(_stampedFl);
 	s.syncAsByte(_launch1Fl);
 	s.syncAsByte(_launched2Fl);
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index 3cb4d43..9eb2134 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -65,15 +65,16 @@ private:
 	int _oldSpecial;
 
 	void sayDang();
+
 public:
 	Scene101(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene102 : public Scene1xx {
@@ -91,6 +92,7 @@ private:
 
 public:
 	Scene102(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
@@ -98,21 +100,21 @@ public:
 	virtual void preActions();
 	virtual void actions();
 	virtual void postActions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene103 : public Scene1xx {
 private:
 	uint32 _updateClock;
+
 public:
 	Scene103(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void actions();
 	virtual void postActions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene104 : public Scene1xx {
@@ -122,13 +124,13 @@ private:
 
 public:
 	Scene104(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene105 : public Scene1xx {
@@ -137,13 +139,13 @@ private:
 
 public:
 	Scene105(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene106 : public Scene1xx {
@@ -156,13 +158,13 @@ private:
 
 public:
 	Scene106(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene107 : public Scene1xx {
@@ -171,13 +173,13 @@ private:
 
 public:
 	Scene107(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene108 : public Scene1xx {
@@ -204,13 +206,13 @@ private:
 
 public:
 	Scene109(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene110 : public Scene1xx {
@@ -219,13 +221,13 @@ private:
 
 public:
 	Scene110(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene111 : public Scene1xx {
@@ -237,13 +239,13 @@ private:
 
 public:
 	Scene111(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene112 : public Scene1xx {
@@ -257,7 +259,6 @@ public:
 };
 
 } // End of namespace Nebular
-
 } // End of namespace MADS
 
 #endif /* MADS_NEBULAR_SCENES1_H */
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index 2c26e88..adb174c 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -123,6 +123,7 @@ Scene201::Scene201(MADSEngine *vm) : Scene2xx(vm) {
 
 void Scene201::synchronize(Common::Serializer &s) {
 	Scene2xx::synchronize(s);
+
 	s.syncAsByte(_pterodactylFlag);
 }
 
@@ -351,6 +352,7 @@ Scene202::Scene202(MADSEngine *vm) : Scene2xx(vm) {
 
 void Scene202::synchronize(Common::Serializer &s) {
 	Scene2xx::synchronize(s);
+
 	s.syncAsByte(_activeMsgFl);
 	s.syncAsByte(_ladderTopFl);
 	s.syncAsByte(_waitingMeteoFl);
@@ -1020,6 +1022,7 @@ Scene203::Scene203(MADSEngine *vm) : Scene2xx(vm) {
 
 void Scene203::synchronize(Common::Serializer &s) {
 	Scene2xx::synchronize(s);
+
 	s.syncAsByte(_rhotundaEat2Fl);
 	s.syncAsByte(_rhotundaEatFl);
 }
@@ -1652,6 +1655,7 @@ Scene208::Scene208(MADSEngine *vm) : Scene2xx(vm) {
 
 void Scene208::synchronize(Common::Serializer &s) {
 	Scene2xx::synchronize(s);
+
 	s.syncAsByte(_rhotundaTurnFl);
 	s.syncAsByte(_boundingFl);
 	s.syncAsSint32LE(_rhotundaTime);
@@ -1971,6 +1975,7 @@ Scene209::Scene209(MADSEngine *vm) : Scene2xx(vm) {
 
 void Scene209::synchronize(Common::Serializer &s) {
 	Scene2xx::synchronize(s);
+
 	s.syncAsByte(_dodgeFl);
 	s.syncAsByte(_forceDodgeFl);
 	s.syncAsByte(_shouldDodgeFl);
@@ -3607,6 +3612,7 @@ Scene210::Scene210(MADSEngine *vm) : Scene2xx(vm) {
 
 void Scene210::synchronize(Common::Serializer &s) {
 	Scene2xx::synchronize(s);
+
 	s.syncAsSint32LE(_curDialogNode);
 	s.syncAsSint32LE(_nextHandsPlace);
 	s.syncAsSint32LE(_twinkleAnimationType);
@@ -4606,6 +4612,7 @@ Scene211::Scene211(MADSEngine *vm) : Scene2xx(vm) {
 
 void Scene211::synchronize(Common::Serializer &s) {
 	Scene2xx::synchronize(s);
+
 	s.syncAsByte(_ambushFl);
 	s.syncAsByte(_wakeFl);
 
diff --git a/engines/mads/nebular/nebular_scenes2.h b/engines/mads/nebular/nebular_scenes2.h
index 750d45e..e70444a 100644
--- a/engines/mads/nebular/nebular_scenes2.h
+++ b/engines/mads/nebular/nebular_scenes2.h
@@ -55,12 +55,12 @@ private:
 
 public:
 	Scene201(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene202: public Scene2xx {
@@ -77,13 +77,13 @@ private:
 
 public:
 	Scene202(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 
 	void setRandomKernelMessage();
 };
@@ -94,13 +94,13 @@ private:
 
 public:
 	Scene203(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene205: public Scene2xx {
@@ -114,12 +114,12 @@ private:
 
 public:
 	Scene205(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene207: public Scene2xx {
@@ -133,13 +133,13 @@ private:
 
 public:
 	Scene207(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene208: public Scene2xx {
@@ -152,13 +152,13 @@ private:
 
 public:
 	Scene208(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene209: public Scene2xx {
@@ -198,13 +198,13 @@ private:
 
 public:
 	Scene209(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene210: public Scene2xx {
@@ -234,15 +234,16 @@ private:
 	void handleTwinklesSpeech(int quoteId, int shiftX, uint32 delay);
 	void newNode(int node);
 	void restoreDialogNode(int node, int msgId, int posY);
+
 public:
 	Scene210(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene211: public Scene2xx {
@@ -253,13 +254,13 @@ private:
 
 public:
 	Scene211(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene212: public Scene2xx {
@@ -289,12 +290,12 @@ private:
 
 public:
 	Scene214(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene215: public Scene2xx {
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 06c4eb6..5d7ee40 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -1193,6 +1193,12 @@ void Scene308::setup() {
 	setAAName();
 }
 
+void Scene308::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+
+	_forceField.synchronize(s);
+}
+
 void Scene308::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites("*SC003x0");
 	_globals._spriteIndexes[0] = _scene->_sprites.addSprites("*SC003x1");
@@ -1309,12 +1315,6 @@ void Scene308::step() {
 	}
 }
 
-void Scene308::synchronize(Common::Serializer &s) {
-	Scene3xx::synchronize(s);
-
-	_forceField.synchronize(s);
-}
-
 /*------------------------------------------------------------------------*/
 
 Scene309::Scene309(MADSEngine *vm) : Scene3xx(vm) {
@@ -1528,6 +1528,12 @@ void Scene310::setup() {
 	setAAName();
 }
 
+void Scene310::synchronize(Common::Serializer &s) {
+	Scene3xx::synchronize(s);
+
+	_forceField.synchronize(s);
+}
+
 void Scene310::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites("*SC003x0");
 	_globals._spriteIndexes[0] = _scene->_sprites.addSprites("*SC003x1");
@@ -1554,12 +1560,6 @@ void Scene310::step() {
 		_scene->_nextSceneId = 309;
 }
 
-void Scene310::synchronize(Common::Serializer &s) {
-	Scene3xx::synchronize(s);
-
-	_forceField.synchronize(s);
-}
-
 /*------------------------------------------------------------------------*/
 
 Scene311::Scene311(MADSEngine *vm) : Scene3xx(vm) {
diff --git a/engines/mads/nebular/nebular_scenes3.h b/engines/mads/nebular/nebular_scenes3.h
index 84c8fe7..30ab333 100644
--- a/engines/mads/nebular/nebular_scenes3.h
+++ b/engines/mads/nebular/nebular_scenes3.h
@@ -95,11 +95,11 @@ private:
 
 public:
 	Scene302(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene303: public Scene3xx {
@@ -117,11 +117,11 @@ private:
 
 public:
 	Scene304(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene307: public Scene3xx {
@@ -154,12 +154,12 @@ private:
 
 public:
 	Scene307(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene308: public Scene3xx {
@@ -168,11 +168,11 @@ private:
 
 public:
 	Scene308(MADSEngine *vm) : Scene3xx(vm) {}
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene309: public Scene3xx {
@@ -184,11 +184,11 @@ private:
 
 public:
 	Scene309(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene310: public Scene3xx {
@@ -197,11 +197,11 @@ private:
 
 public:
 	Scene310(MADSEngine *vm) : Scene3xx(vm) {}
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene311: public Scene3xx {
@@ -210,12 +210,12 @@ private:
 
 public:
 	Scene311(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene313: public Scene3xx {
@@ -269,13 +269,13 @@ private:
 
 public:
 	Scene318(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void preActions();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene319: public Scene3xx {
@@ -298,12 +298,12 @@ private:
 	void handleSlacheDialogs(int quoteId, int counter, uint32 timer);
 public:
 	Scene319(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene320: public Scene300s {
@@ -323,12 +323,12 @@ private:
 
 public:
 	Scene320(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene321: public Scene3xx {
@@ -377,12 +377,12 @@ private:
 
 public:
 	Scene352(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void preActions();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene353: public Scene3xx {
@@ -430,12 +430,12 @@ private:
 
 public:
 	Scene359(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void preActions();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene360: public Scene3xx {
@@ -498,12 +498,12 @@ private:
 
 public:
 	Scene389(MADSEngine *vm);
+	virtual void synchronize(Common::Serializer &s);
 
 	virtual void setup();
 	virtual void enter();
 	virtual void step();
 	virtual void actions();
-	virtual void synchronize(Common::Serializer &s);
 };
 
 class Scene390: public Scene300s {


Commit: 1bcd02177424aa2dd10dfe9788f1c0c75bc0c662
    https://github.com/scummvm/scummvm/commit/1bcd02177424aa2dd10dfe9788f1c0c75bc0c662
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-24T13:32:58-04:00

Commit Message:
MADS: Refactored VGA_COLOR_REV, which wasn't correct

Changed paths:
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index c34f2c6..fd39492 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -30,7 +30,6 @@
 namespace MADS {
 
 #define VGA_COLOR_TRANS(x) ((x) * 255 / 63)
-#define VGA_COLOR_REV(x) ((x) * 63 / 255)
 
 void RGB6::load(Common::SeekableReadStream *f) {
 	r = VGA_COLOR_TRANS(f->readByte());
@@ -342,6 +341,19 @@ Fader::Fader(MADSEngine *vm): _vm(vm) {
 	_colorFlags[3] = false;
 	_colorValues[0] = _colorValues[1] = 0;
 	_colorValues[2] = _colorValues[3] = 0;
+
+	// TODO: It would be better if the fader routines could be refactored
+	// to work directly with 8-bit RGB values rather than 6-bit RGB values
+	Common::fill(&_rgb64Map[0], &_rgb64Map[PALETTE_COUNT], 0);
+	for (int i = 0; i < 64; ++i)
+		_rgb64Map[VGA_COLOR_TRANS(i)] = i;
+	byte v = 0;
+	for (int i = 0; i < PALETTE_COUNT; ++i) {
+		if (_rgb64Map[i])
+			v = _rgb64Map[i];
+		else
+			_rgb64Map[i] = v;
+	}
 }
 
 
@@ -377,7 +389,7 @@ void Fader::fadeToGrey(byte palette[PALETTE_SIZE], byte *paletteMap,
 				intensity = _colorValues[colorCtr];
 			}
 
-			int diff = intensity - VGA_COLOR_REV(palette[palCtr * 3 + colorCtr]);
+			int diff = intensity - _rgb64Map[palette[palCtr * 3 + colorCtr]];
 			palIndex[palCtr][colorCtr] = (byte)ABS(diff);
 			signs[palCtr][colorCtr] = (diff == 0) ? 0 : (diff < 0 ? -1 : 1);
 		}
@@ -391,7 +403,7 @@ void Fader::fadeToGrey(byte palette[PALETTE_SIZE], byte *paletteMap,
 				while (map[index]._accum[colorCtr] >= steps) {
 					map[index]._accum[colorCtr] -= steps;
 
-					byte rgb63 = VGA_COLOR_REV(palette[palCtr * 3 + colorCtr]) +
+					byte rgb63 = _rgb64Map[palette[palCtr * 3 + colorCtr]] +
 						signs[palCtr][colorCtr];
 					palette[palCtr * 3 + colorCtr] = VGA_COLOR_TRANS(rgb63);
 				}
@@ -561,7 +573,7 @@ int Fader::rgbMerge(RGB6 &palEntry) {
 }
 
 int Fader::rgbMerge(byte r, byte g, byte b) {
-	return VGA_COLOR_REV(r) * 38 + VGA_COLOR_REV(g) * 76 + VGA_COLOR_REV(b) * 14;
+	return _rgb64Map[r] * 38 + _rgb64Map[g] * 76 + _rgb64Map[b] * 14;
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 3af0c28..92d23d6 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -187,6 +187,7 @@ private:
 	void insertionSort(int size, byte *id, byte *value);
 protected:
 	MADSEngine *_vm;
+	byte _rgb64Map[PALETTE_COUNT];
 public:
 	bool _colorFlags[4];
 	int _colorValues[4];
@@ -223,12 +224,12 @@ public:
 	/**
 	* Calculates a merge/hash for a given palette entry
 	*/
-	static int rgbMerge(byte r, byte g, byte b);
+	int rgbMerge(byte r, byte g, byte b);
 
 	/**
 	* Calculates a merge/hash for a given palette entry
 	*/
-	static int rgbMerge(RGB6 &palEntry);
+	int rgbMerge(RGB6 &palEntry);
 
 	/**
 	* Fades the given palette to greyscale


Commit: 3202abaa8922bc741b3f28e1a2c1a86d8639a5f4
    https://github.com/scummvm/scummvm/commit/3202abaa8922bc741b3f28e1a2c1a86d8639a5f4
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-24T13:41:22-04:00

Commit Message:
MADS: Standardized fading out methods as fadeOut

Changed paths:
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/palette.cpp
    engines/mads/palette.h



diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index f22ec1a..2a421d1 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -404,7 +404,7 @@ void PictureDialog::save() {
 
 	// Fade the screen to grey
 	int numColors = PALETTE_COUNT - PALETTE_RESERVED_LOW_COUNT - PALETTE_RESERVED_HIGH_COUNT;
-	palette.fadeToGrey(palette._mainPalette, &map[PALETTE_RESERVED_LOW_COUNT],
+	palette.fadeOut(palette._mainPalette, &map[PALETTE_RESERVED_LOW_COUNT],
 		PALETTE_RESERVED_LOW_COUNT, numColors, 248, 8, 1, 16);
 
 	// Remap the greyed out screen to use the small greyscale range
@@ -521,7 +521,7 @@ ScreenDialog::ScreenDialog(MADSEngine *vm) : _vm(vm),
 		_vm->_palette->setFullPalette(pal);
 	} else {
 		_vm->_palette->getFullPalette(pal);
-		_vm->_palette->fadeOut(pal, 0, PALETTE_COUNT, 16, 1, 1, 0, 0, 0);
+		_vm->_palette->fadeOut(pal, nullptr, 0, PALETTE_COUNT, 0, 1, 1, 16);
 	}
 
 	_vm->_screen.copyTo(&_savedSurface);
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 5d7ee40..ddff434 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -3323,7 +3323,8 @@ void Scene319::step() {
 	case 72:
 		_vm->_palette->setColorFlags(0xFF, 0, 0);
 		_vm->_palette->setColorValues(0, 0, 0);
-		_vm->_palette->fadeOut(_vm->_palette->_mainPalette, 18, 228, 16, 1, 8, 248, 0, 0);
+		_vm->_palette->fadeOut(_vm->_palette->_mainPalette, nullptr, 18, 228,
+			248, 0, 1, 16);
 		warning("TODO: shake_countdown = 1;");
 		_scene->_reloadSceneFlag = true;
 		break;
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index fd39492..29045bc 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -365,7 +365,7 @@ void Fader::grabPalette(byte *colors, uint start, uint num) {
 	g_system->getPaletteManager()->grabPalette(colors, start, num);
 }
 
-void Fader::fadeToGrey(byte palette[PALETTE_SIZE], byte *paletteMap,
+void Fader::fadeOut(byte palette[PALETTE_SIZE], byte *paletteMap,
 		int baseColor, int numColors, int baseGrey, int numGreys,
 		int tickDelay, int steps) {
 	GreyEntry map[PALETTE_COUNT];
@@ -736,10 +736,6 @@ void Palette::setColorValues(byte r, byte g, byte b) {
 	_colorValues[2] = b;
 }
 
-void Palette::fadeOut(byte palette[PALETTE_SIZE], int start, int count, int v1, int v2, int v3, int v4, int v5, int v6) {
-	warning("TODO: Palette::fadeOut()");
-}
-
 void Palette::lock() {
 	if (_rgbList[31] && !_lockFl)
 		error("Palette Lock - Unexpected values");
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 92d23d6..6d9498d 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -232,9 +232,9 @@ public:
 	int rgbMerge(RGB6 &palEntry);
 
 	/**
-	* Fades the given palette to greyscale
+	* Fades the given palette out to black or grey
 	*/
-	void fadeToGrey(byte palette[PALETTE_SIZE], byte *paletteMap,
+	void fadeOut(byte palette[PALETTE_SIZE], byte *paletteMap,
 		int baseColor, int numColors, int baseGrey, int numGreys,
 		int tickDelay, int steps);
 };
@@ -311,7 +311,6 @@ public:
 
 	void setColorFlags(byte r, byte g, byte b);
 	void setColorValues(byte r, byte g, byte b);
-	void fadeOut(byte palette[PALETTE_SIZE], int start, int count, int v1, int v2, int v3, int v4, int v5, int v6);
 
 	void lock();
 	void unlock();


Commit: b2860fc675db9958c994778a12947880812d4690
    https://github.com/scummvm/scummvm/commit/b2860fc675db9958c994778a12947880812d4690
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-24T14:21:03-04:00

Commit Message:
MADS: Implemented scene fading

Changed paths:
    engines/mads/nebular/dialogs_nebular.cpp
    engines/mads/palette.cpp
    engines/mads/palette.h
    engines/mads/screen.cpp
    engines/mads/screen.h



diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp
index 2a421d1..a4a7694 100644
--- a/engines/mads/nebular/dialogs_nebular.cpp
+++ b/engines/mads/nebular/dialogs_nebular.cpp
@@ -388,6 +388,8 @@ void PictureDialog::save() {
 	_rgbList.copy(palette._rgbList);
 
 	// Set up palette allocation
+	Common::fill(&palette._colorFlags[0], &palette._colorFlags[3], true);
+
 	uint32 *palFlagP = &palette._palFlags[0];
 	for (int idx = 0; idx < PALETTE_COUNT; ++idx, ++palFlagP) {
 		if (idx < PALETTE_RESERVED_LOW_COUNT ||
diff --git a/engines/mads/palette.cpp b/engines/mads/palette.cpp
index 29045bc..9f56223 100644
--- a/engines/mads/palette.cpp
+++ b/engines/mads/palette.cpp
@@ -422,6 +422,64 @@ void Fader::fadeOut(byte palette[PALETTE_SIZE], byte *paletteMap,
 	}
 }
 
+void Fader::fadeIn(byte palette[PALETTE_SIZE], byte destPalette[PALETTE_SIZE],
+	int baseColor, int numColors, int baseGrey, int numGreys,
+	int tickDelay, int steps) {
+	GreyEntry map[PALETTE_COUNT];
+	byte tempPal[PALETTE_SIZE];;
+	int8 signs[PALETTE_COUNT][3];
+	byte palIndex[PALETTE_COUNT][3];
+	int intensity;
+
+	Common::copy(destPalette, destPalette + PALETTE_SIZE, tempPal);
+
+	mapToGreyRamp(tempPal, baseColor, numColors, baseGrey, numGreys, map);
+
+	for (int palCtr = baseColor; palCtr < (baseColor + numColors); ++palCtr) {
+		int index = palCtr - baseColor;
+		for (int colorCtr = 0; colorCtr < 3; ++colorCtr) {
+			if (_colorFlags[colorCtr]) {
+				int shiftSign = _colorValues[colorCtr];
+				if (shiftSign >= 0) {
+					intensity = map[index]._intensity << shiftSign;
+				}
+				else {
+					intensity = map[index]._intensity >> abs(shiftSign);
+				}
+			}
+			else {
+				intensity = _colorValues[colorCtr];
+			}
+
+			int diff = _rgb64Map[destPalette[palCtr * 3 + colorCtr]] - intensity;
+			palIndex[palCtr][colorCtr] = (byte)ABS(diff);
+			signs[palCtr][colorCtr] = (diff == 0) ? 0 : (diff < 0 ? -1 : 1);
+
+			map[index]._accum[colorCtr] = 0;
+		}
+	}
+
+	for (int stepCtr = 0; stepCtr < steps; ++stepCtr) {
+		for (int palCtr = baseColor; palCtr < (baseColor + numColors); ++palCtr) {
+			int index = palCtr - baseColor;
+			for (int colorCtr = 0; colorCtr < 3; ++colorCtr) {
+				map[index]._accum[colorCtr] += palIndex[palCtr][colorCtr];
+				while (map[index]._accum[colorCtr] >= steps) {
+					map[index]._accum[colorCtr] -= steps;
+
+					byte rgb63 = _rgb64Map[palette[palCtr * 3 + colorCtr]] +
+						signs[palCtr][colorCtr];
+					palette[palCtr * 3 + colorCtr] = VGA_COLOR_TRANS(rgb63);
+				}
+			}
+		}
+
+		setFullPalette(palette);
+
+		_vm->_events->waitForNextFrame();
+	}
+}
+
 void Fader::mapToGreyRamp(byte palette[PALETTE_SIZE], int baseColor, int numColors,
 		int baseGrey, int numGreys, GreyEntry *map) {
 	byte greyList[PALETTE_COUNT];
diff --git a/engines/mads/palette.h b/engines/mads/palette.h
index 6d9498d..0698e21 100644
--- a/engines/mads/palette.h
+++ b/engines/mads/palette.h
@@ -237,6 +237,13 @@ public:
 	void fadeOut(byte palette[PALETTE_SIZE], byte *paletteMap,
 		int baseColor, int numColors, int baseGrey, int numGreys,
 		int tickDelay, int steps);
+
+	/**
+	 * Fade into the given palette
+	 */
+	void fadeIn(byte palette[PALETTE_SIZE], byte destPalette[PALETTE_SIZE],
+		int baseColor, int numColors, int baseGrey, int numGreys,
+		int tickDelay, int steps);
 };
 
 class Palette: public Fader {
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index 6a70bfb..ae12999 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -570,14 +570,27 @@ void ScreenSurface::updateScreen() {
 }
 
 void ScreenSurface::transition(ScreenTransition transitionType, bool surfaceFlag) {
+	Palette &pal = *_vm->_palette;
+	byte palData[PALETTE_SIZE];
+
 	switch (transitionType) {
+	case kTransitionFadeIn:
 	case kTransitionFadeOutIn:
-		fadeOut();
-		fadeIn();
-		break;
+		Common::fill(&pal._colorValues[0], &pal._colorValues[3], 0);
+		Common::fill(&pal._colorFlags[0], &pal._colorFlags[3], false);
 
-	case kTransitionFadeIn:
-		fadeIn();
+		if (transitionType == kTransitionFadeOutIn) {
+			// Fade out
+			pal.getFullPalette(palData);
+			pal.fadeOut(palData, nullptr, 0, PALETTE_COUNT, 0, 0, 1, 16);
+		}
+
+		// Reset palette to black
+		Common::fill(&palData[0], &palData[PALETTE_SIZE], 0);
+		pal.setFullPalette(palData);
+
+		copyRectToScreen(getBounds());
+		pal.fadeIn(palData, pal._mainPalette, 0, 256, 0, 1, 1, 16);
 		break;
 
 	case kTransitionBoxInBottomLeft:
@@ -606,14 +619,4 @@ void ScreenSurface::transition(ScreenTransition transitionType, bool surfaceFlag
 	}
 }
 
-void ScreenSurface::fadeOut() {
-	warning("TODO: Proper fade out");
-}
-
-void ScreenSurface::fadeIn() {
-	warning("TODO: Proper fade in");
-	_vm->_palette->setFullPalette(_vm->_palette->_mainPalette);
-	_vm->_screen.copyRectToScreen(Common::Rect(0, 0, 320, 200));
-}
-
 } // End of namespace MADS
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index 4ad5820..0e678d8 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -197,16 +197,6 @@ public:
 };
 
 class ScreenSurface : public MSurface {
-private:
-	/**
-	 * Handles screen fade out
-	 */
-	void fadeOut();
-
-	/**
-	 * Handles screen fade in
-	 */
-	void fadeIn();
 public:
 	Common::Point _offset;
 public:


Commit: 722b32506e5d28a5037b1bb1bef6f8759af13423
    https://github.com/scummvm/scummvm/commit/722b32506e5d28a5037b1bb1bef6f8759af13423
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-24T14:44:12-04:00

Commit Message:
MADS: Replaced a TODO with a stubbed method

Changed paths:
    engines/mads/scene.cpp
    engines/mads/scene_data.h



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 0e3960c..d589010 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -548,7 +548,7 @@ void Scene::doAction() {
 
 			if (_action._inProgress) {
 				_action._savedFields._commandError = true;
-				warning("TODO: PtrUnk4");
+				_sceneLogic->unhandledAction();
 			}
 
 			if (_action._inProgress)
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index 83caec5..db25298 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -115,6 +115,11 @@ public:
 	virtual void postActions() {}
 
 	/**
+	 * Unhandled action handling
+	 */
+	virtual void unhandledAction() {}
+
+	/**
 	 * Synchronize any local data for the scene
 	 */
 	virtual void synchronize(Common::Serializer &s) {}


Commit: 0d54216beb634ee3c8ef1be12b5935d63f040746
    https://github.com/scummvm/scummvm/commit/0d54216beb634ee3c8ef1be12b5935d63f040746
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-24T15:05:23-04:00

Commit Message:
MADS: Fix checks for assets count when calling releasePlayerSprites

Changed paths:
    engines/mads/game.cpp
    engines/mads/player.cpp



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index f8d6c36..ac77aec 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -170,7 +170,7 @@ void Game::gameLoop() {
 			sectionLoop();
 
 		_player.releasePlayerSprites();
-		assert(_scene._sprites.size() == 0);
+		assert(_scene._sprites._assetCount == 0);
 
 		_vm->_palette->unlock();
 		_vm->_events->waitCursor();
diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index a9c9f11..a9bc0cd 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -694,8 +694,7 @@ void Player::releasePlayerSprites() {
 	_spritesLoaded = false;
 	_spritesChanged = true;
 
-	// FIXME: Find out why this occurs
-	if (scene._sprites.size() > 0) {
+	if (scene._sprites._assetCount > 0) {
 		warning("Player::releasePlayerSprites(): leftover sprites remain, clearing list");
 		scene._sprites.clear();
 	}


Commit: 786c771bb89648b74825a92f983563ad1b94083a
    https://github.com/scummvm/scummvm/commit/786c771bb89648b74825a92f983563ad1b94083a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-24T16:36:34-04:00

Commit Message:
MADS: Implement screen shaking

Changed paths:
    engines/mads/game.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/screen.cpp
    engines/mads/screen.h



diff --git a/engines/mads/game.cpp b/engines/mads/game.cpp
index ac77aec..3f42471 100644
--- a/engines/mads/game.cpp
+++ b/engines/mads/game.cpp
@@ -495,6 +495,7 @@ void Game::loadGame(int slotNumber) {
 	_scene._currentSceneId = -2;
 	_sectionNumber = _scene._nextSceneId / 100;
 	_scene._frameStartTime = _vm->_events->getFrameCounter();
+	_vm->_screen._shakeCountdown = -1;
 
 	// Default the selected inventory item to the first one, if the player has any
 	_scene._userInterface._selectedInvIndex = _objects._inventoryList.size() > 0 ? 0 : -1;
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index ddff434..11eb2f8 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -2800,7 +2800,7 @@ void Scene318::step() {
 
 		if (_internCounter >= 3600) {
 			_vm->_sound->command(59);
-			warning("TODO: shake_countdown = 20;");
+			_vm->_screen._shakeCountdown = 20;
 			_internWalkingFl = true;
 		}
 	}
@@ -3270,22 +3270,22 @@ void Scene319::step() {
 
 		if (_animMode == 2) {
 			if (_animFrame == 13)
-				warning("TODO: shake_countdown = 40;");
+				_vm->_screen._shakeCountdown = 40;
 
 			if (_animFrame == 16)
-				warning("TODO: shake_countdown = 1;");
+				_vm->_screen._shakeCountdown = 1;
 		}
 
 		if (_animMode == 3) {
 			if (_animFrame == 11)
-				warning("TODO: shake_countdown = 60;");
+				_vm->_screen._shakeCountdown = 60;
 
 			if (_animFrame == 18)
-				warning("TODO: shake_countdown = 1;");
+				_vm->_screen._shakeCountdown = 1;
 		}
 
 		if ((_animMode == 4) && (_animFrame == 16))
-			warning("TODO: shake_countdown = 80;");
+			_vm->_screen._shakeCountdown = 80;
 
 		if ((nextFrame >= 0) && (nextFrame != _scene->_activeAnimation->getCurrentFrame())) {
 			_scene->_activeAnimation->setCurrentFrame(nextFrame);
@@ -3308,7 +3308,7 @@ void Scene319::step() {
 
 		_animFrame = _scene->_activeAnimation->getCurrentFrame();
 		_slacheTalkingFl = true;
-		warning("TODO: shake_countdown = 1;");
+		_vm->_screen._shakeCountdown = 1;
 
 		for (int i = 0; i <= 1; i++) {
 			int oldIdx = _globals._sequenceIndexes[i];
@@ -3325,7 +3325,7 @@ void Scene319::step() {
 		_vm->_palette->setColorValues(0, 0, 0);
 		_vm->_palette->fadeOut(_vm->_palette->_mainPalette, nullptr, 18, 228,
 			248, 0, 1, 16);
-		warning("TODO: shake_countdown = 1;");
+		_vm->_screen._shakeCountdown = 1;
 		_scene->_reloadSceneFlag = true;
 		break;
 
@@ -3706,7 +3706,7 @@ void Scene320::step() {
 
 			case 417:
 			case 457:
-				warning("TODO: shake_countdown = 40;");
+				_vm->_screen._shakeCountdown = 40;
 				_vm->_sound->command(59);
 				break;
 
diff --git a/engines/mads/screen.cpp b/engines/mads/screen.cpp
index ae12999..dacd20a 100644
--- a/engines/mads/screen.cpp
+++ b/engines/mads/screen.cpp
@@ -545,6 +545,8 @@ void ScreenObjects::synchronize(Common::Serializer &s) {
 /*------------------------------------------------------------------------*/
 
 ScreenSurface::ScreenSurface() {
+	_shakeCountdown = -1;
+	_random = 0x4D2;
 }
 
 void ScreenSurface::init() {
@@ -553,7 +555,7 @@ void ScreenSurface::init() {
 
 void ScreenSurface::copyRectToScreen(const Common::Point &destPos,
 		const Common::Rect &bounds) {
-	byte *buf = getBasePtr(destPos.x, destPos.y);
+	const byte *buf = getBasePtr(destPos.x, destPos.y);
 
 	if (bounds.width() != 0 && bounds.height() != 0)
 		g_system->copyRectToScreen(buf, this->pitch, bounds.left, bounds.top,
@@ -564,8 +566,25 @@ void ScreenSurface::copyRectToScreen(const Common::Rect &bounds) {
 	copyRectToScreen(Common::Point(bounds.left, bounds.top), bounds);
 }
 
-
 void ScreenSurface::updateScreen() {
+	if (_shakeCountdown >= 0) {
+		_random = _random * 5 + 1;
+		int offset = (_random >> 8) & 3;
+		if (_shakeCountdown-- <= 0)
+			offset = 0;
+
+		// Copy the screen with the left hand hide side of the screen of a given
+		// offset width shown at the very right. The offset changes to give 
+		// an effect of shaking the screen
+		offset *= 4;
+		const byte *buf = getBasePtr(offset, 0);
+		g_system->copyRectToScreen(buf, this->pitch, 0, 0,
+			this->pitch - offset, this->h);
+		if (offset > 0)
+			g_system->copyRectToScreen(this->pixels, this->pitch, 
+				this->pitch - offset, 0, offset, this->h);
+	}
+
 	g_system->updateScreen();
 }
 
diff --git a/engines/mads/screen.h b/engines/mads/screen.h
index 0e678d8..b81fddd 100644
--- a/engines/mads/screen.h
+++ b/engines/mads/screen.h
@@ -197,8 +197,11 @@ public:
 };
 
 class ScreenSurface : public MSurface {
+private:
+	uint16 _random;
 public:
 	Common::Point _offset;
+	int _shakeCountdown;
 public:
 	/**
 	 * Constructor


Commit: ef22702ac4f01ab79248dd41b49b37fb119f68e9
    https://github.com/scummvm/scummvm/commit/ef22702ac4f01ab79248dd41b49b37fb119f68e9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-24T17:25:33-04:00

Commit Message:
MADS: Fix for standing up from chair in scene 101

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 59432c1..9fb3808 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -306,7 +306,7 @@ void Scene101::preActions() {
 		if (_game._player._needToWalk) {
 			switch (_game._trigger) {
 			case 0:
-				_game._player._needToWalk = false;
+				_game._player._readyToWalk = false;
 				_game._player._stepEnabled = false;
 				_scene->_sequences.remove(_globals._sequenceIndexes[11]);
 				_globals._sequenceIndexes[11] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[11], false, 3, 1, 0, 0);
@@ -319,7 +319,7 @@ void Scene101::preActions() {
 				_sittingFl = false;
 				_game._player._visible = true;
 				_game._player._stepEnabled = true;
-				_game._player._needToWalk = true;
+				_game._player._readyToWalk = true;
 				_scene->_hotspots.activate(71, true);
 				_scene->_dynamicHotspots.remove(_chairHotspotId);
 				_globals._sequenceIndexes[12] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[12], false, 6, 0, 0, 0);


Commit: 8f9a75a9255fbccb8be3bbe6fc35aafec00a4260
    https://github.com/scummvm/scummvm/commit/8f9a75a9255fbccb8be3bbe6fc35aafec00a4260
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-24T18:19:54-04:00

Commit Message:
MADS: Add _sceneSurface subsurface, so sprite drawing is cropped correctly

Changed paths:
    engines/mads/scene.cpp
    engines/mads/scene.h



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index d589010..944c082 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -61,6 +61,11 @@ Scene::Scene(MADSEngine *vm): _vm(vm), _action(_vm), _depthSurface(vm),
 
 	_paletteUsageF.push_back(PaletteUsage::UsageEntry(0xF));
 
+	// Set up a scene surface that maps to our physical screen drawing surface
+	_sceneSurface.init(MADS_SCREEN_WIDTH, MADS_SCENE_HEIGHT, MADS_SCREEN_WIDTH,
+		_vm->_screen.getPixels(), Graphics::PixelFormat::createFormatCLUT8());
+
+	// Set up the verb list
 	_verbList.push_back(VerbInit(VERB_LOOK, VERB_THAT, PREP_NONE));
 	_verbList.push_back(VerbInit(VERB_TAKE, VERB_THAT, PREP_NONE));
 	_verbList.push_back(VerbInit(VERB_PUSH, VERB_THAT, PREP_NONE));
@@ -487,7 +492,7 @@ void  Scene::drawElements(ScreenTransition transitionType, bool surfaceFlag) {
 
 	// Draw sprites that have changed
 	if (_vm->getGameID() == GType_RexNebular)	// TODO: Implement for V2 games
-		_spriteSlots.drawSprites(&_vm->_screen);
+		_spriteSlots.drawSprites(&_sceneSurface);
 
 	// Draw text elements onto the view
 	_textDisplay.draw(&_vm->_screen);
diff --git a/engines/mads/scene.h b/engines/mads/scene.h
index 27fb901..7a01d73 100644
--- a/engines/mads/scene.h
+++ b/engines/mads/scene.h
@@ -84,6 +84,7 @@ protected:
 	MADSEngine *_vm;
 public:
 	SceneLogic *_sceneLogic;
+	MSurface _sceneSurface;
 	int _priorSceneId;
 	int _nextSceneId;
 	int _currentSceneId;


Commit: 87f7c0cda3a7d3ce46d8ad0cb39ce33a0f40d557
    https://github.com/scummvm/scummvm/commit/87f7c0cda3a7d3ce46d8ad0cb39ce33a0f40d557
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-24T18:56:44-04:00

Commit Message:
MADS: Generalize sequence record _msgPos as _position

Changed paths:
    engines/mads/messages.cpp
    engines/mads/nebular/nebular_scenes.cpp
    engines/mads/nebular/nebular_scenes1.cpp
    engines/mads/nebular/nebular_scenes1.h
    engines/mads/nebular/nebular_scenes2.cpp
    engines/mads/nebular/nebular_scenes3.cpp
    engines/mads/nebular/nebular_scenes4.cpp
    engines/mads/nebular/nebular_scenes6.cpp
    engines/mads/nebular/nebular_scenes7.cpp
    engines/mads/nebular/nebular_scenes8.cpp
    engines/mads/sequence.cpp
    engines/mads/sequence.h



diff --git a/engines/mads/messages.cpp b/engines/mads/messages.cpp
index 4fd02cc..263d8fa 100644
--- a/engines/mads/messages.cpp
+++ b/engines/mads/messages.cpp
@@ -210,8 +210,8 @@ void KernelMessages::processText(int msgIndex) {
 			x1 = frame->getBounds().left;
 			y1 = frame->getBounds().top;
 		} else {
-			x1 = seqEntry._msgPos.x;
-			y1 = seqEntry._msgPos.y;
+			x1 = seqEntry._position.x;
+			y1 = seqEntry._position.y;
 		}
 	}
 
diff --git a/engines/mads/nebular/nebular_scenes.cpp b/engines/mads/nebular/nebular_scenes.cpp
index f8c113e..cbfc055 100644
--- a/engines/mads/nebular/nebular_scenes.cpp
+++ b/engines/mads/nebular/nebular_scenes.cpp
@@ -420,7 +420,7 @@ void SceneTeleporter::teleporterHandleKey() {
 		_game._player._stepEnabled = false;
 		Common::Point msgPos = teleporterComputeLocation();
 		_handSequenceId = _scene->_sequences.startReverseCycle(_handSpriteId, false, 4, 2, 0, 0);
-		_scene->_sequences.setMsgPosition(_handSequenceId, msgPos);
+		_scene->_sequences.setPosition(_handSequenceId, msgPos);
 		_scene->_sequences.setDepth(_handSequenceId, 2);
 		_scene->_sequences.addSubEntry(_handSequenceId, SEQUENCE_TRIGGER_LOOP, 0, 1);
 		_scene->_sequences.addSubEntry(_handSequenceId, SEQUENCE_TRIGGER_EXPIRE, 0, 2);
diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 9fb3808..1b875ae 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -1671,14 +1671,14 @@ void Scene104::step() {
 				_globals._spriteIndexes[2] = _scene->_sprites.addSprites(formAnimName('a', 0));
 				_vm->_palette->refreshSceneColors();
 				_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], mirrorFl, 7, 1, 0, 0);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(198, 143));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(198, 143));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 				break;
 
 			case 1:
 				_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], mirrorFl, 7, 0, 0, 0);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(198, 143));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(198, 143));
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], -2, -2);
 				_scene->_sequences.addTimer(90, 2);
 				break;
@@ -1704,7 +1704,7 @@ void Scene104::step() {
 				_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 1));
 				_vm->_palette->refreshSceneColors();
 				_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 1, 0, 0);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(198, 143));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[3], Common::Point(198, 143));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 4);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 14);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
@@ -1712,7 +1712,7 @@ void Scene104::step() {
 
 			case 1:
 				_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 5, 1, 0, 0);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(198, 143));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[3], Common::Point(198, 143));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 4);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 15, 32);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
@@ -1720,7 +1720,7 @@ void Scene104::step() {
 
 			case 2:
 				_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 3, 0, 0, 0);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(198, 143));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[3], Common::Point(198, 143));
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], -2, -2);
 				_scene->_sequences.addTimer(90, 3);
 				break;
@@ -1746,7 +1746,7 @@ void Scene104::step() {
 				_globals._spriteIndexes[4] = _scene->_sprites.addSprites(formAnimName('a', 2));
 				_vm->_palette->refreshSceneColors();
 				_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 8, 1, 0, 0);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(198, 143));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(198, 143));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 4);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 				if (_game._storyMode >= STORYMODE_NICE)
@@ -1755,7 +1755,7 @@ void Scene104::step() {
 
 			case 1:
 				_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 8, 0, 0, 0);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(198, 143));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(198, 143));
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], -2, -2);
 				_scene->_sequences.addTimer(90, 2);
 				break;
@@ -1842,7 +1842,7 @@ void Scene105::enter() {
 
 	if (_globals[kFishIn105]) {
 		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6, 0, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(48, 144));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(48, 144));
 
 		int idx = _scene->_dynamicHotspots.add(101, 348, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(56, 141), FACING_NORTHWEST);
@@ -1982,7 +1982,7 @@ Scene106::Scene106(MADSEngine *vm) : Scene1xx(vm) {
 	_backToShipFl = false;
 	_shadowFl = false;
 	_firstEmergingFl = false;
-	_msgPosY = 0;
+	_positionY = 0;
 }
 
 void Scene106::synchronize(Common::Serializer &s) {
@@ -1991,7 +1991,7 @@ void Scene106::synchronize(Common::Serializer &s) {
 	s.syncAsByte(_backToShipFl);
 	s.syncAsByte(_shadowFl);
 	s.syncAsByte(_firstEmergingFl);
-	s.syncAsSint32LE(_msgPosY);
+	s.syncAsSint32LE(_positionY);
 }
 
 void Scene106::setup() {
@@ -2093,7 +2093,7 @@ void Scene106::step() {
 		int msgId = -1;
 		switch (tmpVal) {
 		case 0:
-			_msgPosY = 26;
+			_positionY = 26;
 			msgId = 49;
 			break;
 
@@ -2117,9 +2117,9 @@ void Scene106::step() {
 
 		if (msgId >= 0) {
 			int nextAbortVal = _game._trigger + 1;
-			_scene->_kernelMessages.add(Common::Point(15, _msgPosY), 0x1110, 0, 0, 360, _game.getQuote(msgId));
+			_scene->_kernelMessages.add(Common::Point(15, _positionY), 0x1110, 0, 0, 360, _game.getQuote(msgId));
 			_scene->_sequences.addTimer(150, nextAbortVal);
-			_msgPosY += 14;
+			_positionY += 14;
 		}
 	}
 
@@ -2233,7 +2233,7 @@ void Scene107::enter() {
 
 	if (_globals[kFishIn107]) {
 		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6, 0, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(68, 151));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(68, 151));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
 		int idx = _scene->_dynamicHotspots.add(101, 348, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(78, 135), FACING_SOUTHWEST);
@@ -2249,7 +2249,7 @@ void Scene107::enter() {
 	if (((_scene->_priorSceneId == 105) || (_scene->_priorSceneId == 106)) && (_vm->getRandomNumber(1, 3) == 1)) {
 		_globals._spriteIndexes[0] = _scene->_sprites.addSprites(Resources::formatName(105, 'R', 1, EXT_SS, ""));
 		_globals._sequenceIndexes[0] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[0], true, 4, 0, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[0], Common::Point(270, 150));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[0], Common::Point(270, 150));
 		_scene->_sequences.setMotion(_globals._sequenceIndexes[0], SEQUENCE_TRIGGER_SPRITE, -200, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[0], 2);
 		_scene->_dynamicHotspots.add(218, 348, _globals._sequenceIndexes[0], Common::Rect(0, 0, 0, 0));
@@ -2348,7 +2348,7 @@ void Scene108::enter() {
 
 	if (_globals[kFishIn108]) {
 		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6, 0, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(41, 109));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(41, 109));
 		int idx = _scene->_dynamicHotspots.add(101, 348, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(41, 109), FACING_NORTHWEST);
 	}
@@ -2508,7 +2508,7 @@ void Scene109::enter() {
 
 		_globals._sequenceIndexes[10] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[10], true, 4, 0, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 5);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(126, 39));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[10], Common::Point(126, 39));
 		_scene->_sequences.setMotion(_globals._sequenceIndexes[10], 0, 200, 0);
 		_scene->_sequences.setScale(_globals._sequenceIndexes[10], 80);
 		_game._player._stepEnabled = false;
@@ -2559,7 +2559,7 @@ void Scene109::step() {
 		_hungryFl = true;
 	}
 
-	if (_eatingFirstFish && (_scene->_sequences[_globals._sequenceIndexes[10]]._msgPos.x >= 178)) {
+	if (_eatingFirstFish && (_scene->_sequences[_globals._sequenceIndexes[10]]._position.x >= 178)) {
 		_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 4, 1, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 4);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_SPRITE, 29, 72);
diff --git a/engines/mads/nebular/nebular_scenes1.h b/engines/mads/nebular/nebular_scenes1.h
index 9eb2134..96d2bb9 100644
--- a/engines/mads/nebular/nebular_scenes1.h
+++ b/engines/mads/nebular/nebular_scenes1.h
@@ -154,7 +154,7 @@ private:
 	bool _shadowFl;
 	bool _firstEmergingFl;
 
-	int _msgPosY;
+	int _positionY;
 
 public:
 	Scene106(MADSEngine *vm);
diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp
index adb174c..f93ea39 100644
--- a/engines/mads/nebular/nebular_scenes2.cpp
+++ b/engines/mads/nebular/nebular_scenes2.cpp
@@ -147,7 +147,7 @@ void Scene201::enter() {
 	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 4, 0, 0, 0);
 	_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6, 0, 0, 0);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 8);
-	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(185, 46));
+	_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(185, 46));
 
 	int idx = _scene->_dynamicHotspots.add(NOUN_BIRDS, 209, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 	_scene->_dynamicHotspots.setPosition(idx, Common::Point(186, 81), FACING_NORTH);
@@ -401,14 +401,14 @@ void Scene202::enter() {
 
 	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 6, 0, 0, 0);
 	_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 0);
-	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(149, 113));
+	_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(149, 113));
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 10);
 	int idx = _scene->_dynamicHotspots.add(NOUN_BONE, VERB_WALKTO, _globals._sequenceIndexes[2], Common::Rect(0, 0, 0, 0));
 	_scene->_dynamicHotspots.setPosition(idx, Common::Point(153, 97), FACING_SOUTH);
 
 	if (!(_globals[kBone202Status] & 1)) {
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(130, 108));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(130, 108));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 		idx = _scene->_dynamicHotspots.add(NOUN_BONE, VERB_WALKTO, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(132, 97), FACING_SOUTH);
@@ -416,7 +416,7 @@ void Scene202::enter() {
 
 	if (!(_globals[kBone202Status] & 2)) {
 		_globals._sequenceIndexes[6] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[6], false, 6, 0, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[6], Common::Point(166, 110));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[6], Common::Point(166, 110));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 10);
 		idx = _scene->_dynamicHotspots.add(NOUN_BONE, VERB_WALKTO, _globals._sequenceIndexes[6], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(165, 99), FACING_SOUTH);
@@ -468,7 +468,7 @@ void Scene202::enter() {
 			_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 8);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
 
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(247, 82));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[10], Common::Point(247, 82));
 			_game._player._playerPos = Common::Point(246, 124);
 			_game._player._facing = FACING_NORTH;
 			_globals[kTeleporterUnderstood] = true;
@@ -476,7 +476,7 @@ void Scene202::enter() {
 			_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
 
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
 			_game._player._playerPos = Common::Point(171, 122);
 			_game._player._facing = FACING_NORTH;
 		}
@@ -488,7 +488,7 @@ void Scene202::enter() {
 			_game._player._visible = false;
 			_scene->_sequences.startCycle(_globals._sequenceIndexes[9], true, 1);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
 			_game._player._playerPos = Common::Point(246, 124);
 			_game._player._facing = FACING_NORTH;
 		}
@@ -555,13 +555,13 @@ void Scene202::step() {
 		_vm->_sound->command(41);
 		_scene->_sequences.remove(_globals._sequenceIndexes[10]);
 		_globals._sequenceIndexes[9] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 91);
 		break;
 	case 91:
 		_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
 		_scene->_sequences.addTimer(60, 92);
 		break;
@@ -858,7 +858,7 @@ void Scene202::actions() {
 			break;
 		case 1: {
 			_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[8], _globals._sequenceIndexes[9]);
 			_ladderTopFl = true;
@@ -879,7 +879,7 @@ void Scene202::actions() {
 				_game._player._visible= false;
 				_globals._sequenceIndexes[10] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 1, 6);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
 				_scene->_sequences.updateTimeout(-1, _globals._sequenceIndexes[10]);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
@@ -887,7 +887,7 @@ void Scene202::actions() {
 			case 1:
 				_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 6);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
 				if (_scene->_activeAnimation) {
 					_waitingMeteoFl = true;
 					_globals[kMeteorologistWatch] = METEOROLOGIST_GROUND;
@@ -903,7 +903,7 @@ void Scene202::actions() {
 				_globals._sequenceIndexes[10] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[10], 1, 6);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[10], Common::Point(172, 123));
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[10], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
 				break;
 			case 3:
@@ -922,13 +922,13 @@ void Scene202::actions() {
 				_game._player._stepEnabled = false;
 				_scene->_sequences.remove(_globals._sequenceIndexes[9]);
 				_globals._sequenceIndexes[9] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[9], true, 6, 1, 0, 0);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 				break;
 			case 1:
 				_globals._sequenceIndexes[10] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, -2);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[10], Common::Point(247, 82));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[10], Common::Point(247, 82));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[10], 1);
 				if (_scene->_activeAnimation) {
 					if (_scene->_activeAnimation->getCurrentFrame() > 200) {
@@ -955,13 +955,13 @@ void Scene202::actions() {
 				_meteorologistSpecial = false;
 				_scene->_sequences.remove(_globals._sequenceIndexes[10]);
 				_globals._sequenceIndexes[9] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[9], false, 6, 1, 0, 0);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[9], SEQUENCE_TRIGGER_EXPIRE, 0, 3);
 				break;
 			case 3:
 				_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], true, 1);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[9], Common::Point(247, 82));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 1);
 				_game._player._stepEnabled = true;
 				break;
@@ -2661,7 +2661,7 @@ void Scene209::handleMonkeyFall() {
 		_globals._sequenceIndexes[8] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[8], false, 8, 1, 0, 0);
 		_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[9], oldIdx);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(201, 131));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[9], Common::Point(201, 131));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[8], oldIdx);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[8], 43, 72);
@@ -2760,7 +2760,7 @@ void Scene209::handleMonkey2() {
 		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 60, _game.getQuote(137));
 		_vm->_sound->command(22);
 		_globals._sequenceIndexes[12] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[12], false, 11, 1, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[12], Common::Point(111, 133));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[12], Common::Point(111, 133));
 		_scene->_sequences.setScale(_globals._sequenceIndexes[12], 79);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[12], 1, 6);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[12], SEQUENCE_TRIGGER_EXPIRE, 0, 252);
@@ -2773,7 +2773,7 @@ void Scene209::handleMonkey2() {
 		_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(132));
 		int oldIdx = _globals._sequenceIndexes[12];
 		_globals._sequenceIndexes[12] = _scene->_sequences.startCycle(_globals._spriteIndexes[12], false, 7);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[12], Common::Point(111, 133));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[12], Common::Point(111, 133));
 		_scene->_sequences.setScale(_globals._sequenceIndexes[12], 79);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[12], oldIdx);
 		_scene->_sequences.addTimer(120, 253);
@@ -2857,7 +2857,7 @@ void Scene209::enter() {
 
 	if (_game._objects.isInRoom(OBJ_BINOCULARS)) {
 		_globals._sequenceIndexes[9] = _scene->_sequences.startCycle(_globals._spriteIndexes[9], false, 1);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[9], Common::Point(201, 131));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[9], Common::Point(201, 131));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[9], 8);
 		int idx = _scene->_dynamicHotspots.add(39, 13, _globals._sequenceIndexes[9], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(200, 133), FACING_NORTH);
@@ -3119,7 +3119,7 @@ void Scene209::step() {
 			_game._player._visible = false;
 			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 7);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 229);
 			break;
@@ -3127,7 +3127,7 @@ void Scene209::step() {
 		case 229: {
 			int oldIdx = _globals._sequenceIndexes[2];
 			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 7);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], oldIdx);
 			_scene->_sequences.addTimer(35, 230);
@@ -3138,7 +3138,7 @@ void Scene209::step() {
 			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 			_globals._sequenceIndexes[2] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 7);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 231);
 			break;
@@ -3147,7 +3147,7 @@ void Scene209::step() {
 			int oldIdx = _globals._sequenceIndexes[2];
 			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 8, 10);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], oldIdx);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 232);
@@ -3160,7 +3160,7 @@ void Scene209::step() {
 		case 232: {
 			int oldIdx = _globals._sequenceIndexes[2];
 			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 10);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], oldIdx);
 			_scene->_sequences.addTimer(2, 233);
@@ -3182,14 +3182,14 @@ void Scene209::step() {
 			if (_action.isAction(VERB_HOSE_DOWN, NOUN_BLOWGUN, NOUN_MONKEY)) {
 				_globals._sequenceIndexes[2] = _scene->_sequences.addReverseSpriteCycle(_globals._spriteIndexes[2], false, 7, 16, 0, 0);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 11, 12);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 12, 239);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 235);
 			} else if (_action.isAction(VERB_SHOOT, NOUN_BLOWGUN, NOUN_MONKEY)) {
 				_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 11, 12);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 235);
 				_vm->_sound->command(23);
@@ -3199,7 +3199,7 @@ void Scene209::step() {
 		case 235: {
 			int oldIdx = _globals._sequenceIndexes[2];
 			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 13);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], oldIdx);
 			_scene->_sequences.addTimer(12, 236);
@@ -3212,7 +3212,7 @@ void Scene209::step() {
 			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 14, 16);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(116, 131));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 4);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 237);
 			break;
@@ -4649,7 +4649,7 @@ void Scene211::enter() {
 
 	if (_vm->getRandomNumber(1, 8) == 1) {
 		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(202, 126));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(202, 126));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 8);
 		_scene->_sequences.setMotion(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, -200, 0);
 		_scene->_dynamicHotspots.add(324, 13, _globals._sequenceIndexes[2], Common::Rect(1, 1, 1 + 41, 1 + 10));
@@ -5041,7 +5041,7 @@ void Scene214::enter() {
 
 	if (_game._objects.isInRoom(OBJ_POISON_DARTS)) {
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(103, 86));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(103, 86));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 11);
 	} else {
 		_scene->_hotspots.activate(NOUN_POISON_DARTS, false);
@@ -5049,7 +5049,7 @@ void Scene214::enter() {
 
 	if (_game._objects.isInRoom(OBJ_BLOWGUN)) {
 		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 6, 0, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(90, 87));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(90, 87));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 13);
 	} else {
 		_scene->_hotspots.activate(NOUN_BLOWGUN, false);
@@ -5236,7 +5236,7 @@ void Scene215::enter() {
 	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(formAnimName('a', 0));
 
 	_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle (_globals._spriteIndexes[1], false, 7, 0, 0, 0);
-	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(235, 83));
+	_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(235, 83));
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
 
 	if (_globals[kSexOfRex] == REX_MALE)
diff --git a/engines/mads/nebular/nebular_scenes3.cpp b/engines/mads/nebular/nebular_scenes3.cpp
index 11eb2f8..d54ffbd 100644
--- a/engines/mads/nebular/nebular_scenes3.cpp
+++ b/engines/mads/nebular/nebular_scenes3.cpp
@@ -219,7 +219,7 @@ void Scene3xx::handleForceField(ForceField *force, int *sprites) {
 		if (id >= 0) {
 			force->_seqId[id] = _scene->_sequences.addSpriteCycle(sprites[spriteId], mirror, 2, 0, 0, 0);
 			_scene->_sequences.setDepth(force->_seqId[id], 8);
-			_scene->_sequences.setMsgPosition(force->_seqId[id], Common::Point(posX, posY));
+			_scene->_sequences.setPosition(force->_seqId[id], Common::Point(posX, posY));
 			_scene->_sequences.setMotion(force->_seqId[id], 2, speedX, speedY);
 			_scene->_sequences.addSubEntry(force->_seqId[id], SEQUENCE_TRIGGER_EXPIRE, 0, 150 + id);
 			if (spriteId == 2)
@@ -742,7 +742,7 @@ void Scene307::enter() {
 	initForceField(&_forceField, true);
 
 	_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
-	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+	_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 15);
 
 	_animationMode = 0;
@@ -810,7 +810,7 @@ void Scene307::enter() {
 
 		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 2);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 15);
 	}
 
@@ -973,7 +973,7 @@ void Scene307::actions() {
 			_vm->_sound->command(26);
 			_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 2);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 15);
 			_scene->_sequences.addTimer(90, 5);
 			break;
@@ -1017,7 +1017,7 @@ void Scene307::actions() {
 				_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 				_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 60, 1, 0, 0);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 3, -2);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 15);
 				_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 18, 1, 0, 0);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], -1, 4);
@@ -1028,7 +1028,7 @@ void Scene307::actions() {
 
 			case 1:
 				_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, -2);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 15);
 				break;
 
@@ -1045,31 +1045,31 @@ void Scene307::actions() {
 			case 3:
 				_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 				_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 3);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
 				_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 11);
 				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[5], Common::Point(129, 102));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[5], Common::Point(129, 102));
 				_scene->_sequences.addTimer(48, 4);
 				break;
 
 			case 4:
 				_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 				_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 2);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
 				_scene->_sequences.remove(_globals._sequenceIndexes[5]);
 				_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 12, 1, 0, 0);
 				_scene->_sequences.setAnimRange(_globals._sequenceIndexes[5], 12, 14);
 				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[5], Common::Point(129, 102));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[5], Common::Point(129, 102));
 				_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 5);
 				break;
 
 			case 5:
 				_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 15);
 				_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[5]);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[5], Common::Point(129, 102));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[5], Common::Point(129, 102));
 				_scene->_sequences.addTimer(48, 6);
 				break;
 
@@ -1077,7 +1077,7 @@ void Scene307::actions() {
 				_scene->_sequences.remove(_globals._sequenceIndexes[5]);
 				_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 				_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
-				_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+				_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
 				_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 1);
 				_scene->_sequences.addTimer(48, 7);
 				break;
@@ -1213,7 +1213,7 @@ void Scene308::enter() {
 	_vm->_palette->setEntry(253, 45, 15, 12);
 
 	_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
-	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+	_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 15);
 	_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 9);
@@ -1354,7 +1354,7 @@ void Scene309::enter() {
 	_globals._spriteIndexes[4] = _scene->_sprites.addSprites(Resources::formatName(307, 'X', 0, EXT_SS, ""));
 
 	_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
-	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
+	_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(127, 78));
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 15);
 
 	_globals._sequenceIndexes[3] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[3], false, 7, 1, 0, 0);
@@ -1543,7 +1543,7 @@ void Scene310::enter() {
 
 	_globals._spriteIndexes[3] = _scene->_sprites.addSprites(Resources::formatName(307, 'X', 0, EXT_SS, ""));
 	_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
-	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(127, 78));
+	_scene->_sequences.setPosition(_globals._sequenceIndexes[3], Common::Point(127, 78));
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 15);
 
 	_game._player._visible = false;
@@ -1589,7 +1589,7 @@ void Scene311::enter() {
 	_globals._spriteIndexes[3] = _scene->_sprites.addSprites("*RXCL_2");
 
 	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
-	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+	_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
 
 	_checkGuardFl = false;
@@ -1625,7 +1625,7 @@ void Scene311::step() {
 		case 71:
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 2);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 
 			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
@@ -1643,7 +1643,7 @@ void Scene311::step() {
 		case 73:
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 3);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 
 			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
@@ -1679,7 +1679,7 @@ void Scene311::step() {
 		case 77:
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 2);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 
 			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
@@ -1691,7 +1691,7 @@ void Scene311::step() {
 		case 78:
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
 
 			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
@@ -1749,7 +1749,7 @@ void Scene311::actions() {
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 50, 1, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 3, -2);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
 
 			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 15, 1, 0, 0);
@@ -1762,7 +1762,7 @@ void Scene311::actions() {
 		case 1: {
 			int oldIdx = _globals._sequenceIndexes[1];
 			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -2);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[1], oldIdx);
 			}
@@ -1781,13 +1781,13 @@ void Scene311::actions() {
 		case 3: {
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 3);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 
 			int oldIdx = _globals._sequenceIndexes[2];
 			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 11);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(167, 100));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(167, 100));
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], oldIdx);
 			_scene->_sequences.addTimer(15, 4);
 			}
@@ -1796,14 +1796,14 @@ void Scene311::actions() {
 		case 4:
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 2);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 
 			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 12, 1, 0, 0);
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 12, 14);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(167, 100));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(167, 100));
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 5);
 			break;
 
@@ -1811,7 +1811,7 @@ void Scene311::actions() {
 			int oldIdx = _globals._sequenceIndexes[2];
 			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 15);
 			_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(167, 100));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(167, 100));
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], oldIdx);
 			_scene->_sequences.addTimer(15, 6);
 			}
@@ -1821,7 +1821,7 @@ void Scene311::actions() {
 			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 			_scene->_sequences.addTimer(15, 7);
 			break;
@@ -2443,7 +2443,7 @@ void Scene318::handleDialog() {
 		int synxIdx = _globals._sequenceIndexes[2];
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], synxIdx);
 		_vm->_sound->command(3);
 		_scene->_userInterface.setup(kInputLimitedSentences);
@@ -2514,7 +2514,7 @@ void Scene318::handleDialog() {
 			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 6, 8);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 
@@ -2658,7 +2658,7 @@ void Scene318::enter() {
 			} else
 				_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
 
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
 		}
 	}
@@ -2839,7 +2839,7 @@ void Scene318::actions() {
 			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 			_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 8, 1, 0, 80);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 6, 8);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 			}
@@ -2855,7 +2855,7 @@ void Scene318::actions() {
 			int oldIdx = _globals._sequenceIndexes[2];
 			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 8);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], oldIdx);
 			}
 			break;
@@ -2874,7 +2874,7 @@ void Scene318::actions() {
 			_scene->_sequences.remove(_globals._sequenceIndexes[2]);
 			_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 8, 2, 0, 80);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
 			_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 2, 5);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_SPRITE, 5, 1);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
@@ -2894,7 +2894,7 @@ void Scene318::actions() {
 			int oldIdx = _globals._sequenceIndexes[2];
 			_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 1);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[2], 1);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(142, 121));
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], oldIdx);
 			_scene->_sequences.addTimer(60, 3);
 			}
@@ -3743,7 +3743,7 @@ void Scene320::actions() {
 			handleButtons();
 			_globals._sequenceIndexes[18] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[18], _flippedFl, 4, 2, 0, 0);
 			_scene->_sequences.setScale(_globals._sequenceIndexes[18], 60);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[18], Common::Point(_posX, 170));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[18], Common::Point(_posX, 170));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[18], 0);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[18], SEQUENCE_TRIGGER_LOOP, 0, 1);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[18], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
@@ -4792,7 +4792,7 @@ void Scene357::enter() {
 	_globals[kAfterHavoc] = true;
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(Resources::formatName(307, 'X', 0, EXT_SS, ""));
 	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
-	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(127, 78));
+	_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(127, 78));
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
 
 	if (_scene->_priorSceneId == 318)
@@ -4858,7 +4858,7 @@ void Scene358::setup() {
 void Scene358::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(Resources::formatName(307, 'X', 0, EXT_SS, ""));
 	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
-	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(127, 78));
+	_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(127, 78));
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
 
 	if (_scene->_priorSceneId == 357)
@@ -4928,7 +4928,7 @@ void Scene359::enter() {
 		_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*ROXBD_2");
 
 	_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
-	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(127, 78));
+	_scene->_sequences.setPosition(_globals._sequenceIndexes[3], Common::Point(127, 78));
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 15);
 
 	if (_game._objects.isInRoom(OBJ_SECURITY_CARD)) {
@@ -4974,7 +4974,7 @@ void Scene359::actions() {
 				} else {
 					_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], true, 7, 2, 0, 0);
 					_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
-					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(106, 110));
+					_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(106, 110));
 					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_SPRITE, 6, 1);
 					_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 2);
 				}
@@ -5057,7 +5057,7 @@ void Scene360::setup() {
 void Scene360::enter() {
 	_globals._spriteIndexes[1] = _scene->_sprites.addSprites(Resources::formatName(307, 'X', 0, EXT_SS, ""));
 	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
-	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(127, 78));
+	_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(127, 78));
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
 
 	if (_scene->_priorSceneId == 359)
@@ -5119,7 +5119,7 @@ void Scene361::handleRexAction() {
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 50, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 3, -2);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
 
 		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 15, 1, 0, 0);
@@ -5132,7 +5132,7 @@ void Scene361::handleRexAction() {
 	case 1: {
 		int seqIdx = _globals._sequenceIndexes[1];
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 4);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[1], seqIdx);
 		}
@@ -5151,13 +5151,13 @@ void Scene361::handleRexAction() {
 	case 3: {
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 3);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 
 		int seqIdx = _globals._sequenceIndexes[2];
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 11);
 		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(167, 100));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(167, 100));
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], seqIdx);
 		_scene->_sequences.addTimer(15, 4);
 		}
@@ -5166,14 +5166,14 @@ void Scene361::handleRexAction() {
 	case 4:
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 2);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 
 		_scene->_sequences.setDone(_globals._sequenceIndexes[2]);
 		_globals._sequenceIndexes[2] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[2], false, 12, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 12, 14);
 		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(167, 100));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(167, 100));
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 5);
 		break;
 
@@ -5181,7 +5181,7 @@ void Scene361::handleRexAction() {
 		int seqIdx = _globals._sequenceIndexes[2];
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, 15);
 		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[2]);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], Common::Point(167, 100));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[2], Common::Point(167, 100));
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[2], seqIdx);
 		_scene->_sequences.addTimer(15, 6);
 		}
@@ -5191,7 +5191,7 @@ void Scene361::handleRexAction() {
 		_scene->_sequences.setDone(_globals._sequenceIndexes[2]);
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 		_scene->_sequences.addTimer(48, 7);
 		break;
@@ -5213,7 +5213,7 @@ void Scene361::handleRoxAction() {
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 18, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[1], 2, 4);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
 
 		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 18, 1, 0, 0);
@@ -5226,7 +5226,7 @@ void Scene361::handleRoxAction() {
 	case 1: {
 		int tmpIdx = _globals._sequenceIndexes[1];
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 4);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[1], tmpIdx);
 		}
@@ -5245,14 +5245,14 @@ void Scene361::handleRoxAction() {
 	case 3: {
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 3);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 
 		int tmpIdx = _globals._sequenceIndexes[4];
 		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 12, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 9, 10);
 		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(167, 100));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(167, 100));
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], tmpIdx);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 4);
 		}
@@ -5261,14 +5261,14 @@ void Scene361::handleRoxAction() {
 	case 4: {
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 2);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 
 		int tmpIdx = _globals._sequenceIndexes[4];
 		_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 12, 1, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[4], 11, 15);
 		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(167, 100));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(167, 100));
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], tmpIdx);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 5);
 		}
@@ -5278,7 +5278,7 @@ void Scene361::handleRoxAction() {
 		int tmpIdx = _globals._sequenceIndexes[4];
 		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 16);
 		_scene->_sequences.setMsgLayout(_globals._sequenceIndexes[4]);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(167, 100));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(167, 100));
 		_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], tmpIdx);
 		_scene->_sequences.addTimer(48, 6);
 		}
@@ -5289,7 +5289,7 @@ void Scene361::handleRoxAction() {
 
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 		_scene->_sequences.addTimer(48, 7);
 		break;
@@ -5313,7 +5313,7 @@ void Scene361::enter() {
 		_globals._spriteIndexes[4] = _scene->_sprites.addSprites("*ROXCL_8");
 
 	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
-	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+	_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
 
 	if (_scene->_priorSceneId == 391) {
@@ -5345,7 +5345,7 @@ void Scene361::step() {
 		case 70:
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 2);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 
 			_globals._sequenceIndexes[3] = _scene->_sequences.startCycle(_globals._spriteIndexes[3], false, 1);
@@ -5363,7 +5363,7 @@ void Scene361::step() {
 		case 72:
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 3);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 
 			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
@@ -5399,7 +5399,7 @@ void Scene361::step() {
 		case 76:
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 2);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 
 			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
@@ -5411,7 +5411,7 @@ void Scene361::step() {
 		case 77:
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(165, 76));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 15);
 
 			_scene->_sequences.setDone(_globals._sequenceIndexes[3]);
diff --git a/engines/mads/nebular/nebular_scenes4.cpp b/engines/mads/nebular/nebular_scenes4.cpp
index cb5363b..b1b2b09 100644
--- a/engines/mads/nebular/nebular_scenes4.cpp
+++ b/engines/mads/nebular/nebular_scenes4.cpp
@@ -887,7 +887,7 @@ void Scene402::enter() {
 	if (!_game._objects.isInInventory(OBJ_REPAIR_LIST)) {
 		_globals._sequenceIndexes[14] = _scene->_sequences.startCycle(_globals._spriteIndexes[14], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[14], 7);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[14], Common::Point(210, 80));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[14], Common::Point(210, 80));
 		int idx = _scene->_dynamicHotspots.add(NOUN_REPAIR_LIST, 0xD1, _globals._sequenceIndexes[14], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(0, 0), FACING_NONE);
 	}
@@ -902,14 +902,14 @@ void Scene402::enter() {
 	if (!_game._objects.isInRoom(OBJ_ALIEN_LIQUOR) && !_game._objects.isInInventory(OBJ_CREDIT_CHIP)) {
 		_globals._sequenceIndexes[15] = _scene->_sequences.startCycle(_globals._spriteIndexes[15], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[15], 8);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[15], Common::Point(250, 80));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[15], Common::Point(250, 80));
 		int idx = _scene->_dynamicHotspots.add(NOUN_CREDIT_CHIP, 0x4, _globals._sequenceIndexes[15], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(0, 0), FACING_NONE);
 	}
 
 	_globals._sequenceIndexes[20] = _scene->_sequences.startCycle(_globals._spriteIndexes[20], false, 1);
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[20], 7);
-	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[20], Common::Point(234, 72));
+	_scene->_sequences.setPosition(_globals._sequenceIndexes[20], Common::Point(234, 72));
 
 	if (_globals[kBottleDisplayed]) {
 		_globals._sequenceIndexes[8] = _scene->_sequences.startCycle(_globals._spriteIndexes[8], false, 4);
@@ -1021,7 +1021,7 @@ void Scene402::step() {
 		case 21:
 			_globals._sequenceIndexes[15] = _scene->_sequences.startCycle(_globals._spriteIndexes[15], false, 1);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[15], 8);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[15], Common::Point(250, 80));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[15], Common::Point(250, 80));
 			break;
 
 		default:
@@ -1106,7 +1106,7 @@ void Scene402::step() {
 		case 21: {
 			_globals._sequenceIndexes[15] = _scene->_sequences.startCycle(_globals._spriteIndexes[15], false, 1);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[15], 8);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[15], Common::Point(250, 80));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[15], Common::Point(250, 80));
 			int idx = _scene->_dynamicHotspots.add(NOUN_CREDIT_CHIP, 0x4, _globals._sequenceIndexes[15], Common::Rect(0, 0, 0, 0));
 			_scene->_dynamicHotspots.setPosition(idx, Common::Point(0, 0), FACING_NONE);
 			}
@@ -1678,7 +1678,7 @@ void Scene402::step() {
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[13], SEQUENCE_TRIGGER_EXPIRE, 0, 60);
 		_globals._sequenceIndexes[20] = _scene->_sequences.startCycle(_globals._spriteIndexes[20], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[20], 8);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[20], Common::Point(234, 72));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[20], Common::Point(234, 72));
 		}
 		break;
 
@@ -1937,7 +1937,7 @@ void Scene402::step() {
 
 		_globals._sequenceIndexes[20] = _scene->_sequences.startCycle(_globals._spriteIndexes[20], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[20], 8);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[20], Common::Point(234, 72));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[20], Common::Point(234, 72));
 	}
 
 	if (_game._trigger == 85) {
@@ -2204,7 +2204,7 @@ void Scene402::actions() {
 		_game._player._visible = false;
 		_globals._sequenceIndexes[22] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[22], false, 7, 2, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[22], 1, 2);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[22], Common::Point(_game._player._playerPos.x, _game._player._playerPos.y + 1));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[22], Common::Point(_game._player._playerPos.x, _game._player._playerPos.y + 1));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[22], 5);
 		_scene->_sequences.setScale(_globals._sequenceIndexes[22], 88);
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
@@ -2499,7 +2499,7 @@ void Scene405::actions() {
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 2);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 75);
 		Common::Point msgPos = Common::Point(_game._player._playerPos.x, _game._player._playerPos.y + 1);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], msgPos);
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[3], msgPos);
 		_scene->_sequences.setScale(_globals._sequenceIndexes[3], 87);
 	} else if ((_action.isAction(VERB_PUT, NOUN_SECURITY_CARD, 0x251) || _action.isAction(VERB_CLOSE, NOUN_WIDE_DOOR)) && _globals[kArmoryDoorOpen]) {
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
@@ -2508,7 +2508,7 @@ void Scene405::actions() {
 		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 7, 2, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 2);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], _game._player._playerPos);
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[3], _game._player._playerPos);
 		_scene->_sequences.setScale(_globals._sequenceIndexes[3], 87);
 	} else if (_action.isAction(VERB_PUT, NOUN_CARD_SLOT)) {
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
@@ -2517,7 +2517,7 @@ void Scene405::actions() {
 		_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 7, 2, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[3], 1, 2);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[3], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], _game._player._playerPos);
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[3], _game._player._playerPos);
 		_scene->_sequences.setScale(_globals._sequenceIndexes[3], 87);
 	} else if (_action.isAction(VERB_LOOK, NOUN_CANNON_BALLS))
 		_vm->_dialogs->show(40510);
@@ -2707,7 +2707,7 @@ void Scene406::actions() {
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 2);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 75);
 		Common::Point msgPos = Common::Point(_game._player._playerPos.x, _game._player._playerPos.y + 1);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], msgPos);
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[2], msgPos);
 		_scene->_sequences.setScale(_globals._sequenceIndexes[2], 87);
 	} else if (_action.isAction(VERB_PUT, NOUN_SECURITY_CARD, 0x251) && _globals[kStorageDoorOpen]) {
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
@@ -2717,7 +2717,7 @@ void Scene406::actions() {
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 2);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
 		Common::Point msgPos = Common::Point(_game._player._playerPos.x, _game._player._playerPos.y + 1);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], msgPos);
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[2], msgPos);
 		_scene->_sequences.setScale(_globals._sequenceIndexes[2], 87);
 	} else if (_action.isAction(VERB_PUT, NOUN_CARD_SLOT)) {
 		_game._triggerSetupMode = SEQUENCE_TRIGGER_DAEMON;
@@ -2726,7 +2726,7 @@ void Scene406::actions() {
 		_globals._sequenceIndexes[2] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[2], false, 7, 2, 0, 0);
 		_scene->_sequences.setAnimRange(_globals._sequenceIndexes[2], 1, 2);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[2], SEQUENCE_TRIGGER_EXPIRE, 0, 110);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[2], _game._player._playerPos);
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[2], _game._player._playerPos);
 		_scene->_sequences.setScale(_globals._sequenceIndexes[2], 87);
 	} else if (_action.isAction(VERB_LOOK, NOUN_TRASH))
 		_vm->_dialogs->show(40610);
diff --git a/engines/mads/nebular/nebular_scenes6.cpp b/engines/mads/nebular/nebular_scenes6.cpp
index 9413350..1821a72 100644
--- a/engines/mads/nebular/nebular_scenes6.cpp
+++ b/engines/mads/nebular/nebular_scenes6.cpp
@@ -1608,20 +1608,20 @@ void Scene608::setCarAnimations() {
 	_scene->freeAnimation();
 	if (_globals[kCarStatus] == 0) {
 		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 1);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[6], Common::Point(143, 98));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[6], Common::Point(143, 98));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 6);
 		_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, 1);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[7], Common::Point(141, 67));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[7], Common::Point(141, 67));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 15);
 	} else {
 		_globals._sequenceIndexes[6] = _scene->_sequences.startCycle(_globals._spriteIndexes[6], false, 1);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[6], Common::Point(143, 128));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[6], Common::Point(143, 128));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[6], 6);
 		_globals._sequenceIndexes[7] = _scene->_sequences.startCycle(_globals._spriteIndexes[7], false, 1);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[7], Common::Point(141, 97));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[7], Common::Point(141, 97));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[7], 15);
 		_globals._sequenceIndexes[8] = _scene->_sequences.startCycle(_globals._spriteIndexes[8], false, 1);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[8], Common::Point(144, 126));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[8], Common::Point(144, 126));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[8], 5);
 	}
 }
@@ -2613,7 +2613,7 @@ void Scene609::step() {
 		if (!_globals[kHasTalkedToHermit] && (_game._difficulty != DIFFICULTY_HARD)) {
 			_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 26, 2, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 7);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(287, 73));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[3], Common::Point(287, 73));
 			_scene->_sequences.setScale(_globals._sequenceIndexes[3], 47);
 		}
 		_globals._sequenceIndexes[2] = _scene->_sequences.startCycle(_globals._spriteIndexes[2], false, -1);
@@ -2636,7 +2636,7 @@ void Scene609::step() {
 		if (!_globals[kHasTalkedToHermit]) {
 			_globals._sequenceIndexes[3] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[3], false, 26, 2, 0, 0);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[3], 7);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[3], Common::Point(287, 73));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[3], Common::Point(287, 73));
 			_scene->_sequences.setScale(_globals._sequenceIndexes[3], 47);
 		}
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 585271c..9383492 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -141,7 +141,7 @@ void Scene701::enter() {
 	}
 
 	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
-	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+	_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 
 	int boatStatus = (_scene->_priorSceneId == 703) ? BOAT_GONE : _globals[kBoatStatus];
@@ -182,7 +182,7 @@ void Scene701::enter() {
 		_game._player._visible = false;
 		_game._player._stepEnabled = false;
 		_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, 1);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[5], Common::Point(155, 129));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[5], Common::Point(155, 129));
 		_scene->_sequences.addTimer(15, 60);
 	} else if (_scene->_priorSceneId == 703) {
 		_game._player._playerPos = Common::Point(231, 127);
@@ -207,7 +207,7 @@ void Scene701::step() {
 	case 60:
 		_scene->_sequences.remove(_globals._sequenceIndexes[5]);
 		_globals._sequenceIndexes[5] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[5], false, 6, 1, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[5], Common::Point(155, 129));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[5], Common::Point(155, 129));
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 61);
 		break;
 
@@ -221,7 +221,7 @@ void Scene701::step() {
 		_vm->_sound->command(16);
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 1, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
 		break;
@@ -234,7 +234,7 @@ void Scene701::step() {
 	case 72:
 		_vm->_sound->command(17);
 		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 5, 1, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 73);
 		break;
@@ -242,7 +242,7 @@ void Scene701::step() {
 	case 73:
 		_game._player._stepEnabled = true;
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 		_scene->_kernelMessages.reset();
 		break;
@@ -285,14 +285,14 @@ void Scene701::actions() {
 			_game._player._stepEnabled = false;
 			_game._player._visible = false;
 			_globals._sequenceIndexes[5] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[5], false, 6, 1, 0, 0);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[5], Common::Point(155, 129));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[5], Common::Point(155, 129));
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[5], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			break;
 
 		case 1: {
 			int temp = _globals._sequenceIndexes[5];
 			_globals._sequenceIndexes[5] = _scene->_sequences.startCycle(_globals._spriteIndexes[5], false, -2);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[5], Common::Point(155, 129));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[5], Common::Point(155, 129));
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[5], temp);
 			_scene->_sequences.addTimer(15, 2);
 			}
@@ -312,7 +312,7 @@ void Scene701::actions() {
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_vm->_sound->command(16);
 			_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 1, 0, 0);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 			_scene->_kernelMessages.reset();
 			_scene->_kernelMessages.add(Common::Point(0, 0), 0x310, 34, 0, 120, _game.getQuote(0x30D));
@@ -327,14 +327,14 @@ void Scene701::actions() {
 		case 3:
 			_vm->_sound->command(17);
 			_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 5, 1, 0, 0);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 4);
 			break;
 
 		case 4:
 			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 			_globals[kResurrectRoom] = 701;
 			_scene->_nextSceneId = 605;
@@ -1221,10 +1221,10 @@ void Scene704::enter() {
 		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 6, 0, 0, 0);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 		if (_scene->_priorSceneId == 705) {
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(123, 125));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(123, 125));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 		} else {
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(190, 122));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(190, 122));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 2);
 		}
 		int idx = _scene->_dynamicHotspots.add(NOUN_BONES, 0xD1, _globals._sequenceIndexes[1], Common::Rect(0, 0, 0, 0));
@@ -1250,7 +1250,7 @@ void Scene704::enter() {
 		_scene->_activeAnimation->setCurrentFrame(8);
 	} else if (_boatDirection == 2) {
 		if (_game._objects[OBJ_BOTTLE]._roomNumber == _scene->_currentSceneId) {
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(123, 125));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(123, 125));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 1);
 		}
 		_scene->loadAnimation(formAnimName('A', -1));
@@ -1812,7 +1812,7 @@ void Scene706::handleTakeVase() {
 		if (_vaseMode == 1) {
 			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 4);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(195, 99));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(195, 99));
 			int idx = _scene->_dynamicHotspots.add(NOUN_BOTTLE, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 			_scene->_dynamicHotspots.setPosition(idx, Common::Point(175, 124), FACING_SOUTHEAST);
 			_game._objects.setRoom(OBJ_BOTTLE, _scene->_currentSceneId);
@@ -1844,7 +1844,7 @@ void Scene706::enter() {
 	} else if (_game._objects.isInRoom(OBJ_BOTTLE)) {
 		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 4);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(195, 99));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(195, 99));
 		int idx = _scene->_dynamicHotspots.add(NOUN_BOTTLE, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 		_scene->_dynamicHotspots.setPosition(idx, Common::Point(175, 124), FACING_SOUTHEAST);
 	}
@@ -1918,7 +1918,7 @@ void Scene706::step() {
 
 					_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 					_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 4);
-					_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(195, 99));
+					_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(195, 99));
 					int idx = _scene->_dynamicHotspots.add(NOUN_BOTTLE, VERB_WALKTO, _globals._sequenceIndexes[4], Common::Rect(0, 0, 0, 0));
 					_scene->_dynamicHotspots.setPosition(idx, Common::Point(175, 124), FACING_SOUTHEAST);
 				}
@@ -2199,7 +2199,7 @@ void Scene751::enter() {
 	}
 
 	_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
-	_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+	_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 	_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 
 	if (_scene->_priorSceneId == 752) {
@@ -2211,7 +2211,7 @@ void Scene751::enter() {
 		_game._player._visible = false;
 		_game._player._stepEnabled = false;
 		_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, -2);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(155, 129));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(155, 129));
 		_scene->_sequences.addTimer(15, 70);
 	} else if (_scene->_priorSceneId != -2) {
 		_game._player._playerPos = Common::Point(22, 131);
@@ -2249,7 +2249,7 @@ void Scene751::step() {
 	case 70:
 		_scene->_sequences.remove(_globals._sequenceIndexes[4]);
 		_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 6, 1, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(155, 129));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(155, 129));
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
 		break;
 
@@ -2275,7 +2275,7 @@ void Scene751::step() {
 		_vm->_sound->command(16);
 		_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 		_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 1, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 61);
 		break;
@@ -2288,14 +2288,14 @@ void Scene751::step() {
 	case 62:
 		_vm->_sound->command(17);
 		_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 5, 1, 0, 0);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 		_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 63);
 		break;
 
 	case 63:
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 		_game._player._stepEnabled = true;
 		_scene->_kernelMessages.reset();
@@ -2357,14 +2357,14 @@ void Scene751::actions() {
 			_game._player._stepEnabled = false;
 			_game._player._visible = false;
 			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 6, 1, 0, 0);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(155, 129));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(155, 129));
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 1);
 			break;
 
 		case 1: {
 			int syncIdx = _globals._sequenceIndexes[4];
 			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, -2);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(155, 129));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(155, 129));
 			_scene->_sequences.updateTimeout(_globals._sequenceIndexes[4], syncIdx);
 			_scene->_sequences.addTimer(15, 2);
 			}
@@ -2384,7 +2384,7 @@ void Scene751::actions() {
 			_scene->_sequences.remove(_globals._sequenceIndexes[1]);
 			_vm->_sound->command(16);
 			_globals._sequenceIndexes[1] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[1], false, 5, 1, 0, 0);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 			_scene->_kernelMessages.reset();
 			_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 0, 120, _game.getQuote(0x30D));
@@ -2399,14 +2399,14 @@ void Scene751::actions() {
 		case 3:
 			_vm->_sound->command(17);
 			_globals._sequenceIndexes[1] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[1], false, 5, 1, 0, 0);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[1], SEQUENCE_TRIGGER_EXPIRE, 0, 4);
 			break;
 
 		case 4:
 			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, -1);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(48, 136));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 10);
 			_scene->_sequences.addTimer(60, 5);
 			break;
diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp
index 6f9a46d..c0f24a7 100644
--- a/engines/mads/nebular/nebular_scenes8.cpp
+++ b/engines/mads/nebular/nebular_scenes8.cpp
@@ -911,7 +911,7 @@ void Scene804::enter() {
 			_globals._sequenceIndexes[4] = _scene->_sequences.startCycle(_globals._spriteIndexes[4], false, 1);
 
 		_globals._sequenceIndexes[1] = _scene->_sequences.startCycle(_globals._spriteIndexes[1], false, 1);
-		_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(133, 139));
+		_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(133, 139));
 		_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 8);
 	}
 
@@ -931,7 +931,7 @@ void Scene804::step() {
 		if ((_throttleGone) && (_movingThrottle) && (_scene->_activeAnimation->getCurrentFrame() == 39)) {
 			_globals._sequenceIndexes[1] = _scene->_sequences.startCycle
 				(_globals._spriteIndexes[1], false, 1);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[1], Common::Point(133, 139));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[1], Common::Point(133, 139));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[1], 8);
 			_throttleGone = false;
 		}
@@ -1329,7 +1329,7 @@ void Scene808::actions() {
 		case 0:
 			_game._player._stepEnabled = false;
 			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 4, 1, 0, 0);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(248, 211));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(248, 211));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 2);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
 			break;
@@ -1343,7 +1343,7 @@ void Scene808::actions() {
 				_vm->_sound->command(25);
 			}
 			_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 4, 1, 0, 0);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(248, 211));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(248, 211));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 2);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 71);
 			break;
@@ -1365,7 +1365,7 @@ void Scene808::actions() {
 		case 0:
 			_game._player._stepEnabled = false;
 			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 4, 1, 0, 0);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(248, 186));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(248, 186));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 2);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 90);
 			break;
@@ -1378,7 +1378,7 @@ void Scene808::actions() {
 			}
 			_globals[kTopButtonPushed] = false;
 			_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 4, 1, 0, 0);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(248, 186));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(248, 186));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 2);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 91);
 			break;
@@ -1395,7 +1395,7 @@ void Scene808::actions() {
 		case 0:
 			_game._player._stepEnabled = false;
 			_globals._sequenceIndexes[4] = _scene->_sequences.addSpriteCycle(_globals._spriteIndexes[4], false, 4, 1, 0, 0);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(248, 163));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(248, 163));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 2);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
 			break;
@@ -1409,7 +1409,7 @@ void Scene808::actions() {
 			 }
 			_globals[kTopButtonPushed] = true;
 			_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 4, 1, 0, 0);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(248, 163));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(248, 163));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 2);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 81);
 			break;
@@ -1426,7 +1426,7 @@ void Scene808::actions() {
 		case 0:
 			_game._player._stepEnabled = false;
 			_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 4, 2, 0, 0);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(168, 211));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(168, 211));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 2);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 70);
 			break;
@@ -1443,7 +1443,7 @@ void Scene808::actions() {
 		case 0:
 			_game._player._stepEnabled = false;
 			_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 4, 2, 0, 0);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(172, 163));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(172, 163));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 2);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 80);
 			break;
@@ -1460,7 +1460,7 @@ void Scene808::actions() {
 		case 0:
 			_game._player._stepEnabled = false;
 			_globals._sequenceIndexes[4] = _scene->_sequences.startReverseCycle(_globals._spriteIndexes[4], false, 4, 2, 0, 0);
-			_scene->_sequences.setMsgPosition(_globals._sequenceIndexes[4], Common::Point(172, 186));
+			_scene->_sequences.setPosition(_globals._sequenceIndexes[4], Common::Point(172, 186));
 			_scene->_sequences.setDepth(_globals._sequenceIndexes[4], 2);
 			_scene->_sequences.addSubEntry(_globals._sequenceIndexes[4], SEQUENCE_TRIGGER_EXPIRE, 0, 90);
 			break;
diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index a7c6ded..e0efc7c 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -123,8 +123,8 @@ int SequenceList::add(int spriteListIndex, bool flipped, int frameIndex, int tri
 	_entries[seqIndex]._depth = depth;
 	_entries[seqIndex]._scale = scale;
 	_entries[seqIndex]._nonFixed = nonFixed;
-	_entries[seqIndex]._msgPos.x = msgX;
-	_entries[seqIndex]._msgPos.y = msgY;
+	_entries[seqIndex]._position.x = msgX;
+	_entries[seqIndex]._position.y = msgY;
 	_entries[seqIndex]._numTicks = numTicks;
 	_entries[seqIndex]._extraTicks = extraTicks;
 
@@ -192,7 +192,7 @@ void SequenceList::setSpriteSlot(int seqIndex, SpriteSlot &spriteSlot) {
 	spriteSlot._scale = timerEntry._scale;
 
 	if (!timerEntry._nonFixed) {
-		spriteSlot._position = timerEntry._msgPos;
+		spriteSlot._position = timerEntry._position;
 	} else {
 		MSprite *sprite = spriteSet.getFrame(timerEntry._frameIndex - 1);
 		spriteSlot._position = sprite->_offset;
@@ -231,14 +231,14 @@ bool SequenceList::loadSprites(int seqIndex) {
 				seqEntry._field20 += seqEntry._field18;
 				if (seqEntry._field20 >= 100) {
 					int v = seqEntry._field20 / 100;
-					seqEntry._msgPos.x += v * seqEntry._field1C;
+					seqEntry._position.x += v * seqEntry._field1C;
 					seqEntry._field20 -= v * 100;
 				}
 
 				seqEntry._field22 += seqEntry._field1A;
 				if (seqEntry._field22 >= 100) {
 					int v = seqEntry._field22 / 100;
-					seqEntry._msgPos.y += v * seqEntry._field1E;
+					seqEntry._position.y += v * seqEntry._field1E;
 					seqEntry._field22 -= v * 100;
 				}
 			}
@@ -424,8 +424,8 @@ void SequenceList::setDepth(int seqIndex, int depth) {
 	_entries[seqIndex]._depth = depth;
 }
 
-void SequenceList::setMsgPosition(int seqIndex, const Common::Point &pt) {
-	_entries[seqIndex]._msgPos = pt;
+void SequenceList::setPosition(int seqIndex, const Common::Point &pt) {
+	_entries[seqIndex]._position = pt;
 	_entries[seqIndex]._nonFixed = false;
 }
 
@@ -497,7 +497,7 @@ void SequenceList::setScale(int spriteIdx, int scale) {
 void SequenceList::setMsgLayout(int seqIndex) {
 	Player &player = _vm->_game->_player;
 	int yp = player._playerPos.y + (player._centerOfGravity * player._currentScale) / 100;
-	setMsgPosition(seqIndex, Common::Point(player._playerPos.x, yp));
+	setPosition(seqIndex, Common::Point(player._playerPos.x, yp));
 	setDepth(seqIndex, player._currentDepth);
 	setScale(seqIndex, player._currentScale);
 	updateTimeout(-1, seqIndex);
@@ -508,4 +508,11 @@ void SequenceList::setDone(int seqIndex) {
 	_entries[seqIndex]._timeout = _vm->_game->_player._priorTimer;
 }
 
+void SequenceList::setMotion(int seqIndex, int flags, int deltaX, int deltaY) {
+	warning("TODO: setMotion()");
+	// HACK: Just offset by the delta for now
+	_entries[seqIndex]._position.x += deltaX;
+	_entries[seqIndex]._position.y += deltaY;
+}
+
 } // End of namespace
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index b23f595..71460ea 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -68,7 +68,7 @@ struct SequenceEntry {
 	bool _nonFixed;
 	uint32 _flags;
 
-	Common::Point _msgPos;
+	Common::Point _position;
 	int _field18;
 	int _field1A;
 	int _field1C;
@@ -113,7 +113,7 @@ public:
 	void setAnimRange(int seqIndex, int startVal, int endVal);
 	void scan();
 	void setDepth(int seqIndex, int depth);
-	void setMsgPosition(int seqIndex, const Common::Point &pt);
+	void setPosition(int seqIndex, const Common::Point &pt);
 	int addSpriteCycle(int srcSpriteIdx, bool flipped, int numTicks,
 		int triggerCountdown = 0, int timeoutTicks = 0, int extraTicks = 0);
 	int addReverseSpriteCycle(int srcSpriteIdx, bool flipped, int numTicks,
@@ -126,12 +126,7 @@ public:
 	void setScale(int spriteIdx, int scale);
 	void setMsgLayout(int seqIndex);
 	void setDone(int seqIndex);
-	void setMotion(int seqIndex, int flags, int deltaX, int deltaY) {
-		warning("TODO: setMotion()");
-		// HACK: Just offset by the delta for now
-		_entries[seqIndex]._msgPos.x += deltaX;
-		_entries[seqIndex]._msgPos.y += deltaY;
-	}
+	void setMotion(int seqIndex, int flags, int deltaX, int deltaY);
 };
 
 } // End of namespace MADS


Commit: 690d95640386e927a8767823edb2d1a594f26104
    https://github.com/scummvm/scummvm/commit/690d95640386e927a8767823edb2d1a594f26104
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-24T19:25:31-04:00

Commit Message:
MADS: Properly implement sequence entry object movement

Changed paths:
    engines/mads/sequence.cpp
    engines/mads/sequence.h



diff --git a/engines/mads/sequence.cpp b/engines/mads/sequence.cpp
index e0efc7c..6461102 100644
--- a/engines/mads/sequence.cpp
+++ b/engines/mads/sequence.cpp
@@ -39,12 +39,6 @@ SequenceEntry::SequenceEntry() {
 	_depth = 0;
 	_scale = 0;
 	_dynamicHotspotIndex = -1;
-	_field18 = 0;
-	_field1A = 0;
-	_field1C = 0;
-	_field1E = 0;
-	_field20 = 0;
-	_field22 = 0;
 	_triggerCountdown = 0;
 	_doneFlag = 0;
 	_triggerMode = SEQUENCE_TRIGGER_DAEMON;
@@ -226,26 +220,27 @@ bool SequenceList::loadSprites(int seqIndex) {
 			int height = frame->getHeight() * seqEntry._scale / 100;
 			Common::Point pt = spriteSlot._position;
 
-			// ToDO: Find out the proper meanings of the following fields
+			// Handle sprite movement, if present
 			if (seqEntry._flags & 1) {
-				seqEntry._field20 += seqEntry._field18;
-				if (seqEntry._field20 >= 100) {
-					int v = seqEntry._field20 / 100;
-					seqEntry._position.x += v * seqEntry._field1C;
-					seqEntry._field20 -= v * 100;
+				seqEntry._posAccum.x += seqEntry._posDiff.x;
+				if (seqEntry._posAccum.x >= 100) {
+					int v = seqEntry._posAccum.x / 100;
+					seqEntry._position.x += v * seqEntry._posSign.x;
+					seqEntry._posAccum.x -= v * 100;
 				}
 
-				seqEntry._field22 += seqEntry._field1A;
-				if (seqEntry._field22 >= 100) {
-					int v = seqEntry._field22 / 100;
-					seqEntry._position.y += v * seqEntry._field1E;
-					seqEntry._field22 -= v * 100;
+				seqEntry._posAccum.y += seqEntry._posDiff.y;
+				if (seqEntry._posAccum.y >= 100) {
+					int v = seqEntry._posAccum.y / 100;
+					seqEntry._position.y += v * seqEntry._posSign.y;
+					seqEntry._posAccum.y -= v * 100;
 				}
 			}
 
 			if (seqEntry._flags & 2) {
+				// Check for object having moved off-scren
 				if ((pt.x + width) < 0 || (pt.x + width) >= MADS_SCREEN_WIDTH ||
-						pt.y < 0 || (pt.y + height) >= MADS_SCENE_HEIGHT) {
+						pt.y < 0 || (pt.y - height) >= MADS_SCENE_HEIGHT) {
 					result = true;
 					seqEntry._doneFlag = true;
 				}
@@ -509,10 +504,30 @@ void SequenceList::setDone(int seqIndex) {
 }
 
 void SequenceList::setMotion(int seqIndex, int flags, int deltaX, int deltaY) {
-	warning("TODO: setMotion()");
-	// HACK: Just offset by the delta for now
-	_entries[seqIndex]._position.x += deltaX;
-	_entries[seqIndex]._position.y += deltaY;
+	SequenceEntry &se = _entries[seqIndex];
+	se._flags = flags | 1;
+
+	// Set the direction sign for movement
+	if (deltaX > 0) {
+		se._posSign.x = 1;
+	} else if (deltaX < 0) {
+		se._posSign.x = -1;
+	} else {
+		se._posSign.x = 0;
+	}
+
+	if (deltaY > 0) {
+		se._posSign.y = 1;
+	}
+	else if (deltaY < 0) {
+		se._posSign.y = -1;
+	} else {
+		se._posSign.y = 0;
+	}
+
+	se._posDiff.x = ABS(deltaX);
+	se._posDiff.y = ABS(deltaY);
+	se._posAccum.x = se._posAccum.y = 0;
 }
 
 } // End of namespace
diff --git a/engines/mads/sequence.h b/engines/mads/sequence.h
index 71460ea..ee587ff 100644
--- a/engines/mads/sequence.h
+++ b/engines/mads/sequence.h
@@ -69,12 +69,9 @@ struct SequenceEntry {
 	uint32 _flags;
 
 	Common::Point _position;
-	int _field18;
-	int _field1A;
-	int _field1C;
-	int _field1E;
-	int _field20;
-	int _field22;
+	Common::Point _posDiff;
+	Common::Point _posSign;
+	Common::Point _posAccum;
 	int _triggerCountdown;
 	bool _doneFlag;
 	SequenceSubEntries _entries;


Commit: f7443424981a78280dab9b2e3a0cb47790078f71
    https://github.com/scummvm/scummvm/commit/f7443424981a78280dab9b2e3a0cb47790078f71
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-24T21:19:48-04:00

Commit Message:
MADS: Fix showing wait cursor when scene changes

Changed paths:
    engines/mads/player.cpp



diff --git a/engines/mads/player.cpp b/engines/mads/player.cpp
index a9bc0cd..0777713 100644
--- a/engines/mads/player.cpp
+++ b/engines/mads/player.cpp
@@ -414,7 +414,7 @@ void Player::move() {
 				_walkOffScreen = _walkOffScreenSceneId;
 				_walkAnywhere = true;
 				_walkOffScreenSceneId = 0;
-				_stepEnabled = true;
+				_stepEnabled = false;
 				newFacing = false;
 			}
 


Commit: 4cc0add4a9a96cda367bdf5075af841a8cd2533c
    https://github.com/scummvm/scummvm/commit/4cc0add4a9a96cda367bdf5075af841a8cd2533c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-25T10:35:05-04:00

Commit Message:
MADS: Fix for multiple selection of actions not working

Changed paths:
    engines/mads/action.cpp



diff --git a/engines/mads/action.cpp b/engines/mads/action.cpp
index df9da12..1db143a 100644
--- a/engines/mads/action.cpp
+++ b/engines/mads/action.cpp
@@ -84,7 +84,6 @@ void MADSAction::clear() {
 	_action._objectNameId = -1;
 	_action._indirectObjectId = -1;
 	_textChanged = true;
-	_pickedWord = 0;
 }
 
 void MADSAction::appendVocab(int vocabId, bool capitalize) {


Commit: ce5c2f3e28cf7f7be5d2aa477d9610df04a126eb
    https://github.com/scummvm/scummvm/commit/ce5c2f3e28cf7f7be5d2aa477d9610df04a126eb
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-25T10:58:51-04:00

Commit Message:
MADS: Fix for player disappearing after throwing fish or burger

Changed paths:
    engines/mads/nebular/nebular_scenes1.cpp



diff --git a/engines/mads/nebular/nebular_scenes1.cpp b/engines/mads/nebular/nebular_scenes1.cpp
index 1b875ae..cd3b900 100644
--- a/engines/mads/nebular/nebular_scenes1.cpp
+++ b/engines/mads/nebular/nebular_scenes1.cpp
@@ -2738,7 +2738,7 @@ void Scene109::actions() {
 						_scene->_spriteSlots.fullRefresh();
 						_scene->_sequences.scan();
 						if (_game._player._visible) {
-							_game._player._spritesChanged = true;
+							_game._player._forceRefresh = true;
 							_game._player.update();
 						}
 


Commit: ea19581ae30bed434da8c9426c7b6defd702fc88
    https://github.com/scummvm/scummvm/commit/ea19581ae30bed434da8c9426c7b6defd702fc88
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-25T13:23:05-04:00

Commit Message:
MADS: Standardised on passing depth surfaces as DepthSurface

Changed paths:
    engines/mads/animation.cpp
    engines/mads/animation.h
    engines/mads/msurface.cpp
    engines/mads/msurface.h
    engines/mads/scene.cpp
    engines/mads/scene_data.cpp
    engines/mads/scene_data.h
    engines/mads/sprites.cpp



diff --git a/engines/mads/animation.cpp b/engines/mads/animation.cpp
index 25fa4a8..ac8c996 100644
--- a/engines/mads/animation.cpp
+++ b/engines/mads/animation.cpp
@@ -172,7 +172,7 @@ Animation::~Animation() {
 	}
 }
 
-void Animation::load(UserInterface &interfaceSurface, MSurface &depthSurface,
+void Animation::load(UserInterface &interfaceSurface, DepthSurface &depthSurface,
 		const Common::String &resName, int flags, Common::Array<PaletteCycle> *palCycles,
 		SceneInfo *sceneInfo) {
 	Common::String resourceName = resName;
@@ -366,7 +366,7 @@ bool Animation::drawFrame(SpriteAsset &spriteSet, const Common::Point &pt, int f
 	return 0;
 }
 
-void Animation::loadInterface(UserInterface &interfaceSurface, MSurface &depthSurface,
+void Animation::loadInterface(UserInterface &interfaceSurface, DepthSurface &depthSurface,
 		AAHeader &header, int flags, Common::Array<PaletteCycle> *palCycles, SceneInfo *sceneInfo) {
 	_scene->_depthStyle = 0;
 	if (header._bgType <= ANIMBG_FULL_SIZE) {
diff --git a/engines/mads/animation.h b/engines/mads/animation.h
index 715f6e4..15086d3 100644
--- a/engines/mads/animation.h
+++ b/engines/mads/animation.h
@@ -168,7 +168,7 @@ private:
 	/**
 	 * Load the user interface display for an animation
 	 */
-	void loadInterface(UserInterface &interfaceSurface, MSurface &depthSurface,
+	void loadInterface(UserInterface &interfaceSurface, DepthSurface &depthSurface,
 		AAHeader &header, int flags, Common::Array<PaletteCycle> *palCycles, SceneInfo *sceneInfo);
 
 	/**
@@ -196,7 +196,7 @@ public:
 	/**
 	 * Loads animation data
 	 */
-	void load(UserInterface &interfaceSurface, MSurface &depthSurface, const Common::String &resName,
+	void load(UserInterface &interfaceSurface, DepthSurface &depthSurface, const Common::String &resName,
 		int flags, Common::Array<PaletteCycle> *palCycles, SceneInfo *sceneInfo);
 
 	/**
diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index 3ebbc6b..a7249cd 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -258,7 +258,7 @@ void MSurface::copyFrom(MSurface *src, const Common::Rect &srcBounds,
 }
 
 void MSurface::copyFrom(MSurface *src, const Common::Point &destPos, int depth,
-	MSurface *depthsSurface, int scale, int transparentColor) {
+	DepthSurface *depthsSurface, int scale, int transparentColor) {
 
 	int destX = destPos.x, destY = destPos.y;
 	if (scale == 100) {
diff --git a/engines/mads/msurface.h b/engines/mads/msurface.h
index fbd9270..e3cf89d 100644
--- a/engines/mads/msurface.h
+++ b/engines/mads/msurface.h
@@ -32,6 +32,7 @@ namespace MADS {
 
 class MADSEngine;
 class MSprite;
+class DepthSurface;
 
 /**
  * Basic sprite information
@@ -162,7 +163,7 @@ public:
 	* @param depthSurface	Depth surface to use with sprite depth
 	* @param transparentColor	Transparency palette index
 	*/
-	void copyFrom(MSurface *src, const Common::Point &destPos, int depth, MSurface *depthSurface,
+	void copyFrom(MSurface *src, const Common::Point &destPos, int depth, DepthSurface *depthSurface,
 		int scale, int transparentColor = -1);
 
 	/**
diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 944c082..1391303 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -176,7 +176,7 @@ void Scene::loadScene(int sceneId, const Common::String &prefix, bool palFlag) {
 		flags |= ANIMFLAG_LOAD_BACKGROUND_ONLY;
 
 	_animationData = Animation::init(_vm, this);
-	MSurface depthSurface;
+	DepthSurface depthSurface(_vm);
 	_animationData->load(_userInterface, depthSurface, prefix, flags, nullptr, nullptr);
 
 	_vm->_palette->_paletteUsage.load(&_scenePaletteUsage);
@@ -592,7 +592,7 @@ void Scene::checkKeyboard() {
 
 void Scene::loadAnimation(const Common::String &resName, int trigger) {
 	assert(_activeAnimation == nullptr);
-	MSurface depthSurface;
+	DepthSurface depthSurface(_vm);
 	UserInterface interfaceSurface(_vm);
 
 	_activeAnimation = Animation::init(_vm, this);
diff --git a/engines/mads/scene_data.cpp b/engines/mads/scene_data.cpp
index 256a517..5656ac4 100644
--- a/engines/mads/scene_data.cpp
+++ b/engines/mads/scene_data.cpp
@@ -110,7 +110,7 @@ SceneInfo *SceneInfo::init(MADSEngine *vm) {
 }
 
 void SceneInfo::load(int sceneId, int variant, const Common::String &resName,
-		int flags, MSurface &depthSurface, MSurface &bgSurface) {
+		int flags, DepthSurface &depthSurface, MSurface &bgSurface) {
 	bool sceneFlag = sceneId >= 0;
 
 	// Figure out the resource to use
diff --git a/engines/mads/scene_data.h b/engines/mads/scene_data.h
index db25298..392383a 100644
--- a/engines/mads/scene_data.h
+++ b/engines/mads/scene_data.h
@@ -186,7 +186,7 @@ public:
 	 * loads the data
 	 */
 	void load(int sceneId, int variant, const Common::String &resName, int flags,
-		MSurface &depthSurface, MSurface &bgSurface);
+		DepthSurface &depthSurface, MSurface &bgSurface);
 
 	/**
 	 * Loads the palette for a scene
diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index b0506fc..e4e57bd 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -258,7 +258,7 @@ void SpriteSlots::drawBackground() {
 				if (spriteSlot._depth <= 1) {
 					frame->copyTo(&scene._backgroundSurface, frame->getTransparencyIndex());
 				} else if (scene._depthStyle == 0) {
-					scene._backgroundSurface.copyFrom(frame, pt, spriteSlot._depth, &scene._backgroundSurface,
+					scene._backgroundSurface.copyFrom(frame, pt, spriteSlot._depth, &scene._depthSurface,
 						100, frame->getTransparencyIndex());
 				} else {
 					error("Unsupported depth style");


Commit: 142f2ad208d0dc76d36986c642bbd0f94bde30b9
    https://github.com/scummvm/scummvm/commit/142f2ad208d0dc76d36986c642bbd0f94bde30b9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-25T14:17:38-04:00

Commit Message:
MADS: Change sprite drawing to use DepthSurface getDepth method

Changed paths:
    engines/mads/msurface.cpp



diff --git a/engines/mads/msurface.cpp b/engines/mads/msurface.cpp
index a7249cd..6d74fef 100644
--- a/engines/mads/msurface.cpp
+++ b/engines/mads/msurface.cpp
@@ -258,7 +258,7 @@ void MSurface::copyFrom(MSurface *src, const Common::Rect &srcBounds,
 }
 
 void MSurface::copyFrom(MSurface *src, const Common::Point &destPos, int depth,
-	DepthSurface *depthsSurface, int scale, int transparentColor) {
+	DepthSurface *depthSurface, int scale, int transparentColor) {
 
 	int destX = destPos.x, destY = destPos.y;
 	if (scale == 100) {
@@ -285,20 +285,19 @@ void MSurface::copyFrom(MSurface *src, const Common::Point &destPos, int depth,
 
 		byte *data = src->getData();
 		byte *srcPtr = data + (src->getWidth() * copyRect.top + copyRect.left);
-		byte *depthsData = depthsSurface->getData();
-		byte *depthsPtr = depthsData + (depthsSurface->pitch * destY) + destX;
 		byte *destPtr = (byte *)pixels + (destY * pitch) + destX;
 
 		// 100% scaling variation
 		for (int rowCtr = 0; rowCtr < copyRect.height(); ++rowCtr) {
 			// Copy each byte one at a time checking against the depth
 			for (int xCtr = 0; xCtr < copyRect.width(); ++xCtr) {
-				if ((depth <= (depthsPtr[xCtr] & 0x7f)) && (srcPtr[xCtr] != transparentColor))
+				int pixelDepth = depthSurface == nullptr ? 15 :
+					depthSurface->getDepth(Common::Point(destX + xCtr, destY + rowCtr));
+				if ((depth <= pixelDepth) && (srcPtr[xCtr] != transparentColor))
 					destPtr[xCtr] = srcPtr[xCtr];
 			}
 
 			srcPtr += src->getWidth();
-			depthsPtr += depthsSurface->getWidth();
 			destPtr += getWidth();
 		}
 
@@ -379,7 +378,6 @@ void MSurface::copyFrom(MSurface *src, const Common::Point &destPos, int depth,
 		return;
 
 	byte *destPixelsP = this->getBasePtr(destX + spriteLeft, destY + spriteTop);
-	const byte *depthPixelsP = depthsSurface->getBasePtr(destX + spriteLeft, destY + spriteTop);
 
 	spriteLeft = (spriteLeft * (normalFrame ? 1 : -1));
 
@@ -395,8 +393,8 @@ void MSurface::copyFrom(MSurface *src, const Common::Point &destPos, int depth,
 
 		// Found a line to display. Loop through the pixels
 		const byte *srcP = srcPixelsP;
-		const byte *depthP = depthPixelsP;
 		byte *destP = destPixelsP;
+
 		for (int xp = 0, sprX = 0; xp < frameWidth; ++xp, ++srcP) {
 			if (xp < spriteLeft)
 				// Not yet reached start of display area
@@ -405,16 +403,19 @@ void MSurface::copyFrom(MSurface *src, const Common::Point &destPos, int depth,
 				// Not a display pixel
 				continue;
 
-			if ((*srcP != transparentColor) && (depth <= (*depthP & 0x7f)))
+			// Get depth of current output pixel in depth surface
+			Common::Point pt((destP - (byte *)this->pixels) % this->pitch,
+				(destP - (byte *)this->pixels) / this->pitch);
+			int pixelDepth = (depthSurface == nullptr) ? 15 : depthSurface->getDepth(pt);
+	
+			if ((*srcP != transparentColor) && (depth <= pixelDepth))
 				*destP = *srcP;
 
 			++destP;
-			++depthP;
 		}
 
 		// Move to the next destination line
 		destPixelsP += this->pitch;
-		depthPixelsP += depthsSurface->pitch;
 	}
 }
 


Commit: 6f046eafded01e00beddc7533989a06c50b05624
    https://github.com/scummvm/scummvm/commit/6f046eafded01e00beddc7533989a06c50b05624
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-25T14:39:15-04:00

Commit Message:
MADS: Fix for assert when a scene uses more than one animation

Changed paths:
    engines/mads/scene.cpp



diff --git a/engines/mads/scene.cpp b/engines/mads/scene.cpp
index 1391303..4af956a 100644
--- a/engines/mads/scene.cpp
+++ b/engines/mads/scene.cpp
@@ -591,7 +591,11 @@ void Scene::checkKeyboard() {
 }
 
 void Scene::loadAnimation(const Common::String &resName, int trigger) {
-	assert(_activeAnimation == nullptr);
+	// WORKAROUND: If there's already a previous active animation used by the
+	// scene, then free it before we create the new one
+	if (_activeAnimation)
+		freeAnimation();
+	
 	DepthSurface depthSurface(_vm);
 	UserInterface interfaceSurface(_vm);
 


Commit: a01d502d2015b916b61a99ac0dcc0fcf1a289b78
    https://github.com/scummvm/scummvm/commit/a01d502d2015b916b61a99ac0dcc0fcf1a289b78
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-25T17:42:19-04:00

Commit Message:
MADS: Fix drawing of background elements

Changed paths:
    engines/mads/sprites.cpp



diff --git a/engines/mads/sprites.cpp b/engines/mads/sprites.cpp
index e4e57bd..c98a096 100644
--- a/engines/mads/sprites.cpp
+++ b/engines/mads/sprites.cpp
@@ -256,7 +256,7 @@ void SpriteSlots::drawBackground() {
 
 
 				if (spriteSlot._depth <= 1) {
-					frame->copyTo(&scene._backgroundSurface, frame->getTransparencyIndex());
+					frame->copyTo(&scene._backgroundSurface, pt, frame->getTransparencyIndex());
 				} else if (scene._depthStyle == 0) {
 					scene._backgroundSurface.copyFrom(frame, pt, spriteSlot._depth, &scene._depthSurface,
 						100, frame->getTransparencyIndex());


Commit: 49866d442fdd816a89a5c1bd4ddb1e68013c8d9e
    https://github.com/scummvm/scummvm/commit/49866d442fdd816a89a5c1bd4ddb1e68013c8d9e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-25T18:32:54-04:00

Commit Message:
MADS: Properly implement cursor hotspot handling

Changed paths:
    engines/mads/events.cpp



diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 5d6a16f..870a902 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -90,9 +90,38 @@ void EventsManager::waitCursor() {
 void EventsManager::changeCursor() {
 	if (_cursorSprites) {
 		MSprite *cursor = _cursorSprites->getFrame(_cursorId - 1);
-		CursorMan.replaceCursor(cursor->getData(), cursor->w, cursor->h, 0, 0,
-			cursor->getTransparencyIndex());
+		assert(cursor->w == cursor->h);
+		byte transIndex = cursor->getTransparencyIndex();
+
+		// Check for hotspot indication pixels along the right-hand and bottom
+		// row. Put together, these give the cursor's hotspot x,y
+		int hotspotX = 0, hotspotY = 0;
+		byte *cursorData = cursor->getData();
+		for (int idx = 0; idx < cursor->w; ++idx) {
+			if (cursorData[(cursor->h - 1) * cursor->w + idx] != transIndex)
+				hotspotX = idx;
+
+			if (cursorData[(cursor->h + 1) * cursor->w - 1] != transIndex)
+				hotspotY = idx;
+		}
+
+		// Reduce the cursor data to remove the last column from each row, since
+		// the cursor routines don't have a pitch option
+		byte *destCursor = new byte[(cursor->w - 1) * (cursor->h - 1)];
+		byte *srcP = cursorData;
+		byte *destP = destCursor;
+
+		for (int idx = 0; idx < (cursor->h - 1); ++idx) {
+			Common::copy(srcP, srcP + cursor->w - 1, destP);
+			srcP += cursor->w;
+			destP += cursor->w - 1;
+		}
+
+		// Set the raw cursor data to use
+		CursorMan.replaceCursor(destCursor, cursor->w - 1, cursor->h - 1, 
+			hotspotX, hotspotY, transIndex);
 		showCursor();
+		delete[] destCursor;
 	}
 }
 


Commit: feb02eaea93a3bbbc4b2c651285c99a184cbc086
    https://github.com/scummvm/scummvm/commit/feb02eaea93a3bbbc4b2c651285c99a184cbc086
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-25T20:15:10-04:00

Commit Message:
MADS: Further fix for setting cursor hotspot position

Changed paths:
    engines/mads/events.cpp



diff --git a/engines/mads/events.cpp b/engines/mads/events.cpp
index 870a902..3f2a739 100644
--- a/engines/mads/events.cpp
+++ b/engines/mads/events.cpp
@@ -101,7 +101,7 @@ void EventsManager::changeCursor() {
 			if (cursorData[(cursor->h - 1) * cursor->w + idx] != transIndex)
 				hotspotX = idx;
 
-			if (cursorData[(cursor->h + 1) * cursor->w - 1] != transIndex)
+			if (cursorData[(idx + 1) * cursor->w - 1] != transIndex)
 				hotspotY = idx;
 		}
 


Commit: c5ced2347c07e1e4f1d2b2c1a3da1c4d4463773f
    https://github.com/scummvm/scummvm/commit/c5ced2347c07e1e4f1d2b2c1a3da1c4d4463773f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2014-05-25T22:31:37-04:00

Commit Message:
MADS: Improve user interface animations

Changed paths:
    engines/mads/user_interface.cpp



diff --git a/engines/mads/user_interface.cpp b/engines/mads/user_interface.cpp
index 68f5784..e21a0f6 100644
--- a/engines/mads/user_interface.cpp
+++ b/engines/mads/user_interface.cpp
@@ -104,7 +104,7 @@ void UISlots::draw(bool updateFlag, bool delFlag) {
 		UISlot &slot = (*this)[idx];
 
 		if (dirtyArea._active && dirtyArea._bounds.width() > 0
-				&& dirtyArea._bounds.height() > 0 && slot._flags >= -20) {
+				&& dirtyArea._bounds.height() > 0 && slot._flags > -20) {
 
 			if (slot._flags >= IMG_ERASE) {
 				// Merge area
@@ -449,7 +449,8 @@ void UserInterface::mergeFrom(MSurface *src, const Common::Rect &srcBounds,
 	for (int rowCtr = 0; rowCtr < copyRect.height(); ++rowCtr) {
 		// Process each line of the area
 		for (int xCtr = 0; xCtr < copyRect.width(); ++xCtr) {
-			// Check for the range used for on-screen text, which should be kept intact
+			// Check for the range used for the user interface background, 
+			// which are the only pixels that can be replaced
 			if ((destPtr[xCtr] >= 8 && destPtr[xCtr] <= 15) && (int)srcPtr[xCtr] != transparencyIndex)
 				destPtr[xCtr] = srcPtr[xCtr];
 		}
@@ -884,7 +885,7 @@ void UserInterface::inventoryAnim() {
 	// Loop through the slots list for inventory animation entry
 	for (uint i = 0; i < _uiSlots.size(); ++i) {
 		if (_uiSlots[i]._segmentId == IMG_SPINNING_OBJECT)
-			_uiSlots[i]._flags = IMG_UPDATE_ONLY;
+			_uiSlots[i]._flags = IMG_FULL_UPDATE;
 	}
 
 	// Add a new slot entry for the inventory animation


Commit: dfe6ae9d593a17acfe5bd9bb68d44ce497eeea20
    https://github.com/scummvm/scummvm/commit/dfe6ae9d593a17acfe5bd9bb68d44ce497eeea20
Author: Strangerke (strangerke at scummvm.org)
Date: 2014-05-26T07:20:59+02:00

Commit Message:
MADS: Fix a bug in scene 701 logic, rework some timer calls

Changed paths:
    engines/mads/nebular/nebular_scenes7.cpp



diff --git a/engines/mads/nebular/nebular_scenes7.cpp b/engines/mads/nebular/nebular_scenes7.cpp
index 9383492..08b85bf 100644
--- a/engines/mads/nebular/nebular_scenes7.cpp
+++ b/engines/mads/nebular/nebular_scenes7.cpp
@@ -191,11 +191,11 @@ void Scene701::enter() {
 		_game._player._stepEnabled = false;
 		_scene->loadAnimation(formAnimName('B', 1), 80);
 		_vm->_sound->command(28);
-	} else if (_scene->_priorSceneId != -2 && _scene->_priorSceneId != -620) {
+	} else if (_scene->_priorSceneId != -2 && _scene->_priorSceneId != 620) {
 		_game._player._playerPos = Common::Point(22, 131);
 		_game._player._facing = FACING_EAST;
 		_game._player._stepEnabled = false;
-		_scene->_sequences.addTimer(1 * 60, 70);
+		_scene->_sequences.addTimer(60, 70);
 	}
 
 	_game.loadQuoteSet(0x310, 0x30F, 0);
@@ -228,7 +228,7 @@ void Scene701::step() {
 
 	case 71:
 		_game._player.walk(Common::Point(61, 131), FACING_EAST);
-		_scene->_sequences.addTimer(2 * 60, 72);
+		_scene->_sequences.addTimer(120, 72);
 		break;
 
 	case 72:
@@ -321,7 +321,7 @@ void Scene701::actions() {
 
 		case 1:
 			_game._player.walk(Common::Point(22, 131), FACING_EAST);
-			_scene->_sequences.addTimer(2 * 60, 3);
+			_scene->_sequences.addTimer(120, 3);
 			break;
 
 		case 3:


Commit: ef22b7d449b66a7b953e0584c6ab5db9bdd948b9
    https://github.com/scummvm/scummvm/commit/ef22b7d449b66a7b953e0584c6ab5db9bdd948b9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2014-05-26T15:37:26+03:00

Commit Message:
Merge pull request #464 from dreammaster/mads

MADS: Merge of Rex Nebular game engine

Changed paths:
  A engines/mads/action.cpp
  A engines/mads/action.h
  A engines/mads/animation.cpp
  A engines/mads/animation.h
  A engines/mads/assets.cpp
  A engines/mads/assets.h
  A engines/mads/audio.cpp
  A engines/mads/audio.h
  A engines/mads/compression.cpp
  A engines/mads/compression.h
  A engines/mads/configure.engine
  A engines/mads/debugger.cpp
  A engines/mads/debugger.h
  A engines/mads/detection.cpp
  A engines/mads/detection_tables.h
  A engines/mads/dialogs.cpp
  A engines/mads/dialogs.h
  A engines/mads/dragonsphere/dragonsphere_scenes.cpp
  A engines/mads/dragonsphere/dragonsphere_scenes.h
  A engines/mads/dragonsphere/game_dragonsphere.cpp
  A engines/mads/dragonsphere/game_dragonsphere.h
  A engines/mads/events.cpp
  A engines/mads/events.h
  A engines/mads/font.cpp
  A engines/mads/font.h
  A engines/mads/game.cpp
  A engines/mads/game.h
  A engines/mads/game_data.cpp
  A engines/mads/game_data.h
  A engines/mads/globals.cpp
  A engines/mads/globals.h
  A engines/mads/hotspots.cpp
  A engines/mads/hotspots.h
  A engines/mads/inventory.cpp
  A engines/mads/inventory.h
  A engines/mads/mads.cpp
  A engines/mads/mads.h
  A engines/mads/messages.cpp
  A engines/mads/messages.h
  A engines/mads/module.mk
  A engines/mads/msurface.cpp
  A engines/mads/msurface.h
  A engines/mads/nebular/dialogs_nebular.cpp
  A engines/mads/nebular/dialogs_nebular.h
  A engines/mads/nebular/game_nebular.cpp
  A engines/mads/nebular/game_nebular.h
  A engines/mads/nebular/globals_nebular.cpp
  A engines/mads/nebular/globals_nebular.h
  A engines/mads/nebular/nebular_scenes.cpp
  A engines/mads/nebular/nebular_scenes.h
  A engines/mads/nebular/nebular_scenes1.cpp
  A engines/mads/nebular/nebular_scenes1.h
  A engines/mads/nebular/nebular_scenes2.cpp
  A engines/mads/nebular/nebular_scenes2.h
  A engines/mads/nebular/nebular_scenes3.cpp
  A engines/mads/nebular/nebular_scenes3.h
  A engines/mads/nebular/nebular_scenes4.cpp
  A engines/mads/nebular/nebular_scenes4.h
  A engines/mads/nebular/nebular_scenes5.cpp
  A engines/mads/nebular/nebular_scenes5.h
  A engines/mads/nebular/nebular_scenes6.cpp
  A engines/mads/nebular/nebular_scenes6.h
  A engines/mads/nebular/nebular_scenes7.cpp
  A engines/mads/nebular/nebular_scenes7.h
  A engines/mads/nebular/nebular_scenes8.cpp
  A engines/mads/nebular/nebular_scenes8.h
  A engines/mads/nebular/sound_nebular.cpp
  A engines/mads/nebular/sound_nebular.h
  A engines/mads/palette.cpp
  A engines/mads/palette.h
  A engines/mads/phantom/game_phantom.cpp
  A engines/mads/phantom/game_phantom.h
  A engines/mads/phantom/phantom_scenes.cpp
  A engines/mads/phantom/phantom_scenes.h
  A engines/mads/player.cpp
  A engines/mads/player.h
  A engines/mads/rails.cpp
  A engines/mads/rails.h
  A engines/mads/resources.cpp
  A engines/mads/resources.h
  A engines/mads/scene.cpp
  A engines/mads/scene.h
  A engines/mads/scene_data.cpp
  A engines/mads/scene_data.h
  A engines/mads/screen.cpp
  A engines/mads/screen.h
  A engines/mads/sequence.cpp
  A engines/mads/sequence.h
  A engines/mads/sound.cpp
  A engines/mads/sound.h
  A engines/mads/sprites.cpp
  A engines/mads/sprites.h
  A engines/mads/staticres.cpp
  A engines/mads/staticres.h
  A engines/mads/user_interface.cpp
  A engines/mads/user_interface.h









More information about the Scummvm-git-logs mailing list